From acb2956b5be212b08e52b54998f877ce63d5422a Mon Sep 17 00:00:00 2001 From: ghelmer Date: Tue, 11 Jun 2013 18:43:27 +0000 Subject: Prevent races running the queue by serializing access to the queue directory. PR: bin/113239 --- libexec/atrun/atrun.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c index 8b0315e..745d11e 100644 --- a/libexec/atrun/atrun.c +++ b/libexec/atrun/atrun.c @@ -31,6 +31,7 @@ static const char rcsid[] = /* System Headers */ #include +#include #include #include #ifdef __FreeBSD__ @@ -521,6 +522,9 @@ main(int argc, char *argv[]) if ((spool = opendir(".")) == NULL) perr("cannot read %s", ATJOB_DIR); + if (flock(dirfd(spool), LOCK_EX) == -1) + perr("cannot lock %s", ATJOB_DIR); + now = time(NULL); run_batch = 0; batch_uid = (uid_t) -1; -- cgit v1.1