Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jun 2009 05:05:46 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r194281 - in stable/7/sys: . compat/linux contrib/pf dev/ath/ath_hal
Message-ID:  <200906160505.n5G55kae012721@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Tue Jun 16 05:05:46 2009
New Revision: 194281
URL: http://svn.freebsd.org/changeset/base/194281

Log:
  MFC r192203:
  
  Emulate SO_PEERCRED socket option.
  Temporarily use 0 for pid member as the FreeBSD does not cache remote
  UNIX domain socket peer pid.
  
  PR:		kern/102956
  Approved by:	kib (mentor)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/compat/linux/linux_socket.c
  stable/7/sys/compat/linux/linux_socket.h
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)

Modified: stable/7/sys/compat/linux/linux_socket.c
==============================================================================
--- stable/7/sys/compat/linux/linux_socket.c	Tue Jun 16 03:51:38 2009	(r194280)
+++ stable/7/sys/compat/linux/linux_socket.c	Tue Jun 16 05:05:46 2009	(r194281)
@@ -1159,7 +1159,9 @@ linux_getsockopt(struct thread *td, stru
 	} */ bsd_args;
 	l_timeval linux_tv;
 	struct timeval tv;
-	socklen_t tv_len;
+	socklen_t tv_len, xulen;
+	struct xucred xu;
+	struct l_ucred lxu;
 	int error, name;
 
 	bsd_args.s = args->s;
@@ -1182,6 +1184,23 @@ linux_getsockopt(struct thread *td, stru
 			    sizeof(linux_tv)));
 			/* NOTREACHED */
 			break;
+		case LOCAL_PEERCRED:
+			if (args->optlen != sizeof(lxu))
+				return (EINVAL);
+			xulen = sizeof(xu);
+			error = kern_getsockopt(td, args->s, bsd_args.level,
+			    name, &xu, UIO_SYSSPACE, &xulen);
+			if (error)
+				return (error);
+			/*
+			 * XXX Use 0 for pid as the FreeBSD does not cache peer pid.
+			 */
+			lxu.pid = 0;
+			lxu.uid = xu.cr_uid;
+			lxu.gid = xu.cr_gid;
+			return (copyout(&lxu, PTRIN(args->optval), sizeof(lxu)));
+			/* NOTREACHED */
+			break;
 		default:
 			break;
 		}

Modified: stable/7/sys/compat/linux/linux_socket.h
==============================================================================
--- stable/7/sys/compat/linux/linux_socket.h	Tue Jun 16 03:51:38 2009	(r194280)
+++ stable/7/sys/compat/linux/linux_socket.h	Tue Jun 16 05:05:46 2009	(r194281)
@@ -59,4 +59,10 @@
 #define	LINUX_AF_APPLETALK	5
 #define	LINUX_AF_INET6		10
 
+struct l_ucred {
+	uint32_t	pid;
+	uint32_t	uid;
+	uint32_t	gid;
+};
+
 #endif /* _LINUX_SOCKET_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906160505.n5G55kae012721>