diff options
author | Michael E Brown <mebrown@michaels-house.net> | 2007-10-22 13:16:47 -0500 |
---|---|---|
committer | Michael E Brown <mebrown@michaels-house.net> | 2007-10-22 13:16:47 -0500 |
commit | 725e0550748ea414952e78145fa867678aabc44c (patch) | |
tree | 263f17e295172f9916953b664d2c2cdfc6493bf6 /src | |
parent | 42fb1cd0c6c16e48c4673b18e865e9a10de70541 (diff) | |
download | mock-725e0550748ea414952e78145fa867678aabc44c.tar.gz mock-725e0550748ea414952e78145fa867678aabc44c.tar.xz mock-725e0550748ea414952e78145fa867678aabc44c.zip |
remove becomeUser(0) from backend and have mock.py do it ahead of time. remove password from mockbuild user so you can 'mock shell' and then su - mockbuild.
Diffstat (limited to 'src')
-rwxr-xr-x | src/mock.py | 9 | ||||
-rw-r--r-- | src/py-libs/backend.py | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/mock.py b/src/mock.py index 04b9d8a..5c9ae4d 100755 --- a/src/mock.py +++ b/src/mock.py @@ -56,9 +56,9 @@ def command_parse(config_opts): usage = """ usage: + mock [options] {init|clean} mock [options] [rebuild] /path/to/srpm(s) mock [options] {shell|chroot} <cmd> - mock [options] {init|clean} mock [options] installdeps {SRPM|RPM} mock [options] install PACKAGE commands: @@ -265,7 +265,12 @@ def main(retParams): # do whatever we're here to do # uidManager saves current real uid/gid which are unpriviledged (callers) # due to suid helper, our current effective uid is 0 - chroot = mock.backend.Root(config_opts, mock.uid.uidManager(os.getuid(), os.getgid())) + uidManager = mock.uid.uidManager(os.getuid(), os.getgid()) + chroot = mock.backend.Root(config_opts, uidManager) + + # elevate privs + uidManager.becomeUser(0) + retParams["chroot"] = chroot retParams["config_opts"] = config_opts os.umask(002) diff --git a/src/py-libs/backend.py b/src/py-libs/backend.py index 192104c..b0e7f1a 100644 --- a/src/py-libs/backend.py +++ b/src/py-libs/backend.py @@ -139,9 +139,6 @@ class Root(object): # --> /etc/ is no longer 02775 (new privs model) # --> no /etc/yum.conf symlink (F7 and above) - self.root_log.debug("elevating privs") - self.uidManager.becomeUser(0) - # create our base directory heirarchy mock.util.mkdirIfAbsent(self.cachedir) mock.util.mkdirIfAbsent(self.basedir) @@ -447,6 +444,7 @@ class Root(object): self.doChroot('/usr/sbin/userdel -r %s' % self.chrootuser, raiseExc=False) self.doChroot('/usr/sbin/groupdel %s' % self.chrootgroup, raiseExc=False) self.doChroot('/usr/sbin/useradd -m -u %s -d %s %s' % (self.chrootuid, self.homedir, self.chrootuser), raiseExc=True) + self.doChroot("perl -p -i -e 's/^(%s:)!!/$1/;' /etc/passwd" % (self.chrootuser), raiseExc=True) @traceLog(moduleLog) def _resetLogging(self): |