[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.27 and 1.28

version 1.27, 2002/05/13 16:12:07 version 1.28, 2002/05/13 18:43:53
Line 76 
Line 76 
   
 char *no_export[] =  char *no_export[] =
 {  {
         "TERM", "TERMCAP", "DISPLAY", "_"          "TERM", "TERMCAP", "DISPLAY", "_", "SHELLOPTS", "BASH_VERSINFO",
           "EUID", "GROUPS", "PPID", "UID", "SSH_AUTH_SOCK", "SSH_AGENT_PID",
 };  };
 static int send_mail = 0;  static int send_mail = 0;
   
Line 175 
Line 176 
          * writing a job.           * writing a job.
          */           */
         int jobno;          int jobno;
         char *ap, *ppos, *mailname;          char *ap, *ppos, *mailname, *shell;
           char timestr[TIMESIZE];
         struct passwd *pass_entry;          struct passwd *pass_entry;
         struct stat statbuf;          struct stat statbuf;
           struct tm runtime;
         int fdes, lockdes, fd2;          int fdes, lockdes, fd2;
         FILE *fp, *fpin;          FILE *fp, *fpin;
         struct sigaction act;          struct sigaction act;
Line 290 
Line 293 
                         mailname = pass_entry->pw_name;                          mailname = pass_entry->pw_name;
         }          }
   
           /*
            * Get the shell to run the job under.  First check $SHELL, falling
            * back to the user's shell in the password database or, failing
            * that, /bin/sh.
            */
           if ((shell = getenv("SHELL")) == NULL || *shell == '\0') {
                   pass_entry = getpwuid(real_uid);
                   if (pass_entry != NULL && *pass_entry->pw_shell != '\0')
                           shell = pass_entry->pw_shell;
                   else
                           shell = _PATH_BSHELL;
           }
   
         if (atinput != NULL) {          if (atinput != NULL) {
                 fpin = freopen(atinput, "r", stdin);                  fpin = freopen(atinput, "r", stdin);
                 if (fpin == NULL)                  if (fpin == NULL)
Line 379 
Line 395 
         if ((ch = getchar()) == EOF)          if ((ch = getchar()) == EOF)
                 panic("Input error");                  panic("Input error");
   
           /* We want the job to run under the user's shell. */
           fprintf(fp, "%s << '_END_OF_AT_JOB'\n", shell);
   
         do {          do {
                 (void)fputc(ch, fp);                  (void)fputc(ch, fp);
         } while ((ch = getchar()) != EOF);          } while ((ch = getchar()) != EOF);
   
         (void)fprintf(fp, "\n");          (void)fprintf(fp, "\n_END_OF_AT_JOB\n");
         if (ferror(fp))          if (ferror(fp))
                 panic("Output error");                  panic("Output error");
   
Line 399 
Line 418 
                 perr("Cannot give away file");                  perr("Cannot give away file");
   
         (void)close(fd2);          (void)close(fd2);
         (void)fprintf(stderr, "Job %d will be executed using /bin/sh\n", jobno);  
           runtime = *localtime(&runtimer);
           strftime(timestr, TIMESIZE, "%a %b %e %T %Y", &runtime);
           (void)fprintf(stderr, "commands will be executed using %s\n", shell);
           (void)fprintf(stderr, "job %d at %s\n", jobno, timestr);
 }  }
   
 static void  static void
Line 468 
Line 491 
         PRIV_END;          PRIV_END;
 }  }
   
 static void  static int
 process_jobs(int argc, char **argv, int what)  process_jobs(int argc, char **argv, int what)
 {  {
         /* Delete every argument (job - ID) given */  
         int i;          int i;
         struct stat buf;          struct stat buf;
         DIR *spool;          DIR *spool;
Line 479 
Line 501 
         unsigned long ctm;          unsigned long ctm;
         char queue;          char queue;
         int jobno;          int jobno;
           int error;
   
         PRIV_START;          PRIV_START;
   
Line 491 
Line 514 
         PRIV_END;          PRIV_END;
   
         /* Loop over every file in the directory */          /* Loop over every file in the directory */
         while((dirent = readdir(spool)) != NULL) {          while ((dirent = readdir(spool)) != NULL) {
   
                 PRIV_START;                  PRIV_START;
                 if (stat(dirent->d_name, &buf) != 0)                  if (stat(dirent->d_name, &buf) != 0)
Line 502 
Line 525 
                         continue;                          continue;
   
                 for (i = optind; i < argc; i++) {                  for (i = optind; i < argc; i++) {
                         if (atoi(argv[i]) == jobno) {                          if (argv[i] != NULL && atoi(argv[i]) == jobno) {
                                   /* Treat wrong owner like unknown job. */
                                 if ((buf.st_uid != real_uid) && !(real_uid == 0))                                  if ((buf.st_uid != real_uid) && !(real_uid == 0))
                                         errx(EXIT_FAILURE,                                          continue;
                                              "%s: Not owner\n", argv[i]);                                  argv[i] = NULL;
                                 switch (what) {                                  switch (what) {
                                 case ATRM:                                  case ATRM:
                                         PRIV_START;                                          PRIV_START;
Line 545 
Line 569 
                         }                          }
                 }                  }
         }          }
 }                               /* delete_jobs */          for (error = 0, i = optind; i < argc; i++) {
                   if (argv[i] != NULL) {
                           warnx("%s: no such job number", argv[i]);
                           error++;
                   }
           }
           return(error);
   }
   
 #define ATOI2(s)        ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))  #define ATOI2(s)        ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
   
Line 730 
Line 761 
         case CAT:          case CAT:
                 if (optind == argc)                  if (optind == argc)
                         usage();                          usage();
                 process_jobs(argc, argv, program);                  exit(process_jobs(argc, argv, program));
                 break;                  break;
   
         case AT:          case AT:

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28