diff options
author | millert <millert@openbsd.org> | 2020-04-16 17:51:56 +0000 |
---|---|---|
committer | millert <millert@openbsd.org> | 2020-04-16 17:51:56 +0000 |
commit | 2e6cac80faa0839600eabf86f0b60f68c98b4e81 (patch) | |
tree | 5c673916a0ea03b377f9b815151c1933980da187 /usr.sbin/cron/entry.c | |
parent | Log what caused a flush for better visibility on what could be improved. (diff) | |
download | wireguard-openbsd-2e6cac80faa0839600eabf86f0b60f68c98b4e81.tar.xz wireguard-openbsd-2e6cac80faa0839600eabf86f0b60f68c98b4e81.zip |
Add a mechanism to prevent cron jobs from running concurrently.
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@
Diffstat (limited to 'usr.sbin/cron/entry.c')
-rw-r--r-- | usr.sbin/cron/entry.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index e3f919a86e3..caeb5ba620e 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entry.c,v 1.50 2020/04/15 01:59:34 millert Exp $ */ +/* $OpenBSD: entry.c,v 1.51 2020/04/16 17:51:56 millert Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -354,6 +354,14 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, } e->flags |= DONT_LOG; break; + case 's': + /* only allow the user to set the option once */ + if ((e->flags & SINGLE_JOB) == SINGLE_JOB) { + ecode = e_option; + goto eof; + } + e->flags |= SINGLE_JOB; + break; default: ecode = e_option; goto eof; |