summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron/lib
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2007-06-17 17:25:53 +0000
committeryar <yar@FreeBSD.org>2007-06-17 17:25:53 +0000
commit333d04678de0f758b3332c024f321aa2f9b801b2 (patch)
tree5b2964d6813053eb898acc04fa43beede2e79239 /usr.sbin/cron/lib
parent481992080252c6f1525eb50007ea8390bb08ea27 (diff)
downloadFreeBSD-src-333d04678de0f758b3332c024f321aa2f9b801b2.zip
FreeBSD-src-333d04678de0f758b3332c024f321aa2f9b801b2.tar.gz
Add PAM support to cron(8). Now cron(8) will skip commands scheduled
by unavailable accounts, e.g., those locked, expired, not allowed in at the moment by nologin(5), or whatever, depending on cron's pam.conf(5). This applies to personal crontabs only, /etc/crontab is unaffected. In other words, now the account management policy will apply to commands scheduled by users via crontab(1) so that a user can no longer use cron(8) to set up a delayed backdoor and run commands during periods when the admin doesn't want him to. The PAM check is done just before running a command, not when loading a crontab, because accounts can get locked, expired, and re-enabled any time with no changes to their crontabs. E.g., imagine that you provide a system with payed access, or better a cluster of such systems with centralized account management via PAM. When a user pays for some days of access, you set his expire field respectively. If the account expires before its owner pays more, its crontab commands won't run until the next payment is made. Then it'll be enough to set the expire field in future for the commands to run again. And so on. Document this change in the cron(8) manpage, which includes adding a FILES section and touching the document date. X-Security: should benefit as users have access to cron(8) by default
Diffstat (limited to 'usr.sbin/cron/lib')
-rw-r--r--usr.sbin/cron/lib/Makefile2
-rw-r--r--usr.sbin/cron/lib/entry.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/usr.sbin/cron/lib/Makefile b/usr.sbin/cron/lib/Makefile
index d11c511..296ebd0 100644
--- a/usr.sbin/cron/lib/Makefile
+++ b/usr.sbin/cron/lib/Makefile
@@ -5,6 +5,6 @@ INTERNALLIB=
SRCS= entry.c env.c misc.c
CFLAGS+= -I${.CURDIR}/../cron
-CFLAGS+= -DLOGIN_CAP
+CFLAGS+= -DLOGIN_CAP -DPAM
.include <bsd.lib.mk>
diff --git a/usr.sbin/cron/lib/entry.c b/usr.sbin/cron/lib/entry.c
index 7269152..33ace49 100644
--- a/usr.sbin/cron/lib/entry.c
+++ b/usr.sbin/cron/lib/entry.c
@@ -323,10 +323,12 @@ load_entry(file, error_func, pw, envp)
#endif
}
+#ifndef PAM /* PAM takes care of account expiration by itself */
if (pw->pw_expire && time(NULL) >= pw->pw_expire) {
ecode = e_username;
goto eof;
}
+#endif /* !PAM */
e->uid = pw->pw_uid;
e->gid = pw->pw_gid;
OpenPOWER on IntegriCloud