[Zodb-checkins] CVS: ZODB3/ZEO - runsvr.py:1.3

Guido van Rossum guido@python.org
Tue, 19 Nov 2002 14:11:31 -0500


Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv23892

Modified Files:
	runsvr.py 
Log Message:
Get rid of the -u/--user USER option.

You can now do this with the -u USER zdaemon/zdaemon.py.


=== ZODB3/ZEO/runsvr.py 1.2 => 1.3 ===
--- ZODB3/ZEO/runsvr.py:1.2	Tue Nov 19 13:29:32 2002
+++ ZODB3/ZEO/runsvr.py	Tue Nov 19 14:11:27 2002
@@ -14,8 +14,7 @@
 ##############################################################################
 """Start the ZEO storage server.
 
-Usage: %s [-a ADDRESS] [-d DIRECTORY]
-          [-f FILENAME] [-s STORAGE] [-u USER]
+Usage: %s [-a ADDRESS] [-d DIRECTORY] [-f FILENAME] [-s STORAGE]
 
 Options:
 -a/--address ADDRESS -- server address of the form PORT, HOST:PORT, or PATH
@@ -25,7 +24,6 @@
 -s/--storage STORAGE -- storage specification of the form
                         NAME=MODULE[:ATTRIBUTE]
                         (multiple -s options are supported)
--u/--user USER -- username or uid of user to setuid()
 
 -a is required; either -f must be used or -s must be used.
 """
@@ -140,19 +138,17 @@
 
     family = None
     address = None
-    user = None
     storages = None
     filename = None
     directory = None
 
-    _short_options = "a:d:f:hs:u:"
+    _short_options = "a:d:f:hs:"
     _long_options = [
         "--address=",
         "--directory=",
         "--filename=",
         "--help",
         "--storage=",
-        "--user=",
         ]
 
     def handle_option(self, opt, arg):
@@ -189,8 +185,6 @@
                 module = rest
                 attr = name
             self.storages[name] = module, attr
-        elif opt in ("-u", "--user"):
-            self.user = arg
         else:
             # Pass it to the base class, for --help/-h
             Options.handle_option(self, opt, arg)
@@ -218,7 +212,6 @@
     def main(self):
         self.check_socket()
         self.clear_socket()
-        self.set_uid()
         self.change_dir()
         self.open_storages()
         self.setup_signals()
@@ -247,32 +240,6 @@
                 os.unlink(self.opts.address)
             except os.error:
                 pass
-
-    def set_uid(self):
-        if self.opts.user is None:
-            return
-        if os.name != "posix":
-            self.opts.usage("-u/-user only supported on Unix")
-        if os.geteuid() != 0:
-            self.opts.usage("only root can use -u/--user")
-        # XXX Is it important not to die if the following fails?
-        import pwd
-        try:
-            uid = int(self.opts.user)
-        except: # int() can raise all sorts of errors
-            try:
-                pwrec = pwd.getpwnam(self.opts.user)
-            except KeyError:
-                self.opts.usage("username %r not found" % self.opts.user)
-            uid = pwrec[2]
-        else:
-            try:
-                pwrec = pwd.getpwuid(uid)
-            except KeyError:
-                self.opts.usage("uid %r not found" % self.opts.user)
-        gid = pwrec[3]
-        os.setgid(gid)
-        os.setuid(uid)
 
     def change_dir(self):
         if self.opts.directory: