From df7a39b1d0adfdfc6402d5739a09ff973e96544a Mon Sep 17 00:00:00 2001 From: avg Date: Sat, 26 Mar 2011 11:25:36 +0000 Subject: [PATCH] linux compat: add SO_PASSCRED option with basic handling This seems to have been a part of a bigger patch by dchagin that either haven't been committed or committed partially. Submitted by: dchagin, nox MFC after: 2 weeks --- sys/amd64/linux32/linux.h | 1 + sys/compat/linux/linux_socket.c | 14 ++++++++++++++ sys/i386/linux/linux.h | 1 + 3 files changed, 16 insertions(+) diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index 4a5ec011c7e8..4ed85222fd69 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -695,6 +695,7 @@ union l_semun { #define LINUX_SO_NO_CHECK 11 #define LINUX_SO_PRIORITY 12 #define LINUX_SO_LINGER 13 +#define LINUX_SO_PASSCRED 16 #define LINUX_SO_PEERCRED 17 #define LINUX_SO_RCVLOWAT 18 #define LINUX_SO_SNDLOWAT 19 diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 6940e45be0bd..0fe0dc6ff707 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -300,6 +300,8 @@ linux_to_bsd_so_sockopt(int opt) return (SO_OOBINLINE); case LINUX_SO_LINGER: return (SO_LINGER); + case LINUX_SO_PASSCRED: + return (LOCAL_CREDS); case LINUX_SO_PEERCRED: return (LOCAL_PEERCRED); case LINUX_SO_RCVLOWAT: @@ -1467,6 +1469,12 @@ linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args) switch (bsd_args.level) { case SOL_SOCKET: name = linux_to_bsd_so_sockopt(args->optname); + switch (args->optname) { + case LINUX_SO_PASSCRED: + /* FreeBSD bug? socket level opts at non socket level */ + bsd_args.level = 0; + break; + } switch (name) { case SO_RCVTIMEO: /* FALLTHROUGH */ @@ -1544,6 +1552,12 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args) switch (bsd_args.level) { case SOL_SOCKET: name = linux_to_bsd_so_sockopt(args->optname); + switch (args->optname) { + case LINUX_SO_PASSCRED: + /* FreeBSD bug? socket level opts at non socket level */ + bsd_args.level = 0; + break; + } switch (name) { case SO_RCVTIMEO: /* FALLTHROUGH */ diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index d02614be6219..03da736d5396 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -671,6 +671,7 @@ union l_semun { #define LINUX_SO_NO_CHECK 11 #define LINUX_SO_PRIORITY 12 #define LINUX_SO_LINGER 13 +#define LINUX_SO_PASSCRED 16 #define LINUX_SO_PEERCRED 17 #define LINUX_SO_RCVLOWAT 18 #define LINUX_SO_SNDLOWAT 19