summaryrefslogtreecommitdiff
path: root/usr.sbin/cron
AgeCommit message (Collapse)Author
2023-07-19Fix skipping of white space after the username in /etc/crontab.Todd C. Miller
Only a single white space character was consumed, we should be consuming all white space between fields. This change makes things consistent with how lines without a username are parsed. OK deraadt@ sthen@
2023-06-13Upstream fixes for @yearly, @monthly, @weekly, @daily and @hourly.Todd C. Miller
The bit_nset() macro was being called with the high value one too large for the special strings. There is no security impact due to the layout of the bit strings but this was somewhat lucky. This introduces a set_range() function that performs range checks before calling bit_nset().
2023-06-04Correct the comment in get_range() describing the range syntax.Todd C. Miller
2023-05-08cron: bounds check the high and low bounds for in a random range.Todd C. Miller
The bounds are checked for normal ranges in set_element() but in the case of random ranges this is too late. As a result, a random range with an invalid high/low bounds would only result in a syntax error if the randomized value was out of bounds. This means the entry would be "randomly" rejected by cron or crontab. OK kn@
2023-05-07cron: check for garbage after the '~' in a random range.Todd C. Miller
A bug in the parsing of the optional number after the '~' in a random range prevented proper syntax checking. OK kn@
2023-05-06Support random offsets when using ranges with a step value in cron.Todd C. Miller
This extends the random range syntax to support step values. Instead of choosing a random number between the high and low values, the field is treated as a range with a random offset less than the step value. This can be used to avoid thundering herd problems where multiple machines contact a server all at the same time via cron jobs. The syntax is similar to the existing range/step syntax but uses a random range. For example, instead of "0-59/10" in the minutes field, "0~59/10" can be used to run a command every 10 minutes where the first command starts at a random offset in the range [0,9]. The high and low numbers are optional, "~/10" can be used instead. Requested by job@, OK phessler@
2023-05-05crontab: move spool temp file creation to spool_mkstemp()Todd C. Miller
This fixes a bug introduced in rev 1.86 where if the second seteuid() call failed, a temporary file would be left in the spool directory.
2022-12-28spelling fixes; from paul tagliamonteJason McIntyre
any parts of his diff not taken are noted on tech
2022-07-08Add a missing check for negative tv_sec when setting the timeout.Todd C. Miller
Also clear the entire timeout if the remaining time becomes negative instead of just clearing tv_sec or tv_nsec. OK cheloha@.
2022-07-07If ppoll(2) exits, log to syslog(3) instead of stderrJeremie Courreges-Anglas
By default cron runs as a daemon, with stderr redirected to /dev/null. Better not exit silently, as spotted by sthen@, danj@, "wxallowed" on irc/libera and myself. There probably is a bug lurking in ppoll(2) usage or in the syscall implementation. ok millert@
2022-05-21repair a few more backwards compares that create headachesTheo de Raadt
ok millert
2022-01-28When it's the possessive of 'it', it's spelled "its", without thePhilip Guenther
apostrophe.
2022-01-21Treat ppoll(2) errors as fatal. OK deraadt@Todd C. Miller
2021-10-24For open/openat, if the flags parameter does not contain O_CREAT, theTheo de Raadt
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past have passed mode_t (0, 044, 0644, or such), which might lead future people to copy this broken idiom, and perhaps even believe this parameter has some meaning or implication or application. Delete them all. This comes out of a conversation where tb@ noticed that a strange (but intentional) pledge behaviour is to always knock-out high-bits from mode_t on a number of system calls as a safety factor, and his bewilderment that this appeared to be happening against valid modes (at least visually), but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef. ok millert
2021-06-22reduce verbosity in usage and make it match SYNOPSIS;Jason McIntyre
ok millert
2020-04-18rename the "options" field to "flags" (as suggested by millert): an optionalJason McIntyre
options field was difficult to describe concisely; - tweak wording accordingly - sort flags - condense STANDARDS to avoid text repitition, as suggested by deraadt - document flags may be combined, now deraadt fixed the parsing ok millert deraadt
2020-04-18Rewrite the flag-parsing code to be getopt-like. Tight formations likeTheo de Raadt
-ns are now possible, as well as (useless) repetition like -nnn. ok millert
2020-04-17Log skipped jobs in job_add() not job_runqueue().Todd C. Miller
We want to log when the job is added but will not be run, not every time the run queue is processed.
2020-04-16Reflow text so that the -[nsq] options are described as an optional [options]Theo de Raadt
field before command, rather than muddling up the command description to explain them messily as some sort of exception ok millert
2020-04-16Add a mechanism to prevent cron jobs from running concurrently.Todd C. Miller
This adds a new "-s" flag to the command field which indicates that only a single instance of the job should run concurrenty. OK beck@ job@ deraadt@
2020-04-15Add support for random values using the '~' operator.Todd C. Miller
For example "0~30" will result in a random value between 0 and 30 inclusive. If either (or both) of the numbers on either side of the '~' are omitted, the appropriate limit (low or high) for the field will be used. OK deraadt@ beck@ jmc@
2020-02-11Remove setlocale(3) calls. I checked that no functions are called thatIngo Schwarze
are actually locale-dependent on OpenBSD, and the programs should better not be locale-dependent even when compiled on other systems. millert@ points out that the month and weekday names in the fourth and fifth columns of crontab(5) could in theory be made locale-dependent, but we certainly don't want that, and currently, they are only compared against static const char * arrays in entry.c containing English names. Patch sent in by Jan Stary <hans at stare dot cz>. OK millert@
2020-01-06Add "-n" to EXAMPLES in crontab(5)'s man pagejob
OK Ingo Schwarze
2020-01-06delete ridiculous DIAGNOSTICS section that goes without sayingIngo Schwarze
2019-10-20Use strtonum(3) in atrun. Also limit uid/gid to UID_MAX-1 andTodd C. Miller
GID_MAX-1 for good measure. OK deraadt@
2019-07-03snprintf/vsnprintf return < 0 on error, rather than -1.Theo de Raadt
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
2019-01-25I am retiring my old email address; replace it with my OpenBSD one.Todd C. Miller
2018-07-13Unused variable.Kenneth R Westerback
ok deraadt@
2018-07-11retire the old cron socket path; ok jca millertTheo de Raadt
2018-06-13zap a stray ';' and make a comment less uglyTheo Buehler
2018-06-13avoid a double flag;Jason McIntyre
2018-06-13Add crontab entry option -n for "No mail when run successful"job
OK jmc@ millert@
2018-02-05Pass a FILE * instead of a file descriptor into load_user() andTodd C. Miller
perform the fclose() in process_crontab(). Previously we were closing the crontab fd twice--once in load_user() via fclose() and once in process_crontab(). OK tb@
2017-10-25Open a bunch of fds with O_CLOEXECJeremie Courreges-Anglas
Not needed in theory, but could prevent accidental leaks. ok millert@
2017-10-23Close the socket (and dfd) in at(1) child processesJeremie Courreges-Anglas
Fixes a failure at restart if a child process still has the socket opened. Spotted by millert@, ok friehm@ millert@
2017-10-23Close cron sockets in child processes.friehm
ok jca@
2017-06-08update permissions info to match recent changesTodd C. Miller
2017-06-08Add logging for when we find a non-file in the at spool that wasTodd C. Miller
a file when we scanned the at spool earlier.
2017-06-07In cron(8), require that crontab and at files in the spool be ownedTodd C. Miller
by group crontab. The at(1) command now creates files owned by group crontab, the crontab(1) command already does this. Files in the crontab spool with parse errors are now ignored; crontab(1) will not install a crontab file with parse errors. The system crontab file (/etc/crontab) is not affected by this. The required permissions on crontab files have been tightened. Files in the cron spool must be mode 0600 (as created by crontab(1)). The system crontab file may be readable/writable by the owner, readable by group and readable by other. The system crontab must be readable by the owner.
2017-06-07When running at jobs, open the at spool and use the directory fdTodd C. Miller
with openat(), fstatat() and unlinkat(). This is similar to how we run cron jobs and eliminates the need for run_job() to find the basename of the at file. OK deraadt@
2017-06-05Set the group on cron's Unix domain socket _before_ making itTodd C. Miller
group-writable, not after. Pointed out by Solar Designer.
2016-10-12Document the "-q " prefix accepted in the "command" field.Ingo Schwarze
Original patch from Wouter Clarie <wclarie at gmail com>, tweaked in joint work with jca@, OK millert@, OK jca@ on an earlier version.
2016-08-30Fix fd leak on error. OK jsg@Todd C. Miller
2016-01-11When caching the mtime of the spool directory and system crontab files,Todd C. Miller
stash a struct timespec, not just a time_t. Fixes a bug where cron could skip re-reading the spool after two consecutive changes.
2015-11-17Check pipe(2) return value; noticed by deraadt@Todd C. Miller
2015-11-17Check for setgid() failure before executing editor and warn ifTodd C. Miller
exec of shell + editor fails.
2015-11-15Clean up the remaining uses of stderr and perror() and use warn/errTodd C. Miller
and/or syslog depending on whether stderr is hooked up at the time. Also remove closelog() which is not needed since we are headed for exec. OK guenther@
2015-11-14Cleanup from unifdef: set sact.sa_flags to SA_RESTART instead ofTodd C. Miller
clearing it and then ORin in SA_RESTART.
2015-11-14Remove log_it() and call syslog(3) directly using the same format:Todd C. Miller
"(username) WHAT (details)". Logs due to normal operation (e.g. crontab operations or running commands) are logged at LOG_INFO like before. Actual errors are logged at LOG_ERR, less important things are logged at LOG_WARNING OR LOG_NOTICE. Also ignore SIGHUP now that there is no log file to reopen.