diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-09-23 21:15:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-23 21:15:26 +0200 |
commit | f5951c7305306967a89de09d957ccd5699ec3f85 (patch) | |
tree | 2a68b480d48c7e230a81db1053e8c1a6f4128513 /pkg | |
parent | a74dfdadd7cc02959c2a142658bedabdc4a607a3 (diff) | |
parent | 497678d9e348d10027b0b71de41a6aea11e5aba2 (diff) | |
download | podman-f5951c7305306967a89de09d957ccd5699ec3f85.tar.gz podman-f5951c7305306967a89de09d957ccd5699ec3f85.tar.bz2 podman-f5951c7305306967a89de09d957ccd5699ec3f85.zip |
Merge pull request #4074 from giuseppe/override-etc-passwd-group
execuser: look at the source for /etc/{passwd,group} overrides
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/lookup/lookup.go | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/pkg/lookup/lookup.go b/pkg/lookup/lookup.go index 70b97144f..a249dd753 100644 --- a/pkg/lookup/lookup.go +++ b/pkg/lookup/lookup.go @@ -29,17 +29,30 @@ func GetUserGroupInfo(containerMount, containerUser string, override *Overrides) defaultExecUser *user.ExecUser err error ) - passwdPath := etcpasswd - groupPath := etcgroup if override != nil { // Check for an override /etc/passwd path if override.ContainerEtcPasswdPath != "" { - passwdPath = override.ContainerEtcPasswdPath + passwdDest = override.ContainerEtcPasswdPath } // Check for an override for /etc/group path if override.ContainerEtcGroupPath != "" { - groupPath = override.ContainerEtcGroupPath + groupDest = override.ContainerEtcGroupPath + } + } + + if passwdDest == "" { + // Make sure the /etc/passwd destination is not a symlink to something naughty + if passwdDest, err = securejoin.SecureJoin(containerMount, etcpasswd); err != nil { + logrus.Debug(err) + return nil, err + } + } + if groupDest == "" { + // Make sure the /etc/group destination is not a symlink to something naughty + if groupDest, err = securejoin.SecureJoin(containerMount, etcgroup); err != nil { + logrus.Debug(err) + return nil, err } } @@ -56,15 +69,6 @@ func GetUserGroupInfo(containerMount, containerUser string, override *Overrides) } - // Make sure the /etc/group and /etc/passwd destinations are not a symlink to something naughty - if passwdDest, err = securejoin.SecureJoin(containerMount, passwdPath); err != nil { - logrus.Debug(err) - return nil, err - } - if groupDest, err = securejoin.SecureJoin(containerMount, groupPath); err != nil { - logrus.Debug(err) - return nil, err - } return user.GetExecUserPath(containerUser, defaultExecUser, passwdDest, groupDest) } |