[Zodb-checkins] CVS: ZODB3/zdaemon - component.xml:1.5 sample.conf:1.8 zdctl.py:1.47 zdoptions.py:1.26 zdrun.py:1.20

Jeremy Hylton jeremy at zope.com
Wed Jan 14 10:28:38 EST 2004


Update of /cvs-repository/ZODB3/zdaemon
In directory cvs.zope.org:/tmp/cvs-serv26520/zdaemon

Modified Files:
	component.xml sample.conf zdctl.py zdoptions.py zdrun.py 
Log Message:
Add -m/--umask option to zdaemon.  

Patch from John Belmonte.

Bug fix candidate?  It appears ZODB 3.2 would have the same problem,
preventing some user from connecting to a ZEO server.  It's a new
feature, but a necessary one.


=== ZODB3/zdaemon/component.xml 1.4 => 1.5 ===
--- ZODB3/zdaemon/component.xml:1.4	Tue Jan  6 15:11:29 2004
+++ ZODB3/zdaemon/component.xml	Wed Jan 14 10:28:07 2004
@@ -111,7 +111,7 @@
 
         - call setsid() so it becomes a session leader
 
-        - call umask(022)
+        - call umask() with specified value
       </description>
     </key>
 
@@ -203,6 +203,17 @@
 
         XXX The zdrun.py event log file may be opened *before*
         setuid() is called.  Is this good or bad?
+      </description>
+    </key>
+
+    <key name="umask" datatype="zdaemon.zdoptions.octal_type"
+         required="no"
+         default="022">
+      <description>
+        Command-line option: -m or --umask.
+
+        When daemon mode is used, this option specifies the octal umask
+        of the subprocess.
       </description>
     </key>
 


=== ZODB3/zdaemon/sample.conf 1.7 => 1.8 ===
--- ZODB3/zdaemon/sample.conf:1.7	Fri Jan 24 08:04:08 2003
+++ ZODB3/zdaemon/sample.conf	Wed Jan 14 10:28:07 2004
@@ -10,6 +10,7 @@
   socket-name	zdsock
   exit-codes	0,2
   # user has no default
+  umask		022
   directory	.
   default-to-interactive True
   hang-around   False


=== ZODB3/zdaemon/zdctl.py 1.46 => 1.47 ===
--- ZODB3/zdaemon/zdctl.py:1.46	Mon Nov  3 13:56:29 2003
+++ ZODB3/zdaemon/zdctl.py	Wed Jan 14 10:28:07 2004
@@ -29,6 +29,7 @@
 -p/--program PROGRAM -- the program to run
 -s/--socket-name SOCKET -- Unix socket name for client (default "zdsock")
 -u/--user USER -- run as this user (or numeric uid)
+-m/--umask UMASK -- use this umask for daemon subprocess (default is 022)
 -x/--exit-codes LIST -- list of fatal exit codes (default "0,2")
 -z/--directory DIRECTORY -- directory to chdir to when using -d (default off)
 action [arguments] -- see below
@@ -201,6 +202,7 @@
             args += self._get_override("-f", "forever", flag=1)
             args += self._get_override("-s", "sockname")
             args += self._get_override("-u", "user")
+            args += self._get_override("-m", "umask")
             args += self._get_override(
                 "-x", "exitcodes", ",".join(map(str, self.options.exitcodes)))
             args += self._get_override("-z", "directory")
@@ -353,6 +355,7 @@
         print "sockname:    ", repr(self.options.sockname)
         print "exitcodes:   ", repr(self.options.exitcodes)
         print "user:        ", repr(self.options.user)
+        print "umask:       ", oct(self.options.umask)
         print "directory:   ", repr(self.options.directory)
         print "logfile:     ", repr(self.options.logfile)
         print "hang_around: ", repr(self.options.hang_around)


=== ZODB3/zdaemon/zdoptions.py 1.25 => 1.26 ===
--- ZODB3/zdaemon/zdoptions.py:1.25	Wed Dec 31 15:40:06 2003
+++ ZODB3/zdaemon/zdoptions.py	Wed Jan 14 10:28:07 2004
@@ -335,6 +335,8 @@
         self.add("exitcodes", "runner.exit_codes", "x:", "exit-codes=",
                  list_of_ints, default=[0, 2])
         self.add("user", "runner.user", "u:", "user=")
+        self.add("umask", "runner.umask", "m:", "umask=", octal_type,
+                 default=022)
         self.add("directory", "runner.directory", "z:", "directory=",
                  ZConfig.datatypes.existing_directory)
         self.add("hang_around", "runner.hang_around", default=0)
@@ -370,6 +372,9 @@
         return []
     else:
         return map(int, arg.split(","))
+
+def octal_type(arg):
+    return int(arg, 8)
 
 
 def _test():


=== ZODB3/zdaemon/zdrun.py 1.19 => 1.20 ===
--- ZODB3/zdaemon/zdrun.py:1.19	Wed Dec 31 15:40:06 2003
+++ ZODB3/zdaemon/zdrun.py	Wed Jan 14 10:28:07 2004
@@ -24,6 +24,7 @@
 -h/--help -- print this usage message and exit
 -s/--socket-name SOCKET -- Unix socket name for client (default "zdsock")
 -u/--user USER -- run as this user (or numeric uid)
+-m/--umask UMASK -- use this umask for daemon subprocess (default is 022)
 -x/--exit-codes LIST -- list of fatal exit codes (default "0,2")
 -z/--directory DIRECTORY -- directory to chdir to when using -d (default off)
 program [program-arguments] -- an arbitrary application to run
@@ -382,7 +383,7 @@
         os.close(2)
         sys.stderr = sys.__stderr__ = open("/dev/null", "w")
         os.setsid()
-        os.umask(022) # Create no group/other writable files/directories
+        os.umask(self.options.umask)
         # XXX Stevens, in his Advanced Unix book, section 13.3 (page
         # 417) recommends calling umask(0) and closing unused
         # file descriptors.  In his Network Programming book, he




More information about the Zodb-checkins mailing list