home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / sendmail-5.65c+IDA-1.4.4.1 / src / RCS / daemon.c,v < prev    next >
Encoding:
Text File  |  1991-08-12  |  43.9 KB  |  2,200 lines

  1. head    5.36;
  2. branch    5.36.0;
  3. access;
  4. symbols
  5.     RELEASE:5.36.0.24
  6.     BETA:5.36.0.20
  7.     UICSO:5.36.0
  8.     VANILLA:5.36;
  9. locks; strict;
  10. comment    @ * @;
  11.  
  12.  
  13. 5.36
  14. date    90.06.20.08.35.37;    author paul;    state Exp;
  15. branches
  16.     5.36.0.1;
  17. next    ;
  18.  
  19. 5.36.0.1
  20. date    90.06.20.09.42.45;    author paul;    state Exp;
  21. branches;
  22. next    5.36.0.2;
  23.  
  24. 5.36.0.2
  25. date    90.06.25.09.20.37;    author paul;    state Exp;
  26. branches;
  27. next    5.36.0.3;
  28.  
  29. 5.36.0.3
  30. date    90.07.06.15.23.50;    author paul;    state Exp;
  31. branches;
  32. next    5.36.0.4;
  33.  
  34. 5.36.0.4
  35. date    90.07.08.17.29.09;    author paul;    state Exp;
  36. branches;
  37. next    5.36.0.5;
  38.  
  39. 5.36.0.5
  40. date    90.09.17.09.31.43;    author paul;    state Exp;
  41. branches;
  42. next    5.36.0.6;
  43.  
  44. 5.36.0.6
  45. date    90.10.02.00.47.14;    author paul;    state Exp;
  46. branches;
  47. next    5.36.0.7;
  48.  
  49. 5.36.0.7
  50. date    90.10.16.14.48.07;    author paul;    state Exp;
  51. branches;
  52. next    5.36.0.8;
  53.  
  54. 5.36.0.8
  55. date    90.10.18.10.43.14;    author paul;    state Exp;
  56. branches;
  57. next    5.36.0.9;
  58.  
  59. 5.36.0.9
  60. date    90.11.14.14.37.56;    author paul;    state Exp;
  61. branches;
  62. next    5.36.0.10;
  63.  
  64. 5.36.0.10
  65. date    90.11.28.17.21.46;    author paul;    state Exp;
  66. branches;
  67. next    5.36.0.11;
  68.  
  69. 5.36.0.11
  70. date    90.11.29.21.17.08;    author paul;    state Exp;
  71. branches;
  72. next    5.36.0.12;
  73.  
  74. 5.36.0.12
  75. date    91.01.19.19.26.02;    author paul;    state Exp;
  76. branches;
  77. next    5.36.0.13;
  78.  
  79. 5.36.0.13
  80. date    91.02.17.02.42.12;    author paul;    state Exp;
  81. branches;
  82. next    5.36.0.14;
  83.  
  84. 5.36.0.14
  85. date    91.03.04.21.48.23;    author paul;    state Exp;
  86. branches;
  87. next    5.36.0.15;
  88.  
  89. 5.36.0.15
  90. date    91.03.06.15.10.33;    author paul;    state Exp;
  91. branches;
  92. next    5.36.0.16;
  93.  
  94. 5.36.0.16
  95. date    91.03.06.16.08.39;    author paul;    state Exp;
  96. branches;
  97. next    5.36.0.17;
  98.  
  99. 5.36.0.17
  100. date    91.04.05.14.55.15;    author paul;    state Exp;
  101. branches;
  102. next    5.36.0.18;
  103.  
  104. 5.36.0.18
  105. date    91.05.18.17.22.57;    author paul;    state Exp;
  106. branches;
  107. next    5.36.0.19;
  108.  
  109. 5.36.0.19
  110. date    91.05.23.21.25.27;    author paul;    state Exp;
  111. branches;
  112. next    5.36.0.20;
  113.  
  114. 5.36.0.20
  115. date    91.06.01.22.18.25;    author paul;    state Exp;
  116. branches;
  117. next    5.36.0.21;
  118.  
  119. 5.36.0.21
  120. date    91.06.05.16.46.15;    author paul;    state Exp;
  121. branches;
  122. next    5.36.0.22;
  123.  
  124. 5.36.0.22
  125. date    91.06.13.17.16.27;    author paul;    state Exp;
  126. branches;
  127. next    5.36.0.23;
  128.  
  129. 5.36.0.23
  130. date    91.06.13.19.53.29;    author paul;    state Exp;
  131. branches;
  132. next    5.36.0.24;
  133.  
  134. 5.36.0.24
  135. date    91.06.21.12.41.25;    author paul;    state Exp;
  136. branches;
  137. next    5.36.0.25;
  138.  
  139. 5.36.0.25
  140. date    91.07.02.18.23.30;    author paul;    state Exp;
  141. branches;
  142. next    5.36.0.26;
  143.  
  144. 5.36.0.26
  145. date    91.08.06.18.17.12;    author paul;    state Exp;
  146. branches;
  147. next    5.36.0.27;
  148.  
  149. 5.36.0.27
  150. date    91.08.12.17.52.32;    author paul;    state Exp;
  151. branches;
  152. next    ;
  153.  
  154.  
  155. desc
  156. @@
  157.  
  158.  
  159. 5.36
  160. log
  161. @5.64 Berkeley release
  162. @
  163. text
  164. @/*
  165.  * Copyright (c) 1983 Eric P. Allman
  166.  * Copyright (c) 1988 Regents of the University of California.
  167.  * All rights reserved.
  168.  *
  169.  * Redistribution and use in source and binary forms are permitted provided
  170.  * that: (1) source distributions retain this entire copyright notice and
  171.  * comment, and (2) distributions including binaries display the following
  172.  * acknowledgement:  ``This product includes software developed by the
  173.  * University of California, Berkeley and its contributors'' in the
  174.  * documentation or other materials provided with the distribution and in
  175.  * all advertising materials mentioning features or use of this software.
  176.  * Neither the name of the University nor the names of its contributors may
  177.  * be used to endorse or promote products derived from this software without
  178.  * specific prior written permission.
  179.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  180.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  181.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  182.  */
  183.  
  184. #include <errno.h>
  185. #include "sendmail.h"
  186.  
  187. #ifndef lint
  188. #ifdef DAEMON
  189. static char sccsid[] = "@@(#)daemon.c    5.36 (Berkeley) 6/1/90 (with daemon mode)";
  190. #else
  191. static char sccsid[] = "@@(#)daemon.c    5.36 (Berkeley) 6/1/90 (without daemon mode)";
  192. #endif
  193. #endif /* not lint */
  194.  
  195. int la;    /* load average */
  196.  
  197. #ifdef DAEMON
  198.  
  199. # include <netdb.h>
  200. # include <sys/signal.h>
  201. # include <sys/wait.h>
  202. # include <sys/time.h>
  203. # include <sys/resource.h>
  204.  
  205. /*
  206. **  DAEMON.C -- routines to use when running as a daemon.
  207. **
  208. **    This entire file is highly dependent on the 4.2 BSD
  209. **    interprocess communication primitives.  No attempt has
  210. **    been made to make this file portable to Version 7,
  211. **    Version 6, MPX files, etc.  If you should try such a
  212. **    thing yourself, I recommend chucking the entire file
  213. **    and starting from scratch.  Basic semantics are:
  214. **
  215. **    getrequests()
  216. **        Opens a port and initiates a connection.
  217. **        Returns in a child.  Must set InChannel and
  218. **        OutChannel appropriately.
  219. **    clrdaemon()
  220. **        Close any open files associated with getting
  221. **        the connection; this is used when running the queue,
  222. **        etc., to avoid having extra file descriptors during
  223. **        the queue run and to avoid confusing the network
  224. **        code (if it cares).
  225. **    makeconnection(host, port, outfile, infile)
  226. **        Make a connection to the named host on the given
  227. **        port.  Set *outfile and *infile to the files
  228. **        appropriate for communication.  Returns zero on
  229. **        success, else an exit status describing the
  230. **        error.
  231. **    maphostname(hbuf, hbufsize)
  232. **        Convert the entry in hbuf into a canonical form.  It
  233. **        may not be larger than hbufsize.
  234. */
  235. /*
  236. **  GETREQUESTS -- open mail IPC port and get requests.
  237. **
  238. **    Parameters:
  239. **        none.
  240. **
  241. **    Returns:
  242. **        none.
  243. **
  244. **    Side Effects:
  245. **        Waits until some interesting activity occurs.  When
  246. **        it does, a child is created to process it, and the
  247. **        parent waits for completion.  Return from this
  248. **        routine is always in the child.  The file pointers
  249. **        "InChannel" and "OutChannel" should be set to point
  250. **        to the communication channel.
  251. */
  252.  
  253. struct sockaddr_in    SendmailAddress;/* internet address of sendmail */
  254.  
  255. int    DaemonSocket    = -1;        /* fd describing socket */
  256. char    *NetName;            /* name of home (local?) network */
  257.  
  258. getrequests()
  259. {
  260.     int t;
  261.     register struct servent *sp;
  262.     int on = 1;
  263.     extern reapchild();
  264.  
  265.     /*
  266.     **  Set up the address for the mailer.
  267.     */
  268.  
  269.     sp = getservbyname("smtp", "tcp");
  270.     if (sp == NULL)
  271.     {
  272.         syserr("server \"smtp\" unknown");
  273.         goto severe;
  274.     }
  275.     SendmailAddress.sin_family = AF_INET;
  276.     SendmailAddress.sin_addr.s_addr = INADDR_ANY;
  277.     SendmailAddress.sin_port = sp->s_port;
  278.  
  279.     /*
  280.     **  Try to actually open the connection.
  281.     */
  282.  
  283.     if (tTd(15, 1))
  284.         printf("getrequests: port 0x%x\n", SendmailAddress.sin_port);
  285.  
  286.     /* get a socket for the SMTP connection */
  287.     DaemonSocket = socket(AF_INET, SOCK_STREAM, 0);
  288.     if (DaemonSocket < 0)
  289.     {
  290.         /* probably another daemon already */
  291.         syserr("getrequests: can't create socket");
  292.       severe:
  293. # ifdef LOG
  294.         if (LogLevel > 0)
  295.             syslog(LOG_ALERT, "cannot get connection");
  296. # endif LOG
  297.         finis();
  298.     }
  299.  
  300.     /* turn on network debugging? */
  301.     if (tTd(15, 15))
  302.         (void) setsockopt(DaemonSocket, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof on);
  303.  
  304.     (void) setsockopt(DaemonSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof on);
  305.     (void) setsockopt(DaemonSocket, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof on);
  306.  
  307.     if (bind(DaemonSocket, &SendmailAddress, sizeof SendmailAddress) < 0)
  308.     {
  309.         syserr("getrequests: cannot bind");
  310.         (void) close(DaemonSocket);
  311.         goto severe;
  312.     }
  313.     if (listen(DaemonSocket, 10) < 0)
  314.     {
  315.         syserr("getrequests: cannot listen");
  316.         (void) close(DaemonSocket);
  317.         goto severe;
  318.     }
  319.  
  320.     (void) signal(SIGCHLD, reapchild);
  321.  
  322.     if (tTd(15, 1))
  323.         printf("getrequests: %d\n", DaemonSocket);
  324.  
  325.     for (;;)
  326.     {
  327.         register int pid;
  328.         auto int lotherend;
  329.         extern int RefuseLA;
  330.  
  331.         /* see if we are rejecting connections */
  332.         while ((la = getla()) > RefuseLA)
  333.         {
  334.             setproctitle("rejecting connections: load average: %.2f", (double)la);
  335.             sleep(5);
  336.         }
  337.  
  338.         /* wait for a connection */
  339.         setproctitle("accepting connections");
  340.         do
  341.         {
  342.             errno = 0;
  343.             lotherend = sizeof RealHostAddr;
  344.             t = accept(DaemonSocket, &RealHostAddr, &lotherend);
  345.         } while (t < 0 && errno == EINTR);
  346.         if (t < 0)
  347.         {
  348.             syserr("getrequests: accept");
  349.             sleep(5);
  350.             continue;
  351.         }
  352.  
  353.         /*
  354.         **  Create a subprocess to process the mail.
  355.         */
  356.  
  357.         if (tTd(15, 2))
  358.             printf("getrequests: forking (fd = %d)\n", t);
  359.  
  360.         pid = fork();
  361.         if (pid < 0)
  362.         {
  363.             syserr("daemon: cannot fork");
  364.             sleep(10);
  365.             (void) close(t);
  366.             continue;
  367.         }
  368.  
  369.         if (pid == 0)
  370.         {
  371.             extern struct hostent *gethostbyaddr();
  372.             register struct hostent *hp;
  373.             char buf[MAXNAME];
  374.  
  375.             /*
  376.             **  CHILD -- return to caller.
  377.             **    Collect verified idea of sending host.
  378.             **    Verify calling user id if possible here.
  379.             */
  380.  
  381.             (void) signal(SIGCHLD, SIG_DFL);
  382.  
  383.             /* determine host name */
  384.             hp = gethostbyaddr((char *) &RealHostAddr.sin_addr, sizeof RealHostAddr.sin_addr, AF_INET);
  385.             if (hp != NULL)
  386.                 (void) strcpy(buf, hp->h_name);
  387.             else
  388.             {
  389.                 extern char *inet_ntoa();
  390.  
  391.                 /* produce a dotted quad */
  392.                 (void) sprintf(buf, "[%s]",
  393.                     inet_ntoa(RealHostAddr.sin_addr));
  394.             }
  395.  
  396.             /* should we check for illegal connection here? XXX */
  397.  
  398.             RealHostName = newstr(buf);
  399.  
  400.             (void) close(DaemonSocket);
  401.             InChannel = fdopen(t, "r");
  402.             OutChannel = fdopen(dup(t), "w");
  403.             if (tTd(15, 2))
  404.                 printf("getreq: returning\n");
  405. # ifdef LOG
  406.             if (LogLevel > 11)
  407.                 syslog(LOG_DEBUG, "connected, pid=%d", getpid());
  408. # endif LOG
  409.             return;
  410.         }
  411.  
  412.         /* close the port so that others will hang (for a while) */
  413.         (void) close(t);
  414.     }
  415.     /*NOTREACHED*/
  416. }
  417. /*
  418. **  CLRDAEMON -- reset the daemon connection
  419. **
  420. **    Parameters:
  421. **        none.
  422. **
  423. **    Returns:
  424. **        none.
  425. **
  426. **    Side Effects:
  427. **        releases any resources used by the passive daemon.
  428. */
  429.  
  430. clrdaemon()
  431. {
  432.     if (DaemonSocket >= 0)
  433.         (void) close(DaemonSocket);
  434.     DaemonSocket = -1;
  435. }
  436. /*
  437. **  MAKECONNECTION -- make a connection to an SMTP socket on another machine.
  438. **
  439. **    Parameters:
  440. **        host -- the name of the host.
  441. **        port -- the port number to connect to.
  442. **        outfile -- a pointer to a place to put the outfile
  443. **            descriptor.
  444. **        infile -- ditto for infile.
  445. **
  446. **    Returns:
  447. **        An exit code telling whether the connection could be
  448. **            made and if not why not.
  449. **
  450. **    Side Effects:
  451. **        none.
  452. */
  453.  
  454. makeconnection(host, port, outfile, infile)
  455.     char *host;
  456.     u_short port;
  457.     FILE **outfile;
  458.     FILE **infile;
  459. {
  460.     register int i, s;
  461.     register struct hostent *hp = (struct hostent *)NULL;
  462.     extern char *inet_ntoa();
  463.     int sav_errno;
  464. #ifdef NAMED_BIND
  465.     extern int h_errno;
  466. #endif
  467.  
  468.     /*
  469.     **  Set up the address for the mailer.
  470.     **    Accept "[a.b.c.d]" syntax for host name.
  471.     */
  472.  
  473. #ifdef NAMED_BIND
  474.     h_errno = 0;
  475. #endif
  476.     errno = 0;
  477.  
  478.     if (host[0] == '[')
  479.     {
  480.         long hid;
  481.         register char *p = index(host, ']');
  482.  
  483.         if (p != NULL)
  484.         {
  485.             *p = '\0';
  486.             hid = inet_addr(&host[1]);
  487.             *p = ']';
  488.         }
  489.         if (p == NULL || hid == -1)
  490.         {
  491.             usrerr("Invalid numeric domain spec \"%s\"", host);
  492.             return (EX_NOHOST);
  493.         }
  494.         SendmailAddress.sin_addr.s_addr = hid;
  495.     }
  496.     else
  497.     {
  498.         hp = gethostbyname(host);
  499.         if (hp == NULL)
  500.         {
  501. #ifdef NAMED_BIND
  502.             if (errno == ETIMEDOUT || h_errno == TRY_AGAIN)
  503.                 return (EX_TEMPFAIL);
  504.  
  505.             /* if name server is specified, assume temp fail */
  506.             if (errno == ECONNREFUSED && UseNameServer)
  507.                 return (EX_TEMPFAIL);
  508. #endif
  509.  
  510.             /*
  511.             **  XXX Should look for mail forwarder record here
  512.             **  XXX if (h_errno == NO_ADDRESS).
  513.             */
  514.  
  515.             return (EX_NOHOST);
  516.         }
  517.         bcopy(hp->h_addr, (char *) &SendmailAddress.sin_addr, hp->h_length);
  518.         i = 1;
  519.     }
  520.  
  521.     /*
  522.     **  Determine the port number.
  523.     */
  524.  
  525.     if (port != 0)
  526.         SendmailAddress.sin_port = htons(port);
  527.     else
  528.     {
  529.         register struct servent *sp = getservbyname("smtp", "tcp");
  530.  
  531.         if (sp == NULL)
  532.         {
  533.             syserr("makeconnection: server \"smtp\" unknown");
  534.             return (EX_OSFILE);
  535.         }
  536.         SendmailAddress.sin_port = sp->s_port;
  537.     }
  538.  
  539.     /*
  540.     **  Try to actually open the connection.
  541.     */
  542.  
  543. again:
  544.     if (tTd(16, 1))
  545.         printf("makeconnection (%s [%s])\n", host,
  546.             inet_ntoa(SendmailAddress.sin_addr.s_addr));
  547.  
  548.     s = socket(AF_INET, SOCK_STREAM, 0);
  549.     if (s < 0)
  550.     {
  551.         syserr("makeconnection: no socket");
  552.         sav_errno = errno;
  553.         goto failure;
  554.     }
  555.  
  556.     if (tTd(16, 1))
  557.         printf("makeconnection: %d\n", s);
  558.  
  559.     /* turn on network debugging? */
  560.     if (tTd(16, 14))
  561.     {
  562.         int on = 1;
  563.         (void) setsockopt(DaemonSocket, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof on);
  564.     }
  565.     if (CurEnv->e_xfp != NULL)
  566.         (void) fflush(CurEnv->e_xfp);        /* for debugging */
  567.     errno = 0;                    /* for debugging */
  568.     SendmailAddress.sin_family = AF_INET;
  569.     if (connect(s, &SendmailAddress, sizeof SendmailAddress) < 0)
  570.     {
  571.         sav_errno = errno;
  572.         (void) close(s);
  573.         if (hp && hp->h_addr_list[i])
  574.         {
  575.             bcopy(hp->h_addr_list[i++],
  576.                 (char *)&SendmailAddress.sin_addr, hp->h_length);
  577.             goto again;
  578.         }
  579.  
  580.         /* failure, decide if temporary or not */
  581.     failure:
  582.         switch (sav_errno)
  583.         {
  584.           case EISCONN:
  585.           case ETIMEDOUT:
  586.           case EINPROGRESS:
  587.           case EALREADY:
  588.           case EADDRINUSE:
  589.           case EHOSTDOWN:
  590.           case ENETDOWN:
  591.           case ENETRESET:
  592.           case ENOBUFS:
  593.           case ECONNREFUSED:
  594.           case ECONNRESET:
  595.           case EHOSTUNREACH:
  596.           case ENETUNREACH:
  597.             /* there are others, I'm sure..... */
  598.             return (EX_TEMPFAIL);
  599.  
  600.           case EPERM:
  601.             /* why is this happening? */
  602.             syserr("makeconnection: funny failure, addr=%lx, port=%x",
  603.                 SendmailAddress.sin_addr.s_addr, SendmailAddress.sin_port);
  604.             return (EX_TEMPFAIL);
  605.  
  606.           default:
  607.             {
  608.                 extern char *errstring();
  609.  
  610.                 message(Arpa_Info, "%s", errstring(sav_errno));
  611.                 return (EX_UNAVAILABLE);
  612.             }
  613.         }
  614.     }
  615.  
  616.     /* connection ok, put it into canonical form */
  617.     *outfile = fdopen(s, "w");
  618.     *infile = fdopen(dup(s), "r");
  619.  
  620.     return (EX_OK);
  621. }
  622. /*
  623. **  MYHOSTNAME -- return the name of this host.
  624. **
  625. **    Parameters:
  626. **        hostbuf -- a place to return the name of this host.
  627. **        size -- the size of hostbuf.
  628. **
  629. **    Returns:
  630. **        A list of aliases for this host.
  631. **
  632. **    Side Effects:
  633. **        none.
  634. */
  635.  
  636. char **
  637. myhostname(hostbuf, size)
  638.     char hostbuf[];
  639.     int size;
  640. {
  641.     extern struct hostent *gethostbyname();
  642.     struct hostent *hp;
  643.  
  644.     if (gethostname(hostbuf, size) < 0)
  645.     {
  646.         (void) strcpy(hostbuf, "localhost");
  647.     }
  648.     hp = gethostbyname(hostbuf);
  649.     if (hp != NULL)
  650.     {
  651.         (void) strcpy(hostbuf, hp->h_name);
  652.         return (hp->h_aliases);
  653.     }
  654.     else
  655.         return (NULL);
  656. }
  657.  
  658. /*
  659.  *  MAPHOSTNAME -- turn a hostname into canonical form
  660.  *
  661.  *    Parameters:
  662.  *        hbuf -- a buffer containing a hostname.
  663.  *        hbsize -- the size of hbuf.
  664.  *
  665.  *    Returns:
  666.  *        none.
  667.  *
  668.  *    Side Effects:
  669.  *        Looks up the host specified in hbuf.  If it is not
  670.  *        the canonical name for that host, replace it with
  671.  *        the canonical name.  If the name is unknown, or it
  672.  *        is already the canonical name, leave it unchanged.
  673.  */
  674. maphostname(hbuf, hbsize)
  675.     char *hbuf;
  676.     int hbsize;
  677. {
  678.     register struct hostent *hp;
  679.     u_long in_addr;
  680.     char ptr[256], *cp;
  681.     struct hostent *gethostbyaddr();
  682.  
  683.     /*
  684.      * If first character is a bracket, then it is an address
  685.      * lookup.  Address is copied into a temporary buffer to
  686.      * strip the brackets and to preserve hbuf if address is
  687.      * unknown.
  688.      */
  689.     if (*hbuf != '[') {
  690.         getcanonname(hbuf, hbsize);
  691.         return;
  692.     }
  693.     if ((cp = index(strcpy(ptr, hbuf), ']')) == NULL)
  694.         return;
  695.     *cp = '\0';
  696.     in_addr = inet_addr(&ptr[1]);
  697.     hp = gethostbyaddr((char *)&in_addr, sizeof(struct in_addr), AF_INET);
  698.     if (hp == NULL)
  699.         return;
  700.     if (strlen(hp->h_name) >= hbsize)
  701.         hp->h_name[hbsize - 1] = '\0';
  702.     (void)strcpy(hbuf, hp->h_name);
  703. }
  704.  
  705. # else DAEMON
  706. /* code for systems without sophisticated networking */
  707.  
  708. /*
  709. **  MYHOSTNAME -- stub version for case of no daemon code.
  710. **
  711. **    Can't convert to upper case here because might be a UUCP name.
  712. **
  713. **    Mark, you can change this to be anything you want......
  714. */
  715.  
  716. char **
  717. myhostname(hostbuf, size)
  718.     char hostbuf[];
  719.     int size;
  720. {
  721.     register FILE *f;
  722.  
  723.     hostbuf[0] = '\0';
  724.     f = fopen("/usr/include/whoami", "r");
  725.     if (f != NULL)
  726.     {
  727.         (void) fgets(hostbuf, size, f);
  728.         fixcrlf(hostbuf, TRUE);
  729.         (void) fclose(f);
  730.     }
  731.     return (NULL);
  732. }
  733. /*
  734. **  MAPHOSTNAME -- turn a hostname into canonical form
  735. **
  736. **    Parameters:
  737. **        hbuf -- a buffer containing a hostname.
  738. **        hbsize -- the size of hbuf.
  739. **
  740. **    Returns:
  741. **        none.
  742. **
  743. **    Side Effects:
  744. **        Looks up the host specified in hbuf.  If it is not
  745. **        the canonical name for that host, replace it with
  746. **        the canonical name.  If the name is unknown, or it
  747. **        is already the canonical name, leave it unchanged.
  748. */
  749.  
  750. /*ARGSUSED*/
  751. maphostname(hbuf, hbsize)
  752.     char *hbuf;
  753.     int hbsize;
  754. {
  755.     return;
  756. }
  757.  
  758. #endif DAEMON
  759. @
  760.  
  761.  
  762. 5.36.0.1
  763. log
  764. @IDA patches
  765. @
  766. text
  767. @d22 1
  768. a22 1
  769. #include <sendmail.h>
  770. a40 5
  771. # include <sys/file.h>
  772. # include <sys/types.h>
  773. # include <sys/stat.h>
  774. # include <arpa/nameser.h>
  775. # include <resolv.h>
  776. a70 8
  777. **
  778. **    mapinit(c)
  779. **        Open and initialize a dbm database.  Reopen if our current
  780. **        file descriptor is out of date.
  781. **
  782. **    mapkey(c, key, argval, argsiz)
  783. **        Search a database for a match to the given key, sprintf'ing
  784. **        the argument through the result if found.
  785. d133 1
  786. a133 1
  787. # endif /* LOG */
  788. a161 4
  789. #ifdef OUTPUT_PID
  790.     (void) write_pid_to_file ();
  791. #endif /* OUTPUT_PID */
  792.  
  793. d168 3
  794. a170 5
  795.         /*
  796.          * see if we are rejecting connections
  797.          */
  798. #ifndef BUSYEXIT
  799.         while ((la = getla()) > RefuseLA) {
  800. d172 1
  801. a172 1
  802.             sleep (5);
  803. a173 11
  804. #else
  805.         /*
  806.          * see if we are rejecting connections (but let srvrsmtp
  807.          * return a 421 Too busy to get rid of the request instead
  808.          * of stalling it).
  809.          */
  810.         if ((la = getla()) > RefuseLA)
  811.             setproctitle("Rejecting connections: load %d", la);
  812.         else
  813. #endif /* !BUSYEXIT */
  814.             setproctitle("Waiting for connection");
  815. d175 2
  816. d245 1
  817. a245 1
  818. # endif /* LOG */
  819. a305 15
  820.     **  Don't do recursive domain searches.  An example why not:
  821.     **  Machine cerl.cecer.army.mil has a UUCP connection to
  822.     **  osiris.cso.uiuc.edu.  Also at UIUC is a machine called
  823.     **  uinova.cerl.uiuc.edu that accepts mail for the its parent domain
  824.     **  cerl.uiuc.edu.  Sending mail to cerl!user with recursion on
  825.     **  will select cerl.uiuc.edu which maps to uinova.cerl.uiuc.edu.
  826.     **  We leave RES_DEFNAMES on so single names in the current domain
  827.     **  still work.
  828.     **
  829.     **  Paul Pomes, CSO, UIUC    17-Oct-88
  830.     */
  831.  
  832.     _res.options &= (~RES_DNSRCH & 0xffff);
  833.  
  834.     /*
  835. d419 1
  836. a419 2
  837.         errno = sav_errno;
  838.         switch (errno)
  839. d496 15
  840. a510 17
  841. **  MAPHOSTNAME -- turn a hostname into canonical form
  842. **
  843. **    Parameters:
  844. **        hbuf -- a buffer containing a hostname.
  845. **        hbsize -- the size of hbuf.
  846. **
  847. **    Returns:
  848. **        An exit code telling if the hostname was found and
  849. **        canonicalized.
  850. **
  851. **    Side Effects:
  852. **        Looks up the host specified in hbuf.  If it is not
  853. **        the canonical name for that host, replace it with
  854. **        the canonical name.  If the name is unknown, or it
  855. **        is already the canonical name, leave it unchanged.
  856. **/
  857. bool
  858. d516 3
  859. a518 2
  860.     extern struct hostent *gethostbyname();
  861.     static char tmphbuf[MAXNAME];
  862. d526 3
  863. a528 9
  864.     if (*hbuf == '[')
  865.     {
  866.         extern struct hostent *gethostbyaddr();
  867.         u_long in_addr;
  868.  
  869.         (void) strncpy(tmphbuf, hbuf+1, strlen(hbuf)-2);
  870.         tmphbuf[strlen(hbuf)-2]='\0';
  871.         in_addr = inet_addr(tmphbuf);
  872.         hp = gethostbyaddr((char *) &in_addr, sizeof(struct in_addr), AF_INET);
  873. d530 5
  874. a534 31
  875.     else
  876.     {
  877.         register int ret;
  878.  
  879.         /*
  880.         ** See note in makeconnection() above for why we disable
  881.         ** recursive domain matching.  -pbp
  882.         */
  883.         _res.options &= (~RES_DNSRCH & 0xffff);
  884.  
  885.         hp = gethostbyname(hbuf);
  886.         if (hp == NULL) {
  887.             /* try lowercase version */
  888.             (void) strcpy(tmphbuf, hbuf);
  889.             (void) makelower(tmphbuf);
  890.             /* Could be just an MX record; look for anything */
  891.             ret = getcanonname(tmphbuf,sizeof(tmphbuf));
  892.             if (ret != TRUE) {
  893.                 if (tTd(9, 1))
  894.                     printf("maphostname(%s, %d) => %.*s\n",
  895.                         hbuf, hbsize, hbsize-1, 
  896.                         hp ? hp->h_name : "NOT_FOUND");
  897.                 return FALSE;
  898.             }
  899.             strcpy(hbuf,tmphbuf);
  900.             return TRUE;
  901.         }
  902.     }
  903.     if (tTd(9, 1))
  904.         printf("maphostname(%s, %d) => %.*s\n",
  905.             hbuf, hbsize, hbsize-1, hp ? hp->h_name : "NOT_FOUND");
  906. d536 1
  907. a536 2
  908.         return FALSE;
  909.  
  910. d539 1
  911. a539 2
  912.     (void) strcpy(hbuf, hp->h_name);
  913.     return TRUE;
  914. d543 1
  915. a543 1
  916. /* code for systems without sophisticated networking */
  917. d570 1
  918. a570 2
  919.  
  920. /*
  921. d578 1
  922. a578 2
  923. **        An exit code telling if the hostname was found and
  924. **        canonicalized.
  925. d592 1
  926. a592 1
  927.     return (FALSE);
  928. d595 1
  929. a595 272
  930. #endif /* DAEMON */
  931. /*
  932. **  MAPINIT -- Open and (re)initialize a dbm database
  933. **
  934. **    Parameters:
  935. **        c -- the (one character) name of the database
  936. **
  937. **    Returns:
  938. **        An exit code telling if we could open the database.
  939. **
  940. */
  941. #if defined(NDBM) || defined(SDBM)
  942. bool
  943. mapinit(c)
  944.     char c;
  945. {
  946.     struct stat stb;
  947.     struct dbm_table *db;
  948.     char buf[MAXNAME];
  949.  
  950.     db = &DbmTab[c & 0177];
  951.  
  952.     if (db->db_name == NULL) {
  953.         syserr("database '%c' has not been defined", c);
  954.         return FALSE;
  955.     }
  956.  
  957. # ifdef YPMARK
  958.     /*
  959.      * Yellow pages are always supposed to be ready
  960.      */
  961.     if (db->db_name[0] == YPMARK)
  962.         return TRUE;
  963. # endif /* YPMARK */
  964.  
  965.     /*
  966.      * Have we already (unsuccessfully) tried to open it?
  967.      */
  968.     if (db->db_dbm == DB_NOSUCHFILE) {
  969.         if (tTd(60, 1))
  970.             printf("mapinit(%c) => NO_FILE\n", c);
  971.         return FALSE;
  972.     }
  973.  
  974.     /*
  975.      * If it already is open, check if it has been changed.
  976.      */
  977.     (void) sprintf(buf, "%s%s", db->db_name, DB_DIREXT);
  978.     if (db->db_dbm != DB_NOTYETOPEN) {
  979.         if (stat(buf, &stb) < 0 && (sleep(30), stat(buf, &stb) < 0)) {
  980.             syserr("somebody removed %s for db '%c'", buf, c);
  981.             db->db_dbm = DB_NOSUCHFILE;
  982.             if (tTd(60, 1))
  983.                 printf("mapinit(%c) => FILE_REMOVED\n", c);
  984.             return FALSE;
  985.         }
  986.         if (db->db_mtime != stb.st_mtime) {
  987.             if (tTd(60, 1))
  988.                 printf("database '%c' [%s] has changed; reopening it\n",
  989.                     c, db->db_name);
  990.             (void) dbm_close(db->db_dbm);
  991.             db->db_dbm = DB_NOTYETOPEN;
  992.         }
  993.     }
  994.  
  995.     /*
  996.      * Initialize database if not already open (r/w for aliases)
  997.      */
  998.     if (db->db_dbm == DB_NOTYETOPEN) {
  999.         db->db_dbm = dbm_open(db->db_name,
  1000.         c == DB_ALIAS ? O_RDWR : O_RDONLY, 0);
  1001. #if defined(apollo)
  1002.         /*  See option D in setoption() (readcf.c)  */
  1003.         OpMode == MD_INITALIAS &&
  1004. #endif /* apollo */
  1005.         if (db->db_dbm == DB_NOSUCHFILE) {
  1006.  
  1007.             /* try once more */
  1008.             sleep(30);
  1009.             db->db_dbm = dbm_open(db->db_name,
  1010. #if defined(apollo)
  1011.             OpMode == MD_INITALIAS &&
  1012. #endif /* apollo */
  1013.             c == DB_ALIAS ? O_RDWR : O_RDONLY, 0);
  1014.         }
  1015.         if (db->db_dbm == DB_NOSUCHFILE) {
  1016.             syserr("can't open database '%c' [%s]", c, db->db_name);
  1017.             if (tTd(60, 1))
  1018.                 printf("mapinit(%c) => CAN'T OPEN %s\n",
  1019.                     c, db->db_name);
  1020.             return FALSE;
  1021.         }
  1022.         if (stat(buf, &stb) < 0 && (sleep(30), stat(buf, &stb) < 0)) {
  1023.             syserr("can't stat %s", buf);
  1024.             if (tTd(60, 1))
  1025.                 printf("mapinit(%c) => FILE_REMOVED\n", c);
  1026.             return FALSE;
  1027.         }
  1028.         db->db_mtime = stb.st_mtime;
  1029.  
  1030.         /*
  1031.          * Make sure the database isn't being updated
  1032.          */
  1033.         if (flock(dbm_dirfno(db->db_dbm), LOCK_EX | LOCK_NB) < 0)
  1034.             if (errno == EWOULDBLOCK) {
  1035.                 if (tTd(60, 1))
  1036.                     printf("%s%s is locked, waiting...\n",
  1037.                         db->db_name, DB_DIREXT);
  1038.                 (void) flock(dbm_dirfno(db->db_dbm), LOCK_EX);
  1039.             }
  1040.             else
  1041.                 syserr("flock failed for db %c [%s]",
  1042.                     c, db->db_name);
  1043.         (void) flock(dbm_dirfno(db->db_dbm), LOCK_UN);
  1044.     }
  1045.     return TRUE;
  1046. }
  1047. /*
  1048. **  MAPKEY -- Search a dbm database.
  1049. **
  1050. **    Search the named database using the given key.  If
  1051. **    a result is found, sprintf the argument through the
  1052. **    result back into the key and return TRUE;
  1053. **    otherwise return FALSE and do nothing.
  1054. **
  1055. **    Keysize may also be given as zero, in which case the
  1056. **    sprintf'ed result is returned if the key matched.
  1057. **
  1058. **    Parameters:
  1059. **        c -- the database
  1060. **        key -- search string
  1061. **        argval -- sprintf argument & result
  1062. **        argsiz -- size of argval
  1063. **
  1064. **    Returns:
  1065. **        An exit code telling if there was a match.
  1066. **
  1067. **    Side Effects:
  1068. **        The argval is rewritten to reflect what was found
  1069. **        in the database.
  1070. */
  1071.  
  1072. mapkey(c, key, keysiz, arg)
  1073.     char c, *key, *arg;
  1074.     int keysiz;
  1075. {
  1076.     struct dbm_table *db;
  1077.     DATUM dkey, result;
  1078.     static char lowkey[MAXLINE+1];
  1079. #ifdef YPMARK
  1080.     static char *yp_domain = NULL;
  1081. #endif /* YPMARK */
  1082.  
  1083.     db = &DbmTab[c & 0177];
  1084.  
  1085.     if (tTd(60, 1))
  1086.         printf("mapkey('%c', \"%s\", \"%s\") => ",
  1087.             c, key, arg ? arg : "--");
  1088.  
  1089.     /*
  1090.      * Init the database; return if failure
  1091.      */
  1092.     if (!mapinit(c))
  1093.         return FALSE;
  1094.  
  1095.     /*
  1096.      * Normalize key (ie turn it to lowercase)
  1097.      */
  1098.     (void) strcpy(lowkey, key);
  1099.     (void) makelower(lowkey);
  1100.  
  1101. #ifdef YPMARK
  1102.     /*
  1103.      * Test for yellow page database first
  1104.      */
  1105.     if (db->db_name[0] == YPMARK) {
  1106.         if (yp_domain == NULL)
  1107.             (void) yp_get_default_domain(&yp_domain);
  1108.  
  1109.     /*
  1110.      * We include the null after the string, but Sun doesn't
  1111.      */
  1112.         if (yp_match(yp_domain, &db->db_name[1], lowkey,
  1113.             strlen(key)+1, &result.dptr, &result.dsize) != 0 &&
  1114.             yp_match(yp_domain, &db->db_name[1], lowkey,
  1115.             strlen(key), &result.dptr, &result.dsize) != 0)
  1116.             result.dptr = NULL;
  1117.         else
  1118.             /* smash newline */
  1119.             result.dptr[result.dsize] = '\0';
  1120.     }
  1121.     else
  1122.     {
  1123. #endif /* YPMARK */
  1124.         /*
  1125.          * Go look for matching dbm entry
  1126.          */
  1127.         dkey.dptr = lowkey;
  1128.         dkey.dsize = strlen(dkey.dptr) + 1;
  1129.         result = dbm_fetch(db->db_dbm, dkey);
  1130. #ifdef YPMARK
  1131.     }
  1132. #endif /* YPMARK */
  1133.  
  1134.     /*
  1135.      * Well, were we successful?
  1136.      */
  1137.     if (result.dptr == NULL) {
  1138.         if (tTd(60, 1))
  1139.             printf("NOT_FOUND\n");
  1140.         return FALSE;
  1141.     }
  1142.  
  1143.     /*
  1144.      * Yes, rewrite result if sprintf arg was given.
  1145.      */
  1146.     if (strlen(result.dptr) > MAXLINE)
  1147.     {
  1148.         syserr("mapkey: strlen(result.dptr) (%d) > %d\n",
  1149.             strlen(result.dptr), MAXLINE);
  1150. # ifdef LOG
  1151.         syslog(LOG_ALERT, "mapkey: strlen(result.dptr) (%d) > %d\n",
  1152.             strlen(result.dptr), MAXLINE);
  1153. # endif /* LOG */
  1154.     }
  1155.     if (arg == NULL)
  1156.         (void) strcpy(lowkey, result.dptr);
  1157.     else
  1158.         (void) sprintf(lowkey, result.dptr, arg);
  1159.     if (strlen(lowkey) > MAXLINE)
  1160.     {
  1161.         syserr("mapkey: strlen(lowkey) (%d) > %d\n",
  1162.             strlen(lowkey), MAXLINE);
  1163. # ifdef LOG
  1164.         syslog(LOG_ALERT, "mapkey: strlen(lowkey) (%d) > %d\n",
  1165.             strlen(lowkey), MAXLINE);
  1166. # endif /* LOG */
  1167.     }
  1168.  
  1169.     /*
  1170.      * if keysiz is zero, that means we should return a string from
  1171.      * the heap
  1172.      */
  1173.     if (keysiz == 0)
  1174.         key = newstr(lowkey);
  1175.     else
  1176.     {
  1177.         if (strlen(lowkey)+1 > keysiz) {
  1178.             syserr("mapkey: result \"%s\" too long after expansion\n",
  1179.                 lowkey, keysiz);
  1180.             lowkey[keysiz-1] = '\0';
  1181.         }
  1182.         (void) strcpy(key, lowkey);
  1183.     }
  1184.     if (tTd(60, 1))
  1185.         printf("%s\n", key);
  1186.  
  1187.     /* Ugly kludge that assumes that sizeof(int) == sizeof(char *) */
  1188.     return (int) key;
  1189. }
  1190.  
  1191. #else NDBM || SDBM
  1192.  
  1193. /* should really read the table into the stab instead */
  1194. mapkey(db, key, keysiz, arg)
  1195.     char db, *key, *arg;
  1196.     int keysiz;
  1197. {
  1198.     return FALSE;
  1199. }
  1200.  
  1201. #endif /* NDBM || SDBM */
  1202. @
  1203.  
  1204.  
  1205. 5.36.0.2
  1206. log
  1207. @Patches for HP-UX from Andy Linton <root@@comp.vuw.ac.nz>.  Thanks Andy!
  1208. @
  1209. text
  1210. @d779 1
  1211. a779 6
  1212.         if (flock(dbm_dirfno(db->db_dbm),
  1213. #if defined(hpux) 
  1214.               (c == DB_ALIAS ? LOCK_EX : LOCK_SH) | LOCK_NB) < 0)
  1215. #else
  1216.               LOCK_EX | LOCK_NB) < 0)
  1217. #endif /* hpux */
  1218. d784 1
  1219. a784 6
  1220.                 (void) flock(dbm_dirfno(db->db_dbm),
  1221. #if defined(hpux) 
  1222.                          (c == DB_ALIAS ? LOCK_EX : LOCK_SH));
  1223. #else
  1224.                          LOCK_EX);
  1225. #endif /* hpux */
  1226. @
  1227.  
  1228.  
  1229. 5.36.0.3
  1230. log
  1231. @Don't dup(s) for fdopen on a socket.  Sequent's run out of file descriptors
  1232. that way.
  1233.  
  1234.  
  1235. @
  1236. text
  1237. @d499 1
  1238. a499 1
  1239.     *infile = fdopen(s, "r");
  1240. @
  1241.  
  1242.  
  1243. 5.36.0.4
  1244. log
  1245. @inet_ntoa() was being handed a sin_addr.s_addr instead of a sin_addr.
  1246. @
  1247. text
  1248. @d426 1
  1249. a426 1
  1250.             inet_ntoa(SendmailAddress.sin_addr));
  1251. @
  1252.  
  1253.  
  1254. 5.36.0.5
  1255. log
  1256. @Corrected mapkey() return semantics.
  1257. @
  1258. text
  1259. @a827 1
  1260. char *
  1261. d849 1
  1262. a849 1
  1263.         return NULL;
  1264. d896 1
  1265. a896 1
  1266.         return NULL;
  1267. d943 2
  1268. a944 1
  1269.     return (key);
  1270. a949 1
  1271. char *
  1272. d954 1
  1273. a954 1
  1274.     return NULL;
  1275. @
  1276.  
  1277.  
  1278. 5.36.0.6
  1279. log
  1280. @Corrected missing/mis-placed ifdefs NAMED_BIND.  From Greg Onufer
  1281. (greg@@cheers.bungi.com).
  1282. @
  1283. text
  1284. @d331 1
  1285. d353 1
  1286. d355 1
  1287. a355 1
  1288. #endif /* NAMED_BIND */
  1289. a584 1
  1290. #ifdef NAMED_BIND
  1291. a589 1
  1292. #endif /* NAMED_BIND */
  1293. @
  1294.  
  1295.  
  1296. 5.36.0.7
  1297. log
  1298. @Bruce Lilly (bruce%balilly@@sonyd1.broadcast.sony.com) provided additional
  1299. #ifdef NAMED_BIND statements and some code cleanups.  Some variables
  1300. initialized that may get used before being set otherwise.  lockf() 
  1301. emulations of flock() return EAGAIN instead of EWOULDBLOCK. *Sigh*
  1302. Allow qualification of simple names into the default (current) domain (Neil
  1303. Rickert).
  1304. @
  1305. text
  1306. @d22 1
  1307. a22 2
  1308. #include <sys/signal.h>
  1309. #include "sendmail.h"
  1310. d25 1
  1311. a25 1
  1312. # ifdef DAEMON
  1313. d27 1
  1314. a27 1
  1315. # else /* !DAEMON */
  1316. d29 1
  1317. a29 1
  1318. # endif /* DAEMON */
  1319. d37 1
  1320. a41 3
  1321. # ifndef LOCK_EX
  1322. #  include "flock.h"
  1323. # endif /* !LOCK_EX */
  1324. d44 2
  1325. a45 4
  1326. # ifdef NAMED_BIND
  1327. #  include <arpa/nameser.h>
  1328. #  include <resolv.h>
  1329. # endif /* NAMED_BIND */
  1330. d175 1
  1331. a175 1
  1332. # ifdef OUTPUT_PID
  1333. d177 1
  1334. a177 1
  1335. # endif /* OUTPUT_PID */
  1336. d188 1
  1337. a188 1
  1338. # ifndef BUSYEXIT
  1339. d193 1
  1340. a193 1
  1341. # else /* BUSYEXIT */
  1342. d202 1
  1343. a202 1
  1344. # endif /* !BUSYEXIT */
  1345. d325 1
  1346. a325 2
  1347.     register int i = 0;
  1348.     register int s;
  1349. d329 1
  1350. a329 1
  1351. # ifdef NAMED_BIND
  1352. d353 1
  1353. a353 1
  1354. # endif /* NAMED_BIND */
  1355. d358 1
  1356. a358 1
  1357.         long hid = -1;
  1358. d379 1
  1359. a379 1
  1360. # ifdef NAMED_BIND
  1361. d386 1
  1362. a386 1
  1363. # endif /* NAMED_BIND */
  1364. a450 1
  1365. # ifdef NAMED_BIND
  1366. a456 1
  1367. # endif /* NAMED_BIND */
  1368. d583 1
  1369. a583 1
  1370. # ifdef NAMED_BIND
  1371. d589 1
  1372. a590 7
  1373.         /*
  1374.         ** But make sure default domain qualification is enabled -
  1375.         ** it may have been disabled in deliver.c.  -nr
  1376.         */
  1377.         _res.options |= RES_DEFNAMES ;
  1378. # endif /* NAMED_BIND */
  1379.  
  1380. d621 1
  1381. a621 1
  1382. #else /* DAEMON */
  1383. d687 1
  1384. a687 1
  1385. #if defined(NDBM) || defined(OTHERDBM)
  1386. a744 1
  1387. # if defined(apollo)
  1388. d746 5
  1389. a750 5
  1390.             OpMode == MD_INITALIAS &&
  1391.             c == DB_ALIAS ? O_RDWR : O_RDONLY, 0);
  1392. # else /* !apollo */
  1393.         db->db_dbm = dbm_open(db->db_name, O_RDWR, 0);
  1394. # endif /* apollo */
  1395. a754 1
  1396. # if defined(apollo)
  1397. d756 4
  1398. a759 5
  1399.                 OpMode == MD_INITALIAS &&
  1400.                 c == DB_ALIAS ? O_RDWR : O_RDONLY, 0);
  1401. # else /* !apollo */
  1402.             db->db_dbm = dbm_open(db->db_name, O_RDWR, 0);
  1403. # endif /* apollo */
  1404. d780 1
  1405. a780 1
  1406. # if defined(hpux) 
  1407. d782 1
  1408. a782 1
  1409. # else /* !hpux */
  1410. d784 2
  1411. a785 2
  1412. # endif /* hpux */
  1413.             if (errno == EWOULDBLOCK || errno == EAGAIN) {
  1414. d790 1
  1415. a790 1
  1416. # if defined(hpux) 
  1417. d792 1
  1418. a792 1
  1419. # else /* !hpux */
  1420. d794 1
  1421. a794 1
  1422. # endif /* hpux */
  1423. d797 2
  1424. a798 3
  1425.                 syserr("flock failed for db %c [%s], fd %d",
  1426.                     c, db->db_name, dbm_dirfno(db->db_dbm));
  1427.  
  1428. d834 1
  1429. a834 1
  1430.     XDATUM dkey, result;
  1431. d836 1
  1432. a836 1
  1433. # ifdef YPMARK
  1434. d838 1
  1435. a838 1
  1436. # endif /* YPMARK */
  1437. d858 1
  1438. a858 1
  1439. # ifdef YPMARK
  1440. d880 1
  1441. a880 1
  1442. # endif /* YPMARK */
  1443. d887 1
  1444. a887 1
  1445. # ifdef YPMARK
  1446. d889 1
  1447. a889 1
  1448. # endif /* YPMARK */
  1449. d936 1
  1450. a936 1
  1451.                 lowkey);
  1452. d947 1
  1453. a947 1
  1454. #else /* !NDBM && !OTHERDBM */
  1455. d958 1
  1456. a958 1
  1457. #endif /* NDBM || OTHERDBM */
  1458. @
  1459.  
  1460.  
  1461. 5.36.0.8
  1462. log
  1463. @Loop in myhostname() if NAMED_BIND defined and nameserver is unreachable.
  1464. Suggested by Steve Hubert (hubert@@cac.washington.edu).
  1465. @
  1466. text
  1467. @a534 7
  1468. # ifdef NAMED_BIND
  1469.     while ((hp = gethostbyname(hostbuf)) == NULL)
  1470.     {
  1471.         setproctitle("gethostbyname(%s) failed, sleeping", hostbuf);
  1472.         sleep(10);
  1473.     }
  1474. # else /* !NAMED_BIND */
  1475. a535 1
  1476. # endif /* NAMED_BIND */
  1477. @
  1478.  
  1479.  
  1480. 5.36.0.9
  1481. log
  1482. @Changed location of '{' to be consistent with the vanilla sendmail source.
  1483. Simplified locking in mapinit().  Now only the alias file is opened O_RDWR
  1484. when OpMode == MD_INITALIAS.  All others are O_RDONLY.  The same situation
  1485. for flock(): LOCK_SH unless re-writing the alias database.  Anyothing
  1486. re-writing a DBM database should be using exclusive locks which will block
  1487. a LOCK_SH request.  This provides better support for NFS-mounted, read-only
  1488. filesystems containing the mail database files.
  1489. @
  1490. text
  1491. @d41 4
  1492. d194 1
  1493. a194 2
  1494.         while ((la = getla()) > RefuseLA)
  1495.         {
  1496. d614 1
  1497. a614 2
  1498.         if (hp == NULL)
  1499.         {
  1500. d620 1
  1501. a620 2
  1502.             if (ret != TRUE)
  1503.             {
  1504. d623 1
  1505. a623 1
  1506.                         hbuf, hbsize, hbsize-1,
  1507. a715 1
  1508.     int k;
  1509. d720 1
  1510. a720 2
  1511.     if (db->db_name == NULL)
  1512.     {
  1513. d736 1
  1514. a736 2
  1515.     if (db->db_dbm == DB_NOSUCHFILE)
  1516.     {
  1517. d746 2
  1518. a747 4
  1519.     if (db->db_dbm != DB_NOTYETOPEN)
  1520.     {
  1521.         if (stat(buf, &stb) < 0 && (sleep(30), stat(buf, &stb) < 0))
  1522.         {
  1523. d754 1
  1524. a754 2
  1525.         if (db->db_mtime != stb.st_mtime)
  1526.         {
  1527. d764 1
  1528. a764 1
  1529.      * Initialize database if not already open (r/w for aliases iff init)
  1530. d766 2
  1531. a767 2
  1532.     if (db->db_dbm == DB_NOTYETOPEN)
  1533.     {
  1534. d769 7
  1535. a775 4
  1536.             (OpMode == MD_INITALIAS && c == DB_ALIAS)
  1537.             ? O_RDWR : O_RDONLY, 0);
  1538.         if (db->db_dbm == DB_NOSUCHFILE)
  1539.         {
  1540. d778 1
  1541. d780 5
  1542. a784 2
  1543.                 (OpMode == MD_INITALIAS && c == DB_ALIAS)
  1544.                 ? O_RDWR : O_RDONLY, 0);
  1545. d786 1
  1546. a786 2
  1547.         if (db->db_dbm == DB_NOSUCHFILE)
  1548.         {
  1549. d793 1
  1550. a793 2
  1551.         if (stat(buf, &stb) < 0 && (sleep(30), stat(buf, &stb) < 0))
  1552.         {
  1553. a800 1
  1554. # ifndef GDBM
  1555. d805 6
  1556. a810 4
  1557.             ((OpMode == MD_INITALIAS && c == DB_ALIAS) ? LOCK_EX : LOCK_SH) | LOCK_NB) < 0)
  1558.         {
  1559.             if (errno == EWOULDBLOCK || errno == EAGAIN)
  1560.             {
  1561. d815 5
  1562. a819 1
  1563.                         ((OpMode == MD_INITALIAS && c == DB_ALIAS) ? LOCK_EX : LOCK_SH));
  1564. d824 1
  1565. a824 1
  1566.         }
  1567. a825 1
  1568. # endif /* !GDBM */
  1569. d888 1
  1570. a888 2
  1571.     if (db->db_name[0] == YPMARK)
  1572.     {
  1573. d920 1
  1574. a920 2
  1575.     if (result.dptr == NULL)
  1576.     {
  1577. d960 1
  1578. a960 2
  1579.         if (strlen(lowkey)+1 > keysiz)
  1580.         {
  1581. d983 1
  1582. @
  1583.  
  1584.  
  1585. 5.36.0.10
  1586. log
  1587. @Changed reapchild() declaration to SIG_TYPE.  Added casts to bind(),
  1588. accept(), and connect() statements.
  1589. @
  1590. text
  1591. @d104 1
  1592. a104 1
  1593. struct sockaddr_in    SendmailAddress; /* internet address of sendmail */
  1594. d114 1
  1595. a114 1
  1596.     extern SIG_TYPE reapchild();
  1597. d158 1
  1598. a158 2
  1599.     if (bind(DaemonSocket,
  1600.         (struct sockaddr *) &SendmailAddress, sizeof SendmailAddress) < 0)
  1601. d211 1
  1602. a211 2
  1603.             t = accept(DaemonSocket,
  1604.                 (struct sockaddr *) &RealHostAddr, &lotherend);
  1605. d450 1
  1606. a450 2
  1607.     if (connect(s,
  1608.         (struct sockaddr *) &SendmailAddress, sizeof SendmailAddress) < 0)
  1609. @
  1610.  
  1611.  
  1612. 5.36.0.11
  1613. log
  1614. @Deleted #ifdef/#define OUTPUT_PID in favor of testing whether _PATH_SENDMAILPID
  1615. is set.  sendmail.h now #include's pathnames.h instead of the other
  1616. modules.
  1617. @
  1618. text
  1619. @d177 3
  1620. a179 3
  1621. # ifdef _PATH_SENDMAILPID
  1622.     (void) WritePid();
  1623. # endif /* _PATH_SENDMAILPID */
  1624. @
  1625.  
  1626.  
  1627. 5.36.0.12
  1628. log
  1629. @Deleted #include <sys/types.h> as it's already included via sendmail.h from
  1630. useful.h.  #include "sendmail.h" relocated to top of #include list.
  1631. @
  1632. text
  1633. @a20 1
  1634. #include "sendmail.h"
  1635. d23 1
  1636. d41 1
  1637. @
  1638.  
  1639.  
  1640. 5.36.0.13
  1641. log
  1642. @Fixed return type of maphostname() #ifndef DAEMON.
  1643. @
  1644. text
  1645. @a691 1
  1646. bool
  1647. a976 1
  1648. /*ARGSUSED*/
  1649. @
  1650.  
  1651.  
  1652. 5.36.0.14
  1653. log
  1654. @ANSIfied.
  1655. @
  1656. text
  1657. @a107 1
  1658. void
  1659. d113 1
  1660. d193 1
  1661. a193 1
  1662.             Xsleep (5);
  1663. d217 1
  1664. a217 1
  1665.             Xsleep(5);
  1666. a228 2
  1667.         if (pid > 0 && tTd(4, 2))
  1668.             printf("getrequests: forking (pid = %d)\n", pid);
  1669. d232 1
  1670. a232 1
  1671.             Xsleep(10);
  1672. d239 1
  1673. d257 2
  1674. a297 1
  1675. void
  1676. d323 1
  1677. a323 1
  1678.     const char *host;
  1679. d331 1
  1680. d494 2
  1681. d527 1
  1682. d538 1
  1683. a538 1
  1684.         Xsleep(10);
  1685. d575 1
  1686. d586 1
  1687. d753 1
  1688. a753 1
  1689.         if (stat(buf, &stb) < 0 && (Xsleep(30), stat(buf, &stb) < 0))
  1690. d782 1
  1691. a782 1
  1692.             Xsleep(30);
  1693. d795 1
  1694. a795 1
  1695.         if (stat(buf, &stb) < 0 && (Xsleep(30), stat(buf, &stb) < 0))
  1696. d842 2
  1697. a843 2
  1698. **        keysiz -- size of key
  1699. **        arg -- sprintf argument
  1700. d849 1
  1701. a849 1
  1702. **        The key is rewritten to reflect what was found
  1703. d855 1
  1704. a855 3
  1705.     char c;
  1706.     const char *arg;
  1707.     char *key;
  1708. d981 1
  1709. a981 3
  1710.     char db;
  1711.     const char *arg;
  1712.     char *key;
  1713. @
  1714.  
  1715.  
  1716. 5.36.0.15
  1717. log
  1718. @Check results of fdopen() calls in makeconnection() to guard against
  1719. descriptor leaks.  Suggested by Kannan Varadan.
  1720. @
  1721. text
  1722. @d503 1
  1723. a503 8
  1724.     /* Necessary to catch leaks */
  1725.     if (*outfile == NULL || *infile == NULL)
  1726.     {
  1727.         syserr("makeconnection: *outfile or *infile NULL");
  1728.         return (EX_TEMPFAIL);
  1729.     }
  1730.     else
  1731.         return (EX_OK);
  1732. @
  1733.  
  1734.  
  1735. 5.36.0.16
  1736. log
  1737. @Surrounded signal(SIG_CHLD, ...) calls with #ifdef SIG_CHLD ala conf.c,
  1738. queue.c.  Deleted BUSYWAIT code as it's a performance disaster.
  1739. @
  1740. text
  1741. @a170 1
  1742. # ifdef SIGCHLD
  1743. a171 1
  1744. # endif /* SIGCHLD */
  1745. d189 1
  1746. d195 11
  1747. a205 1
  1748.         setproctitle("Waiting for connection");
  1749. a249 1
  1750. # ifdef SIGCHLD
  1751. a250 1
  1752. # endif /* SIGCHLD */
  1753. @
  1754.  
  1755.  
  1756. 5.36.0.17
  1757. log
  1758. @Added RCS ID string
  1759. @
  1760. text
  1761. @a27 1
  1762. static char rcsid[] = "@@(#)$Id$ (with daemon mode)";
  1763. a29 1
  1764. static char rcsid[] = "@@(#)$Id$ (without daemon mode)";
  1765. @
  1766.  
  1767.  
  1768. 5.36.0.18
  1769. log
  1770. @Now uses the unsigned value INADDR_NONE to initialize hid.  Socket values
  1771. are now dup()ed prior to the second fdopen().
  1772. @
  1773. text
  1774. @d27 2
  1775. a28 2
  1776. static char sccsid[] = "@@(#)daemon.c    5.36 (Berkeley) 6/1/90 (with daemon mode)    %I% local";
  1777. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.17 1991/04/05 14:55:15 paul Exp paul $ (with daemon mode)";
  1778. d30 2
  1779. a31 2
  1780. static char sccsid[] = "@@(#)daemon.c    5.36 (Berkeley) 6/1/90 (without daemon mode)    %I% local";
  1781. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.17 1991/04/05 14:55:15 paul Exp paul $ (without daemon mode)";
  1782. a316 1
  1783. int
  1784. d356 1
  1785. a356 1
  1786.         unsigned long hid = INADDR_NONE;
  1787. d365 1
  1788. a365 1
  1789.         if (p == NULL || hid == INADDR_NONE)
  1790. d495 1
  1791. a496 1
  1792.     *outfile = fdopen(dup(s), "w");
  1793. @
  1794.  
  1795.  
  1796. 5.36.0.19
  1797. log
  1798. @Moved #include of signal.h and time.h to sendmail.h
  1799.  
  1800. Further changes for Interactive Systems UNIX adapted from patches
  1801. sent by Andy Linton <Andy.Linton@@comp.vuw.ac.nz>.
  1802. @
  1803. text
  1804. @d23 1
  1805. a23 3
  1806. #ifdef ISC
  1807. # include <net/errno.h>
  1808. #endif /* ISC */
  1809. d28 1
  1810. a28 1
  1811. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.18 1991/05/18 17:22:57 paul Exp paul $ (with daemon mode)";
  1812. d31 1
  1813. a31 1
  1814. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.18 1991/05/18 17:22:57 paul Exp paul $ (without daemon mode)";
  1815. a39 3
  1816. # ifdef ISC
  1817.   typedef short pid_t;
  1818. # endif /* ISC */
  1819. d41 2
  1820. a42 3
  1821. # ifndef ISC
  1822. #  include <sys/resource.h>
  1823. # endif /* !ISC */
  1824. @
  1825.  
  1826.  
  1827. 5.36.0.20
  1828. log
  1829. @De-linting (omitted voids).
  1830. @
  1831. text
  1832. @d30 1
  1833. a30 1
  1834. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.19 1991/05/23 21:25:27 paul Exp paul $ (with daemon mode)";
  1835. d33 1
  1836. a33 1
  1837. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.19 1991/05/23 21:25:27 paul Exp paul $ (without daemon mode)";
  1838. d631 1
  1839. a631 1
  1840.             (void) strcpy(hbuf,tmphbuf);
  1841. @
  1842.  
  1843.  
  1844. 5.36.0.21
  1845. log
  1846. @Deleted unneeded include of sys/resource.h, added some casts to keep
  1847. S5R4 compilers happy.
  1848. @
  1849. text
  1850. @d30 1
  1851. a30 1
  1852. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.21 1991/06/04 18:27:11 paul Exp paul $ (with daemon mode)";
  1853. d33 1
  1854. a33 1
  1855. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.21 1991/06/04 18:27:11 paul Exp paul $ (without daemon mode)";
  1856. d46 3
  1857. d641 1
  1858. a641 1
  1859.     if ((int)(strlen(hp->h_name)) >= hbsize)
  1860. d935 1
  1861. a935 1
  1862.     if ((int)(strlen(result.dptr)) > MAXLINE)
  1863. d948 1
  1864. a948 1
  1865.     if ((int)(strlen(lowkey)) > MAXLINE)
  1866. d966 1
  1867. a966 1
  1868.         if ((int)(strlen(lowkey)+1) > keysiz)
  1869. @
  1870.  
  1871.  
  1872. 5.36.0.22
  1873. log
  1874. @Date:    Sat, 8 Jun 1991 10:27:47 -0400
  1875. From:    bruce%balilly@@broadcast.sony.com (Bruce Lilly)
  1876. Subject: case sensitive/insensitive database lookups
  1877.  
  1878. Files affected: alias.c, daemon.c
  1879.  
  1880. Allow case-sensitive (as well as -insensitive) database lookup.  Needed
  1881. because (a) user names in the aliases file, used as a dbm key, may be stored
  1882. with upper-case letters preserved (if mailerflag 'u' is specified for the
  1883. local mailer), making it impossible to retrieve aliases for these users without
  1884. the change (see loweraddr() in parseaddr.c), and (b) at most it requires one
  1885. additional dbm access per lookup, and only if keys supplied have upper-case
  1886. letters, so it is inexpensive.  Code is included for lookup of keys that may
  1887. or may not be NULL-terminated.
  1888. @
  1889. text
  1890. @d30 1
  1891. a30 1
  1892. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.21 1991/06/05 16:46:15 paul Exp paul $ (with daemon mode)";
  1893. d33 1
  1894. a33 1
  1895. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.21 1991/06/05 16:46:15 paul Exp paul $ (without daemon mode)";
  1896. d897 1
  1897. a897 2
  1898.         if (
  1899.             yp_match(yp_domain, &db->db_name[1], key,
  1900. a898 2
  1901.             yp_match(yp_domain, &db->db_name[1], key,
  1902.             strlen(key), &result.dptr, &result.dsize) != 0 &&
  1903. a899 2
  1904.             strlen(key)+1, &result.dptr, &result.dsize) != 0 &&
  1905.             yp_match(yp_domain, &db->db_name[1], lowkey,
  1906. d912 2
  1907. a913 4
  1908.         dkey.dsize = strlen(key);
  1909.         dkey.dptr = key;
  1910.  
  1911.         /* verbatim key */
  1912. a914 19
  1913.         if (result.dptr == (char *)NULL)
  1914.         {
  1915.             /* try null-terminated version of given key */
  1916.             dkey.dsize += 1;
  1917.             result = dbm_fetch(db->db_dbm, dkey);
  1918.             if (result.dptr == (char *)NULL)
  1919.             {
  1920.                 /* use lower case key */
  1921.                 dkey.dsize -= 1;
  1922.                 dkey.dptr = lowkey;
  1923.                 result = dbm_fetch(db->db_dbm, dkey);
  1924.                 if (result.dptr == (char *)NULL)
  1925.                 {
  1926.                     /* try as null-terminated lower case */
  1927.                     dkey.dsize += 1;
  1928.                     result = dbm_fetch(db->db_dbm, dkey);
  1929.                 }
  1930.             }
  1931.         }
  1932. @
  1933.  
  1934.  
  1935. 5.36.0.23
  1936. log
  1937. @Further changes to support NO_PADDING.
  1938. @
  1939. text
  1940. @d30 1
  1941. a30 1
  1942. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.22 1991/06/13 17:16:27 paul Exp paul $ (with daemon mode)";
  1943. d33 1
  1944. a33 1
  1945. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.22 1991/06/13 17:16:27 paul Exp paul $ (without daemon mode)";
  1946. d862 1
  1947. a862 1
  1948.     char *lowkey;
  1949. d882 1
  1950. a882 1
  1951.     lowkey = newstr(key);
  1952. d909 1
  1953. a909 1
  1954.             result.dptr[result.dsize--] = '\0';
  1955. a944 1
  1956.     free(lowkey);
  1957. d958 1
  1958. a958 1
  1959.     if (arg == NULL)
  1960. d960 6
  1961. a965 3
  1962.         lowkey = dbm_newstr(result);
  1963.         if (tTd(60, 2))
  1964.             printf("[ no arg ] %s\n", lowkey);
  1965. d967 2
  1966. d970 1
  1967. a970 33
  1968.     {
  1969.         char *fmt, *percent;
  1970.         bool need_sprintf = FALSE;
  1971.  
  1972.         fmt = dbm_newstr(result);
  1973.         percent = fmt;
  1974.         while ((percent = index(percent, '%')) != NULL)
  1975.         {
  1976.             if (*(++percent) == 's')
  1977.             {
  1978.                 need_sprintf = TRUE;
  1979.                 break;
  1980.             }
  1981.             else if (*percent == '%') /* %% */
  1982.                 ++percent;
  1983.         }
  1984.         if (need_sprintf)
  1985.         {
  1986.             /* expect an arg */
  1987.             lowkey = xalloc(result.dsize + strlen(arg));
  1988.             (void) sprintf(lowkey, fmt, arg);
  1989.             if (tTd(60, 2))
  1990.                 printf("[%s] %s => %s\n", fmt, arg, lowkey);
  1991.             free(fmt);
  1992.         }
  1993.         else
  1994.         {
  1995.             /* keep the allocated string */
  1996.             lowkey = fmt;
  1997.             if (tTd(60, 2))
  1998.                 printf("[ no arg expected ] %s\n", lowkey);
  1999.         }
  2000.     }
  2001. d986 1
  2002. a986 1
  2003.         key = lowkey;
  2004. a995 1
  2005.         free(lowkey);
  2006. @
  2007.  
  2008.  
  2009. 5.36.0.24
  2010. log
  2011. @Bruce Lilly straightened out usage of DAEMON and VMUNIX for selecting
  2012. sendmail features.  Maphostname() now uses uname() if available and all
  2013. else fails.  Neil Rickert contributed patch to preserve error messages
  2014. about host unreachables and time-outs.
  2015. @
  2016. text
  2017. @d29 2
  2018. a30 2
  2019. static char sccsid[] = "@@(#)daemon.c    5.36 (Berkeley) 6/1/90 (with daemon mode)";
  2020. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.23 1991/06/13 19:53:29 paul Exp paul $ (with daemon mode)";
  2021. d32 2
  2022. a33 2
  2023. static char sccsid[] = "@@(#)daemon.c    5.36 (Berkeley) 6/1/90 (without daemon mode)";
  2024. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.23 1991/06/13 19:53:29 paul Exp paul $ (without daemon mode)";
  2025. d39 2
  2026. a40 1
  2027. #ifdef VMUNIX
  2028. a51 6
  2029. struct sockaddr_in    SendmailAddress; /* internet address of sendmail */
  2030.  
  2031. #endif /* VMUNIX */
  2032.  
  2033. #ifdef DAEMON
  2034.  
  2035. d108 2
  2036. d111 1
  2037. a301 2
  2038. #endif /* DAEMON */
  2039. #ifdef VMUNIX
  2040. d330 1
  2041. a330 1
  2042.     int sav_errno = 0;
  2043. d443 1
  2044. a443 1
  2045.         (void) setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof on);
  2046. d452 1
  2047. a452 13
  2048.         switch (errno)
  2049.         {
  2050.             case ETIMEDOUT:
  2051.             case EHOSTUNREACH:
  2052.             case ENETUNREACH:
  2053.             /* there are others, I'm sure..... */
  2054.             if (sav_errno == 0)
  2055.                 sav_errno = errno;
  2056.             break;
  2057.  
  2058.             default:
  2059.             sav_errno = errno;
  2060.         }
  2061. d533 1
  2062. d535 1
  2063. d643 3
  2064. a645 7
  2065.  
  2066. #else /* !VMUNIX */
  2067. /* code for systems without sophisticated networking */
  2068.  
  2069. # ifdef HAS_UNAME
  2070. #  include <sys/utsname.h>
  2071. # endif /* HAS_UNAME */
  2072. d648 1
  2073. a648 1
  2074. **  MYHOSTNAME -- stub version for case of no gethostent(3N) code.
  2075. a660 3
  2076. # ifdef HAS_UNAME
  2077.     struct    utsname    utsname;
  2078. # endif /* HAS_UNAME */
  2079. a662 4
  2080. # ifdef HAS_UNAME
  2081.     if (uname(&utsname) != -1)
  2082.         strncpy(hostbuf, utsname.nodename, min(8, size-1));
  2083. # else /* !HAS_UNAME */
  2084. d670 20
  2085. a689 9
  2086. # endif /* HAS_UNAME */
  2087.     if (hostbuf[0])
  2088.     {
  2089.         static char *alias[2];
  2090.         /*
  2091.          * an alias is nodename.uucp
  2092.          * this is an alias and the nodename is the canonical form
  2093.          * because ".uucp" isn't an official top-level domain.
  2094.          */
  2095. d691 7
  2096. a697 10
  2097.         if (alias[0])
  2098.             free(alias[0]); /* in case called more than once */
  2099.         alias[0] = (char *)xalloc(strlen(hostbuf)+6);
  2100.         strcpy(alias[0], hostbuf);
  2101.         strcat(alias[0], ".uucp");
  2102.         alias[1] = (char *)NULL;
  2103.         return(alias);
  2104.     }
  2105.     else
  2106.         return (NULL);
  2107. d700 1
  2108. a700 1
  2109. #endif /* VMUNIX */
  2110. @
  2111.  
  2112.  
  2113. 5.36.0.25
  2114. log
  2115. @Ultrix fix: be sure last character is a new-line before zapping it from
  2116. a YP string.
  2117. @
  2118. text
  2119. @d30 1
  2120. a30 1
  2121. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.24 1991/06/21 12:41:25 paul Exp paul $ (with daemon mode)";
  2122. d33 1
  2123. a33 1
  2124. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.24 1991/06/21 12:41:25 paul Exp paul $ (without daemon mode)";
  2125. d924 2
  2126. a925 3
  2127.  
  2128.         /* smash newline */
  2129.         else if (result.dptr[result.dsize] == '\n')
  2130. @
  2131.  
  2132.  
  2133. 5.36.0.26
  2134. log
  2135. @Date:    Wed, 31 Jul 91 13:24:05 -0500
  2136. To:      Paul Pomes <Paul-Pomes@@uiuc.edu>
  2137. cc:      "Mark D. Baushke" <mdb@@esd.3com.com>
  2138. From:    Neil Rickert <rickert@@cs.niu.edu>
  2139. Subject: patches / bugs in sendmail-IDA.
  2140.  
  2141. I am enclosing the patch I prepared for a few users who were having problems
  2142. with frozen config files on Suns, in spite of static linking and using
  2143. ../uiuc/malloc.c .
  2144.  
  2145. It eliminates any code that even smells of YP/NIS prior to the completion of
  2146. freeze/thaw operations.
  2147.  
  2148. It is probably safe, and perhaps even desirable, to remove the yp_unbind()
  2149. calls from main.c
  2150.  
  2151.  -Neil
  2152. @
  2153. text
  2154. @d30 1
  2155. a30 1
  2156. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.25 1991/07/02 18:23:30 paul Exp paul $ (with daemon mode)";
  2157. d33 1
  2158. a33 1
  2159. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.25 1991/07/02 18:23:30 paul Exp paul $ (without daemon mode)";
  2160. a556 15
  2161. #  ifdef sun
  2162.     /*
  2163.      *    An ugly hack.
  2164.      *    This routine is mainly called to assign a default value
  2165.      *    to $w .  As such it must be called before the config file
  2166.      *    is processed.  On Sun systems this involves calls to some
  2167.      *    of the yp lookup routines.  They apparently leave state
  2168.      *    information lying around which is inconsistent with the
  2169.      *    use of frozen configurations.  Since the standard Sun
  2170.      *    setup leaves hostnames unqualified anyway, omitting the
  2171.      *    gethostbyname() call should have little effect.
  2172.      */
  2173.  
  2174.     hp = NULL;
  2175. #  else /* !sun */
  2176. a557 1
  2177. #  endif /* sun */
  2178. @
  2179.  
  2180.  
  2181. 5.36.0.27
  2182. log
  2183. @Final correction (I hope!) for trimmijng new-line from end of
  2184. strings returned from yp_match().
  2185. @
  2186. text
  2187. @d30 1
  2188. a30 1
  2189. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.26 1991/08/06 18:17:12 paul Exp paul $ (with daemon mode)";
  2190. d33 1
  2191. a33 1
  2192. static char rcsid[] = "@@(#)$Id: daemon.c,v 5.36.0.26 1991/08/06 18:17:12 paul Exp paul $ (without daemon mode)";
  2193. d941 1
  2194. a941 1
  2195.         /* smash newline if supplied */
  2196. d943 1
  2197. a943 1
  2198.             result.dptr[result.dsize] = '\0';
  2199. @
  2200.