Alex Lourie has uploaded a new change for review. Change subject: packaging: setup: stop and notify if setup is not run as root ......................................................................
packaging: setup: stop and notify if setup is not run as root Change-Id: Id1a46f817cad72bd0de7752a2a90db3d3fe77512 Bug-Url: https://bugzilla.redhat.com/853955 Signed-off-by: Alex Lourie <alou...@redhat.com> --- M packaging/ovirt-engine-dwh-setup.py 1 file changed, 15 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-dwh refs/changes/53/18753/1 diff --git a/packaging/ovirt-engine-dwh-setup.py b/packaging/ovirt-engine-dwh-setup.py index 56d1e84..09efa8b 100755 --- a/packaging/ovirt-engine-dwh-setup.py +++ b/packaging/ovirt-engine-dwh-setup.py @@ -16,8 +16,7 @@ import os import time import traceback -import glob -import shutil +import pwd import argparse import common_utils as utils from decorators import transactionDisplay @@ -63,6 +62,16 @@ ERR_DB_CREATE_FAILED = "Error while trying to create %s db" % DB_NAME log_file = utils.initLogging("%s-setup" % DWH_PACKAGE_NAME, "/var/log/ovirt-engine") + +def _verifyUserPermissions(): + username = pwd.getpwuid(os.getuid())[0] + if os.geteuid() != 0: + sys.exit( + 'Error: insufficient permissions for user {user}, ' + 'you must run with user root.'.format( + user=username + ) + ) def dbExists(db_dict): logging.debug("checking if %s db already exists" % db_dict["name"]) @@ -242,6 +251,10 @@ ''' main ''' + + # Check permissions first + _verifyUserPermissions() + rc = 0 doBackup = None backupFile = None -- To view, visit http://gerrit.ovirt.org/18753 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id1a46f817cad72bd0de7752a2a90db3d3fe77512 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-dwh Gerrit-Branch: master Gerrit-Owner: Alex Lourie <alou...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches