1 /* Copyright 1993,1994 by Paul Vixie 2 * All rights reserved 3 */ 4 5 /* 6 * Copyright (c) 1997 by Internet Software Consortium 7 * 8 * Permission to use, copy, modify, and distribute this software for any 9 * purpose with or without fee is hereby granted, provided that the above 10 * copyright notice and this permission notice appear in all copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS 13 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 14 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE 15 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 18 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 19 * SOFTWARE. 20 */ 21 22 /* reorder these #include's at your peril */ 23 24 #include <sys/param.h> 25 #include <sys/types.h> 26 #include <sys/time.h> 27 #include <sys/wait.h> 28 #include <sys/fcntl.h> 29 #include <sys/file.h> 30 #include <sys/stat.h> 31 32 #include <bitstring.h> 33 #include <ctype.h> 34 #include <dirent.h> 35 #include <err.h> 36 #include <errno.h> 37 #include <fcntl.h> 38 #include <grp.h> 39 #include <libutil.h> 40 #include <locale.h> 41 #include <pwd.h> 42 #include <signal.h> 43 #include <stdarg.h> 44 #include <stdio.h> 45 #include <stdlib.h> 46 #include <string.h> 47 #include <time.h> 48 #include <unistd.h> 49 #include <utime.h> 50 51 #if defined(SYSLOG) 52 # include <syslog.h> 53 #endif 54 55 #if (defined(BSD)) && (BSD >= 199103) || defined(__linux) || defined(AIX) 56 # include <paths.h> 57 #endif /*BSD*/ 58 59 #if !defined(_PATH_SENDMAIL) 60 # define _PATH_SENDMAIL "/usr/lib/sendmail" 61 #endif /*SENDMAIL*/ 62 63 #if defined(__bsdi__) && (_BSDI_VERSION > 199510) 64 #include <login_cap.h> 65 #endif /* __bsdi__ */ 66 67 #define DIR_T struct dirent 68 #define WAIT_T int 69 #define SIG_T sig_t 70 #define TIME_T time_t 71 #define PID_T pid_t 72 73 #ifndef TZNAME_ALREADY_DEFINED 74 extern char *tzname[2]; 75 #endif 76 #define TZONE(tm) tzname[(tm).tm_isdst] 77 78 #if (BSD >= 198606) 79 # define HAVE_FCHOWN 80 # define HAVE_FCHMOD 81 #endif 82 83 #if (BSD >= 199103) 84 # define HAVE_SAVED_UIDS 85 #endif 86 87 #define MY_UID(pw) getuid() 88 #define MY_GID(pw) getgid() 89 90 #if !defined(AIX) && !defined(UNICOS) 91 # define SYS_TIME_H 1 92 #else 93 # define SYS_TIME_H 0 94 #endif 95 96 /* getopt() isn't part of POSIX. some systems define it in <stdlib.h> anyway. 97 * of those that do, some complain that our definition is different and some 98 * do not. to add to the misery and confusion, some systems define getopt() 99 * in ways that we cannot predict or comprehend, yet do not define the adjunct 100 * external variables needed for the interface. 101 */ 102 #if (!defined(BSD) || (BSD < 198911)) 103 int getopt(int, char * const *, const char *); 104 #endif 105 106 #if (!defined(BSD) || (BSD < 199103)) 107 extern char *optarg; 108 extern int optind, opterr, optopt; 109 #endif 110 111 /* digital unix needs this but does not give us a way to identify it. 112 */ 113 extern int flock(int, int); 114 115 /* not all systems who provice flock() provide these definitions. 116 */ 117 #ifndef LOCK_SH 118 # define LOCK_SH 1 119 #endif 120 #ifndef LOCK_EX 121 # define LOCK_EX 2 122 #endif 123 #ifndef LOCK_NB 124 # define LOCK_NB 4 125 #endif 126 #ifndef LOCK_UN 127 # define LOCK_UN 8 128 #endif 129