summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2015-11-09 15:57:39 +0000
committermillert <millert@openbsd.org>2015-11-09 15:57:39 +0000
commitb75be85290fb3514f2cd2c72477149aedd99d2a2 (patch)
treea795ebdbab200d8a68794abcc3e15264de8d6d38 /usr.sbin/cron
parentuse open() with flags instead of creat() (diff)
downloadwireguard-openbsd-b75be85290fb3514f2cd2c72477149aedd99d2a2.tar.xz
wireguard-openbsd-b75be85290fb3514f2cd2c72477149aedd99d2a2.zip
Rename AT_DIR -> AT_SPOOL and SPOOL_DIR -> CRON_SPOOL to improve
readability.
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r--usr.sbin/cron/atrun.c16
-rw-r--r--usr.sbin/cron/client.c6
-rw-r--r--usr.sbin/cron/common.c42
-rw-r--r--usr.sbin/cron/cron.c6
-rw-r--r--usr.sbin/cron/crontab.c16
-rw-r--r--usr.sbin/cron/database.c14
-rw-r--r--usr.sbin/cron/pathnames.h14
7 files changed, 57 insertions, 57 deletions
diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c
index 6b746ba44a7..96d55d23e0b 100644
--- a/usr.sbin/cron/atrun.c
+++ b/usr.sbin/cron/atrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atrun.c,v 1.36 2015/11/09 14:44:05 millert Exp $ */
+/* $OpenBSD: atrun.c,v 1.37 2015/11/09 15:57:39 millert Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -65,12 +65,12 @@ scan_atjobs(at_db **db, struct timespec *ts)
struct dirent *file;
struct stat sb;
- if ((dfd = open(AT_DIR, O_RDONLY|O_DIRECTORY)) == -1) {
- log_it("CRON", getpid(), "OPEN FAILED", AT_DIR);
+ if ((dfd = open(AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1) {
+ log_it("CRON", getpid(), "OPEN FAILED", AT_SPOOL);
return (0);
}
if (fstat(dfd, &sb) != 0) {
- log_it("CRON", getpid(), "FSTAT FAILED", AT_DIR);
+ log_it("CRON", getpid(), "FSTAT FAILED", AT_SPOOL);
close(dfd);
return (0);
}
@@ -80,7 +80,7 @@ scan_atjobs(at_db **db, struct timespec *ts)
}
if ((atdir = fdopendir(dfd)) == NULL) {
- log_it("CRON", getpid(), "OPENDIR FAILED", AT_DIR);
+ log_it("CRON", getpid(), "OPENDIR FAILED", AT_SPOOL);
close(dfd);
return (0);
}
@@ -161,7 +161,7 @@ atrun(at_db *db, double batch_maxload, time_t now)
if (job->run_time > now)
continue;
- snprintf(atfile, sizeof(atfile), "%s/%lld.%c", AT_DIR,
+ snprintf(atfile, sizeof(atfile), "%s/%lld.%c", AT_SPOOL,
(long long)job->run_time, job->queue);
if (lstat(atfile, &sb) != 0 || !S_ISREG(sb.st_mode)) {
@@ -194,7 +194,7 @@ atrun(at_db *db, double batch_maxload, time_t now)
&& (batch_maxload == 0.0 ||
((getloadavg(&la, 1) == 1) && la <= batch_maxload))
) {
- snprintf(atfile, sizeof(atfile), "%s/%lld.%c", AT_DIR,
+ snprintf(atfile, sizeof(atfile), "%s/%lld.%c", AT_SPOOL,
(long long)batch->run_time, batch->queue);
run_job(batch, atfile);
TAILQ_REMOVE(&db->jobs, batch, entries);
@@ -481,7 +481,7 @@ run_job(atjob *job, char *atfile)
fprintf(mail, "Subject: Output from \"at\" job\n");
fprintf(mail, "Auto-Submitted: auto-generated\n");
fprintf(mail, "\nYour \"at\" job on %s\n\"%s/%s/%s\"\n",
- hostname, CRONDIR, AT_DIR, atfile);
+ hostname, CRONDIR, AT_SPOOL, atfile);
fprintf(mail, "\nproduced the following output:\n\n");
/* Pipe the job's output to sendmail. */
diff --git a/usr.sbin/cron/client.c b/usr.sbin/cron/client.c
index 1957b6369f3..b0d021263da 100644
--- a/usr.sbin/cron/client.c
+++ b/usr.sbin/cron/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.4 2015/11/06 23:47:42 millert Exp $ */
+/* $OpenBSD: client.c,v 1.5 2015/11/09 15:57:39 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -99,9 +99,9 @@ poke_daemon(const char *spool_dir, unsigned char cookie)
bzero(&s_un, sizeof(s_un));
if (snprintf(s_un.sun_path, sizeof s_un.sun_path, "%s/%s",
- SPOOL_DIR, CRONSOCK) >= sizeof(s_un.sun_path)) {
+ CRON_SPOOL, CRONSOCK) >= sizeof(s_un.sun_path)) {
fprintf(stderr, "%s: %s/%s: path too long\n",
- __progname, SPOOL_DIR, CRONSOCK);
+ __progname, CRON_SPOOL, CRONSOCK);
return;
}
s_un.sun_family = AF_UNIX;
diff --git a/usr.sbin/cron/common.c b/usr.sbin/cron/common.c
index 0c07f1b3354..0900f806bd2 100644
--- a/usr.sbin/cron/common.c
+++ b/usr.sbin/cron/common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.c,v 1.2 2015/11/04 20:28:17 millert Exp $ */
+/* $OpenBSD: common.c,v 1.3 2015/11/09 15:57:39 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -68,54 +68,54 @@ set_cron_cwd(void)
exit(EXIT_FAILURE);
}
- /* CRONDIR okay (now==CWD), now look at SPOOL_DIR ("tabs" or some such)
+ /* CRONDIR okay (now==CWD), now look at CRON_SPOOL ("tabs" or some such)
*/
- if (stat(SPOOL_DIR, &sb) < 0 && errno == ENOENT) {
- perror(SPOOL_DIR);
- if (0 == mkdir(SPOOL_DIR, 0700)) {
- fprintf(stderr, "%s: created\n", SPOOL_DIR);
- stat(SPOOL_DIR, &sb);
+ if (stat(CRON_SPOOL, &sb) < 0 && errno == ENOENT) {
+ perror(CRON_SPOOL);
+ if (0 == mkdir(CRON_SPOOL, 0700)) {
+ fprintf(stderr, "%s: created\n", CRON_SPOOL);
+ stat(CRON_SPOOL, &sb);
} else {
- fprintf(stderr, "%s: ", SPOOL_DIR);
+ fprintf(stderr, "%s: ", CRON_SPOOL);
perror("mkdir");
exit(EXIT_FAILURE);
}
}
if (!S_ISDIR(sb.st_mode)) {
fprintf(stderr, "'%s' is not a directory, bailing out.\n",
- SPOOL_DIR);
+ CRON_SPOOL);
exit(EXIT_FAILURE);
}
if (grp != NULL) {
if (sb.st_gid != grp->gr_gid)
- chown(SPOOL_DIR, -1, grp->gr_gid);
+ chown(CRON_SPOOL, -1, grp->gr_gid);
if (sb.st_mode != 01730)
- chmod(SPOOL_DIR, 01730);
+ chmod(CRON_SPOOL, 01730);
}
- /* finally, look at AT_DIR ("atjobs" or some such)
+ /* finally, look at AT_SPOOL ("atjobs" or some such)
*/
- if (stat(AT_DIR, &sb) < 0 && errno == ENOENT) {
- perror(AT_DIR);
- if (0 == mkdir(AT_DIR, 0700)) {
- fprintf(stderr, "%s: created\n", AT_DIR);
- stat(AT_DIR, &sb);
+ if (stat(AT_SPOOL, &sb) < 0 && errno == ENOENT) {
+ perror(AT_SPOOL);
+ if (0 == mkdir(AT_SPOOL, 0700)) {
+ fprintf(stderr, "%s: created\n", AT_SPOOL);
+ stat(AT_SPOOL, &sb);
} else {
- fprintf(stderr, "%s: ", AT_DIR);
+ fprintf(stderr, "%s: ", AT_SPOOL);
perror("mkdir");
exit(EXIT_FAILURE);
}
}
if (!S_ISDIR(sb.st_mode)) {
fprintf(stderr, "'%s' is not a directory, bailing out.\n",
- AT_DIR);
+ AT_SPOOL);
exit(EXIT_FAILURE);
}
if (grp != NULL) {
if (sb.st_gid != grp->gr_gid)
- chown(AT_DIR, -1, grp->gr_gid);
+ chown(AT_SPOOL, -1, grp->gr_gid);
if (sb.st_mode != 01770)
- chmod(AT_DIR, 01770);
+ chmod(AT_SPOOL, 01770);
}
}
diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c
index 2d5b1e8f271..4e00df83aae 100644
--- a/usr.sbin/cron/cron.c
+++ b/usr.sbin/cron/cron.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cron.c,v 1.64 2015/11/09 01:12:27 millert Exp $ */
+/* $OpenBSD: cron.c,v 1.65 2015/11/09 15:57:39 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -430,8 +430,8 @@ open_socket(void)
}
bzero(&s_un, sizeof(s_un));
if (snprintf(s_un.sun_path, sizeof(s_un.sun_path), "%s/%s",
- SPOOL_DIR, CRONSOCK) >= sizeof(s_un.sun_path)) {
- fprintf(stderr, "%s/%s: path too long\n", SPOOL_DIR, CRONSOCK);
+ CRON_SPOOL, CRONSOCK) >= sizeof(s_un.sun_path)) {
+ fprintf(stderr, "%s/%s: path too long\n", CRON_SPOOL, CRONSOCK);
log_it("CRON", getpid(), "DEATH", "path too long");
exit(EXIT_FAILURE);
}
diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c
index d695e79228f..bf42a4d9309 100644
--- a/usr.sbin/cron/crontab.c
+++ b/usr.sbin/cron/crontab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crontab.c,v 1.83 2015/11/06 23:47:42 millert Exp $ */
+/* $OpenBSD: crontab.c,v 1.84 2015/11/09 15:57:39 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -236,7 +236,7 @@ list_cmd(void)
FILE *f;
log_it(RealUser, Pid, "LIST", User);
- if (snprintf(n, sizeof n, "%s/%s", SPOOL_DIR, User) >= sizeof(n)) {
+ if (snprintf(n, sizeof n, "%s/%s", CRON_SPOOL, User) >= sizeof(n)) {
fprintf(stderr, "path too long\n");
exit(EXIT_FAILURE);
}
@@ -262,7 +262,7 @@ delete_cmd(void)
char n[MAX_FNAME];
log_it(RealUser, Pid, "DELETE", User);
- if (snprintf(n, sizeof n, "%s/%s", SPOOL_DIR, User) >= sizeof(n)) {
+ if (snprintf(n, sizeof n, "%s/%s", CRON_SPOOL, User) >= sizeof(n)) {
fprintf(stderr, "path too long\n");
exit(EXIT_FAILURE);
}
@@ -273,7 +273,7 @@ delete_cmd(void)
perror(n);
exit(EXIT_FAILURE);
}
- poke_daemon(SPOOL_DIR, RELOAD_CRON);
+ poke_daemon(CRON_SPOOL, RELOAD_CRON);
}
static void
@@ -293,7 +293,7 @@ edit_cmd(void)
struct timespec ts[2];
log_it(RealUser, Pid, "BEGIN EDIT", User);
- if (snprintf(n, sizeof n, "%s/%s", SPOOL_DIR, User) >= sizeof(n)) {
+ if (snprintf(n, sizeof n, "%s/%s", CRON_SPOOL, User) >= sizeof(n)) {
fprintf(stderr, "path too long\n");
exit(EXIT_FAILURE);
}
@@ -443,7 +443,7 @@ replace_cmd(void)
return (-2);
}
if (snprintf(TempFilename, sizeof TempFilename, "%s/tmp.XXXXXXXXX",
- SPOOL_DIR) >= sizeof(TempFilename)) {
+ CRON_SPOOL) >= sizeof(TempFilename)) {
TempFilename[0] = '\0';
fprintf(stderr, "path too long\n");
return (-2);
@@ -536,7 +536,7 @@ replace_cmd(void)
goto done;
}
- if (snprintf(n, sizeof n, "%s/%s", SPOOL_DIR, User) >= sizeof(n)) {
+ if (snprintf(n, sizeof n, "%s/%s", CRON_SPOOL, User) >= sizeof(n)) {
fprintf(stderr, "path too long\n");
error = -2;
goto done;
@@ -551,7 +551,7 @@ replace_cmd(void)
TempFilename[0] = '\0';
log_it(RealUser, Pid, "REPLACE", User);
- poke_daemon(SPOOL_DIR, RELOAD_CRON);
+ poke_daemon(CRON_SPOOL, RELOAD_CRON);
done:
(void) signal(SIGHUP, SIG_DFL);
diff --git a/usr.sbin/cron/database.c b/usr.sbin/cron/database.c
index f0e3990c0f8..6a4227e2d47 100644
--- a/usr.sbin/cron/database.c
+++ b/usr.sbin/cron/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.29 2015/11/09 01:12:27 millert Exp $ */
+/* $OpenBSD: database.c,v 1.30 2015/11/09 15:57:39 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -51,12 +51,12 @@ load_database(cron_db **db)
DIR *dir;
user *u;
- /* before we start loading any data, do a stat on SPOOL_DIR
+ /* before we start loading any data, do a stat on CRON_SPOOL
* so that if anything changes as of this moment (i.e., before we've
* cached any of the database), we'll see the changes next time.
*/
- if (stat(SPOOL_DIR, &statbuf) < 0) {
- log_it("CRON", getpid(), "STAT FAILED", SPOOL_DIR);
+ if (stat(CRON_SPOOL, &statbuf) < 0) {
+ log_it("CRON", getpid(), "STAT FAILED", CRON_SPOOL);
return;
}
@@ -92,8 +92,8 @@ load_database(cron_db **db)
* efficiency. however, we need to close it in every fork, and
* we fork a lot more often than the mtime of the dir changes.
*/
- if (!(dir = opendir(SPOOL_DIR))) {
- log_it("CRON", getpid(), "OPENDIR FAILED", SPOOL_DIR);
+ if (!(dir = opendir(CRON_SPOOL))) {
+ log_it("CRON", getpid(), "OPENDIR FAILED", CRON_SPOOL);
/* Restore system crontab entry as needed. */
if (!TAILQ_EMPTY(&new_db->users) &&
(u = TAILQ_FIRST(&old_db->users))) {
@@ -122,7 +122,7 @@ load_database(cron_db **db)
if (strlcpy(fname, dp->d_name, sizeof fname) >= sizeof fname)
continue; /* XXX log? */
- if (snprintf(tabname, sizeof tabname, "%s/%s", SPOOL_DIR, fname) >=
+ if (snprintf(tabname, sizeof tabname, "%s/%s", CRON_SPOOL, fname) >=
sizeof(tabname))
continue; /* XXX log? */
diff --git a/usr.sbin/cron/pathnames.h b/usr.sbin/cron/pathnames.h
index e5db8c6be6a..b7f8a657779 100644
--- a/usr.sbin/cron/pathnames.h
+++ b/usr.sbin/cron/pathnames.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pathnames.h,v 1.18 2015/11/04 12:53:05 millert Exp $ */
+/* $OpenBSD: pathnames.h,v 1.19 2015/11/09 15:57:39 millert Exp $ */
/* Copyright 1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -23,7 +23,7 @@
#include <paths.h>
/* CRONDIR is where cron(8) and crontab(1) both chdir
- * to; SPOOL_DIR, CRON_ALLOW, CRON_DENY, and LOG_FILE
+ * to; CRON_SPOOL, CRON_ALLOW, CRON_DENY, and LOG_FILE
* are all relative to this directory.
*/
#define CRONDIR "/var/cron"
@@ -36,15 +36,15 @@
* newer than they were last time around (or which
* didn't exist last time around...)
*/
-#define SPOOL_DIR "tabs"
+#define CRON_SPOOL "tabs"
- /* ATDIR is where the at jobs live (relative to CRONDIR)
- * This directory will have its modtime updated
- * whenever at(1) changes a crontab; this is
+ /* AT_SPOOL is where the at jobs live (relative to
+ * CRONDIR). This directory will have its modtime
+ * updated whenever at(1) changes a crontab; this is
* the signal for cron(8) to look for changes in the
* jobs directory (new, changed or jobs).
*/
-#define AT_DIR "atjobs"
+#define AT_SPOOL "atjobs"
/* CRONSOCK is the name of the socket used by at and
* crontab to poke cron to re-read the at and cron