aboutsummaryrefslogtreecommitdiffstats
path: root/community/at/0011-clear-nonjobs.patch
blob: e684cc49ee062e979393bf8fdc1499c89bb46857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Patch-Source: https://src.fedoraproject.org/rpms/at/blob/f36/f/at-3.1.16-clear-nonjobs.patch (updated)
--
From c65246e094527163ee0b2003041ff6c942e14e47 Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tmraz@fedoraproject.org>
Date: Sep 09 2015 12:07:23 +0000
Subject: clear non-job files from at dir

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