BSD 4_3_Tahoe release
[unix-history] / usr / src / usr.lib / sendmail / src / main.c
index b04dfe3..bc98bbb 100644 (file)
@@ -1,27 +1,38 @@
 /*
 /*
-**  Sendmail
-**  Copyright (c) 1983  Eric P. Allman
-**  Berkeley, California
-**
-**  Copyright (c) 1983 Regents of the University of California.
-**  All rights reserved.  The Berkeley software License Agreement
-**  specifies the terms and conditions for redistribution.
-*/
+ * Copyright (c) 1983 Eric P. Allman
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
 
 #ifndef lint
 char copyright[] =
 
 #ifndef lint
 char copyright[] =
-"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+"@(#) Copyright (c) 1988 Regents of the University of California.\n\
  All rights reserved.\n";
  All rights reserved.\n";
-#endif not lint
+#endif /* not lint */
 
 #ifndef lint
 
 #ifndef lint
-static char    SccsId[] = "@(#)main.c  5.11 (Berkeley) 1/30/86";
-#endif not lint
+static char sccsid[] = "@(#)main.c     5.18 (Berkeley) 6/30/88";
+#endif /* not lint */
 
 
-# define  _DEFINE
-# include <signal.h>
-# include <sgtty.h>
-# include "sendmail.h"
+#define        _DEFINE
+
+#include <signal.h>
+#include <sgtty.h>
+#include "sendmail.h"
+#include <arpa/nameser.h>
+#include <resolv.h>
 
 # ifdef lint
 char   edata, end;
 
 # ifdef lint
 char   edata, end;
@@ -59,9 +70,6 @@ char  edata, end;
 */
 
 
 */
 
 
-
-
-
 int            NextMailer;     /* "free" index into Mailer struct */
 char           *FullName;      /* sender's full name */
 ENVELOPE       BlankEnvelope;  /* a "blank" envelope */
 int            NextMailer;     /* "free" index into Mailer struct */
 char           *FullName;      /* sender's full name */
 ENVELOPE       BlankEnvelope;  /* a "blank" envelope */
@@ -87,11 +95,6 @@ ERROR %%%%   Cannot have daemon mode without SMTP   %%%% ERROR
 #endif SMTP
 #endif DAEMON
 
 #endif SMTP
 #endif DAEMON
 
-
-
-
-
-
 main(argc, argv, envp)
        int argc;
        char **argv;
 main(argc, argv, envp)
        int argc;
        char **argv;
@@ -132,10 +135,17 @@ main(argc, argv, envp)
        }
        reenter = TRUE;
 
        }
        reenter = TRUE;
 
+       /* Enforce use of local time */
+       unsetenv("TZ");
+
        /*
        **  Be sure we have enough file descriptors.
        /*
        **  Be sure we have enough file descriptors.
+       **      But also be sure that 0, 1, & 2 are open.
        */
 
        */
 
+       i = open("/dev/null", 2);
+       while (i >= 0 && i < 2)
+               i = dup(i);
        for (i = 3; i < 50; i++)
                (void) close(i);
        errno = 0;
        for (i = 3; i < 50; i++)
                (void) close(i);
        errno = 0;
@@ -225,9 +235,7 @@ main(argc, argv, envp)
        OldUmask = umask(0);
        OpMode = MD_DELIVER;
        MotherPid = getpid();
        OldUmask = umask(0);
        OpMode = MD_DELIVER;
        MotherPid = getpid();
-# ifndef V6
        FullName = getenv("NAME");
        FullName = getenv("NAME");
-# endif V6
 
 # ifdef LOG
        openlog("sendmail", LOG_PID, LOG_MAIL);
 
 # ifdef LOG
        openlog("sendmail", LOG_PID, LOG_MAIL);
@@ -318,13 +326,14 @@ main(argc, argv, envp)
                  case 'C':     /* select configuration file (already done) */
                        break;
 
                  case 'C':     /* select configuration file (already done) */
                        break;
 
-# ifdef DEBUG
+#ifdef DEBUG
                  case 'd':     /* debugging -- redo in case frozen */
                        tTsetup(tTdvect, sizeof tTdvect, "0-99.1");
                        tTflag(&p[2]);
                        setbuf(stdout, (char *) NULL);
                  case 'd':     /* debugging -- redo in case frozen */
                        tTsetup(tTdvect, sizeof tTdvect, "0-99.1");
                        tTflag(&p[2]);
                        setbuf(stdout, (char *) NULL);
+                       _res.options |= RES_DEBUG;
                        break;
                        break;
-# endif DEBUG
+#endif
 
                  case 'f':     /* from address */
                  case 'r':     /* obsolete -f flag */
 
                  case 'f':     /* from address */
                  case 'r':     /* obsolete -f flag */
@@ -917,7 +926,7 @@ thaw(freezefile)
 {
        int f;
        union frz fhdr;
 {
        int f;
        union frz fhdr;
-       extern char edata;
+       extern char edata, end;
        extern char Version[];
        extern caddr_t brk();
 
        extern char Version[];
        extern caddr_t brk();