Package: libtirpc
Severity: normal
Tags: patch upstream
Justification: fails to build from source

SCM_CREDS and struct cmsgcred are in bits/socket.h on debian/kfreebsd.
Also, getting the credentials of a unix domain socket peer seems to
work differently.

-- System Information:
Debian Release: 6.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: kfreebsd-i386 (i686)

Kernel: kFreeBSD 8.1-1-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff -ru ref/libtirpc-0.2.1/src/clnt_vc.c libtirpc-0.2.1/src/clnt_vc.c
--- ref/libtirpc-0.2.1/src/clnt_vc.c	2009-11-30 09:04:55.000000000 -0500
+++ libtirpc-0.2.1/src/clnt_vc.c	2011-01-16 20:01:49.438522186 -0500
@@ -70,6 +70,7 @@
 #define MCALL_MSG_SIZE 24
 
 #define CMGROUP_MAX    16
+#ifndef SCM_CREDS
 #define SCM_CREDS      0x03            /* process creds (struct cmsgcred) */
 
 /*
@@ -87,6 +88,7 @@
         short   cmcred_ngroups;         /* number or groups */
         gid_t   cmcred_groups[CMGROUP_MAX];     /* groups */
 };
+#endif
 
 struct cmessage {
         struct cmsghdr cmsg;
diff -ru ref/libtirpc-0.2.1/src/getpeereid.c libtirpc-0.2.1/src/getpeereid.c
--- ref/libtirpc-0.2.1/src/getpeereid.c	2009-11-30 09:04:55.000000000 -0500
+++ libtirpc-0.2.1/src/getpeereid.c	2011-01-16 20:25:04.117482780 -0500
@@ -29,6 +29,7 @@
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <sys/user.h>
 
 #include <errno.h>
 #include <unistd.h>
@@ -36,12 +37,22 @@
 int
 getpeereid(int s, uid_t *euid, gid_t *egid)
 {
+#ifdef XUCRED_VERSION
+	struct xucred uc;
+#define uid  cr_uid
+#define gid  cr_gid
+#else
 	struct ucred uc;
+#endif
 	socklen_t uclen;
 	int error;
 
 	uclen = sizeof(uc); 
+#ifdef XUCRED_VERSION
+	error = getsockopt(s, 0, LOCAL_PEERCRED, &uc, &uclen);
+#else
 	error = getsockopt(s, SOL_SOCKET, SO_PEERCRED, &uc, &uclen); /*  SCM_CREDENTIALS */
+#endif
 	if (error != 0)
 		return (error);
 	//	if (uc.cr_version != XUCRED_VERSION)

Reply via email to