Import of pkgsrc-2013Q2

This commit is contained in:
2013-09-26 17:14:40 +02:00
commit 785076ae39
74991 changed files with 4380255 additions and 0 deletions

13
sysutils/gamin/DESCR Normal file
View File

@@ -0,0 +1,13 @@
Gamin is a file and directory monitoring system defined to be a subset
of the FAM (File Alteration Monitor) system.
The main goals of the project are:
1. Minimize the security model of FAM -- the daemon runs under the
user account.
2. Simplify the code base, dropping some of the most exotic features
of FAM.
3. Provide an API and ABI compatible replacement for FAM.
4. Try to fix some other issues like resource consumption.
This package provides the Gamin server.

20
sysutils/gamin/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# $NetBSD: Makefile,v 1.22 2012/09/15 10:06:23 obache Exp $
.include "../../sysutils/gamin/Makefile.common"
PKGREVISION= 6
CONFIGURE_ARGS+= --enable-server
TEST_TARGET= check
.include "options.mk"
INSTALLATION_DIRS= libexec
do-install:
${INSTALL_LIB} ${WRKSRC}/server/gam_server \
${DESTDIR}${PREFIX}/libexec
.include "../../devel/glib2/buildlink3.mk"
.include "../../sysutils/libgamin/buildlink3.mk"
.include "../../mk/bsd.pkg.mk"

View File

@@ -0,0 +1,44 @@
# $NetBSD: Makefile.common,v 1.7 2012/10/23 19:51:02 asau Exp $
#
# used by sysutils/gamin/Makefile
# used by sysutils/libgamin/Makefile
DISTNAME= gamin-0.1.10
CATEGORIES= sysutils
MASTER_SITES= http://www.gnome.org/~veillard/gamin/sources/
MAINTAINER= pkgsrc-users@NetBSD.org
HOMEPAGE= http://www.gnome.org/~veillard/gamin/
COMMENT= File alteration monitor
LICENSE= gnu-lgpl-v2
CONFLICTS= fam-[0-9]*
MAKE_JOBS_SAFE= no
USE_LIBTOOL= yes
USE_TOOLS+= pkg-config
GNU_CONFIGURE= yes
CONFIGURE_ARGS+= --disable-debug
CONFIGURE_ARGS+= --disable-debug-api
CONFIGURE_ARGS+= --disable-gtk-doc
CONFIGURE_ARGS+= --without-threads
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
SUBST_CLASSES+= sysconfdir
SUBST_MESSAGE.sysconfdir=fixing up sysconfdir
SUBST_STAGE.sysconfdir= pre-configure
SUBST_FILES.sysconfdir= doc/config.html doc/gamin.html server/gam_conf.c
SUBST_SED.sysconfdir= -e "s,/etc/gamin/,${PKG_SYSCONFDIR}/,"
DISTINFO_FILE= ${.CURDIR}/../../sysutils/gamin/distinfo
PATCHDIR= ${.CURDIR}/../../sysutils/gamin/patches
LIBS.SunOS+= -lsocket

2
sysutils/gamin/PLIST Normal file
View File

@@ -0,0 +1,2 @@
@comment $NetBSD: PLIST,v 1.2 2009/03/15 21:27:47 jmcneill Exp $
libexec/gam_server

19
sysutils/gamin/distinfo Normal file
View File

@@ -0,0 +1,19 @@
$NetBSD: distinfo,v 1.9 2012/12/25 21:02:56 joerg Exp $
SHA1 (gamin-0.1.10.tar.gz) = f4c6b9fe87757552ef58fef4abef9e42cd3142ac
RMD160 (gamin-0.1.10.tar.gz) = fb6ba5ec2d2f49afacf10dda4095f02f5930d686
Size (gamin-0.1.10.tar.gz) = 653392 bytes
SHA1 (patch-aa) = 0d3700cf3e1abd4dab2f6e801d31e25e352474a0
SHA1 (patch-ab) = d0f280fc8b2cbedee2d2a38cd67e8eb6aecba66d
SHA1 (patch-ac) = bc06c646288bf1f1fcf4aa73eb06da55e0620b1e
SHA1 (patch-ad) = 0ed5da772a0afbce7abf01623c9aebdd67e68537
SHA1 (patch-ae) = 957f1bc0690b6c41b7724c9667387b7f1e03e014
SHA1 (patch-af) = 7cda705d59206a1fad0c91b56206630f01717adc
SHA1 (patch-ag) = 59b35394c29d0cbbf7905df24ef4ba913ebfec46
SHA1 (patch-ah) = 79e132b615a6492587a10a550c421fcc91a27761
SHA1 (patch-ai) = 54c6d347eef37a97e16c6f00870953fbdba41182
SHA1 (patch-server_gam__eq.c) = 913e63d71bf3518b224a72ec415389a244f3d372
SHA1 (patch-server_gam__node.c) = 286655e55996523d4ce5ea3df0ce6f9e12cf4278
SHA1 (patch-server_gam__node.h) = 49a0d381b4900564c4f0ba7a654eb22e294c0a16
SHA1 (patch-server_gam__subscription.c) = 58f6c10e4e1e899d097662536ea31bf8a692b114
SHA1 (patch-server_gam__subscription.h) = 6347865210aa0338bc8b0a81fc671824c786fd26

11
sysutils/gamin/options.mk Normal file
View File

@@ -0,0 +1,11 @@
# $NetBSD: options.mk,v 1.1 2010/04/18 18:22:43 jmmv Exp $
PKG_OPTIONS_VAR= PKG_OPTIONS.gamin
PKG_SUPPORTED_OPTIONS= debug
.include "../../mk/bsd.options.mk"
.if !empty(PKG_OPTIONS:Mdebug)
CONFIGURE_ARGS+= --enable-debug
CONFIGURE_ARGS+= --enable-debug-api
.endif

View File

@@ -0,0 +1,12 @@
$NetBSD: patch-aa,v 1.3 2007/08/05 20:03:35 tnn Exp $
--- server/gam_poll_basic.c.orig 2007-07-04 15:46:29.000000000 +0200
+++ server/gam_poll_basic.c
@@ -38,7 +38,6 @@
#include "gam_event.h"
#include "gam_excludes.h"
-#define VERBOSE_POLL
static gboolean gam_poll_basic_add_subscription(GamSubscription * sub);
static gboolean gam_poll_basic_remove_subscription(GamSubscription * sub);

View File

@@ -0,0 +1,38 @@
$NetBSD: patch-ab,v 1.3 2007/08/05 20:03:35 tnn Exp $
--- server/gam_kqueue.c.orig 2007-07-04 15:50:41.000000000 +0200
+++ server/gam_kqueue.c
@@ -326,7 +326,7 @@ gam_kqueue_isdir (const char *pathname,
static gboolean
gam_kqueue_get_uint_sysctl (const char *name, unsigned int *value)
{
- unsigned int value_len = sizeof(*value);
+ size_t value_len = sizeof(*value);
if (sysctlbyname(name, value, &value_len, (void *)NULL, 0) < 0)
{
@@ -1135,8 +1135,10 @@ gam_kqueue_init (void)
if (! gam_kqueue_get_uint_sysctl("kern.maxfiles", &maxfiles))
return FALSE;
+#if defined(KERN_MAXFILESPERPROC)
if (! gam_kqueue_get_uint_sysctl("kern.maxfilesperproc", &maxfilesperproc))
return FALSE;
+#endif
/*
* We make sure to:
@@ -1145,9 +1147,13 @@ gam_kqueue_init (void)
*/
maxfiles *= CFG_GLOBAL_FILE_RESERVE_RATIO;
+#if defined(KERN_MAXFILESPERPROC)
maxfilesperproc = maxfilesperproc > CFG_SELF_FILE_RESERVE
? maxfilesperproc - CFG_SELF_FILE_RESERVE
: 0;
+#else
+ maxfilesperproc = maxfiles;
+#endif
max_open_files = MIN(maxfiles, maxfilesperproc);

View File

@@ -0,0 +1,13 @@
$NetBSD: patch-ac,v 1.4 2008/11/24 21:48:39 wiz Exp $
--- doc/Makefile.in.orig 2008-11-24 15:25:06.000000000 +0000
+++ doc/Makefile.in
@@ -350,7 +350,7 @@ uninstall-am:
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
-all: web $(top_srcdir)/NEWS
+all:
web: $(PAGES)

View File

@@ -0,0 +1,19 @@
$NetBSD: patch-ad,v 1.4 2007/08/05 20:16:46 tnn Exp $
--- libgamin/Makefile.in.orig 2007-07-27 16:36:40.000000000 +0200
+++ libgamin/Makefile.in
@@ -260,12 +260,12 @@ libgamin_1_la_SOURCES = \
CLEANFILES = gam_error.c gam_event.c
libgamin_1_la_LIBADD =
-libgamin_1_la_LDFLAGS = -Wl,--version-script=$(srcdir)/gamin_sym.version \
+libgamin_1_la_LDFLAGS = \
-version-info @GAMIN_VERSION_INFO@ @THREAD_LIBS@
libfam_la_SOURCES = $(libgamin_1_la_SOURCES)
libfam_la_LIBADD = $(libgamin_1_la_LIBADD)
-libfam_la_LDFLAGS = -Wl,--version-script=$(srcdir)/gamin_sym.version \
+libfam_la_LDFLAGS = \
-version-info @FAM_VERSION_INFO@ @THREAD_LIBS@
gamin_SOURCES = gamin.c

View File

@@ -0,0 +1,306 @@
$NetBSD: patch-ae,v 1.3 2012/03/17 02:19:08 wiz Exp $
--- libgamin/gam_api.c.orig 2007-08-27 10:21:03.000000000 +0000
+++ libgamin/gam_api.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include <sys/param.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
@@ -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) {

View File

@@ -0,0 +1,306 @@
$NetBSD: patch-af,v 1.2 2009/03/17 13:34:06 jmcneill Exp $
--- server/gam_channel.c.orig 2007-07-04 09:36:49.000000000 -0400
+++ server/gam_channel.c
@@ -1,8 +1,10 @@
#include "server_config.h"
+#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <glib.h>
+#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
@@ -12,6 +14,37 @@
#include "gam_channel.h"
#include "gam_protocol.h"
+#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)
+#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
+
/* #define CHANNEL_VERBOSE_DEBUGGING */
/************************************************************************
* *
@@ -28,37 +61,35 @@
static gboolean
gam_client_conn_send_cred(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;
+
+#if defined(BSDCRED) && !defined(LOCAL_CREDS)
+ struct cmsghdr *cmsg;
+ char cmsgbuf[CMSG_SPACE(CRED_DATASIZE)];
+#endif
- iov.iov_base = &data[0];
- 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;
- 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, CMSG_SPACE(CRED_DATASIZE));
+ msg.msg_control = (void *)cmsgbuf;
+ msg.msg_controllen = CMSG_LEN(CRED_DATASIZE);
+ 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;
@@ -66,7 +97,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);
@@ -89,43 +120,26 @@ gam_client_conn_check_cred(GIOChannel *
{
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;
-#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 FALSE;
- }
- }
+#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;
+ 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:
@@ -133,26 +147,33 @@ gam_client_conn_check_cred(GIOChannel *
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;
}
-#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,
"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);
@@ -167,23 +188,37 @@ gam_client_conn_check_cred(GIOChannel *
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) == 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);
+ 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);
@@ -194,7 +229,7 @@ gam_client_conn_check_cred(GIOChannel *
}
if (!gam_client_conn_send_cred(fd)) {
- GAM_DEBUG(DEBUG_INFO, "Failed to send credential byte to client\n");
+ GAM_DEBUG(DEBUG_INFO, "Failed to send credential bytes to client\n");
goto failed;
}
@@ -551,12 +586,6 @@ gam_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
*/
@@ -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
+#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 (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
GAM_DEBUG(DEBUG_INFO, "Failed to bind to socket %s\n", path);

View File

@@ -0,0 +1,139 @@
$NetBSD: patch-ag,v 1.1 2009/03/18 14:44:38 jmcneill Exp $
--- server/gam_fs.c.orig 2008-11-12 15:45:28.000000000 -0500
+++ server/gam_fs.c
@@ -10,6 +10,10 @@
#include "gam_error.h"
#include "gam_fs.h"
+#if defined(__NetBSD__)
+#include <sys/statvfs.h>
+#endif
+
#define DEFAULT_POLL_TIMEOUT 0
typedef struct _gam_fs_properties {
@@ -21,12 +25,16 @@ typedef struct _gam_fs_properties {
typedef struct _gam_fs {
char *path;
char *fsname;
+ guint64 flags;
} gam_fs;
static gboolean initialized = FALSE;
+#if defined(__NetBSD__)
+static gboolean initializing = FALSE;
+#endif
static GList *filesystems = NULL;
static GList *fs_props = NULL;
-static struct stat mtab_sbuf;
+static struct stat mtab_sbuf, hal_mtab_sbuf;
static void
gam_fs_free_filesystems (void)
@@ -110,6 +118,7 @@ gam_fs_filesystem_sort_cb (gconstpointer
return strlen(fsb->path) - strlen (fsa->path);
}
+#if defined(__linux__)
static void
gam_fs_scan_mtab (void)
{
@@ -165,10 +174,40 @@ gam_fs_scan_mtab (void)
gam_fs_free_filesystems ();
filesystems = g_list_sort (new_filesystems, gam_fs_filesystem_sort_cb);
}
+#endif
+
+#if defined(__NetBSD__)
+static void
+gam_fs_getmntinfo (void)
+{
+ struct statvfs *stat;
+ GList *new_filesystems = NULL;
+ gam_fs *fs = NULL;
+ int i, n;
+
+ n = getmntinfo(&stat, MNT_NOWAIT);
+ if (n == -1)
+ return;
+
+ for (i = 0; i < n; i++)
+ {
+ fs = g_new0 (gam_fs, 1);
+ fs->path = g_strdup (stat[i].f_mntonname);
+ fs->fsname = g_strdup (stat[i].f_fstypename);
+ fs->flags = stat[i].f_flag;
+
+ new_filesystems = g_list_prepend (new_filesystems, fs);
+ }
+
+ gam_fs_free_filesystems ();
+ filesystems = g_list_sort (new_filesystems, gam_fs_filesystem_sort_cb);
+}
+#endif
void
gam_fs_init (void)
{
+#if defined(__linux__)
if (initialized == FALSE)
{
initialized = TRUE;
@@ -199,6 +238,56 @@ gam_fs_init (void)
mtab_sbuf = sbuf;
}
+#elif defined(__NetBSD__)
+ if (initialized == FALSE && initializing == FALSE)
+ {
+ GList *iterator = NULL;
+ GHashTable *fs_hash = NULL;
+ gam_fs *fs = NULL;
+
+ initialized = initializing = TRUE;
+
+ gam_fs_getmntinfo ();
+
+ iterator = filesystems;
+ fs_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ while (iterator) {
+ fs = iterator->data;
+
+ if (!g_hash_table_lookup (fs_hash, fs->fsname)) {
+ if (fs->flags & MNT_LOCAL)
+ gam_fs_set (fs->fsname, GFS_MT_DEFAULT, 0);
+ else
+ gam_fs_set (fs->fsname, GFS_MT_POLL, 5);
+
+ g_hash_table_insert (fs_hash, g_strdup (fs->fsname), GINT_TO_POINTER (1));
+ }
+
+ iterator = g_list_next (iterator);
+ }
+
+ g_hash_table_destroy (fs_hash);
+ initializing = FALSE;
+ } else if (initializing == FALSE) {
+ struct stat sbuf;
+ gboolean need_update = FALSE;
+
+ if (stat ("/etc/fstab", &sbuf) == 0)
+ if (sbuf.st_mtime != mtab_sbuf.st_mtime) {
+ mtab_sbuf = sbuf;
+ need_update = TRUE;
+ }
+ if (stat ("/media/.hal-mtab", &sbuf) == 0)
+ if (sbuf.st_mtime != hal_mtab_sbuf.st_mtime) {
+ hal_mtab_sbuf = sbuf;
+ need_update = TRUE;
+ }
+
+ if (need_update == TRUE)
+ gam_fs_getmntinfo ();
+ }
+#endif
}
gam_fs_mon_type

View File

@@ -0,0 +1,16 @@
$NetBSD: patch-ah,v 1.1 2010/04/16 22:32:14 jmmv Exp $
The server package does not build the libgamin library because it is already
installed, so we can trick the package to build the tests.
--- configure.orig 2010-04-16 22:22:26.000000000 +0000
+++ configure
@@ -22098,7 +22098,7 @@ fi
enable_tests="no"
-if test x$enable_server = xyes && test x$enable_libgamin = xyes ; then
+if test x$enable_server = xyes ; then
pkg_failed=no
{ echo "$as_me:$LINENO: checking for TEST" >&5

View File

@@ -0,0 +1,25 @@
$NetBSD: patch-ai,v 1.1 2010/04/16 22:32:14 jmmv Exp $
Tests are only built for the server package, which does not build the libgamin
library. Link against the installed version.
--- tests/Makefile.in.orig 2008-11-24 15:25:07.000000000 +0000
+++ tests/Makefile.in
@@ -69,7 +69,7 @@ CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
-AM_CFLAGS = @AM_CFLAGS@
+AM_CFLAGS = @AM_CFLAGS@ $$(pkg-config --cflags gamin)
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
@@ -208,7 +208,7 @@ LDADD = $(top_builddir)/libgamin/libgami
testgam_SOURCES = testing.c
testgam_LDFLAGS =
testgam_DEPENDENCIES = $(DEPS)
-testgam_LDADD = $(LDADDS) -L$(top_builddir)/libgamin -lgamin-1
+testgam_LDADD = $(LDADDS) $$(pkg-config --libs gamin)
all: all-am
.SUFFIXES:

View File

@@ -0,0 +1,13 @@
$NetBSD: patch-server_gam__eq.c,v 1.1 2012/12/25 21:02:56 joerg Exp $
--- server/gam_eq.c.orig 2012-12-25 13:34:53.000000000 +0000
+++ server/gam_eq.c
@@ -124,7 +124,7 @@ gam_eq_flush (gam_eq_t *eq, GamConnDataP
{
gboolean done_work = FALSE;
if (!eq)
- return;
+ return FALSE;
#ifdef GAM_EQ_VERBOSE
GAM_DEBUG(DEBUG_INFO, "gam_eq: Flushing event queue for %s\n", gam_connection_get_pidname (conn));

View File

@@ -0,0 +1,15 @@
$NetBSD: patch-server_gam__node.c,v 1.1 2012/03/17 02:19:08 wiz Exp $
G_CONST_RETURN has been obsoleted.
--- server/gam_node.c.orig 2007-07-04 13:36:49.000000000 +0000
+++ server/gam_node.c
@@ -122,7 +122,7 @@ gam_node_set_is_dir(GamNode * node, gboo
* it has finished with the string. If it must keep it longer, it
* should makes its own copy. The returned string must not be freed.
*/
-G_CONST_RETURN char *
+const char *
gam_node_get_path(GamNode * node)
{
g_assert(node);

View File

@@ -0,0 +1,15 @@
$NetBSD: patch-server_gam__node.h,v 1.1 2012/03/17 02:19:08 wiz Exp $
G_CONST_RETURN has been obsoleted.
--- server/gam_node.h.orig 2007-07-04 13:36:49.000000000 +0000
+++ server/gam_node.h
@@ -58,7 +58,7 @@ gboolean gam_node_is_dir
void gam_node_set_is_dir (GamNode *node,
gboolean is_dir);
-G_CONST_RETURN char *gam_node_get_path (GamNode *node);
+const char *gam_node_get_path (GamNode *node);
GList *gam_node_get_subscriptions (GamNode *node);

View File

@@ -0,0 +1,15 @@
$NetBSD: patch-server_gam__subscription.c,v 1.1 2012/03/17 02:19:08 wiz Exp $
G_CONST_RETURN has been obsoleted.
--- server/gam_subscription.c.orig 2007-07-04 13:36:49.000000000 +0000
+++ server/gam_subscription.c
@@ -141,7 +141,7 @@ gam_subscription_pathlen(GamSubscription
* @param sub the GamSubscription
* @returns The path being monitored. It should not be freed.
*/
-G_CONST_RETURN char *
+const char *
gam_subscription_get_path(GamSubscription * sub)
{
if (sub == NULL)

View File

@@ -0,0 +1,15 @@
$NetBSD: patch-server_gam__subscription.h,v 1.1 2012/03/17 02:19:08 wiz Exp $
G_CONST_RETURN has been obsoleted.
--- server/gam_subscription.h.orig 2007-07-04 13:36:49.000000000 +0000
+++ server/gam_subscription.h
@@ -21,7 +21,7 @@ int gam_subscription_pa
int gam_subscription_get_reqno (GamSubscription *sub);
-G_CONST_RETURN char *gam_subscription_get_path (GamSubscription *sub);
+const char *gam_subscription_get_path (GamSubscription *sub);
GamListener *gam_subscription_get_listener (GamSubscription *sub);