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 / alias.c,v next >
Encoding:
Text File  |  1991-08-14  |  32.6 KB  |  1,704 lines

  1. head    5.21;
  2. branch    5.21.0;
  3. access;
  4. symbols
  5.     RELEASE:5.21.0.21
  6.     BETA:5.21.0.17
  7.     UICSO:5.21.0
  8.     VANILLA:5.21;
  9. locks; strict;
  10. comment    @ * @;
  11.  
  12.  
  13. 5.21
  14. date    90.06.20.08.35.01;    author paul;    state Exp;
  15. branches
  16.     5.21.0.1;
  17. next    ;
  18.  
  19. 5.21.0.1
  20. date    90.06.20.09.42.28;    author paul;    state Exp;
  21. branches;
  22. next    5.21.0.2;
  23.  
  24. 5.21.0.2
  25. date    90.06.25.09.19.29;    author paul;    state Exp;
  26. branches;
  27. next    5.21.0.3;
  28.  
  29. 5.21.0.3
  30. date    90.08.02.14.37.37;    author paul;    state Exp;
  31. branches;
  32. next    5.21.0.4;
  33.  
  34. 5.21.0.4
  35. date    90.08.27.17.14.39;    author paul;    state Exp;
  36. branches;
  37. next    5.21.0.5;
  38.  
  39. 5.21.0.5
  40. date    90.09.17.09.34.01;    author paul;    state Exp;
  41. branches;
  42. next    5.21.0.6;
  43.  
  44. 5.21.0.6
  45. date    90.10.13.17.39.29;    author paul;    state Exp;
  46. branches;
  47. next    5.21.0.7;
  48.  
  49. 5.21.0.7
  50. date    90.11.19.16.12.54;    author paul;    state Exp;
  51. branches;
  52. next    5.21.0.8;
  53.  
  54. 5.21.0.8
  55. date    90.11.24.02.18.57;    author paul;    state Exp;
  56. branches;
  57. next    5.21.0.9;
  58.  
  59. 5.21.0.9
  60. date    91.01.19.19.26.02;    author paul;    state Exp;
  61. branches;
  62. next    5.21.0.10;
  63.  
  64. 5.21.0.10
  65. date    91.02.15.20.15.20;    author paul;    state Exp;
  66. branches;
  67. next    5.21.0.11;
  68.  
  69. 5.21.0.11
  70. date    91.02.17.02.49.44;    author paul;    state Exp;
  71. branches;
  72. next    5.21.0.12;
  73.  
  74. 5.21.0.12
  75. date    91.03.04.21.48.23;    author paul;    state Exp;
  76. branches;
  77. next    5.21.0.13;
  78.  
  79. 5.21.0.13
  80. date    91.04.02.23.06.52;    author paul;    state Exp;
  81. branches;
  82. next    5.21.0.14;
  83.  
  84. 5.21.0.14
  85. date    91.04.05.14.55.15;    author paul;    state Exp;
  86. branches;
  87. next    5.21.0.15;
  88.  
  89. 5.21.0.15
  90. date    91.05.18.03.39.58;    author paul;    state Exp;
  91. branches;
  92. next    5.21.0.16;
  93.  
  94. 5.21.0.16
  95. date    91.05.23.21.16.31;    author paul;    state Exp;
  96. branches;
  97. next    5.21.0.17;
  98.  
  99. 5.21.0.17
  100. date    91.05.29.05.11.52;    author paul;    state Exp;
  101. branches;
  102. next    5.21.0.18;
  103.  
  104. 5.21.0.18
  105. date    91.06.05.02.20.56;    author paul;    state Exp;
  106. branches;
  107. next    5.21.0.19;
  108.  
  109. 5.21.0.19
  110. date    91.06.13.17.16.44;    author paul;    state Exp;
  111. branches;
  112. next    5.21.0.20;
  113.  
  114. 5.21.0.20
  115. date    91.06.13.19.53.29;    author paul;    state Exp;
  116. branches;
  117. next    5.21.0.21;
  118.  
  119. 5.21.0.21
  120. date    91.06.21.12.16.37;    author paul;    state Exp;
  121. branches;
  122. next    5.21.0.22;
  123.  
  124. 5.21.0.22
  125. date    91.07.11.05.34.08;    author paul;    state Exp;
  126. branches;
  127. next    5.21.0.23;
  128.  
  129. 5.21.0.23
  130. date    91.08.08.22.13.25;    author paul;    state Exp;
  131. branches;
  132. next    5.21.0.24;
  133.  
  134. 5.21.0.24
  135. date    91.08.14.16.56.42;    author paul;    state Exp;
  136. branches;
  137. next    ;
  138.  
  139.  
  140. desc
  141. @@
  142.  
  143.  
  144. 5.21
  145. log
  146. @5.64 Berkeley release
  147. @
  148. text
  149. @/*
  150.  * Copyright (c) 1983 Eric P. Allman
  151.  * Copyright (c) 1988 Regents of the University of California.
  152.  * All rights reserved.
  153.  *
  154.  * Redistribution and use in source and binary forms are permitted provided
  155.  * that: (1) source distributions retain this entire copyright notice and
  156.  * comment, and (2) distributions including binaries display the following
  157.  * acknowledgement:  ``This product includes software developed by the
  158.  * University of California, Berkeley and its contributors'' in the
  159.  * documentation or other materials provided with the distribution and in
  160.  * all advertising materials mentioning features or use of this software.
  161.  * Neither the name of the University nor the names of its contributors may
  162.  * be used to endorse or promote products derived from this software without
  163.  * specific prior written permission.
  164.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  165.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  166.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  167.  */
  168.  
  169. #ifndef lint
  170. #ifdef DBM
  171. static char sccsid[] = "@@(#)alias.c    5.21 (Berkeley) 6/1/90 (with DBM)";
  172. #else
  173. static char sccsid[] = "@@(#)alias.c    5.21 (Berkeley) 6/1/90 (without DBM)";
  174. #endif
  175. #endif /* not lint */
  176.  
  177. # include <sys/types.h>
  178. # include <sys/stat.h>
  179. # include <signal.h>
  180. # include <errno.h>
  181. # include "sendmail.h"
  182. # include <sys/file.h>
  183. # include <pwd.h>
  184.  
  185. /*
  186. **  ALIAS -- Compute aliases.
  187. **
  188. **    Scans the alias file for an alias for the given address.
  189. **    If found, it arranges to deliver to the alias list instead.
  190. **    Uses libdbm database if -DDBM.
  191. **
  192. **    Parameters:
  193. **        a -- address to alias.
  194. **        sendq -- a pointer to the head of the send queue
  195. **            to put the aliases in.
  196. **
  197. **    Returns:
  198. **        none
  199. **
  200. **    Side Effects:
  201. **        Aliases found are expanded.
  202. **
  203. **    Notes:
  204. **        If NoAlias (the "-n" flag) is set, no aliasing is
  205. **            done.
  206. **
  207. **    Deficiencies:
  208. **        It should complain about names that are aliased to
  209. **            nothing.
  210. */
  211.  
  212.  
  213. #ifdef DBM
  214. typedef struct
  215. {
  216.     char    *dptr;
  217.     int    dsize;
  218. } DATUM;
  219. extern DATUM fetch();
  220. #endif DBM
  221.  
  222. alias(a, sendq)
  223.     register ADDRESS *a;
  224.     ADDRESS **sendq;
  225. {
  226.     register char *p;
  227.     extern char *aliaslookup();
  228.  
  229.     if (tTd(27, 1))
  230.         printf("alias(%s)\n", a->q_paddr);
  231.  
  232.     /* don't realias already aliased names */
  233.     if (bitset(QDONTSEND, a->q_flags))
  234.         return;
  235.  
  236.     CurEnv->e_to = a->q_paddr;
  237.  
  238.     /*
  239.     **  Look up this name
  240.     */
  241.  
  242.     if (NoAlias)
  243.         p = NULL;
  244.     else
  245.         p = aliaslookup(a->q_user);
  246.     if (p == NULL)
  247.         return;
  248.  
  249.     /*
  250.     **  Match on Alias.
  251.     **    Deliver to the target list.
  252.     */
  253.  
  254.     if (tTd(27, 1))
  255.         printf("%s (%s, %s) aliased to %s\n",
  256.             a->q_paddr, a->q_host, a->q_user, p);
  257.     message(Arpa_Info, "aliased to %s", p);
  258.     AliasLevel++;
  259.     sendtolist(p, a, sendq);
  260.     AliasLevel--;
  261. }
  262. /*
  263. **  ALIASLOOKUP -- look up a name in the alias file.
  264. **
  265. **    Parameters:
  266. **        name -- the name to look up.
  267. **
  268. **    Returns:
  269. **        the value of name.
  270. **        NULL if unknown.
  271. **
  272. **    Side Effects:
  273. **        none.
  274. **
  275. **    Warnings:
  276. **        The return value will be trashed across calls.
  277. */
  278.  
  279. char *
  280. aliaslookup(name)
  281.     char *name;
  282. {
  283. # ifdef DBM
  284.     DATUM rhs, lhs;
  285.  
  286.     /* create a key for fetch */
  287.     lhs.dptr = name;
  288.     lhs.dsize = strlen(name) + 1;
  289.     rhs = fetch(lhs);
  290.     return (rhs.dptr);
  291. # else DBM
  292.     register STAB *s;
  293.  
  294.     s = stab(name, ST_ALIAS, ST_FIND);
  295.     if (s == NULL)
  296.         return (NULL);
  297.     return (s->s_alias);
  298. # endif DBM
  299. }
  300. /*
  301. **  INITALIASES -- initialize for aliasing
  302. **
  303. **    Very different depending on whether we are running DBM or not.
  304. **
  305. **    Parameters:
  306. **        aliasfile -- location of aliases.
  307. **        init -- if set and if DBM, initialize the DBM files.
  308. **
  309. **    Returns:
  310. **        none.
  311. **
  312. **    Side Effects:
  313. **        initializes aliases:
  314. **        if DBM:  opens the database.
  315. **        if ~DBM: reads the aliases into the symbol table.
  316. */
  317.  
  318. # define DBMMODE    0644
  319.  
  320. initaliases(aliasfile, init)
  321.     char *aliasfile;
  322.     bool init;
  323. {
  324. #ifdef DBM
  325.     int atcnt;
  326.     time_t modtime;
  327.     bool automatic = FALSE;
  328.     char buf[MAXNAME];
  329. #endif DBM
  330.     struct stat stb;
  331.     static bool initialized = FALSE;
  332.  
  333.     if (initialized)
  334.         return;
  335.     initialized = TRUE;
  336.  
  337.     if (aliasfile == NULL || stat(aliasfile, &stb) < 0)
  338.     {
  339.         if (aliasfile != NULL && init)
  340.             syserr("Cannot open %s", aliasfile);
  341.         NoAlias = TRUE;
  342.         errno = 0;
  343.         return;
  344.     }
  345.  
  346. # ifdef DBM
  347.     /*
  348.     **  Check to see that the alias file is complete.
  349.     **    If not, we will assume that someone died, and it is up
  350.     **    to us to rebuild it.
  351.     */
  352.  
  353.     if (!init)
  354.         dbminit(aliasfile);
  355.     atcnt = SafeAlias * 2;
  356.     if (atcnt > 0)
  357.     {
  358.         while (!init && atcnt-- >= 0 && aliaslookup("@@") == NULL)
  359.         {
  360.             /*
  361.             **  Reinitialize alias file in case the new
  362.             **  one is mv'ed in instead of cp'ed in.
  363.             **
  364.             **    Only works with new DBM -- old one will
  365.             **    just consume file descriptors forever.
  366.             **    If you have a dbmclose() it can be
  367.             **    added before the sleep(30).
  368.             */
  369.  
  370.             sleep(30);
  371. # ifdef NDBM
  372.             dbminit(aliasfile);
  373. # endif NDBM
  374.         }
  375.     }
  376.     else
  377.         atcnt = 1;
  378.  
  379.     /*
  380.     **  See if the DBM version of the file is out of date with
  381.     **  the text version.  If so, go into 'init' mode automatically.
  382.     **    This only happens if our effective userid owns the DBM.
  383.     **    Note the unpalatable hack to see if the stat succeeded.
  384.     */
  385.  
  386.     modtime = stb.st_mtime;
  387.     (void) strcpy(buf, aliasfile);
  388.     (void) strcat(buf, ".pag");
  389.     stb.st_ino = 0;
  390.     if (!init && (stat(buf, &stb) < 0 || stb.st_mtime < modtime || atcnt < 0))
  391.     {
  392.         errno = 0;
  393.         if (AutoRebuild && stb.st_ino != 0 && stb.st_uid == geteuid())
  394.         {
  395.             init = TRUE;
  396.             automatic = TRUE;
  397.             message(Arpa_Info, "rebuilding alias database");
  398. #ifdef LOG
  399.             if (LogLevel >= 7)
  400.                 syslog(LOG_INFO, "rebuilding alias database");
  401. #endif LOG
  402.         }
  403.         else
  404.         {
  405. #ifdef LOG
  406.             if (LogLevel >= 7)
  407.                 syslog(LOG_INFO, "alias database out of date");
  408. #endif LOG
  409.             message(Arpa_Info, "Warning: alias database out of date");
  410.         }
  411.     }
  412.  
  413.  
  414.     /*
  415.     **  If necessary, load the DBM file.
  416.     **    If running without DBM, load the symbol table.
  417.     */
  418.  
  419.     if (init)
  420.     {
  421. #ifdef LOG
  422.         if (LogLevel >= 6)
  423.         {
  424.             extern char *username();
  425.  
  426.             syslog(LOG_NOTICE, "alias database %srebuilt by %s",
  427.                 automatic ? "auto" : "", username());
  428.         }
  429. #endif LOG
  430.         readaliases(aliasfile, TRUE);
  431.     }
  432. # else DBM
  433.     readaliases(aliasfile, init);
  434. # endif DBM
  435. }
  436. /*
  437. **  READALIASES -- read and process the alias file.
  438. **
  439. **    This routine implements the part of initaliases that occurs
  440. **    when we are not going to use the DBM stuff.
  441. **
  442. **    Parameters:
  443. **        aliasfile -- the pathname of the alias file master.
  444. **        init -- if set, initialize the DBM stuff.
  445. **
  446. **    Returns:
  447. **        none.
  448. **
  449. **    Side Effects:
  450. **        Reads aliasfile into the symbol table.
  451. **        Optionally, builds the .dir & .pag files.
  452. */
  453.  
  454. static
  455. readaliases(aliasfile, init)
  456.     char *aliasfile;
  457.     bool init;
  458. {
  459.     register char *p;
  460.     char *rhs;
  461.     bool skipping;
  462.     int naliases, bytes, longest;
  463.     FILE *af;
  464.     void (*oldsigint)();
  465.     ADDRESS al, bl;
  466.     register STAB *s;
  467.     char line[BUFSIZ];
  468.  
  469.     if ((af = fopen(aliasfile, "r")) == NULL)
  470.     {
  471.         if (tTd(27, 1))
  472.             printf("Can't open %s\n", aliasfile);
  473.         errno = 0;
  474.         NoAlias++;
  475.         return;
  476.     }
  477.  
  478. # ifdef DBM
  479.     /* see if someone else is rebuilding the alias file already */
  480.     if (flock(fileno(af), LOCK_EX | LOCK_NB) < 0 && errno == EWOULDBLOCK)
  481.     {
  482.         /* yes, they are -- wait until done and then return */
  483.         message(Arpa_Info, "Alias file is already being rebuilt");
  484.         if (OpMode != MD_INITALIAS)
  485.         {
  486.             /* wait for other rebuild to complete */
  487.             (void) flock(fileno(af), LOCK_EX);
  488.         }
  489.         (void) fclose(af);
  490.         errno = 0;
  491.         return;
  492.     }
  493. # endif DBM
  494.  
  495.     /*
  496.     **  If initializing, create the new DBM files.
  497.     */
  498.  
  499.     if (init)
  500.     {
  501.         oldsigint = signal(SIGINT, SIG_IGN);
  502.         (void) strcpy(line, aliasfile);
  503.         (void) strcat(line, ".dir");
  504.         if (close(creat(line, DBMMODE)) < 0)
  505.         {
  506.             syserr("cannot make %s", line);
  507.             (void) signal(SIGINT, oldsigint);
  508.             return;
  509.         }
  510.         (void) strcpy(line, aliasfile);
  511.         (void) strcat(line, ".pag");
  512.         if (close(creat(line, DBMMODE)) < 0)
  513.         {
  514.             syserr("cannot make %s", line);
  515.             (void) signal(SIGINT, oldsigint);
  516.             return;
  517.         }
  518.         dbminit(aliasfile);
  519.     }
  520.  
  521.     /*
  522.     **  Read and interpret lines
  523.     */
  524.  
  525.     FileName = aliasfile;
  526.     LineNumber = 0;
  527.     naliases = bytes = longest = 0;
  528.     skipping = FALSE;
  529.     while (fgets(line, sizeof (line), af) != NULL)
  530.     {
  531.         int lhssize, rhssize;
  532.  
  533.         LineNumber++;
  534.         p = index(line, '\n');
  535.         if (p != NULL)
  536.             *p = '\0';
  537.         switch (line[0])
  538.         {
  539.           case '#':
  540.           case '\0':
  541.             skipping = FALSE;
  542.             continue;
  543.  
  544.           case ' ':
  545.           case '\t':
  546.             if (!skipping)
  547.                 syserr("Non-continuation line starts with space");
  548.             skipping = TRUE;
  549.             continue;
  550.         }
  551.         skipping = FALSE;
  552.  
  553.         /*
  554.         **  Process the LHS
  555.         **    Find the final colon, and parse the address.
  556.         **    It should resolve to a local name -- this will
  557.         **    be checked later (we want to optionally do
  558.         **    parsing of the RHS first to maximize error
  559.         **    detection).
  560.         */
  561.  
  562.         for (p = line; *p != '\0' && *p != ':' && *p != '\n'; p++)
  563.             continue;
  564.         if (*p++ != ':')
  565.         {
  566.             syserr("missing colon");
  567.             continue;
  568.         }
  569.         if (parseaddr(line, &al, 1, ':') == NULL)
  570.         {
  571.             syserr("illegal alias name");
  572.             continue;
  573.         }
  574.         loweraddr(&al);
  575.  
  576.         /*
  577.         **  Process the RHS.
  578.         **    'al' is the internal form of the LHS address.
  579.         **    'p' points to the text of the RHS.
  580.         */
  581.  
  582.         rhs = p;
  583.         for (;;)
  584.         {
  585.             register char c;
  586.  
  587.             if (init && CheckAliases)
  588.             {
  589.                 /* do parsing & compression of addresses */
  590.                 while (*p != '\0')
  591.                 {
  592.                     extern char *DelimChar;
  593.  
  594.                     while (isspace(*p) || *p == ',')
  595.                         p++;
  596.                     if (*p == '\0')
  597.                         break;
  598.                     if (parseaddr(p, &bl, -1, ',') == NULL)
  599.                         usrerr("%s... bad address", p);
  600.                     p = DelimChar;
  601.                 }
  602.             }
  603.             else
  604.             {
  605.                 p = &p[strlen(p)];
  606.                 if (p[-1] == '\n')
  607.                     *--p = '\0';
  608.             }
  609.  
  610.             /* see if there should be a continuation line */
  611.             c = fgetc(af);
  612.             if (!feof(af))
  613.                 (void) ungetc(c, af);
  614.             if (c != ' ' && c != '\t')
  615.                 break;
  616.  
  617.             /* read continuation line */
  618.             if (fgets(p, sizeof line - (p - line), af) == NULL)
  619.                 break;
  620.             LineNumber++;
  621.         }
  622.         if (al.q_mailer != LocalMailer)
  623.         {
  624.             syserr("cannot alias non-local names");
  625.             continue;
  626.         }
  627.  
  628.         /*
  629.         **  Insert alias into symbol table or DBM file
  630.         */
  631.  
  632.         lhssize = strlen(al.q_user) + 1;
  633.         rhssize = strlen(rhs) + 1;
  634.  
  635. # ifdef DBM
  636.         if (init)
  637.         {
  638.             DATUM key, content;
  639.  
  640.             key.dsize = lhssize;
  641.             key.dptr = al.q_user;
  642.             content.dsize = rhssize;
  643.             content.dptr = rhs;
  644.             store(key, content);
  645.         }
  646.         else
  647. # endif DBM
  648.         {
  649.             s = stab(al.q_user, ST_ALIAS, ST_ENTER);
  650.             s->s_alias = newstr(rhs);
  651.         }
  652.  
  653.         /* statistics */
  654.         naliases++;
  655.         bytes += lhssize + rhssize;
  656.         if (rhssize > longest)
  657.             longest = rhssize;
  658.     }
  659.  
  660. # ifdef DBM
  661.     if (init)
  662.     {
  663.         /* add the distinquished alias "@@" */
  664.         DATUM key;
  665.  
  666.         key.dsize = 2;
  667.         key.dptr = "@@";
  668.         store(key, key);
  669.  
  670.         /* restore the old signal */
  671.         (void) signal(SIGINT, oldsigint);
  672.     }
  673. # endif DBM
  674.  
  675.     /* closing the alias file drops the lock */
  676.     (void) fclose(af);
  677.     CurEnv->e_to = NULL;
  678.     FileName = NULL;
  679.     message(Arpa_Info, "%d aliases, longest %d bytes, %d bytes total",
  680.             naliases, longest, bytes);
  681. # ifdef LOG
  682.     if (LogLevel >= 8)
  683.         syslog(LOG_INFO, "%d aliases, longest %d bytes, %d bytes total",
  684.             naliases, longest, bytes);
  685. # endif LOG
  686. }
  687. /*
  688. **  FORWARD -- Try to forward mail
  689. **
  690. **    This is similar but not identical to aliasing.
  691. **
  692. **    Parameters:
  693. **        user -- the name of the user who's mail we would like
  694. **            to forward to.  It must have been verified --
  695. **            i.e., the q_home field must have been filled
  696. **            in.
  697. **        sendq -- a pointer to the head of the send queue to
  698. **            put this user's aliases in.
  699. **
  700. **    Returns:
  701. **        none.
  702. **
  703. **    Side Effects:
  704. **        New names are added to send queues.
  705. */
  706.  
  707. forward(user, sendq)
  708.     ADDRESS *user;
  709.     ADDRESS **sendq;
  710. {
  711.     char buf[60];
  712.     extern bool safefile();
  713.  
  714.     if (tTd(27, 1))
  715.         printf("forward(%s)\n", user->q_paddr);
  716.  
  717.     if (user->q_mailer != LocalMailer || bitset(QBADADDR, user->q_flags))
  718.         return;
  719.     if (user->q_home == NULL)
  720.         syserr("forward: no home");
  721.  
  722.     /* good address -- look for .forward file in home */
  723.     define('z', user->q_home, CurEnv);
  724.     expand("\001z/.forward", buf, &buf[sizeof buf - 1], CurEnv);
  725.     if (!safefile(buf, user->q_uid, S_IREAD))
  726.         return;
  727.  
  728.     /* we do have an address to forward to -- do it */
  729.     include(buf, "forwarding", user, sendq);
  730. }
  731. @
  732.  
  733.  
  734. 5.21.0.1
  735. log
  736. @IDA patches
  737. @
  738. text
  739. @d65 6
  740. a70 1
  741. #if defined(DBM) && !defined(NDBM) && !defined(SDBM)
  742. d72 1
  743. a72 1
  744. #endif /* DBM && !NDBM && !SDBM */
  745. d82 1
  746. a82 1
  747.         printf("alias(%s)\n", a->q_user);
  748. d128 1
  749. a128 2
  750. **        The return value will be trashed across calls
  751. **        unless NDBM or SDBM is defined and we're using mapkey().
  752. a135 12
  753. #  if defined(NDBM) || defined(SDBM)
  754.     char *newname;
  755.  
  756.     if (tTd(27, 3))
  757.         printf("aliaslookup(\"%s\") => ", name);
  758.     newname = (char *) mapkey(DB_ALIAS, name, 0, 0);
  759.     if (tTd(27, 3))
  760.         printf("%s\n", newname == NULL ? "NOT_FOUND" : newname);
  761.     return newname;
  762.  
  763. #  else /* !NDBM && !SDBM */
  764.  
  765. a136 1
  766.     char *lowname = xalloc(strlen(name) + 1); /* potential space hog */
  767. d139 1
  768. a139 3
  769.     (void) strcpy(lowname, name);
  770.     (void) makelower(lowname);
  771.     lhs.dptr = lowname;
  772. a140 2
  773.     if (tTd(27, 3))
  774.         printf("aliaslookup(\"%s\") => ", lhs.dptr);
  775. a141 3
  776.     if (tTd(27, 3))
  777.         printf("%s\n", rhs.dptr == NULL ? "NOT_FOUND" : rhs.dptr);
  778.     (void) free(lowname);
  779. d143 1
  780. a143 2
  781. #  endif /* NDBM || SDBM */
  782. # else /* !DBM */
  783. a146 2
  784.     if (tTd(27, 3))
  785.         printf("%s\n", s == NULL ? "NOT_FOUND" : s->s_alias);
  786. d150 1
  787. a150 1
  788. # endif /* DBM */
  789. d158 1
  790. d172 2
  791. a173 1
  792. initaliases(init)
  793. d181 1
  794. a181 1
  795. #endif /* DBM */
  796. d189 1
  797. a189 8
  798.     if (AliasFile == NULL ||
  799. #ifdef YPMARK
  800.         (AliasFile[0] != YPMARK &&
  801. #endif /* YPMARK */
  802.          stat(AliasFile, &stb) < 0)
  803. #ifdef YPMARK
  804.         )
  805. #endif /* YPMARK */
  806. d191 2
  807. a192 2
  808.         if (AliasFile != NULL && init)
  809.             syserr("Cannot open %s", AliasFile);
  810. a204 1
  811. #if !defined(NDBM) && !defined(SDBM)
  812. d206 1
  813. a206 2
  814.         dbminit(AliasFile);
  815. #endif /* !NDBM && !SDBM */
  816. d209 1
  817. d211 11
  818. d223 5
  819. d239 2
  820. a240 2
  821.     (void) strcpy(buf, AliasFile);
  822.     (void) strcat(buf, DB_PAGEXT);
  823. d242 1
  824. a242 5
  825.     if (!init &&
  826. #ifdef YPMARK
  827.         AliasFile[0] != YPMARK &&
  828. #endif /* YPMARK */
  829.         (stat(buf, &stb) < 0 || stb.st_mtime < modtime || atcnt < 0))
  830. d253 1
  831. a253 1
  832. #endif /* LOG */
  833. d260 1
  834. a260 1
  835. #endif /* LOG */
  836. d281 2
  837. a282 2
  838. #endif /* LOG */
  839.         readaliases(TRUE);
  840. d284 3
  841. a286 3
  842. # else /* !DBM */
  843.     readaliases(init);
  844. # endif /* DBM */
  845. d295 1
  846. d302 1
  847. a302 1
  848. **        Reads AliasFile into the symbol table.
  849. d307 2
  850. a308 1
  851. readaliases(init)
  852. d316 1
  853. a316 1
  854.     SIG_TYPE (*oldsigint)();
  855. d321 1
  856. a321 11
  857. # ifdef YPMARK
  858.     if (AliasFile[0] == YPMARK) {
  859.         if (tTd(27, 1))
  860.             printf("Can't reinit YP databases: \"%s\"\n", AliasFile);
  861.         /* reuse old aliases */
  862.         errno = 0;
  863.         return;
  864.     }
  865. # endif /* YPMARK */
  866.  
  867.     if ((af = fopen(AliasFile, "r")) == NULL)
  868. d324 1
  869. a324 1
  870.             printf("Can't open %s\n", AliasFile);
  871. d345 1
  872. a345 1
  873. # endif /* DBM */
  874. d354 2
  875. a355 2
  876.         (void) strcpy(line, AliasFile);
  877.         (void) strcat(line, DB_PAGEXT);
  878. d362 2
  879. a363 2
  880.         (void) strcpy(line, AliasFile);
  881.         (void) strcat(line, DB_DIREXT);
  882. d370 1
  883. a370 5
  884. # if defined(NDBM) || defined(SDBM)
  885.         mapinit(DB_ALIAS);
  886. # else /* !NDBM && !SDBM */
  887.         dbminit(AliasFile);
  888. # endif /* NDBM || SDBM */
  889. d377 1
  890. a377 1
  891.     FileName = AliasFile;
  892. a476 6
  893.             if (tTd(27, 3)) {
  894.                 printf("Mailer al.q_mailer:\n");
  895.                 print_mailer(al.q_mailer);
  896.                 printf("\nMailer LocalMailer:\n");
  897.                 print_mailer(LocalMailer);
  898.             }
  899. a495 3
  900. # if defined(NDBM) || defined(SDBM)
  901.             (void) dbm_store(AliasDbm, key, content, DBM_REPLACE);
  902. # else /* !NDBM && !SDBM */
  903. a496 1
  904. # endif /* NDBM || SDBM */
  905. d499 1
  906. a499 1
  907. # endif /* DBM */
  908. d515 1
  909. a516 3
  910. # ifdef YP
  911.         DATUM content;
  912.         char    Now[65];
  913. a517 24
  914.         /* add the YP stamps.  N.B., don't pad the lengths by 1! */
  915.         gethostname (Now, 64);
  916.         key.dsize = strlen ("YP_MASTER_NAME");
  917.         key.dptr = "YP_MASTER_NAME";
  918.         content.dsize = strlen (Now);
  919.         content.dptr = Now;
  920. # if defined(NDBM) || defined(SDBM)
  921.         (void) dbm_store(AliasDbm, key, content, DBM_INSERT);
  922. # else /* !NDBM && !SDBM */
  923.         store(key, content);
  924. # endif /* NDBM || SDBM */
  925.         (void) sprintf (Now, "%010u", time(0));
  926.         key.dsize = strlen ("YP_LAST_MODIFIED");
  927.         key.dptr = "YP_LAST_MODIFIED";
  928.         content.dsize = strlen (Now);
  929.         content.dptr = Now;
  930. # if defined(NDBM) || defined(SDBM)
  931.         (void) dbm_store(AliasDbm, key, content, DBM_INSERT);
  932. # else /* !NDBM && !SDBM */
  933.         store(key, Now);
  934. # endif /* NDBM || SDBM */
  935. # endif /* YP */
  936.  
  937.         /* add the distinquished alias "@@" */
  938. a519 3
  939. # if defined(NDBM) || defined(SDBM)
  940.         (void) dbm_store(AliasDbm, key, key, DBM_INSERT);
  941. # else /* !NDBM && !SDBM */
  942. a520 1
  943. # endif /* NDBM || SDBM */
  944. d525 1
  945. a525 1
  946. # endif /* DBM */
  947. d537 1
  948. a537 1
  949. # endif /* LOG */
  950. a581 52
  951. }
  952. /*
  953. **  PRINT_MAILER -- Print contents of struct mailer
  954. **
  955. **    This is for debugging
  956. **
  957. **    Parameters:
  958. **        Mpnt -- pointer to struct mailer
  959. **
  960. **    Returns:
  961. **        none.
  962. **
  963. **    Side Effects:
  964. **        none.
  965. */
  966.  
  967. print_mailer(Mpnt)
  968.     MAILER    *Mpnt;
  969. {
  970.     register int    i;
  971.     register char    **j;
  972.  
  973.     if (Mpnt == (MAILER *) NULL) {
  974.         printf("Null MAILER pointer\n");
  975.         return;
  976.     }
  977.     printf("m_name (symbolic name) %s\n",
  978.         (Mpnt->m_name == (char *)NULL) ? "NULL" : Mpnt->m_name);
  979.     printf("m_mailer (pathname) %s\n",
  980.         (Mpnt->m_mailer == (char *)NULL) ? "NULL" : Mpnt->m_mailer);
  981.     printf("m_flags BITMAP:    ");
  982.     for (i = 0; i < (BITMAPBYTES / sizeof (int)); i++)
  983.         printf("  %X", Mpnt->m_flags[i]);
  984.     printf("\n");
  985.     printf("m_mno (internal mailer number) %d\n", (int) Mpnt->m_mno);
  986.     printf("m_argv (template argument vector):  ");
  987.     for (j = Mpnt->m_argv; *j != (char *) NULL; j++)
  988.         printf(" \"%s\"", *j);
  989.     printf("\n");
  990.     printf("m_se_rwset (rewriting ruleset for envelope senders): %d\n",
  991.         (int) Mpnt->m_se_rwset);
  992.     printf("m_sh_rwset (rewriting ruleset for header senders): %d\n",
  993.         (int) Mpnt->m_sh_rwset);
  994.     printf("m_re_rwset (rewriting ruleset for envelope recipients): %d\n",
  995.         (int) Mpnt->m_re_rwset);
  996.     printf("m_rh_rwset (rewriting ruleset for header recipient): %d\n",
  997.         (int) Mpnt->m_rh_rwset);
  998.     printf("m_eol (end of line string) %s\n",
  999.         (Mpnt->m_eol == (char *)NULL) ? "NULL" : Mpnt->m_eol);
  1000.     printf("m_maxsize (size limit on message to this mailer): %D\n",
  1001.         Mpnt->m_maxsize);
  1002.     return;
  1003. @
  1004.  
  1005.  
  1006. 5.21.0.2
  1007. log
  1008. @Patches for HP-UX from Andy Linton <root@@comp.vuw.ac.nz>.  Thanks Andy!
  1009. @
  1010. text
  1011. @a340 7
  1012. #if defined(hpux)
  1013.         /*
  1014.          * We can't get an exclusive lock on a file that
  1015.          * isn't opened for writing - sigh!
  1016.          */
  1017.         if ((af = fopen(AliasFile, "r+")) == NULL)
  1018. #else
  1019. a342 1
  1020. #endif /* hpux */
  1021. @
  1022.  
  1023.  
  1024. 5.21.0.3
  1025. log
  1026. @Reported maximum alias size now includes the size of the lhs+rhs and the
  1027. name of the longest alias.  Check success of dbm_store/store call.
  1028. @
  1029. text
  1030. @a330 1
  1031.     char longest_lhs[BUFSIZ];
  1032. a534 1
  1033.             if (
  1034. d536 1
  1035. a536 1
  1036.                 dbm_store(AliasDbm, key, content, DBM_REPLACE)
  1037. d538 1
  1038. a538 1
  1039.                 store(key, content)
  1040. a539 2
  1041.                 < 0)
  1042.                 syserr("DBM store of %s (size %d) failed", al.q_user, (lhssize+rhssize));
  1043. d551 2
  1044. a552 4
  1045.         if ((rhssize + lhssize) > longest) {
  1046.             longest = rhssize + lhssize;
  1047.             (void) strcpy(longest_lhs, al.q_user);
  1048.         }
  1049. d604 2
  1050. a605 2
  1051.     message(Arpa_Info, "%d aliases, longest (%s) %d bytes, %d bytes total",
  1052.             naliases, longest_lhs, longest, bytes);
  1053. d608 2
  1054. a609 2
  1055.         syslog(LOG_INFO, "%d aliases, longest (%s) %d bytes, %d bytes total",
  1056.             naliases, longest_lhs, longest, bytes);
  1057. @
  1058.  
  1059.  
  1060. 5.21.0.4
  1061. log
  1062. @Use MAXHOSTNAMELEN from sys/param.h instead of a hardwired 64.  Provide
  1063. a default value for older systems.
  1064. @
  1065. text
  1066. @a35 6
  1067. #ifdef YP
  1068. # include <sys/param.h>
  1069. # ifndef MAXHOSTNAMELEN
  1070. #  define MAXHOSTNAMELEN    64
  1071. # endif /* !MAXHOSTNAMELEN */
  1072. #endif /* YP */
  1073. d567 1
  1074. a567 1
  1075.         char    Now[MAXHOSTNAMELEN+1];
  1076. d570 1
  1077. a570 1
  1078.         gethostname (Now, MAXHOSTNAMELEN);
  1079. @
  1080.  
  1081.  
  1082. 5.21.0.5
  1083. log
  1084. @Corrected use of mapkey() return value, changed a printf() format from %D
  1085. to %ld.
  1086. @
  1087. text
  1088. @a139 1
  1089.     char *mapkey();
  1090. d143 1
  1091. a143 1
  1092.     newname = mapkey(DB_ALIAS, name, 0, (char *)0);
  1093. d407 1
  1094. a407 1
  1095.         (void) mapinit(DB_ALIAS);
  1096. d716 1
  1097. a716 1
  1098.     printf("m_maxsize (size limit on message to this mailer): %ld\n",
  1099. @
  1100.  
  1101.  
  1102. 5.21.0.6
  1103. log
  1104. @Re-did #statement indentation.  All files to be exclusively flock()'ed are
  1105. now opened with type "r+" rather than "r".  Many platforms implement flock()
  1106. with lockf().  The latter requires that files be opened for writing to 
  1107. obtain an exclusive lock.  Added GDBM support.
  1108. @
  1109. text
  1110. @d21 7
  1111. a27 9
  1112. #include <sys/types.h>
  1113. #include <sys/stat.h>
  1114. #include <signal.h>
  1115. #include <errno.h>
  1116. #include "sendmail.h"
  1117. #include <sys/file.h>
  1118. #ifndef LOCK_EX
  1119. # include "flock.h"
  1120. #endif /* !LOCK_EX */
  1121. d29 7
  1122. a35 1
  1123. #include <pwd.h>
  1124. a42 8
  1125. #ifndef lint
  1126. # ifdef DBM
  1127. static char sccsid[] = "@@(#)alias.c    5.21 (Berkeley) 6/1/90 (with DBM)";
  1128. # else /* !DBM */
  1129. static char sccsid[] = "@@(#)alias.c    5.21 (Berkeley) 6/1/90 (without DBM)";
  1130. # endif /* DBM */
  1131. #endif /* not lint */
  1132.  
  1133. d71 3
  1134. a73 3
  1135. #if defined(DBM) && !defined(NDBM) && !defined(OTHERDBM)
  1136. extern XDATUM fetch();
  1137. #endif /* DBM && !NDBM && !OTHERDBM */
  1138. d130 1
  1139. a130 1
  1140. **        unless NDBM or OTHERDBM is defined and we're using mapkey().
  1141. d137 2
  1142. a138 2
  1143. #ifdef DBM
  1144. # if defined(NDBM) || defined(OTHERDBM)
  1145. d140 1
  1146. a140 1
  1147.     extern char *mapkey();
  1148. d144 1
  1149. a144 1
  1150.     newname = mapkey(DB_ALIAS, name, 0, (char *)NULL);
  1151. d149 1
  1152. a149 1
  1153. # else /* !NDBM && !OTHERDBM */
  1154. d151 2
  1155. a152 2
  1156.     XDATUM rhs, lhs;
  1157.     char *lowname = newstr(name);
  1158. d155 1
  1159. d164 1
  1160. a164 1
  1161.     free(lowname);
  1162. d166 2
  1163. a167 2
  1164. # endif /* NDBM || OTHERDBM */
  1165. #else /* !DBM */
  1166. d176 1
  1167. a176 1
  1168. #endif /* DBM */
  1169. d195 1
  1170. a195 1
  1171. #define DBMMODE    0644
  1172. d229 1
  1173. a229 1
  1174. #ifdef DBM
  1175. d236 1
  1176. a236 1
  1177. # if !defined(NDBM) && !defined(SDBM)
  1178. d239 1
  1179. a239 1
  1180. # endif /* !NDBM && !SDBM */
  1181. d259 1
  1182. a259 1
  1183. # ifdef YPMARK
  1184. d261 1
  1185. a261 1
  1186. # endif /* YPMARK */
  1187. d270 1
  1188. a270 1
  1189. # ifdef LOG
  1190. d273 1
  1191. a273 1
  1192. # endif /* LOG */
  1193. d277 1
  1194. a277 1
  1195. # ifdef LOG
  1196. d280 1
  1197. a280 1
  1198. # endif /* LOG */
  1199. d285 1
  1200. d293 1
  1201. a293 1
  1202. # ifdef LOG
  1203. d301 1
  1204. a301 1
  1205. # endif /* LOG */
  1206. d304 1
  1207. a304 1
  1208. #else /* !DBM */
  1209. d306 1
  1210. a306 1
  1211. #endif /* DBM */
  1212. d340 1
  1213. a340 1
  1214. #ifdef YPMARK
  1215. d348 11
  1216. a358 6
  1217. #endif /* YPMARK */
  1218.     /*
  1219.      * We can't get an exclusive lock on a file that isn't opened for
  1220.      * writing on most systems - sigh!
  1221.      */
  1222.     if ((af = fopen(AliasFile, "r+")) == NULL)
  1223. d367 1
  1224. a367 1
  1225. #ifdef DBM
  1226. d369 1
  1227. a369 2
  1228.     if (flock(fileno(af), LOCK_EX | LOCK_NB) < 0 &&
  1229.         (errno == EWOULDBLOCK || errno == EAGAIN))
  1230. d382 1
  1231. a382 1
  1232. #endif /* DBM */
  1233. d407 1
  1234. a407 1
  1235. #if defined(NDBM) || defined(OTHERDBM)
  1236. d409 1
  1237. a409 1
  1238. #else /* !NDBM && !OTHERDBM */
  1239. d411 1
  1240. a411 1
  1241. #endif /* NDBM || OTHERDBM */
  1242. d448 1
  1243. a448 1
  1244.         **    Find the first colon, and parse the address.
  1245. d534 1
  1246. a534 1
  1247. #ifdef DBM
  1248. d537 1
  1249. a537 1
  1250.             XDATUM key, content;
  1251. d544 1
  1252. a544 1
  1253. # if defined(NDBM) || defined(OTHERDBM)
  1254. d546 1
  1255. a546 1
  1256. # else /* !NDBM && !OTHERDBM */
  1257. d548 1
  1258. a548 1
  1259. # endif /* NDBM || OTHERDBM */
  1260. d553 1
  1261. a553 1
  1262. #endif /* DBM */
  1263. d568 1
  1264. a568 1
  1265. #ifdef DBM
  1266. d571 1
  1267. a571 1
  1268.         XDATUM key;
  1269. d573 1
  1270. a573 1
  1271.         XDATUM content;
  1272. d582 1
  1273. a582 1
  1274. #  if defined(NDBM) || defined(OTHERDBM)
  1275. d584 1
  1276. a584 1
  1277. #  else /* !NDBM && !OTHERDBM */
  1278. d586 1
  1279. a586 1
  1280. #  endif /* NDBM || OTHERDBM */
  1281. d592 1
  1282. a592 1
  1283. #  if defined(NDBM) || defined(OTHERDBM)
  1284. d594 1
  1285. a594 1
  1286. #  else /* !NDBM && !OTHERDBM */
  1287. d596 1
  1288. a596 1
  1289. #  endif /* NDBM || OTHERDBM */
  1290. d602 1
  1291. a602 1
  1292. # if defined(NDBM) || defined(OTHERDBM)
  1293. d604 1
  1294. a604 1
  1295. # else /* !NDBM && !OTHERDBM */
  1296. d606 1
  1297. a606 1
  1298. # endif /* NDBM || OTHERDBM */
  1299. d611 1
  1300. a611 1
  1301. #endif /* DBM */
  1302. d619 1
  1303. a619 1
  1304. #ifdef LOG
  1305. d623 1
  1306. a623 1
  1307. #endif /* LOG */
  1308. @
  1309.  
  1310.  
  1311. 5.21.0.7
  1312. log
  1313. @Moved test and include of flock.h to sendmail.h.
  1314. @
  1315. text
  1316. @d26 5
  1317. @
  1318.  
  1319.  
  1320. 5.21.0.8
  1321. log
  1322. @Added forward declaration of readaliases() for gcc.
  1323. @
  1324. text
  1325. @a193 1
  1326. void readaliases();
  1327. d322 1
  1328. a322 1
  1329. static void
  1330. @
  1331.  
  1332.  
  1333. 5.21.0.9
  1334. log
  1335. @Deleted #include <sys/types.h> as it's already included via sendmail.h from
  1336. useful.h.  #include "sendmail.h" relocated to top of #include list.
  1337. @
  1338. text
  1339. @d21 1
  1340. a21 1
  1341. #include "sendmail.h"
  1342. d25 1
  1343. @
  1344.  
  1345.  
  1346. 5.21.0.10
  1347. log
  1348. @Bulletproofing for POSIX.
  1349. @
  1350. text
  1351. @a31 3
  1352. #ifndef S_IREAD
  1353. # define    S_IREAD        _S_IREAD
  1354. #endif /* !S_IREAD */
  1355. @
  1356.  
  1357.  
  1358. 5.21.0.11
  1359. log
  1360. @declared print_mailer() static.
  1361. @
  1362. text
  1363. @a679 1
  1364. static
  1365. @
  1366.  
  1367.  
  1368. 5.21.0.12
  1369. log
  1370. @ANSIfied.
  1371. @
  1372. text
  1373. @a43 8
  1374. #ifdef __STDC__
  1375. static void print_mailer(MAILER *);
  1376. static void readaliases(int);
  1377. #else /* !__STDC__ */
  1378. static void print_mailer();
  1379. static void readaliases();
  1380. #endif /* __STDC__ */
  1381.  
  1382. a75 1
  1383. void
  1384. d81 1
  1385. d141 1
  1386. d196 1
  1387. a197 1
  1388. void
  1389. d244 1
  1390. a244 1
  1391.             Xsleep(30);
  1392. d295 3
  1393. d300 1
  1394. a640 1
  1395. void
  1396. d646 1
  1397. d680 1
  1398. a680 1
  1399. static void
  1400. @
  1401.  
  1402.  
  1403. 5.21.0.13
  1404. log
  1405. @Include <sys/signal.h>, not <signal.h>.
  1406. @
  1407. text
  1408. @d23 1
  1409. a23 1
  1410. #include <sys/signal.h>
  1411. @
  1412.  
  1413.  
  1414. 5.21.0.14
  1415. log
  1416. @Added RCS ID string
  1417. @
  1418. text
  1419. @a38 1
  1420. static char rcsid[] = "@@(#)$Id$ (with DBM)";
  1421. a40 1
  1422. static char rcsid[] = "@@(#)$Id$ (without DBM)";
  1423. @
  1424.  
  1425.  
  1426. 5.21.0.15
  1427. log
  1428. @Minor presentation cleanup.
  1429. @
  1430. text
  1431. @d38 2
  1432. a39 2
  1433. static char sccsid[] = "@@(#)alias.c    5.21 (Berkeley) 6/1/90 (with DBM)    %I% local";
  1434. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.14 1991/04/05 14:55:15 paul Exp paul $ (with DBM)";
  1435. d41 2
  1436. a42 2
  1437. static char sccsid[] = "@@(#)alias.c    5.21 (Berkeley) 6/1/90 (without DBM)    %I% local";
  1438. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.14 1991/04/05 14:55:15 paul Exp paul $ (without DBM)";
  1439. d346 1
  1440. a346 2
  1441.     if (AliasFile[0] == YPMARK)
  1442.     {
  1443. d519 1
  1444. a519 2
  1445.             if (tTd(27, 3))
  1446.             {
  1447. d563 1
  1448. a563 2
  1449.         if ((rhssize + lhssize) > longest)
  1450.         {
  1451. d692 1
  1452. a692 2
  1453.     if (Mpnt == (MAILER *) NULL)
  1454.     {
  1455. @
  1456.  
  1457.  
  1458. 5.21.0.16
  1459. log
  1460. @Further changes for Interactive Systems UNIX adapted from patches
  1461. sent by Andy Linton <Andy.Linton@@comp.vuw.ac.nz>.
  1462. @
  1463. text
  1464. @d23 1
  1465. a24 3
  1466. #ifdef ISC
  1467. # include <net/errno.h>
  1468. #endif /* ISC */
  1469. d39 1
  1470. a39 1
  1471. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.15 1991/05/18 03:39:58 paul Exp paul $ (with DBM)";
  1472. d42 1
  1473. a42 1
  1474. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.15 1991/05/18 03:39:58 paul Exp paul $ (without DBM)";
  1475. a422 1
  1476.     *longest_lhs = '\0';
  1477. @
  1478.  
  1479.  
  1480. 5.21.0.17
  1481. log
  1482. @News sccsid mesg.
  1483. @
  1484. text
  1485. @d41 1
  1486. a41 1
  1487. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.16 1991/05/23 21:16:31 paul Exp $ (with DBM)";
  1488. d44 1
  1489. a44 1
  1490. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.16 1991/05/23 21:16:31 paul Exp $ (without DBM)";
  1491. d523 1
  1492. @
  1493.  
  1494.  
  1495. 5.21.0.18
  1496. log
  1497. @Fix handling of multi-line .forward files.  From Eric Wassenaar
  1498. (e07@@nikhefh.nikhef.nl)>
  1499. @
  1500. text
  1501. @d41 1
  1502. a41 1
  1503. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.17 1991/05/29 05:11:52 paul Exp paul $ (with DBM)";
  1504. d44 1
  1505. a44 1
  1506. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.17 1991/05/29 05:11:52 paul Exp paul $ (without DBM)";
  1507. a126 2
  1508.     if (!bitset(QSELFREF, a->q_flags))
  1509.         a->q_flags |= QDONTSEND;
  1510. @
  1511.  
  1512.  
  1513. 5.21.0.19
  1514. log
  1515. @Date:    Sat, 8 Jun 1991 10:27:47 -0400
  1516. From:    bruce%balilly@@broadcast.sony.com (Bruce Lilly)
  1517. Subject: case sensitive/insensitive database lookups
  1518.  
  1519. Files affected: alias.c, daemon.c
  1520.  
  1521. Allow case-sensitive (as well as -insensitive) database lookup.  Needed
  1522. because (a) user names in the aliases file, used as a dbm key, may be stored
  1523. with upper-case letters preserved (if mailerflag 'u' is specified for the
  1524. local mailer), making it impossible to retrieve aliases for these users without
  1525. the change (see loweraddr() in parseaddr.c), and (b) at most it requires one
  1526. additional dbm access per lookup, and only if keys supplied have upper-case
  1527. letters, so it is inexpensive.  Code is included for lookup of keys that may
  1528. or may not be NULL-terminated.
  1529. @
  1530. text
  1531. @d41 1
  1532. a41 1
  1533. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.18 1991/06/05 02:20:56 paul Exp paul $ (with DBM)";
  1534. d44 1
  1535. a44 1
  1536. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.18 1991/06/05 02:20:56 paul Exp paul $ (without DBM)";
  1537. d170 2
  1538. a171 1
  1539.     lhs.dsize = strlen(name);
  1540. d173 1
  1541. a173 4
  1542.         printf("aliaslookup(\"%s\") => ", name);
  1543.  
  1544.     /* first try key as given */
  1545.     lhs.dptr = name;
  1546. d175 2
  1547. a176 19
  1548.     if (rhs.dptr == (char *)NULL)
  1549.     {
  1550.         /* try null-terminated version */
  1551.         lhs.dsize += 1;
  1552.         rhs = fetch(lhs);
  1553.         lhs.dsize -= 1;
  1554.         if (rhs.dptr == (char *)NULL)
  1555.         {
  1556.             /* try lower-case version */
  1557.             lhs.dptr = lowname;
  1558.             rhs = fetch(lhs);
  1559.             if (rhs.dptr == (char *)NULL)
  1560.             {
  1561.                 /* try null-terminated lower-case version */
  1562.                 lhs.dsize += 1;
  1563.                 rhs = fetch(lhs);
  1564.             }
  1565.         }
  1566.     }
  1567. a177 3
  1568.     if (tTd(27, 3))
  1569.         (rhs.dptr) ? printf("%.*s\n", rhs.dsize, rhs.dptr)
  1570.                : printf("NOT_FOUND\n");
  1571. @
  1572.  
  1573.  
  1574. 5.21.0.20
  1575. log
  1576. @Further changes to support NO_PADDING.
  1577. @
  1578. text
  1579. @d41 1
  1580. a41 1
  1581. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.19 1991/06/13 17:16:44 paul Exp paul $ (with DBM)";
  1582. d44 1
  1583. a44 1
  1584. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.19 1991/06/13 17:16:44 paul Exp paul $ (without DBM)";
  1585. d560 2
  1586. a561 6
  1587.         lhssize = strlen(al.q_user);
  1588.         rhssize = strlen(rhs);
  1589. #ifndef NO_PADDING
  1590.         lhssize++;
  1591.         rhssize++;
  1592. #endif /* !NO_PADDING */
  1593. @
  1594.  
  1595.  
  1596. 5.21.0.21
  1597. log
  1598. @Changed occurences of time_t to TIME_TYPE.
  1599. @
  1600. text
  1601. @d40 2
  1602. a41 2
  1603. static char sccsid[] = "@@(#)alias.c    5.21 (Berkeley) 6/1/90 (with DBM)";
  1604. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.20 1991/06/13 19:53:29 paul Exp paul $ (with DBM)";
  1605. d43 2
  1606. a44 2
  1607. static char sccsid[] = "@@(#)alias.c    5.21 (Berkeley) 6/1/90 (without DBM)";
  1608. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.20 1991/06/13 19:53:29 paul Exp paul $ (without DBM)";
  1609. a84 3
  1610. # ifdef __STDC__
  1611. extern XDATUM fetch(XDATUM);
  1612. # else /* !__STDC__ */
  1613. a85 1
  1614. # endif /* __STDC__ */
  1615. d238 1
  1616. a238 1
  1617.     TIME_TYPE modtime;
  1618. @
  1619.  
  1620.  
  1621. 5.21.0.22
  1622. log
  1623. @Don't carry over QSELFREF when handling .forward files.
  1624. @
  1625. text
  1626. @d41 1
  1627. a41 1
  1628. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.21 1991/06/21 12:16:37 paul Exp paul $ (with DBM)";
  1629. d44 1
  1630. a44 1
  1631. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.21 1991/06/21 12:16:37 paul Exp paul $ (without DBM)";
  1632. d704 1
  1633. a704 5
  1634.     /*
  1635.      * we do have an address to forward to -- do it but
  1636.      * don't carry over selfref from alias.
  1637.      */
  1638.     user->q_flags &= ~QSELFREF;
  1639. @
  1640.  
  1641.  
  1642. 5.21.0.23
  1643. log
  1644. @From: e07@@nikhefh.nikhef.nl (Eric Wassenaar)
  1645. Date: 22 Jul 91 14:40:21 GMT
  1646. Newsgroup: comp.mail.sendmail
  1647. Subject: Re: sendmail-5.65c+IDA-1.4.4 - Double delivery problem
  1648.  
  1649. This is a slight amendment to the patch of Neil Rickert.
  1650. It involves no functional change, only a simple change of
  1651. the place where the QSELFREF flag is reset.
  1652. Blame me for having overlooked this one in the original patch.
  1653.  
  1654. The memory of self-reference is needed only within the scope
  1655. of the routines alias() and include(). It is therefore best
  1656. to reset the QSELFREF bit in the beginning of those routines
  1657. itself to make calls to them independent.
  1658.  
  1659. As already has been pointed out, it must not be done within
  1660. sendtolist() since that would nullify the effect for which
  1661. this flag was introduced. (The flag should be carried over
  1662. across the multiple calls of sendtolist() in the loop in
  1663. the include() routine.)
  1664.  
  1665. Eric Wassenaar
  1666. --
  1667. Organization: NIKHEF-H, National Institute for Nuclear and High-Energy Physics
  1668. Address: Kruislaan 409, P.O. Box 41882, 1009 DB Amsterdam, the Netherlands
  1669. Phone: +31 20 592 0412, Home: +31 20 6909449, Telefax: +31 20 592 5155
  1670. Internet: e07@@nikhef.nl
  1671. @
  1672. text
  1673. @d41 1
  1674. a41 1
  1675. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.22 1991/07/11 05:34:08 paul Exp paul $ (with DBM)";
  1676. d44 1
  1677. a44 1
  1678. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.22 1991/07/11 05:34:08 paul Exp paul $ (without DBM)";
  1679. a127 3
  1680.  
  1681.     /* sendtolist() will detect a possible self-reference for this alias */
  1682.     a->q_flags &= ~QSELFREF;
  1683. @
  1684.  
  1685.  
  1686. 5.21.0.24
  1687. log
  1688. @A wrapper around dbminit() of the alias file used SDBM instead of OTHERDBM.
  1689. @
  1690. text
  1691. @d41 1
  1692. a41 1
  1693. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.23 1991/08/08 22:13:25 paul Exp paul $ (with DBM)";
  1694. d44 1
  1695. a44 1
  1696. static char rcsid[] = "@@(#)$Id: alias.c,v 5.21.0.23 1991/08/08 22:13:25 paul Exp paul $ (without DBM)";
  1697. d279 1
  1698. a279 1
  1699. # if !defined(NDBM) && !defined(OTHERDBM)
  1700. d282 1
  1701. a282 1
  1702. # endif /* !NDBM && !OTHERDBM */
  1703. @
  1704.