[Checkins] SVN: zc.zodbrecipes/trunk/ Bugs Fixed: Shell-scripts using su weren't generated correctly.

Jim Fulton jim at zope.com
Thu Jan 3 15:56:55 EST 2008


Log message for revision 82660:
  Bugs Fixed: Shell-scripts using su weren't generated correctly.
  

Changed:
  U   zc.zodbrecipes/trunk/README.txt
  U   zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py
  U   zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt

-=-
Modified: zc.zodbrecipes/trunk/README.txt
===================================================================
--- zc.zodbrecipes/trunk/README.txt	2008-01-03 19:17:13 UTC (rev 82659)
+++ zc.zodbrecipes/trunk/README.txt	2008-01-03 20:56:54 UTC (rev 82660)
@@ -9,6 +9,14 @@
 Changes
 *******
 
+0.3.1 (2008-01-03)
+==================
+
+Bugs Fixed
+----------
+
+Shell-scripts using su weren't generated correctly.
+
 0.3 (2008-01-03)
 ================
 

Modified: zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py
===================================================================
--- zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py	2008-01-03 19:17:13 UTC (rev 82659)
+++ zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py	2008-01-03 20:56:54 UTC (rev 82660)
@@ -190,18 +190,19 @@
             if options.get('shell-script') == 'true':
                 if not os.path.exists(options['zdaemon']):
                     logger.warn(no_zdaemon % options['zdaemon'])
-                if options.get('user'):
-                    su = 'su %s -c' % options['user']
-                else:
-                    su = ''
 
-                dest = os.path.join(options['rc-directory'], rc)
-                contents = shell_script_template % dict(
+                contents = "%(zdaemon)s -C '%(conf)s' $*" % dict(
                     zdaemon = options['zdaemon'],
                     conf = zdaemon_conf_path,
-                    su = su,
                     )
+                if options.get('user'):
+                    contents = 'su %(user)s -c \\\n  "%(contents)s"' % dict(
+                        user = options['user'],
+                        contents = contents,
+                        )
+                contents = "#!/bin/sh\n%s\n" % contents
 
+                dest = os.path.join(options['rc-directory'], rc)
                 if not (os.path.exists(dest) and open(dest).read() == contents):
                     open(dest, 'w').write(contents)
                     os.chmod(dest, 0755)
@@ -283,11 +284,6 @@
 zc.recipe.eggs:script recipe and the zdaemon egg.
 """
 
-shell_script_template = r"""#!/bin/sh
-%(su)s %(zdaemon)s \
-    -C "%(conf)s" $*
-"""
-
 def event_log(path, *data):
     return ZConfig.schemaless.Section(
         'eventlog', '', None,

Modified: zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt
===================================================================
--- zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt	2008-01-03 19:17:13 UTC (rev 82659)
+++ zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt	2008-01-03 20:56:54 UTC (rev 82660)
@@ -567,5 +567,5 @@
 
     >>> cat('rc', 'demo-server')
     #!/bin/sh
-    su bob -c /sample-buildout/bin/zdaemon \
-        -C "/sample-buildout/etc/server-zdaemon.conf" $*
+    su bob -c \
+      "/sample-buildout/bin/zdaemon -C '/sample-buildout/etc/server-zdaemon.conf' $*"



More information about the Checkins mailing list