From ab69635cc1c91f09efc20b31512554722e4a7928 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 23 Feb 2012 13:32:14 -0500 Subject: [PATCH] Print error if nova-manage should be run as root. Fix bug 939531. This patch makes nova-manage print out a more friendly error message if it needs to be run as root instead of failing with an exception traceback. It catches an EACCES error when opening the config file or opening log files and exits cleanly. Change-Id: I2bd2bf3750c2bd3d672a037edb56f2b0b9bf1379 --- bin/nova-manage | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 552186987496..f636c947cd2f 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -55,6 +55,7 @@ """ import ast +import errno import gettext import glob import json @@ -2387,8 +2388,14 @@ def main(): except Exception: print 'sudo failed, continuing as if nothing happened' - argv = FLAGS(sys.argv) - logging.setup() + try: + argv = FLAGS(sys.argv) + logging.setup() + except IOError, e: + if e.errno == errno.EACCES: + print _('Please re-run nova-manage as root.') + sys.exit(2) + raise script_name = argv.pop(0) if len(argv) < 1: