Author: gstein Date: Fri Mar 9 22:17:03 2012 New Revision: 1299074 URL: http://svn.apache.org/viewvc?rev=1299074&view=rev Log: The daemonization code resets the umask to 000 to avoid funky parent process values. We need to set the umask post-daemonization, so that logic is moved to Daemon.run().
* tools/server-side/svnpubsub/svnwcsub.py: (Daemon.__init__): add UMASK param and stash it away. (Daemon.run): possibly set the umask of the process (handle_options): remove the umask processing (main): pass the umask option to the Daemon instance Modified: subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py Modified: subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py URL: http://svn.apache.org/viewvc/subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py?rev=1299074&r1=1299073&r2=1299074&view=diff ============================================================================== --- subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py (original) +++ subversion/trunk/tools/server-side/svnpubsub/svnwcsub.py Fri Mar 9 22:17:03 2012 @@ -326,9 +326,10 @@ class ReloadableConfig(ConfigParser.Safe class Daemon(daemonize.Daemon): - def __init__(self, logfile, pidfile, bdec): + def __init__(self, logfile, pidfile, umask, bdec): daemonize.Daemon.__init__(self, logfile, pidfile) + self.umask = umask self.bdec = bdec def setup(self): @@ -336,7 +337,15 @@ class Daemon(daemonize.Daemon): pass def run(self): - # Start the BDEC (on the main thread), then start up twisted + # Set the umask in the daemon process. Defaults to 000 for + # daemonized processes. Foreground processes simply inherit + # the value from the parent process. + if self.umask is not None: + umask = int(options.umask, 8) + os.umask(umask) + logging.info('umask set to %03o', umask) + + # Start the BDEC (on the main thread), then start the client self.bdec.start() run_client(self.bdec) @@ -394,11 +403,6 @@ def handle_options(options): logging.info('setting uid %d', uid) os.setuid(uid) - if options.umask: - umask = int(options.umask, 8) - os.umask(umask) - logging.info('umask set to %03o', umask) - def main(args): parser = optparse.OptionParser( @@ -438,7 +442,7 @@ def main(args): # We manage the logfile ourselves (along with possible rotation). The # daemon process can just drop stdout/stderr into /dev/null. - d = Daemon('/dev/null', options.pidfile, bdec) + d = Daemon('/dev/null', options.pidfile, options.umask, bdec) if options.daemon: # Daemonize the process and call sys.exit() with appropriate code d.daemonize_exit()