Only su if we're root.
authorBernard Blackham <[email protected]>
Sun, 1 Aug 2004 06:05:27 +0000 (06:05 +0000)
committerBernard Blackham <[email protected]>
Sun, 1 Aug 2004 06:05:27 +0000 (06:05 +0000)
sql-edition/servers/VendServer.py

index 4e0b16c..cad1c39 100755 (executable)
@@ -15,6 +15,7 @@ from random import random, seed
 from Idler import TrainIdler,GrayIdler
 import socket
 from traceback import print_tb
+from posix import geteuid
 
 GREETING = 'UCC SNACKS'
 PIN_LENGTH = 4
@@ -340,7 +341,10 @@ def run_forever(rfh, wfh, options, cf):
                                        # XXX this should move somewhere else:
                                        if cur_selection == '55':
                                                mk.set_message('OPENSESAME')
-                                               ret = os.system('su - "%s" -c "dispense door"'%username)
+                                               if geteuid() == 0:
+                                                       ret = os.system('su - "%s" -c "dispense door"'%username)
+                                               else:
+                                                       ret = os.system('dispense door')
                                                if ret == 0:
                                                        mk.set_message(center('DOOR OPEN'))
                                                else:

UCC git Repository :: git.ucc.asn.au