BSD 4_4_Lite2 release
[unix-history] / usr / src / usr.sbin / sendmail / src / conf.c
index ef0ed46..8467caa 100644 (file)
@@ -3,11 +3,37 @@
  * Copyright (c) 1988, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
  * Copyright (c) 1988, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
- * %sccs.include.redist.c%
+ * 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.
+ *
+ * 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
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)conf.c     8.192 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c     8.203 (Berkeley) 6/20/95";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -39,7 +65,7 @@ static char sccsid[] = "@(#)conf.c    8.192 (Berkeley) %G%";
 
 
 
 
 
 
-\f/*
+/*
 **  Header info table
 **     Final (null) entry contains the flags used for any other field.
 **
 **  Header info table
 **     Final (null) entry contains the flags used for any other field.
 **
@@ -332,7 +358,7 @@ setupmaps()
                hes_map_lookup, null_map_store);
 #endif
 
                hes_map_lookup, null_map_store);
 #endif
 
-#ifdef NETINFO
+#if NETINFO
        MAPDEF("netinfo", NULL, MCF_ALIASOK,
                map_parseargs, ni_map_open, null_map_close,
                ni_map_lookup, null_map_store);
        MAPDEF("netinfo", NULL, MCF_ALIASOK,
                map_parseargs, ni_map_open, null_map_close,
                ni_map_lookup, null_map_store);
@@ -949,7 +975,7 @@ setsignal(sig, handler)
        int sig;
        sigfunc_t handler;
 {
        int sig;
        sigfunc_t handler;
 {
-#if defined(SYS5SIGNALS) || defined(BSD4_3) || defined(_AUX_SOURCE)
+#if defined(SYS5SIGNALS) || defined(BSD4_3)
        return signal(sig, handler);
 #else
        struct sigaction n, o;
        return signal(sig, handler);
 #else
        struct sigaction n, o;
@@ -965,6 +991,31 @@ setsignal(sig, handler)
 #endif
 }
 \f/*
 #endif
 }
 \f/*
+**  RELEASESIGNAL -- release a held signal
+**
+**     Parameters:
+**             sig -- the signal to release.
+**
+**     Returns:
+**             0 on success.
+**             -1 on failure.
+*/
+
+int
+releasesignal(sig)
+       int sig;
+{
+#ifdef BSD4_3
+       return sigsetmask(sigblock(0) & ~(1 << sig));
+#else
+       sigset_t sset;
+
+       sigemptyset(&sset);
+       sigaddset(&sset, sig);
+       return sigprocmask(SIG_UNBLOCK, &sset, NULL);
+#endif
+}
+\f/*
 **  HOLDSIGS -- arrange to hold all signals
 **
 **     Parameters:
 **  HOLDSIGS -- arrange to hold all signals
 **
 **     Parameters:
@@ -1125,12 +1176,16 @@ init_vendor_macros(e)
 # endif
 #endif
 
 # endif
 #endif
 
+#ifdef _AUX_SOURCE
+struct nlist   Nl[2];
+#else
 struct nlist   Nl[] =
 {
        { LA_AVENRUN },
 struct nlist   Nl[] =
 {
        { LA_AVENRUN },
-#define        X_AVENRUN       0
        { 0 },
 };
        { 0 },
 };
+#endif
+#define        X_AVENRUN       0
 
 getla()
 {
 
 getla()
 {
@@ -1159,6 +1214,10 @@ getla()
                }
                (void) fcntl(kmem, F_SETFD, 1);
 
                }
                (void) fcntl(kmem, F_SETFD, 1);
 
+#ifdef _AUX_SOURCE
+               strcpy(Nl[X_AVENRUN].n_name, LA_AVENRUN);
+#endif
+
 #ifdef _AIX3
                if (knlist(Nl, 1, sizeof Nl[0]) < 0)
 #else
 #ifdef _AIX3
                if (knlist(Nl, 1, sizeof Nl[0]) < 0)
 #else
@@ -1539,7 +1598,7 @@ bool
 refuseconnections()
 {
        extern bool enoughdiskspace();
 refuseconnections()
 {
        extern bool enoughdiskspace();
-       extern void setproctitle();
+       extern void setproctitle __P((char *, ...));
 
 #ifdef XLA
        if (!xla_smtp_ok())
 
 #ifdef XLA
        if (!xla_smtp_ok())
@@ -1569,10 +1628,8 @@ refuseconnections()
 **  SETPROCTITLE -- set process title for ps
 **
 **     Parameters:
 **  SETPROCTITLE -- set process title for ps
 **
 **     Parameters:
-**             fmt -- a printf style format string.  If NULL, the first
-**                     parameter is a literal proctitle previously
-**                     returned by getproctitle.
-**             va_alist -- possible parameters to fmt.
+**             fmt -- a printf style format string.
+**             a, b, c -- possible parameters to fmt.
 **
 **     Returns:
 **             none.
 **
 **     Returns:
 **             none.
@@ -1631,8 +1688,6 @@ typedef unsigned int      *pt_entry_t;
 
 #if SPT_TYPE != SPT_BUILTIN
 
 
 #if SPT_TYPE != SPT_BUILTIN
 
-char   ProcTitleBuf[MAXLINE];
-
 /*VARARGS1*/
 void
 # ifdef __STDC__
 /*VARARGS1*/
 void
 # ifdef __STDC__
@@ -1646,6 +1701,7 @@ setproctitle(fmt, va_alist)
 # if SPT_TYPE != SPT_NONE
        register char *p;
        register int i;
 # if SPT_TYPE != SPT_NONE
        register char *p;
        register int i;
+       SETPROC_STATIC char buf[MAXLINE];
        VA_LOCAL_DECL
 #  if SPT_TYPE == SPT_PSTAT
        union pstun pst;
        VA_LOCAL_DECL
 #  if SPT_TYPE == SPT_PSTAT
        union pstun pst;
@@ -1655,32 +1711,37 @@ setproctitle(fmt, va_alist)
        extern char *LastArgv;
 #  endif
 
        extern char *LastArgv;
 #  endif
 
-       VA_START(fmt);
-       if (fmt == NULL)
-       {
-               /* restore old proctitle */
-               (void) strcpy(ProcTitleBuf, va_arg(ap, char *));
-       }
-       else
-       {
-               p = ProcTitleBuf;
+       p = buf;
 
 
-               /* print sendmail: heading for grep */
-               (void) strcpy(p, "sendmail: ");
-               p += strlen(p);
+       /* print sendmail: heading for grep */
+       (void) strcpy(p, "sendmail: ");
+       p += strlen(p);
 
 
-               /* print the argument string */
-               (void) vsprintf(p, fmt, ap);
-       }
+       /* print the argument string */
+       VA_START(fmt);
+       (void) vsprintf(p, fmt, ap);
        VA_END;
 
        VA_END;
 
-       i = strlen(ProcTitleBuf);
+       i = strlen(buf);
+
+#  if SPT_TYPE == SPT_PSTAT
+       pst.pst_command = buf;
+       pstat(PSTAT_SETCMD, pst, i, 0, 0);
+#  endif
+#  if SPT_TYPE == SPT_PSSTRINGS
+       PS_STRINGS->ps_nargvstr = 1;
+       PS_STRINGS->ps_argvstr = buf;
+#  endif
+#  if SPT_TYPE == SPT_SYSMIPS
+       sysmips(SONY_SYSNEWS, NEWS_SETPSARGS, buf);
+#  endif
+#  if SPT_TYPE == SPT_REUSEARGV
        if (i > LastArgv - Argv[0] - 2)
        {
                i = LastArgv - Argv[0] - 2;
        if (i > LastArgv - Argv[0] - 2)
        {
                i = LastArgv - Argv[0] - 2;
-               ProcTitleBuf[i] = '\0';
+               buf[i] = '\0';
        }
        }
-       (void) strcpy(Argv[0], ProcTitleBuf);
+       (void) strcpy(Argv[0], buf);
        p = &Argv[0][i];
        while (p < LastArgv)
                *p++ = SPT_PADCHAR;
        p = &Argv[0][i];
        while (p < LastArgv)
                *p++ = SPT_PADCHAR;
@@ -2204,6 +2265,7 @@ vsprintf(s, fmt, ap)
 **  USERSHELLOK -- tell if a user's shell is ok for unrestricted use
 **
 **     Parameters:
 **  USERSHELLOK -- tell if a user's shell is ok for unrestricted use
 **
 **     Parameters:
+**             user -- the name of the user we are checking.
 **             shell -- the user's shell from /etc/passwd
 **
 **     Returns:
 **             shell -- the user's shell from /etc/passwd
 **
 **     Returns:
@@ -2261,14 +2323,16 @@ char    *DefaultUserShells[] =
 #define WILDCARD_SHELL "/SENDMAIL/ANY/SHELL/"
 
 bool
 #define WILDCARD_SHELL "/SENDMAIL/ANY/SHELL/"
 
 bool
-usershellok(shell)
+usershellok(user, shell)
+       char *user;
        char *shell;
 {
 #if HASGETUSERSHELL
        register char *p;
        extern char *getusershell();
 
        char *shell;
 {
 #if HASGETUSERSHELL
        register char *p;
        extern char *getusershell();
 
-       if (shell == NULL || shell[0] == '\0' || ConfigLevel <= 1)
+       if (shell == NULL || shell[0] == '\0' || wordinclass(user, 't') ||
+           ConfigLevel <= 1)
                return TRUE;
 
        setusershell();
                return TRUE;
 
        setusershell();
@@ -2284,7 +2348,7 @@ usershellok(shell)
        register FILE *shellf;
        char buf[MAXLINE];
 
        register FILE *shellf;
        char buf[MAXLINE];
 
-       if (shell == NULL || shell[0] == '\0')
+       if (shell == NULL || shell[0] == '\0' || wordinclass(user, 't'))
                return TRUE;
 
 # if USEGETCONFATTR
                return TRUE;
 
 # if USEGETCONFATTR
@@ -2844,7 +2908,7 @@ getcfname()
 
        if (ConfFile != NULL)
                return ConfFile;
 
        if (ConfFile != NULL)
                return ConfFile;
-#ifdef NETINFO
+#if NETINFO
        {
                extern char *ni_propval();
                char *cflocation;
        {
                extern char *ni_propval();
                char *cflocation;
@@ -3073,16 +3137,12 @@ strstr(big, little)
 **     work around these problems.
 */
 
 **     work around these problems.
 */
 
-extern int     h_errno;
-
 struct hostent *
 sm_gethostbyname(name)
        char *name;
 {
        struct hostent *h;
 #if defined(SOLARIS) && SOLARIS < 204 || defined(sony_news) && defined(__svr4)
 struct hostent *
 sm_gethostbyname(name)
        char *name;
 {
        struct hostent *h;
 #if defined(SOLARIS) && SOLARIS < 204 || defined(sony_news) && defined(__svr4)
-       extern int h_errno;
-
 # if SOLARIS == 203
        static struct hostent hp;
        static char buf[1000];
 # if SOLARIS == 203
        static struct hostent hp;
        static char buf[1000];
@@ -3099,17 +3159,14 @@ sm_gethostbyname(name)
        h = __switch_gethostbyname(name);
 # endif
 #else
        h = __switch_gethostbyname(name);
 # endif
 #else
-# if defined(NIS)
        int nmaps;
        char *maptype[MAXMAPSTACK];
        short mapreturn[MAXMAPACTIONS];
        char hbuf[MAXNAME];
        int nmaps;
        char *maptype[MAXMAPSTACK];
        short mapreturn[MAXMAPACTIONS];
        char hbuf[MAXNAME];
-# endif
 
        if (tTd(61, 10))
                printf("gethostbyname(%s)... ", name);
        h = gethostbyname(name);
 
        if (tTd(61, 10))
                printf("gethostbyname(%s)... ", name);
        h = gethostbyname(name);
-# if defined(NIS)
        if (h == NULL)
        {
                if (tTd(61, 10))
        if (h == NULL)
        {
                if (tTd(61, 10))
@@ -3117,7 +3174,8 @@ sm_gethostbyname(name)
 
                nmaps = switch_map_find("hosts", maptype, mapreturn);
                while (--nmaps >= 0)
 
                nmaps = switch_map_find("hosts", maptype, mapreturn);
                while (--nmaps >= 0)
-                       if (strcmp(maptype[nmaps], "nis") == 0)
+                       if (strcmp(maptype[nmaps], "nis") == 0 ||
+                           strcmp(maptype[nmaps], "files") == 0)
                                break;
                if (nmaps >= 0)
                {
                                break;
                if (nmaps >= 0)
                {
@@ -3136,7 +3194,6 @@ sm_gethostbyname(name)
                        }
                }
        }
                        }
                }
        }
-# endif
 #endif
        if (tTd(61, 10))
        {
 #endif
        if (tTd(61, 10))
        {
@@ -3155,8 +3212,6 @@ sm_gethostbyaddr(addr, len, type)
        int type;
 {
 #if defined(SOLARIS) && SOLARIS < 204
        int type;
 {
 #if defined(SOLARIS) && SOLARIS < 204
-       extern int h_errno;
-
 # if SOLARIS == 203
        static struct hostent hp;
        static char buf[1000];
 # if SOLARIS == 203
        static struct hostent hp;
        static char buf[1000];
@@ -3185,7 +3240,7 @@ sm_getpwnam(user)
 
 struct passwd *
 sm_getpwuid(uid)
 
 struct passwd *
 sm_getpwuid(uid)
-       uid_t uid;
+       UID_T uid;
 {
        return getpwuid(uid);
 }
 {
        return getpwuid(uid);
 }
@@ -3236,7 +3291,7 @@ load_if_names()
        close(s);
 
        /* scan the list of IP address */
        close(s);
 
        /* scan the list of IP address */
-       if (tTd(0, 4))
+       if (tTd(0, 40))
                printf("scanning for interface specific names, ifc_len=%d\n",
                        ifc.ifc_len);
 
                printf("scanning for interface specific names, ifc_len=%d\n",
                        ifc.ifc_len);
 
@@ -3342,7 +3397,7 @@ load_if_names()
 **             Caller should free the return value of ni_proval
 */
 
 **             Caller should free the return value of ni_proval
 */
 
-#ifdef NETINFO
+#if NETINFO
 
 # include <netinfo/ni.h>
 
 
 # include <netinfo/ni.h>
 
@@ -3558,7 +3613,7 @@ char      *CompileOptions[] =
 #if HESIOD
        "HESIOD",
 #endif
 #if HESIOD
        "HESIOD",
 #endif
-#if LOG
+#ifdef LOG
        "LOG",
 #endif
 #if MATCHGECOS
        "LOG",
 #endif
 #if MATCHGECOS