summaryrefslogtreecommitdiff
path: root/usr.sbin/cron
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2015-11-04 20:28:18 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2015-11-04 20:28:18 +0000
commitd3037ce85fdf672ecf23feb9122711d0bfff6ad9 (patch)
tree78f10e62a05c58c3281b29ece05db3bf5c93d5c2 /usr.sbin/cron
parent5fc6bd7c6445514ec75f98c8790517cb902f2176 (diff)
Change cron from including all headers in every file to only including
what each .c file needs. I have not removed cron.h since it will be used in a future clean up of the cron's .h files. OK nicm@
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r--usr.sbin/cron/atrun.c30
-rw-r--r--usr.sbin/cron/client.c20
-rw-r--r--usr.sbin/cron/common.c22
-rw-r--r--usr.sbin/cron/cron.c26
-rw-r--r--usr.sbin/cron/cron.h4
-rw-r--r--usr.sbin/cron/crontab.c30
-rw-r--r--usr.sbin/cron/database.c21
-rw-r--r--usr.sbin/cron/do_command.c26
-rw-r--r--usr.sbin/cron/entry.c18
-rw-r--r--usr.sbin/cron/env.c17
-rw-r--r--usr.sbin/cron/externs.h50
-rw-r--r--usr.sbin/cron/job.c13
-rw-r--r--usr.sbin/cron/macros.h4
-rw-r--r--usr.sbin/cron/misc.c19
-rw-r--r--usr.sbin/cron/popen.c20
-rw-r--r--usr.sbin/cron/structs.h4
-rw-r--r--usr.sbin/cron/user.c16
17 files changed, 251 insertions, 89 deletions
diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c
index 1b427a6a489..c873ed1a164 100644
--- a/usr.sbin/cron/atrun.c
+++ b/usr.sbin/cron/atrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atrun.c,v 1.33 2015/10/25 21:30:11 millert Exp $ */
+/* $OpenBSD: atrun.c,v 1.34 2015/11/04 20:28:17 millert Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -20,9 +20,33 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
-#include "cron.h"
-#include <limits.h>
+#include <sys/types.h>
#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <bsd_auth.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <login_cap.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "pathnames.h"
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
+#include "globals.h"
static void unlink_job(at_db *, atjob *);
static void run_job(atjob *, char *);
diff --git a/usr.sbin/cron/client.c b/usr.sbin/cron/client.c
index 2cf65abd00a..0334bff30e3 100644
--- a/usr.sbin/cron/client.c
+++ b/usr.sbin/cron/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.2 2015/11/03 04:16:36 guenther Exp $ */
+/* $OpenBSD: client.c,v 1.3 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,7 +17,23 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "cron.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h> /* for structs.h */
+#include <unistd.h>
+#include <utime.h>
+
+#include "pathnames.h"
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
+#include "globals.h"
/* int in_file(const char *string, FILE *file, int error)
* return TRUE if one of the lines in file matches string exactly,
diff --git a/usr.sbin/cron/common.c b/usr.sbin/cron/common.c
index 0b44b811de8..0c07f1b3354 100644
--- a/usr.sbin/cron/common.c
+++ b/usr.sbin/cron/common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.c,v 1.1 2015/10/31 12:19:41 millert Exp $ */
+/* $OpenBSD: common.c,v 1.2 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,7 +17,25 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "cron.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <errno.h>
+#include <grp.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "pathnames.h"
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
+#include "globals.h"
void
set_cron_cwd(void)
diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c
index b1bb36b6901..68e12e22187 100644
--- a/usr.sbin/cron/cron.c
+++ b/usr.sbin/cron/cron.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cron.c,v 1.61 2015/11/04 12:53:05 millert Exp $ */
+/* $OpenBSD: cron.c,v 1.62 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -19,7 +19,29 @@
#define MAIN_PROGRAM
-#include "cron.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/un.h>
+#include <sys/wait.h>
+
+#include <bitstring.h>
+#include <errno.h>
+#include <locale.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "pathnames.h"
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
+#include "globals.h"
enum timejump { negative, small, medium, large };
diff --git a/usr.sbin/cron/cron.h b/usr.sbin/cron/cron.h
index 695470ce877..0c6390650bf 100644
--- a/usr.sbin/cron/cron.h
+++ b/usr.sbin/cron/cron.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cron.h,v 1.11 2015/10/06 14:58:37 tedu Exp $ */
+/* $OpenBSD: cron.h,v 1.12 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,9 +17,7 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define CRON_VERSION "V5.0"
#include "config.h"
-#include "externs.h"
#include "pathnames.h"
#include "macros.h"
#include "structs.h"
diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c
index b6fee330734..afb38e10114 100644
--- a/usr.sbin/cron/crontab.c
+++ b/usr.sbin/cron/crontab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crontab.c,v 1.81 2015/11/03 21:10:08 millert Exp $ */
+/* $OpenBSD: crontab.c,v 1.82 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,18 +17,34 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <err.h>
-
#define MAIN_PROGRAM
-#include "cron.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <err.h>
+#include <errno.h>
+#include <locale.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "pathnames.h"
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
+#include "globals.h"
#define NHEADER_LINES 3
enum opt_t { opt_unknown, opt_list, opt_delete, opt_edit, opt_replace };
-static char *getoptargs = "u:ler";
-
static pid_t Pid;
static gid_t crontab_gid;
static gid_t user_gid;
@@ -133,7 +149,7 @@ parse_args(int argc, char *argv[])
strlcpy(RealUser, User, sizeof(RealUser));
Filename[0] = '\0';
Option = opt_unknown;
- while (-1 != (argch = getopt(argc, argv, getoptargs))) {
+ while ((argch = getopt(argc, argv, "u:ler")) != -1) {
switch (argch) {
case 'u':
if (getuid() != 0) {
diff --git a/usr.sbin/cron/database.c b/usr.sbin/cron/database.c
index 19d2e186da9..d9c41d94c08 100644
--- a/usr.sbin/cron/database.c
+++ b/usr.sbin/cron/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.27 2015/10/26 14:27:41 millert Exp $ */
+/* $OpenBSD: database.c,v 1.28 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,7 +17,24 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "cron.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <dirent.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h> /* for structs.h */
+#include <unistd.h>
+
+#include "pathnames.h"
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
#define HASH(a,b) ((a)+(b))
diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c
index 9aba71f3e3a..a3218c9a776 100644
--- a/usr.sbin/cron/do_command.c
+++ b/usr.sbin/cron/do_command.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: do_command.c,v 1.51 2015/10/29 22:41:27 millert Exp $ */
+/* $OpenBSD: do_command.c,v 1.52 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,9 +17,31 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "cron.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <bsd_auth.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <login_cap.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h> /* for structs.h */
+#include <unistd.h>
#include <vis.h>
+#include "config.h"
+#include "pathnames.h"
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
+
static void child_process(entry *, user *);
void
diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c
index 952dfab07ff..1a0592bc338 100644
--- a/usr.sbin/cron/entry.c
+++ b/usr.sbin/cron/entry.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entry.c,v 1.44 2015/11/04 12:53:05 millert Exp $ */
+/* $OpenBSD: entry.c,v 1.45 2015/11/04 20:28:17 millert Exp $ */
/*
* Copyright 1988,1990,1993,1994 by Paul Vixie
@@ -18,7 +18,21 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "cron.h"
+#include <sys/types.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <ctype.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h> /* for structs.h */
+#include <unistd.h>
+
+#include "pathnames.h"
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
typedef enum ecode {
e_none, e_minute, e_hour, e_dom, e_month, e_dow,
diff --git a/usr.sbin/cron/env.c b/usr.sbin/cron/env.c
index 5f41c1d6b96..f8ce702ae08 100644
--- a/usr.sbin/cron/env.c
+++ b/usr.sbin/cron/env.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: env.c,v 1.31 2015/10/29 21:24:09 millert Exp $ */
+/* $OpenBSD: env.c,v 1.32 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,7 +17,20 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "cron.h"
+#include <sys/types.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h> /* for structs.h */
+
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
+#include "globals.h"
char **
env_init(void)
diff --git a/usr.sbin/cron/externs.h b/usr.sbin/cron/externs.h
deleted file mode 100644
index 9e5798a0c85..00000000000
--- a/usr.sbin/cron/externs.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* $OpenBSD: externs.h,v 1.18 2015/11/04 12:53:05 millert Exp $ */
-
-/* Copyright 1993,1994 by Paul Vixie
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1997,2000 by Internet Software Consortium, Inc.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* reorder these #include's at your peril */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <grp.h>
-#include <limits.h>
-#include <locale.h>
-#include <pwd.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <poll.h>
-#include <unistd.h>
-#include <utime.h>
-#include <syslog.h>
-#include <login_cap.h>
-#include <bsd_auth.h>
diff --git a/usr.sbin/cron/job.c b/usr.sbin/cron/job.c
index 2648dc87a3f..f206ebbf71e 100644
--- a/usr.sbin/cron/job.c
+++ b/usr.sbin/cron/job.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: job.c,v 1.11 2015/02/09 22:35:08 deraadt Exp $ */
+/* $OpenBSD: job.c,v 1.12 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,7 +17,16 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "cron.h"
+#include <sys/types.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h> /* for structs.h */
+
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
typedef struct _job {
struct _job *next;
diff --git a/usr.sbin/cron/macros.h b/usr.sbin/cron/macros.h
index 7b52d1b90a8..585f788096b 100644
--- a/usr.sbin/cron/macros.h
+++ b/usr.sbin/cron/macros.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: macros.h,v 1.13 2015/10/26 14:27:41 millert Exp $ */
+/* $OpenBSD: macros.h,v 1.14 2015/11/04 20:28:17 millert Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,6 +17,8 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define CRON_VERSION "V5.0"
+
#define TRUE 1
#define FALSE 0
diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c
index 200ae4e6ca1..9dd4ad08f3e 100644
--- a/usr.sbin/cron/misc.c
+++ b/usr.sbin/cron/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.67 2015/11/04 14:47:02 millert Exp $ */
+/* $OpenBSD: misc.c,v 1.68 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,7 +17,20 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "cron.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <time.h> /* for structs.h */
+
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
+#include "globals.h"
static int syslog_open = FALSE;
@@ -122,8 +135,6 @@ log_it(const char *username, pid_t xpid, const char *event, const char *detail)
break;
syslog(*info ? LOG_INFO : LOG_WARNING, "(%s) %s (%s)", username, event,
detail);
-
-
}
void
diff --git a/usr.sbin/cron/popen.c b/usr.sbin/cron/popen.c
index 2f33d264f02..eb449673729 100644
--- a/usr.sbin/cron/popen.c
+++ b/usr.sbin/cron/popen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popen.c,v 1.28 2015/10/04 09:08:46 tedu Exp $ */
+/* $OpenBSD: popen.c,v 1.29 2015/11/04 20:28:17 millert Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@@ -37,7 +37,23 @@
* globbing stuff since we don't need it. also execvp instead of execv.
*/
-#include "cron.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <errno.h>
+#include <login_cap.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h> /* for structs.h */
+
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
#define MAX_ARGV 100
#define MAX_GARGV 1000
diff --git a/usr.sbin/cron/structs.h b/usr.sbin/cron/structs.h
index 1b72d79fe7e..d3ac43c88ce 100644
--- a/usr.sbin/cron/structs.h
+++ b/usr.sbin/cron/structs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: structs.h,v 1.5 2004/06/17 22:11:55 millert Exp $ */
+/* $OpenBSD: structs.h,v 1.6 2015/11/04 20:28:17 millert Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,6 +17,8 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+struct passwd;
+
typedef struct _entry {
struct _entry *next;
struct passwd *pwd;
diff --git a/usr.sbin/cron/user.c b/usr.sbin/cron/user.c
index 2fbc356ae23..d31d58056bc 100644
--- a/usr.sbin/cron/user.c
+++ b/usr.sbin/cron/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.15 2015/10/06 14:58:37 tedu Exp $ */
+/* $OpenBSD: user.c,v 1.16 2015/11/04 20:28:17 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -17,7 +17,19 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "cron.h"
+#include <sys/types.h>
+
+#include <bitstring.h> /* for structs.h */
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h> /* for structs.h */
+
+#include "macros.h"
+#include "structs.h"
+#include "funcs.h"
void
free_user(user *u)