Looks great, ok nicm
On Wed, Nov 04, 2015 at 08:50:37AM -0700, Todd C. Miller wrote:
> This changes 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 internal .h files.
>
> - todd
>
> Index: usr.sbin/cron/atrun.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/atrun.c,v
> retrieving revision 1.33
> diff -u -p -u -r1.33 atrun.c
> --- usr.sbin/cron/atrun.c 25 Oct 2015 21:30:11 -0000 1.33
> +++ usr.sbin/cron/atrun.c 4 Nov 2015 15:48:07 -0000
> @@ -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 *);
> Index: usr.sbin/cron/client.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/client.c,v
> retrieving revision 1.2
> diff -u -p -u -r1.2 client.c
> --- usr.sbin/cron/client.c 3 Nov 2015 04:16:36 -0000 1.2
> +++ usr.sbin/cron/client.c 4 Nov 2015 15:48:07 -0000
> @@ -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,
> Index: usr.sbin/cron/common.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/common.c,v
> retrieving revision 1.1
> diff -u -p -u -r1.1 common.c
> --- usr.sbin/cron/common.c 31 Oct 2015 12:19:41 -0000 1.1
> +++ usr.sbin/cron/common.c 4 Nov 2015 15:48:07 -0000
> @@ -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)
> Index: usr.sbin/cron/cron.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/cron.c,v
> retrieving revision 1.61
> diff -u -p -u -r1.61 cron.c
> --- usr.sbin/cron/cron.c 4 Nov 2015 12:53:05 -0000 1.61
> +++ usr.sbin/cron/cron.c 4 Nov 2015 15:48:07 -0000
> @@ -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 };
>
> Index: usr.sbin/cron/cron.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/cron.h,v
> retrieving revision 1.11
> diff -u -p -u -r1.11 cron.h
> --- usr.sbin/cron/cron.h 6 Oct 2015 14:58:37 -0000 1.11
> +++ usr.sbin/cron/cron.h 4 Nov 2015 15:48:07 -0000
> @@ -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"
> Index: usr.sbin/cron/crontab.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/crontab.c,v
> retrieving revision 1.81
> diff -u -p -u -r1.81 crontab.c
> --- usr.sbin/cron/crontab.c 3 Nov 2015 21:10:08 -0000 1.81
> +++ usr.sbin/cron/crontab.c 4 Nov 2015 15:48:07 -0000
> @@ -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) {
> Index: usr.sbin/cron/database.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/database.c,v
> retrieving revision 1.27
> diff -u -p -u -r1.27 database.c
> --- usr.sbin/cron/database.c 26 Oct 2015 14:27:41 -0000 1.27
> +++ usr.sbin/cron/database.c 4 Nov 2015 15:48:07 -0000
> @@ -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))
>
> Index: usr.sbin/cron/do_command.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/do_command.c,v
> retrieving revision 1.51
> diff -u -p -u -r1.51 do_command.c
> --- usr.sbin/cron/do_command.c 29 Oct 2015 22:41:27 -0000 1.51
> +++ usr.sbin/cron/do_command.c 4 Nov 2015 15:48:07 -0000
> @@ -17,8 +17,30 @@
> * 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 *);
>
> Index: usr.sbin/cron/entry.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/entry.c,v
> retrieving revision 1.44
> diff -u -p -u -r1.44 entry.c
> --- usr.sbin/cron/entry.c 4 Nov 2015 12:53:05 -0000 1.44
> +++ usr.sbin/cron/entry.c 4 Nov 2015 15:48:07 -0000
> @@ -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,
> Index: usr.sbin/cron/env.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/env.c,v
> retrieving revision 1.31
> diff -u -p -u -r1.31 env.c
> --- usr.sbin/cron/env.c 29 Oct 2015 21:24:09 -0000 1.31
> +++ usr.sbin/cron/env.c 4 Nov 2015 15:48:07 -0000
> @@ -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)
> Index: usr.sbin/cron/externs.h
> ===================================================================
> RCS file: usr.sbin/cron/externs.h
> diff -N usr.sbin/cron/externs.h
> --- usr.sbin/cron/externs.h 4 Nov 2015 12:53:05 -0000 1.18
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -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>
> Index: usr.sbin/cron/job.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/job.c,v
> retrieving revision 1.11
> diff -u -p -u -r1.11 job.c
> --- usr.sbin/cron/job.c 9 Feb 2015 22:35:08 -0000 1.11
> +++ usr.sbin/cron/job.c 4 Nov 2015 15:48:07 -0000
> @@ -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;
> Index: usr.sbin/cron/macros.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/macros.h,v
> retrieving revision 1.13
> diff -u -p -u -r1.13 macros.h
> --- usr.sbin/cron/macros.h 26 Oct 2015 14:27:41 -0000 1.13
> +++ usr.sbin/cron/macros.h 4 Nov 2015 15:48:07 -0000
> @@ -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
>
> Index: usr.sbin/cron/misc.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/misc.c,v
> retrieving revision 1.67
> diff -u -p -u -r1.67 misc.c
> --- usr.sbin/cron/misc.c 4 Nov 2015 14:47:02 -0000 1.67
> +++ usr.sbin/cron/misc.c 4 Nov 2015 15:48:07 -0000
> @@ -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,
> break;
> syslog(*info ? LOG_INFO : LOG_WARNING, "(%s) %s (%s)", username, event,
> detail);
> -
> -
> }
>
> void
> Index: usr.sbin/cron/popen.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/popen.c,v
> retrieving revision 1.28
> diff -u -p -u -r1.28 popen.c
> --- usr.sbin/cron/popen.c 4 Oct 2015 09:08:46 -0000 1.28
> +++ usr.sbin/cron/popen.c 4 Nov 2015 15:48:07 -0000
> @@ -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
> Index: usr.sbin/cron/structs.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/structs.h,v
> retrieving revision 1.5
> diff -u -p -u -r1.5 structs.h
> --- usr.sbin/cron/structs.h 17 Jun 2004 22:11:55 -0000 1.5
> +++ usr.sbin/cron/structs.h 4 Nov 2015 15:48:07 -0000
> @@ -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;
> Index: usr.sbin/cron/user.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/cron/user.c,v
> retrieving revision 1.15
> diff -u -p -u -r1.15 user.c
> --- usr.sbin/cron/user.c 6 Oct 2015 14:58:37 -0000 1.15
> +++ usr.sbin/cron/user.c 4 Nov 2015 15:48:07 -0000
> @@ -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)
> Index: usr.bin/at/at.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/at/at.c,v
> retrieving revision 1.67
> diff -u -p -u -r1.67 at.c
> --- usr.bin/at/at.c 3 Nov 2015 16:28:43 -0000 1.67
> +++ usr.bin/at/at.c 4 Nov 2015 15:48:07 -0000
> @@ -33,9 +33,31 @@
>
> #define MAIN_PROGRAM
>
> -#include "cron.h"
> -#include "at.h"
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +
> +#include <bitstring.h> /* for structs.h */
> +#include <ctype.h>
> +#include <dirent.h>
> +#include <errno.h>
> +#include <fcntl.h>
> #include <limits.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"
> +
> +#include "at.h"
>
> #define ALARMC 10 /* Number of seconds to wait for timeout */
> #define TIMESIZE 50 /* Size of buffer passed to strftime() */
>