hammer2 - Flush asynchronization, bug fixes, stabilization (2)
[dragonfly.git] / usr.bin / at / at.c
blob1ba8cd575c5f027146204ce798f94d676591b710
1 /*
2 * at.c : Put file into atrun queue
3 * Copyright (C) 1993, 1994 Thomas Koenig
5 * Atrun & Atq modifications
6 * Copyright (C) 1993 David Parsons
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. The name of the author(s) may not be used to endorse or promote
14 * products derived from this software without specific prior written
15 * permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * $FreeBSD: src/usr.bin/at/at.c,v 1.30 2007/09/21 01:55:11 kevlo Exp $
31 #define _USE_BSD 1
33 /* System Headers */
35 #include <sys/param.h>
36 #include <sys/stat.h>
37 #include <sys/time.h>
38 #include <sys/wait.h>
39 #include <ctype.h>
40 #include <dirent.h>
41 #include <err.h>
42 #include <errno.h>
43 #include <fcntl.h>
44 #include <langinfo.h>
45 #include <locale.h>
46 #include <pwd.h>
47 #include <signal.h>
48 #include <stddef.h>
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <string.h>
52 #include <time.h>
53 #include <unistd.h>
55 /* Local headers */
57 #include "at.h"
58 #include "panic.h"
59 #include "parsetime.h"
60 #include "perm.h"
62 #define MAIN
63 #include "privs.h"
65 /* Macros */
67 #ifndef ATJOB_DIR
68 #define ATJOB_DIR "/usr/spool/atjobs/"
69 #endif
71 #ifndef LFILE
72 #define LFILE ATJOB_DIR ".lockfile"
73 #endif
75 #ifndef ATJOB_MX
76 #define ATJOB_MX 255
77 #endif
79 #define ALARMC 10 /* Number of seconds to wait for timeout */
81 #define SIZE 255
82 #define TIMESIZE 50
84 enum { ATQ, ATRM, AT, BATCH, CAT }; /* what program we want to run */
86 /* File scope variables */
88 const char *no_export[] =
90 "TERM", "TERMCAP", "DISPLAY", "_"
91 } ;
92 static int send_mail = 0;
94 /* External variables */
95 uid_t real_uid, effective_uid;
96 gid_t real_gid, effective_gid;
98 extern char **environ;
99 int fcreated;
100 char atfile[sizeof(ATJOB_DIR) + 14] = ATJOB_DIR;
102 char *atinput = NULL; /* where to get input from */
103 char atqueue = 0; /* which queue to examine for jobs (atq) */
104 char atverify = 0; /* verify time instead of queuing job */
105 char *namep;
107 /* Function declarations */
109 static void sigc(int signo);
110 static void alarmc(int signo);
111 static char *cwdname(void);
112 static void writefile(time_t runtimer, char queue);
113 static void list_jobs(long *, int);
114 static long nextjob(void);
115 static time_t ttime(const char *arg);
116 static char * timer2str(time_t runtimer);
117 static int in_job_list(long, long *, int);
118 static long *get_job_list(int, char *[], int *);
120 /* Signal catching functions */
122 static void
123 sigc(int signo __unused)
125 /* If the user presses ^C, remove the spool file and exit
127 if (fcreated)
129 PRIV_START
130 unlink(atfile);
131 PRIV_END
134 _exit(EXIT_FAILURE);
137 static void
138 alarmc(int signo __unused)
140 char buf[1024];
142 /* Time out after some seconds. */
143 strlcpy(buf, namep, sizeof(buf));
144 strlcat(buf, ": file locking timed out\n", sizeof(buf));
145 write(STDERR_FILENO, buf, strlen(buf));
146 sigc(0);
149 /* Local functions */
151 static char *
152 cwdname(void)
154 /* Read in the current directory; the name will be overwritten on
155 * subsequent calls.
157 static char *ptr = NULL;
158 static size_t size = SIZE;
160 if (ptr == NULL)
161 if ((ptr = malloc(size)) == NULL)
162 errx(EXIT_FAILURE, "virtual memory exhausted");
164 while (1)
166 if (ptr == NULL)
167 panic("out of memory");
169 if (getcwd(ptr, size-1) != NULL)
170 return ptr;
172 if (errno != ERANGE)
173 perr("cannot get directory");
175 free (ptr);
176 size += SIZE;
177 if ((ptr = malloc(size)) == NULL)
178 errx(EXIT_FAILURE, "virtual memory exhausted");
182 static long
183 nextjob(void)
185 long jobno;
186 FILE *fid;
188 if ((fid = fopen(ATJOB_DIR ".SEQ", "r+")) != NULL) {
189 if (fscanf(fid, "%5lx", &jobno) == 1) {
190 rewind(fid);
191 jobno = (1+jobno) % 0xfffff; /* 2^20 jobs enough? */
192 fprintf(fid, "%05lx\n", jobno);
194 else
195 jobno = EOF;
196 fclose(fid);
197 return jobno;
199 else if ((fid = fopen(ATJOB_DIR ".SEQ", "w")) != NULL) {
200 fprintf(fid, "%05lx\n", jobno = 1);
201 fclose(fid);
202 return 1;
204 return EOF;
207 static void
208 writefile(time_t runtimer, char queue)
210 /* This does most of the work if at or batch are invoked for writing a job.
212 long jobno;
213 char *ap, *ppos, *mailname;
214 struct passwd *pass_entry;
215 struct stat statbuf;
216 int fdes, lockdes, fd2;
217 FILE *fp, *fpin;
218 struct sigaction act;
219 char **atenv;
220 int ch;
221 mode_t cmask;
222 struct flock lock;
224 setlocale(LC_TIME, "");
226 /* Install the signal handler for SIGINT; terminate after removing the
227 * spool file if necessary
229 act.sa_handler = sigc;
230 sigemptyset(&(act.sa_mask));
231 act.sa_flags = 0;
233 sigaction(SIGINT, &act, NULL);
235 /* Loop over all possible file names for running something at this
236 * particular time, see if a file is there; the first empty slot at any
237 * particular time is used. Lock the file LFILE first to make sure
238 * we're alone when doing this.
241 PRIV_START
243 if ((lockdes = open(LFILE, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR)) < 0)
244 perr("cannot open lockfile " LFILE);
246 lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; lock.l_start = 0;
247 lock.l_len = 0;
249 act.sa_handler = alarmc;
250 sigemptyset(&(act.sa_mask));
251 act.sa_flags = 0;
253 /* Set an alarm so a timeout occurs after ALARMC seconds, in case
254 * something is seriously broken.
256 sigaction(SIGALRM, &act, NULL);
257 alarm(ALARMC);
258 fcntl(lockdes, F_SETLKW, &lock);
259 alarm(0);
261 if ((jobno = nextjob()) == EOF)
262 perr("cannot generate job number");
264 ppos = atfile + strlen(atfile);
265 snprintf(ppos, sizeof(atfile) - strlen(atfile), "%c%5lx%8lx", queue,
266 jobno, (unsigned long) (runtimer/60));
268 for(ap=ppos; *ap != '\0'; ap ++)
269 if (*ap == ' ')
270 *ap = '0';
272 if (stat(atfile, &statbuf) != 0)
273 if (errno != ENOENT)
274 perr("cannot access " ATJOB_DIR);
276 /* Create the file. The x bit is only going to be set after it has
277 * been completely written out, to make sure it is not executed in the
278 * meantime. To make sure they do not get deleted, turn off their r
279 * bit. Yes, this is a kluge.
281 cmask = umask(S_IRUSR | S_IWUSR | S_IXUSR);
282 if ((fdes = creat(atfile, O_WRONLY)) == -1)
283 perr("cannot create atjob file");
285 if ((fd2 = dup(fdes)) <0)
286 perr("error in dup() of job file");
288 if(fchown(fd2, real_uid, real_gid) != 0)
289 perr("cannot give away file");
291 PRIV_END
293 /* We no longer need suid root; now we just need to be able to write
294 * to the directory, if necessary.
297 REDUCE_PRIV(DAEMON_UID, DAEMON_GID)
299 /* We've successfully created the file; let's set the flag so it
300 * gets removed in case of an interrupt or error.
302 fcreated = 1;
304 /* Now we can release the lock, so other people can access it
306 lock.l_type = F_UNLCK; lock.l_whence = SEEK_SET; lock.l_start = 0;
307 lock.l_len = 0;
308 fcntl(lockdes, F_SETLKW, &lock);
309 close(lockdes);
311 if((fp = fdopen(fdes, "w")) == NULL)
312 panic("cannot reopen atjob file");
314 /* Get the userid to mail to, first by trying getlogin(),
315 * then from LOGNAME, finally from getpwuid().
317 mailname = getlogin();
318 if (mailname == NULL)
319 mailname = getenv("LOGNAME");
321 if ((mailname == NULL) || (mailname[0] == '\0')
322 || (strlen(mailname) >= MAXLOGNAME) || (getpwnam(mailname)==NULL))
324 pass_entry = getpwuid(real_uid);
325 if (pass_entry != NULL)
326 mailname = pass_entry->pw_name;
329 if (atinput != NULL)
331 fpin = freopen(atinput, "r", stdin);
332 if (fpin == NULL)
333 perr("cannot open input file");
335 fprintf(fp, "#!/bin/sh\n# atrun uid=%ld gid=%ld\n# mail %*s %d\n",
336 (long) real_uid, (long) real_gid, MAXLOGNAME - 1, mailname,
337 send_mail);
339 /* Write out the umask at the time of invocation
341 fprintf(fp, "umask %lo\n", (unsigned long) cmask);
343 /* Write out the environment. Anything that may look like a
344 * special character to the shell is quoted, except for \n, which is
345 * done with a pair of "'s. Don't export the no_export list (such
346 * as TERM or DISPLAY) because we don't want these.
348 for (atenv= environ; *atenv != NULL; atenv++)
350 int export = 1;
351 char *eqp;
353 eqp = strchr(*atenv, '=');
354 if (ap == NULL)
355 eqp = *atenv;
356 else
358 size_t i;
359 for (i=0; i<NELEM(no_export); i++)
361 export = export
362 && (strncmp(*atenv, no_export[i],
363 (size_t) (eqp-*atenv)) != 0);
365 eqp++;
368 if (export)
370 fwrite(*atenv, sizeof(char), eqp-*atenv, fp);
371 for(ap = eqp;*ap != '\0'; ap++)
373 if (*ap == '\n')
374 fprintf(fp, "\"\n\"");
375 else
377 if (!isalnum(*ap)) {
378 switch (*ap) {
379 case '%': case '/': case '{': case '[':
380 case ']': case '=': case '}': case '@':
381 case '+': case '#': case ',': case '.':
382 case ':': case '-': case '_':
383 break;
384 default:
385 fputc('\\', fp);
386 break;
389 fputc(*ap, fp);
392 fputs("; export ", fp);
393 fwrite(*atenv, sizeof(char), eqp-*atenv -1, fp);
394 fputc('\n', fp);
398 /* Cd to the directory at the time and write out all the
399 * commands the user supplies from stdin.
401 fprintf(fp, "cd ");
402 for (ap = cwdname(); *ap != '\0'; ap++)
404 if (*ap == '\n')
405 fprintf(fp, "\"\n\"");
406 else
408 if (*ap != '/' && !isalnum(*ap))
409 fputc('\\', fp);
411 fputc(*ap, fp);
414 /* Test cd's exit status: die if the original directory has been
415 * removed, become unreadable or whatever
417 fprintf(fp, " || {\n\t echo 'Execution directory "
418 "inaccessible' >&2\n\t exit 1\n}\n");
420 while((ch = getchar()) != EOF)
421 fputc(ch, fp);
423 fprintf(fp, "\n");
424 if (ferror(fp))
425 panic("output error");
427 if (ferror(stdin))
428 panic("input error");
430 fclose(fp);
432 /* Set the x bit so that we're ready to start executing
435 if (fchmod(fd2, S_IRUSR | S_IWUSR | S_IXUSR) < 0)
436 perr("cannot give away file");
438 close(fd2);
440 /* Print output. */
441 char *timestr = timer2str(runtimer);
443 fprintf(stderr, "Job %ld will be executed using /bin/sh\n", jobno);
444 fprintf(stderr, "Job %ld at %s\n", jobno, timestr);
445 free(timestr);
448 static int
449 in_job_list(long job, long *joblist, int len)
451 int i;
453 for (i = 0; i < len; i++)
454 if (job == joblist[i])
455 return 1;
457 return 0;
460 static void
461 list_jobs(long *joblist, int len)
463 /* List all a user's jobs in the queue, by looping through ATJOB_DIR,
464 * or everybody's if we are root
466 struct passwd *pw;
467 DIR *spool;
468 struct dirent *dirent;
469 struct stat buf;
470 unsigned long ctm;
471 char queue;
472 long jobno;
473 time_t runtimer;
474 char *timestr;
475 int first=1;
477 setlocale(LC_TIME, "");
479 PRIV_START
481 if (chdir(ATJOB_DIR) != 0)
482 perr("cannot change to " ATJOB_DIR);
484 if ((spool = opendir(".")) == NULL)
485 perr("cannot open " ATJOB_DIR);
487 /* Loop over every file in the directory
489 while((dirent = readdir(spool)) != NULL) {
490 if (stat(dirent->d_name, &buf) != 0)
491 perr("cannot stat in " ATJOB_DIR);
493 /* See it's a regular file and has its x bit turned on and
494 * is the user's
496 if (!S_ISREG(buf.st_mode)
497 || ((buf.st_uid != real_uid) && ! (real_uid == 0))
498 || !(S_IXUSR & buf.st_mode || atverify))
499 continue;
501 if(sscanf(dirent->d_name, "%c%5lx%8lx", &queue, &jobno, &ctm)!=3)
502 continue;
504 /* If jobs are given, only list those jobs */
505 if (joblist && !in_job_list(jobno, joblist, len))
506 continue;
508 if (atqueue && (queue != atqueue))
509 continue;
511 /* Get datetime */
512 runtimer = 60*(time_t) ctm;
513 timestr = timer2str(runtimer);
515 /* Look up owner's uid in password database file */
516 pw = getpwuid(buf.st_uid);
518 if (first) {
519 printf("Date\t\t\t\tOwner\t\tQueue\tJob#\n");
520 first=0;
522 printf("%s\t%-16s%c%s\t%ld\n",
523 timestr,
524 pw ? pw->pw_name : "???",
525 queue,
526 (S_IXUSR & buf.st_mode) ? "":"(done)",
527 jobno);
528 free(timestr);
530 closedir(spool);
532 PRIV_END
535 static void
536 process_jobs(int argc, char **argv, int what)
538 /* Delete every argument (job - ID) given
540 int i;
541 struct stat buf;
542 DIR *spool;
543 struct dirent *dirent;
544 unsigned long ctm;
545 char queue;
546 long jobno;
548 PRIV_START
550 if (chdir(ATJOB_DIR) != 0)
551 perr("cannot change to " ATJOB_DIR);
553 if ((spool = opendir(".")) == NULL)
554 perr("cannot open " ATJOB_DIR);
556 PRIV_END
558 /* Loop over every file in the directory
560 while((dirent = readdir(spool)) != NULL) {
562 PRIV_START
563 if (stat(dirent->d_name, &buf) != 0)
564 perr("cannot stat in " ATJOB_DIR);
565 PRIV_END
567 if(sscanf(dirent->d_name, "%c%5lx%8lx", &queue, &jobno, &ctm)!=3)
568 continue;
570 for (i=optind; i < argc; i++) {
571 if (atoi(argv[i]) == jobno) {
572 if ((buf.st_uid != real_uid) && !(real_uid == 0))
573 errx(EXIT_FAILURE, "%s: not owner", argv[i]);
574 switch (what) {
575 case ATRM:
577 PRIV_START
579 if (unlink(dirent->d_name) != 0)
580 perr(dirent->d_name);
582 PRIV_END
584 break;
586 case CAT:
588 FILE *fp;
589 int ch;
591 PRIV_START
593 fp = fopen(dirent->d_name,"r");
595 PRIV_END
597 if (!fp) {
598 perr("cannot open file");
600 while((ch = getc(fp)) != EOF) {
601 putchar(ch);
603 fclose(fp);
605 break;
607 default:
608 errx(EXIT_FAILURE, "internal error, process_jobs = %d",
609 what);
614 closedir(spool);
615 } /* delete_jobs */
617 #define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
619 static time_t
620 ttime(const char *arg)
623 * This is pretty much a copy of stime_arg1() from touch.c. I changed
624 * the return value and the argument list because it's more convenient
625 * (IMO) to do everything in one place. - Joe Halpin
627 struct timeval tv[2];
628 time_t now;
629 struct tm *t;
630 int yearset;
631 char *p;
633 if (gettimeofday(&tv[0], NULL))
634 panic("Cannot get current time");
636 /* Start with the current time. */
637 now = tv[0].tv_sec;
638 if ((t = localtime(&now)) == NULL)
639 panic("localtime");
640 /* [[CC]YY]MMDDhhmm[.SS] */
641 if ((p = strchr(arg, '.')) == NULL)
642 t->tm_sec = 0; /* Seconds defaults to 0. */
643 else {
644 if (strlen(p + 1) != 2)
645 goto terr;
646 *p++ = '\0';
647 t->tm_sec = ATOI2(p);
650 yearset = 0;
651 switch(strlen(arg)) {
652 case 12: /* CCYYMMDDhhmm */
653 t->tm_year = ATOI2(arg);
654 t->tm_year *= 100;
655 yearset = 1;
656 /* FALLTHROUGH */
657 case 10: /* YYMMDDhhmm */
658 if (yearset) {
659 yearset = ATOI2(arg);
660 t->tm_year += yearset;
661 } else {
662 yearset = ATOI2(arg);
663 t->tm_year = yearset + 2000;
665 t->tm_year -= 1900; /* Convert to UNIX time. */
666 /* FALLTHROUGH */
667 case 8: /* MMDDhhmm */
668 t->tm_mon = ATOI2(arg);
669 --t->tm_mon; /* Convert from 01-12 to 00-11 */
670 t->tm_mday = ATOI2(arg);
671 t->tm_hour = ATOI2(arg);
672 t->tm_min = ATOI2(arg);
673 break;
674 default:
675 goto terr;
678 t->tm_isdst = -1; /* Figure out DST. */
679 tv[0].tv_sec = tv[1].tv_sec = mktime(t);
680 if (tv[0].tv_sec != -1)
681 return tv[0].tv_sec;
682 else
683 terr:
684 panic(
685 "out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]");
688 /* The caller must free up the memory. */
689 static char *
690 timer2str(time_t runtimer)
692 struct tm runtime;
693 char *timestr;
694 size_t rv;
696 timestr = malloc(TIMESIZE);
697 if (timestr == NULL)
698 panic("out of memory");
700 runtime = *localtime(&runtimer);
701 rv = strftime(timestr, TIMESIZE, nl_langinfo(D_T_FMT), &runtime);
702 if (rv == 0)
703 panic("TIMESIZE too low");
705 return (timestr);
708 static long *
709 get_job_list(int argc, char *argv[], int *joblen)
711 int i, len;
712 long *joblist;
713 char *ep;
715 joblist = NULL;
716 len = argc;
717 if (len > 0) {
718 if ((joblist = malloc(len * sizeof(*joblist))) == NULL)
719 panic("out of memory");
721 for (i = 0; i < argc; i++) {
722 errno = 0;
723 if ((joblist[i] = strtol(argv[i], &ep, 10)) < 0 ||
724 ep == argv[i] || *ep != '\0' || errno)
725 panic("invalid job number");
729 *joblen = len;
730 return joblist;
734 main(int argc, char **argv)
736 int c;
737 char queue = DEFAULT_AT_QUEUE;
738 char queue_set = 0;
739 char *pgm;
741 int program = AT; /* our default program */
742 const char *options = "q:f:t:rmvldbc"; /* default options for at */
743 time_t timer;
744 long *joblist;
745 int joblen;
747 joblist = NULL;
748 joblen = 0;
749 timer = -1;
750 RELINQUISH_PRIVS
752 /* Eat any leading paths
754 if ((pgm = strrchr(argv[0], '/')) == NULL)
755 pgm = argv[0];
756 else
757 pgm++;
759 namep = pgm;
761 /* find out what this program is supposed to do
763 if (strcmp(pgm, "atq") == 0) {
764 program = ATQ;
765 options = "q:v";
767 else if (strcmp(pgm, "atrm") == 0) {
768 program = ATRM;
769 options = "";
771 else if (strcmp(pgm, "batch") == 0) {
772 program = BATCH;
773 options = "f:q:mv";
776 /* process whatever options we can process
778 opterr=1;
779 while ((c=getopt(argc, argv, options)) != -1)
780 switch (c) {
781 case 'v': /* verify time settings */
782 atverify = 1;
783 break;
785 case 'm': /* send mail when job is complete */
786 send_mail = 1;
787 break;
789 case 'f':
790 atinput = optarg;
791 break;
793 case 'q': /* specify queue */
794 if (strlen(optarg) > 1)
795 usage();
797 atqueue = queue = *optarg;
798 if (!(islower(queue)||isupper(queue)))
799 usage();
801 queue_set = 1;
802 break;
804 case 'd':
805 warnx("-d is deprecated; use -r instead");
806 /* FALLTHROUGH */
808 case 'r':
809 if (program != AT)
810 usage();
812 program = ATRM;
813 options = "";
814 break;
816 case 't':
817 if (program != AT)
818 usage();
819 timer = ttime(optarg);
820 break;
822 case 'l':
823 if (program != AT)
824 usage();
826 program = ATQ;
827 options = "q:";
828 break;
830 case 'b':
831 if (program != AT)
832 usage();
834 program = BATCH;
835 options = "f:q:mv";
836 break;
838 case 'c':
839 program = CAT;
840 options = "";
841 break;
843 default:
844 usage();
845 break;
847 /* end of options eating
850 /* select our program
852 if(!check_permission())
853 errx(EXIT_FAILURE, "you do not have permission to use this program");
854 switch (program) {
855 case ATQ:
857 REDUCE_PRIV(DAEMON_UID, DAEMON_GID)
859 if (queue_set == 0)
860 joblist = get_job_list(argc - optind, argv + optind, &joblen);
861 list_jobs(joblist, joblen);
862 break;
864 case ATRM:
866 REDUCE_PRIV(DAEMON_UID, DAEMON_GID)
868 process_jobs(argc, argv, ATRM);
869 break;
871 case CAT:
873 process_jobs(argc, argv, CAT);
874 break;
876 case AT:
878 * If timer is > -1, then the user gave the time with -t. In that
879 * case, it's already been set. If not, set it now.
881 if (timer == -1)
882 timer = parsetime(argc, argv);
884 if (atverify)
886 struct tm *tm = localtime(&timer);
887 fprintf(stderr, "%s\n", asctime(tm));
889 writefile(timer, queue);
890 break;
892 case BATCH:
893 if (queue_set)
894 queue = toupper(queue);
895 else
896 queue = DEFAULT_BATCH_QUEUE;
898 if (argc > optind)
899 timer = parsetime(argc, argv);
900 else
901 timer = time(NULL);
903 if (atverify)
905 struct tm *tm = localtime(&timer);
906 fprintf(stderr, "%s\n", asctime(tm));
909 writefile(timer, queue);
910 break;
912 default:
913 panic("internal error");
914 break;
916 exit(EXIT_SUCCESS);