Better detection of permission denied when reading /etc/awx/settings.py to display appropriate error message.

This commit is contained in:
Chris Church
2014-08-13 09:53:34 -04:00
parent 2e39e093af
commit 9d7e240c9d
2 changed files with 16 additions and 10 deletions

View File

@@ -80,12 +80,12 @@ def manage():
sys.stdout.write('%s\n' % __version__)
# If running as a user without permission to read settings, display an
# error message. Allow --help to still work.
elif getattr(settings, 'MUST_BE_ROOT_OR_AWX', False):
if len(sys.argv) == 1 or len(sys.argv) >= 2 and sys.argv[1] in ('-h', '--help'):
elif settings.SECRET_KEY == 'permission-denied':
if len(sys.argv) == 1 or len(sys.argv) >= 2 and sys.argv[1] in ('-h', '--help', 'help'):
execute_from_command_line(sys.argv)
sys.stdout.write('\n')
prog = os.path.basename(sys.argv[0])
sys.stdout.write('%s must be run as root or awx.\n' % prog)
sys.stdout.write('Permission denied: %s must be run as root or awx.\n' % prog)
sys.exit(1)
else:
execute_from_command_line(sys.argv)