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