diff options
author | cvs2svn <cvs2svn@FreeBSD.org> | 1999-01-21 00:55:32 +0000 |
---|---|---|
committer | cvs2svn <cvs2svn@FreeBSD.org> | 1999-01-21 00:55:32 +0000 |
commit | 76b5366091f76c9bc73570149ef5055648fc2c39 (patch) | |
tree | 590d020e0f2a5bea6e09d66d951a674443b21d67 /contrib/sendmail/src/conf.c | |
parent | 4b4d01da6f07f7754ff6a6e4f5223e9f0984d1a6 (diff) |
Notes
Diffstat (limited to 'contrib/sendmail/src/conf.c')
-rw-r--r-- | contrib/sendmail/src/conf.c | 267 |
1 files changed, 64 insertions, 203 deletions
diff --git a/contrib/sendmail/src/conf.c b/contrib/sendmail/src/conf.c index 82e7543f1047..838cd17d2356 100644 --- a/contrib/sendmail/src/conf.c +++ b/contrib/sendmail/src/conf.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)conf.c 8.450 (Berkeley) 12/17/1998"; +static char sccsid[] = "@(#)conf.c 8.431 (Berkeley) 6/25/98"; #endif /* not lint */ # include "sendmail.h" @@ -217,6 +217,7 @@ setdefaults(e) int i; struct passwd *pw; char buf[MAXNAME]; + extern void inittimeouts __P((char *)); extern void setdefuser __P((void)); extern void setupmaps __P((void)); extern void setupmailers __P((void)); @@ -246,7 +247,7 @@ setdefaults(e) DefGid = 1; /* option g */ setdefuser(); } - TrustedUid = 0; + TrustedFileUid = 0; if (tTd(37, 4)) printf("setdefaults: DefUser=%s, DefUid=%d, DefGid=%d\n", DefUser != NULL ? DefUser : "<1:1>", @@ -291,7 +292,6 @@ setdefaults(e) #ifdef HESIOD_INIT HesiodContext = NULL; #endif - ControlSocketName = NULL; setupmaps(); setupmailers(); setupheaders(); @@ -324,6 +324,7 @@ void setupmailers() { char buf[100]; + extern void makemailer __P((char *)); strcpy(buf, "prog, P=/bin/sh, F=lsoDq9, T=DNS/RFC822/X-Unix, A=sh -c \201u"); makemailer(buf); @@ -837,14 +838,6 @@ switch_map_find(service, maptype, mapreturn) *p++ = '\0'; if (buf[0] == '\0') continue; - if (p == NULL) - { - sm_syslog(LOG_ERR, NOQID, - "Bad line on %.100s: %.100s", - ServiceSwitchFile, - buf); - continue; - } while (isspace(*p)) p++; if (*p == '\0') @@ -1287,10 +1280,10 @@ init_md(argc, argv) #endif #ifdef __QNX__ /* - ** Due to QNX's network distributed nature, you can target a tcpip - ** stack on a different node in the qnx network; this patch lets - ** this feature work. The __sock_locate() must be done before the - ** environment is clear. + ** Due to QNX's network distributed nature, you can target a tcpip + ** stack on a different node in the qnx network; this patch lets + ** this feature work. The __sock_locate() must be done before the + ** environment is clear. */ __sock_locate(); #endif @@ -2054,7 +2047,7 @@ refuseconnections(port) else if (conncnt++ > ConnRateThrottle && ConnRateThrottle > 0) { /* sleep to flatten out connection load */ - sm_setproctitle(TRUE, "deferring connections on port %d: %d per second", + setproctitle("deferring connections on port %d: %d per second", port, ConnRateThrottle); if (LogLevel >= 14) sm_syslog(LOG_INFO, NOQID, @@ -2066,7 +2059,7 @@ refuseconnections(port) CurrentLA = getla(); if (CurrentLA >= refusela) { - sm_setproctitle(TRUE, "rejecting connections on port %d: load average: %d", + setproctitle("rejecting connections on port %d: load average: %d", port, CurrentLA); if (LogLevel >= 14) sm_syslog(LOG_INFO, NOQID, @@ -2077,7 +2070,7 @@ refuseconnections(port) if (!enoughdiskspace(MinBlocksFree + 1)) { - sm_setproctitle(TRUE, "rejecting connections on port %d: min free: %d", + setproctitle("rejecting connections on port %d: min free: %d", port, MinBlocksFree); if (LogLevel >= 14) sm_syslog(LOG_INFO, NOQID, @@ -2088,10 +2081,12 @@ refuseconnections(port) if (MaxChildren > 0 && CurChildren >= MaxChildren) { + extern void proc_list_probe __P((void)); + proc_list_probe(); if (CurChildren >= MaxChildren) { - sm_setproctitle(TRUE, "rejecting connections on port %d: %d children, max %d", + setproctitle("rejecting connections on port %d: %d children, max %d", port, CurChildren, MaxChildren); if (LogLevel >= 14) sm_syslog(LOG_INFO, NOQID, @@ -2175,12 +2170,12 @@ typedef unsigned int *pt_entry_t; # define SPT_PADCHAR ' ' # endif -#endif /* SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN */ - # ifndef SPT_BUFSIZE # define SPT_BUFSIZE MAXLINE # endif +#endif /* SPT_TYPE != SPT_NONE && SPT_TYPE != SPT_BUILTIN */ + /* ** Pointers for setproctitle. ** This allows "ps" listings to give more useful information. @@ -2325,44 +2320,6 @@ setproctitle(fmt, va_alist) #endif /* SPT_TYPE != SPT_BUILTIN */ /* -** SM_SETPROCTITLE -- set process task and set process title for ps -** -** Possibly set process status and call setproctitle() to -** change the ps display. -** -** Parameters: -** status -- whether or not to store as process status -** fmt -- a printf style format string. -** a, b, c -- possible parameters to fmt. -** -** Returns: -** none. -*/ - -/*VARARGS2*/ -void -# ifdef __STDC__ -sm_setproctitle(bool status, const char *fmt, ...) -# else -sm_setproctitle(status, fmt, va_alist) - bool status; - const char *fmt; - va_dcl -#endif -{ - char buf[SPT_BUFSIZE]; - - VA_LOCAL_DECL - /* print the argument string */ - VA_START(fmt); - (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); - VA_END; - - if (status) - proc_list_set(getpid(), buf); - setproctitle("%s", buf); -} -/* ** WAITFOR -- wait for a particular process id. ** ** Parameters: @@ -2832,8 +2789,8 @@ dgux_inet_addr(host) /* -** this version hacked to add `atend' flag to allow state machine -** to reset if invoked by the program to scan args for a 2nd time +** this version hacked to add `atend' flag to allow state machine +** to reset if invoked by the program to scan args for a 2nd time */ #if defined(LIBC_SCCS) && !defined(lint) @@ -3005,7 +2962,7 @@ char *DefaultUserShells[] = "/bin/bsh", /* Bourne shell */ "/usr/bin/bsh", #endif -#if defined(__svr4__) || defined(__svr5__) +#ifdef __svr4__ "/bin/ksh", /* Korn shell */ "/usr/bin/ksh", #endif @@ -3708,63 +3665,9 @@ setvendor(vendor) } #endif -#if defined(VENDOR_NAME) && defined(VENDOR_CODE) - if (strcasecmp(vendor, VENDOR_NAME) == 0) - { - VendorCode = VENDOR_CODE; - return TRUE; - } -#endif - return FALSE; } /* -** GETVENDOR -- return vendor name based on vendor code -** -** Parameters: -** vendorcode -- numeric representation of vendor. -** -** Returns: -** string containing vendor name. -*/ - -char * -getvendor(vendorcode) - int vendorcode; -{ -#if defined(VENDOR_NAME) && defined(VENDOR_CODE) - /* - ** Can't have the same switch case twice so need to - ** handle VENDOR_CODE outside of switch. It might - ** match one of the existing VENDOR_* codes. - */ - - if (vendorcode == VENDOR_CODE) - return VENDOR_NAME; -#endif - - switch (vendorcode) - { - case VENDOR_BERKELEY: - return "Berkeley"; - - case VENDOR_SUN: - return "Sun"; - - case VENDOR_HP: - return "HP"; - - case VENDOR_IBM: - return "IBM"; - - case VENDOR_SENDMAIL: - return "Sendmail"; - - default: - return "Unknown"; - } -} -/* ** VENDOR_PRE_DEFAULTS, VENDOR_POST_DEFAULTS -- set vendor-specific defaults ** ** Vendor_pre_defaults is called before reading the configuration @@ -3827,7 +3730,7 @@ vendor_daemon_setup(e) if (getluid() != -1) { usrerr("Daemon cannot have LUID"); - finis(FALSE, EX_USAGE); + exit(EX_USAGE); } #endif /* SECUREWARE */ } @@ -4270,88 +4173,11 @@ secureware_setup_secure(uid) rc, uid); break; } - finis(FALSE, EX_NOPERM); + exit(EX_NOPERM); } } #endif /* SECUREWARE */ /* -** ADD_LOCAL_HOST_NAMES -- Add a hostname to class 'w' based on IP address -** -** Add hostnames to class 'w' based on the IP address read from -** the network interface. -** -** Parameters: -** sa -- a pointer to a SOCKADDR containing the address -** -** Returns: -** 0 if successful, -1 if host lookup fails. -*/ - -int -add_hostnames(sa) - SOCKADDR *sa; -{ - struct hostent *hp; - - /* lookup name with IP address */ - switch (sa->sa.sa_family) - { - case AF_INET: - hp = sm_gethostbyaddr((char *) &sa->sin.sin_addr, - sizeof(sa->sin.sin_addr), sa->sa.sa_family); - break; - - default: -#if _FFR_LOG_UNSUPPORTED_FAMILIES - /* XXX: Give warning about unsupported family */ - if (LogLevel > 3) - sm_syslog(LOG_WARNING, NOQID, - "Unsupported address family %d: %.100s", - sa->sa.sa_family, anynet_ntoa(sa)); -#endif - return -1; - } - - if (hp == NULL) - { - int save_errno = errno; - - if (LogLevel > 3) - sm_syslog(LOG_WARNING, NOQID, - "gethostbyaddr(%.100s) failed: %d\n", - anynet_ntoa(sa), -#if NAMED_BIND - h_errno -#else - -1 -#endif - ); - errno = save_errno; - return -1; - } - - /* save its cname */ - if (!wordinclass((char *) hp->h_name, 'w')) - { - setclass('w', (char *) hp->h_name); - if (tTd(0, 4)) - printf("\ta.k.a.: %s\n", hp->h_name); - } - - /* save all it aliases name */ - while (*hp->h_aliases) - { - if (!wordinclass(*hp->h_aliases, 'w')) - { - setclass('w', *hp->h_aliases); - if (tTd(0, 4)) - printf("\ta.k.a.: %s\n", *hp->h_aliases); - } - hp->h_aliases++; - } - return 0; -} -/* ** LOAD_IF_NAMES -- load interface-specific names into $=w ** ** Parameters: @@ -4428,8 +4254,9 @@ load_if_names() for (i = 0; i < ifc.ifc_len; ) { struct ifreq *ifr = (struct ifreq *) &ifc.ifc_buf[i]; - SOCKADDR *sa = (SOCKADDR *) &ifr->ifr_addr; + struct sockaddr *sa = &ifr->ifr_addr; struct in_addr ia; + struct hostent *hp; #ifdef SIOCGIFFLAGS struct ifreq ifrf; #endif @@ -4437,14 +4264,14 @@ load_if_names() extern char *inet_ntoa(); #ifdef BSD4_4_SOCKADDR - if (sa->sa.sa_len > sizeof ifr->ifr_addr) - i += sizeof ifr->ifr_name + sa->sa.sa_len; + if (sa->sa_len > sizeof ifr->ifr_addr) + i += sizeof ifr->ifr_name + sa->sa_len; else #endif i += sizeof *ifr; if (tTd(0, 20)) - printf("%s\n", anynet_ntoa(sa)); + printf("%s\n", anynet_ntoa((SOCKADDR *) sa)); if (ifr->ifr_addr.sa_family != AF_INET) continue; @@ -4463,7 +4290,7 @@ load_if_names() continue; /* extract IP address from the list*/ - ia = sa->sin.sin_addr; + ia = (((struct sockaddr_in *) sa)->sin_addr); if (ia.s_addr == INADDR_ANY || ia.s_addr == INADDR_NONE) { message("WARNING: interface %s is UP with %s address", @@ -4473,7 +4300,7 @@ load_if_names() /* save IP address in text from */ (void) snprintf(ip_addr, sizeof ip_addr, "[%.*s]", - (int)sizeof ip_addr - 3, + sizeof ip_addr - 3, inet_ntoa(ia)); if (!wordinclass(ip_addr, 'w')) { @@ -4486,7 +4313,41 @@ load_if_names() if (bitset(IFF_LOOPBACK, IFRFREF.ifr_flags)) continue; - (void) add_hostnames(sa); + /* lookup name with IP address */ + hp = sm_gethostbyaddr((char *) &ia, sizeof(ia), AF_INET); + if (hp == NULL) + { + if (LogLevel > 3) + sm_syslog(LOG_WARNING, NOQID, + "gethostbyaddr(%.100s) failed: %d\n", + inet_ntoa(ia), +#if NAMED_BIND + h_errno); +#else + -1); +#endif + continue; + } + + /* save its cname */ + if (!wordinclass((char *) hp->h_name, 'w')) + { + setclass('w', (char *) hp->h_name); + if (tTd(0, 4)) + printf("\ta.k.a.: %s\n", hp->h_name); + } + + /* save all it aliases name */ + while (*hp->h_aliases) + { + if (!wordinclass(*hp->h_aliases, 'w')) + { + setclass('w', *hp->h_aliases); + if (tTd(0, 4)) + printf("\ta.k.a.: %s\n", *hp->h_aliases); + } + hp->h_aliases++; + } } free(ifc.ifc_buf); close(s); @@ -4551,7 +4412,7 @@ sm_syslog(level, id, fmt, va_alist) extern int SyslogErrno; extern char *DoprEnd; VA_LOCAL_DECL - extern void sm_dopr __P((char *, const char *, va_list)); + extern void sm_dopr __P((char *, const char *, ...)); SyslogErrno = errno; if (id == NULL) |