summaryrefslogtreecommitdiffstats
path: root/gitautodeploy/gitautodeploy.py
diff options
context:
space:
mode:
authorOliver Poignant <oliver@poignant.se>2017-01-08 01:06:24 +0100
committerOliver Poignant <oliver@poignant.se>2017-01-08 01:06:24 +0100
commit324c3518d4b98da5bb660c62fa1503c47139c088 (patch)
treeab97540187b22d07a5df35a3b7da07b32dad52e6 /gitautodeploy/gitautodeploy.py
parent98b6a63e343f2a6a1888f8373845b0b1bd3c89d4 (diff)
downloadGit-Auto-Deploy-324c3518d4b98da5bb660c62fa1503c47139c088.zip
Git-Auto-Deploy-324c3518d4b98da5bb660c62fa1503c47139c088.tar.gz
Git-Auto-Deploy-324c3518d4b98da5bb660c62fa1503c47139c088.tar.bz2
Warning when running as root. Improved logging.
Diffstat (limited to 'gitautodeploy/gitautodeploy.py')
-rw-r--r--gitautodeploy/gitautodeploy.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/gitautodeploy/gitautodeploy.py b/gitautodeploy/gitautodeploy.py
index 6bf8693..31e1696 100644
--- a/gitautodeploy/gitautodeploy.py
+++ b/gitautodeploy/gitautodeploy.py
@@ -172,6 +172,7 @@ class GitAutoDeploy(object):
import logging
import base64
from .lock import Lock
+ import getpass
# This solves https://github.com/olipo186/Git-Auto-Deploy/issues/118
try:
@@ -218,6 +219,11 @@ class GitAutoDeploy(object):
fileHandler.setFormatter(logFormatter)
logger.addHandler(fileHandler)
+ # Display a warning when trying to run as root
+ if not self._config['allow-root-user'] and getpass.getuser() == 'root':
+ logger.critical("Refusing to start. This application shouldn't run as root. Please run it as a different user. To disregard this warning and start anyway, set the config option \"allow-root-user\" to true, or use the command line argument --allow-root-user")
+ sys.exit()
+
if 'ssh-keyscan' in self._config and self._config['ssh-keyscan']:
self._startup_event.log_info('Scanning repository hosts for ssh keys...')
self.ssh_key_scan()