[BACK]Return to at.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / at

Diff for /src/usr.bin/at/at.c between version 1.29 and 1.30

version 1.29, 2002/05/14 18:05:39 version 1.30, 2002/07/15 19:13:29
Line 33 
Line 33 
  */   */
   
 #include <sys/param.h>  #include <sys/param.h>
   #include <sys/socket.h>
 #include <sys/stat.h>  #include <sys/stat.h>
 #include <sys/time.h>  #include <sys/time.h>
   #include <sys/un.h>
   
 #include <ctype.h>  #include <ctype.h>
 #include <dirent.h>  #include <dirent.h>
 #include <err.h>  #include <err.h>
Line 49 
Line 52 
 #include <string.h>  #include <string.h>
 #include <time.h>  #include <time.h>
 #include <unistd.h>  #include <unistd.h>
   #include <utime.h>
 #include <utmp.h>  #include <utmp.h>
   
 #if (MAXLOGNAME-1) > UT_NAMESIZE  #if (MAXLOGNAME-1) > UT_NAMESIZE
Line 93 
Line 97 
 static void alarmc(int);  static void alarmc(int);
 static void writefile(time_t, char);  static void writefile(time_t, char);
 static void list_jobs(int, char **, int, int);  static void list_jobs(int, char **, int, int);
   static void poke_daemon(void);
 static time_t ttime(const char *);  static time_t ttime(const char *);
   
 static void  static void
Line 260 
Line 265 
                 if (fpin == NULL)                  if (fpin == NULL)
                         perr("Cannot open input file");                          perr("Cannot open input file");
         }          }
         (void)fprintf(fp, "#!/bin/sh\n# atrun uid=%u gid=%u\n# mail %*s %d\n",          (void)fprintf(fp, "#!/bin/sh\n# atrun uid=%ld gid=%ld\n# mail %*s %d\n",
             real_uid, real_gid, LOGNAMESIZE, mailname, send_mail);              (long)real_uid, (long)real_gid, LOGNAMESIZE, mailname, send_mail);
   
         /* Write out the umask at the time of invocation */          /* Write out the umask at the time of invocation */
         (void)fprintf(fp, "umask %o\n", cmask);          (void)fprintf(fp, "umask %o\n", cmask);
Line 369 
Line 374 
   
         (void)close(fd2);          (void)close(fd2);
   
           /* Poke cron so it knows to reload the at spool. */
           poke_daemon();
   
         runtime = *localtime(&runtimer);          runtime = *localtime(&runtimer);
         strftime(timestr, TIMESIZE, "%a %b %e %T %Y", &runtime);          strftime(timestr, TIMESIZE, "%a %b %e %T %Y", &runtime);
         (void)fprintf(stderr, "commands will be executed using %s\n", shell);          (void)fprintf(stderr, "commands will be executed using %s\n", shell);
Line 604 
Line 612 
         FILE *fp;          FILE *fp;
         DIR *spool;          DIR *spool;
         int job_matches, jobs_len, uids_len;          int job_matches, jobs_len, uids_len;
         int error, i, ch;          int error, i, ch, changed;
   
         PRIV_START;          PRIV_START;
   
Line 644 
Line 652 
         }          }
   
         /* Loop over every file in the directory */          /* Loop over every file in the directory */
           changed = 0;
         while ((dirent = readdir(spool)) != NULL) {          while ((dirent = readdir(spool)) != NULL) {
   
                 PRIV_START;                  PRIV_START;
Line 688 
Line 697 
   
                                 if (!interactive ||                                  if (!interactive ||
                                     (interactive && rmok(runtimer))) {                                      (interactive && rmok(runtimer))) {
                                         if (unlink(dirent->d_name) != 0)                                          if (unlink(dirent->d_name) == 0)
                                                   changed = 1;
                                           else
                                                 perr(dirent->d_name);                                                  perr(dirent->d_name);
                                         if (!force && !interactive)                                          if (!force && !interactive)
                                                 fprintf(stderr,                                                  fprintf(stderr,
Line 733 
Line 744 
         free(jobs);          free(jobs);
         free(uids);          free(uids);
   
           /* If we modied the spool, poke cron so it knows to reload. */
           if (changed)
                   poke_daemon();
   
         return (error);          return (error);
 }  }
   
Line 803 
Line 818 
     terr:      terr:
                 panic("out of range or illegal time specification: "                  panic("out of range or illegal time specification: "
                     "[[CC]YY]MMDDhhmm[.SS]");                      "[[CC]YY]MMDDhhmm[.SS]");
   }
   
   #define RELOAD_AT       0x4     /* XXX - from cron's macros.h */
   
   /* XXX - share with crontab */
   static void
   poke_daemon() {
           int sock, flags;
           unsigned char poke;
           struct sockaddr_un sun;
   
           PRIV_START;
   
           if (utime(_PATH_ATJOBS, NULL) < 0) {
                   warn("can't update mtime on %s", _PATH_ATJOBS);
                   PRIV_END;
                   return;
           }
   
           /* Failure to poke the daemon socket is not a fatal error. */
           (void) signal(SIGPIPE, SIG_IGN);
           strlcpy(sun.sun_path, CRONDIR "/" SPOOL_DIR "/" CRONSOCK,
               sizeof(sun.sun_path));
           sun.sun_family = AF_UNIX;
           sun.sun_len = strlen(sun.sun_path);
           if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0 &&
               connect(sock, (struct sockaddr *)&sun, sizeof(sun)) == 0) {
                   poke = RELOAD_AT;
                   write(sock, &poke, 1);
                   close(sock);
           } else
                   fprintf(stderr, "Warning, cron does not appear to be running.\n");
           (void) signal(SIGPIPE, SIG_DFL);
   
           PRIV_END;
 }  }
   
 int  int

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30