From: Bernard Blackham Date: Sun, 1 Aug 2004 06:05:27 +0000 (+0000) Subject: Only su if we're root. X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=080a4622cf40b8183448cb21d24b397dc55a5cef;p=zanchey%2Fdispense2.git Only su if we're root. --- diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index 4e0b16c..cad1c39 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -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: