Bug 746100 - user level configuration file
Summary: user level configuration file
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: 15
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Clark Williams
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-10-13 21:23 UTC by Piotr Romanus
Modified: 2012-08-07 20:07 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-08-07 20:07:13 UTC
Type: ---


Attachments (Terms of Use)

Description Piotr Romanus 2011-10-13 21:23:45 UTC
Description of problem:

I would be nice to have ability to customize mock behavior on per-user basis. I created a little patch that looks at ~/.mock/user.cfg after reading /etc/mock/site-defaults.cfg.


diff --git a/py/mock.py b/py/mock.py
index 0a819f8..4af3fe5 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -613,6 +613,12 @@ def main(ret):
             if options.chroot == "default": log.error("  Did you forget to specify the chroot to use with '-r'
             sys.exit(1)
 
+    # Read user specific config file
+    cfg = '%s/%s' % (os.path.expanduser('~' + os.getlogin()), '.mock/user.cfg')
+    if os.path.exists(cfg):
+        config_opts['config_paths'].append(cfg)
+        execfile(cfg)
+
     # configure logging
     config_opts['chroot_name'] = options.chroot
     log_ini = os.path.join(config_path, config_opts["log_config_file"])

Comment 1 Michael E Brown 2011-10-14 02:11:11 UTC
May I point out that this has potentially catastrophic negative security implications. The config file contains arbitrary python code that runs with elevated privileges.

Comment 2 Clark Williams 2012-06-07 17:39:11 UTC
What if we drop privs before reading the user config? Something like this:

+    # Read user specific config file
+    cfg = '%s/%s' % (os.path.expanduser('~' + os.getlogin()), '.mock/user.cfg')
+    if os.path.exists(cfg):
+        config_opts['config_paths'].append(cfg)
+        uidManager.dropPrivsTemp()
+        execfile(cfg)
+        uidManager.restorePrivs()
+

Comment 3 Clark Williams 2012-06-07 19:23:43 UTC
My point with the above is that we can allow setting of various mock variables and at the same time prevent arbitrary code from doing evil things.

Comment 4 Fedora End Of Life 2012-08-07 20:07:15 UTC
This message is a notice that Fedora 15 is now at end of life. Fedora
has stopped maintaining and issuing updates for Fedora 15. It is
Fedora's policy to close all bug reports from releases that are no
longer maintained. At this time, all open bugs with a Fedora 'version'
of '15' have been closed as WONTFIX.

(Please note: Our normal process is to give advanced warning of this
occurring, but we forgot to do that. A thousand apologies.)

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, feel free to reopen
this bug and simply change the 'version' to a later Fedora version.

Bug Reporter: Thank you for reporting this issue and we are sorry that
we were unable to fix it before Fedora 15 reached end of life. If you
would still like to see this bug fixed and are able to reproduce it
against a later version of Fedora, you are encouraged to click on
"Clone This Bug" (top right of this page) and open it against that
version of Fedora.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

The process we are following is described here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping


Note You need to log in before you can comment on or make changes to this bug.