[PATCH] Don't mess up ctime during cobbler reposync

Robert Vogelgesang vogel at folz.de
Mon May 3 12:45:04 UTC 2010


On Fri, Apr 30, 2010 at 01:00:02PM -0400, Scott Henson wrote:
> Excerpts from Robert Vogelgesang's message of Fri Apr 30 04:08:59 -0400 2010:
> > 
> > The problem: The commands are executed as written, but only the parts
> > of the commands after the pipe symbol are logged; i. e. for cmd1 only
> > "xargs -0 chown root:apache" is logged, and for cmd2 only
> > "xargs -0 chmod a+rX".  I've done a cursory search in the standard
> > Python docs for any special meaning of the pipe symbol, but found
> > nothing.
> > 
> > So I'm asking here for help, to resolve this strange logging problem.
> > Maybe this is an issue with cobbler's use of python's logging?
> 
> Cobbler uses subprocess and if you look at utils.subprocess_call, you
> will see it calling Popen.  Basically this won't honor pipes in the
> output.  You have to chain together calls to subprocess.Popen to do
> pipes.
> 
> http://docs.python.org/library/subprocess.html#replacing-shell-pipeline
> 
> Makes it a little difficult to do with cobbler's implementation.  I'm
> thinking we make call_subprocess smart enough to pipe things together
> when its given a list, and just do the normal thing when given a
> string?

subprocess.Popen optionally uses the shell to execute the command
string, and util.subprocess_call does already enable the shell when
calling subprocess.Popen.

This is why the commands *are* doing what they are supposed to do,
as I wrote in my initial mail.

The problem with my previous patch is just that the "left hand side"
of the pipe does not get logged.  A possible, but less efficient,
solution is to use find(1)'s -exec action instead of a pipe.
I've attached a patch that implements this.

	Robert

> -- 
> Scott Henson
> Red Hat CIS Operator
> WVU Alum BSAE/BSME
> _______________________________________________
> cobbler-devel mailing list
> cobbler-devel at lists.fedorahosted.org
> https://fedorahosted.org/mailman/listinfo/cobbler-devel
-------------- next part --------------
--- action_reposync.py_icomfort-cobbler-branch_fetch-repomd-safely	2010-04-12 19:00:01.000000000 +0200
+++ action_reposync.py	2010-05-03 11:04:31.959551571 +0200
@@ -563,14 +563,14 @@
         a safeguard.
         """
         # all_path = os.path.join(repo_path, "*")
-        cmd1 = "chown -R root:apache %s" % repo_path
+        cmd1 = "find %s -not -user root -or -not -group apache -exec chown root:apache '{}' ';'" % repo_path
         utils.subprocess_call(self.logger, cmd1)
 
-        cmd2 = "chmod -R 755 %s" % repo_path
+        cmd2 = "find %s '(' -type d -and -not -perm -755 ')' -or '(' -type f -and -not -perm -444 ')' -exec chmod a+rX '{}' ';'" % repo_path
         utils.subprocess_call(self.logger, cmd2)
 
         if self.config.api.is_selinux_enabled():
-            cmd3 = "chcon --reference /var/www %s >/dev/null 2>/dev/null" % repo_path
+            cmd3 = "/sbin/restorecon -R %s >/dev/null 2>/dev/null" % repo_path
             utils.subprocess_call(self.logger, cmd3)
 
 


More information about the cobbler-devel mailing list