pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mail/dovecot2 Add support for net_getunixcred() to Net...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5120bc0677d6
branches:  trunk
changeset: 603842:5120bc0677d6
user:      taca <taca%pkgsrc.org@localhost>
date:      Mon May 14 14:04:59 2012 +0000

description:
Add support for net_getunixcred() to NetBSD before 5.0 which dosen't
have getpeereid(3); no LOCAL_PEEREID socket options.

Bump PKGREVISION.

diffstat:

 mail/dovecot2/Makefile                        |   3 +-
 mail/dovecot2/distinfo                        |   3 +-
 mail/dovecot2/patches/patch-src_lib_network.c |  97 +++++++++++++++++++++++++++
 3 files changed, 101 insertions(+), 2 deletions(-)

diffs (127 lines):

diff -r c46ec89c924e -r 5120bc0677d6 mail/dovecot2/Makefile
--- a/mail/dovecot2/Makefile    Mon May 14 12:15:14 2012 +0000
+++ b/mail/dovecot2/Makefile    Mon May 14 14:04:59 2012 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.24 2012/05/10 13:25:37 ghen Exp $
+# $NetBSD: Makefile,v 1.25 2012/05/14 14:04:59 taca Exp $
 
 DISTNAME=      dovecot-2.1.6
+PKGREVISION=   1
 CATEGORIES=    mail
 MASTER_SITES=  http://www.dovecot.org/releases/2.1/
 
diff -r c46ec89c924e -r 5120bc0677d6 mail/dovecot2/distinfo
--- a/mail/dovecot2/distinfo    Mon May 14 12:15:14 2012 +0000
+++ b/mail/dovecot2/distinfo    Mon May 14 14:04:59 2012 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.21 2012/05/10 13:25:38 ghen Exp $
+$NetBSD: distinfo,v 1.22 2012/05/14 14:04:59 taca Exp $
 
 SHA1 (dovecot-2.1.6.tar.gz) = 88bde8a8110646ef1a5b594337a21964e5b35850
 RMD160 (dovecot-2.1.6.tar.gz) = 807ddcc41402b0ea6c8bfd33ec8df9ed1ff75d95
@@ -10,3 +10,4 @@
 SHA1 (patch-af) = 6d4b339898cba762243c1ff415e0fd09e3dec750
 SHA1 (patch-aj) = 9e7970d29d11c097b9588ad16611f6d0e48235c2
 SHA1 (patch-ak) = ca4edaa46472a0cb609cea4d06893c7bd1312f54
+SHA1 (patch-src_lib_network.c) = 31e666492a2ce7c660e04f5e6aa57018b047940d
diff -r c46ec89c924e -r 5120bc0677d6 mail/dovecot2/patches/patch-src_lib_network.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/dovecot2/patches/patch-src_lib_network.c     Mon May 14 14:04:59 2012 +0000
@@ -0,0 +1,97 @@
+$NetBSD: patch-src_lib_network.c,v 1.1 2012/05/14 14:04:59 taca Exp $
+
+* Add support for net_getunixcred() to NetBSD before 5.0 which dosen't
+  have getpeereid(3); no LOCAL_PEEREID socket options.
+
+--- src/lib/network.c.orig     2012-03-26 13:59:30.000000000 +0000
++++ src/lib/network.c
+@@ -37,6 +37,10 @@ union sockaddr_union_unix {
+ #  define SIZEOF_SOCKADDR(so) (sizeof(so.sin))
+ #endif
+ 
++#if !defined(HAVE_GETPEEREID) && !defined(SO_PEERCRED) && !defined(HAVE_GETPEERUCRED) && defined(MSG_WAITALL) && defined(LOCAL_CREDS)
++#  define NEEDS_LOCAL_CREDS 1
++#endif
++
+ bool net_ip_compare(const struct ip_addr *ip1, const struct ip_addr *ip2)
+ {
+       return net_ip_cmp(ip1, ip2) == 0;
+@@ -298,6 +302,16 @@ int net_connect_unix(const char *path)
+               return -1;
+       }
+ 
++#ifdef NEEDS_LOCAL_CREDS
++      {
++              int on = 1;
++              if (setsockopt(fd, 0, LOCAL_CREDS, &on, sizeof on)) {
++                      i_error("setsockopt(LOCAL_CREDS) failed: %m");
++                      return -1;
++              }
++      }
++#endif
++
+       return fd;
+ }
+ 
+@@ -454,6 +468,16 @@ int net_listen_unix(const char *path, in
+               return -1;
+       }
+ 
++#ifdef NEEDS_LOCAL_CREDS
++      {
++              int on = 1;
++              if (setsockopt(fd, 0, LOCAL_CREDS, &on, sizeof on)) {
++                      i_error("setsockopt(LOCAL_CREDS) failed: %m");
++                      return -1;
++              }
++      }
++#endif
++
+       /* bind */
+       if (bind(fd, &sa.sa, sizeof(sa)) < 0) {
+               if (errno != EADDRINUSE)
+@@ -731,6 +755,44 @@ int net_getunixcred(int fd, struct net_u
+               return -1;
+       }
+       return 0;
++#elif NEEDS_LOCAL_CREDS
++      /* NetBSD < 5 */
++      int i, n, on;
++      struct iovec iov;
++      struct msghdr msg;
++      struct {
++              struct cmsghdr ch;
++              char buf[110];
++      } cdata;
++      struct sockcred *sc;
++
++      iov.iov_base = (char *)&on;
++      iov.iov_len = 1;
++
++      sc = (struct sockcred *)cdata.buf;
++      sc->sc_uid = sc->sc_euid = sc->sc_gid = sc->sc_egid = -1;
++      memset(&cdata.ch, 0, sizeof cdata.ch);
++
++      memset(&msg, 0, sizeof msg);
++
++      msg.msg_iov = &iov;
++      msg.msg_iovlen = 1;
++      msg.msg_control = &cdata;
++      msg.msg_controllen = sizeof(cdata.ch) + sizeof(cdata.buf);
++
++      for (i = 0; i < 10; i++) {
++              n = recvmsg(fd, &msg, MSG_WAITALL | MSG_PEEK);
++              if (n >= 0 || errno != EAGAIN)
++                      break;
++              usleep(100);
++      }
++      if (n < 0) {
++              i_error("recvmsg() failed: %m");
++              return -1;
++      }
++      cred_r->uid = sc->sc_euid;
++      cred_r->gid = sc->sc_egid;
++      return 0;
+ #else
+       errno = EINVAL;
+       return -1;



Home | Main Index | Thread Index | Old Index