Index: atrun.c =================================================================== --- atrun.c (revision 343994) +++ atrun.c (working copy) @@ -200,29 +200,45 @@ PRIV_END - if (stream == NULL) + if (stream == NULL) { + unlink(filename); perr("cannot open input file %s", filename); + } - if ((fd_in = dup(fileno(stream))) <0) + if ((fd_in = dup(fileno(stream))) <0) { + unlink(filename); perr("error duplicating input file descriptor"); + } - if (fstat(fd_in, &buf) == -1) + if (fstat(fd_in, &buf) == -1) { + unlink(filename); perr("error in fstat of input file descriptor"); + } - if (lstat(filename, &lbuf) == -1) + if (lstat(filename, &lbuf) == -1) { + unlink(filename); perr("error in fstat of input file"); + } - if (S_ISLNK(lbuf.st_mode)) + if (S_ISLNK(lbuf.st_mode)) { + unlink(filename); perrx("Symbolic link encountered in job %s - aborting", filename); + } if ((lbuf.st_dev != buf.st_dev) || (lbuf.st_ino != buf.st_ino) || (lbuf.st_uid != buf.st_uid) || (lbuf.st_gid != buf.st_gid) || - (lbuf.st_size!=buf.st_size)) + (lbuf.st_size!=buf.st_size)) { + unlink(filename); perrx("Somebody changed files from under us for job %s - aborting", filename); + } - if (buf.st_nlink > 1) + if (buf.st_nlink > 1) { + unlink(filename); perrx("Somebody is trying to run a linked script for job %s", filename); + } + + unlink(filename); if ((fflags = fcntl(fd_in, F_GETFD)) <0) perr("error in fcntl"); @@ -561,10 +577,6 @@ if (islower(queue)) run_file(dirent->d_name, buf.st_uid, buf.st_gid); } - /* Delete older files - */ - if ((run_time < now) && !(S_IXUSR & buf.st_mode) && (S_IRUSR & buf.st_mode)) - unlink(dirent->d_name); } /* run the single batch file, if any */