Print this page
5433 at(1) doesn't properly handle being invoked from a path containing spaces
        
*** 99,108 ****
--- 99,109 ----
  static void atime(struct tm *, struct tm *);
  static int not_this_project(char *);
  static char *mkjobname(time_t);
  static time_t parse_time(char *);
  static time_t gtime(struct tm *);
+ static void escapestr(char *);
  void atabort(char *)__NORETURN;
  void yyerror(void);
  extern int yyparse(void);
  
  extern void     audit_at_delete(char *, char *, int);
*** 544,553 ****
--- 545,571 ----
          tv = 60 * tv + tptr->tm_sec;
          return (tv);
  }
  
  /*
+  * Escape a string to be used inside the job shell script.
+  */
+ static void
+ escapestr(char *str)
+ {
+         char c;
+         putchar('\'');
+         while ((c = *str++) != '\0') {
+                 if (c != '\'')
+                         putchar(c);
+                 else
+                         printf("\'\\\'\'"); /* ' -> '\'' */
+         }
+         putchar('\'');
+ }
+ 
+ /*
   * make job file from proto + stdin
   */
  static void
  copy(char *jobfile, FILE *inputfile, int when)
  {
*** 676,686 ****
                          }
                          /* change back afterwards */
                          if (seteuid(effeusr) < 0) {
                                  atabort(CANTCHUID);
                          }
!                         printf("%s", dirbuf);
                          break;
                  case 'm':
                          printf("%o", um);
                          break;
                  case '<':
--- 694,704 ----
                          }
                          /* change back afterwards */
                          if (seteuid(effeusr) < 0) {
                                  atabort(CANTCHUID);
                          }
!                         escapestr(dirbuf);
                          break;
                  case 'm':
                          printf("%o", um);
                          break;
                  case '<':