From 46cb317fd7dd3e7399d4dea53e20ef78aedced64 Mon Sep 17 00:00:00 2001 From: Michael E Brown Date: Wed, 28 Nov 2007 15:51:10 -0600 Subject: drop privs early to parse cmdline args and config files. pick them up again before we start doing real work. --- src/mock.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mock.py b/src/mock.py index 0110b3a..e5cfda0 100755 --- a/src/mock.py +++ b/src/mock.py @@ -182,7 +182,7 @@ def set_config_opts_per_cmdline(config_opts, options): config_opts['clean'] = options.clean if options.resultdir: - config_opts['resultdir'] = options.resultdir + config_opts['resultdir'] = os.path.expanduser(options.resultdir) if options.uniqueext: config_opts['unique-ext'] = options.uniqueext if options.rpmbuild_timeout is not None: @@ -252,6 +252,13 @@ def do_rebuild(config_opts, chroot, srpms): raise def main(retParams): + # drop unprivleged to parse args, etc. + # uidManager saves current real uid/gid which are unpriviledged (callers) + # due to suid helper, our current effective uid is 0 + uidManager = mock.uid.uidManager(os.getuid(), os.getgid()) + uidManager.dropPrivsTemp() + del(os.environ["HOME"]) + # defaults config_opts = {} setup_default_config_opts(config_opts) @@ -298,9 +305,6 @@ def main(retParams): warn_obsolete_config_options(config_opts) # 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 - uidManager = mock.uid.uidManager(os.getuid(), os.getgid()) chroot = mock.backend.Root(config_opts, uidManager) # elevate privs -- cgit