BSD 4_4_Lite1 release
[unix-history] / usr / src / usr.sbin / sendmail / src / conf.c
index c3a10aa..4ac109a 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.80 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c     8.89 (Berkeley) 4/18/94";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -41,7 +67,7 @@ static char sccsid[] = "@(#)conf.c    8.80 (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.
 **
@@ -121,6 +147,7 @@ struct prival PrivacyValues[] =
        "restrictmailq",        PRIV_RESTRICTMAILQ,
        "restrictqrun",         PRIV_RESTRICTQRUN,
        "authwarnings",         PRIV_AUTHWARNINGS,
        "restrictmailq",        PRIV_RESTRICTMAILQ,
        "restrictqrun",         PRIV_RESTRICTQRUN,
        "authwarnings",         PRIV_AUTHWARNINGS,
+       "noreceipts",           PRIV_NORECEIPTS,
        "goaway",               PRIV_GOAWAY,
        NULL,                   0,
 };
        "goaway",               PRIV_GOAWAY,
        NULL,                   0,
 };
@@ -642,17 +669,17 @@ struct    nlist Nl[] =
 #  define FSHIFT       5
 # endif
 
 #  define FSHIFT       5
 # endif
 
-# if defined(__alpha)
+# if defined(__alpha) || defined(IRIX)
 #  define FSHIFT       10
 # endif
 #  define FSHIFT       10
 # endif
+#endif
 
 
-# if (LA_TYPE == LA_INT) || (LA_TYPE == LA_SHORT)
-#  define FSHIFT       8
-# endif
+#ifndef FSHIFT
+# define FSHIFT                8
 #endif
 
 #endif
 
-#if ((LA_TYPE == LA_INT) || (LA_TYPE == LA_SHORT)) && !defined(FSCALE)
-#  define FSCALE       (1 << FSHIFT)
+#ifndef FSCALE
+# define FSCALE                (1 << FSHIFT)
 #endif
 
 getla()
 #endif
 
 getla()
@@ -695,6 +722,9 @@ getla()
                                        _PATH_UNIX, LA_AVENRUN);
                        return (-1);
                }
                                        _PATH_UNIX, LA_AVENRUN);
                        return (-1);
                }
+#ifdef IRIX
+               Nl[X_AVENRUN].n_value &= 0x7fffffff;
+#endif
        }
        if (tTd(3, 20))
                printf("getla: symbol address = %#x\n", Nl[X_AVENRUN].n_value);
        }
        if (tTd(3, 20))
                printf("getla: symbol address = %#x\n", Nl[X_AVENRUN].n_value);
@@ -802,7 +832,7 @@ getla()
 
 
 #else
 
 
 #else
-#if LA_TYPE == LA_PROC
+#if LA_TYPE == LA_PROCSTR
 
 /*
 **  Read /proc/loadavg for the load average.  This is assumed to be
 
 /*
 **  Read /proc/loadavg for the load average.  This is assumed to be
@@ -819,25 +849,20 @@ getla()
 int
 getla()
 {
 int
 getla()
 {
-       register double avenrun;
+       double avenrun;
        register int result;
        register int result;
-       static FILE *fp = NULL;
-
-       avenrun = 0.0;
+       FILE *fp;
 
 
-       if (fp == NULL)
+       fp = fopen(_PATH_LOADAVG, "r");
+       if (fp == NULL) 
        {
        {
-               fp = fopen(_PATH_LOADAVG, "r");
-               if (fp == NULL) 
-               {
-                       if (tTd(3, 1))
-                               printf("getla: fopen(%s): %s\n",
-                                       _PATH_LOADAVG, errstring(errno));
-                       return -1;
-               }
+               if (tTd(3, 1))
+                       printf("getla: fopen(%s): %s\n",
+                               _PATH_LOADAVG, errstring(errno));
+               return -1;
        }
        }
-       (void) rewind(fp);
        result = fscanf(fp, "%lf", &avenrun);
        result = fscanf(fp, "%lf", &avenrun);
+       fclose(fp);
        if (result != 1)
        {
                if (tTd(3, 1))
        if (result != 1)
        {
                if (tTd(3, 1))
@@ -971,10 +996,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.
@@ -1013,8 +1036,6 @@ refuseconnections()
 
 #ifndef HASSETPROCTITLE
 
 
 #ifndef HASSETPROCTITLE
 
-char   ProcTitleBuf[MAXLINE];
-
 /*VARARGS1*/
 #ifdef __STDC__
 setproctitle(char *fmt, ...)
 /*VARARGS1*/
 #ifdef __STDC__
 setproctitle(char *fmt, ...)
@@ -1027,6 +1048,7 @@ setproctitle(fmt, va_alist)
 # ifdef SETPROCTITLE
        register char *p;
        register int i;
 # ifdef SETPROCTITLE
        register char *p;
        register int i;
+       SETPROC_STATIC char buf[MAXLINE];
        VA_LOCAL_DECL
 #  ifdef __hpux
        union pstun pst;
        VA_LOCAL_DECL
 #  ifdef __hpux
        union pstun pst;
@@ -1034,32 +1056,33 @@ setproctitle(fmt, va_alist)
        extern char **Argv;
        extern char *LastArgv;
 
        extern char **Argv;
        extern char *LastArgv;
 
-       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);
+
+#  ifdef __hpux
+       pst.pst_command = buf;
+       pstat(PSTAT_SETCMD, pst, i, 0, 0);
+#  else
+#   ifdef PS_STRINGS
+       PS_STRINGS->ps_nargvstr = 1;
+       PS_STRINGS->ps_argvstr = buf;
+#   else
        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++ = PROCTITLEPAD;
        p = &Argv[0][i];
        while (p < LastArgv)
                *p++ = PROCTITLEPAD;
@@ -1096,8 +1119,10 @@ reapchild()
        {
                if (count++ > 1000)
                {
        {
                if (count++ > 1000)
                {
+#ifdef LOG
                        syslog(LOG_ALERT, "reapchild: waitpid loop: pid=%d, status=%x",
                                pid, status);
                        syslog(LOG_ALERT, "reapchild: waitpid loop: pid=%d, status=%x",
                                pid, status);
+#endif
                        break;
                }
        }
                        break;
                }
        }
@@ -1289,7 +1314,7 @@ setsid __P ((void))
 #ifdef TIOCNOTTY
        int fd;
 
 #ifdef TIOCNOTTY
        int fd;
 
-       fd = open("/dev/tty", 2);
+       fd = open("/dev/tty", O_RDWR, 0);
        if (fd >= 0)
        {
                (void) ioctl(fd, (int) TIOCNOTTY, (char *) 0);
        if (fd >= 0)
        {
                (void) ioctl(fd, (int) TIOCNOTTY, (char *) 0);
@@ -1303,6 +1328,24 @@ setsid __P ((void))
 # endif
 }
 
 # endif
 }
 
+#endif
+\f/*
+**  FSYNC -- dummy fsync
+*/
+
+#ifdef NEEDFSYNC
+
+fsync(fd)
+       int fd;
+{
+# ifdef O_SYNC
+       return fcntl(fd, F_SETFL, O_SYNC);
+# else
+       /* nothing we can do */
+       return 0;
+# endif
+}
+
 #endif
 \f/*
 **  DGUX_INET_ADDR -- inet_addr for DG/UX
 #endif
 \f/*
 **  DGUX_INET_ADDR -- inet_addr for DG/UX
@@ -1572,6 +1615,7 @@ usershellok(shell)
 #define SFS_VFS                3       /* use <sys/vfs.h> implementation */
 #define SFS_MOUNT      4       /* use <sys/mount.h> implementation */
 #define SFS_STATFS     5       /* use <sys/statfs.h> implementation */
 #define SFS_VFS                3       /* use <sys/vfs.h> implementation */
 #define SFS_MOUNT      4       /* use <sys/mount.h> implementation */
 #define SFS_STATFS     5       /* use <sys/statfs.h> implementation */
+#define SFS_STATVFS    6       /* use <sys/statvfs.h> implementation */
 
 #ifndef SFS_TYPE
 # define SFS_TYPE      SFS_NONE
 
 #ifndef SFS_TYPE
 # define SFS_TYPE      SFS_NONE
@@ -1589,6 +1633,9 @@ usershellok(shell)
 #if SFS_TYPE == SFS_MOUNT
 # include <sys/mount.h>
 #endif
 #if SFS_TYPE == SFS_MOUNT
 # include <sys/mount.h>
 #endif
+#if SFS_TYPE == SFS_STATVFS
+# include <sys/statvfs.h>
+#endif
 
 long
 freespace(dir, bsize)
 
 long
 freespace(dir, bsize)
@@ -1607,10 +1654,15 @@ freespace(dir, bsize)
 #   define f_bavail    fd_bfreen
 #   define FSBLOCKSIZE fs.fd_bsize
 #  else
 #   define f_bavail    fd_bfreen
 #   define FSBLOCKSIZE fs.fd_bsize
 #  else
+#   if SFS_TYPE == SFS_STATVFS
+       struct statvfs fs;
+#    define FSBLOCKSIZE        fs.f_bsize
+#   else
        struct statfs fs;
        struct statfs fs;
-#   define FSBLOCKSIZE fs.f_bsize
-#   if defined(_SCO_unix_) || defined(IRIX) || defined(apollo)
-#    define f_bavail f_bfree
+#    define FSBLOCKSIZE        fs.f_bsize
+#    if defined(_SCO_unix_) || defined(IRIX) || defined(apollo)
+#     define f_bavail f_bfree
+#    endif
 #   endif
 #  endif
 # endif
 #   endif
 #  endif
 # endif