From b677b13560fc1e670022cefa2d330d84dac2304a Mon Sep 17 00:00:00 2001 From: Eric Windisch Date: Tue, 23 Apr 2013 10:43:19 -0400 Subject: Remove rootwrap from IPC directory creation Removes processutils/rootwrap dependency. Fixes bug 1160420 and partially fixes 1180631. The attempt will still be made to create /var/run/openstack, but will give a reasonable error when it happens. If the directory exists, but permissions are denied, we should also give a reasonable error. A patch will be submitted to devstack that will set and create the IPC directory as necessary. Packagers should do this as well. Change-Id: I7814320adbfd0b2fe54cc2e523452c18ab2e7687 --- openstack/common/rpc/impl_zmq.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'openstack') diff --git a/openstack/common/rpc/impl_zmq.py b/openstack/common/rpc/impl_zmq.py index add3973..c64c772 100644 --- a/openstack/common/rpc/impl_zmq.py +++ b/openstack/common/rpc/impl_zmq.py @@ -30,7 +30,6 @@ from openstack.common import excutils from openstack.common.gettextutils import _ from openstack.common import importutils from openstack.common import jsonutils -from openstack.common import processutils as utils from openstack.common.rpc import common as rpc_common zmq = importutils.try_import('eventlet.green.zmq') @@ -521,23 +520,23 @@ class ZmqProxy(ZmqBaseReactor): CONF.rpc_zmq_port) consumption_proxy = InternalContext(None) - if not os.path.isdir(ipc_dir): - try: - utils.execute('mkdir', '-p', ipc_dir, run_as_root=True) - utils.execute('chown', "%s:%s" % (os.getuid(), os.getgid()), - ipc_dir, run_as_root=True) - utils.execute('chmod', '750', ipc_dir, run_as_root=True) - except utils.ProcessExecutionError: + try: + os.makedirs(ipc_dir) + except os.error: + if not os.path.isdir(ipc_dir): with excutils.save_and_reraise_exception(): - LOG.error(_("Could not create IPC directory %s") % - (ipc_dir, )) - + LOG.error(_("Required IPC directory does not exist at" + " %s") % (ipc_dir, )) try: self.register(consumption_proxy, consume_in, zmq.PULL, out_bind=True) except zmq.ZMQError: + if os.access(ipc_dir, os.X_OK): + with excutils.save_and_reraise_exception(): + LOG.error(_("Permission denied to IPC directory at" + " %s") % (ipc_dir, )) with excutils.save_and_reraise_exception(): LOG.error(_("Could not create ZeroMQ receiver daemon. " "Socket may already be in use.")) -- cgit