portability fixes for DG/UX 5.4.3
[unix-history] / usr / src / usr.sbin / sendmail / src / conf.c
index 1645e42..d7fa90d 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)conf.c     8.77 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c     8.91 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -121,6 +121,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,
 };
@@ -522,6 +523,9 @@ setsignal(sig, handler)
 
        bzero(&n, sizeof n);
        n.sa_handler = handler;
 
        bzero(&n, sizeof n);
        n.sa_handler = handler;
+# ifdef SA_RESTART
+       n.sa_flags = SA_RESTART;
+# endif
        if (sigaction(sig, &n, &o) < 0)
                return SIG_ERR;
        return o.sa_handler;
        if (sigaction(sig, &n, &o) < 0)
                return SIG_ERR;
        return o.sa_handler;
@@ -602,6 +606,7 @@ init_md(argc, argv)
 #define LA_SUBR                4       /* call getloadavg */
 #define LA_MACH                5       /* MACH load averages (as on NeXT boxes) */
 #define LA_SHORT       6       /* read kmem for avenrun; interpret as short */
 #define LA_SUBR                4       /* call getloadavg */
 #define LA_MACH                5       /* MACH load averages (as on NeXT boxes) */
 #define LA_SHORT       6       /* read kmem for avenrun; interpret as short */
+#define LA_PROCSTR     7       /* read string ("1.17") from /proc/loadavg */
 
 /* do guesses based on general OS type */
 #ifndef LA_TYPE
 
 /* do guesses based on general OS type */
 #ifndef LA_TYPE
@@ -641,17 +646,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()
@@ -694,6 +699,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);
@@ -800,6 +808,52 @@ getla()
 }
 
 
 }
 
 
+#else
+#if LA_TYPE == LA_PROCSTR
+
+/*
+**  Read /proc/loadavg for the load average.  This is assumed to be
+**  in a format like "0.15 0.12 0.06".
+**
+**     Initially intended for Linux.  This has been in the kernel
+**     since at least 0.99.15.
+*/
+
+# ifndef _PATH_LOADAVG
+#  define _PATH_LOADAVG        "/proc/loadavg"
+# endif
+
+int
+getla()
+{
+       double avenrun;
+       register int result;
+       FILE *fp;
+
+       fp = fopen(_PATH_LOADAVG, "r");
+       if (fp == NULL) 
+       {
+               if (tTd(3, 1))
+                       printf("getla: fopen(%s): %s\n",
+                               _PATH_LOADAVG, errstring(errno));
+               return -1;
+       }
+       result = fscanf(fp, "%lf", &avenrun);
+       fclose(fp);
+       if (result != 1)
+       {
+               if (tTd(3, 1))
+                       printf("getla: fscanf() = %d: %s\n",
+                               result, errstring(errno));
+               return -1;
+       }
+
+       if (tTd(3, 1))
+               printf("getla(): %.2f\n", avenrun);
+
+       return ((int) (avenrun + 0.5));
+}
+
 #else
 
 getla()
 #else
 
 getla()
@@ -812,6 +866,7 @@ getla()
 #endif
 #endif
 #endif
 #endif
 #endif
 #endif
+#endif
 
 
 /*
 
 
 /*
@@ -842,11 +897,9 @@ getla()
 static char  rcsid[] = "@(#)$Id: getloadavg.c,v 1.16 1991/06/21 12:51:15 paul Exp $";
 #endif /* !lint */
 
 static char  rcsid[] = "@(#)$Id: getloadavg.c,v 1.16 1991/06/21 12:51:15 paul Exp $";
 #endif /* !lint */
 
-#   ifdef apollo
+#ifdef apollo
 # undef volatile
 #    include <apollo/base.h>
 # undef volatile
 #    include <apollo/base.h>
-#    include <apollo/time.h>
-#    include <sys/types.h>
 
 /* ARGSUSED */
 int getloadavg( call_data )
 
 /* ARGSUSED */
 int getloadavg( call_data )
@@ -1045,8 +1098,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;
                }
        }
@@ -1238,7 +1293,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);
@@ -1252,15 +1307,34 @@ 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
 **
 **     Data General DG/UX version of inet_addr returns a struct in_addr
 #endif
 \f/*
 **  DGUX_INET_ADDR -- inet_addr for DG/UX
 **
 **     Data General DG/UX version of inet_addr returns a struct in_addr
-**     instead of a long.  This patches things.
+**     instead of a long.  This patches things.  Only needed on versions
+**     prior to 5.4.3.
 */
 
 */
 
-#ifdef DGUX
+#ifdef DGUX_5_4_2
 
 #undef inet_addr
 
 
 #undef inet_addr
 
@@ -1521,6 +1595,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
@@ -1538,6 +1613,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)
@@ -1556,10 +1634,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
@@ -1571,10 +1654,14 @@ freespace(dir, bsize)
 #  if SFS_TYPE == SFS_4ARGS
        if (statfs(dir, &fs, sizeof fs, 0) == 0)
 #  else
 #  if SFS_TYPE == SFS_4ARGS
        if (statfs(dir, &fs, sizeof fs, 0) == 0)
 #  else
-#   if defined(ultrix)
-       if (statfs(dir, &fs) > 0)
+#   if SFS_TYPE == SFS_STATVFS
+       if (statvfs(dir, &fs) == 0)
 #   else
 #   else
+#    if defined(ultrix)
+       if (statfs(dir, &fs) > 0)
+#    else
        if (statfs(dir, &fs) == 0)
        if (statfs(dir, &fs) == 0)
+#    endif
 #   endif
 #  endif
 # endif
 #   endif
 #  endif
 # endif