home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume27 / vixie-cron / patch01 < prev    next >
Text File  |  1994-01-25  |  15KB  |  409 lines

  1. Newsgroups: comp.sources.unix
  2. From: paul@vix.com (Paul Vixie)
  3. Subject: v27i206: vixie-cron - Vixie's Cron, V3.0, Patch01
  4. Sender: unix-sources-moderator@gw.home.vix.com
  5. Approved: vixie@gw.home.vix.com
  6.  
  7. Submitted-By: paul@vix.com (Paul Vixie)
  8. Posting-Number: Volume 27, Issue 206
  9. Archive-Name: vixie-cron/patch01
  10.  
  11. This is Patch01 to Cron-3.0.  Please apply it.  Changes are:
  12.  
  13.     Some of the documentation has been reformatted to fit in 80 char lines;
  14.     it has also been corrected on some NeXT system and general environment
  15.     variable details.
  16.  
  17.     The EDITOR (or VISUAL) environment variable is now allowed to have
  18.     multiple tokens in it when running "crontab -e".
  19.  
  20.     Some more code has been reformatted to the BSD style.
  21.  
  22.     A bug was fixed in the way environment variables were searched.
  23.  
  24. I do not expect to release another Cron patch for a long time.  I have finished
  25. everything I wanted to do for 3.0, and this patch represents the final touches
  26. on recently added features.
  27.  
  28. *** /tmp/RCSA015433    Tue Jan 25 18:20:06 1994
  29. --- CHANGES    Tue Jan 25 17:59:31 1994
  30. ***************
  31. *** 32,62 ****
  32.   V2, chances are good that V3 will fix your problems.
  33.   
  34. ! About a dozen people have reminded me that I forgot to initialize "crontab_fd"
  35. ! in database.c.  Keith Cantrell was the first, so he gets the point.
  36.   
  37. - Steve Simmons reminded me that once an account has been deleted from the system,
  38. - "crontab -u USER -d" will not work.  My solution is to suggest to all of you that
  39. - before you delete a user's account, you first delete that user's crontab file if
  40. - any.  From cron's point of view, usernames can never be treated as arbitrary
  41. - strings.  Either they are valid user names, or they are not.  I will not make
  42. - an exception for the "-d" case, for security reasons that I consider reasonable.
  43. - It is trivial for a root user to delete the entry by hand if necessary.
  44. - Dan O'Neil reminded me that I forgot to reset "log_fd" in misc.c.  A lot of others
  45. - also reminded me of this, but Dan gets the point.  I didn't fix it there, since the
  46. - real bug was that it should have been open in the parent.
  47. - Peter Kabal reminded me that I forgot to "#ifdef DEBUGGING" some code in misc.c.
  48. - Hans Trompert actually told me first, but Peter sent the patch so he gets the point.
  49.   Russell Nelson told me that I'd forgotten to "#include <syslog.h>" in misc.c,
  50. ! which explains why a lot of other people complained that it wasn't using syslog
  51. ! even when they configured it that way :-).  Steve Simmons told me first, though,
  52. ! so he gets the point.
  53. ! An interrim version of the daemon tried to "stat" every file before executing it;
  54. ! this turned out to be a horribly bad idea since finding the name of a file from
  55. ! a shell command is a hard job (that's why we have shells, right?)  I removed this
  56. ! bogus code.  Dave Burgess gets the point.
  57.   
  58.   Dennis R. Conley sent a suggestion for MMDF systems, which I've added to the
  59. --- 32,65 ----
  60.   V2, chances are good that V3 will fix your problems.
  61.   
  62. ! About a dozen people have reminded me that I forgot to initialize
  63. ! "crontab_fd" in database.c.  Keith Cantrell was the first, so he gets the
  64. ! point.
  65. ! Steve Simmons reminded me that once an account has been deleted from the
  66. ! system, "crontab -u USER -d" will not work.  My solution is to suggest to
  67. ! all of you that before you delete a user's account, you first delete that
  68. ! user's crontab file if any.  From cron's point of view, usernames can never
  69. ! be treated as arbitrary strings.  Either they are valid user names, or they
  70. ! are not.  I will not make an exception for the "-d" case, for security
  71. ! reasons that I consider reasonable.  It is trivial for a root user to delete
  72. ! the entry by hand if necessary.
  73. ! Dan O'Neil reminded me that I forgot to reset "log_fd" in misc.c.  A lot of
  74. ! others also reminded me of this, but Dan gets the point.  I didn't fix it
  75. ! there, since the real bug was that it should have been open in the parent.
  76. ! Peter Kabal reminded me that I forgot to "#ifdef DEBUGGING" some code in
  77. ! misc.c.  Hans Trompert actually told me first, but Peter sent the patch so
  78. ! he gets the point.
  79.   
  80.   Russell Nelson told me that I'd forgotten to "#include <syslog.h>" in misc.c,
  81. ! which explains why a lot of other people complained that it wasn't using
  82. ! syslog even when they configured it that way :-).  Steve Simmons told me
  83. ! first, though, so he gets the point.
  84. ! An interrim version of the daemon tried to "stat" every file before
  85. ! executing it; this turned out to be a horribly bad idea since finding the
  86. ! name of a file from a shell command is a hard job (that's why we have
  87. ! shells, right?)  I removed this bogus code.  Dave Burgess gets the point.
  88.   
  89.   Dennis R. Conley sent a suggestion for MMDF systems, which I've added to the
  90. ***************
  91. *** 63,80 ****
  92.   comments in cron.h.
  93.   
  94. ! Mike Heisler noted that I use comments in the CONVERSION file which are documented
  95. ! as illegal in the man pages.  Thanks, Mike.
  96.   
  97. ! Irving Wolfe sent me some very cheerful changes for a NeXT system, but I consider
  98. ! the system itself broken and I can't bring myself to #ifdef for something as screwed
  99. ! up as this system seems to be.  Sorry, NeXT users -- pray for POSIX.  Irving also
  100. ! asked for a per-job MAILTO, but the syntactic overkill that would require is more
  101. ! than I'm willing to add.  Remember, on BSD4.2, cron was a 12K daemon.  My cron is
  102. ! about ten times that size already.
  103. ! Lots of folks complained that the autogenerated "Date:" header wasn't in ARPA format.
  104. ! I didn't understand this -- either folks will use Sendmail and not generate a Date:
  105. ! at all (since Sendmail will do it), or folks will use something other than Sendmail
  106. ! which won't care about Date: formats.  But I've "fixed" it anyway...
  107.   
  108.   Several people suggested that "*" should be able to take a "/step".  One person
  109. --- 66,86 ----
  110.   comments in cron.h.
  111.   
  112. ! Mike Heisler noted that I use comments in the CONVERSION file which are
  113. ! documented as illegal in the man pages.  Thanks, Mike.
  114.   
  115. ! Irving Wolfe sent me some very cheerful changes for a NeXT system, but I
  116. ! consider the system itself broken and I can't bring myself to #ifdef for
  117. ! something as screwed up as this system seems to be.  However, various others
  118. ! did send me smaller patches which appear to have cause cron to build and run
  119. ! correctly on (the latest) NeXT machines, with or without the "-posix" CFLAG.
  120. ! Irving also asked for a per-job MAILTO, and this was finally added later when
  121. ! I integrated the BSD/386 changes contributed by BSDi, and generalized some of
  122. ! the parsing.
  123. ! Lots of folks complained that the autogenerated "Date:" header wasn't in
  124. ! ARPA format.  I didn't understand this -- either folks will use Sendmail and
  125. ! not generate a Date:  at all (since Sendmail will do it), or folks will use
  126. ! something other than Sendmail which won't care about Date: formats.  But
  127. ! I've "fixed" it anyway...
  128.   
  129.   Several people suggested that "*" should be able to take a "/step".  One person
  130. *** /tmp/RCSA015433    Tue Jan 25 18:20:06 1994
  131. --- FEATURES    Tue Jan 25 17:56:29 1994
  132. ***************
  133. *** 4,9 ****
  134.   
  135.   --    Environment variables can be set in each crontab.  SHELL, USER,
  136. !     and HOME are set from the user's passwd entry; all except USER
  137. !     can be changed in the crontab.  PATH is especially useful to
  138.       set there.  TZ can be set, but cron ignores it other than passing
  139.       it on through to the commands it runs.  Format is
  140. --- 4,9 ----
  141.   
  142.   --    Environment variables can be set in each crontab.  SHELL, USER,
  143. !     LOGNAME, and HOME are set from the user's passwd entry; all except
  144. !     USER can be changed in the crontab.  PATH is especially useful to
  145.       set there.  TZ can be set, but cron ignores it other than passing
  146.       it on through to the commands it runs.  Format is
  147. ***************
  148. *** 19,31 ****
  149.           FOOBAR = this is a long blanky example
  150.   
  151. !     Above, FOOBAR would get `this is a long blanky example' as its value.
  152.   
  153. !     SHELL and HOME will be examined when it's time to run a command; if
  154. !     you don't change them, they default to your /etc/passwd entry.
  155.   
  156. -     *DANGER*, WILL ROBINSON! This means that all 'uucp' logins should set
  157. -     SHELL=/bin/sh or cron will try to use /usr/lib/uucp/uucico as the
  158. -     shell.  This won't work.
  159.       MAILTO, if set to the login name of a user on your system, will be the
  160.       person that cron mails the output of commands in that crontab.  This is
  161. --- 19,28 ----
  162.           FOOBAR = this is a long blanky example
  163.   
  164. !     Above, FOOBAR would get "this is a long blanky example" as its value.
  165.   
  166. !     SHELL and HOME will be used when it's time to run a command; if
  167. !     you don't set them, HOME defaults to your /etc/passwd entry
  168. !     and SHELL defaults to /bin/sh.
  169.   
  170.       MAILTO, if set to the login name of a user on your system, will be the
  171.       person that cron mails the output of commands in that crontab.  This is
  172. ***************
  173. *** 33,40 ****
  174.       doesn't know anything about aliasing.
  175.   
  176. -     Setting SHELL=/bin/sh will in general speed up your commands since it
  177. -     is a much smaller shell than the one you probably use normally (csh
  178. -     or ksh) and has enough features to work non-interactively.
  179.   --    Weekdays can be specified by name.  Case is not significant, but only
  180.       the first three letters should be specified.
  181. --- 30,33 ----
  182. ***************
  183. *** 63,68 ****
  184.       a '#' introduces the comment.
  185.   
  186. ! --    (big win) If the `crontab' command changes anything in any crontab, it
  187. !     tells the 'cron' daemon, who reloads all the tables before running the
  188.       next iteration.  In some crons, you have to kill and restart the
  189.       daemon whenever you change a crontab.  In other crons, the crontab
  190. --- 56,61 ----
  191.       a '#' introduces the comment.
  192.   
  193. ! --    (big win) If the `crontab' command changes anything in any crontab,
  194. !     the 'cron' daemon will reload all the tables before running the
  195.       next iteration.  In some crons, you have to kill and restart the
  196.       daemon whenever you change a crontab.  In other crons, the crontab
  197. ***************
  198. *** 86,88 ****
  199.       is why we keep 'e->dow_star' and 'e->dom_star'.  I didn't think up
  200.       this behaviour; it's how cron has always worked but the documentation
  201. !     hasn't been very clear.
  202. --- 79,84 ----
  203.       is why we keep 'e->dow_star' and 'e->dom_star'.  I didn't think up
  204.       this behaviour; it's how cron has always worked but the documentation
  205. !     hasn't been very clear.  I have been told that some AT&T crons do not
  206. !     act this way and do the more reasonable thing, which is (IMHO) to "or"
  207. !     the various field-matches together.  In that sense this cron may not
  208. !     be completely similar to some AT&T crons.
  209. *** /tmp/RCSA015433    Tue Jan 25 18:20:07 1994
  210. --- crontab.5    Tue Jan 25 18:19:34 1994
  211. ***************
  212. *** 18,22 ****
  213.   .\" $Id: crontab.5,v 2.4 1994/01/15 20:43:43 vixie Exp vixie $
  214.   .\" 
  215. ! .TH CRONTAB 5 "7 January 1994"
  216.   .UC 4
  217.   .SH NAME
  218. --- 18,22 ----
  219.   .\" $Id: crontab.5,v 2.4 1994/01/15 20:43:43 vixie Exp vixie $
  220.   .\" 
  221. ! .TH CRONTAB 5 "24 January 1994"
  222.   .UC 4
  223.   .SH NAME
  224. ***************
  225. *** 78,81 ****
  226. --- 78,82 ----
  227.   The format of a cron command is very much the V7 standard, with a number of
  228.   upward-compatible extensions.  Each line has five time and date fields,
  229. + followed by a user name if this is the system crontab file,
  230.   followed by a command.  Commands are executed by
  231.   .IR cron (8)
  232. ***************
  233. *** 130,134 ****
  234.   run.
  235.   The entire command portion of the line, up to a newline or %
  236. ! character, will be executed by the user's login shell or by the shell
  237.   specified in the SHELL variable of the cronfile.
  238.   Percent-signs (%) in the command, unless escaped with backslash
  239. --- 131,135 ----
  240.   run.
  241.   The entire command portion of the line, up to a newline or %
  242. ! character, will be executed by /bin/sh or by the shell
  243.   specified in the SHELL variable of the cronfile.
  244.   Percent-signs (%) in the command, unless escaped with backslash
  245. *** /tmp/RCSA015433    Tue Jan 25 18:20:07 1994
  246. --- crontab.c    Tue Jan 25 18:09:17 1994
  247. ***************
  248. *** 405,409 ****
  249.               exit(ERROR_EXIT);
  250.           }
  251. !         execlp(editor, editor, Filename, NULL);
  252.           perror(editor);
  253.           exit(ERROR_EXIT);
  254. --- 405,415 ----
  255.               exit(ERROR_EXIT);
  256.           }
  257. !         if (strlen(editor) + strlen(Filename) + 2 >= MAX_TEMPSTR) {
  258. !             fprintf(stderr, "%s: editor or filename too long\n",
  259. !                 ProgramName);
  260. !             exit(ERROR_EXIT);
  261. !         }
  262. !         sprintf(q, "%s %s", editor, Filename);
  263. !         execlp(_PATH_BSHELL, _PATH_BSHELL, "-c", q, NULL);
  264.           perror(editor);
  265.           exit(ERROR_EXIT);
  266. *** /tmp/RCSA017615    Tue Jan 25 20:00:53 1994
  267. --- env.c    Tue Jan 25 19:58:50 1994
  268. ***************
  269. *** 17,21 ****
  270.   
  271.   #if !defined(lint) && !defined(LINT)
  272. ! static char rcsid[] = "$Id: env.c,v 2.6 1994/01/15 20:43:43 vixie Exp vixie $";
  273.   #endif
  274.   
  275. --- 17,21 ----
  276.   
  277.   #if !defined(lint) && !defined(LINT)
  278. ! static char rcsid[] = "$Id: env.c,v 2.7 1994/01/26 02:25:50 vixie Exp vixie $";
  279.   #endif
  280.   
  281. ***************
  282. *** 30,34 ****
  283.   
  284.       p[0] = NULL;
  285. !     return p;
  286.   }
  287.   
  288. --- 30,34 ----
  289.   
  290.       p[0] = NULL;
  291. !     return (p);
  292.   }
  293.   
  294. ***************
  295. *** 59,63 ****
  296.           p[i] = strdup(envp[i]);
  297.       p[count] = NULL;
  298. !     return p;
  299.   }
  300.   
  301. --- 59,63 ----
  302.           p[i] = strdup(envp[i]);
  303.       p[count] = NULL;
  304. !     return (p);
  305.   }
  306.   
  307. ***************
  308. *** 89,93 ****
  309.           free(envp[found]);
  310.           envp[found] = strdup(envstr);
  311. !         return envp;
  312.       }
  313.   
  314. --- 89,93 ----
  315.           free(envp[found]);
  316.           envp[found] = strdup(envstr);
  317. !         return (envp);
  318.       }
  319.   
  320. ***************
  321. *** 101,105 ****
  322.       p[count] = p[count-1];
  323.       p[count-1] = strdup(envstr);
  324. !     return p;
  325.   }
  326.   
  327. --- 101,105 ----
  328.       p[count] = p[count-1];
  329.       p[count-1] = strdup(envstr);
  330. !     return (p);
  331.   }
  332.   
  333. ***************
  334. *** 123,127 ****
  335.       skip_comments(f);
  336.       if (EOF == get_string(envstr, MAX_ENVSTR, f, "\n"))
  337. !         return ERR;
  338.   
  339.       Debug(DPARS, ("load_env, read <%s>\n", envstr))
  340. --- 123,127 ----
  341.       skip_comments(f);
  342.       if (EOF == get_string(envstr, MAX_ENVSTR, f, "\n"))
  343. !         return (ERR);
  344.   
  345.       Debug(DPARS, ("load_env, read <%s>\n", envstr))
  346. ***************
  347. *** 133,137 ****
  348.           fseek(f, filepos, 0);
  349.           Set_LineNum(fileline);
  350. !         return FALSE;
  351.       }
  352.   
  353. --- 133,137 ----
  354.           fseek(f, filepos, 0);
  355.           Set_LineNum(fileline);
  356. !         return (FALSE);
  357.       }
  358.   
  359. ***************
  360. *** 157,161 ****
  361.       (void) sprintf(envstr, "%s=%s", name, val);
  362.       Debug(DPARS, ("load_env, <%s> <%s> -> <%s>\n", name, val, envstr))
  363. !     return TRUE;
  364.   }
  365.   
  366. --- 157,161 ----
  367.       (void) sprintf(envstr, "%s=%s", name, val);
  368.       Debug(DPARS, ("load_env, <%s> <%s> -> <%s>\n", name, val, envstr))
  369. !     return (TRUE);
  370.   }
  371.   
  372. ***************
  373. *** 166,174 ****
  374.       register char    **envp;
  375.   {
  376. !     for (;  *envp;  envp++) {
  377. !         register char    *p = strchr(*envp, '=');
  378. !         if (p && !strncmp(*envp, name, p - *envp))
  379. !             return p+1;
  380.       }
  381. !     return NULL;
  382.   }
  383. --- 166,178 ----
  384.       register char    **envp;
  385.   {
  386. !     register int    len = strlen(name);
  387. !     register char    *p, *q;
  388. !     while (p = *envp++) {
  389. !         if (!(q = strchr(p, '=')))
  390. !             continue;
  391. !         if ((q - p) == len && !strncmp(p, name, len))
  392. !             return (q+1);
  393.       }
  394. !     return (NULL);
  395.   }
  396.