From fa08e375fcbc349bb83ad911fe60ac4e6bae073e Mon Sep 17 00:00:00 2001 From: Mark McClain Date: Wed, 13 Mar 2013 11:07:10 -0400 Subject: [PATCH] sync Oslo Grizzly stable branch with Quantum fixes bug 1154393 Change-Id: I3442ff3da05447926b3e5882299ec7a92b9e38e3 --- quantum/openstack/common/context.py | 2 +- quantum/openstack/common/exception.py | 2 +- quantum/openstack/common/excutils.py | 2 +- quantum/openstack/common/fileutils.py | 2 +- quantum/openstack/common/importutils.py | 2 +- quantum/openstack/common/local.py | 2 +- quantum/openstack/common/lockutils.py | 6 +++--- quantum/openstack/common/log.py | 11 ++++++----- quantum/openstack/common/network_utils.py | 2 +- quantum/openstack/common/notifier/__init__.py | 2 +- quantum/openstack/common/notifier/api.py | 2 +- quantum/openstack/common/notifier/log_notifier.py | 2 +- quantum/openstack/common/notifier/no_op_notifier.py | 2 +- quantum/openstack/common/notifier/rpc_notifier.py | 2 +- quantum/openstack/common/notifier/rpc_notifier2.py | 2 +- quantum/openstack/common/notifier/test_notifier.py | 2 +- quantum/openstack/common/processutils.py | 2 +- quantum/openstack/common/rpc/amqp.py | 8 +++++--- quantum/openstack/common/rpc/impl_fake.py | 2 +- quantum/openstack/common/rpc/impl_kombu.py | 2 +- quantum/openstack/common/rpc/impl_qpid.py | 2 +- quantum/openstack/common/rpc/impl_zmq.py | 10 ++++++++++ quantum/openstack/common/setup.py | 2 +- quantum/openstack/common/timeutils.py | 2 +- quantum/openstack/common/version.py | 2 +- 25 files changed, 45 insertions(+), 32 deletions(-) diff --git a/quantum/openstack/common/context.py b/quantum/openstack/common/context.py index 442ab1d8e2b..e9cfd73cc11 100644 --- a/quantum/openstack/common/context.py +++ b/quantum/openstack/common/context.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/exception.py b/quantum/openstack/common/exception.py index 09c4d00a4f3..975a53a6921 100644 --- a/quantum/openstack/common/exception.py +++ b/quantum/openstack/common/exception.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/excutils.py b/quantum/openstack/common/excutils.py index 6f6a81a0b9c..d7fe150f0c9 100644 --- a/quantum/openstack/common/excutils.py +++ b/quantum/openstack/common/excutils.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # Copyright 2012, Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/fileutils.py b/quantum/openstack/common/fileutils.py index 4746ad49814..b988ad03d5c 100644 --- a/quantum/openstack/common/fileutils.py +++ b/quantum/openstack/common/fileutils.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/importutils.py b/quantum/openstack/common/importutils.py index 9dec764fb40..3bd277f47e2 100644 --- a/quantum/openstack/common/importutils.py +++ b/quantum/openstack/common/importutils.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/local.py b/quantum/openstack/common/local.py index 8bdc837a911..f1bfc824bf6 100644 --- a/quantum/openstack/common/local.py +++ b/quantum/openstack/common/local.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/lockutils.py b/quantum/openstack/common/lockutils.py index 973607e2002..79639e0c3ac 100644 --- a/quantum/openstack/common/lockutils.py +++ b/quantum/openstack/common/lockutils.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -107,10 +107,10 @@ class _InterProcessLock(object): class _WindowsLock(_InterProcessLock): def trylock(self): - msvcrt.locking(self.lockfile, msvcrt.LK_NBLCK, 1) + msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_NBLCK, 1) def unlock(self): - msvcrt.locking(self.lockfile, msvcrt.LK_UNLCK, 1) + msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_UNLCK, 1) class _PosixLock(_InterProcessLock): diff --git a/quantum/openstack/common/log.py b/quantum/openstack/common/log.py index 37245d4da56..873672acdb8 100644 --- a/quantum/openstack/common/log.py +++ b/quantum/openstack/common/log.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. @@ -328,7 +328,7 @@ def setup(product_name): if CONF.log_config: logging.config.fileConfig(CONF.log_config) else: - _setup_logging_from_conf(product_name) + _setup_logging_from_conf() sys.excepthook = _create_logging_excepthook(product_name) @@ -362,8 +362,8 @@ def _find_facility_from_conf(): return facility -def _setup_logging_from_conf(product_name): - log_root = getLogger(product_name).logger +def _setup_logging_from_conf(): + log_root = getLogger(None).logger for handler in log_root.handlers: log_root.removeHandler(handler) @@ -401,7 +401,8 @@ def _setup_logging_from_conf(product_name): if CONF.log_format: handler.setFormatter(logging.Formatter(fmt=CONF.log_format, datefmt=datefmt)) - handler.setFormatter(LegacyFormatter(datefmt=datefmt)) + else: + handler.setFormatter(LegacyFormatter(datefmt=datefmt)) if CONF.debug: log_root.setLevel(logging.DEBUG) diff --git a/quantum/openstack/common/network_utils.py b/quantum/openstack/common/network_utils.py index 69f67321636..5224e01aa94 100644 --- a/quantum/openstack/common/network_utils.py +++ b/quantum/openstack/common/network_utils.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2012 OpenStack LLC. +# Copyright 2012 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/notifier/__init__.py b/quantum/openstack/common/notifier/__init__.py index 482d54e4fdd..45c3b46ae93 100644 --- a/quantum/openstack/common/notifier/__init__.py +++ b/quantum/openstack/common/notifier/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/notifier/api.py b/quantum/openstack/common/notifier/api.py index 13cfea2e251..5af9f9a2d29 100644 --- a/quantum/openstack/common/notifier/api.py +++ b/quantum/openstack/common/notifier/api.py @@ -1,4 +1,4 @@ -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/notifier/log_notifier.py b/quantum/openstack/common/notifier/log_notifier.py index cea98311c49..99d9fa1c41e 100644 --- a/quantum/openstack/common/notifier/log_notifier.py +++ b/quantum/openstack/common/notifier/log_notifier.py @@ -1,4 +1,4 @@ -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/notifier/no_op_notifier.py b/quantum/openstack/common/notifier/no_op_notifier.py index ee1ddbdcac3..bc7a56ca7ac 100644 --- a/quantum/openstack/common/notifier/no_op_notifier.py +++ b/quantum/openstack/common/notifier/no_op_notifier.py @@ -1,4 +1,4 @@ -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/notifier/rpc_notifier.py b/quantum/openstack/common/notifier/rpc_notifier.py index e7caa97e28d..c3a59e3a49e 100644 --- a/quantum/openstack/common/notifier/rpc_notifier.py +++ b/quantum/openstack/common/notifier/rpc_notifier.py @@ -1,4 +1,4 @@ -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/notifier/rpc_notifier2.py b/quantum/openstack/common/notifier/rpc_notifier2.py index 6d725f0160a..860d92a356f 100644 --- a/quantum/openstack/common/notifier/rpc_notifier2.py +++ b/quantum/openstack/common/notifier/rpc_notifier2.py @@ -1,4 +1,4 @@ -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/notifier/test_notifier.py b/quantum/openstack/common/notifier/test_notifier.py index 5e348803dc1..96c1746bf42 100644 --- a/quantum/openstack/common/notifier/test_notifier.py +++ b/quantum/openstack/common/notifier/test_notifier.py @@ -1,4 +1,4 @@ -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/processutils.py b/quantum/openstack/common/processutils.py index 12ef558a42e..9287cad94fb 100644 --- a/quantum/openstack/common/processutils.py +++ b/quantum/openstack/common/processutils.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/rpc/amqp.py b/quantum/openstack/common/rpc/amqp.py index d648c4fc3d6..dbfc790c688 100644 --- a/quantum/openstack/common/rpc/amqp.py +++ b/quantum/openstack/common/rpc/amqp.py @@ -443,9 +443,11 @@ class ProxyCallback(_ThreadPoolWithWait): connection_pool=self.connection_pool, log_failure=False) except Exception: - LOG.exception(_('Exception during message handling')) - ctxt.reply(None, sys.exc_info(), - connection_pool=self.connection_pool) + # sys.exc_info() is deleted by LOG.exception(). + exc_info = sys.exc_info() + LOG.error(_('Exception during message handling'), + exc_info=exc_info) + ctxt.reply(None, exc_info, connection_pool=self.connection_pool) class MulticallProxyWaiter(object): diff --git a/quantum/openstack/common/rpc/impl_fake.py b/quantum/openstack/common/rpc/impl_fake.py index 779d2445293..7274802810c 100644 --- a/quantum/openstack/common/rpc/impl_fake.py +++ b/quantum/openstack/common/rpc/impl_fake.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC +# Copyright 2011 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain diff --git a/quantum/openstack/common/rpc/impl_kombu.py b/quantum/openstack/common/rpc/impl_kombu.py index cbc92bdec30..a410232dd34 100644 --- a/quantum/openstack/common/rpc/impl_kombu.py +++ b/quantum/openstack/common/rpc/impl_kombu.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC +# Copyright 2011 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain diff --git a/quantum/openstack/common/rpc/impl_qpid.py b/quantum/openstack/common/rpc/impl_qpid.py index db165bceb98..7d3ed441ad1 100644 --- a/quantum/openstack/common/rpc/impl_qpid.py +++ b/quantum/openstack/common/rpc/impl_qpid.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC +# Copyright 2011 OpenStack Foundation # Copyright 2011 - 2012, Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/rpc/impl_zmq.py b/quantum/openstack/common/rpc/impl_zmq.py index dc8a5e8675d..b1690789d62 100644 --- a/quantum/openstack/common/rpc/impl_zmq.py +++ b/quantum/openstack/common/rpc/impl_zmq.py @@ -16,6 +16,7 @@ import os import pprint +import re import socket import sys import types @@ -431,6 +432,8 @@ class ZmqProxy(ZmqBaseReactor): def __init__(self, conf): super(ZmqProxy, self).__init__(conf) + pathsep = set((os.path.sep or '', os.path.altsep or '', '/', '\\')) + self.badchars = re.compile(r'[%s]' % re.escape(''.join(pathsep))) self.topic_proxy = {} @@ -456,6 +459,13 @@ class ZmqProxy(ZmqBaseReactor): LOG.info(_("Creating proxy for topic: %s"), topic) try: + # The topic is received over the network, + # don't trust this input. + if self.badchars.search(topic) is not None: + emsg = _("Topic contained dangerous characters.") + LOG.warn(emsg) + raise RPCException(emsg) + out_sock = ZmqSocket("ipc://%s/zmq_topic_%s" % (ipc_dir, topic), sock_type, bind=True) diff --git a/quantum/openstack/common/setup.py b/quantum/openstack/common/setup.py index d0a3e948c44..030df61c994 100644 --- a/quantum/openstack/common/setup.py +++ b/quantum/openstack/common/setup.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # Copyright 2012-2013 Hewlett-Packard Development Company, L.P. # All Rights Reserved. # diff --git a/quantum/openstack/common/timeutils.py b/quantum/openstack/common/timeutils.py index 8e40660f6ac..60943659076 100644 --- a/quantum/openstack/common/timeutils.py +++ b/quantum/openstack/common/timeutils.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2011 OpenStack LLC. +# Copyright 2011 OpenStack Foundation. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/quantum/openstack/common/version.py b/quantum/openstack/common/version.py index 3a38c584a35..89082e4d6da 100644 --- a/quantum/openstack/common/version.py +++ b/quantum/openstack/common/version.py @@ -1,5 +1,5 @@ -# Copyright 2012 OpenStack LLC +# Copyright 2012 OpenStack Foundation # Copyright 2012-2013 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); you may