Lines 27-33
Link Here
|
27 |
*/ |
27 |
*/ |
28 |
|
28 |
|
29 |
#include <sys/cdefs.h> |
29 |
#include <sys/cdefs.h> |
30 |
__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/compat/linux/linux_socket.c,v 1.59.2.1 2006/01/10 10:12:55 glebius Exp $"); |
30 |
__FBSDID("$FreeBSD: src/sys/compat/linux/linux_socket.c,v 1.59.2.1 2006/01/10 10:12:55 glebius Exp $"); |
31 |
|
31 |
|
32 |
/* XXX we use functions that might not exist. */ |
32 |
/* XXX we use functions that might not exist. */ |
33 |
#include "opt_compat.h" |
33 |
#include "opt_compat.h" |
Lines 39-44
Link Here
|
39 |
|
39 |
|
40 |
#include <sys/param.h> |
40 |
#include <sys/param.h> |
41 |
#include <sys/proc.h> |
41 |
#include <sys/proc.h> |
|
|
42 |
#include <sys/syslog.h> |
42 |
#include <sys/systm.h> |
43 |
#include <sys/systm.h> |
43 |
#include <sys/sysproto.h> |
44 |
#include <sys/sysproto.h> |
44 |
#include <sys/fcntl.h> |
45 |
#include <sys/fcntl.h> |
Lines 53-58
Link Here
|
53 |
#include <sys/syscallsubr.h> |
54 |
#include <sys/syscallsubr.h> |
54 |
#include <sys/uio.h> |
55 |
#include <sys/uio.h> |
55 |
#include <sys/syslog.h> |
56 |
#include <sys/syslog.h> |
|
|
57 |
#include <sys/un.h> |
56 |
|
58 |
|
57 |
#include <netinet/in.h> |
59 |
#include <netinet/in.h> |
58 |
#include <netinet/in_systm.h> |
60 |
#include <netinet/in_systm.h> |
Lines 299-304
Link Here
|
299 |
return (SO_OOBINLINE); |
301 |
return (SO_OOBINLINE); |
300 |
case LINUX_SO_LINGER: |
302 |
case LINUX_SO_LINGER: |
301 |
return (SO_LINGER); |
303 |
return (SO_LINGER); |
|
|
304 |
case LINUX_SO_PEERCRED: |
305 |
return (LOCAL_PEERCRED); |
302 |
} |
306 |
} |
303 |
return (-1); |
307 |
return (-1); |
304 |
} |
308 |
} |
Lines 1114-1120
Link Here
|
1114 |
caddr_t val; |
1118 |
caddr_t val; |
1115 |
int *avalsize; |
1119 |
int *avalsize; |
1116 |
} */ bsd_args; |
1120 |
} */ bsd_args; |
1117 |
int error, name; |
1121 |
struct linux_ucred { |
|
|
1122 |
uint32_t pid; |
1123 |
uint32_t uid; |
1124 |
uint32_t gid; |
1125 |
} linux_ucred; |
1126 |
struct xucred xuc; |
1127 |
int error, name, optlen, rc, xuclen; |
1118 |
|
1128 |
|
1119 |
if ((error = copyin(args, &linux_args, sizeof(linux_args)))) |
1129 |
if ((error = copyin(args, &linux_args, sizeof(linux_args)))) |
1120 |
return (error); |
1130 |
return (error); |
Lines 1136-1148
Link Here
|
1136 |
name = -1; |
1146 |
name = -1; |
1137 |
break; |
1147 |
break; |
1138 |
} |
1148 |
} |
1139 |
if (name == -1) |
1149 |
if (name == -1) { |
|
|
1150 |
log(LOG_WARNING, "LINUX: 'getsockopt' level=0x%04x" |
1151 |
"optname=0x%04x not implemented\n", |
1152 |
linux_args.level, linux_args.optname); |
1140 |
return (EINVAL); |
1153 |
return (EINVAL); |
|
|
1154 |
}; |
1141 |
|
1155 |
|
1142 |
bsd_args.name = name; |
1156 |
bsd_args.name = name; |
1143 |
bsd_args.val = PTRIN(linux_args.optval); |
1157 |
if (bsd_args.level == SOL_SOCKET && name == LOCAL_PEERCRED) { |
1144 |
bsd_args.avalsize = PTRIN(linux_args.optlen); |
1158 |
if ((error = copyin(PTRIN(linux_args.optval), |
1145 |
return (getsockopt(td, &bsd_args)); |
1159 |
&linux_ucred, sizeof(linux_ucred)))) |
|
|
1160 |
return (error); |
1161 |
if ((error = copyin(PTRIN(linux_args.optlen), |
1162 |
&optlen, sizeof(optlen)))) |
1163 |
return (error); |
1164 |
if (optlen < sizeof(linux_ucred)) |
1165 |
return (EFAULT); |
1166 |
xuclen = sizeof(xuc); |
1167 |
if ((rc = error = kern_getsockopt(td, bsd_args.s, |
1168 |
0, bsd_args.name, |
1169 |
(caddr_t) &xuc, UIO_SYSSPACE, &xuclen))) |
1170 |
return (error); |
1171 |
if (xuc.cr_version != XUCRED_VERSION) |
1172 |
return (EINVAL); |
1173 |
/* XXX get PID */ |
1174 |
linux_ucred.pid = 0; |
1175 |
linux_ucred.uid = xuc.cr_uid; |
1176 |
linux_ucred.gid = xuc.cr_gid; |
1177 |
if ((error = copyout(&linux_ucred, |
1178 |
PTRIN(linux_args.optval), sizeof(linux_ucred)))) |
1179 |
return (error); |
1180 |
return (rc); |
1181 |
} else { |
1182 |
bsd_args.val = PTRIN(linux_args.optval); |
1183 |
bsd_args.avalsize = PTRIN(linux_args.optlen); |
1184 |
return (getsockopt(td, &bsd_args)); |
1185 |
}; |
1146 |
} |
1186 |
} |
1147 |
|
1187 |
|
1148 |
int |
1188 |
int |