summaryrefslogtreecommitdiffstats
path: root/py
diff options
context:
space:
mode:
authorMike Bonnet <mikeb@redhat.com>2008-01-24 16:07:51 -0500
committerMichael E Brown <mebrown@michaels-house.net>2008-01-24 18:45:49 -0600
commit0fd7dd4e63e09671bb816510b3fde1555814e085 (patch)
tree00e056673ab140f75458583e0bfbcfe78c3dec69 /py
parentbbc2b4dd0c6b7331ae789caabecbc5e154f96e52 (diff)
downloadmock-0fd7dd4e63e09671bb816510b3fde1555814e085.tar.gz
mock-0fd7dd4e63e09671bb816510b3fde1555814e085.tar.xz
mock-0fd7dd4e63e09671bb816510b3fde1555814e085.zip
add --unpriv option to drop privileges when running a command with --chroot
On Thu, 2008-01-24 at 16:04 -0500, Mike Bonnet wrote: > On Thu, 2008-01-24 at 15:42 -0500, Mike Bonnet wrote: > > This patch adds a --unpriv option that will cause privileges to be > > dropped before running a command with --chroot. This can be used to > > more closely simulate the environment used when running rpmbuilds. > > Let me try that again... Ok, the attachments are getting stripped off for some reason, trying inline... >From 85e14d38aec32cf20d7f2bbdc77044d41c32a0a2 Mon Sep 17 00:00:00 2001 From: Mike Bonnet <mikeb@redhat.com> Date: Thu, 24 Jan 2008 15:37:15 -0500 Subject: [PATCH] optionally drop privileges when running a command with --chroot Signed-off-by: Michael E Brown <mebrown@michaels-house.net>
Diffstat (limited to 'py')
-rwxr-xr-xpy/mock.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/py/mock.py b/py/mock.py
index 4a589bc..f422a33 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -150,6 +150,8 @@ def command_parse(config_opts):
dest="rpmbuild_timeout", type="int", default=None,
help="Fail build if rpmbuild takes longer than 'timeout'"
" seconds ")
+ parser.add_option("--unpriv", action="store_true", default=False,
+ help="Drop privileges before running command when using --chroot")
# verbosity
parser.add_option("-v", "--verbose", action="store_const", const=2,
@@ -532,7 +534,11 @@ def main(ret):
chroot._resetLogging()
try:
chroot._mountall()
- chroot.doChroot(args, shell=shell)
+ if options.unpriv:
+ chroot.doChroot(args, shell=shell,
+ uid=chroot.chrootuid, gid=chroot.chrootgid)
+ else:
+ chroot.doChroot(args, shell=shell)
finally:
chroot._umountall()