clear non-job files from at dir

This commit is contained in:
Tomas Mraz 2015-09-09 14:07:23 +02:00
parent 1aae4dded4
commit c65246e094
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,42 @@
diff -up at-3.1.16/atd.c.clear-nonjobs at-3.1.16/atd.c
--- at-3.1.16/atd.c.clear-nonjobs 2014-12-11 10:32:24.000000000 +0100
+++ at-3.1.16/atd.c 2015-09-09 11:40:22.544679351 +0200
@@ -414,10 +414,22 @@ run_file(const char *filename, uid_t uid
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,
@@ -427,12 +439,6 @@ run_file(const char *filename, uid_t uid
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);

View File

@ -3,7 +3,7 @@
Summary: Job spooling tools
Name: at
Version: 3.1.16
Release: 6%{?dist}
Release: 7%{?dist}
# http://packages.debian.org/changelogs/pool/main/a/at/current/copyright
# + install-sh is MIT license with changes under Public Domain
License: GPLv3+ and GPLv2+ and ISC and MIT and Public Domain
@ -29,6 +29,7 @@ Patch10: at-3.1.14-usePOSIXtimers.patch
Patch12: at-3.1.14-wrong_format.patch
Patch13: at-3.1.16-noabort.patch
Patch14: at-3.1.16-fclose-error.patch
Patch15: at-3.1.16-clear-nonjobs.patch
BuildRequires: fileutils /etc/init.d
BuildRequires: flex flex-static bison autoconf
@ -77,6 +78,7 @@ cp %{SOURCE1} .
%patch12 -p1 -b .wrong
%patch13 -p1 -b .noabort
%patch14 -p1 -b .fclose
%patch15 -p1 -b .clear-nojobs
%build
# patch9 touches configure.in
@ -174,6 +176,9 @@ chown daemon:daemon %{_localstatedir}/spool/at/.SEQ
%attr(0644,root,root) /%{_unitdir}/atd.service
%changelog
* Wed Sep 9 2015 Tomáš Mráz <tmraz@redhat.com> - 3.1.16-7
- clear non-job files from at dir
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.16-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild