diff options
author | Guy Helmer <ghelmer@FreeBSD.org> | 2013-06-11 18:43:27 +0000 |
---|---|---|
committer | Guy Helmer <ghelmer@FreeBSD.org> | 2013-06-11 18:43:27 +0000 |
commit | 2b0cbe6d3a0055b9fb5c2fc7a8685a46bdcdb307 (patch) | |
tree | a31ea3f580d38d845254e954ffc37045ba60d4cb /libexec | |
parent | e1de133c2ef2853c646fc02e07b0443729750d2b (diff) | |
download | src-2b0cbe6d3a0055b9fb5c2fc7a8685a46bdcdb307.tar.gz src-2b0cbe6d3a0055b9fb5c2fc7a8685a46bdcdb307.zip |
Prevent races running the queue by serializing access to the
queue directory.
PR: bin/113239
Notes
Notes:
svn path=/head/; revision=251625
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/atrun/atrun.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c index 8b0315e94451..745d11e00337 100644 --- a/libexec/atrun/atrun.c +++ b/libexec/atrun/atrun.c @@ -31,6 +31,7 @@ static const char rcsid[] = /* System Headers */ #include <sys/fcntl.h> +#include <sys/file.h> #include <sys/types.h> #include <sys/stat.h> #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; |