Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/at.c 2015-12-06 16:45:10.000000000 +0100
- +++ b/at.c 2016-02-20 11:36:22.000000000 +0100
- @@ -122,7 +122,7 @@
- extern char **environ;
- int fcreated;
- char *namep;
- -char atfile[] = ATJOB_DIR "/12345678901234";
- +char atfile[] = ATJOB_DIR "/12345678901234567";
- char *atinput = (char *) 0; /* where to get input from */
- char atqueue = 0; /* which queue to examine for jobs (atq) */
- @@ -244,6 +244,7 @@
- int kill_errno;
- int rc;
- int mailsize = 128;
- + char *shell_path;
- /* Install the signal handler for SIGINT; terminate after removing the
- * spool file if necessary
- @@ -299,7 +300,7 @@
- perr("Cannot generate job number");
- (void)snprintf(ppos, sizeof(atfile) - (ppos - atfile),
- - "%c%5lx%8lx", queue, jobno, (unsigned long) (runtimer / 60));
- + "%c%5lx%8lx%2u", queue, jobno, (unsigned long) (runtimer / 60), (unsigned int) (runtimer % 60));
- for (ap = ppos; *ap != '\0'; ap++)
- if (*ap == ' ')
- @@ -352,6 +353,19 @@
- if ((fp = fdopen(fd, "w")) == NULL)
- panic("Cannot reopen atjob file");
- + shell_path = getenv("SHELL");
- + if(shell_path == NULL || shell_path[0] == '\0')
- + {
- + /* POSIX.2 allows the shell specified by the user's SHELL environment
- + variable, the login shell from the user's password database entry,
- + or /bin/sh to be the command interpreter that processes the at-job.
- + It also alows a warning diagnostic to be printed. Because of the
- + possible variance, we always output the diagnostic. */
- +
- + shell_path = "/bin/sh";
- + fprintf(stderr, "warning: commands will be executed using %s\n", shell_path);
- + }
- +
- /* Get the userid to mail to, first by trying getlogin(), which reads
- * /var/run/utmp, then from LOGNAME, finally from getpwuid().
- */
- @@ -374,8 +388,8 @@
- perr("Cannot open input file %.500s", atinput);
- }
- - fprintf(fp, "#!/bin/sh\n# atrun uid=%d gid=%d\n# mail %s %d\n",
- - real_uid, real_gid, mailname, send_mail);
- + fprintf(fp, "#!%s\n# atrun uid=%d gid=%d\n# mail %s %d\n",
- + shell_path, real_uid, real_gid, mailname, send_mail);
- /* Write out the umask at the time of invocation
- */
- @@ -574,6 +588,7 @@
- struct stat buf;
- struct tm *runtime;
- unsigned long ctm;
- + unsigned int ctmsec;
- char queue;
- long jobno;
- time_t runtimer;
- @@ -600,21 +615,25 @@
- || atverify)
- continue;
- - if (sscanf(dirent->d_name, "%c%5lx%8lx", &queue, &jobno, &ctm) != 3)
- - continue;
- + if (sscanf(dirent->d_name, "%c%5lx%8lx%2u", &queue, &jobno, &ctm, &ctmsec) != 4)
- + {
- + ctmsec = 0;
- + if (sscanf(dirent->d_name, "%c%5lx%8lx", &queue, &jobno, &ctm) != 3)
- + continue;
- + }
- if (atqueue && (queue != atqueue))
- continue;
- - runtimer = 60 * (time_t) ctm;
- + runtimer = (time_t) ctm * 60 + ctmsec;
- runtime = localtime(&runtimer);
- strftime(timestr, TIMESIZE, TIMEFORMAT_POSIX, runtime);
- if ((pwd = getpwuid(buf.st_uid)))
- - printf("%ld\t%s %c %s\n", jobno, timestr, queue, pwd->pw_name);
- + printf("%ld\t%s\tqueue=%c user=%s\n", jobno, timestr, queue, pwd->pw_name);
- else
- - printf("%ld\t%s %c\n", jobno, timestr, queue);
- + printf("%ld\t%s\tqueue=%c\n", jobno, timestr, queue);
- }
- PRIV_END
- }
- @@ -857,8 +876,6 @@
- fprintf(stderr, "invalid date format: %s\n", optarg);
- exit(EXIT_FAILURE);
- }
- - /* drop seconds */
- - timer -= timer % 60;
- break;
- default:
- @@ -937,14 +954,6 @@
- fprintf(stderr, "%s\n", asctime(tm));
- }
- - /* POSIX.2 allows the shell specified by the user's SHELL environment
- - variable, the login shell from the user's password database entry,
- - or /bin/sh to be the command interpreter that processes the at-job.
- - It also alows a warning diagnostic to be printed. Because of the
- - possible variance, we always output the diagnostic. */
- -
- - fprintf(stderr, "warning: commands will be executed using /bin/sh\n");
- -
- writefile(timer, queue);
- break;
Advertisement
Add Comment
Please, Sign In to add comment