Skip to content

Commit

Permalink
Merge "Deprecate root_helper in favor of rootwrap_config"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 2, 2012
2 parents 40a1965 + 1d447e6 commit 8583ce6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/nova-rootwrap
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Filters which commands nova is allowed to run as another user.
To use this, you should set the following in nova.conf:
root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf
rootwrap_config=/etc/nova/rootwrap.conf
You also need to let the nova user run nova-rootwrap as root in sudoers:
nova ALL = (root) NOPASSWD: /usr/bin/nova-rootwrap /etc/nova/rootwrap.conf *
Expand Down
6 changes: 5 additions & 1 deletion nova/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,11 @@ def _get_my_ip():
'formatted with on creation.'),
cfg.StrOpt('root_helper',
default='sudo',
help='Command prefix to use for running commands as root'),
help='Deprecated: command to use for running commands as root'),
cfg.StrOpt('rootwrap_config',
default=None,
help='Path to the rootwrap configuration file to use for '
'running commands as root'),
cfg.StrOpt('network_driver',
default='nova.network.linux_net',
help='Driver to use for network creation'),
Expand Down
14 changes: 12 additions & 2 deletions nova/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import lockfile
import netaddr

from nova.common import deprecated
from nova import exception
from nova import flags
from nova.openstack.common import cfg
Expand All @@ -65,6 +66,12 @@
cfg.BoolOpt('disable_process_locking', default=False,
help='Whether to disable inter-process locks'))

if FLAGS.rootwrap_config is None or FLAGS.root_helper != 'sudo':
deprecated.warn(_('The root_helper option (which lets you specify a '
'root wrapper different from nova-rootwrap, and '
'defaults to using sudo) is now deprecated. You '
'should use the rootwrap_config option instead.'))


def vpn_ping(address, port, timeout=0.05, session_id=None):
"""Sends a vpn negotiation packet and returns the server session.
Expand Down Expand Up @@ -118,7 +125,7 @@ def execute(*cmd, **kwargs):
"""Helper method to execute command with optional retry.
If you add a run_as_root=True command, don't forget to add the
corresponding filter to nova.rootwrap !
corresponding filter to etc/nova/rootwrap.d !
:param cmd: Passed to subprocess.Popen.
:param process_input: Send to opened process.
Expand Down Expand Up @@ -159,7 +166,10 @@ def execute(*cmd, **kwargs):
'to utils.execute: %r') % kwargs)

if run_as_root:
cmd = shlex.split(FLAGS.root_helper) + list(cmd)
if (FLAGS.rootwrap_config is not None):
cmd = ['sudo', 'nova-rootwrap', FLAGS.rootwrap_config] + list(cmd)
else:
cmd = shlex.split(FLAGS.root_helper) + list(cmd)
cmd = map(str, cmd)

while attempts > 0:
Expand Down

0 comments on commit 8583ce6

Please sign in to comment.