fix confusion regarding quoting with fuzzy local name matching resulting
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 19 Jul 1992 09:33:50 +0000 (01:33 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 19 Jul 1992 09:33:50 +0000 (01:33 -0800)
from 8-bit clean conversion

SCCS-vsn: usr.sbin/sendmail/src/recipient.c 5.34
SCCS-vsn: usr.sbin/sendmail/src/version.c 5.109

usr/src/usr.sbin/sendmail/src/recipient.c
usr/src/usr.sbin/sendmail/src/version.c

index 1b6dd6a..edfdfb1 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)recipient.c        5.33 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c        5.34 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <sys/types.h>
 #endif /* not lint */
 
 # include <sys/types.h>
@@ -341,6 +341,9 @@ recipient(a, sendq, e)
        */
 
   trylocaluser:
        */
 
   trylocaluser:
+       if (tTd(29, 7))
+               printf("at trylocaluser %s\n", a->q_user);
+
        if (m == LocalMailer && !bitset(QDONTSEND, a->q_flags))
        {
                if (strncmp(a->q_user, ":include:", 9) == 0)
        if (m == LocalMailer && !bitset(QDONTSEND, a->q_flags))
        {
                if (strncmp(a->q_user, ":include:", 9) == 0)
@@ -445,11 +448,12 @@ recipient(a, sendq, e)
 
        if (!bitset(QDONTSEND, a->q_flags))
        {
 
        if (!bitset(QDONTSEND, a->q_flags))
        {
+               auto bool fuzzy;
                register struct passwd *pw;
                extern struct passwd *finduser();
 
                /* warning -- finduser may trash buf */
                register struct passwd *pw;
                extern struct passwd *finduser();
 
                /* warning -- finduser may trash buf */
-               pw = finduser(buf);
+               pw = finduser(buf, &fuzzy);
                if (pw == NULL)
                {
                        a->q_flags |= QBADADDR;
                if (pw == NULL)
                {
                        a->q_flags |= QBADADDR;
@@ -459,7 +463,7 @@ recipient(a, sendq, e)
                {
                        char nbuf[MAXNAME];
 
                {
                        char nbuf[MAXNAME];
 
-                       if (strcmp(a->q_user, pw->pw_name) != 0)
+                       if (fuzzy)
                        {
                                /* name was a fuzzy match */
                                a->q_user = newstr(pw->pw_name);
                        {
                                /* name was a fuzzy match */
                                a->q_user = newstr(pw->pw_name);
@@ -500,6 +504,9 @@ recipient(a, sendq, e)
 **
 **     Parameters:
 **             name -- the name to match against.
 **
 **     Parameters:
 **             name -- the name to match against.
+**             fuzzyp -- an outarg that is set to TRUE if this entry
+**                     was found using the fuzzy matching algorithm;
+**                     set to FALSE otherwise.
 **
 **     Returns:
 **             A pointer to a pw struct.
 **
 **     Returns:
 **             A pointer to a pw struct.
@@ -510,29 +517,42 @@ recipient(a, sendq, e)
 */
 
 struct passwd *
 */
 
 struct passwd *
-finduser(name)
+finduser(name, fuzzyp)
        char *name;
        char *name;
+       bool *fuzzyp;
 {
        register struct passwd *pw;
        register char *p;
        extern struct passwd *getpwent();
        extern struct passwd *getpwnam();
 
 {
        register struct passwd *pw;
        register char *p;
        extern struct passwd *getpwent();
        extern struct passwd *getpwnam();
 
+       if (tTd(29, 4))
+               printf("finduser(%s): ", name);
+
        /* map upper => lower case */
        for (p = name; *p != '\0'; p++)
        {
                if (isascii(*p) && isupper(*p))
                        *p = tolower(*p);
        }
        /* map upper => lower case */
        for (p = name; *p != '\0'; p++)
        {
                if (isascii(*p) && isupper(*p))
                        *p = tolower(*p);
        }
+       *fuzzyp = FALSE;
 
        /* look up this login name using fast path */
        if ((pw = getpwnam(name)) != NULL)
 
        /* look up this login name using fast path */
        if ((pw = getpwnam(name)) != NULL)
+       {
+               if (tTd(29, 4))
+                       printf("found (non-fuzzy)\n");
                return (pw);
                return (pw);
+       }
 
 #ifdef MATCHGECOS
        /* see if fuzzy matching allowed */
        if (!MatchGecos)
 
 #ifdef MATCHGECOS
        /* see if fuzzy matching allowed */
        if (!MatchGecos)
+       {
+               if (tTd(29, 4))
+                       printf("not found (fuzzy disabled)\n");
                return NULL;
                return NULL;
+       }
 
        /* search for a matching full name instead */
        for (p = name; *p != '\0'; p++)
 
        /* search for a matching full name instead */
        for (p = name; *p != '\0'; p++)
@@ -548,12 +568,16 @@ finduser(name)
                fullname(pw, buf);
                if (index(buf, ' ') != NULL && !strcasecmp(buf, name))
                {
                fullname(pw, buf);
                if (index(buf, ' ') != NULL && !strcasecmp(buf, name))
                {
+                       if (tTd(29, 4))
+                               printf("fuzzy matches %s\n", pw->pw_name);
                                message(Arpa_Info, "sending to %s <%s>",
                                    buf, pw->pw_name);
                        return (pw);
                }
        }
 #endif
                                message(Arpa_Info, "sending to %s <%s>",
                                    buf, pw->pw_name);
                        return (pw);
                }
        }
 #endif
+       if (tTd(29, 4))
+               printf("no fuzzy match found\n");
        return (NULL);
 }
 \f/*
        return (NULL);
 }
 \f/*
index 0c58f6e..54a5b4a 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)version.c  5.108 (Berkeley) %G%";
+static char sccsid[] = "@(#)version.c  5.109 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-char   Version[] = "5.108";
+char   Version[] = "5.109";