From 080a4622cf40b8183448cb21d24b397dc55a5cef Mon Sep 17 00:00:00 2001 From: Bernard Blackham Date: Sun, 1 Aug 2004 06:05:27 +0000 Subject: [PATCH] Only su if we're root. --- sql-edition/servers/VendServer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: -- 2.20.1