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

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