From: Bernard Blackham Date: Sun, 1 Aug 2004 06:05:27 +0000 (+0000) Subject: Only su if we're root. X-Git-Tag: IMPORT-FROM-UCCCVS~94 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=1c0bfa3fd5d75950d78f0146ce99d51b5efb6377;p=uccvend-vendserver.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: