Fix seteuid magic

This commit is contained in:
David Bartley 2007-12-03 02:58:44 -05:00
parent 8aa2bd1b24
commit ac241a6e34
3 changed files with 16 additions and 14 deletions

View File

@ -18,8 +18,10 @@ for pathent in sys.path[:]:
if not pathent.find('/usr') == 0 and not pathent.find('/var') == 0:
sys.path.remove(pathent)
euid = os.getuid()
egid = os.getgid()
euid = os.geteuid()
egid = os.getegid()
uid = os.getuid()
gid = os.getgid()
try:
os.setreuid(euid, euid)
os.setregid(egid, egid)
@ -28,4 +30,4 @@ except OSError, e:
sys.exit(1)
import csc.apps.urwid.main
csc.apps.urwid.main.start(euid, egid)
csc.apps.urwid.main.start(uid, gid)

View File

@ -20,11 +20,11 @@ def list_group_members(data):
search.member_list( mlist )
def group_members(data):
data, euid = data
data, uid = data
# only syscom may modify non-club groups
if data['group'] != 'office':
user = pwd.getpwuid(euid).pw_name
user = pwd.getpwuid(uid).pw_name
users = grp.getgrnam('syscom').gr_mem
if user not in users:
member = members.get(data['group'])
@ -66,8 +66,8 @@ class IntroPage(WizardPanel):
return False
class InfoPage(WizardPanel):
def __init__(self, state, euid):
state['euid'] = euid
def __init__(self, state, uid):
state['uid'] = uid
WizardPanel.__init__(self, state)
def init_widgets(self):
self.group = WordEdit("Club or Group: ")
@ -85,7 +85,7 @@ class InfoPage(WizardPanel):
"group" : group_name,
"groups" : [group],
}
group_members((data, self.state['euid']))
group_members((data, self.state['uid']))
class ChangeMember(WizardPanel):
def __init__(self, state, data):

View File

@ -74,9 +74,9 @@ def main_menu():
("Manage Club or Group Members", manage_group, None),
("Manage Positions", manage_positions, None),
("Manage Office Staff", groups.group_members,
(office_data, ui.euid)),
(office_data, ui.uid)),
("Manage Systems Committee", groups.group_members,
(syscom_data, ui.euid)),
(syscom_data, ui.uid)),
("Exit", raise_abort, None),
]
@ -102,7 +102,7 @@ def new_club(*args, **kwargs):
def manage_group(*args, **kwargs):
push_wizard("Manage Club or Group Members", [
groups.IntroPage,
(groups.InfoPage, ui.euid),
(groups.InfoPage, ui.uid),
], (60, 15))
def renew_member(*args, **kwargs):
@ -154,9 +154,9 @@ def run():
push_window( main_menu(), program_name() )
event_loop( ui )
def start(euid, egid):
ui.euid = euid
ui.egid = egid
def start(uid, gid):
ui.uid = uid
ui.gid = gid
ui.run_wrapper( run )
if __name__ == '__main__':