summaryrefslogtreecommitdiff
path: root/mail
diff options
context:
space:
mode:
authortaca <taca@pkgsrc.org>2012-05-14 14:04:59 +0000
committertaca <taca@pkgsrc.org>2012-05-14 14:04:59 +0000
commitf45a78c0c64008d13d5cc46f022763bde7ee2cf5 (patch)
tree099fdd5058a94cce96119dbc5d6a536e2a9c66f2 /mail
parent1628eeaf17894840cc5c7bc6aebc290daac249c3 (diff)
downloadpkgsrc-f45a78c0c64008d13d5cc46f022763bde7ee2cf5.tar.gz
Add support for net_getunixcred() to NetBSD before 5.0 which dosen't
have getpeereid(3); no LOCAL_PEEREID socket options. Bump PKGREVISION.
Diffstat (limited to 'mail')
-rw-r--r--mail/dovecot2/Makefile3
-rw-r--r--mail/dovecot2/distinfo3
-rw-r--r--mail/dovecot2/patches/patch-src_lib_network.c97
3 files changed, 101 insertions, 2 deletions
diff --git a/mail/dovecot2/Makefile b/mail/dovecot2/Makefile
index a89f6425ef9..c62ab8c3f70 100644
--- a/mail/dovecot2/Makefile
+++ b/mail/dovecot2/Makefile
@@ -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 --git a/mail/dovecot2/distinfo b/mail/dovecot2/distinfo
index e1ab1b3029e..c93a69d553e 100644
--- a/mail/dovecot2/distinfo
+++ b/mail/dovecot2/distinfo
@@ -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-ae) = 51d8cb998cc2ded8bfc767710e465b752c50e656
SHA1 (patch-af) = 6d4b339898cba762243c1ff415e0fd09e3dec750
SHA1 (patch-aj) = 9e7970d29d11c097b9588ad16611f6d0e48235c2
SHA1 (patch-ak) = ca4edaa46472a0cb609cea4d06893c7bd1312f54
+SHA1 (patch-src_lib_network.c) = 31e666492a2ce7c660e04f5e6aa57018b047940d
diff --git a/mail/dovecot2/patches/patch-src_lib_network.c b/mail/dovecot2/patches/patch-src_lib_network.c
new file mode 100644
index 00000000000..7c7751f6a96
--- /dev/null
+++ b/mail/dovecot2/patches/patch-src_lib_network.c
@@ -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;