History log of /freebsd-current/usr.sbin/cron/crontab/crontab.c
Revision Date Author Comments
# fe590ffe 01-Jun-2023 Eric van Gyzen <vangyzen@FreeBSD.org>

Import vixie cron 4.0

Specifically, import the diff from commit e745bd4c10ab to
commit 83563783cc2 in https://github.com/vixie/cron.git

My sole motivation is changing to the common MIT license.
The old license, especially the "buildable source" clause,
is unfriendly for commercial users of this code. Simply
changing the license without importing [most of] the code
accompanying that license seemed legally dubious.

The most regrettable change is losing Paul's uucp path.
I partially atone for this loss by restoring the upstream
$Id$ tags, since $FreeBSD$ is no longer useful.

This is [intended to be] a complete list of the functional
changes in this commit. Some changes were made so that we
could consider vixie cron to be our upstream and reduce our
diffs against it, while others were simply a good idea.

- main() - use putenv instead of setenv for PATH
- open_pidfile no longer needs snprintf to build pidfile
- crontab main() - abort() on impossible errors
- check for truncation when building strings with snprintf
- getdtablesize() -> sysconf(_SC_OPEN_MAX)

These changes were not taken from upstream's 4.0 diff because
they [could] actually change behavior. Some of them might be
beneficial, but should be taken separately.

- config.h - sendmail args: remove -oi and add -or0s
- call setlocale(LC_ALL, "") at the top of main()
- acquire_daemonlock - we already use pidfile
- cast getpid(), uid_t, and gid_t to long for printf
- remove unnecessary braces - I consider them beneficial
- BSDi support
- glue_strings() - use snprintf(), as we often already did

MFC after: on demand
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D40260


# e93f27e3 18-Apr-2023 John Baldwin <jhb@FreeBSD.org>

cron: Use C89 function definitions.

Reviewed by: zlei
Differential Revision: https://reviews.freebsd.org/D39529


# d21656dc 20-Dec-2016 Conrad Meyer <cem@FreeBSD.org>

Add a 'force' option for non-interactive crontab removal

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


# 5e5d4b23 01-Sep-2016 Ed Maste <emaste@FreeBSD.org>

cron: use existing maximum username constant MAXLOGNAME

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


# e78e0c43 16-Feb-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

crontab: ftruncate() with ftello() instead of ftell().

Obtained from: OpenBSD (CVS rev. 1.47)


# 7044922b 22-Dec-2015 Pedro F. Giffuni <pfg@FreeBSD.org>

crontab: properly free an entry

This should close memory leak.

Obtained from: OpenBSD (rev. 1.62)
CID: 271773


# 902d9eaf 01-Sep-2012 Ed Schouten <ed@FreeBSD.org>

Rework all non-contributed files that use `struct timezone'.

This structure is not part of POSIX. According to POSIX, gettimeofday()
has the following prototype:

int gettimeofday(struct timeval *restrict tp, void *restrict tzp);

Also, POSIX states that gettimeofday() shall return 0 (as long as tzp is
not used). Remove dead error handling code. Also use NULL for a
nul-pointer instead of integer 0.

While there, change all pieces of code that only use tv_sec to use
time(3), as this provides less overhead.


# 5cdfc55c 02-Jul-2012 John Baldwin <jhb@FreeBSD.org>

Add a one second sleep before touching the spool directory. If the touch
occurs in the same second as the earlier operations to create the temporary
file and the cron(8) daemon is rescans the spool directory during that
second, then the daemon may miss a cron edit and not properly update its
internal database.

MFC after: 1 month


# cc427081 26-Feb-2012 Xin LI <delphij@FreeBSD.org>

Drop setuid status while doing file operations to prevent potential
information leak. This changeset is intended to be a minimal one
to make backports easier.

Reviewed by: kevlo, remko
MFC after: 1 week


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 90f43da7 17-Nov-2008 Matteo Riondato <matteo@FreeBSD.org>

Be more precise and use sizeof(tn)
Pointed out by: glewis@

MFC after: 3 days


# 66d48cda 09-Nov-2008 Matteo Riondato <matteo@FreeBSD.org>

Make usr.sbin/cron/crontab and usr.sbin/cron/lib WARNS=3 clean

Tested with: make universe

MFC after: 3 days


# 37f1755c 09-Nov-2008 Matteo Riondato <matteo@FreeBSD.org>

Revert to previous revision.
I should not commit anything at 3.50 AM.
In addition to danfe's comments, I got others.
I'll work on a better version of the patch.


# 8037791b 09-Nov-2008 Matteo Riondato <matteo@FreeBSD.org>

Don't leave files in /var/cront/tabs when interrupted

PR: 17363
MFC after: 3 days


# 2b9f079c 08-Nov-2008 Matteo Riondato <matteo@FreeBSD.org>

Be paranoid and use snprintf

PR: bin/122137
Submitted by: Steven Kreuzer <skreuzer@exit2shell.com>
MFC after: 3 days


# c11807ac 05-Nov-2008 Matteo Riondato <matteo@FreeBSD.org>

Be paranoid and zero out passwd

PR: 122070
Submitted by: Steven Kreuzer <skreuzer@exit2shell.com>
Reminded by: gnn@
MFC after: 3 days


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 784bddbc 07-Nov-2007 Kevin Lo <kevlo@FreeBSD.org>

Cleanup of userland __P use


# 405a44d3 03-Sep-2006 Ruslan Ermilov <ru@FreeBSD.org>

Use a #define to refer to /etc/crontab.


# 9896de5a 09-Jan-2006 Brooks Davis <brooks@FreeBSD.org>

/etc/crontab is similar enough to parse as correct if you run
"crontab /etc/crontab", but not the same format due to the who field.
Add some limited anti-foot-shooting support and refuse to load
/etc/crontab as someone's crontab. Users wishing shoot their foot in
this manner may copy /etc/crontab elsewhere. :)

MFC After: 1 week


# 0cd2e3ab 14-Sep-2004 Diomidis Spinellis <dds@FreeBSD.org>

Ensure that edits that do not span a clock tick are not lost.

PR: bin/22612
MT5: 4 weeks
MT4: 2 weeks


# 9a2ef7d1 13-Sep-2004 Diomidis Spinellis <dds@FreeBSD.org>

Refactoring: move two similar code blocks into a seprate function.


# 08e019a8 13-Sep-2004 Diomidis Spinellis <dds@FreeBSD.org>

Fix for the following behavior:
$ crontab -e
[Add an entry with an error in the crontab file.]
crontab: errors in crontab file, can't install
Do you want to retry the same edit? yes
[Exit the editor without any changes.]
crontab: no changes made to crontab
[Entry is lost.]

Now crontab will loop until the error is fixed, or the
user answers no.


# e9d295bf 01-Oct-2002 Dima Dorfman <dd@FreeBSD.org>

Actually use the exitstatus value that we maintain.

PR: 43562
Submitted by: Marc Olzheim <marcolz@ilse.nl>


# 7bc6d015 09-Jul-2001 Brian Somers <brian@FreeBSD.org>

Fix the type of the NULL arg to execl()

Idea from: Theo de Raadt <deraadt@openbsd.org>


# d952a14d 15-Jun-2001 Peter Wemm <peter@FreeBSD.org>

Where is the pointy hat? Fix cut/paste error. (hey, it compiled! :-)


# 8966f504 12-Apr-2001 Peter Wemm <peter@FreeBSD.org>

Remove the 'DO NOT EDIT THIS FILE' crud that we spit out with 'crontab -l'.
Otherwise, "crontab -l > file; vi file; crontab file" adds an extra set
of "DO NOT EDIT" markers each and every time which is a bit silly.


# 1a37aa56 09-Dec-2000 David E. O'Brien <obrien@FreeBSD.org>

Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.


# 25e9ca2b 06-Nov-2000 David Malone <dwmalone@FreeBSD.org>

Attempt to fix problem with users being able to convince the crontab
program to read any file which is a valid crontab file.

The fix is based on that used in NetBSD and OpenBSD - we keep the
file open while the user is editing it. This means that files must
be edited in place. Cron attempts to warn you if your editor does
not do this. The fact that the file must be edited in place is also
noted in the man page.

This patch has been confirmed to work by atleast one person on
-security and has been tested locally.

Obtained from: OpenBSD


# 30cfb241 14-Oct-2000 Paul Richards <paul@FreeBSD.org>

Since -e and -r are right next to each other prompt before clobbering
a crontab you were planning to edit.


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 401e6468 15-Sep-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3). Rewrote man page in mdoc format.


# 6c3f552a 30-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 476602a9 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# bdddbd2f 16-Dec-1996 Paul Traina <pst@FreeBSD.org>

Replace my "inane" usage of snprintf to copy strings with strncpy as
used by OpenBSD. (Quite frankly, I think it's perfectly reasonable to
use snprintf to copy strings, given that the semantics for strncpy()
are utterly idiotic and there is no POSIX sstrncpy().)

While I'm at it, incorporate some of OpenBSD's bugfixes to cron.

NOT for 2.2


# 18fb104c 04-Aug-1996 Paul Traina <pst@FreeBSD.org>

Gratuitous whitespace change so that I can commit the source of the recent
buffer overflow patch.
Reviewed by: pst
Submitted by: Dave Andersen <angio@aros.net>


# b04b7cf5 04-Aug-1996 Paul Traina <pst@FreeBSD.org>

Fix up some more buffer overflow problems.


# fd2c4394 09-Apr-1996 Marc G. Fournier <scrappy@FreeBSD.org>

Quick patch to fix a bug where issuing ctl-c while in crontab -e
leaves editor running in background (PR: bin/751)

Submitted by: candy@fct.kgc.co.jp (Toshihiro Kanda)


# 709e8f9a 29-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 8dac9202 21-Dec-1994 Andrey A. Chernov <ache@FreeBSD.org>

Now crontab works not only for vi editor, i.e. refers to
file name not to file fd


# 84f33dea 27-Aug-1994 Jordan K. Hubbard <jkh@FreeBSD.org>

Paul Vixie's cron, version 3.0. Munged into bmake format. If this goes
well, expect our two seperate directories for cron and crontab to go away
shortly.
Submitted by: jkh