Commit ba5c3484 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Antoine Catton

Better check for group_list in slapgrid utils.

parent 235218d5
...@@ -178,9 +178,8 @@ def dropPrivileges(uid, gid): ...@@ -178,9 +178,8 @@ def dropPrivileges(uid, gid):
return return
# drop privileges # drop privileges
user_name = pwd.getpwuid(uid)[0] user_name = pwd.getpwuid(uid)[0]
group_list = [x.gr_gid for x in grp.getgrall() if user_name in x.gr_mem] group_list = set([x.gr_gid for x in grp.getgrall() if user_name in x.gr_mem])
if gid not in group_list: group_list.add(gid)
group_list.append(gid)
os.initgroups(pwd.getpwuid(uid)[0], gid) os.initgroups(pwd.getpwuid(uid)[0], gid)
os.setgid(gid) os.setgid(gid)
os.setuid(uid) os.setuid(uid)
...@@ -190,7 +189,7 @@ def dropPrivileges(uid, gid): ...@@ -190,7 +189,7 @@ def dropPrivileges(uid, gid):
'and group_list = %s' % ( 'and group_list = %s' % (
uid, gid, group_list) uid, gid, group_list)
new_uid, new_gid, new_group_list = os.getuid(), os.getgid(), os.getgroups() new_uid, new_gid, new_group_list = os.getuid(), os.getgid(), os.getgroups()
if not (new_uid == uid and new_gid == gid and new_group_list == group_list): if not (new_uid == uid and new_gid == gid and set(new_group_list) == group_list):
raise OSError('%s new_uid = %r and new_gid = %r and ' \ raise OSError('%s new_uid = %r and new_gid = %r and ' \
'new_group_list = %r which is fatal.' 'new_group_list = %r which is fatal.'
% (message_pre, % (message_pre,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment