Merge lp:~soren/nova/derootification into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Eric Day
Approved revision: 244
Merged at revision: 254
Proposed branch: lp:~soren/nova/derootification
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 75 lines (+21/-2)
3 files modified
nova/flags.py (+1/-0)
nova/server.py (+5/-1)
nova/twistd.py (+15/-1)
To merge this branch: bzr merge lp:~soren/nova/derootification
Reviewer Review Type Date Requested Status
Eric Day (community) Approve
termie (community) Approve
Review via email: mp+32888@code.launchpad.net

Commit message

Ensure that --gid and --uid options work for both twisted and non-twisted daemons.

Description of the change

Ensure that --gid and --uid options work for both twisted and non-twisted daemons. It's crucial for security that we can run as non-root.

To post a comment you must log in.
Revision history for this message
termie (termie) wrote :

i'd say skip making a local copy of ArgumentSerializer if we are only using it once, otherwise it either needs an additional newline before it or no newline before it.

the flag parser class needs additional newlines on either side of it.

please make the long line fit within 80 chars

other than those style nits, looks great :) Will approve once those are in.

review: Needs Fixing
Revision history for this message
termie (termie) :
review: Approve
Revision history for this message
Eric Day (eday) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/flags.py'
2--- nova/flags.py 2010-08-16 12:16:21 +0000
3+++ nova/flags.py 2010-08-17 22:07:42 +0000
4@@ -141,6 +141,7 @@
5 return _wrapped
6
7
8+DEFINE = _wrapper(gflags.DEFINE)
9 DEFINE_string = _wrapper(gflags.DEFINE_string)
10 DEFINE_integer = _wrapper(gflags.DEFINE_integer)
11 DEFINE_bool = _wrapper(gflags.DEFINE_bool)
12
13=== modified file 'nova/server.py'
14--- nova/server.py 2010-08-09 14:46:33 +0000
15+++ nova/server.py 2010-08-17 22:07:42 +0000
16@@ -44,6 +44,8 @@
17 flags.DEFINE_string('logfile', None, 'log file to output to')
18 flags.DEFINE_string('pidfile', None, 'pid file to output to')
19 flags.DEFINE_string('working_directory', './', 'working directory...')
20+flags.DEFINE_integer('uid', os.getuid(), 'uid under which to run')
21+flags.DEFINE_integer('gid', os.getgid(), 'gid under which to run')
22
23
24 def stop(pidfile):
25@@ -135,6 +137,8 @@
26 threaded=False),
27 stdin=stdin,
28 stdout=stdout,
29- stderr=stderr
30+ stderr=stderr,
31+ uid=FLAGS.uid,
32+ gid=FLAGS.gid
33 ):
34 main(args)
35
36=== modified file 'nova/twistd.py'
37--- nova/twistd.py 2010-08-12 18:52:32 +0000
38+++ nova/twistd.py 2010-08-17 22:07:42 +0000
39@@ -21,6 +21,7 @@
40 manage pid files and support syslogging.
41 """
42
43+import gflags
44 import logging
45 import os
46 import signal
47@@ -49,6 +50,14 @@
48 return
49
50
51+class FlagParser(object):
52+ def __init__(self, parser):
53+ self.parser = parser
54+
55+ def Parse(self, s):
56+ return self.parser(s)
57+
58+
59 def WrapTwistedOptions(wrapped):
60 class TwistedOptionsToFlags(wrapped):
61 subCommands = None
62@@ -79,7 +88,12 @@
63 reflect.accumulateClassList(self.__class__, 'optParameters', twistd_params)
64 for param in twistd_params:
65 key = param[0].replace('-', '_')
66- flags.DEFINE_string(key, param[2], str(param[-1]))
67+ if len(param) > 4:
68+ flags.DEFINE(FlagParser(param[4]),
69+ key, param[2], str(param[3]),
70+ serializer=gflags.ArgumentSerializer())
71+ else:
72+ flags.DEFINE_string(key, param[2], str(param[3]))
73
74 def _absorbHandlers(self):
75 twistd_handlers = {}