Skip to content

Commit d2205b9

Browse files
internal/scaffold: don't change /etc/passwd perms (#2469) (#2538)
* internal/scaffold: don't change /etc/passwd perms Co-authored-by: Joe Lanford <[email protected]>
1 parent d2d47d4 commit d2205b9

File tree

9 files changed

+5
-48
lines changed

9 files changed

+5
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Added
44

55
### Changed
6+
- Operator user setup and entrypoint scripts no longer insert dynamic runtime user entries into `/etc/passwd`. To use dynamic runtime users, use a container runtime that supports it (e.g. CRI-O). ([#2469](https://github.com/operator-framework/operator-sdk/pull/2469))
67

78
### Deprecated
89

internal/scaffold/ansible/entrypoint.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,5 @@ func (e *Entrypoint) GetInput() (input.Input, error) {
3636

3737
const entrypointTmpl = `#!/bin/bash -e
3838
39-
# This is documented here:
40-
# https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines
41-
42-
if ! whoami &>/dev/null; then
43-
if [ -w /etc/passwd ]; then
44-
echo "${USER_NAME:-runner}:x:$(id -u):$(id -g):${USER_NAME:-runner} user:${HOME}:/sbin/nologin" >> /etc/passwd
45-
fi
46-
fi
47-
4839
exec ${OPERATOR} exec-entrypoint ansible --watches-file=/opt/ansible/watches.yaml $@
4940
`

internal/scaffold/ansible/usersetup.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ const userSetupTmpl = `#!/bin/sh
3838
set -x
3939
4040
# ensure $HOME exists and is accessible by group 0 (we don't know what the runtime UID will be)
41+
echo "${USER_NAME}:x:${USER_UID}:0:${USER_NAME} user:${HOME}:/sbin/nologin" >> /etc/passwd
4142
mkdir -p ${HOME}/.ansible/tmp
4243
chown -R ${USER_UID}:0 ${HOME}
4344
chmod -R ug+rwx ${HOME}
4445
45-
# runtime user will need to be able to self-insert in /etc/passwd
46-
chmod g+rw /etc/passwd
47-
4846
# no need for this script to remain in the image after running
4947
rm $0
5048
`

internal/scaffold/entrypoint.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,5 @@ func (e *Entrypoint) GetInput() (input.Input, error) {
3838

3939
const entrypointTmpl = `#!/bin/sh -e
4040
41-
# This is documented here:
42-
# https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines
43-
44-
if ! whoami &>/dev/null; then
45-
if [ -w /etc/passwd ]; then
46-
echo "${USER_NAME:-{{.ProjectName}}}:x:$(id -u):$(id -g):${USER_NAME:-{{.ProjectName}}} user:${HOME}:/sbin/nologin" >> /etc/passwd
47-
fi
48-
fi
49-
5041
exec ${OPERATOR} $@
5142
`

internal/scaffold/entrypoint_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ func EntrypointTest(t *testing.T) {
3535

3636
const entrypointExp = `#!/bin/sh -e
3737
38-
# This is documented here:
39-
# https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines
40-
41-
if ! whoami &>/dev/null; then
42-
if [ -w /etc/passwd ]; then
43-
echo "${USER_NAME:-app-operator}:x:$(id -u):$(id -g):${USER_NAME:-app-operator} user:${HOME}:/sbin/nologin" >> /etc/passwd
44-
fi
45-
fi
46-
4738
exec ${OPERATOR} $@
4839
4940
`

internal/scaffold/helm/entrypoint.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ func (e *Entrypoint) GetInput() (input.Input, error) {
3636

3737
const entrypointTmpl = `#!/bin/sh -e
3838
39-
# This is documented here:
40-
# https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines
41-
42-
if ! whoami &>/dev/null; then
43-
if [ -w /etc/passwd ]; then
44-
echo "${USER_NAME:-helm}:x:$(id -u):$(id -g):${USER_NAME:-helm} user:${HOME}:/sbin/nologin" >> /etc/passwd
45-
fi
46-
fi
47-
4839
cd $HOME
4940
exec ${OPERATOR} exec-entrypoint helm --watches-file=$HOME/watches.yaml $@
5041
`

internal/scaffold/helm/usersetup.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ const userSetupTmpl = `#!/bin/sh
3838
set -x
3939
4040
# ensure $HOME exists and is accessible by group 0 (we don't know what the runtime UID will be)
41+
echo "${USER_NAME}:x:${USER_UID}:0:${USER_NAME} user:${HOME}:/sbin/nologin" >> /etc/passwd
4142
mkdir -p ${HOME}
4243
chown ${USER_UID}:0 ${HOME}
4344
chmod ug+rwx ${HOME}
4445
45-
# runtime user will need to be able to self-insert in /etc/passwd
46-
chmod g+rw /etc/passwd
47-
4846
# no need for this script to remain in the image after running
4947
rm $0
5048
`

internal/scaffold/usersetup.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ const userSetupTmpl = `#!/bin/sh
4040
set -x
4141
4242
# ensure $HOME exists and is accessible by group 0 (we don't know what the runtime UID will be)
43+
echo "${USER_NAME}:x:${USER_UID}:0:${USER_NAME} user:${HOME}:/sbin/nologin" >> /etc/passwd
4344
mkdir -p ${HOME}
4445
chown ${USER_UID}:0 ${HOME}
4546
chmod ug+rwx ${HOME}
4647
47-
# runtime user will need to be able to self-insert in /etc/passwd
48-
chmod g+rw /etc/passwd
49-
5048
# no need for this script to remain in the image after running
5149
rm $0
5250
`

internal/scaffold/usersetup_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,11 @@ const userSetupExp = `#!/bin/sh
3737
set -x
3838
3939
# ensure $HOME exists and is accessible by group 0 (we don't know what the runtime UID will be)
40+
echo "${USER_NAME}:x:${USER_UID}:0:${USER_NAME} user:${HOME}:/sbin/nologin" >> /etc/passwd
4041
mkdir -p ${HOME}
4142
chown ${USER_UID}:0 ${HOME}
4243
chmod ug+rwx ${HOME}
4344
44-
# runtime user will need to be able to self-insert in /etc/passwd
45-
chmod g+rw /etc/passwd
46-
4745
# no need for this script to remain in the image after running
4846
rm $0
4947
`

0 commit comments

Comments
 (0)