diff options
author | Michael E Brown <michael_e_brown@dell.com> | 2008-01-20 15:09:14 -0600 |
---|---|---|
committer | Michael E Brown <michael_e_brown@dell.com> | 2008-01-20 15:09:14 -0600 |
commit | 78d6a209b8dfe438880e4d62a58693e33693560b (patch) | |
tree | 27b4fa77cc3f6bab283dc87c1fde134ae45ae616 | |
parent | 7d45de8aa01207413b615874ba58d0239f00a92e (diff) | |
download | mock-78d6a209b8dfe438880e4d62a58693e33693560b.tar.gz mock-78d6a209b8dfe438880e4d62a58693e33693560b.tar.xz mock-78d6a209b8dfe438880e4d62a58693e33693560b.zip |
get rid of one level of shell indirection where possible.
-rw-r--r-- | py/mock/backend.py | 23 | ||||
-rw-r--r-- | py/mock/plugins/ccache.py | 2 |
2 files changed, 15 insertions, 10 deletions
diff --git a/py/mock/backend.py b/py/mock/backend.py index ec61ac4..43affce 100644 --- a/py/mock/backend.py +++ b/py/mock/backend.py @@ -379,7 +379,8 @@ class Root(object): os.environ["HOME"] = self.homedir # Completely/Permanently drop privs while running the following: self.doChroot( - "rpm -Uvh --nodeps %s" % (srpmChrootFilename,), + ["rpm", "-Uvh", "--nodeps", srpmChrootFilename], + shell=False, uid=self.chrootuid, gid=self.chrootgid, ) @@ -393,7 +394,8 @@ class Root(object): chrootspec = spec.replace(self.makeChrootPath(), '') # get rid of rootdir prefix # Completely/Permanently drop privs while running the following: self.doChroot( - "bash --login -c 'rpmbuild -bs --target %s --nodeps %s'" % (self.rpmbuild_arch, chrootspec), + ["bash", "--login", "-c", 'rpmbuild -bs --target %s --nodeps %s' % (self.rpmbuild_arch, chrootspec)], + shell=False, logger=self.build_log, timeout=timeout, uid=self.chrootuid, gid=self.chrootgid, @@ -413,7 +415,8 @@ class Root(object): self._callHooks('prebuild') self.doChroot( - "bash --login -c 'rpmbuild -bb --target %s --nodeps %s'" % (self.rpmbuild_arch, chrootspec), + ["bash", "--login", "-c", 'rpmbuild -bb --target %s --nodeps %s' % (self.rpmbuild_arch, chrootspec)], + shell=False, logger=self.build_log, timeout=timeout, uid=self.chrootuid, gid=self.chrootgid, @@ -501,14 +504,16 @@ class Root(object): # safe and easy. blow away existing /builddir and completely re-create. mock.util.rmtree(self.makeChrootPath(self.homedir)) - dets = { 'uid': self.chrootuid, 'gid': self.chrootgid, 'user': self.chrootuser, 'group': self.chrootgroup, 'home': self.homedir } + dets = { 'uid': str(self.chrootuid), 'gid': str(self.chrootgid), 'user': self.chrootuser, 'group': self.chrootgroup, 'home': self.homedir } - self.doChroot('/usr/sbin/userdel -r %(user)s' % dets, raiseExc=False) - self.doChroot('/usr/sbin/groupdel %(group)s' % dets, raiseExc=False) + self.doChroot(['/usr/sbin/userdel', '-r', dets['user']], shell=False, raiseExc=False) + self.doChroot(['/usr/sbin/groupdel', dets['group']], shell=False, raiseExc=False) - self.doChroot('/usr/sbin/groupadd -g %(gid)s %(group)s' % dets) - self.doChroot(self.useradd % dets) - self.doChroot("perl -p -i -e 's/^(%s:)!!/$1/;' /etc/passwd" % (self.chrootuser), raiseExc=True) + self.doChroot(['/usr/sbin/groupadd', '-g', dets['gid'], dets['group']], shell=False) + self.doChroot(self.useradd % dets, shell=True) + self.doChroot( + ["perl", "-p", "-i", "-e", 's/^(%s:)!!/$1/;' % self.chrootuser, "/etc/passwd"], + shell=False, raiseExc=True) decorate(traceLog()) def _resetLogging(self): diff --git a/py/mock/plugins/ccache.py b/py/mock/plugins/ccache.py index 77a9130..52e55fd 100644 --- a/py/mock/plugins/ccache.py +++ b/py/mock/plugins/ccache.py @@ -39,7 +39,7 @@ class CCache(object): # ccache itself manages size and settings. decorate(traceLog()) def _ccacheBuildHook(self): - self.rootObj.doChroot("ccache -M %s" % self.ccache_opts['max_cache_size']) + self.rootObj.doChroot(["ccache", "-M", str(self.ccache_opts['max_cache_size'])], shell=False) # basic idea here is that we add 'cc', 'gcc', 'g++' shell scripts to # to /tmp/ccache, which is bind-mounted from a shared location. |