Skip to content

Commit 1b6e742

Browse files
author
Richard Jones
committed
Fixed roundup-server for windows, thanks Juergen Hermann.
1 parent 0ec0ad5 commit 1b6e742

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

roundup-server

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
Based on CGIHTTPServer in the Python library.
2222
23-
$Id: roundup-server,v 1.15 2001-10-12 02:23:26 richard Exp $
23+
$Id: roundup-server,v 1.16 2001-10-27 00:12:21 richard Exp $
2424
2525
"""
2626
import sys
@@ -216,23 +216,24 @@ def main():
216216
elif opt == '-u': user = arg
217217
elif opt == '-h': usage()
218218

219-
# if root, setuid to the running user
220-
if not os.getuid() and user is not None:
221-
try:
222-
import pwd
223-
except ImportError:
224-
raise ValueError, "Can't change users - no pwd module"
225-
try:
226-
uid = pwd.getpwnam(user)[2]
227-
except KeyError:
228-
raise ValueError, "User %s doesn't exist"%user
229-
os.setuid(uid)
230-
elif os.getuid() and user is not None:
231-
print 'WARNING: ignoring "-u" argument, not root'
232-
233-
# People can remove this check if they're really determined
234-
if not os.getuid() and user is None:
235-
raise ValueError, "Can't run as root!"
219+
if hasattr(os, 'getuid'):
220+
# if root, setuid to the running user
221+
if not os.getuid() and user is not None:
222+
try:
223+
import pwd
224+
except ImportError:
225+
raise ValueError, "Can't change users - no pwd module"
226+
try:
227+
uid = pwd.getpwnam(user)[2]
228+
except KeyError:
229+
raise ValueError, "User %s doesn't exist"%user
230+
os.setuid(uid)
231+
elif os.getuid() and user is not None:
232+
print 'WARNING: ignoring "-u" argument, not root'
233+
234+
# People can remove this check if they're really determined
235+
if not os.getuid() and user is None:
236+
raise ValueError, "Can't run as root!"
236237

237238
# handle instance specs
238239
if args:
@@ -260,6 +261,9 @@ if __name__ == '__main__':
260261

261262
#
262263
# $Log: not supported by cvs2svn $
264+
# Revision 1.15 2001/10/12 02:23:26 richard
265+
# Didn't clean up after myself :)
266+
#
263267
# Revision 1.14 2001/10/12 02:20:32 richard
264268
# server now handles setuid'ing much better
265269
#

0 commit comments

Comments
 (0)