pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/sysutils Fix socket credentials issue on NetBSD, and P...
details: https://anonhg.NetBSD.org/pkgsrc/rev/71b5dc96ce32
branches: trunk
changeset: 556161:71b5dc96ce32
user: jmcneill <jmcneill%pkgsrc.org@localhost>
date: Tue Mar 17 13:34:06 2009 +0000
description:
Fix socket credentials issue on NetBSD, and PATCHDIR typo in shared
Makefile. Bump both PKGREVISIONs.
diffstat:
sysutils/gamin/Makefile | 4 +-
sysutils/gamin/Makefile.common | 5 +-
sysutils/gamin/distinfo | 7 +-
sysutils/gamin/patches/patch-ae | 98 +++++++++++++++++++++++++++++-----------
sysutils/gamin/patches/patch-af | 84 ++++++++++++++++++++++++----------
sysutils/libgamin/Makefile | 4 +-
6 files changed, 141 insertions(+), 61 deletions(-)
diffs (truncated from 476 to 300 lines):
diff -r 8f124566c41c -r 71b5dc96ce32 sysutils/gamin/Makefile
--- a/sysutils/gamin/Makefile Tue Mar 17 12:20:00 2009 +0000
+++ b/sysutils/gamin/Makefile Tue Mar 17 13:34:06 2009 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.14 2009/03/15 21:27:47 jmcneill Exp $
+# $NetBSD: Makefile,v 1.15 2009/03/17 13:34:06 jmcneill Exp $
.include "../../sysutils/gamin/Makefile.common"
-PKGREVISION= 1
+PKGREVISION= 2
CONFIGURE_ARGS+= --enable-server
do-install:
diff -r 8f124566c41c -r 71b5dc96ce32 sysutils/gamin/Makefile.common
--- a/sysutils/gamin/Makefile.common Tue Mar 17 12:20:00 2009 +0000
+++ b/sysutils/gamin/Makefile.common Tue Mar 17 13:34:06 2009 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.common,v 1.1 2009/03/15 21:27:47 jmcneill Exp $
+# $NetBSD: Makefile.common,v 1.2 2009/03/17 13:34:06 jmcneill Exp $
#
# used by sysutils/gamin/Makefile
# used by sysutils/libgamin/Makefile
@@ -25,6 +25,7 @@
CONFIGURE_ARGS+= --without-python
CONFIGURE_ARGS+= --disable-libgamin
CONFIGURE_ARGS+= --disable-server
+CONFIGURE_ARGS+= CPPFLAGS="-D_NETBSD_SOURCE"
PKG_SYSCONFSUBDIR= gamin
DOCDIR= ${PREFIX}/share/doc/gamin
@@ -37,4 +38,4 @@
DISTINFO_FILE= ${.CURDIR}/../../sysutils/gamin/distinfo
FILESDIR= ${.CURDIR}/../../sysutils/gamin/files
-PATCHES= ${.CURDIR}/../../sysutils/gamin/patches
+PATCHDIR= ${.CURDIR}/../../sysutils/gamin/patches
diff -r 8f124566c41c -r 71b5dc96ce32 sysutils/gamin/distinfo
--- a/sysutils/gamin/distinfo Tue Mar 17 12:20:00 2009 +0000
+++ b/sysutils/gamin/distinfo Tue Mar 17 13:34:06 2009 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.5 2008/11/24 21:48:39 wiz Exp $
+$NetBSD: distinfo,v 1.6 2009/03/17 13:34:06 jmcneill Exp $
SHA1 (gamin-0.1.10.tar.gz) = f4c6b9fe87757552ef58fef4abef9e42cd3142ac
RMD160 (gamin-0.1.10.tar.gz) = fb6ba5ec2d2f49afacf10dda4095f02f5930d686
@@ -7,5 +7,6 @@
SHA1 (patch-ab) = d0f280fc8b2cbedee2d2a38cd67e8eb6aecba66d
SHA1 (patch-ac) = bc06c646288bf1f1fcf4aa73eb06da55e0620b1e
SHA1 (patch-ad) = 0ed5da772a0afbce7abf01623c9aebdd67e68537
-SHA1 (patch-ae) = 4e81484b9110c70b8776bbfb49d64971eca38cdf
-SHA1 (patch-af) = ed7ba9cfd393f3109c9028cf68e3a5909c95d414
+SHA1 (patch-ae) = 954e0d2678193e0bedab7e87b80548a3eef71b0e
+SHA1 (patch-af) = 7cda705d59206a1fad0c91b56206630f01717adc
+SHA1 (patch-ag) = 59b35394c29d0cbbf7905df24ef4ba913ebfec46
diff -r 8f124566c41c -r 71b5dc96ce32 sysutils/gamin/patches/patch-ae
--- a/sysutils/gamin/patches/patch-ae Tue Mar 17 12:20:00 2009 +0000
+++ b/sysutils/gamin/patches/patch-ae Tue Mar 17 13:34:06 2009 +0000
@@ -1,6 +1,6 @@
-$NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $
+$NetBSD: patch-ae,v 1.2 2009/03/17 13:34:06 jmcneill Exp $
---- libgamin/gam_api.c.orig 2005-08-05 18:31:46.000000000 -0400
+--- libgamin/gam_api.c.orig 2007-08-27 06:21:03.000000000 -0400
+++ libgamin/gam_api.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
@@ -10,11 +10,28 @@
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
-@@ -51,6 +52,20 @@ const char *FamErrlist[] = {
+@@ -51,6 +52,37 @@ const char *FamErrlist[] = {
NULL
};
-+#if defined(SOCKCREDSIZE)
++#if defined(LOCAL_PEEREID)
++static int
++gam_nb_getpeereid(int fd, pid_t *pid, uid_t *uid, gid_t *gid)
++{
++ struct unpcbid cred;
++ socklen_t len = sizeof(cred);
++
++ if (getsockopt(fd, 0, LOCAL_PEEREID, &cred, &len) < 0)
++ return 0;
++ if (pid)
++ *pid = cred.unp_pid;
++ if (uid)
++ *uid = cred.unp_euid;
++ if (gid)
++ *gid = cred.unp_egid;
++ return 1;
++}
++#elif defined(SOCKCREDSIZE)
+#define BSDCRED struct sockcred
+#define CRED_DATASIZE (SOCKCREDSIZE(NGROUPS))
+#define credpid(c,p) (p)
@@ -31,7 +48,7 @@
#ifdef GAMIN_DEBUG_API
int FAMDebug(FAMConnection *fc, const char *filename, FAMRequest * fr,
void *userData);
-@@ -307,12 +322,6 @@ gamin_check_secure_path(const char *path
+@@ -314,12 +346,6 @@ gamin_check_secure_path(const char *path
goto cleanup;
}
#endif
@@ -44,7 +61,7 @@
/*
* Looks good though binding may fail due to an existing server
*/
-@@ -372,6 +381,18 @@ gamin_connect_unix_socket(const char *pa
+@@ -379,6 +405,18 @@ gamin_connect_unix_socket(const char *pa
}
strncpy(&addr.sun_path[0], path, (sizeof(addr) - 4) - 1);
#endif
@@ -63,7 +80,7 @@
if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
if (retries == 0) {
-@@ -419,37 +440,35 @@ gamin_connect_unix_socket(const char *pa
+@@ -426,37 +464,35 @@ gamin_connect_unix_socket(const char *pa
static int
gamin_write_credential_byte(int fd)
{
@@ -79,18 +96,18 @@
+ struct iovec iov;
+ pid_t pid = getpid();
+ int written;
-
-- iov.iov_base = &data[0];
-- iov.iov_len = 1;
++
+#if defined(BSDCRED) && !defined(LOCAL_CREDS)
+ struct cmsghdr *cmsg;
+ char cmsgbuf[CMSG_SPACE(CRED_DATASIZE)];
+#endif
-- memset (&msg, 0, sizeof (msg));
+- iov.iov_base = &data[0];
+- iov.iov_len = 1;
+ iov.iov_base = &pid;
+ iov.iov_len = sizeof(pid_t);
-+
+
+- memset (&msg, 0, sizeof (msg));
+ memset (&msg, 0, sizeof(msg));
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
@@ -120,7 +137,7 @@
if (written < 0) {
if (errno == EINTR)
goto retry;
-@@ -457,7 +476,7 @@ retry:
+@@ -464,7 +500,7 @@ retry:
"Failed to write credential bytes to socket %d\n", fd);
return (-1);
}
@@ -129,7 +146,7 @@
gam_error(DEBUG_INFO, "Wrote %d credential bytes to socket %d\n",
written, fd);
return (-1);
-@@ -641,43 +660,26 @@ gamin_check_cred(GAMDataPtr conn, int fd
+@@ -648,43 +684,26 @@ gamin_check_cred(GAMDataPtr conn, int fd
{
struct msghdr msg;
struct iovec iov;
@@ -144,8 +161,11 @@
- struct cmsghdr hdr;
- struct cmsgcred cred;
- } cmsg;
--#endif
--
++#if defined(BSDCRED)
++ struct cmsghdr *cmsg;
++ char cmsgbuf[CMSG_SPACE(CRED_DATASIZE)];
+ #endif
+
- s_uid = getuid();
-
-#if defined(LOCAL_CREDS) && defined(HAVE_CMSGCRED)
@@ -158,11 +178,8 @@
- return(-1);
- }
- }
-+#if defined(BSDCRED)
-+ struct cmsghdr *cmsg;
-+ char cmsgbuf[CMSG_SPACE(CRED_DATASIZE)];
- #endif
-
+-#endif
+-
- iov.iov_base = &buf;
- iov.iov_len = 1;
+ iov.iov_base = &pid;
@@ -183,7 +200,7 @@
#endif
retry:
-@@ -685,26 +687,33 @@ retry:
+@@ -692,26 +711,33 @@ retry:
if (errno == EINTR)
goto retry;
@@ -199,15 +216,15 @@
+ if (msg.msg_controllen == 0) {
+ GAM_DEBUG(DEBUG_INFO,
+ "No control message received over recvmsg()\n");
-+ goto failed;
-+ }
-+ if ((msg.msg_flags & MSG_CTRUNC) != 0) {
-+ GAM_DEBUG(DEBUG_INFO,
-+ "Lost control message data over recvmsg()\n");
goto failed;
}
-#ifdef HAVE_CMSGCRED
- if (cmsg.hdr.cmsg_len < sizeof(cmsg) || cmsg.hdr.cmsg_type != SCM_CREDS) {
++ if ((msg.msg_flags & MSG_CTRUNC) != 0) {
++ GAM_DEBUG(DEBUG_INFO,
++ "Lost control message data over recvmsg()\n");
++ goto failed;
++ }
+ cmsg = CMSG_FIRSTHDR(&msg);
+ if (cmsg->cmsg_type != SCM_CREDS) {
GAM_DEBUG(DEBUG_INFO,
@@ -225,7 +242,7 @@
struct ucred cr;
socklen_t cr_len = sizeof(cr);
-@@ -719,23 +728,31 @@ retry:
+@@ -726,23 +752,37 @@ retry:
fd, cr_len, (int) sizeof(cr));
goto failed;
}
@@ -234,6 +251,12 @@
- c_uid = cmsg.cred.cmcred_euid;
- c_gid = cmsg.cred.cmcred_groups[0];
-#else /* !SO_PEERCRED && !HAVE_CMSGCRED */
++#elif defined(LOCAL_PEEREID)
++ if (gam_nb_getpeereid(fd, &c_pid, &c_uid, &c_gid) == 0) {
++ GAM_DEBUG(DEBUG_INFO,
++ "Failed to gam_nb_getpeereid() credentials on %d\n", fd);
++ goto failed;
++ }
+#elif defined(BSDCRED)
+ BSDCRED *cr = (BSDCRED *)CMSG_DATA(cmsg);
+ c_pid = credpid(cr, pid);
@@ -262,3 +285,22 @@
GAM_DEBUG(DEBUG_INFO,
"Credentials: s_uid %d, c_uid %d, c_gid %d, c_pid %d\n",
(int) s_uid, (int) c_uid, (int) c_gid, (int) c_pid);
+@@ -1288,14 +1328,16 @@ FAMNextEvent(FAMConnection * fc, FAMEven
+
+ // FIXME: drop and reacquire lock while blocked?
+ gamin_data_lock(conn);
+- if (!gamin_data_event_ready(conn)) {
++ while ((ret = gamin_data_event_ready(conn)) == 0) {
+ if (gamin_read_data(conn, fc->fd, 1) < 0) {
+ gamin_try_reconnect(conn, fc->fd);
+ FAMErrno = FAM_CONNECT;
+ return (-1);
+ }
+ }
+- ret = gamin_data_read_event(conn, fe);
++ if (ret > 0)
++ ret = gamin_data_read_event(conn, fe);
++
+ gamin_data_unlock(conn);
+
+ if (ret < 0) {
diff -r 8f124566c41c -r 71b5dc96ce32 sysutils/gamin/patches/patch-af
--- a/sysutils/gamin/patches/patch-af Tue Mar 17 12:20:00 2009 +0000
+++ b/sysutils/gamin/patches/patch-af Tue Mar 17 13:34:06 2009 +0000
@@ -1,8 +1,11 @@
-$NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $
+$NetBSD: patch-af,v 1.2 2009/03/17 13:34:06 jmcneill Exp $
---- server/gam_channel.c.orig 2005-08-09 12:17:39.000000000 -0400
+--- server/gam_channel.c.orig 2007-07-04 09:36:49.000000000 -0400
+++ server/gam_channel.c
-@@ -3,6 +3,7 @@
+@@ -1,8 +1,10 @@
+ #include "server_config.h"
++#include <string.h>
+ #include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <glib.h>
@@ -10,11 +13,28 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
-@@ -12,6 +13,20 @@
+@@ -12,6 +14,37 @@
#include "gam_channel.h"
#include "gam_protocol.h"
-+#if defined(SOCKCREDSIZE)
++#if defined(LOCAL_PEEREID)
++static gboolean
Home |
Main Index |
Thread Index |
Old Index