cron: log when a crontab path is too long
Log via syslog when snprintf truncates the crontab path, instead of silently skipping the entry. Signed-off-by: Christos Longros <chris.longros@gmail.com> Reviewed by: bcr, kevans Differential Revision: https://reviews.freebsd.org/D56235
This commit is contained in:
committed by
Kyle Evans
parent
2c2ec6bbc9
commit
91bfba010b
@@ -19,7 +19,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $Id: cron.8,v 1.2 1998/08/14 00:32:36 vixie Exp $
|
.\" $Id: cron.8,v 1.2 1998/08/14 00:32:36 vixie Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd January 20, 2026
|
.Dd April 29, 2026
|
||||||
.Dt CRON 8
|
.Dt CRON 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -227,7 +227,14 @@ configuration file for
|
|||||||
.It Pa /usr/local/etc/cron.d
|
.It Pa /usr/local/etc/cron.d
|
||||||
Directory for third-party package provided crontab files.
|
Directory for third-party package provided crontab files.
|
||||||
.It Pa /var/cron/tabs
|
.It Pa /var/cron/tabs
|
||||||
Directory for personal crontab files
|
Directory for personal crontab files.
|
||||||
|
Internally the daemon constructs the relative path
|
||||||
|
.Pa tabs/ Ns Ar filename ,
|
||||||
|
which must fit within
|
||||||
|
.Dv MAXNAMLEN
|
||||||
|
bytes; in practice this allows filenames up to 250 bytes.
|
||||||
|
Longer entries are skipped and a diagnostic is logged via
|
||||||
|
.Xr syslog 3 .
|
||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr crontab 1 ,
|
.Xr crontab 1 ,
|
||||||
|
|||||||
@@ -166,8 +166,10 @@ load_database(cron_db *old_db)
|
|||||||
fname[sizeof(fname)-1] = '\0';
|
fname[sizeof(fname)-1] = '\0';
|
||||||
|
|
||||||
if (snprintf(tabname, sizeof tabname, CRON_TAB(fname))
|
if (snprintf(tabname, sizeof tabname, CRON_TAB(fname))
|
||||||
>= sizeof(tabname))
|
>= (int)sizeof(tabname)) {
|
||||||
continue; /* XXX log? */
|
log_it("CRON", getpid(), "TABNAME TOO LONG", fname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
process_crontab(fname, fname, tabname,
|
process_crontab(fname, fname, tabname,
|
||||||
&statbuf, &new_db, old_db);
|
&statbuf, &new_db, old_db);
|
||||||
|
|||||||
Reference in New Issue
Block a user