tags 610716 +patch
--

Attached please find proposed patch against 0.2.2-2.

Given the source is derived from FreeBSD,
it is unfortunate, that the code does not build on FreeBSD kernel.

Petr
--- libtirpc-0.2.2.orig/src/svc_dg.c
+++ libtirpc-0.2.2/src/svc_dg.c
@@ -620,6 +620,7 @@ cache_get(xprt, msg, replyp, replylenp)
 void
 svc_dg_enable_pktinfo(int fd, const struct __rpc_sockinfo *si)
 {
+#ifdef __linux__
 	int val = 1;
 
 	switch (si->si_af) {
@@ -631,6 +632,7 @@ svc_dg_enable_pktinfo(int fd, const stru
 		(void) setsockopt(fd, SOL_IPV6, IPV6_PKTINFO, &val, sizeof(val));
 		break;
 	}
+#endif	
 }
 
 /*
@@ -641,6 +643,7 @@ svc_dg_enable_pktinfo(int fd, const stru
 int
 svc_dg_valid_pktinfo(struct msghdr *msg)
 {
+#ifdef __linux__
 	struct cmsghdr *cmsg;
 
 	if (!msg->msg_name)
@@ -685,4 +688,7 @@ svc_dg_valid_pktinfo(struct msghdr *msg)
 	}
 
 	return 1;
+#else
+        return 0;
+#endif        	
 }
--- libtirpc-0.2.2.orig/src/rpc_soc.c
+++ libtirpc-0.2.2/src/rpc_soc.c
@@ -105,6 +105,7 @@ clnt_com_create(raddr, prog, vers, sockp
 		static int have_cloexec;
 		fd = __rpc_nconf2fd_flags(nconf, flags);
 		if (fd == -1) {
+#ifdef SOCK_CLOEXEC		
 			if ((flags & SOCK_CLOEXEC) && have_cloexec <= 0) {
 				fd = __rpc_nconf2fd(nconf);
 				if (fd == -1)
@@ -117,6 +118,10 @@ clnt_com_create(raddr, prog, vers, sockp
 				goto syserror;
 		} else if (flags & SOCK_CLOEXEC)
 			have_cloexec = 1;
+#else
+                        goto syserror;
+                }        
+#endif			
 		madefd = TRUE;
 	}
 
--- libtirpc-0.2.2.orig/src/clnt_vc.c
+++ libtirpc-0.2.2/src/clnt_vc.c
@@ -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 @@ struct cmsgcred {
         short   cmcred_ngroups;         /* number or groups */
         gid_t   cmcred_groups[CMGROUP_MAX];     /* groups */
 };
+#endif
 
 struct cmessage {
         struct cmsghdr cmsg;
--- libtirpc-0.2.2.orig/src/getpeereid.c
+++ libtirpc-0.2.2/src/getpeereid.c
@@ -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)
--- libtirpc-0.2.2.orig/tirpc/reentrant.h
+++ libtirpc-0.2.2/tirpc/reentrant.h
@@ -36,7 +36,7 @@
  * These definitions are only guaranteed to be valid on Linux. 
  */
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__GLIBC__)
 
 #include <pthread.h>
 

Reply via email to