summaryrefslogtreecommitdiff
path: root/src/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c1072
1 files changed, 465 insertions, 607 deletions
diff --git a/src/conf.c b/src/conf.c
index d708a27..25c369d 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -1,45 +1,24 @@
/*
- * Copyright (c) 1983, 1995-1997 Eric P. Allman
+ * Copyright (c) 1998 Sendmail, Inc. All rights reserved.
+ * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * By using this file, you agree to the terms and conditions set
+ * forth in the LICENSE file which can be found at the top level of
+ * the sendmail distribution.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
*/
#ifndef lint
-static char sccsid[] = "@(#)conf.c 8.379 (Berkeley) 10/20/97";
+static char sccsid[] = "@(#)conf.c 8.452 (Berkeley) 1/26/1999";
#endif /* not lint */
# include "sendmail.h"
# include "pathnames.h"
# include <sys/ioctl.h>
# include <sys/param.h>
+# include <limits.h>
/*
** CONF.C -- Sendmail Configuration Tables.
@@ -63,8 +42,6 @@ static char sccsid[] = "@(#)conf.c 8.379 (Berkeley) 10/20/97";
*/
-
-
/*
** Header info table
** Final (null) entry contains the flags used for any other field.
@@ -140,15 +117,63 @@ struct prival PrivacyValues[] =
{ "novrfy", PRIV_NOVRFY },
{ "restrictmailq", PRIV_RESTRICTMAILQ },
{ "restrictqrun", PRIV_RESTRICTQRUN },
-#if _FFR_PRIVACY_NOETRN
{ "noetrn", PRIV_NOETRN },
-#endif
+ { "noverb", PRIV_NOVERB },
{ "authwarnings", PRIV_AUTHWARNINGS },
{ "noreceipts", PRIV_NORECEIPTS },
{ "goaway", PRIV_GOAWAY },
{ NULL, 0 }
};
+/*
+** DontBlameSendmail values
+*/
+struct dbsval DontBlameSendmailValues[] =
+{
+ { "safe", DBS_SAFE },
+ { "assumesafechown", DBS_ASSUMESAFECHOWN },
+ { "groupwritabledirpathsafe", DBS_GROUPWRITABLEDIRPATHSAFE },
+ { "groupwritableforwardfilesafe",
+ DBS_GROUPWRITABLEFORWARDFILESAFE },
+ { "groupwritableincludefilesafe",
+ DBS_GROUPWRITABLEINCLUDEFILESAFE },
+ { "groupwritablealiasfile", DBS_GROUPWRITABLEALIASFILE },
+ { "worldwritablealiasfile", DBS_WORLDWRITABLEALIASFILE },
+ { "forwardfileinunsafedirpath", DBS_FORWARDFILEINUNSAFEDIRPATH },
+ { "includefileinunsafedirpath", DBS_INCLUDEFILEINUNSAFEDIRPATH },
+ { "mapinunsafedirpath", DBS_MAPINUNSAFEDIRPATH },
+ { "linkedaliasfileinwritabledir",
+ DBS_LINKEDALIASFILEINWRITABLEDIR },
+ { "linkedclassfileinwritabledir",
+ DBS_LINKEDCLASSFILEINWRITABLEDIR },
+ { "linkedforwardfileinwritabledir",
+ DBS_LINKEDFORWARDFILEINWRITABLEDIR },
+ { "linkedincludefileinwritabledir",
+ DBS_LINKEDINCLUDEFILEINWRITABLEDIR },
+ { "linkedmapinwritabledir", DBS_LINKEDMAPINWRITABLEDIR },
+ { "linkedserviceswitchfileinwritabledir",
+ DBS_LINKEDSERVICESWITCHFILEINWRITABLEDIR },
+ { "filedeliverytohardlink", DBS_FILEDELIVERYTOHARDLINK },
+ { "filedeliverytosymlink", DBS_FILEDELIVERYTOSYMLINK },
+ { "writemaptohardlink", DBS_WRITEMAPTOHARDLINK },
+ { "writemaptosymlink", DBS_WRITEMAPTOSYMLINK },
+ { "writestatstohardlink", DBS_WRITESTATSTOHARDLINK },
+ { "writestatstosymlink", DBS_WRITESTATSTOSYMLINK },
+ { "forwardfileingroupwritabledirpath",
+ DBS_FORWARDFILEINGROUPWRITABLEDIRPATH },
+ { "includefileingroupwritabledirpath",
+ DBS_INCLUDEFILEINGROUPWRITABLEDIRPATH },
+ { "classfileinunsafedirpath", DBS_CLASSFILEINUNSAFEDIRPATH },
+ { "errorheaderinunsafedirpath", DBS_ERRORHEADERINUNSAFEDIRPATH },
+ { "helpfileinunsafedirpath", DBS_HELPFILEINUNSAFEDIRPATH },
+ { "forwardfileinunsafedirpathsafe",
+ DBS_FORWARDFILEINUNSAFEDIRPATHSAFE },
+ { "includefileinunsafedirpathsafe",
+ DBS_INCLUDEFILEINUNSAFEDIRPATHSAFE },
+ { "runprograminunsafedirpath", DBS_RUNPROGRAMINUNSAFEDIRPATH },
+ { "runwritableprogram", DBS_RUNWRITABLEPROGRAM },
+ { NULL, 0 }
+};
/*
@@ -190,12 +215,12 @@ setdefaults(e)
register ENVELOPE *e;
{
int i;
+ struct passwd *pw;
char buf[MAXNAME];
- extern void inittimeouts();
- extern void setdefuser();
- extern void setupmaps();
- extern void setupmailers();
- extern void setupheaders();
+ extern void setdefuser __P((void));
+ extern void setupmaps __P((void));
+ extern void setupmailers __P((void));
+ extern void setupheaders __P((void));
SpaceSub = ' '; /* option B */
QueueLA = 8; /* option x */
@@ -206,8 +231,26 @@ setdefaults(e)
QueueFactor = WkRecipFact * 20; /* option q */
FileMode = (RealUid != geteuid()) ? 0644 : 0600;
/* option F */
- DefUid = 1; /* option u */
- DefGid = 1; /* option g */
+
+ if (((pw = getpwnam("mailnull")) != NULL && pw->pw_uid != 0) ||
+ ((pw = getpwnam("sendmail")) != NULL && pw->pw_uid != 0) ||
+ ((pw = getpwnam("daemon")) != NULL && pw->pw_uid != 0))
+ {
+ DefUid = pw->pw_uid; /* option u */
+ DefGid = pw->pw_gid; /* option g */
+ DefUser = newstr(pw->pw_name);
+ }
+ else
+ {
+ DefUid = 1; /* option u */
+ DefGid = 1; /* option g */
+ setdefuser();
+ }
+ TrustedUid = 0;
+ if (tTd(37, 4))
+ printf("setdefaults: DefUser=%s, DefUid=%d, DefGid=%d\n",
+ DefUser != NULL ? DefUser : "<1:1>",
+ (int) DefUid, (int) DefGid);
CheckpointInterval = 10; /* option C */
MaxHopCount = 25; /* option h */
e->e_sendmode = SM_FORK; /* option d */
@@ -217,7 +260,8 @@ setdefaults(e)
MciCacheTimeout = 5 MINUTES; /* option K */
LogLevel = 9; /* option L */
inittimeouts(NULL); /* option r */
- PrivacyFlags = 0; /* option p */
+ PrivacyFlags = PRIV_PUBLIC; /* option p */
+ DontBlameSendmail = DBS_SAFE; /* DontBlameSendmail option */
#if MIME8TO7
MimeMode = MM_CVTMIME|MM_PASS8BIT; /* option 8 */
#else
@@ -240,11 +284,15 @@ setdefaults(e)
ColonOkInAddr = TRUE;
DontLockReadFiles = TRUE;
DoubleBounceAddr = "postmaster";
+ MaxHeadersLength = MAXHDRSLEN;
snprintf(buf, sizeof buf, "%s%sdead.letter",
_PATH_VARTMP,
_PATH_VARTMP[sizeof _PATH_VARTMP - 2] == '/' ? "" : "/");
DeadLetterDrop = newstr(buf);
- setdefuser();
+#ifdef HESIOD_INIT
+ HesiodContext = NULL;
+#endif
+ ControlSocketName = NULL;
setupmaps();
setupmailers();
setupheaders();
@@ -265,6 +313,9 @@ setdefuser()
defpwent = sm_getpwuid(DefUid);
snprintf(defuserbuf, sizeof defuserbuf, "%s",
defpwent == NULL ? "nobody" : defpwent->pw_name);
+ if (tTd(37, 4))
+ printf("setdefuser: DefUid=%d, DefUser=%s\n",
+ (int) DefUid, DefUser);
}
/*
** SETUPMAILERS -- initialize default mailers
@@ -274,7 +325,6 @@ void
setupmailers()
{
char buf[100];
- extern void makemailer();
strcpy(buf, "prog, P=/bin/sh, F=lsoDq9, T=DNS/RFC822/X-Unix, A=sh -c \201u");
makemailer(buf);
@@ -399,6 +449,12 @@ setupmaps()
dequote_init, null_map_open, null_map_close,
dequote_map, null_map_store);
+#ifdef MAP_REGEX
+ MAPDEF("regex", NULL, 0,
+ regex_map_init, null_map_open, null_map_close,
+ regex_map_lookup, null_map_store);
+#endif
+
#if USERDB
/* user database */
MAPDEF("userdb", ".db", 0,
@@ -426,7 +482,7 @@ setupmaps()
map_parseargs, null_map_open, null_map_close,
null_map_lookup, null_map_store);
-#if _FFR_SYSLOG_MAP
+#if _FFR_MAP_SYSLOG
/* syslog map -- logs information to syslog */
MAPDEF("syslog", NULL, 0,
syslog_map_parseargs, null_map_open, null_map_close,
@@ -761,10 +817,14 @@ switch_map_find(service, maptype, mapreturn)
{
/* (re)read service switch */
register FILE *fp;
+ int sff = SFF_REGONLY|SFF_OPENASROOT|SFF_NOLOCK;
+
+ if (!bitset(DBS_LINKEDSERVICESWITCHFILEINWRITABLEDIR, DontBlameSendmail))
+ sff |= SFF_NOWLINK;
if (ConfigFileRead)
ServiceCacheTime = now;
- fp = fopen(ServiceSwitchFile, "r");
+ fp = safefopen(ServiceSwitchFile, O_RDONLY, 0, sff);
if (fp != NULL)
{
char buf[MAXLINE];
@@ -781,6 +841,14 @@ 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')
@@ -833,38 +901,42 @@ switch_map_find(service, maptype, mapreturn)
}
#endif
+#if !defined(_USE_SUN_NSSWITCH_)
/* if the service file doesn't work, use an absolute fallback */
+# ifdef _USE_DEC_SVC_CONF_
punt:
+# endif
for (svcno = 0; svcno < MAXMAPACTIONS; svcno++)
mapreturn[svcno] = 0;
svcno = 0;
if (strcmp(service, "aliases") == 0)
{
maptype[svcno++] = "files";
-#ifdef AUTO_NIS_ALIASES
-# ifdef NISPLUS
+# ifdef AUTO_NIS_ALIASES
+# ifdef NISPLUS
maptype[svcno++] = "nisplus";
-# endif
-# ifdef NIS
+# endif
+# ifdef NIS
maptype[svcno++] = "nis";
+# endif
# endif
-#endif
return svcno;
}
if (strcmp(service, "hosts") == 0)
{
-# if NAMED_BIND
+# if NAMED_BIND
maptype[svcno++] = "dns";
-# else
-# if defined(sun) && !defined(BSD) && !defined(_USE_SUN_NSSWITCH_)
+# else
+# if defined(sun) && !defined(BSD)
/* SunOS */
maptype[svcno++] = "nis";
+# endif
# endif
-# endif
maptype[svcno++] = "files";
return svcno;
}
return -1;
+#endif
}
/*
** USERNAME -- return the user id of the logged in user.
@@ -962,7 +1034,7 @@ ttypath()
}
/* see if we have write permission */
- if (stat(pathn, &stbuf) < 0 || !bitset(02, stbuf.st_mode))
+ if (stat(pathn, &stbuf) < 0 || !bitset(S_IWOTH, stbuf.st_mode))
{
errno = 0;
return (NULL);
@@ -1217,6 +1289,15 @@ init_md(argc, argv)
/* keep gethostby*() from stripping the local domain name */
set_domain_trim_off();
#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.
+ */
+ __sock_locate();
+#endif
#if SECUREWARE || defined(_SCO_unix_)
set_auth_parameters(argc, argv);
@@ -1330,10 +1411,6 @@ init_vendor_macros(e)
#include <nlist.h>
-#ifdef IRIX64
-# define nlist nlist64
-#endif
-
/* _PATH_UNIX should be defined in <paths.h> */
#ifndef _PATH_UNIX
# if defined(SYSTEM5)
@@ -1664,95 +1741,12 @@ getla()
#endif /* LA_TYPE == LA_PROCSTR */
#if LA_TYPE == LA_IRIX6
-
-#include <nlist.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#define X_AVENRUN 0
-struct nlist Nl32[] =
-{
- { LA_AVENRUN },
- { 0 },
-};
-struct nlist64 Nl64[] =
-{
- { LA_AVENRUN },
- { 0 },
-};
+#include <sys/sysmp.h>
int getla(void)
{
static int kmem = -1;
- static enum { getla_none, getla_32, getla_64 } kernel_type =
- getla_none;
- uint32_t avenrun[3];
-
- if (kernel_type == getla_none)
- {
- /* Try 32 bit kernel ... */
- errno = 0;
- if (nlist(_PATH_UNIX, Nl32) == 0)
- {
- if (tTd(3, 20))
- printf("getla: Kernel is 32bit\n");
-
- if (Nl32[X_AVENRUN].n_value == 0)
- {
- if (tTd(3, 1))
- printf("getla: nlist(%s, %s) ==> 0\n",
- _PATH_UNIX, LA_AVENRUN);
- }
- else
- kernel_type = getla_32;
- }
- else if (errno != 0)
- {
- if (tTd(3, 1))
- printf("getla: nlist(%s): %s\n",
- _PATH_UNIX, errstring(errno));
- }
- else
- {
- if (tTd(3, 20))
- printf("getla: Kernel is not 32bit\n");
- }
-
- /* Try 64 bit kernel ... */
- errno = 0;
- if (nlist64(_PATH_UNIX, Nl64) == 0)
- {
- if (tTd(3, 20))
- printf("getla: Kernel is 64bit\n");
-
- if (Nl64[X_AVENRUN].n_value == 0)
- {
- if (tTd(3, 1))
- printf("getla: nlist(%s, %s) ==> 0\n",
- _PATH_UNIX, LA_AVENRUN);
- }
- else
- kernel_type = getla_64;
- }
- else if (errno != 0)
- {
- if (tTd(3, 1))
- printf("getla: nlist64(%s): %s\n",
- _PATH_UNIX, errstring(errno));
- }
- else
- {
- if (tTd(3, 20))
- printf("getla: Kernel is not 64bit\n");
- }
- }
-
- if (kernel_type == getla_none)
- {
- if (tTd(3, 1))
- printf("getla: Failed to determine kernel type\n");
- return -1;
- }
+ int avenrun[3];
if (kmem < 0)
{
@@ -1760,56 +1754,34 @@ int getla(void)
if (kmem < 0)
{
if (tTd(3, 1))
- printf("getla: open(/dev/kmem): %s\n",
+ printf("getla: open(%s): %s\n", _PATH_KMEM,
errstring(errno));
return -1;
}
(void) fcntl(kmem, F_SETFD, 1);
}
- switch (kernel_type)
+ if (lseek(kmem, (sysmp(MP_KERNADDR, MPKA_AVENRUN) & 0x7fffffff), SEEK_SET) == -1 ||
+ read(kmem, (char *)avenrun, sizeof(avenrun)) < sizeof(avenrun))
{
- case getla_none:
+ if (tTd(3, 1))
+ printf("getla: lseek or read: %s\n",
+ errstring(errno));
return -1;
-
- case getla_32:
- if (lseek(kmem, (off_t) Nl32[X_AVENRUN].n_value, SEEK_SET) == -1 ||
- read(kmem, (char *) avenrun, sizeof(avenrun)) < sizeof(avenrun))
- {
- if (tTd(3, 1))
- printf("getla: lseek or read: %s\n",
- errstring(errno));
- return -1;
- }
- break;
-
- case getla_64:
- /* Using of lseek64 is perhaps overkill ... */
- if (lseek64(kmem, (off64_t) Nl64[X_AVENRUN].n_value, SEEK_SET) == -1 ||
- read(kmem, (char *) avenrun, sizeof(avenrun)) <
- sizeof(avenrun))
- {
- if (tTd(3, 1))
- printf("getla: lseek64 or read: %s\n",
- errstring(errno));
- return -1;
- }
- break;
}
if (tTd(3, 5))
{
- printf("getla: avenrun = %ld",
- (long int) avenrun[0]);
+ printf("getla: avenrun = %ld", (long int) avenrun[0]);
if (tTd(3, 15))
printf(", %ld, %ld",
- (long int)avenrun[1],
- (long int)avenrun[2]);
+ (long int) avenrun[1], (long int) avenrun[2]);
printf("\n");
}
+
if (tTd(3, 1))
- printf("getla: %d\n",
- (int) (avenrun[0] + FSCALE/2) >> FSHIFT);
+ printf("getla: %d\n", (int) (avenrun[0] + FSCALE/2) >> FSHIFT);
return ((int) (avenrun[0] + FSCALE/2) >> FSHIFT);
+
}
#endif
@@ -1909,6 +1881,8 @@ getla()
#endif /* LA_TYPE == LA_DEVSHORT */
#if LA_TYPE == LA_ALPHAOSF
+struct rtentry;
+struct mbuf;
# include <sys/table.h>
int getla()
@@ -2068,7 +2042,7 @@ refuseconnections(port)
time_t now;
static time_t lastconn = (time_t) 0;
static int conncnt = 0;
- extern bool enoughdiskspace();
+ extern bool enoughdiskspace __P((long));
#ifdef XLA
if (!xla_smtp_ok())
@@ -2084,7 +2058,7 @@ refuseconnections(port)
else if (conncnt++ > ConnRateThrottle && ConnRateThrottle > 0)
{
/* sleep to flatten out connection load */
- setproctitle("deferring connections on port %d: %d per second",
+ sm_setproctitle(TRUE, "deferring connections on port %d: %d per second",
port, ConnRateThrottle);
if (LogLevel >= 14)
sm_syslog(LOG_INFO, NOQID,
@@ -2096,7 +2070,7 @@ refuseconnections(port)
CurrentLA = getla();
if (CurrentLA >= refusela)
{
- setproctitle("rejecting connections on port %d: load average: %d",
+ sm_setproctitle(TRUE, "rejecting connections on port %d: load average: %d",
port, CurrentLA);
if (LogLevel >= 14)
sm_syslog(LOG_INFO, NOQID,
@@ -2107,7 +2081,7 @@ refuseconnections(port)
if (!enoughdiskspace(MinBlocksFree + 1))
{
- setproctitle("rejecting connections on port %d: min free: %d",
+ sm_setproctitle(TRUE, "rejecting connections on port %d: min free: %d",
port, MinBlocksFree);
if (LogLevel >= 14)
sm_syslog(LOG_INFO, NOQID,
@@ -2118,12 +2092,10 @@ refuseconnections(port)
if (MaxChildren > 0 && CurChildren >= MaxChildren)
{
- extern void proc_list_probe __P((void));
-
proc_list_probe();
if (CurChildren >= MaxChildren)
{
- setproctitle("rejecting connections on port %d: %d children, max %d",
+ sm_setproctitle(TRUE, "rejecting connections on port %d: %d children, max %d",
port, CurChildren, MaxChildren);
if (LogLevel >= 14)
sm_syslog(LOG_INFO, NOQID,
@@ -2207,12 +2179,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.
@@ -2249,18 +2221,23 @@ initsetproctitle(argc, argv, envp)
Argv = argv;
/*
- ** Find the last environment variable within sendmail's
- ** process memory area.
- */
- while (i > 0 && (envp[i - 1] < argv[0] ||
- envp[i - 1] > (argv[argc - 1] +
- strlen(argv[argc - 1]) + 1 + envpsize)))
- i--;
-
- if (i > 0)
- LastArgv = envp[i - 1] + strlen(envp[i - 1]);
- else
- LastArgv = argv[argc - 1] + strlen(argv[argc - 1]);
+ ** Determine how much space we can use for setproctitle.
+ ** Use all contiguous argv and envp pointers starting at argv[0]
+ */
+ for (i = 0; i < argc; i++)
+ {
+ if (i==0 || LastArgv + 1 == argv[i])
+ LastArgv = argv[i] + strlen(argv[i]);
+ else
+ continue;
+ }
+ for (i=0; envp[i] != NULL; i++)
+ {
+ if (LastArgv + 1 == envp[i])
+ LastArgv = envp[i] + strlen(envp[i]);
+ else
+ continue;
+ }
}
#if SPT_TYPE != SPT_BUILTIN
@@ -2352,6 +2329,44 @@ 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:
@@ -2723,6 +2738,23 @@ initgroups(name, basegid)
#endif
/*
+** SETGROUPS -- set group list
+**
+** Stub implementation for systems that don't have group lists
+*/
+
+#ifndef NGROUPS_MAX
+
+int
+setgroups(ngroups, grouplist)
+ int ngroups;
+ GIDSET_T grouplist[];
+{
+ return 0;
+}
+
+#endif
+ /*
** SETSID -- set session id (for non-POSIX systems)
*/
@@ -2804,8 +2836,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)
@@ -2921,333 +2953,6 @@ vsprintf(s, fmt, ap)
#endif
/*
-** SNPRINTF, VSNPRINT -- counted versions of printf
-**
-** These versions have been grabbed off the net. They have been
-** cleaned up to compile properly and support for .precision and
-** %lx has been added.
-*/
-
-/**************************************************************
- * Original:
- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
- * A bombproof version of doprnt (sm_dopr) included.
- * Sigh. This sort of thing is always nasty do deal with. Note that
- * the version here does not include floating point...
- *
- * snprintf() is used instead of sprintf() as it does limit checks
- * for string length. This covers a nasty loophole.
- *
- * The other functions are there to prevent NULL pointers from
- * causing nast effects.
- **************************************************************/
-
-/*static char _id[] = "$Id: snprintf.c,v 1.2 1995/10/09 11:19:47 roberto Exp $";*/
-static void sm_dopr();
-static char *DoprEnd;
-static int SnprfOverflow;
-
-#if !HASSNPRINTF
-
-/* VARARGS3 */
-int
-# ifdef __STDC__
-snprintf(char *str, size_t count, const char *fmt, ...)
-# else
-snprintf(str, count, fmt, va_alist)
- char *str;
- size_t count;
- const char *fmt;
- va_dcl
-#endif
-{
- int len;
- VA_LOCAL_DECL
-
- VA_START(fmt);
- len = vsnprintf(str, count, fmt, ap);
- VA_END;
- return len;
-}
-
-
-# ifndef luna2
-int
-vsnprintf(str, count, fmt, args)
- char *str;
- size_t count;
- const char *fmt;
- va_list args;
-{
- str[0] = 0;
- DoprEnd = str + count - 1;
- SnprfOverflow = 0;
- sm_dopr( str, fmt, args );
- if (count > 0)
- DoprEnd[0] = 0;
- if (SnprfOverflow && tTd(57, 2))
- printf("\nvsnprintf overflow, len = %d, str = %s",
- count, shortenstring(str, 203));
- return strlen(str);
-}
-
-# endif /* !luna2 */
-#endif /* !HASSNPRINTF */
-
-/*
- * sm_dopr(): poor man's version of doprintf
- */
-
-static void fmtstr __P((char *value, int ljust, int len, int zpad, int maxwidth));
-static void fmtnum __P((long value, int base, int dosign, int ljust, int len, int zpad));
-static void dostr __P(( char * , int ));
-static char *output;
-static void dopr_outch __P(( int c ));
-static int SyslogErrno;
-
-static void
-sm_dopr( buffer, format, args )
- char *buffer;
- const char *format;
- va_list args;
-{
- int ch;
- long value;
- int longflag = 0;
- int pointflag = 0;
- int maxwidth = 0;
- char *strvalue;
- int ljust;
- int len;
- int zpad;
-# if !HASSTRERROR && !defined(ERRLIST_PREDEFINED)
- extern char *sys_errlist[];
- extern int sys_nerr;
-# endif
-
-
- output = buffer;
- while( (ch = *format++) ){
- switch( ch ){
- case '%':
- ljust = len = zpad = maxwidth = 0;
- longflag = pointflag = 0;
- nextch:
- ch = *format++;
- switch( ch ){
- case 0:
- dostr( "**end of format**" , 0);
- return;
- case '-': ljust = 1; goto nextch;
- case '0': /* set zero padding if len not set */
- if(len==0 && !pointflag) zpad = '0';
- case '1': case '2': case '3':
- case '4': case '5': case '6':
- case '7': case '8': case '9':
- if (pointflag)
- maxwidth = maxwidth*10 + ch - '0';
- else
- len = len*10 + ch - '0';
- goto nextch;
- case '*':
- if (pointflag)
- maxwidth = va_arg( args, int );
- else
- len = va_arg( args, int );
- goto nextch;
- case '.': pointflag = 1; goto nextch;
- case 'l': longflag = 1; goto nextch;
- case 'u': case 'U':
- /*fmtnum(value,base,dosign,ljust,len,zpad) */
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value, 10,0, ljust, len, zpad ); break;
- case 'o': case 'O':
- /*fmtnum(value,base,dosign,ljust,len,zpad) */
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value, 8,0, ljust, len, zpad ); break;
- case 'd': case 'D':
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value, 10,1, ljust, len, zpad ); break;
- case 'x':
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value, 16,0, ljust, len, zpad ); break;
- case 'X':
- if( longflag ){
- value = va_arg( args, long );
- } else {
- value = va_arg( args, int );
- }
- fmtnum( value,-16,0, ljust, len, zpad ); break;
- case 's':
- strvalue = va_arg( args, char *);
- if (maxwidth > 0 || !pointflag) {
- if (pointflag && len > maxwidth)
- len = maxwidth; /* Adjust padding */
- fmtstr( strvalue,ljust,len,zpad, maxwidth);
- }
- break;
- case 'c':
- ch = va_arg( args, int );
- dopr_outch( ch ); break;
- case 'm':
-#if HASSTRERROR
- dostr(strerror(SyslogErrno), 0);
-#else
- if (SyslogErrno < 0 || SyslogErrno > sys_nerr)
- {
- dostr("Error ", 0);
- fmtnum(SyslogErrno, 10, 0, 0, 0, 0);
- }
- else
- dostr(sys_errlist[SyslogErrno], 0);
-#endif
- break;
-
- case '%': dopr_outch( ch ); continue;
- default:
- dostr( "???????" , 0);
- }
- break;
- default:
- dopr_outch( ch );
- break;
- }
- }
- *output = 0;
-}
-
-static void
-fmtstr( value, ljust, len, zpad, maxwidth )
- char *value;
- int ljust, len, zpad, maxwidth;
-{
- int padlen, strlen; /* amount to pad */
-
- if( value == 0 ){
- value = "<NULL>";
- }
- for( strlen = 0; value[strlen]; ++ strlen ); /* strlen */
- if (strlen > maxwidth && maxwidth)
- strlen = maxwidth;
- padlen = len - strlen;
- if( padlen < 0 ) padlen = 0;
- if( ljust ) padlen = -padlen;
- while( padlen > 0 ) {
- dopr_outch( ' ' );
- --padlen;
- }
- dostr( value, maxwidth );
- while( padlen < 0 ) {
- dopr_outch( ' ' );
- ++padlen;
- }
-}
-
-static void
-fmtnum( value, base, dosign, ljust, len, zpad )
- long value;
- int base, dosign, ljust, len, zpad;
-{
- int signvalue = 0;
- unsigned long uvalue;
- char convert[20];
- int place = 0;
- int padlen = 0; /* amount to pad */
- int caps = 0;
-
- /* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n",
- value, base, dosign, ljust, len, zpad )); */
- uvalue = value;
- if( dosign ){
- if( value < 0 ) {
- signvalue = '-';
- uvalue = -value;
- }
- }
- if( base < 0 ){
- caps = 1;
- base = -base;
- }
- do{
- convert[place++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")
- [uvalue % (unsigned)base ];
- uvalue = (uvalue / (unsigned)base );
- }while(uvalue);
- convert[place] = 0;
- padlen = len - place;
- if( padlen < 0 ) padlen = 0;
- if( ljust ) padlen = -padlen;
- /* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n",
- convert,place,signvalue,padlen)); */
- if( zpad && padlen > 0 ){
- if( signvalue ){
- dopr_outch( signvalue );
- --padlen;
- signvalue = 0;
- }
- while( padlen > 0 ){
- dopr_outch( zpad );
- --padlen;
- }
- }
- while( padlen > 0 ) {
- dopr_outch( ' ' );
- --padlen;
- }
- if( signvalue ) dopr_outch( signvalue );
- while( place > 0 ) dopr_outch( convert[--place] );
- while( padlen < 0 ){
- dopr_outch( ' ' );
- ++padlen;
- }
-}
-
-static void
-dostr( str , cut)
- char *str;
- int cut;
-{
- if (cut) {
- while(*str && cut-- > 0) dopr_outch(*str++);
- } else {
- while(*str) dopr_outch(*str++);
- }
-}
-
-static void
-dopr_outch( c )
- int c;
-{
-#if 0
- if( iscntrl(c) && c != '\n' && c != '\t' ){
- c = '@' + (c & 0x1F);
- if( DoprEnd == 0 || output < DoprEnd )
- *output++ = '^';
- }
-#endif
- if( DoprEnd == 0 || output < DoprEnd )
- *output++ = c;
- else
- SnprfOverflow++;
-}
- /*
** USERSHELLOK -- tell if a user's shell is ok for unrestricted use
**
** Parameters:
@@ -3267,6 +2972,9 @@ dopr_outch( c )
# if defined(_AIX3) || defined(_AIX4)
# include <userconf.h>
+# if _AIX4 >= 40200
+# include <userpw.h>
+# endif
# include <usersec.h>
# endif
@@ -3301,9 +3009,18 @@ char *DefaultUserShells[] =
"/bin/bsh", /* Bourne shell */
"/usr/bin/bsh",
#endif
-#ifdef __svr4__
+#if defined(__svr4__) || defined(__svr5__)
+ "/bin/ksh", /* Korn shell */
+ "/usr/bin/ksh",
+#endif
+#ifdef sgi
+ "/sbin/sh", /* SGI's shells really live in /sbin */
+ "/sbin/csh",
"/bin/ksh", /* Korn shell */
+ "/sbin/ksh",
"/usr/bin/ksh",
+ "/bin/tcsh", /* Extended csh */
+ "/usr/bin/tcsh",
#endif
NULL
};
@@ -3338,7 +3055,8 @@ usershellok(user, shell)
register FILE *shellf;
char buf[MAXLINE];
- if (shell == NULL || shell[0] == '\0' || wordinclass(user, 't'))
+ if (shell == NULL || shell[0] == '\0' || wordinclass(user, 't') ||
+ ConfigLevel <= 1)
return TRUE;
# if USEGETCONFATTR
@@ -3372,6 +3090,11 @@ usershellok(user, shell)
{
/* no /etc/shells; see if it is one of the std shells */
char **d;
+
+ if (errno != ENOENT && LogLevel > 3)
+ sm_syslog(LOG_ERR, NOQID,
+ "usershellok: cannot open %s: %s",
+ _PATH_SHELLS, errstring(errno));
for (d = DefaultUserShells; *d != NULL; d++)
{
@@ -3391,7 +3114,7 @@ usershellok(user, shell)
if (*p == '#' || *p == '\0')
continue;
q = p;
- while (*p != '\0' && *p != '#' && !isspace(*p))
+ while (*p != '\0' && *p != '#' && !(isascii(*p) && isspace(*p)))
p++;
*p = '\0';
if (strcmp(shell, q) == 0 || strcmp(WILDCARD_SHELL, q) == 0)
@@ -3503,8 +3226,10 @@ freediskspace(dir, bsize)
*bsize = FSBLOCKSIZE;
if (fs.SFS_BAVAIL <= 0)
return 0;
+ else if (fs.SFS_BAVAIL > LONG_MAX)
+ return LONG_MAX;
else
- return fs.SFS_BAVAIL;
+ return (long) fs.SFS_BAVAIL;
}
#endif
return (-1);
@@ -3692,6 +3417,7 @@ lockfile(fd, filename, ext, type)
int type;
{
int i;
+ int save_errno;
# if !HASFLOCK
int action;
struct flock lfd;
@@ -3724,9 +3450,10 @@ lockfile(fd, filename, ext, type)
printf("SUCCESS\n");
return TRUE;
}
+ save_errno = errno;
if (tTd(55, 60))
- printf("(%s) ", errstring(errno));
+ printf("(%s) ", errstring(save_errno));
/*
** On SunOS, if you are testing using -oQ/tmp/mqueue or
@@ -3737,21 +3464,19 @@ lockfile(fd, filename, ext, type)
** that this indicates that the lock is successfully grabbed.
*/
- if (errno == EINVAL)
+ if (save_errno == EINVAL)
{
if (tTd(55, 60))
printf("SUCCESS\n");
return TRUE;
}
- if (!bitset(LOCK_NB, type) || (errno != EACCES && errno != EAGAIN))
+ if (!bitset(LOCK_NB, type) || (save_errno != EACCES && save_errno != EAGAIN))
{
int omode = -1;
# ifdef F_GETFL
- int oerrno = errno;
-
(void) fcntl(fd, F_GETFL, &omode);
- errno = oerrno;
+ errno = save_errno;
# endif
syserr("cannot lockf(%s%s, fd=%d, type=%o, omode=%o, euid=%d)",
filename, ext, fd, type, omode, geteuid());
@@ -3772,18 +3497,17 @@ lockfile(fd, filename, ext, type)
printf("SUCCESS\n");
return TRUE;
}
+ save_errno = errno;
if (tTd(55, 60))
- printf("(%s) ", errstring(errno));
+ printf("(%s) ", errstring(save_errno));
- if (!bitset(LOCK_NB, type) || errno != EWOULDBLOCK)
+ if (!bitset(LOCK_NB, type) || save_errno != EWOULDBLOCK)
{
int omode = -1;
# ifdef F_GETFL
- int oerrno = errno;
-
(void) fcntl(fd, F_GETFL, &omode);
- errno = oerrno;
+ errno = save_errno;
# endif
syserr("cannot flock(%s%s, fd=%d, type=%o, omode=%o, euid=%d)",
filename, ext, fd, type, omode, geteuid());
@@ -3792,6 +3516,7 @@ lockfile(fd, filename, ext, type)
# endif
if (tTd(55, 60))
printf("FAIL\n");
+ errno = save_errno;
return FALSE;
}
/*
@@ -3861,7 +3586,7 @@ chownsafe(fd, safedir)
int rval;
/* give the system administrator a chance to override */
- if (ChownAlwaysSafe)
+ if (bitset(DBS_ASSUMESAFECHOWN, DontBlameSendmail))
return TRUE;
/*
@@ -3878,7 +3603,7 @@ chownsafe(fd, safedir)
return safedir && errno == 0 && rval IS_SAFE_CHOWN;
# endif
#else
- return ChownAlwaysSafe;
+ return bitset(DBS_ASSUMESAFECHOWN, DontBlameSendmail);
#endif
}
/*
@@ -3938,7 +3663,7 @@ getcfname()
return ConfFile;
#if NETINFO
{
- extern char *ni_propval();
+ extern char *ni_propval __P((char *, char *, char *, char *, int));
char *cflocation;
cflocation = ni_propval("/locations", NULL, "sendmail",
@@ -3987,9 +3712,63 @@ 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
@@ -4029,6 +3808,13 @@ void
vendor_post_defaults(e)
ENVELOPE *e;
{
+#ifdef __QNX__
+ char *p;
+
+ /* Makes sure the SOCK environment variable remains */
+ if (p = getextenv("SOCK"))
+ setuserenv("SOCK", p);
+#endif
#if defined(SUN_EXTENSIONS) && defined(SUN_DEFAULT_VALUES)
sun_post_defaults(e);
#endif
@@ -4045,7 +3831,7 @@ vendor_daemon_setup(e)
if (getluid() != -1)
{
usrerr("Daemon cannot have LUID");
- exit(EX_USAGE);
+ finis(FALSE, EX_USAGE);
}
#endif /* SECUREWARE */
}
@@ -4090,8 +3876,8 @@ vendor_set_uid(uid)
** e -- the current envelope.
**
** Returns:
-** TRUE -- if the connection should be accepted.
-** FALSE -- if it should be rejected.
+** error message from rejection.
+** NULL if not rejected.
*/
#if TCPWRAPPERS
@@ -4103,39 +3889,62 @@ int deny_severity = LOG_NOTICE;
#endif
#if DAEMON
-bool
+char *
validate_connection(sap, hostname, e)
SOCKADDR *sap;
char *hostname;
ENVELOPE *e;
{
+#if TCPWRAPPERS
+ char *host;
+#endif
+
if (tTd(48, 3))
printf("validate_connection(%s, %s)\n",
hostname, anynet_ntoa(sap));
if (rscheck("check_relay", hostname, anynet_ntoa(sap), e) != EX_OK)
{
+ static char reject[BUFSIZ*2];
+ extern char MsgBuf[];
+
if (tTd(48, 4))
printf(" ... validate_connection: BAD (rscheck)\n");
- return FALSE;
+
+ if (strlen(MsgBuf) > 5)
+ {
+ if (isascii(MsgBuf[0]) && isdigit(MsgBuf[0]) &&
+ isascii(MsgBuf[1]) && isdigit(MsgBuf[1]) &&
+ isascii(MsgBuf[2]) && isdigit(MsgBuf[2]))
+ strcpy(reject, &MsgBuf[4]);
+ else
+ strcpy(reject, MsgBuf);
+ }
+ else
+ strcpy(reject, "Access denied");
+
+ return reject;
}
#if TCPWRAPPERS
- if (TcpWrappers &&
- !hosts_ctl("sendmail", hostname, anynet_ntoa(sap), STRING_UNKNOWN))
+ if (hostname[0] == '[' && hostname[strlen(hostname) - 1] == ']')
+ host = "unknown";
+ else
+ host = hostname;
+ if (!hosts_ctl("sendmail", host, anynet_ntoa(sap), STRING_UNKNOWN))
{
if (tTd(48, 4))
printf(" ... validate_connection: BAD (tcpwrappers)\n");
if (LogLevel >= 4)
sm_syslog(LOG_NOTICE, NOQID,
"tcpwrappers (%s, %s) rejection",
- hostname, anynet_ntoa(sap));
- return FALSE;
+ host, anynet_ntoa(sap));
+ return "Access denied";
}
#endif
if (tTd(48, 4))
printf(" ... validate_connection: OK\n");
- return TRUE;
+ return NULL;
}
#endif
@@ -4153,8 +3962,6 @@ validate_connection(sap, hostname, e)
static char sccsid[] = "@(#)strtol.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#include <limits.h>
-
/*
* Convert a string to a long integer.
*
@@ -4467,11 +4274,88 @@ secureware_setup_secure(uid)
rc, uid);
break;
}
- exit(EX_NOPERM);
+ finis(FALSE, 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:
@@ -4491,6 +4375,9 @@ struct mbuf;
# ifndef SUNOS403
# include <sys/time.h>
# endif
+# if _AIX4 >= 40300
+# undef __P
+# endif
# include <net/if.h>
#endif
@@ -4545,9 +4432,8 @@ load_if_names()
for (i = 0; i < ifc.ifc_len; )
{
struct ifreq *ifr = (struct ifreq *) &ifc.ifc_buf[i];
- struct sockaddr *sa = &ifr->ifr_addr;
+ SOCKADDR *sa = (SOCKADDR *) &ifr->ifr_addr;
struct in_addr ia;
- struct hostent *hp;
#ifdef SIOCGIFFLAGS
struct ifreq ifrf;
#endif
@@ -4555,14 +4441,14 @@ load_if_names()
extern char *inet_ntoa();
#ifdef BSD4_4_SOCKADDR
- if (sa->sa_len > sizeof ifr->ifr_addr)
- i += sizeof ifr->ifr_name + sa->sa_len;
+ if (sa->sa.sa_len > sizeof ifr->ifr_addr)
+ i += sizeof ifr->ifr_name + sa->sa.sa_len;
else
#endif
i += sizeof *ifr;
if (tTd(0, 20))
- printf("%s\n", anynet_ntoa((SOCKADDR *) sa));
+ printf("%s\n", anynet_ntoa(sa));
if (ifr->ifr_addr.sa_family != AF_INET)
continue;
@@ -4581,7 +4467,7 @@ load_if_names()
continue;
/* extract IP address from the list*/
- ia = (((struct sockaddr_in *) sa)->sin_addr);
+ ia = sa->sin.sin_addr;
if (ia.s_addr == INADDR_ANY || ia.s_addr == INADDR_NONE)
{
message("WARNING: interface %s is UP with %s address",
@@ -4604,41 +4490,7 @@ load_if_names()
if (bitset(IFF_LOOPBACK, IFRFREF.ifr_flags))
continue;
- /* 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++;
- }
+ (void) add_hostnames(sa);
}
free(ifc.ifc_buf);
close(s);
@@ -4700,7 +4552,10 @@ sm_syslog(level, id, fmt, va_alist)
int seq = 1;
int idlen;
extern int SnprfOverflow;
+ extern int SyslogErrno;
+ extern char *DoprEnd;
VA_LOCAL_DECL
+ extern void sm_dopr __P((char *, const char *, va_list));
SyslogErrno = errno;
if (id == NULL)
@@ -4809,7 +4664,7 @@ bufalloc:
** syslog succeeds during interrupt handlers.
*/
-#ifdef __hpux
+#if defined(__hpux) && !defined(HPUX11)
# define MAXSYSLOGTRIES 100
# undef syslog
@@ -4883,15 +4738,18 @@ local_hostname_length(hostname)
char *CompileOptions[] =
{
-#if HESIOD
+#ifdef HESIOD
"HESIOD",
#endif
#if HES_GETMAILHOST
"HES_GETMAILHOST",
#endif
-#if LDAPMAP
+#ifdef LDAPMAP
"LDAPMAP",
#endif
+#ifdef MAP_REGEX
+ "MAP_REGEX",
+#endif
#if LOG
"LOG",
#endif
@@ -4907,7 +4765,7 @@ char *CompileOptions[] =
#if NAMED_BIND
"NAMED_BIND",
#endif
-#if NDBM
+#ifdef NDBM
"NDBM",
#endif
#if NETINET
@@ -4928,13 +4786,13 @@ char *CompileOptions[] =
#if NETX25
"NETX25",
#endif
-#if NEWDB
+#ifdef NEWDB
"NEWDB",
#endif
-#if NIS
+#ifdef NIS
"NIS",
#endif
-#if NISPLUS
+#ifdef NISPLUS
"NISPLUS",
#endif
#if QUEUE
@@ -4949,7 +4807,7 @@ char *CompileOptions[] =
#if SMTPDEBUG
"SMTPDEBUG",
#endif
-#if SUID_ROOT_FILES_OK
+#ifdef SUID_ROOT_FILES_OK
"SUID_ROOT_FILES_OK",
#endif
#if TCPWRAPPERS
@@ -4961,7 +4819,7 @@ char *CompileOptions[] =
#if XDEBUG
"XDEBUG",
#endif
-#if XLA
+#ifdef XLA
"XLA",
#endif
NULL