diff options
author | jmcneill <jmcneill@pkgsrc.org> | 2009-03-17 13:34:06 +0000 |
---|---|---|
committer | jmcneill <jmcneill@pkgsrc.org> | 2009-03-17 13:34:06 +0000 |
commit | 38ce593bec1c4351125d7032ea293dc82df32ac3 (patch) | |
tree | 02ccc73563c4bcba987e5282baba3ed7ec839048 /sysutils | |
parent | 9dce5bb3913dcb0662742be4867183b17633dd00 (diff) | |
download | pkgsrc-38ce593bec1c4351125d7032ea293dc82df32ac3.tar.gz |
Fix socket credentials issue on NetBSD, and PATCHDIR typo in shared
Makefile. Bump both PKGREVISIONs.
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/gamin/Makefile | 4 | ||||
-rw-r--r-- | sysutils/gamin/Makefile.common | 5 | ||||
-rw-r--r-- | sysutils/gamin/distinfo | 7 | ||||
-rw-r--r-- | sysutils/gamin/patches/patch-ae | 98 | ||||
-rw-r--r-- | sysutils/gamin/patches/patch-af | 84 | ||||
-rw-r--r-- | sysutils/libgamin/Makefile | 4 |
6 files changed, 141 insertions, 61 deletions
diff --git a/sysutils/gamin/Makefile b/sysutils/gamin/Makefile index f0bb1ceca38..1ffc86cf1c3 100644 --- a/sysutils/gamin/Makefile +++ b/sysutils/gamin/Makefile @@ -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 --git a/sysutils/gamin/Makefile.common b/sysutils/gamin/Makefile.common index 2c1958acc1c..35ebc78d263 100644 --- a/sysutils/gamin/Makefile.common +++ b/sysutils/gamin/Makefile.common @@ -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+= --with-html-dir=${DOCDIR:Q} 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 @@ SUBST_SED.sysconfdir= -e "s,/etc/gamin/,${PKG_SYSCONFDIR}/," DISTINFO_FILE= ${.CURDIR}/../../sysutils/gamin/distinfo FILESDIR= ${.CURDIR}/../../sysutils/gamin/files -PATCHES= ${.CURDIR}/../../sysutils/gamin/patches +PATCHDIR= ${.CURDIR}/../../sysutils/gamin/patches diff --git a/sysutils/gamin/distinfo b/sysutils/gamin/distinfo index 893c98e87a9..e37ed5a2b9d 100644 --- a/sysutils/gamin/distinfo +++ b/sysutils/gamin/distinfo @@ -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-aa) = 0d3700cf3e1abd4dab2f6e801d31e25e352474a0 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 --git a/sysutils/gamin/patches/patch-ae b/sysutils/gamin/patches/patch-ae index 17eb6b4dc2b..a5d3852ba08 100644 --- a/sysutils/gamin/patches/patch-ae +++ b/sysutils/gamin/patches/patch-ae @@ -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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ #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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ #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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ /* * 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ + 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ - 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ - 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ #endif retry: -@@ -685,26 +687,33 @@ retry: +@@ -692,26 +711,33 @@ retry: if (errno == EINTR) goto retry; @@ -199,15 +216,15 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ + 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ - 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 @@ $NetBSD: patch-ae,v 1.1 2005/08/30 23:24:33 jlam Exp $ 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 --git a/sysutils/gamin/patches/patch-af b/sysutils/gamin/patches/patch-af index 6864e1e7071..dd0783b7117 100644 --- a/sysutils/gamin/patches/patch-af +++ b/sysutils/gamin/patches/patch-af @@ -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 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ #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 ++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 FALSE; ++ if (pid) ++ *pid = cred.unp_pid; ++ if (uid) ++ *uid = cred.unp_euid; ++ if (gid) ++ *gid = cred.unp_egid; ++ return TRUE; ++} ++#elif defined(SOCKCREDSIZE) +#define BSDCRED struct sockcred +#define CRED_DATASIZE (SOCKCREDSIZE(NGROUPS)) +#define credpid(c,p) (p) @@ -31,7 +51,7 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ /* #define CHANNEL_VERBOSE_DEBUGGING */ /************************************************************************ * * -@@ -28,37 +43,35 @@ +@@ -28,37 +61,35 @@ static gboolean gam_client_conn_send_cred(int fd) { @@ -87,7 +107,7 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ if (written < 0) { if (errno == EINTR) goto retry; -@@ -66,7 +79,7 @@ retry: +@@ -66,7 +97,7 @@ retry: "Failed to write credential bytes to socket %d\n", fd); return (-1); } @@ -96,7 +116,7 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ gam_error(DEBUG_INFO, "Wrote %d credential bytes to socket %d\n", written, fd); return (-1); -@@ -89,43 +102,26 @@ gam_client_conn_check_cred(GIOChannel * +@@ -89,43 +120,26 @@ gam_client_conn_check_cred(GIOChannel * { struct msghdr msg; struct iovec iov; @@ -111,11 +131,8 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ - struct cmsghdr hdr; - struct cmsgcred cred; - } cmsg; -+#if defined(BSDCRED) -+ struct cmsghdr *cmsg; -+ char cmsgbuf[CMSG_SPACE(CRED_DATASIZE)]; - #endif - +-#endif +- - s_uid = getuid(); - -#if defined(LOCAL_CREDS) && defined(HAVE_CMSGCRED) @@ -128,8 +145,11 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ - return FALSE; - } - } --#endif -- ++#if defined(BSDCRED) ++ struct cmsghdr *cmsg; ++ char cmsgbuf[CMSG_SPACE(CRED_DATASIZE)]; + #endif + - iov.iov_base = &buf; - iov.iov_len = 1; + iov.iov_base = &pid; @@ -150,7 +170,7 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ #endif retry: -@@ -133,26 +129,33 @@ gam_client_conn_check_cred(GIOChannel * +@@ -133,26 +147,33 @@ gam_client_conn_check_cred(GIOChannel * if (errno == EINTR) goto retry; @@ -166,15 +186,15 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ + 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, @@ -192,7 +212,7 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ struct ucred cr; socklen_t cr_len = sizeof(cr); -@@ -167,23 +170,31 @@ gam_client_conn_check_cred(GIOChannel * +@@ -167,23 +188,37 @@ gam_client_conn_check_cred(GIOChannel * fd, cr_len, (int) sizeof(cr)); goto failed; } @@ -201,6 +221,12 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ - 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) == FALSE) { ++ 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); @@ -229,7 +255,7 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ 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); -@@ -194,7 +205,7 @@ gam_client_conn_check_cred(GIOChannel * +@@ -194,7 +229,7 @@ gam_client_conn_check_cred(GIOChannel * } if (!gam_client_conn_send_cred(fd)) { @@ -238,7 +264,7 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ goto failed; } -@@ -551,12 +562,6 @@ gam_check_secure_path(const char *path) +@@ -551,12 +586,6 @@ gam_check_secure_path(const char *path) goto cleanup; } #endif @@ -251,7 +277,15 @@ $NetBSD: patch-af,v 1.1 2005/08/30 23:24:33 jlam Exp $ /* * Looks good though binding may fail due to an existing server */ -@@ -646,6 +651,18 @@ gam_listen_unix_socket(const char *path) +@@ -620,6 +649,7 @@ gam_listen_unix_socket(const char *path) + { + int fd; + struct sockaddr_un addr; ++ struct stat st; + + fd = socket(PF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { +@@ -646,6 +676,18 @@ gam_listen_unix_socket(const char *path) strncpy(&addr.sun_path[0], path, (sizeof(addr) - 4) - 1); umask(0077); #endif diff --git a/sysutils/libgamin/Makefile b/sysutils/libgamin/Makefile index b7ae34c04a6..008c2de2866 100644 --- a/sysutils/libgamin/Makefile +++ b/sysutils/libgamin/Makefile @@ -1,8 +1,10 @@ -# $NetBSD: Makefile,v 1.2 2009/03/16 13:06:46 tron Exp $ +# $NetBSD: Makefile,v 1.3 2009/03/17 13:34:06 jmcneill Exp $ .include "../../sysutils/gamin/Makefile.common" PKGNAME= ${DISTNAME:S/^gamin/lib&/} +PKGREVISION= 1 + CONFIGURE_ARGS+= --enable-libgamin post-install: |