Commit e8c3cd5f authored by Marco Mariani's avatar Marco Mariani

grid: updated privilege dropping under cygwin

parent 9011abf3
...@@ -184,7 +184,7 @@ def dropPrivileges(uid, gid, logger): ...@@ -184,7 +184,7 @@ def dropPrivileges(uid, gid, logger):
if uid == 0 or gid == 0: if uid == 0 or gid == 0:
raise OSError('Dropping privileges to uid = %r or ' raise OSError('Dropping privileges to uid = %r or '
'gid = %r is too dangerous' % (uid, gid)) 'gid = %r is too dangerous' % (uid, gid))
if current_uid or current_gid: if (current_uid or current_gid) and sys.platform != 'cygwin':
logger.debug('Running as uid = %r, gid = %r, dropping ' logger.debug('Running as uid = %r, gid = %r, dropping '
'not needed and not possible' % (current_uid, current_gid)) 'not needed and not possible' % (current_uid, current_gid))
return return
...@@ -194,6 +194,12 @@ def dropPrivileges(uid, gid, logger): ...@@ -194,6 +194,12 @@ def dropPrivileges(uid, gid, logger):
group_list.add(gid) group_list.add(gid)
os.initgroups(pwd.getpwuid(uid)[0], gid) os.initgroups(pwd.getpwuid(uid)[0], gid)
os.setgid(gid) os.setgid(gid)
if sys.platform == 'cygwin':
os.setreuid(-1, uid)
logger.debug('Privileges dropped from Cygwin to uid=%r gid=%r' % (uid, gid))
# skip further checks
return
os.setuid(uid) os.setuid(uid)
# assert that privileges are dropped # assert that privileges are dropped
......
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