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
=== modified file 'nova/flags.py'
--- nova/flags.py 2010-08-16 12:16:21 +0000
+++ nova/flags.py 2010-08-17 22:07:42 +0000
@@ -141,6 +141,7 @@
141 return _wrapped141 return _wrapped
142142
143143
144DEFINE = _wrapper(gflags.DEFINE)
144DEFINE_string = _wrapper(gflags.DEFINE_string)145DEFINE_string = _wrapper(gflags.DEFINE_string)
145DEFINE_integer = _wrapper(gflags.DEFINE_integer)146DEFINE_integer = _wrapper(gflags.DEFINE_integer)
146DEFINE_bool = _wrapper(gflags.DEFINE_bool)147DEFINE_bool = _wrapper(gflags.DEFINE_bool)
147148
=== modified file 'nova/server.py'
--- nova/server.py 2010-08-09 14:46:33 +0000
+++ nova/server.py 2010-08-17 22:07:42 +0000
@@ -44,6 +44,8 @@
44flags.DEFINE_string('logfile', None, 'log file to output to')44flags.DEFINE_string('logfile', None, 'log file to output to')
45flags.DEFINE_string('pidfile', None, 'pid file to output to')45flags.DEFINE_string('pidfile', None, 'pid file to output to')
46flags.DEFINE_string('working_directory', './', 'working directory...')46flags.DEFINE_string('working_directory', './', 'working directory...')
47flags.DEFINE_integer('uid', os.getuid(), 'uid under which to run')
48flags.DEFINE_integer('gid', os.getgid(), 'gid under which to run')
4749
4850
49def stop(pidfile):51def stop(pidfile):
@@ -135,6 +137,8 @@
135 threaded=False),137 threaded=False),
136 stdin=stdin,138 stdin=stdin,
137 stdout=stdout,139 stdout=stdout,
138 stderr=stderr140 stderr=stderr,
141 uid=FLAGS.uid,
142 gid=FLAGS.gid
139 ):143 ):
140 main(args)144 main(args)
141145
=== modified file 'nova/twistd.py'
--- nova/twistd.py 2010-08-12 18:52:32 +0000
+++ nova/twistd.py 2010-08-17 22:07:42 +0000
@@ -21,6 +21,7 @@
21manage pid files and support syslogging.21manage pid files and support syslogging.
22"""22"""
2323
24import gflags
24import logging25import logging
25import os26import os
26import signal27import signal
@@ -49,6 +50,14 @@
49 return50 return
5051
5152
53class FlagParser(object):
54 def __init__(self, parser):
55 self.parser = parser
56
57 def Parse(self, s):
58 return self.parser(s)
59
60
52def WrapTwistedOptions(wrapped):61def WrapTwistedOptions(wrapped):
53 class TwistedOptionsToFlags(wrapped):62 class TwistedOptionsToFlags(wrapped):
54 subCommands = None63 subCommands = None
@@ -79,7 +88,12 @@
79 reflect.accumulateClassList(self.__class__, 'optParameters', twistd_params)88 reflect.accumulateClassList(self.__class__, 'optParameters', twistd_params)
80 for param in twistd_params:89 for param in twistd_params:
81 key = param[0].replace('-', '_')90 key = param[0].replace('-', '_')
82 flags.DEFINE_string(key, param[2], str(param[-1]))91 if len(param) > 4:
92 flags.DEFINE(FlagParser(param[4]),
93 key, param[2], str(param[3]),
94 serializer=gflags.ArgumentSerializer())
95 else:
96 flags.DEFINE_string(key, param[2], str(param[3]))
8397
84 def _absorbHandlers(self):98 def _absorbHandlers(self):
85 twistd_handlers = {}99 twistd_handlers = {}