Selaa lähdekoodia

Prevent qvm-clock-sync permissions exception

qvm-clock-sync fails with a python subprocess error on line 43 when the `date ... -s ...` fails due to insufficient privileges to set the date. This commit checks to see if the program has effective UID root before attempting to set the date.
Max Zinkus 6 vuotta sitten
vanhempi
commit
65435dce78
1 muutettua tiedostoa jossa 4 lisäystä ja 1 poistoa
  1. 4 1
      qvm-tools/qvm-sync-clock

+ 4 - 1
qvm-tools/qvm-sync-clock

@@ -20,12 +20,15 @@
 #
 #
 import sys
+import os
 import re
 import subprocess
 from qubesadmin import Qubes
 
 def main():
-
+    if os.geteuid() != 0:
+        sys.stderr.write('This program must be run as root to set the date.')
+        sys.exit(1)
     app = Qubes()
     clockvm = app.clockvm