From e22f303f79350d122b3bdd61bbc33598275d68ec Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Fri, 1 Apr 2011 02:11:40 +0200 Subject: [PATCH] Warn user when restoring backup as root (#159) --- dom0/qvm-tools/qvm-backup-restore | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dom0/qvm-tools/qvm-backup-restore b/dom0/qvm-tools/qvm-backup-restore index cbb81bcc..991ebb4f 100755 --- a/dom0/qvm-tools/qvm-backup-restore +++ b/dom0/qvm-tools/qvm-backup-restore @@ -127,6 +127,9 @@ def main(): parser.add_option ("--skip-conflicting", action="store_true", dest="skip_conflicting", default=False, help="Do not restore VMs that are already present on the host") + parser.add_option ("--force-root", action="store_true", dest="force_root", default=False, + help="Force to run, even with root privileges") + parser.add_option ("--recreate-conf-files", action="store_true", dest="recreate_conf", default=False, help="Recreate conf files after restore") @@ -242,6 +245,15 @@ def main(): print + if os.geteuid() == 0: + print "*** Running this tool as root is strongly discouraged, this will lead you in permissions problems." + if options.force_root: + print "Continuing as commanded. You have been warned." + else: + print "Retry as unprivileged user." + print "... or use --force-root to continue anyway." + exit(1) + if there_are_conflicting_vms: print "*** There VMs with conflicting names on the host! ***" if options.skip_conflicting: