Blame SOURCES/at-3.1.13-clear-nonjobs.patch

b8fa79
diff -up at-3.1.13/atd.c.clear-nonjobs at-3.1.13/atd.c
b8fa79
--- at-3.1.13/atd.c.clear-nonjobs	2016-04-20 17:15:00.579327865 +0200
b8fa79
+++ at-3.1.13/atd.c	2016-04-20 17:18:06.215376744 +0200
b8fa79
@@ -414,10 +414,22 @@ run_file(const char *filename, uid_t uid
b8fa79
     sprintf(fmt, "#!/bin/sh\n# atrun uid=%%d gid=%%d\n# mail %%%ds %%d",
b8fa79
 	mailsize );
b8fa79
 
b8fa79
+    /* Unlink the file unless there was an error reading it (perhaps
b8fa79
+     * temporary).
b8fa79
+     * If the file has a bogus format there is no reason in trying
b8fa79
+     * to run it again and again.
b8fa79
+     */
b8fa79
     if (fscanf(stream, fmt,
b8fa79
-	       &nuid, &ngid, mailname, &send_mail) != 4)
b8fa79
-	pabort("File %.500s is in wrong format - aborting",
b8fa79
-	       filename);
b8fa79
+	       &nuid, &ngid, mailname, &send_mail) != 4) {
b8fa79
+		if (ferror(stream))
b8fa79
+			perr("Error reading the job file");
b8fa79
+
b8fa79
+		unlink(filename);
b8fa79
+		pabort("File %.500s is in wrong format - aborting",
b8fa79
+			filename);
b8fa79
+    }
b8fa79
+
b8fa79
+    unlink(filename);
b8fa79
 
b8fa79
     if (mailname[0] == '-')
b8fa79
 	pabort("illegal mail name %.300s in job %8lu (%.300s)", mailname,
b8fa79
@@ -427,12 +439,6 @@ run_file(const char *filename, uid_t uid
b8fa79
 	pabort("Job %8lu (%.500s) - userid %d does not match file uid %d",
b8fa79
 	       jobno, filename, nuid, uid);
b8fa79
 
b8fa79
-    /* We are now committed to executing this script.  Unlink the
b8fa79
-     * original.
b8fa79
-     */
b8fa79
-
b8fa79
-    unlink(filename);
b8fa79
-
b8fa79
     fclose(stream);
b8fa79
     if (chdir(ATSPOOL_DIR) < 0)
b8fa79
 	perr("Cannot chdir to " ATSPOOL_DIR);