aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/cron
Commit message (Collapse)AuthorAgeFilesLines
* Replace literal uses of /usr/local in C sources with _PATH_LOCALBASEStefan Eßer2020-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Literal references to /usr/local exist in a large number of files in the FreeBSD base system. Many are in contributed software, in configuration files, or in the documentation, but 19 uses have been identified in C source files or headers outside the contrib and sys/contrib directories. This commit makes it possible to set _PATH_LOCALBASE in paths.h to use a different prefix for locally installed software. In order to avoid changes to openssh source files, LOCALBASE is passed to the build via Makefiles under src/secure. While _PATH_LOCALBASE could have been used here, there is precedent in the construction of the path used to a xauth program which depends on the LOCALBASE value passed on the compiler command line to select a non-default directory. This could be changed in a later commit to make the openssh build consistently use _PATH_LOCALBASE. It is considered out-of-scope for this commit. Reviewed by: imp MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D26942 Notes: svn path=/head/; revision=367075
* cron: respect PATH from login.confKyle Evans2020-03-303-34/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | As a followup to the use of login.conf environment vars (other than PATH) in cron, this patch adds PATH (and HOME) to the list of login.conf settings respected. The new logic is as follows: 1. SHELL is always _PATH_BSHELL unless explicitly overridden in the crontab file itself; no other settings are respected. This is unchanged. 2. PATH is taken from the first of: crontab file, login.conf, _PATH_DEFPATH 3. HOME is taken from the first of: crontab file, login.conf, passwd entry, unset 4. The current directory for invoking the command is taken from the crontab file's value of HOME (existing behavior), or the passwd entry, but not anywhere else (so it might not equal HOME if that was set in login.conf). Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk> Reviewed by: sigsys_gmail.com Differential Revision: https://reviews.freebsd.org/D23597 Notes: svn path=/head/; revision=359434
* cron(8): rip out do_univKyle Evans2020-02-101-46/+1
| | | | | | | | This was an old Dynix hack, the function is a NOP on FreeBSD. We have no need to retain this; Dynix was discontinued long ago. Notes: svn path=/head/; revision=357715
* cron(8): convert vfork() usage to fork()Kyle Evans2020-02-105-31/+8
| | | | | | | | | | | | | vfork() is error-prone, and the usage here definitely grew to not be clearly OK given vfork-semantics; e.g. setusercontext(3) within the child. Rip out vfork() and the rest of the references to it. fork is heavier, but it's unclear that the difference will be all that obvious. Reported by: Andrew Gierth and sigsys@gmail.com Notes: svn path=/head/; revision=357714
* cron(8): set the environment variables of the user and/or login classKyle Evans2020-02-052-8/+31
| | | | | | | | | | | | | | | Prior to processing environment variable set in the crontab file as those should be of higher precedent, pull in the user or login class environment. This is another supporting feature for allowing one to configure system-wide settings that may affect both regular cron jobs as well as services. This is the final part of D21481. Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk> Notes: svn path=/head/; revision=357565
* cron(8): use proper variable to determine mailer process statusKyle Evans2019-12-261-4/+6
| | | | | | | | | | | | | | | | | | | | | | | While the mailer is normally opened/set if the mailto is set, this is not the case if the grandchild actually didn't produce any output. This change corrects the situation to only attempt to kill/close the mail process if it was actually opened in the first place. The reporter initially stumbled on the -n (suppress mail on success) flag leading to a SIGKILL of the process group, but simultaneously discovered/reported the behavior with !-n jobs if MAILTO was set and no output happened. All of these places that are checking mailto should actually be checking whether mail is set, so do that for consistency+correctness. This set of bugs were introduced by r352668. Submitted by: sigsys@gmail.com Reported by: sigsys@gmail.com Notes: svn path=/head/; revision=356103
* cron: add log suppression and mail suppression for successful runsKyle Evans2019-09-255-56/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds two new extensions to crontab, ported from OpenBSD: - -n: suppress mail on succesful run - -q: suppress logging of command execution The -q option appears decades old, but -n is relatively new. The original proposal by Job Snijder can be found here [1], and gives very convincing reasons for inclusion in base. This patch is a nearly identical port of OpenBSD cron for -q and -n features. It is written to follow existing conventions and style of the existing codebase. Example usage: # should only send email, but won't show up in log * * * * * -q date # should not send email * * * * * -n date # should not send email or log * * * * * -n -q date # should send email because of ping failure * * * * * -n -q ping -c 1 5.5.5.5 [1]: https://marc.info/?l=openbsd-tech&m=152874866117948&w=2 PR: 237538 Submitted by: Naveen Nathan <freebsd_t.lastninja.net> Reviewed by: bcr (manpages) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D20046 Notes: svn path=/head/; revision=352668
* cron(8): schedule interval jobs that get loaded during executionKyle Evans2019-04-202-5/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | Jobs using the @<second> syntax currently only get executed if they exist when cron is started. The simplest reproducer of this is: echo '@20 root echo "Hello!"' >> /etc/cron.d/myjob myjob will get loaded at the next second==0, but this echo job will not run until cron restarts. These jobs are normally handled in run_reboot_jobs(), which sets e->lastexit of INTERVAL jobs to the startup time so they run 'n' seconds later. Fix this by special-casing TargetTime > 0 in the database load. Preexisting jobs will be handled at startup during run_reboot_jobs as normal, but if we've reloaded a database during runtime we'll hit this case and set e->lastexit to the current time when we process it. They will then run every 'n' seconds from that point, and a full restart of cron is no longer required to make these jobs work. Reported by: Juraj Lutter (otis_sk.freebsd.org) Reviewed by: allanjude, bapt, bjk (earlier version), Juraj Lutter MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D19924 Notes: svn path=/head/; revision=346427
* cron(8): Add MAILFROM ability for crontabsKyle Evans2019-04-153-5/+16
| | | | | | | | | | This changes the sender mail address in a similar fashion to how MAILTO may change the recipient. The default from address remains unchanged. MFC after: 1 week Notes: svn path=/head/; revision=346252
* Move etc/crontab to usr.sbin/cron/cron/Brad Davis2018-09-062-0/+24
| | | | | | | | Approved by: re (gjb), will (mentor) Differential Revision: https://reviews.freebsd.org/D16786 Notes: svn path=/head/; revision=338497
* Remove old, dead compat code.Warner Losh2018-06-101-18/+2
| | | | | | | | | | | | | We no longer need to od these things conditionally, and the fallbacks are to 4.2BSD era defaults, which nobody uses anymore. Vixie cron has diverged from upstream anyway in our tree, and it's not clear there's actually a viable upstream anymore. Plus, we don't follow the vendor-supplied code pattern here. I'm doing this to reduce false positives from grep. Notes: svn path=/head/; revision=334910
* Add new functionality and syntax to cron(1) to allow to run jobs at aGleb Smirnoff2018-06-075-14/+88
| | | | | | | | | | | | | | | | | | | | | | | | | given interval, which is counted in seconds since exit of the previous invocation of the job. Example user crontab entry: @25 sleep 10 The example will launch 'sleep 10' every 35 seconds. This is a rather useless example above, but clearly explains the functionality. The practical goal here is to avoid overlap of previous job invocation to a new one, or to avoid too short interval(s) for jobs that last long and doesn't have any point of immediate launch soon after previous run. Another useful effect of interval jobs can be noticed when a cluster of machines periodically communicates with a single node. Running the task time based creates too much load on the node. Running interval based spreads invocations across machines in cluster. Note that -j/-J won't help in this case. Sponsored by: Netflix Notes: svn path=/head/; revision=334817
* cron(8): Correct test senseKyle Evans2018-04-121-1/+1
| | | | | | | | | | We're about to use the result of fstat(2) either way, so don't do that if it fails... X-MFC-With: r332429 Notes: svn path=/head/; revision=332431
* cron(8): Reload database if an existing job in cron.d changed as wellKyle Evans2018-04-121-1/+13
| | | | | | | | | | | | | | | | | | Directory mtime will only change if a file is added or removed, not modified. For /var/cron/tabs, this is fine because of how crontab(1) manages it using temp files so all crontab(1) changes will trigger a reload of the database. For /etc/cron.d and /usr/local/etc/cron.d, this is not necessarily the case. Instead of checking their mtime, we should descend into them and check mtime on all jobs also. Reported by: des Reviewed by: bapt MFC after: 1 week Notes: svn path=/head/; revision=332429
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-312-2/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* cron(8) manpage updatesEnji Cooper2017-07-191-3/+7
| | | | | | | | | | | - Document /etc/cron.d and /usr/local/etc/cron.d under FILES. - Reword documentation for -n: add appropriate soft-stop and remove contraction to appease igor. MFC after: 3 days Notes: svn path=/head/; revision=321240
* Fix trivial whitespace bug introduced in usage message changes for -nEnji Cooper2017-07-191-1/+1
| | | | | | | | | support (r304570). MFC after: now Notes: svn path=/head/; revision=321235
* usr.sbin: normalize paths using SRCTOP-relative paths or :H when possibleEnji Cooper2017-03-042-2/+2
| | | | | | | | | | This simplifies make logic/output MFC after: 1 month Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314659
* Add a 'force' option for non-interactive crontab removalConrad Meyer2016-12-202-5/+15
| | | | | | | | | | | | Add a '-f' option to force crontab '-r' to be non-interactive. Submitted by: Sam Gwydir <sam at samgwydir.com> Reviewed by: me, wblock (previous version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8815 Notes: svn path=/head/; revision=310329
* Allow symlinks to be followed in cron.d directories and fix detection ofBaptiste Daroussin2016-10-311-2/+3
| | | | | | | | | regular files on NFS Reported by: jilles Notes: svn path=/head/; revision=308158
* Fix typo in cron(8) dateBaptiste Daroussin2016-10-311-1/+1
| | | | | | | Reported by: jilles Notes: svn path=/head/; revision=308157
* cron(8): add support for /etc/cron.d and /usr/local/etc/cron.dBaptiste Daroussin2016-10-315-10/+54
| | | | | | | | | | | | | | | | For automation tools it is way easier to maintain files in directories rather than modifying /etc/crontab. The files in those directories are in the same format as /etc/crontab Reviewed by: adrian MFC after: 2 weeks Relnotes: yes Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D8400 Notes: svn path=/head/; revision=308139
* cron: use existing maximum username constant MAXLOGNAMEEd Maste2016-09-022-2/+2
| | | | | | | | | | | | | | | | | Previously cron had its own maximum username length limit, which was smaller than the system's MAXLOGNAME. This could lead to crontab -u updating the wrong user's crontab (if the name was truncated, and matched another user). PR: 212305 Reported by: Andrii Kuzik Reviewed by: allanjude, jilles MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D7747 Notes: svn path=/head/; revision=305269
* Add the "-n" flag to cron(8), to prevent it from daemonizing.Edward Tomasz Napierala2016-08-212-4/+11
| | | | | | | | | | | | This makes it possible to use it with external supervisors. The "-n" flag name is compatible with Linux, NetBSD, and OpenBSD. Reviewed by: jilles, pfg, wblock MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D7581 Notes: svn path=/head/; revision=304570
* usr.sbin: minor spelling fixes on comments.Pedro F. Giffuni2016-05-012-3/+3
| | | | | | | No functional change. Notes: svn path=/head/; revision=298886
* crontab: ftruncate() with ftello() instead of ftell().Pedro F. Giffuni2016-02-161-1/+1
| | | | | | | Obtained from: OpenBSD (CVS rev. 1.47) Notes: svn path=/head/; revision=295672
* cron: use (char *)NULL instead of (char *)0 in execle.Pedro F. Giffuni2016-02-161-2/+3
| | | | | | | Obtained from: OpenBSD (CVS Rev 1.25) Notes: svn path=/head/; revision=295671
* Add sbin and /usr/local directories to _PATH_DEFPATH.Jilles Tjoelker2016-01-051-2/+2
| | | | | | | | | | | | | | | | | | | | Set _PATH_DEFPATH to /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin. This is the path in the default class in the default /etc/login.conf, excluding ~/bin which would not be expanded properly in a string constant. For normal logins, _PATH_DEFPATH is overridden by /etc/login.conf, ~/.login_conf or shell startup files. _PATH_DEFPATH is still used as a default by execlp(), execvp(), posix_spawnp() and sh if PATH is not set, and by cron. Especially the latter is a common trap (most recently in PR 204813). PR: 204813 Reviewed by: secteam (delphij), alfred Notes: svn path=/head/; revision=293204
* Undo change from r292607 that was not meant to be therePedro F. Giffuni2015-12-221-1/+1
| | | | | | | Pointyhat: me Notes: svn path=/head/; revision=292608
* cron: Check the return value of pipe(2)Pedro F. Giffuni2015-12-221-3/+5
| | | | | | | | Fix inspired by: OpenBSD (rev 1.56) CID: 1009830 Notes: svn path=/head/; revision=292607
* crontab: properly free an entryPedro F. Giffuni2015-12-221-1/+1
| | | | | | | | | | This should close memory leak. Obtained from: OpenBSD (rev. 1.62) CID: 271773 Notes: svn path=/head/; revision=292606
* crontab: replace malloc + bzero with callocPedro F. Giffuni2015-12-221-2/+1
| | | | | | | Obtained from: OpenBSD (Rev 1.20) Notes: svn path=/head/; revision=292605
* Add META_MODE support.Simon J. Gerraty2015-06-133-0/+56
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-083-6/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-273-6/+2
| |\ | |/ |/| | | Notes: svn path=/projects/bmake/; revision=283595
| * Merge from head@274682Simon J. Gerraty2014-11-193-6/+5
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=274683
| * \ Merge head from 7/28Simon J. Gerraty2014-08-195-3/+7
| |\ \ | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=270164
| * | | Updated dependenciesSimon J. Gerraty2014-05-162-2/+0
| | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=266219
| * | | Updated dependenciesSimon J. Gerraty2014-05-102-0/+4
| | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265802
| * | | Merge headSimon J. Gerraty2014-04-281-20/+7
| |\ \ \ | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265044
| * | | | Updated dependenciesSimon J. Gerraty2013-03-112-0/+2
| | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=248169
| * | | | Updated dependenciesSimon J. Gerraty2013-02-163-6/+0
| | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246868
| * | | | Sync from headSimon J. Gerraty2012-11-046-31/+164
| |\ \ \ \ | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=242545
| * | | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.Marcel Moolenaar2012-08-223-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net> Notes: svn path=/projects/bmake/; revision=239572
* | | | | | Readd Makefile.inc that were used to include upper level Makefile.inc andBaptiste Daroussin2014-11-281-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set (among other things) the destination where the binary should be installed Notes: svn path=/head/; revision=275218
* | | | | | Convert usr.sbin to LIBADDBaptiste Daroussin2014-11-253-9/+2
| |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduce overlinking Notes: svn path=/head/; revision=275054
* | | | | Revert r267233 for now. PIE support needs to be reworked.Bryan Drewery2014-08-192-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. 50+% of NO_PIE use is fixed by adding -fPIC to INTERNALLIB and other build-only utility libraries. 2. Another 40% is fixed by generating _pic.a variants of various libraries. 3. Some of the NO_PIE use is a bit absurd as it is disabling PIE (and ASLR) where it never would work anyhow, such as csu or loader. This suggests there may be better ways of adding support to the tree. Many of these cases can be fixed such that -fPIE will work but there is really no reason to have it in those cases. 4. Some of the uses are working around hacks done to some Makefiles that are really building libraries but have been using bsd.prog.mk because the code is cleaner. Had they been using bsd.lib.mk then NO_PIE would not have been needed. We likely do want to enable PIE by default (opt-out) for non-tree consumers (such as ports). For in-tree though we probably want to only enable PIE (opt-in) for common attack targets such as remote service daemons and setuid utilities. This is also a great performance compromise since ASLR is expected to reduce performance. As such it does not make sense to enable it in all utilities such as ls(1) that have little benefit to having it enabled. Reported by: kib Notes: svn path=/head/; revision=270168
* | | | | Check gethostname(2) return code - but even if it succeeds it may notPeter Wemm2014-08-051-2/+5
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | null terminate. Temporarily use "From: $user@$hostname" rather than "From: $user". The latter exposes incompatible behavior if using dma(8). sendmail(8) (and other alternatives) canonify either form on submission (even if masquerading), but dma will leak a non-compliant address to the internet. Notes: svn path=/head/; revision=269550
* | | | use .Mt to mark up email addresses consistently (part2)Baptiste Daroussin2014-06-203-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR: 191174 Submitted by: Franco Fichtner <franco@lastsummer.de> Notes: svn path=/head/; revision=267668
* | | | In preparation for ASLR [1] support add WITH_PIE to support building with -fPIE.Bryan Drewery2014-06-082-0/+4
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is currently an opt-in build flag. Once ASLR support is ready and stable it should changed to opt-out and be enabled by default along with ASLR. Each application Makefile uses opt-out to ensure that ASLR will be enabled by default in new directories when the system is compiled with PIE/ASLR. [2] Mark known build failures as NO_PIE for now. The only known runtime failure was rtld. [1] http://www.bsdcan.org/2014/schedule/events/452.en.html Submitted by: Shawn Webb <lattera@gmail.com> Discussed between: des@ and Shawn Webb [2] Notes: svn path=/head/; revision=267233