File at-3.1.8-atrm-race.patch of Package at

Copyright (c) 2011 Ingo Schwarze <ischwarze@astaro.com>

This patch is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

--- atd.c	2011-02-25 12:40:46.000000000 +0100
+++ atd.c.new	2011-02-25 14:59:44.000000000 +0100
@@ -291,16 +291,16 @@ run_file(const char *filename, uid_t uid
     newname[0] = '=';
 
     /* We try to make a hard link to lock the file.  If we fail, then
-     * somebody else has already locked it (a second atd?); log the
+     * somebody else has already locked or deleted it; log the
      * fact and return.
      */
     if (link(filename, newname) == -1) {
-	if (errno == EEXIST) {
-	    syslog(LOG_WARNING, "trying to execute job %.100s twice",filename);
-	    return;
-	} else {
-	    perr("Can't link execution file");
-	}
+	syslog(LOG_WARNING,
+	    (errno == EEXIST ? "trying to execute job %.100s twice"
+			     : "Can't link execution file %.100s: %m"),
+	    filename);
+	free(newname);
+	return;
     }
     /* If something goes wrong between here and the unlink() call,
      * the job gets restarted as soon as the "=" entry is cleared
openSUSE Build Service is sponsored by