jcs's openbsd hax
openbsd

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@

millert fa575ea2 02ab83e9

+276 -92
+25 -3
usr.bin/at/at.c
··· 1 - /* $OpenBSD: at.c,v 1.67 2015/11/03 16:28:43 millert Exp $ */ 1 + /* $OpenBSD: at.c,v 1.68 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* 4 4 * at.c : Put file into atrun queue ··· 33 33 34 34 #define MAIN_PROGRAM 35 35 36 - #include "cron.h" 37 - #include "at.h" 36 + #include <sys/types.h> 37 + #include <sys/stat.h> 38 + 39 + #include <bitstring.h> /* for structs.h */ 40 + #include <ctype.h> 41 + #include <dirent.h> 42 + #include <errno.h> 43 + #include <fcntl.h> 38 44 #include <limits.h> 45 + #include <locale.h> 46 + #include <pwd.h> 47 + #include <signal.h> 48 + #include <stdio.h> 49 + #include <stdlib.h> 50 + #include <string.h> 51 + #include <time.h> 52 + #include <unistd.h> 53 + 54 + #include "pathnames.h" 55 + #include "macros.h" 56 + #include "structs.h" 57 + #include "funcs.h" 58 + #include "globals.h" 59 + 60 + #include "at.h" 39 61 40 62 #define ALARMC 10 /* Number of seconds to wait for timeout */ 41 63 #define TIMESIZE 50 /* Size of buffer passed to strftime() */
+27 -3
usr.sbin/cron/atrun.c
··· 1 - /* $OpenBSD: atrun.c,v 1.33 2015/10/25 21:30:11 millert Exp $ */ 1 + /* $OpenBSD: atrun.c,v 1.34 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com> ··· 20 20 * Materiel Command, USAF, under agreement number F39502-99-1-0512. 21 21 */ 22 22 23 - #include "cron.h" 23 + #include <sys/types.h> 24 + #include <sys/resource.h> 25 + #include <sys/stat.h> 26 + #include <sys/wait.h> 27 + 28 + #include <bitstring.h> /* for structs.h */ 29 + #include <bsd_auth.h> 30 + #include <ctype.h> 31 + #include <dirent.h> 32 + #include <errno.h> 33 + #include <fcntl.h> 24 34 #include <limits.h> 25 - #include <sys/resource.h> 35 + #include <login_cap.h> 36 + #include <pwd.h> 37 + #include <signal.h> 38 + #include <stdio.h> 39 + #include <stdlib.h> 40 + #include <string.h> 41 + #include <time.h> 42 + #include <unistd.h> 43 + 44 + #include "config.h" 45 + #include "pathnames.h" 46 + #include "macros.h" 47 + #include "structs.h" 48 + #include "funcs.h" 49 + #include "globals.h" 26 50 27 51 static void unlink_job(at_db *, atjob *); 28 52 static void run_job(atjob *, char *);
+18 -2
usr.sbin/cron/client.c
··· 1 - /* $OpenBSD: client.c,v 1.2 2015/11/03 04:16:36 guenther Exp $ */ 1 + /* $OpenBSD: client.c,v 1.3 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #include "cron.h" 20 + #include <sys/types.h> 21 + #include <sys/socket.h> 22 + #include <sys/un.h> 23 + 24 + #include <bitstring.h> /* for structs.h */ 25 + #include <stdio.h> 26 + #include <stdlib.h> 27 + #include <string.h> 28 + #include <time.h> /* for structs.h */ 29 + #include <unistd.h> 30 + #include <utime.h> 31 + 32 + #include "pathnames.h" 33 + #include "macros.h" 34 + #include "structs.h" 35 + #include "funcs.h" 36 + #include "globals.h" 21 37 22 38 /* int in_file(const char *string, FILE *file, int error) 23 39 * return TRUE if one of the lines in file matches string exactly,
+20 -2
usr.sbin/cron/common.c
··· 1 - /* $OpenBSD: common.c,v 1.1 2015/10/31 12:19:41 millert Exp $ */ 1 + /* $OpenBSD: common.c,v 1.2 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #include "cron.h" 20 + #include <sys/types.h> 21 + #include <sys/stat.h> 22 + 23 + #include <bitstring.h> /* for structs.h */ 24 + #include <errno.h> 25 + #include <grp.h> 26 + #include <limits.h> 27 + #include <stdio.h> 28 + #include <stdlib.h> 29 + #include <string.h> 30 + #include <time.h> 31 + #include <unistd.h> 32 + 33 + #include "config.h" 34 + #include "pathnames.h" 35 + #include "macros.h" 36 + #include "structs.h" 37 + #include "funcs.h" 38 + #include "globals.h" 21 39 22 40 void 23 41 set_cron_cwd(void)
+24 -2
usr.sbin/cron/cron.c
··· 1 - /* $OpenBSD: cron.c,v 1.61 2015/11/04 12:53:05 millert Exp $ */ 1 + /* $OpenBSD: cron.c,v 1.62 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 19 19 20 20 #define MAIN_PROGRAM 21 21 22 - #include "cron.h" 22 + #include <sys/types.h> 23 + #include <sys/socket.h> 24 + #include <sys/stat.h> 25 + #include <sys/un.h> 26 + #include <sys/wait.h> 27 + 28 + #include <bitstring.h> 29 + #include <errno.h> 30 + #include <locale.h> 31 + #include <poll.h> 32 + #include <signal.h> 33 + #include <stdio.h> 34 + #include <stdlib.h> 35 + #include <string.h> 36 + #include <time.h> 37 + #include <unistd.h> 38 + 39 + #include "config.h" 40 + #include "pathnames.h" 41 + #include "macros.h" 42 + #include "structs.h" 43 + #include "funcs.h" 44 + #include "globals.h" 23 45 24 46 enum timejump { negative, small, medium, large }; 25 47
+1 -3
usr.sbin/cron/cron.h
··· 1 - /* $OpenBSD: cron.h,v 1.11 2015/10/06 14:58:37 tedu Exp $ */ 1 + /* $OpenBSD: cron.h,v 1.12 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #define CRON_VERSION "V5.0" 21 20 #include "config.h" 22 - #include "externs.h" 23 21 #include "pathnames.h" 24 22 #include "macros.h" 25 23 #include "structs.h"
+23 -7
usr.sbin/cron/crontab.c
··· 1 - /* $OpenBSD: crontab.c,v 1.81 2015/11/03 21:10:08 millert Exp $ */ 1 + /* $OpenBSD: crontab.c,v 1.82 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #include <err.h> 21 - 22 20 #define MAIN_PROGRAM 23 21 24 - #include "cron.h" 22 + #include <sys/types.h> 23 + #include <sys/stat.h> 24 + #include <sys/wait.h> 25 + 26 + #include <bitstring.h> /* for structs.h */ 27 + #include <err.h> 28 + #include <errno.h> 29 + #include <locale.h> 30 + #include <pwd.h> 31 + #include <signal.h> 32 + #include <stdio.h> 33 + #include <stdlib.h> 34 + #include <string.h> 35 + #include <time.h> 36 + #include <unistd.h> 37 + 38 + #include "pathnames.h" 39 + #include "macros.h" 40 + #include "structs.h" 41 + #include "funcs.h" 42 + #include "globals.h" 25 43 26 44 #define NHEADER_LINES 3 27 45 28 46 enum opt_t { opt_unknown, opt_list, opt_delete, opt_edit, opt_replace }; 29 - 30 - static char *getoptargs = "u:ler"; 31 47 32 48 static pid_t Pid; 33 49 static gid_t crontab_gid; ··· 133 149 strlcpy(RealUser, User, sizeof(RealUser)); 134 150 Filename[0] = '\0'; 135 151 Option = opt_unknown; 136 - while (-1 != (argch = getopt(argc, argv, getoptargs))) { 152 + while ((argch = getopt(argc, argv, "u:ler")) != -1) { 137 153 switch (argch) { 138 154 case 'u': 139 155 if (getuid() != 0) {
+19 -2
usr.sbin/cron/database.c
··· 1 - /* $OpenBSD: database.c,v 1.27 2015/10/26 14:27:41 millert Exp $ */ 1 + /* $OpenBSD: database.c,v 1.28 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #include "cron.h" 20 + #include <sys/types.h> 21 + #include <sys/stat.h> 22 + 23 + #include <bitstring.h> /* for structs.h */ 24 + #include <dirent.h> 25 + #include <fcntl.h> 26 + #include <limits.h> 27 + #include <pwd.h> 28 + #include <stdio.h> 29 + #include <stdlib.h> 30 + #include <string.h> 31 + #include <time.h> /* for structs.h */ 32 + #include <unistd.h> 33 + 34 + #include "pathnames.h" 35 + #include "macros.h" 36 + #include "structs.h" 37 + #include "funcs.h" 21 38 22 39 #define HASH(a,b) ((a)+(b)) 23 40
+24 -2
usr.sbin/cron/do_command.c
··· 1 - /* $OpenBSD: do_command.c,v 1.51 2015/10/29 22:41:27 millert Exp $ */ 1 + /* $OpenBSD: do_command.c,v 1.52 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #include "cron.h" 20 + #include <sys/types.h> 21 + #include <sys/wait.h> 22 + 23 + #include <bitstring.h> /* for structs.h */ 24 + #include <bsd_auth.h> 25 + #include <ctype.h> 26 + #include <errno.h> 27 + #include <fcntl.h> 28 + #include <limits.h> 29 + #include <login_cap.h> 30 + #include <pwd.h> 31 + #include <signal.h> 32 + #include <stdio.h> 33 + #include <stdlib.h> 34 + #include <string.h> 35 + #include <time.h> /* for structs.h */ 36 + #include <unistd.h> 21 37 #include <vis.h> 38 + 39 + #include "config.h" 40 + #include "pathnames.h" 41 + #include "macros.h" 42 + #include "structs.h" 43 + #include "funcs.h" 22 44 23 45 static void child_process(entry *, user *); 24 46
+16 -2
usr.sbin/cron/entry.c
··· 1 - /* $OpenBSD: entry.c,v 1.44 2015/11/04 12:53:05 millert Exp $ */ 1 + /* $OpenBSD: entry.c,v 1.45 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* 4 4 * Copyright 1988,1990,1993,1994 by Paul Vixie ··· 18 18 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 19 */ 20 20 21 - #include "cron.h" 21 + #include <sys/types.h> 22 + 23 + #include <bitstring.h> /* for structs.h */ 24 + #include <ctype.h> 25 + #include <pwd.h> 26 + #include <stdio.h> 27 + #include <stdlib.h> 28 + #include <string.h> 29 + #include <time.h> /* for structs.h */ 30 + #include <unistd.h> 31 + 32 + #include "pathnames.h" 33 + #include "macros.h" 34 + #include "structs.h" 35 + #include "funcs.h" 22 36 23 37 typedef enum ecode { 24 38 e_none, e_minute, e_hour, e_dom, e_month, e_dow,
+15 -2
usr.sbin/cron/env.c
··· 1 - /* $OpenBSD: env.c,v 1.31 2015/10/29 21:24:09 millert Exp $ */ 1 + /* $OpenBSD: env.c,v 1.32 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #include "cron.h" 20 + #include <sys/types.h> 21 + 22 + #include <bitstring.h> /* for structs.h */ 23 + #include <ctype.h> 24 + #include <errno.h> 25 + #include <stdio.h> 26 + #include <stdlib.h> 27 + #include <string.h> 28 + #include <time.h> /* for structs.h */ 29 + 30 + #include "macros.h" 31 + #include "structs.h" 32 + #include "funcs.h" 33 + #include "globals.h" 21 34 22 35 char ** 23 36 env_init(void)
-50
usr.sbin/cron/externs.h
··· 1 - /* $OpenBSD: externs.h,v 1.18 2015/11/04 12:53:05 millert Exp $ */ 2 - 3 - /* Copyright 1993,1994 by Paul Vixie 4 - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 5 - * Copyright (c) 1997,2000 by Internet Software Consortium, Inc. 6 - * 7 - * Permission to use, copy, modify, and distribute this software for any 8 - * purpose with or without fee is hereby granted, provided that the above 9 - * copyright notice and this permission notice appear in all copies. 10 - * 11 - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 12 - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 14 - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 17 - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 - */ 19 - 20 - /* reorder these #include's at your peril */ 21 - 22 - #include <sys/types.h> 23 - #include <sys/time.h> 24 - #include <sys/wait.h> 25 - #include <sys/file.h> 26 - #include <sys/stat.h> 27 - #include <sys/socket.h> 28 - #include <sys/un.h> 29 - 30 - #include <bitstring.h> 31 - #include <ctype.h> 32 - #include <dirent.h> 33 - #include <errno.h> 34 - #include <fcntl.h> 35 - #include <grp.h> 36 - #include <limits.h> 37 - #include <locale.h> 38 - #include <pwd.h> 39 - #include <signal.h> 40 - #include <stdarg.h> 41 - #include <stdio.h> 42 - #include <stdlib.h> 43 - #include <string.h> 44 - #include <time.h> 45 - #include <poll.h> 46 - #include <unistd.h> 47 - #include <utime.h> 48 - #include <syslog.h> 49 - #include <login_cap.h> 50 - #include <bsd_auth.h>
+11 -2
usr.sbin/cron/job.c
··· 1 - /* $OpenBSD: job.c,v 1.11 2015/02/09 22:35:08 deraadt Exp $ */ 1 + /* $OpenBSD: job.c,v 1.12 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #include "cron.h" 20 + #include <sys/types.h> 21 + 22 + #include <bitstring.h> /* for structs.h */ 23 + #include <stdio.h> 24 + #include <stdlib.h> 25 + #include <time.h> /* for structs.h */ 26 + 27 + #include "macros.h" 28 + #include "structs.h" 29 + #include "funcs.h" 21 30 22 31 typedef struct _job { 23 32 struct _job *next;
+3 -1
usr.sbin/cron/macros.h
··· 1 - /* $OpenBSD: macros.h,v 1.13 2015/10/26 14:27:41 millert Exp $ */ 1 + /* $OpenBSD: macros.h,v 1.14 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 16 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 + 20 + #define CRON_VERSION "V5.0" 19 21 20 22 #define TRUE 1 21 23 #define FALSE 0
+15 -4
usr.sbin/cron/misc.c
··· 1 - /* $OpenBSD: misc.c,v 1.67 2015/11/04 14:47:02 millert Exp $ */ 1 + /* $OpenBSD: misc.c,v 1.68 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #include "cron.h" 20 + #include <sys/types.h> 21 + #include <sys/wait.h> 22 + 23 + #include <bitstring.h> /* for structs.h */ 24 + #include <stdio.h> 25 + #include <stdlib.h> 26 + #include <string.h> 27 + #include <syslog.h> 28 + #include <time.h> /* for structs.h */ 29 + 30 + #include "macros.h" 31 + #include "structs.h" 32 + #include "funcs.h" 33 + #include "globals.h" 21 34 22 35 static int syslog_open = FALSE; 23 36 ··· 122 135 break; 123 136 syslog(*info ? LOG_INFO : LOG_WARNING, "(%s) %s (%s)", username, event, 124 137 detail); 125 - 126 - 127 138 } 128 139 129 140 void
+18 -2
usr.sbin/cron/popen.c
··· 1 - /* $OpenBSD: popen.c,v 1.28 2015/10/04 09:08:46 tedu Exp $ */ 1 + /* $OpenBSD: popen.c,v 1.29 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 1988, 1993, 1994 ··· 37 37 * globbing stuff since we don't need it. also execvp instead of execv. 38 38 */ 39 39 40 - #include "cron.h" 40 + #include <sys/types.h> 41 + #include <sys/wait.h> 42 + 43 + #include <bitstring.h> /* for structs.h */ 44 + #include <errno.h> 45 + #include <login_cap.h> 46 + #include <pwd.h> 47 + #include <signal.h> 48 + #include <stdio.h> 49 + #include <stdlib.h> 50 + #include <string.h> 51 + #include <unistd.h> 52 + #include <time.h> /* for structs.h */ 53 + 54 + #include "macros.h" 55 + #include "structs.h" 56 + #include "funcs.h" 41 57 42 58 #define MAX_ARGV 100 43 59 #define MAX_GARGV 1000
+3 -1
usr.sbin/cron/structs.h
··· 1 - /* $OpenBSD: structs.h,v 1.5 2004/06/17 22:11:55 millert Exp $ */ 1 + /* $OpenBSD: structs.h,v 1.6 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 16 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 + 20 + struct passwd; 19 21 20 22 typedef struct _entry { 21 23 struct _entry *next;
+14 -2
usr.sbin/cron/user.c
··· 1 - /* $OpenBSD: user.c,v 1.15 2015/10/06 14:58:37 tedu Exp $ */ 1 + /* $OpenBSD: user.c,v 1.16 2015/11/04 20:28:17 millert Exp $ */ 2 2 3 3 /* Copyright 1988,1990,1993,1994 by Paul Vixie 4 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") ··· 17 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 18 */ 19 19 20 - #include "cron.h" 20 + #include <sys/types.h> 21 + 22 + #include <bitstring.h> /* for structs.h */ 23 + #include <ctype.h> 24 + #include <errno.h> 25 + #include <stdio.h> 26 + #include <stdlib.h> 27 + #include <string.h> 28 + #include <time.h> /* for structs.h */ 29 + 30 + #include "macros.h" 31 + #include "structs.h" 32 + #include "funcs.h" 21 33 22 34 void 23 35 free_user(user *u)