diff options
author | Mike Bonnet <mikeb@redhat.com> | 2008-01-24 16:07:51 -0500 |
---|---|---|
committer | Michael E Brown <mebrown@michaels-house.net> | 2008-01-24 18:45:49 -0600 |
commit | 0fd7dd4e63e09671bb816510b3fde1555814e085 (patch) | |
tree | 00e056673ab140f75458583e0bfbcfe78c3dec69 /py | |
parent | bbc2b4dd0c6b7331ae789caabecbc5e154f96e52 (diff) | |
download | mock-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-x | py/mock.py | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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() |