more updates for DSN
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 23 Mar 1995 10:09:25 +0000 (02:09 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Thu, 23 Mar 1995 10:09:25 +0000 (02:09 -0800)
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 8.59
SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 8.60

usr/src/usr.sbin/sendmail/src/savemail.c
usr/src/usr.sbin/sendmail/src/srvrsmtp.c

index 29acfa9..7fb213a 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)savemail.c 8.58 (Berkeley) %G%";
+static char sccsid[] = "@(#)savemail.c 8.59 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -755,7 +755,8 @@ errbody(mci, e, separator)
                p = e->e_parent->e_from.q_mailer->m_mtatype;
                if (p == NULL)
                        p = "dns";
                p = e->e_parent->e_from.q_mailer->m_mtatype;
                if (p == NULL)
                        p = "dns";
-               (void) sprintf(buf, "Reporting-MTA: %s; %s", p, MyHostName);
+               (void) sprintf(buf, "Reporting-MTA: %s; %s", p,
+                       xtextify(MyHostName));
                putline(buf, mci);
 
                /* Received-From-MTA: shows where we got this message from */
                putline(buf, mci);
 
                /* Received-From-MTA: shows where we got this message from */
@@ -766,7 +767,7 @@ errbody(mci, e, separator)
                        if (p == NULL)
                                p = "dns";
                        (void) sprintf(buf, "Received-From-MTA: %s; %s",
                        if (p == NULL)
                                p = "dns";
                        (void) sprintf(buf, "Received-From-MTA: %s; %s",
-                               p, RealHostName);
+                               p, xtextify(RealHostName));
                        putline(buf, mci);
                }
 
                        putline(buf, mci);
                }
 
@@ -802,11 +803,16 @@ errbody(mci, e, separator)
                        for (r = q; r->q_alias != NULL; r = r->q_alias)
                                continue;
                        if (strchr(r->q_user, '@') == NULL)
                        for (r = q; r->q_alias != NULL; r = r->q_alias)
                                continue;
                        if (strchr(r->q_user, '@') == NULL)
-                               (void) sprintf(buf, "Final-Recipient: %s; %s@%s",
-                                       p, xtextify(r->q_user), MyHostName);
+                       {
+                               (void) sprintf(buf, "Final-Recipient: %s; %s@",
+                                       p, xtextify(r->q_user));
+                               strcat(buf, xtextify(MyHostName));
+                       }
                        else
                        else
+                       {
                                (void) sprintf(buf, "Final-Recipient: %s; %s",
                                        p, xtextify(r->q_user));
                                (void) sprintf(buf, "Final-Recipient: %s; %s",
                                        p, xtextify(r->q_user));
+                       }
                        putline(buf, mci);
 
                        /* Action: -- what happened? */
                        putline(buf, mci);
 
                        /* Action: -- what happened? */
@@ -860,7 +866,7 @@ errbody(mci, e, separator)
                                if (p == NULL)
                                        p = "smtp";
                                (void) sprintf(buf, "Diagnostic-Code: %s; %s",
                                if (p == NULL)
                                        p = "smtp";
                                (void) sprintf(buf, "Diagnostic-Code: %s; %s",
-                                       p, q->q_rstatus);
+                                       p, xtextify(q->q_rstatus));
                                putline(buf, mci);
                        }
 
                                putline(buf, mci);
                        }
 
@@ -1066,6 +1072,42 @@ xtextify(t)
        return bp;
 }
 \f/*
        return bp;
 }
 \f/*
+**  XTEXTOK -- check if a string is legal xtext
+**
+**     Xtext is used in Delivery Status Notifications.  The spec was
+**     taken from draft-ietf-notary-mime-delivery-04.txt.
+**
+**     Parameters:
+**             s -- the string to check.
+**
+**     Returns:
+**             TRUE -- if 's' is legal xtext.
+**             FALSE -- if it has any illegal characters in it.
+*/
+
+bool
+xtextok(s)
+       char *s;
+{
+       int c;
+
+       while ((c = *s++) != '\0')
+       {
+               if (c == '+')
+               {
+                       c = *s++;
+                       if (!isascii(c) || !isxdigit(c))
+                               return FALSE;
+                       c = *s++;
+                       if (!isascii(c) || !isxdigit(c))
+                               return FALSE;
+               }
+               else if (c < '!' || c > '~' || c == '\\' || c == '(')
+                       return FALSE;
+       }
+       return TRUE;
+}
+\f/*
 **  PRUNEROUTE -- prune an RFC-822 source route
 ** 
 **     Trims down a source route to the last internet-registered hop.
 **  PRUNEROUTE -- prune an RFC-822 source route
 ** 
 **     Trims down a source route to the last internet-registered hop.
index d53fb2c..aa96d68 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef SMTP
 
 #ifndef lint
 #ifdef SMTP
-static char sccsid[] = "@(#)srvrsmtp.c 8.59 (Berkeley) %G% (with SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.60 (Berkeley) %G% (with SMTP)";
 #else
 #else
-static char sccsid[] = "@(#)srvrsmtp.c 8.59 (Berkeley) %G% (without SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.60 (Berkeley) %G% (without SMTP)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -820,6 +820,16 @@ mail_esmtp_args(kp, vp, e)
                        usrerr("501 ENVID requires a value");
                        /* NOTREACHED */
                }
                        usrerr("501 ENVID requires a value");
                        /* NOTREACHED */
                }
+               if (!xtextok(vp))
+               {
+                       usrerr("501 Syntax error in ENVID parameter value");
+                       /* NOTREACHED */
+               }
+               if (e->e_envid != NULL)
+               {
+                       usrerr("501 Duplicate ENVID parameter");
+                       /* NOTREACHED */
+               }
                e->e_envid = newstr(vp);
        }
        else if (strcasecmp(kp, "ret") == 0)
                e->e_envid = newstr(vp);
        }
        else if (strcasecmp(kp, "ret") == 0)
@@ -829,6 +839,11 @@ mail_esmtp_args(kp, vp, e)
                        usrerr("501 RET requires a value");
                        /* NOTREACHED */
                }
                        usrerr("501 RET requires a value");
                        /* NOTREACHED */
                }
+               if (bitset(EF_RET_PARAM, e->e_flags))
+               {
+                       usrerr("501 Duplicate RET parameter");
+                       /* NOTREACHED */
+               }
                e->e_flags |= EF_RET_PARAM;
                if (strcasecmp(vp, "hdrs") == 0)
                        e->e_flags |= EF_NO_BODY_RETN;
                e->e_flags |= EF_RET_PARAM;
                if (strcasecmp(vp, "hdrs") == 0)
                        e->e_flags |= EF_NO_BODY_RETN;
@@ -901,6 +916,16 @@ rcpt_esmtp_args(a, kp, vp, e)
                        usrerr("501 ORCPT requires a value");
                        /* NOTREACHED */
                }
                        usrerr("501 ORCPT requires a value");
                        /* NOTREACHED */
                }
+               if (!xtextok(vp))
+               {
+                       usrerr("501 Syntax error in ORCPT parameter value");
+                       /* NOTREACHED */
+               }
+               if (a->q_orcpt != NULL)
+               {
+                       usrerr("501 Duplicate ORCPT parameter");
+                       /* NOTREACHED */
+               }
                a->q_orcpt = newstr(vp);
        }
        else
                a->q_orcpt = newstr(vp);
        }
        else