Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Jul 2014 12:10:27 +0000 (UTC)
From:      Vsevolod Stakhov <vsevolod@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r360606 - in head/mail/exim: . files
Message-ID:  <201407041210.s64CARpv022368@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vsevolod
Date: Fri Jul  4 12:10:26 2014
New Revision: 360606
URL: http://svnweb.freebsd.org/changeset/ports/360606
QAT: https://qat.redports.org/buildarchive/r360606/

Log:
  - Update extra patch for XCLIENT support:
   * now xclient is parsed by splitting, so xclient handling was rewritten;
   * support xtext decoding;
   * support of [UNAVAILABLE] and [TEMPUNAVAIL] that was broken;
   * announce xclient in ehlo reply for hosts permitted for xclient;
   * use verify_check_host as it seems to be the proper choice now.
  - Remove blank lines from pkg-plist [1]
  - Bump revision
  
  Submitted by:	bapt [1]

Modified:
  head/mail/exim/Makefile
  head/mail/exim/files/extra-patch-xclient
  head/mail/exim/pkg-plist

Modified: head/mail/exim/Makefile
==============================================================================
--- head/mail/exim/Makefile	Fri Jul  4 12:09:44 2014	(r360605)
+++ head/mail/exim/Makefile	Fri Jul  4 12:10:26 2014	(r360606)
@@ -3,7 +3,7 @@
 
 PORTNAME=	exim
 PORTVERSION?=	${EXIM_VERSION}
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	mail ipv6
 MASTER_SITES=	${MASTER_SITE_EXIM:S/$/:exim/}
 MASTER_SITE_SUBDIR=	exim4/:exim

Modified: head/mail/exim/files/extra-patch-xclient
==============================================================================
--- head/mail/exim/files/extra-patch-xclient	Fri Jul  4 12:09:44 2014	(r360605)
+++ head/mail/exim/files/extra-patch-xclient	Fri Jul  4 12:10:26 2014	(r360606)
@@ -1,6 +1,8 @@
---- src/globals.c.orig	2011-10-10 09:18:13.000000000 +0400
-+++ src/globals.c	2011-10-16 02:33:45.000000000 +0400
-@@ -633,6 +633,7 @@
+diff --git src/globals.c src/globals.c
+index 5db858b..b7c718a 100644
+--- src/globals.c
++++ src/globals.c
+@@ -691,6 +691,7 @@ uschar *helo_try_verify_hosts  = NULL;
  BOOL    helo_verified          = FALSE;
  BOOL    helo_verify_failed     = FALSE;
  uschar *helo_verify_hosts      = NULL;
@@ -8,19 +10,23 @@
  const uschar *hex_digits       = CUS"0123456789abcdef";
  uschar *hold_domains           = NULL;
  BOOL    host_checking          = FALSE;
---- src/globals.h.orig	2011-10-10 09:18:13.000000000 +0400
-+++ src/globals.h	2011-10-16 02:34:09.000000000 +0400
-@@ -398,6 +398,7 @@
+diff --git src/globals.h src/globals.h
+index 8d83be7..f35e99c 100644
+--- src/globals.h
++++ src/globals.h
+@@ -424,6 +424,7 @@ extern uschar *helo_lookup_domains;    /* If these given, lookup host name */
+ extern uschar *helo_try_verify_hosts;  /* Soft check HELO argument for these */
  extern BOOL    helo_verified;          /* True if HELO verified */
  extern BOOL    helo_verify_failed;     /* True if attempt failed */
- extern uschar *helo_verify_hosts;      /* Hard check HELO argument for these */
 +extern uschar *xclient_allow_hosts;    /* Allow XCLIENT command for specified hosts */
+ extern uschar *helo_verify_hosts;      /* Hard check HELO argument for these */
  extern const uschar *hex_digits;             /* Used in several places */
  extern uschar *hold_domains;           /* Hold up deliveries to these */
- extern BOOL    host_find_failed_syntax;/* DNS syntax check failure */
---- src/macros.h.orig	2007-08-30 18:31:06.000000000 +0400
-+++ src/macros.h	2007-12-10 17:36:29.512226916 +0300
-@@ -714,7 +714,7 @@
+diff --git src/macros.h src/macros.h
+index b878b41..eec812d 100644
+--- src/macros.h
++++ src/macros.h
+@@ -726,7 +726,7 @@ is "empty". */
  
  enum { SCH_NONE, SCH_AUTH, SCH_DATA, SCH_EHLO, SCH_ETRN, SCH_EXPN, SCH_HELO,
         SCH_HELP, SCH_MAIL, SCH_NOOP, SCH_QUIT, SCH_RCPT, SCH_RSET, SCH_STARTTLS,
@@ -29,9 +35,11 @@
  
  /* Returns from host_find_by{name,dns}() */
  
---- src/readconf.c.orig	2007-12-10 19:03:32.809885687 +0300
-+++ src/readconf.c	2007-12-10 19:13:37.344336141 +0300
-@@ -404,7 +404,8 @@
+diff --git src/readconf.c src/readconf.c
+index bba5325..a375851 100644
+--- src/readconf.c
++++ src/readconf.c
+@@ -444,7 +444,8 @@ static optionlist optionlist_config[] = {
    { "uucp_from_pattern",        opt_stringptr,   &uucp_from_pattern },
    { "uucp_from_sender",         opt_stringptr,   &uucp_from_sender },
    { "warn_message_file",        opt_stringptr,   &warn_message_file },
@@ -41,9 +49,11 @@
  };
  
  static int optionlist_config_size =
---- src/smtp_in.c.orig	2007-12-10 15:54:30.000000000 +0300
-+++ src/smtp_in.c	2009-02-03 17:29:33.181798456 +0300
-@@ -63,10 +63,10 @@
+diff --git src/smtp_in.c src/smtp_in.c
+index cb1a869..8a8b157 100644
+--- src/smtp_in.c
++++ src/smtp_in.c
+@@ -67,10 +67,10 @@ enum {
    /* These commands are required to be synchronized, i.e. to be the last in a
    block of commands when pipelining. */
  
@@ -58,7 +68,7 @@
  
    /* This is a dummy to identify the non-sync commands when pipelining */
  
-@@ -152,6 +152,7 @@
+@@ -156,6 +156,7 @@ static smtp_cmd_list cmd_list[] = {
    { "rset",       sizeof("rset")-1,       RSET_CMD, FALSE, FALSE },  /* First */
    { "helo",       sizeof("helo")-1,       HELO_CMD, TRUE,  FALSE },
    { "ehlo",       sizeof("ehlo")-1,       EHLO_CMD, TRUE,  FALSE },
@@ -66,7 +76,7 @@
    { "auth",       sizeof("auth")-1,       AUTH_CMD, TRUE,  TRUE  },
    #ifdef SUPPORT_TLS
    { "starttls",   sizeof("starttls")-1,   STARTTLS_CMD, FALSE, FALSE },
-@@ -184,7 +185,7 @@
+@@ -188,7 +189,7 @@ It must be kept in step with the SCH_xxx enumerations. */
  
  static uschar *smtp_names[] =
    {
@@ -75,14 +85,63 @@
    US"HELP", US"MAIL", US"NOOP", US"QUIT", US"RCPT", US"RSET", US"STARTTLS",
    US"VRFY" };
  
-@@ -847,6 +848,205 @@
+@@ -895,8 +896,259 @@ log_write(0, LOG_MAIN, "no MAIL in SMTP connection from %s D=%s%s",
+   readconf_printtime(time(NULL) - smtp_connection_start), s);
  }
  
- 
++/*************************************************
++*          Decode byte-string in xtext           *
++*************************************************/
++
++/* This function decodes a string in xtextformat as defined in RFC 1891 and
++required by the SMTP XCLIENT extension. We put the result in a piece of
++store of equal length - it cannot be longer than this. Although in general the
++result of decoding an xtext may be binary, in the context in which it is used
++by Exim (for decoding the value of XCLIENT command), the result is
++expected to be an addr-spec. We therefore add on a terminating zero, for
++convenience.
++
++Arguments:
++  code        points to the coded string
++  end         points to the end of coded string
++  ptr         where to put the pointer to the result, which is in
++              dynamic store
++
++Returns:      the number of bytes in the result, excluding the final zero;
++              -1 if the input is malformed
++*/
++
++int
++xclient_xtextdecode(uschar *code, uschar *end, uschar **ptr)
++{
++register int x;
++uschar *result = store_get(end - code + 1);
++*ptr = result;
++
++while (code < end)
++  {
++  x = (*code++);
++  if (x < 33 || x > 127 || x == '=') return -1;
++  if (x == '+')
++    {
++    register int y;
++    if (!isxdigit((x = (*code++)))) return -1;
++    y = ((isdigit(x))? x - '0' : (tolower(x) - 'a' + 10)) << 4;
++    if (!isxdigit((x = (*code++)))) return -1;
++    *result++ = y | ((isdigit(x))? x - '0' : (tolower(x) - 'a' + 10));
++    }
++  else *result++ = x;
++  }
++
++*result = 0;
++return result - *ptr;
++}
++
 +/*************************************************
 +*   Check XCLIENT line and set sender_address    *
 +*************************************************/
 +
++
 +/* Check the format of a XCLIENT line. 
 + * XCLIENT Command syntax
 + *
@@ -132,156 +191,161 @@
 +static BOOL
 +smtp_handle_xclient(uschar *s)
 +{
-+  uschar *p, *end, *arg;
++  uschar *p, *c, *end, *decoded_buf;
 +  int len;
++  enum {
++    XCLIENT_READ_COMMAND = 0,
++    XCLIENT_READ_VALUE,
++    XCLIENT_SKIP_SPACES
++  } state = XCLIENT_SKIP_SPACES;
++  enum {
++    XCLIENT_CMD_ADDR = 0,
++    XCLIENT_CMD_NAME,
++    XCLIENT_CMD_PORT,
++    XCLIENT_CMD_PROTO,
++    XCLIENT_CMD_LOGIN,
++    XCLIENT_CMD_HELO,
++    XCLIENT_CMD_UNKNOWN
++  } xclient_cmd = XCLIENT_CMD_UNKNOWN;
++
 +  p = s;
 +  end = s + Ustrlen(s);
 +
-+  while (p <= end) {
-+    /* Addr */
-+    if (strncmpic(p, US"ADDR=", 5) == 0) {
-+      p += 5;
-+      arg = p;
-+      while (*p++ != ' ' && p <= end );
-+      len = p - arg;
-+      /* Strip whitespace */
-+      if(*(p - 1) == ' ') {
-+        len --;
-+      }
-+      if (len > 0) {
-+        sender_host_address = string_copy_malloc(string_copyn(arg, len));
++  while (p < end) {
++    switch (state) {
++    case XCLIENT_READ_COMMAND:
++      if (*p != '=') {
++        p ++;
 +      }
 +      else {
-+        return FALSE;
-+      }
-+    }
-+    /* Name */
-+    else if (strncmpic(p, US"NAME=", 5) == 0) {
-+      p += 5;
-+      arg = p;
-+      while (*p++ != ' ' && p <= end );
-+      len = p - arg;
-+      /* Strip whitespace */
-+      if(*(p - 1) == ' ') {
-+        len --;
-+      }
-+      if (len > 0) {
-+        if ((len == sizeof(XCLIENT_UNAVAIL) - 1 && strncmpic(arg, XCLIENT_UNAVAIL, sizeof (XCLIENT_UNAVAIL) -1) == 0) ||
-+            (len == sizeof(XCLIENT_TEMPUNAVAIL) - 1 && strncmpic(arg, XCLIENT_TEMPUNAVAIL, sizeof (XCLIENT_UNAVAIL) -1) == 0)) {
-+          sender_host_name = NULL;
++        if (c == p) {
++          return FALSE;
 +        }
-+        else {
-+          sender_host_name = string_copy_malloc(string_copyn(arg, len));
++        if (p - c == 4) {
++          if (strncmpic(c, US"ADDR", 4) == 0) {
++            xclient_cmd = XCLIENT_CMD_ADDR;
++          }
++          else if (strncmpic(c, US"NAME", 4) == 0) {
++            xclient_cmd = XCLIENT_CMD_NAME;
++          }
++          else if (strncmpic(c, US"PORT", 4) == 0) {
++            xclient_cmd = XCLIENT_CMD_PORT;
++          }
++          else if (strncmpic(c, US"HELO", 4) == 0) {
++            xclient_cmd = XCLIENT_CMD_HELO;
++          }
 +        }
-+      }
-+      else {
-+        return FALSE;
-+      }
-+    }
-+    /* Helo */
-+    else if (strncmpic(p, US"HELO=", 5) == 0) {
-+      p += 5;
-+      arg = p;
-+      while (*p++ != ' ' && p <= end );
-+      len = p - arg;
-+      /* Strip whitespace */
-+      if(*(p - 1) == ' ') {
-+        len --;
-+      }
-+        
-+      if (len > 0) {
-+        if ((len == sizeof(XCLIENT_UNAVAIL) - 1 && strncmpic(arg, XCLIENT_UNAVAIL, sizeof (XCLIENT_UNAVAIL) -1) == 0) ||
-+            (len == sizeof(XCLIENT_TEMPUNAVAIL) - 1 && strncmpic(arg, XCLIENT_TEMPUNAVAIL, sizeof (XCLIENT_UNAVAIL) -1) == 0)) {
-+          sender_helo_name = NULL;
++        else if (p - c == 5) {
++          if (strncmpic(c, US"PROTO", 5) == 0) {
++            xclient_cmd = XCLIENT_CMD_PROTO;
++          }
++          else if (strncmpic(c, US"LOGIN", 5) == 0) {
++            xclient_cmd = XCLIENT_CMD_LOGIN;
++          }
 +        }
 +        else {
-+          sender_helo_name = string_copy_malloc(string_copyn(arg, len));
++          return FALSE;
 +        }
++        p ++;
++        c = p;
++        state = XCLIENT_READ_VALUE;
 +      }
-+      else {
-+        return FALSE;
-+      }
-+    }
-+    /* Port */
-+    else if (strncmpic(p, US"PORT=", 5) == 0) {
-+      p += 5;
-+      arg = p;
-+      while (*p++ != ' ' && p <= end);
-+      len = p - arg;
-+      if(*(p - 1) == ' ') {
-+        len --;
-+      }
-+      if (len > 0) {
-+        if ((len == sizeof(XCLIENT_UNAVAIL) - 1 && strncmpic(arg, XCLIENT_UNAVAIL, sizeof (XCLIENT_UNAVAIL) -1) == 0) ||
-+            (len == sizeof(XCLIENT_TEMPUNAVAIL) - 1 && strncmpic(arg, XCLIENT_TEMPUNAVAIL, sizeof (XCLIENT_UNAVAIL) -1) == 0)) {
-+          sender_host_port = 0;
++      break;
++    case XCLIENT_READ_VALUE:
++      if (isspace (*p) || p == end - 1) {
++        len = p - c;
++        if (p == end - 1) {
++          len ++;
++          p ++;
 +        }
-+        else {
-+          sender_host_port = Uatoi(arg);
++        if (len == 0) {
++          return FALSE;
 +        }
-+      }
-+      else {
-+        return FALSE;
-+      }
-+    }
-+    /* Login */
-+    else if (strncmpic(p, US"LOGIN=", 6) == 0) {
-+      p += 6;
-+      arg = p;
-+      while (*p++ != ' ' && p <= end);
-+      len = p - arg;
-+      if(*(p - 1) == ' ') {
-+        len --;
-+      }
-+      if (len > 0) {
-+        if ((len == sizeof(XCLIENT_UNAVAIL) - 1 && strncmpic(arg, XCLIENT_UNAVAIL, sizeof (XCLIENT_UNAVAIL) -1) == 0) ||
-+            (len == sizeof(XCLIENT_TEMPUNAVAIL) - 1 && strncmpic(arg, XCLIENT_TEMPUNAVAIL, sizeof (XCLIENT_UNAVAIL) -1) == 0)) {
-+          authenticated_id = NULL;
-+          sender_host_authenticated = NULL;
++        if ((len == 13 && (strncmpic(c, XCLIENT_UNAVAIL, 13) == 0) ||
++            strncmpic(c, XCLIENT_TEMPUNAVAIL, 13) == 0)) {
++          decoded_buf = NULL;
 +        }
-+        else {
-+          authenticated_id = string_copy_malloc(string_copyn(arg, len));
-+          sender_host_authenticated = "xclient";
-+          authentication_failed = FALSE;
++        else if ((len = xclient_xtextdecode(c, p, &decoded_buf)) == -1) {
++          return FALSE;
 +        }
++        switch (xclient_cmd) {
++        case XCLIENT_CMD_ADDR:
++          sender_host_address = decoded_buf ? string_copy_malloc(decoded_buf) : NULL;
++          break;
++        case XCLIENT_CMD_NAME:
++          sender_host_name = decoded_buf ? string_copy_malloc(decoded_buf) : NULL;
++          break;
++        case XCLIENT_CMD_HELO:
++          sender_helo_name = decoded_buf ? string_copy_malloc(decoded_buf) : NULL;
++          break;
++        case XCLIENT_CMD_PORT:
++          sender_host_port = decoded_buf ? Uatoi(decoded_buf) : 0;
++          break;
++        case XCLIENT_CMD_LOGIN:
++          if (decoded_buf != NULL) {
++            authenticated_id = string_copy_malloc(decoded_buf);
++            sender_host_authenticated = "xclient";
++            authentication_failed = FALSE;
++          }
++          else {
++            authenticated_id = NULL;
++            sender_host_authenticated = NULL;
++          }
++          break;
++        case XCLIENT_CMD_PROTO:
++          if (decoded_buf != NULL) {
++            if (len == 4 && strncmpic(decoded_buf, US"SMTP", 4) == 0) {
++              esmtp = FALSE;
++            }
++            else if (len == 5 && strncmpic(decoded_buf, US"ESMTP", 5) == 0) {
++              esmtp = TRUE;
++            }
++            else {
++              return FALSE;
++            }
++          }
++          else {
++            return FALSE;
++          }
++          break;
++        }
++        p ++;
++        state = XCLIENT_SKIP_SPACES;
 +      }
 +      else {
-+        return FALSE;
++        p ++;
 +      }
-+    }
-+    /* Proto */
-+    else if (strncmpic(p, US"PROTO=", 6) == 0) {
-+      p += 6;
-+      arg = p;
-+      while (*p++ != ' ' && p <= end);
-+      len = p - arg;
-+      if(*(p - 1) == ' ') {
-+        len --;
++      break;
++    case XCLIENT_SKIP_SPACES:
++      if (isspace (*p)) {
++        p ++;
 +      }
-+      if (len > 0) {
-+        if (len == 4 && (strncmpic(arg, US"SMTP", 4) == 0)) {
-+          esmtp = FALSE;
-+        }
-+        else if (len == 5 && (strncmpic(arg, US"ESMTP", 5) == 0)) {
-+          esmtp = TRUE;
-+        }
++      else {
++        c = p;
++        state = XCLIENT_READ_COMMAND;
 +      }
-+    }
-+    else {
++      break;
++    default:
 +      return FALSE;
 +    }
 +  }
+ 
+ 
++  if (state == XCLIENT_SKIP_SPACES) {
++    host_build_sender_fullhost();
++    return TRUE;
++  }
 +
-+  host_build_sender_fullhost();
-+  return TRUE;
++  return FALSE;
 +}
 +
 +#undef XCLIENT_UNAVAIL
 +#undef XCLIENT_TEMPUNAVAIL
- 
++
  /*************************************************
  *   Check HELO line and set sender_helo_name     *
-@@ -1131,6 +1331,11 @@
+ *************************************************/
+@@ -1189,6 +1441,11 @@ while (done <= 0)
      bsmtp_transaction_linecount = receive_linecount;
      break;
  
@@ -293,7 +357,20 @@
  
      /* The MAIL FROM command requires an address as an operand. All we
      do here is to parse it for syntactic correctness. The form "<>" is
-@@ -3158,7 +3363,50 @@
+@@ -3190,6 +3447,12 @@ while (done <= 0)
+         tls_advertised = TRUE;
+         }
+       #endif
++      
++      if (verify_check_host(&xclient_allow_hosts) != FAIL)
++        {
++        s = string_cat(s, &size, &ptr, smtp_code, 3);
++        s = string_cat(s, &size, &ptr, US"-XCLIENT\r\n", 10);
++        }
+ 
+       #ifdef EXPERIMENTAL_PRDR
+       /* Per Recipient Data Response, draft by Eric A. Hall extending RFC */
+@@ -3241,7 +3504,42 @@ while (done <= 0)
      toomany = FALSE;
      break;   /* HELO/EHLO */
  
@@ -315,16 +392,8 @@
 +        US"XCLIENT must have at least one operand");
 +      break;
 +      }
-+    if(xclient_allow_hosts != NULL) 
-+      {
-+        if (match_isinlist (sender_host_address, &xclient_allow_hosts, ':', NULL, NULL, MCL_NOEXPAND, FALSE, NULL) != OK) 
-+          {
-+            done = synprot_error(L_smtp_syntax_error, 550, NULL,
-+                  US"XCLIENT is not allowed");
-+            break;
-+          }
-+      }
-+    else
++
++    if(verify_check_host(&xclient_allow_hosts) == FAIL) 
 +      {
 +      done = synprot_error(L_smtp_syntax_error, 550, NULL,
 +        US"XCLIENT is not allowed");
@@ -344,3 +413,12 @@
      /* The MAIL command requires an address as an operand. All we do
      here is to parse it for syntactic correctness. The form "<>" is
      a special case which converts into an empty string. The start/end
+@@ -4139,6 +4437,8 @@ while (done <= 0)
+           verify_check_host(&tls_advertise_hosts) != FAIL)
+         Ustrcat(buffer, " STARTTLS");
+       #endif
++      if (verify_check_host(&xclient_allow_hosts) != FAIL)
++        Ustrcat(buffer, " XCLIENT");
+       Ustrcat(buffer, " HELO EHLO MAIL RCPT DATA");
+       Ustrcat(buffer, " NOOP QUIT RSET HELP");
+       if (acl_smtp_etrn != NULL) Ustrcat(buffer, " ETRN");

Modified: head/mail/exim/pkg-plist
==============================================================================
--- head/mail/exim/pkg-plist	Fri Jul  4 12:09:44 2014	(r360605)
+++ head/mail/exim/pkg-plist	Fri Jul  4 12:10:26 2014	(r360606)
@@ -46,7 +46,6 @@
 @sample %%ETCDIR%%/configure.sample
 %%SA_EXIM%%@sample %%ETCDIR%%/sa-exim.conf.sample
 @dirrmtry %%ETCDIR%%
-
 %%EXIM%%@owner %%EXIM_USER%%
 %%EXIM%%@group %%EXIM_GROUP%%
 %%EXIM%%@cwd /
@@ -55,7 +54,6 @@
 %%EXIM%%@owner root
 %%EXIM%%@group wheel
 %%EXIM%%@exec install -d -o %%EXIM_USER%% -g %%EXIM_GROUP%% /%%LOGDIR%%
-
 %%SO_1024%%@owner %%EXIM_USER%%
 %%SO_1024%%@group %%EXIM_GROUP%%
 %%SO_1024%%@cwd /



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407041210.s64CARpv022368>