Date: Saturday, May 21, 2016 @ 23:58:54
  Author: bisson
Revision: 268470

implement FS#49421

Added:
  libmilter/trunk/fd-passing-libmilter.patch
Modified:
  libmilter/trunk/PKGBUILD

----------------------------+
 PKGBUILD                   |    9 +++-
 fd-passing-libmilter.patch |   80 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+), 3 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2016-05-21 17:25:55 UTC (rev 268469)
+++ PKGBUILD    2016-05-21 21:58:54 UTC (rev 268470)
@@ -6,17 +6,20 @@
 pkgname=libmilter
 _pkgname=sendmail
 pkgver=8.15.1
-pkgrel=1
+pkgrel=2
 pkgdesc='Implementation of the sendmail Mail Filter API'
 url='https://www.milter.org/developers/api/'
 arch=('i686' 'x86_64')
 options=('staticlibs')
 license=('custom:Sendmail open source license')
-source=("ftp://ftp.sendmail.org/pub/${_pkgname}/${_pkgname}.${pkgver}.tar.gz";)
-sha1sums=('ab5a2e80927c52c3621240d6bc424fb4b4d65f99')
+source=("ftp://ftp.sendmail.org/pub/${_pkgname}/${_pkgname}.${pkgver}.tar.gz";
+        'fd-passing-libmilter.patch')
+sha1sums=('ab5a2e80927c52c3621240d6bc424fb4b4d65f99'
+          '9d9ed55077dffd17aee2376fbce57ef77c0139c0')
 
 prepare() {
        cd "${srcdir}/${_pkgname}-${pkgver}"
+       patch -p1 -i ../fd-passing-libmilter.patch # FS#49421
 
        # From 
http://www.j-chkmail.org/wiki/doku.php/doc/installation/start#libmilter
        cat >> devtools/Site/site.config.m4 <<EOF

Added: fd-passing-libmilter.patch
===================================================================
--- fd-passing-libmilter.patch                          (rev 0)
+++ fd-passing-libmilter.patch  2016-05-21 21:58:54 UTC (rev 268470)
@@ -0,0 +1,80 @@
+Description: systemd-like socket activation support for libmilter
+Author: Mikhail Gusarov <dotted...@debian.org
+diff --git a/libmilter/docs/smfi_setconn.html 
b/libmilter/docs/smfi_setconn.html
+index 70a510e..013f04e 100644
+--- a/libmilter/docs/smfi_setconn.html
++++ b/libmilter/docs/smfi_setconn.html
+@@ -43,6 +43,7 @@ Set the socket through which this filter should communicate 
with sendmail.
+       <LI><CODE>{unix|local}:/path/to/file</CODE> -- A named pipe.
+       <LI><CODE>inet:port@{hostname|ip-address}</CODE> -- An IPV4 socket.
+       <LI><CODE>inet6:port@{hostname|ip-address}</CODE> -- An IPV6 socket.
++      <LI><CODE>fd:number</CODE> -- Pre-opened file descriptor.
+       </UL>
+       </TD></TR>
+     </TABLE>
+diff --git a/libmilter/listener.c b/libmilter/listener.c
+index 48c552f..2249a1f 100644
+--- a/libmilter/listener.c
++++ b/libmilter/listener.c
+@@ -197,6 +197,11 @@ mi_milteropen(conn, backlog, rmsocket, name)
+                       L_socksize = sizeof addr.sin6;
+               }
+ #endif /* NETINET6 */
++              else if (strcasecmp(p, "fd") == 0)
++              {
++                      addr.sa.sa_family = AF_UNSPEC;
++                      L_socksize = sizeof (_SOCK_ADDR);
++              }
+               else
+               {
+                       smi_log(SMI_LOG_ERR, "%s: unknown socket type %s",
+@@ -443,7 +448,21 @@ mi_milteropen(conn, backlog, rmsocket, name)
+       }
+ #endif /* NETINET || NETINET6 */
+ 
+-      sock = socket(addr.sa.sa_family, SOCK_STREAM, 0);
++      if (addr.sa.sa_family == AF_UNSPEC)
++      {
++              char *end;
++              sock = strtol(colon, &end, 10);
++              if (*end != '\0' || sock < 0)
++              {
++                      smi_log(SMI_LOG_ERR, "%s: expected positive integer as 
fd, got %s", name, colon);
++                      return INVALID_SOCKET;
++              }
++      }
++      else
++      {
++              sock = socket(addr.sa.sa_family, SOCK_STREAM, 0);
++      }
++
+       if (!ValidSocket(sock))
+       {
+               smi_log(SMI_LOG_ERR,
+@@ -466,6 +485,7 @@ mi_milteropen(conn, backlog, rmsocket, name)
+ #if NETUNIX
+           addr.sa.sa_family != AF_UNIX &&
+ #endif /* NETUNIX */
++          addr.sa.sa_family != AF_UNSPEC &&
+           setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &sockopt,
+                      sizeof(sockopt)) == -1)
+       {
+@@ -511,7 +531,8 @@ mi_milteropen(conn, backlog, rmsocket, name)
+       }
+ #endif /* NETUNIX */
+ 
+-      if (bind(sock, &addr.sa, L_socksize) < 0)
++      if (addr.sa.sa_family != AF_UNSPEC &&
++          bind(sock, &addr.sa, L_socksize) < 0)
+       {
+               smi_log(SMI_LOG_ERR,
+                       "%s: Unable to bind to port %s: %s",
+@@ -817,7 +838,7 @@ mi_listener(conn, dbg, smfi, timeout, backlog)
+ # ifdef BSD4_4_SOCKADDR
+                    cliaddr.sa.sa_len == 0 ||
+ # endif /* BSD4_4_SOCKADDR */
+-                   cliaddr.sa.sa_family != L_family))
++                   (L_family != AF_UNSPEC && cliaddr.sa.sa_family != 
L_family)))
+               {
+                       (void) closesocket(connfd);
+                       connfd = INVALID_SOCKET;

Reply via email to