fix lockf code; have getcanonname recognize canonical names
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sat, 14 Dec 1991 04:13:18 +0000 (20:13 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sat, 14 Dec 1991 04:13:18 +0000 (20:13 -0800)
SCCS-vsn: usr.sbin/sendmail/src/domain.c 5.32
SCCS-vsn: usr.sbin/sendmail/src/version.c 5.82
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 5.47
SCCS-vsn: usr.sbin/sendmail/src/queue.c 5.35
SCCS-vsn: usr.sbin/sendmail/src/alias.c 5.30
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 5.47

usr/src/usr.sbin/sendmail/src/alias.c
usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/domain.c
usr/src/usr.sbin/sendmail/src/queue.c
usr/src/usr.sbin/sendmail/src/version.c

index b382ab4..4df483b 100644 (file)
 
 #ifndef lint
 #ifdef NEWDB
 
 #ifndef lint
 #ifdef NEWDB
-static char sccsid[] = "@(#)alias.c    5.29 (Berkeley) %G% (with NEWDB)";
+static char sccsid[] = "@(#)alias.c    5.30 (Berkeley) %G% (with NEWDB)";
 #else
 #ifdef DBM
 #else
 #ifdef DBM
-static char sccsid[] = "@(#)alias.c    5.29 (Berkeley) %G% (with DBM)";
+static char sccsid[] = "@(#)alias.c    5.30 (Berkeley) %G% (with DBM)";
 #else
 #else
-static char sccsid[] = "@(#)alias.c    5.29 (Berkeley) %G% (without DBM)";
+static char sccsid[] = "@(#)alias.c    5.30 (Berkeley) %G% (without DBM)";
 #endif
 #endif
 #endif /* not lint */
 #endif
 #endif
 #endif /* not lint */
@@ -371,6 +371,12 @@ initaliases(aliasfile, init)
 **             Optionally, builds the .dir & .pag files.
 */
 
 **             Optionally, builds the .dir & .pag files.
 */
 
+# ifdef LOCKF
+# define RDLK_MODE     "r+"
+# else
+# define RDLK_MODE     "r"
+# endif
+
 static
 readaliases(aliasfile, init)
        char *aliasfile;
 static
 readaliases(aliasfile, init)
        char *aliasfile;
@@ -390,7 +396,7 @@ readaliases(aliasfile, init)
 # endif
        char line[BUFSIZ];
 
 # endif
        char line[BUFSIZ];
 
-       if ((af = fopen(aliasfile, "r")) == NULL)
+       if ((af = fopen(aliasfile, RDLK_MODE)) == NULL)
        {
                if (tTd(27, 1))
                        printf("Can't open %s\n", aliasfile);
        {
                if (tTd(27, 1))
                        printf("Can't open %s\n", aliasfile);
index f37a849..a31f3ee 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)deliver.c  5.46 (Berkeley) %G%";
+static char sccsid[] = "@(#)deliver.c  5.47 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -21,6 +21,9 @@ static char sccsid[] = "@(#)deliver.c 5.46 (Berkeley) %G%";
 #include <arpa/nameser.h>
 #include <resolv.h>
 #endif
 #include <arpa/nameser.h>
 #include <resolv.h>
 #endif
+#ifdef LOCKF
+#include <unistd.h>
+#endif
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
 
 /*
 **  DELIVER -- Deliver a message to a list of addresses.
@@ -1440,6 +1443,29 @@ sendall(e, mode)
                /* be sure we are immune from the terminal */
                disconnect(FALSE);
 
                /* be sure we are immune from the terminal */
                disconnect(FALSE);
 
+# ifdef LOCKF
+               /*
+               **  When our parent closed lockfp, we lost the lock.
+               **  Try to get it back now.
+               */
+
+               if (lockfp != NULL)
+               {
+                       if (fseek(lockfp, 0, SEEK_SET) != 0 ||
+                           lockf(fileno(lockfp), F_TLOCK, 0) < 0)
+                       {
+                               /* oops....  lost it */
+# ifdef LOG
+                               if (LogLevel > 5)
+                                       syslog(LOG_NOTICE, "%s: lost lock",
+                                               CurEnv->e_id);
+# endif /* LOG */
+                               fclose(lockfp);
+                               exit(EX_OK);
+                       }
+               }
+# endif /* LOCKF */
+
                break;
        }
 
                break;
        }
 
index 4f81896..ae9c98e 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef NAMED_BIND
 
 #ifndef lint
 #ifdef NAMED_BIND
-static char sccsid[] = "@(#)domain.c   5.31 (Berkeley) %G% (with name server)";
+static char sccsid[] = "@(#)domain.c   5.32 (Berkeley) %G% (with name server)";
 #else
 #else
-static char sccsid[] = "@(#)domain.c   5.31 (Berkeley) %G% (without name server)";
+static char sccsid[] = "@(#)domain.c   5.32 (Berkeley) %G% (without name server)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -246,7 +246,7 @@ loop:
                         */
                        if (errno == ECONNREFUSED) {
                                h_errno = TRY_AGAIN;
                         */
                        if (errno == ECONNREFUSED) {
                                h_errno = TRY_AGAIN;
-                               return rval;
+                               return FALSE;
                        }
                        if (h_errno == NO_DATA)
                        {
                        }
                        if (h_errno == NO_DATA)
                        {
@@ -256,11 +256,15 @@ loop:
                        }
                        if ((h_errno != HOST_NOT_FOUND) ||
                            (_res.options & RES_DNSRCH) == 0)
                        }
                        if ((h_errno != HOST_NOT_FOUND) ||
                            (_res.options & RES_DNSRCH) == 0)
-                               return rval;
+                               return FALSE;
                }
        }
        if (ret < 0)
        {
                }
        }
        if (ret < 0)
        {
+               /*
+               **  Try the unmodified name.
+               */
+
                cp = host;
                if (tTd(8, 5))
                        printf("getcanonname: trying %s\n", cp);
                cp = host;
                if (tTd(8, 5))
                        printf("getcanonname: trying %s\n", cp);
@@ -274,7 +278,8 @@ loop:
                {
                        if (tTd(8, 8))
                                printf("\tNO: h_errno=%d\n", h_errno);
                {
                        if (tTd(8, 8))
                                printf("\tNO: h_errno=%d\n", h_errno);
-                       return rval;
+                       if (h_errno != NO_DATA)
+                               return FALSE;
                }
        }
 
                }
        }
 
@@ -301,7 +306,7 @@ loop:
                        if (tTd(8, 20))
                                printf("qdcount failure (%d)\n",
                                        ntohs(hp->qdcount));
                        if (tTd(8, 20))
                                printf("qdcount failure (%d)\n",
                                        ntohs(hp->qdcount));
-                       return rval;            /* ???XXX??? */
+                       return FALSE;           /* ???XXX??? */
                }
        }
 
                }
        }
 
index e7646c0..c9a60c8 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef QUEUE
 
 #ifndef lint
 #ifdef QUEUE
-static char sccsid[] = "@(#)queue.c    5.34 (Berkeley) %G% (with queueing)";
+static char sccsid[] = "@(#)queue.c    5.35 (Berkeley) %G% (with queueing)";
 #else
 #else
-static char sccsid[] = "@(#)queue.c    5.34 (Berkeley) %G% (without queueing)";
+static char sccsid[] = "@(#)queue.c    5.35 (Berkeley) %G% (without queueing)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -97,7 +97,7 @@ queueup(e, queueall, announce)
 # ifdef LOCKF
                        if (lockf(fd, F_TLOCK, 0) < 0)
                        {
 # ifdef LOCKF
                        if (lockf(fd, F_TLOCK, 0) < 0)
                        {
-                               if (errno != EACCES)
+                               if (errno != EACCES && errno != EAGAIN)
                                        syserr("cannot lockf(%s)", tf);
                                close(fd);
                                fd = -1;
                                        syserr("cannot lockf(%s)", tf);
                                close(fd);
                                fd = -1;
@@ -714,6 +714,12 @@ dowork(w)
 **             we had been invoked by argument.
 */
 
 **             we had been invoked by argument.
 */
 
+# ifdef LOCKF
+# define RDLK_MODE     "r+"
+# else
+# define RDLK_MODE     "r"
+# endif
+
 FILE *
 readqf(e, full)
        register ENVELOPE *e;
 FILE *
 readqf(e, full)
        register ENVELOPE *e;
@@ -733,7 +739,7 @@ readqf(e, full)
        */
 
        qf = queuename(e, 'q');
        */
 
        qf = queuename(e, 'q');
-       qfp = fopen(qf, "r");
+       qfp = fopen(qf, RDLK_MODE);
        if (qfp == NULL)
        {
                if (errno != ENOENT)
        if (qfp == NULL)
        {
                if (errno != ENOENT)
index 4406e36..5890f42 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)version.c  5.81 (Berkeley) %G%";
+static char sccsid[] = "@(#)version.c  5.82 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-char   Version[] = "5.81";
+char   Version[] = "5.82";