Commit 44d46f4d authored by Jim Fulton's avatar Jim Fulton

moved setuid code to beginning to get all files created as effective user

parent 05a6ce7e
......@@ -86,7 +86,7 @@
"""Start the server storage.
"""
__version__ = "$Revision: 1.11 $"[11:-2]
__version__ = "$Revision: 1.12 $"[11:-2]
import sys, os, getopt, string
......@@ -216,6 +216,37 @@ def main(argv):
__builtins__.__debug__=debug
if debug: os.environ['Z_DEBUG_MODE']='1'
# Try to set uid to "-u" -provided uid.
# Try to set gid to "-u" user's primary group.
# This will only work if this script is run by root.
try:
import pwd
try:
try: UID=string.atoi(UID)
except: pass
gid = None
if type(UID) == type(""):
uid = pwd.getpwnam(UID)[2]
gid = pwd.getpwnam(UID)[3]
elif type(UID) == type(1):
uid = pwd.getpwuid(UID)[2]
gid = pwd.getpwuid(UID)[3]
else:
raise KeyError
try:
if gid is not None:
try:
os.setgid(gid)
except OSError:
pass
os.setuid(uid)
except OSError:
pass
except KeyError:
zLOG.LOG("z2", zLOG.ERROR, ("can't find UID %s" % UID))
except:
pass
if Z:
try: import posix
except: pass
......@@ -265,37 +296,6 @@ def main(argv):
ZEO.StorageServer.StorageServer(unix, storages)
# Try to set uid to "-u" -provided uid.
# Try to set gid to "-u" user's primary group.
# This will only work if this script is run by root.
try:
import pwd
try:
try: UID=string.atoi(UID)
except: pass
gid = None
if type(UID) == type(""):
uid = pwd.getpwnam(UID)[2]
gid = pwd.getpwnam(UID)[3]
elif type(UID) == type(1):
uid = pwd.getpwuid(UID)[2]
gid = pwd.getpwuid(UID)[3]
else:
raise KeyError
try:
if gid is not None:
try:
os.setgid(gid)
except OSError:
pass
os.setuid(uid)
except OSError:
pass
except KeyError:
zLOG.LOG("z2", zLOG.ERROR, ("can't find UID %s" % UID))
except:
pass
open(zeo_pid,'w').write("%s %s" % (os.getppid(), os.getpid()))
asyncore.loop()
......
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