head 1.3; access; symbols pkgsrc-2026Q1:1.3.0.114 pkgsrc-2026Q1-base:1.3 pkgsrc-2025Q4:1.3.0.112 pkgsrc-2025Q4-base:1.3 pkgsrc-2025Q3:1.3.0.110 pkgsrc-2025Q3-base:1.3 pkgsrc-2025Q2:1.3.0.108 pkgsrc-2025Q2-base:1.3 pkgsrc-2025Q1:1.3.0.106 pkgsrc-2025Q1-base:1.3 pkgsrc-2024Q4:1.3.0.104 pkgsrc-2024Q4-base:1.3 pkgsrc-2024Q3:1.3.0.102 pkgsrc-2024Q3-base:1.3 pkgsrc-2024Q2:1.3.0.100 pkgsrc-2024Q2-base:1.3 pkgsrc-2024Q1:1.3.0.98 pkgsrc-2024Q1-base:1.3 pkgsrc-2023Q4:1.3.0.96 pkgsrc-2023Q4-base:1.3 pkgsrc-2023Q3:1.3.0.94 pkgsrc-2023Q3-base:1.3 pkgsrc-2023Q2:1.3.0.92 pkgsrc-2023Q2-base:1.3 pkgsrc-2023Q1:1.3.0.90 pkgsrc-2023Q1-base:1.3 pkgsrc-2022Q4:1.3.0.88 pkgsrc-2022Q4-base:1.3 pkgsrc-2022Q3:1.3.0.86 pkgsrc-2022Q3-base:1.3 pkgsrc-2022Q2:1.3.0.84 pkgsrc-2022Q2-base:1.3 pkgsrc-2022Q1:1.3.0.82 pkgsrc-2022Q1-base:1.3 pkgsrc-2021Q4:1.3.0.80 pkgsrc-2021Q4-base:1.3 pkgsrc-2021Q3:1.3.0.78 pkgsrc-2021Q3-base:1.3 pkgsrc-2021Q2:1.3.0.76 pkgsrc-2021Q2-base:1.3 pkgsrc-2021Q1:1.3.0.74 pkgsrc-2021Q1-base:1.3 pkgsrc-2020Q4:1.3.0.72 pkgsrc-2020Q4-base:1.3 pkgsrc-2020Q3:1.3.0.70 pkgsrc-2020Q3-base:1.3 pkgsrc-2020Q2:1.3.0.66 pkgsrc-2020Q2-base:1.3 pkgsrc-2020Q1:1.3.0.46 pkgsrc-2020Q1-base:1.3 pkgsrc-2019Q4:1.3.0.68 pkgsrc-2019Q4-base:1.3 pkgsrc-2019Q3:1.3.0.64 pkgsrc-2019Q3-base:1.3 pkgsrc-2019Q2:1.3.0.62 pkgsrc-2019Q2-base:1.3 pkgsrc-2019Q1:1.3.0.60 pkgsrc-2019Q1-base:1.3 pkgsrc-2018Q4:1.3.0.58 pkgsrc-2018Q4-base:1.3 pkgsrc-2018Q3:1.3.0.56 pkgsrc-2018Q3-base:1.3 pkgsrc-2018Q2:1.3.0.54 pkgsrc-2018Q2-base:1.3 pkgsrc-2018Q1:1.3.0.52 pkgsrc-2018Q1-base:1.3 pkgsrc-2017Q4:1.3.0.50 pkgsrc-2017Q4-base:1.3 pkgsrc-2017Q3:1.3.0.48 pkgsrc-2017Q3-base:1.3 pkgsrc-2017Q2:1.3.0.44 pkgsrc-2017Q2-base:1.3 pkgsrc-2017Q1:1.3.0.42 pkgsrc-2017Q1-base:1.3 pkgsrc-2016Q4:1.3.0.40 pkgsrc-2016Q4-base:1.3 pkgsrc-2016Q3:1.3.0.38 pkgsrc-2016Q3-base:1.3 pkgsrc-2016Q2:1.3.0.36 pkgsrc-2016Q2-base:1.3 pkgsrc-2016Q1:1.3.0.34 pkgsrc-2016Q1-base:1.3 pkgsrc-2015Q4:1.3.0.32 pkgsrc-2015Q4-base:1.3 pkgsrc-2015Q3:1.3.0.30 pkgsrc-2015Q3-base:1.3 pkgsrc-2015Q2:1.3.0.28 pkgsrc-2015Q2-base:1.3 pkgsrc-2015Q1:1.3.0.26 pkgsrc-2015Q1-base:1.3 pkgsrc-2014Q4:1.3.0.24 pkgsrc-2014Q4-base:1.3 pkgsrc-2014Q3:1.3.0.22 pkgsrc-2014Q3-base:1.3 pkgsrc-2014Q2:1.3.0.20 pkgsrc-2014Q2-base:1.3 pkgsrc-2014Q1:1.3.0.18 pkgsrc-2014Q1-base:1.3 pkgsrc-2013Q4:1.3.0.16 pkgsrc-2013Q4-base:1.3 pkgsrc-2013Q3:1.3.0.14 pkgsrc-2013Q3-base:1.3 pkgsrc-2013Q2:1.3.0.12 pkgsrc-2013Q2-base:1.3 pkgsrc-2013Q1:1.3.0.10 pkgsrc-2013Q1-base:1.3 pkgsrc-2012Q4:1.3.0.8 pkgsrc-2012Q4-base:1.3 pkgsrc-2012Q3:1.3.0.6 pkgsrc-2012Q3-base:1.3 pkgsrc-2012Q2:1.3.0.4 pkgsrc-2012Q2-base:1.3 pkgsrc-2012Q1:1.3.0.2 pkgsrc-2012Q1-base:1.3 pkgsrc-2011Q4:1.2.0.24 pkgsrc-2011Q4-base:1.2 pkgsrc-2011Q3:1.2.0.22 pkgsrc-2011Q3-base:1.2 pkgsrc-2011Q2:1.2.0.20 pkgsrc-2011Q2-base:1.2 pkgsrc-2011Q1:1.2.0.18 pkgsrc-2011Q1-base:1.2 pkgsrc-2010Q4:1.2.0.16 pkgsrc-2010Q4-base:1.2 pkgsrc-2010Q3:1.2.0.14 pkgsrc-2010Q3-base:1.2 pkgsrc-2010Q2:1.2.0.12 pkgsrc-2010Q2-base:1.2 pkgsrc-2010Q1:1.2.0.10 pkgsrc-2010Q1-base:1.2 pkgsrc-2009Q4:1.2.0.8 pkgsrc-2009Q4-base:1.2 pkgsrc-2009Q3:1.2.0.6 pkgsrc-2009Q3-base:1.2 pkgsrc-2009Q2:1.2.0.4 pkgsrc-2009Q2-base:1.2 pkgsrc-2009Q1:1.2.0.2 pkgsrc-2009Q1-base:1.2 pkgsrc-2008Q4:1.1.0.32 pkgsrc-2008Q4-base:1.1 pkgsrc-2008Q3:1.1.0.30 pkgsrc-2008Q3-base:1.1 cube-native-xorg:1.1.0.28 cube-native-xorg-base:1.1 pkgsrc-2008Q2:1.1.0.26 pkgsrc-2008Q2-base:1.1 cwrapper:1.1.0.24 pkgsrc-2008Q1:1.1.0.22 pkgsrc-2008Q1-base:1.1 pkgsrc-2007Q4:1.1.0.20 pkgsrc-2007Q4-base:1.1 pkgsrc-2007Q3:1.1.0.18 pkgsrc-2007Q3-base:1.1 pkgsrc-2007Q2:1.1.0.16 pkgsrc-2007Q2-base:1.1 pkgsrc-2007Q1:1.1.0.14 pkgsrc-2007Q1-base:1.1 pkgsrc-2006Q4:1.1.0.12 pkgsrc-2006Q4-base:1.1 pkgsrc-2006Q3:1.1.0.10 pkgsrc-2006Q3-base:1.1 pkgsrc-2006Q2:1.1.0.8 pkgsrc-2006Q2-base:1.1 pkgsrc-2006Q1:1.1.0.6 pkgsrc-2006Q1-base:1.1 pkgsrc-2005Q4:1.1.0.4 pkgsrc-2005Q4-base:1.1 pkgsrc-2005Q3:1.1.0.2 pkgsrc-2005Q3-base:1.1; locks; strict; comment @# @; 1.3 date 2012.03.17.02.19.08; author wiz; state Exp; branches; next 1.2; 1.2 date 2009.03.17.13.34.06; author jmcneill; state Exp; branches; next 1.1; 1.1 date 2005.08.30.23.24.33; author jlam; state Exp; branches; next ; desc @@ 1.3 log @Fix build after G_CONST_RETURN has been deprecated. Based on PR 46210 by Francis GUDIN. @ text @$NetBSD: patch-ae,v 1.2 2009/03/17 13:34:06 jmcneill Exp $ --- libgamin/gam_api.c.orig 2007-08-27 10:21:03.000000000 +0000 +++ libgamin/gam_api.c @@@@ -7,6 +7,7 @@@@ #include #include #include +#include #include #include #include @@@@ -51,6 +52,37 @@@@ const char *FamErrlist[] = { NULL }; +#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) +#define creduid(c) (c->sc_euid) +#define credgid(c) (c->sc_egid) +#elif defined(HAVE_CMSGCRED) +#define BSDCRED struct cmsgcred +#define CRED_DATASIZE (sizeof(struct cmsgcred)) +#define credpid(c,p) (c->cmcred_pid) +#define creduid(c) (c->cmcred_euid) +#define credgid(c) (c->cmcred_groups[0]) +#endif + #ifdef GAMIN_DEBUG_API int FAMDebug(FAMConnection *fc, const char *filename, FAMRequest * fr, void *userData); @@@@ -314,12 +346,6 @@@@ gamin_check_secure_path(const char *path goto cleanup; } #endif - if (st.st_mode & (S_IRWXG|S_IRWXO)) { - gam_error(DEBUG_INFO, - "Socket %s has wrong permissions\n", - path); - goto cleanup; - } /* * Looks good though binding may fail due to an existing server */ @@@@ -379,6 +405,18 @@@@ gamin_connect_unix_socket(const char *pa } strncpy(&addr.sun_path[0], path, (sizeof(addr) - 4) - 1); #endif +#if defined(BSDCRED) && defined(LOCAL_CREDS) + /* Set the socket to receive credentials. */ + { + int on = 1; + + if (setsockopt(fd, 0, LOCAL_CREDS, &on, sizeof(on)) < 0) { + gam_error(DEBUG_INFO, + "Unable to setsockopt() LOCAL_CREDS on %d\n", fd); + return(-1); + } + } +#endif if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (retries == 0) { @@@@ -426,37 +464,35 @@@@ gamin_connect_unix_socket(const char *pa static int gamin_write_credential_byte(int fd) { - char data[2] = { 0, 0 }; - int written; -#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS) - struct { - struct cmsghdr hdr; - struct cmsgcred cred; - } cmsg; - struct iovec iov; struct msghdr msg; + 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 + + 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; - msg.msg_control = &cmsg; - msg.msg_controllen = sizeof (cmsg); - memset (&cmsg, 0, sizeof (cmsg)); - cmsg.hdr.cmsg_len = sizeof (cmsg); - cmsg.hdr.cmsg_level = SOL_SOCKET; - cmsg.hdr.cmsg_type = SCM_CREDS; +#if defined(BSDCRED) && !defined(LOCAL_CREDS) + memset(cmsgbuf, 0, sizeof(cmsgbuf)); + msg.msg_control = (void *)cmsgbuf; + msg.msg_controllen = sizeof(cmsgbuf); + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_len = CMSG_LEN(CRED_DATASIZE); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_CREDS; #endif retry: -#if defined(HAVE_CMSGCRED) && !defined(LOCAL_CREDS) written = sendmsg(fd, &msg, 0); -#else - written = write(fd, &data[0], 1); -#endif if (written < 0) { if (errno == EINTR) goto retry; @@@@ -464,7 +500,7 @@@@ retry: "Failed to write credential bytes to socket %d\n", fd); return (-1); } - if (written != 1) { + if (written != iov.iov_len) { gam_error(DEBUG_INFO, "Wrote %d credential bytes to socket %d\n", written, fd); return (-1); @@@@ -648,43 +684,26 @@@@ gamin_check_cred(GAMDataPtr conn, int fd { struct msghdr msg; struct iovec iov; - char buf; - pid_t c_pid; + pid_t c_pid, pid; uid_t c_uid, s_uid; gid_t c_gid; -#ifdef HAVE_CMSGCRED - struct { - struct cmsghdr hdr; - struct cmsgcred cred; - } cmsg; +#if defined(BSDCRED) + struct cmsghdr *cmsg; + char cmsgbuf[CMSG_SPACE(CRED_DATASIZE)]; #endif - s_uid = getuid(); - -#if defined(LOCAL_CREDS) && defined(HAVE_CMSGCRED) - /* Set the socket to receive credentials on the next message */ - { - int on = 1; - - if (setsockopt(fd, 0, LOCAL_CREDS, &on, sizeof(on)) < 0) { - gam_error(DEBUG_INFO, "Unable to set LOCAL_CREDS socket option\n"); - return(-1); - } - } -#endif - - iov.iov_base = &buf; - iov.iov_len = 1; + iov.iov_base = &pid; + iov.iov_len = sizeof(pid_t); memset(&msg, 0, sizeof(msg)); msg.msg_iov = &iov; msg.msg_iovlen = 1; -#ifdef HAVE_CMSGCRED - memset(&cmsg, 0, sizeof(cmsg)); - msg.msg_control = &cmsg; - msg.msg_controllen = sizeof(cmsg); +#if defined(BSDCRED) + memset(cmsgbuf, 0, sizeof(cmsgbuf)); + msg.msg_control = (void *)cmsgbuf; + msg.msg_controllen = sizeof(cmsgbuf); #endif retry: @@@@ -692,26 +711,33 @@@@ retry: if (errno == EINTR) goto retry; - GAM_DEBUG(DEBUG_INFO, "Failed to read credentials byte on %d\n", fd); + GAM_DEBUG(DEBUG_INFO, "Failed to read credential bytes on %d\n", fd); goto failed; } - - if (buf != '\0') { - GAM_DEBUG(DEBUG_INFO, "Credentials byte was not nul on %d\n", fd); + GAM_DEBUG(DEBUG_INFO, "Read pid %d on %d\n", pid, fd); +#if defined(BSDCRED) + 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) { + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg->cmsg_type != SCM_CREDS) { GAM_DEBUG(DEBUG_INFO, "Message from recvmsg() was not SCM_CREDS\n"); goto failed; } #endif - GAM_DEBUG(DEBUG_INFO, "read credentials byte\n"); + GAM_DEBUG(DEBUG_INFO, "read credential bytes\n"); { -#ifdef SO_PEERCRED +#if defined(SO_PEERCRED) struct ucred cr; socklen_t cr_len = sizeof(cr); @@@@ -726,23 +752,37 @@@@ retry: fd, cr_len, (int) sizeof(cr)); goto failed; } -#elif defined(HAVE_CMSGCRED) - c_pid = cmsg.cred.cmcred_pid; - 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); + c_uid = creduid(cr); + c_gid = credgid(cr); +#else GAM_DEBUG(DEBUG_INFO, "Socket credentials not supported on this OS\n"); goto failed; #endif } + s_uid = getuid(); if (s_uid != c_uid) { GAM_DEBUG(DEBUG_INFO, "Credentials check failed: s_uid %d, c_uid %d\n", (int) s_uid, (int) c_uid); goto failed; } + if (pid != c_pid) { + GAM_DEBUG(DEBUG_INFO, + "read credentials do not match: pid %d, c_pid %d\n", + (int) pid, (int) c_pid); + goto failed; + } 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) { @ 1.2 log @Fix socket credentials issue on NetBSD, and PATCHDIR typo in shared Makefile. Bump both PKGREVISIONs. @ text @d1 1 a1 1 $NetBSD$ d3 1 a3 1 --- libgamin/gam_api.c.orig 2007-08-27 06:21:03.000000000 -0400 d99 3 a101 1 + d106 1 a106 3 - iov.iov_base = &data[0]; - iov.iov_len = 1; d219 5 a227 5 + if ((msg.msg_flags & MSG_CTRUNC) != 0) { + GAM_DEBUG(DEBUG_INFO, + "Lost control message data over recvmsg()\n"); + goto failed; + } @ 1.1 log @Port gamin to NetBSD by rewriting the routines that rely on socket credentials to understand NetBSD's sockcred. Bump the PKGREVISION to 1. @ text @d3 1 a3 1 --- libgamin/gam_api.c.orig 2005-08-05 18:31:46.000000000 -0400 d13 1 a13 1 @@@@ -51,6 +52,20 @@@@ const char *FamErrlist[] = { d17 18 a34 1 +#if defined(SOCKCREDSIZE) d51 1 a51 1 @@@@ -307,12 +322,6 @@@@ gamin_check_secure_path(const char *path d64 1 a64 1 @@@@ -372,6 +381,18 @@@@ gamin_connect_unix_socket(const char *pa d83 1 a83 1 @@@@ -419,37 +440,35 @@@@ gamin_connect_unix_socket(const char *pa d99 1 a99 3 - iov.iov_base = &data[0]; - iov.iov_len = 1; d105 2 a106 1 - memset (&msg, 0, sizeof (msg)); d109 2 a110 1 + d140 1 a140 1 @@@@ -457,7 +476,7 @@@@ retry: d149 1 a149 1 @@@@ -641,43 +660,26 @@@@ gamin_check_cred(GAMDataPtr conn, int fd d164 5 a168 2 -#endif - d181 2 a182 5 +#if defined(BSDCRED) + struct cmsghdr *cmsg; + char cmsgbuf[CMSG_SPACE(CRED_DATASIZE)]; #endif d203 1 a203 1 @@@@ -685,26 +687,33 @@@@ retry: a218 5 + goto failed; + } + if ((msg.msg_flags & MSG_CTRUNC) != 0) { + GAM_DEBUG(DEBUG_INFO, + "Lost control message data over recvmsg()\n"); d223 5 d245 1 a245 1 @@@@ -719,23 +728,31 @@@@ retry: d254 6 d288 19 @