compat linux (and linux32) uid16 functions cleanup and fixes.
- Move uid16 functions to their own file linux_uid16.c, included by needed archs (arm, i386 and m68k). - Add new MI types linux_{u,g}id16_t. - Add macros to handle linux_uid16_t and uid_t conversions. - Add linux_sys_getres{uid,gid}16 syscalls, to fix an overflow with bad sizes given to copyout when linux_sys_getres{uid,gid} are used. - Update arm syscall table to use more uid16 functions.
This commit is contained in:
parent
609d13b264
commit
5cec0f492f
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_commons.c,v 1.5 2007/08/15 12:07:29 ad Exp $ */
|
||||
/* $NetBSD: linux_commons.c,v 1.6 2008/01/15 22:38:34 njoly Exp $ */
|
||||
|
||||
/*
|
||||
* This file includes C files from the common
|
||||
|
@ -13,7 +13,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.5 2007/08/15 12:07:29 ad Exp $");
|
||||
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.6 2008/01/15 22:38:34 njoly Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_sysv.h"
|
||||
|
@ -39,3 +39,4 @@ __KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.5 2007/08/15 12:07:29 ad Exp $")
|
|||
#include "../../common/linux_oldselect.c"
|
||||
#include "../../common/linux_olduname.c"
|
||||
#include "../../common/linux_oldolduname.c"
|
||||
#include "../../common/linux_uid16.c"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: syscalls.master,v 1.32 2007/12/24 14:17:17 njoly Exp $
|
||||
$NetBSD: syscalls.master,v 1.33 2008/01/15 22:38:34 njoly Exp $
|
||||
|
||||
; Derived from sys/compat/linux/arch/*/syscalls.master
|
||||
; and from Linux 2.4.12 arch/arm/kernel/calls.S
|
||||
|
@ -75,8 +75,8 @@
|
|||
14 STD { int linux_sys_mknod(const char *path, int mode, \
|
||||
int dev); }
|
||||
15 NOARGS { int sys_chmod(const char *path, int mode); }
|
||||
16 STD { int linux_sys_lchown16(const char *path, int uid, \
|
||||
int gid); }
|
||||
16 STD { int linux_sys_lchown16(const char *path, \
|
||||
linux_uid16_t uid, linux_gid16_t gid); }
|
||||
17 OBSOL break
|
||||
18 OBSOL ostat
|
||||
19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \
|
||||
|
@ -139,8 +139,10 @@
|
|||
struct linux_old_sigaction *osa); }
|
||||
68 STD { int linux_sys_siggetmask(void); }
|
||||
69 STD { int linux_sys_sigsetmask(linux_old_sigset_t mask); }
|
||||
70 NOARGS { int sys_setreuid(uid_t ruid, uid_t euid); }
|
||||
71 NOARGS { int sys_setregid(gid_t rgid, gid_t egid); }
|
||||
70 STD { int linux_sys_setreuid16(linux_uid16_t ruid, \
|
||||
linux_uid16_t euid); }
|
||||
71 STD { int linux_sys_setregid16(linux_gid16_t rgid, \
|
||||
linux_gid16_t egid); }
|
||||
72 STD { int linux_sys_sigsuspend(void *restart, \
|
||||
int oldmask, int mask); }
|
||||
73 STD { int linux_sys_sigpending(linux_old_sigset_t *set); }
|
||||
|
@ -155,8 +157,10 @@
|
|||
struct timezone *tzp); }
|
||||
79 STD { int linux_sys_settimeofday(struct timeval *tp, \
|
||||
struct timezone *tzp); }
|
||||
80 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
|
||||
81 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
|
||||
80 STD { int linux_sys_getgroups16(int gidsetsize, \
|
||||
linux_gid16_t *gidset); }
|
||||
81 STD { int linux_sys_setgroups16(int gidsetsize, \
|
||||
linux_gid16_t *gidset); }
|
||||
82 STD { int linux_sys_oldselect(struct linux_oldselect *lsp); }
|
||||
83 NOARGS { int sys_symlink(const char *path, const char *to); }
|
||||
84 NOARGS { int compat_43_sys_lstat(const char *path, \
|
||||
|
@ -179,7 +183,8 @@
|
|||
long length); }
|
||||
93 NOARGS { int compat_43_sys_ftruncate(int fd, long length); }
|
||||
94 NOARGS { int sys_fchmod(int fd, int mode); }
|
||||
95 STD { int linux_sys_fchown16(int fd, int uid, int gid); }
|
||||
95 STD { int linux_sys_fchown16(int fd, linux_uid16_t uid, \
|
||||
linux_gid16_t gid); }
|
||||
96 STD { int linux_sys_getpriority(int which, int who); }
|
||||
97 NOARGS { int sys_setpriority(int which, int who, int prio); }
|
||||
98 NOARGS { int sys_profil(void *samples, u_int size, \
|
||||
|
@ -272,19 +277,19 @@
|
|||
struct timespec *rmtp); }
|
||||
163 STD { void *linux_sys_mremap(void *old_address, \
|
||||
size_t old_size, size_t new_size, u_long flags); }
|
||||
164 STD { int linux_sys_setresuid(uid_t ruid, uid_t euid, \
|
||||
uid_t suid); }
|
||||
165 STD { int linux_sys_getresuid(uid_t *ruid, uid_t *euid, \
|
||||
uid_t *suid); }
|
||||
164 STD { int linux_sys_setresuid16(linux_uid16_t ruid, \
|
||||
linux_uid16_t euid, linux_uid16_t suid); }
|
||||
165 STD { int linux_sys_getresuid16(linux_uid16_t *ruid, \
|
||||
linux_uid16_t *euid, linux_uid16_t *suid); }
|
||||
166 UNIMPL
|
||||
167 UNIMPL query_module
|
||||
168 NOARGS { int sys_poll(struct pollfd *fds, u_int nfds, \
|
||||
int timeout); }
|
||||
169 UNIMPL nfsservctl
|
||||
170 STD { int linux_sys_setresgid(gid_t rgid, gid_t egid, \
|
||||
gid_t sgid); }
|
||||
171 STD { int linux_sys_getresgid(gid_t *rgid, gid_t *egid, \
|
||||
gid_t *sgid); }
|
||||
170 STD { int linux_sys_setresgid16(linux_gid16_t rgid, \
|
||||
linux_gid16_t egid, linux_gid16_t sgid); }
|
||||
171 STD { int linux_sys_getresgid16(linux_gid16_t *rgid, \
|
||||
linux_gid16_t *egid, linux_gid16_t *sgid); }
|
||||
172 UNIMPL prctl
|
||||
173 UNIMPL rt_sigreturn
|
||||
;173 STD { int linux_sys_rt_sigreturn( \
|
||||
|
@ -310,8 +315,8 @@
|
|||
size_t nbyte, linux_off_t offset); }
|
||||
181 STD { int linux_sys_pwrite(int fd, char *buf, \
|
||||
size_t nbyte, linux_off_t offset); }
|
||||
182 STD { int linux_sys_chown16(const char *path, int uid, \
|
||||
int gid); }
|
||||
182 STD { int linux_sys_chown16(const char *path, \
|
||||
linux_uid16_t uid, linux_gid16_t gid); }
|
||||
183 NOARGS { int sys___getcwd(char *bufp, size_t length); }
|
||||
184 UNIMPL capget
|
||||
185 UNIMPL capset
|
||||
|
@ -354,13 +359,13 @@
|
|||
gid_t *gidset); }
|
||||
207 NOARGS fchown32 { int sys___posix_fchown(int fd, uid_t uid, \
|
||||
gid_t gid); }
|
||||
208 NOARGS setresuid32 { int linux_sys_setresuid(uid_t ruid, \
|
||||
208 STD setresuid32 { int linux_sys_setresuid(uid_t ruid, \
|
||||
uid_t euid, uid_t suid); }
|
||||
209 NOARGS getresuid32 { int linux_sys_getresuid(uid_t *ruid, \
|
||||
209 STD getresuid32 { int linux_sys_getresuid(uid_t *ruid, \
|
||||
uid_t *euid, uid_t *suid); }
|
||||
210 NOARGS setresgid32 { int linux_sys_setresgid(gid_t rgid, \
|
||||
210 STD setresgid32 { int linux_sys_setresgid(gid_t rgid, \
|
||||
gid_t egid, gid_t sgid); }
|
||||
211 NOARGS getresgid32 { int linux_sys_getresgid(gid_t *rgid, \
|
||||
211 STD getresgid32 { int linux_sys_getresgid(gid_t *rgid, \
|
||||
gid_t *egid, gid_t *sgid); }
|
||||
212 NOARGS chown32 { int sys___posix_chown(const char *path, \
|
||||
uid_t uid, gid_t gid); }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_commons.c,v 1.10 2007/08/15 12:07:29 ad Exp $ */
|
||||
/* $NetBSD: linux_commons.c,v 1.11 2008/01/15 22:38:34 njoly Exp $ */
|
||||
|
||||
/*
|
||||
* This file includes C files from the common
|
||||
|
@ -13,7 +13,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.10 2007/08/15 12:07:29 ad Exp $");
|
||||
__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.11 2008/01/15 22:38:34 njoly Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_sysv.h"
|
||||
|
@ -41,3 +41,4 @@ __KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.10 2007/08/15 12:07:29 ad Exp $"
|
|||
#include "../../common/linux_oldselect.c"
|
||||
#include "../../common/linux_olduname.c"
|
||||
#include "../../common/linux_oldolduname.c"
|
||||
#include "../../common/linux_uid16.c"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: syscalls.master,v 1.88 2007/12/24 14:17:18 njoly Exp $
|
||||
$NetBSD: syscalls.master,v 1.89 2008/01/15 22:38:34 njoly Exp $
|
||||
|
||||
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||
|
||||
|
@ -75,7 +75,7 @@
|
|||
int dev); }
|
||||
15 NOARGS { int sys_chmod(const char *path, int mode); }
|
||||
16 STD { int linux_sys_lchown16(const char *path, \
|
||||
int uid, int gid); }
|
||||
linux_uid16_t uid, linux_gid16_t gid); }
|
||||
;17 - no longer in linux source.
|
||||
17 STD { int linux_sys_break(char *nsize); }
|
||||
18 OBSOL ostat
|
||||
|
@ -147,8 +147,10 @@
|
|||
struct linux_old_sigaction *osa); }
|
||||
68 STD { int linux_sys_siggetmask(void); }
|
||||
69 STD { int linux_sys_sigsetmask(linux_old_sigset_t mask); }
|
||||
70 STD { int linux_sys_setreuid16(int ruid, int euid); }
|
||||
71 STD { int linux_sys_setregid16(int rgid, int egid); }
|
||||
70 STD { int linux_sys_setreuid16(linux_uid16_t ruid, \
|
||||
linux_uid16_t euid); }
|
||||
71 STD { int linux_sys_setregid16(linux_gid16_t rgid, \
|
||||
linux_gid16_t egid); }
|
||||
72 STD { int linux_sys_sigsuspend(void *restart, \
|
||||
int oldmask, int mask); }
|
||||
73 STD { int linux_sys_sigpending(linux_old_sigset_t *set); }
|
||||
|
@ -163,9 +165,10 @@
|
|||
struct timezone *tzp); }
|
||||
79 STD { int linux_sys_settimeofday(struct timeval *tp, \
|
||||
struct timezone *tzp); }
|
||||
80 STD { int linux_sys_getgroups16(int gidsetsize, linux_gid_t *gidset); }
|
||||
80 STD { int linux_sys_getgroups16(int gidsetsize, \
|
||||
linux_gid16_t *gidset); }
|
||||
81 STD { int linux_sys_setgroups16(int gidsetsize, \
|
||||
linux_gid_t *gidset); }
|
||||
linux_gid16_t *gidset); }
|
||||
82 STD { int linux_sys_oldselect(struct linux_oldselect *lsp); }
|
||||
83 NOARGS { int sys_symlink(const char *path, const char *to); }
|
||||
84 NOARGS { int compat_43_sys_lstat(const char *path, \
|
||||
|
@ -188,7 +191,8 @@
|
|||
long length); }
|
||||
93 NOARGS { int compat_43_sys_ftruncate(int fd, long length); }
|
||||
94 NOARGS { int sys_fchmod(int fd, int mode); }
|
||||
95 STD { int linux_sys_fchown16(int fd, int uid, int gid); }
|
||||
95 STD { int linux_sys_fchown16(int fd, linux_uid16_t uid, \
|
||||
linux_gid16_t gid); }
|
||||
96 STD { int linux_sys_getpriority(int which, int who); }
|
||||
97 NOARGS { int sys_setpriority(int which, int who, int prio); }
|
||||
98 NOARGS { int sys_profil(void *samples, u_int size, \
|
||||
|
@ -284,19 +288,19 @@
|
|||
struct timespec *rmtp); }
|
||||
163 STD { void *linux_sys_mremap(void *old_address, \
|
||||
size_t old_size, size_t new_size, u_long flags); }
|
||||
164 STD { int linux_sys_setresuid16(uid_t ruid, uid_t euid, \
|
||||
uid_t suid); }
|
||||
165 NOARGS linux_getresuid16 { int linux_sys_getresuid( \
|
||||
uid_t *ruid, uid_t *euid, uid_t *suid); }
|
||||
164 STD { int linux_sys_setresuid16(linux_uid16_t ruid, \
|
||||
linux_uid16_t euid, linux_uid16_t suid); }
|
||||
165 STD { int linux_sys_getresuid16(linux_uid16_t *ruid, \
|
||||
linux_uid16_t *euid, linux_uid16_t *suid); }
|
||||
166 UNIMPL vm86
|
||||
167 UNIMPL query_module
|
||||
168 NOARGS { int sys_poll(struct pollfd *fds, u_int nfds, \
|
||||
int timeout); }
|
||||
169 UNIMPL nfsservctl
|
||||
170 STD { int linux_sys_setresgid16(gid_t rgid, gid_t egid, \
|
||||
gid_t sgid); }
|
||||
171 NOARGS linux_getresgid16 { int linux_sys_getresgid( \
|
||||
gid_t *rgid, gid_t *egid, gid_t *sgid); }
|
||||
170 STD { int linux_sys_setresgid16(linux_gid16_t rgid, \
|
||||
linux_gid16_t egid, linux_gid16_t sgid); }
|
||||
171 STD { int linux_sys_getresgid16(linux_gid16_t *rgid, \
|
||||
linux_gid16_t *egid, linux_gid16_t *sgid); }
|
||||
172 UNIMPL prctl
|
||||
173 STD { int linux_sys_rt_sigreturn( \
|
||||
struct linux_ucontext *ucp); }
|
||||
|
@ -321,8 +325,8 @@
|
|||
size_t nbyte, linux_off_t offset); }
|
||||
181 STD { int linux_sys_pwrite(int fd, char *buf, \
|
||||
size_t nbyte, linux_off_t offset); }
|
||||
182 STD { int linux_sys_chown16(const char *path, int uid, \
|
||||
int gid); }
|
||||
182 STD { int linux_sys_chown16(const char *path, \
|
||||
linux_uid16_t uid, linux_gid16_t gid); }
|
||||
183 NOARGS { int sys___getcwd(char *bufp, size_t length); }
|
||||
184 UNIMPL capget
|
||||
185 UNIMPL capset
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.linux_m68k,v 1.3 2002/03/31 22:40:17 christos Exp $
|
||||
# $NetBSD: files.linux_m68k,v 1.4 2008/01/15 22:38:34 njoly Exp $
|
||||
#
|
||||
# Config file description for m68k-dependent Linux compat code.
|
||||
|
||||
|
@ -17,3 +17,4 @@ file compat/linux/common/linux_socketcall.c compat_linux
|
|||
file compat/linux/common/linux_llseek.c compat_linux
|
||||
file compat/linux/common/linux_oldmmap.c compat_linux
|
||||
file compat/linux/common/linux_oldselect.c compat_linux
|
||||
file compat/linux/common/linux_uid16.c compat_linux
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: syscalls.master,v 1.58 2007/12/24 14:17:18 njoly Exp $
|
||||
$NetBSD: syscalls.master,v 1.59 2008/01/15 22:38:34 njoly Exp $
|
||||
|
||||
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||
|
||||
|
@ -77,7 +77,7 @@
|
|||
15 NOARGS { int sys_chmod(const char *path, int mode); }
|
||||
;16 lchown on i386; chown on m68k.
|
||||
16 STD { int linux_sys_chown16(const char *path, \
|
||||
int uid, int gid); }
|
||||
linux_uid16_t uid, linux_gid16_t gid); }
|
||||
17 OBSOL break
|
||||
18 OBSOL ostat
|
||||
#if !defined(_KERNEL) || defined(COMPAT_43)
|
||||
|
@ -143,8 +143,10 @@
|
|||
struct linux_old_sigaction *osa); }
|
||||
68 STD { int linux_sys_siggetmask(void); }
|
||||
69 STD { int linux_sys_sigsetmask(linux_old_sigset_t mask); }
|
||||
70 STD { int linux_sys_setreuid16(int ruid, int euid); }
|
||||
71 STD { int linux_sys_setregid16(int rgid, int egid); }
|
||||
70 STD { int linux_sys_setreuid16(linux_uid16_t ruid, \
|
||||
linux_uid16_t euid); }
|
||||
71 STD { int linux_sys_setregid16(linux_gid16_t rgid, \
|
||||
linux_gid16_t egid); }
|
||||
72 STD { int linux_sys_sigsuspend(void *restart, \
|
||||
int oldmask, int mask); }
|
||||
73 STD { int linux_sys_sigpending(linux_old_sigset_t *set); }
|
||||
|
@ -163,8 +165,10 @@
|
|||
struct timezone *tzp); }
|
||||
79 STD { int linux_sys_settimeofday(struct timeval *tp, \
|
||||
struct timezone *tzp); }
|
||||
80 STD { int linux_sys_getgroups16(u_int gidsetsize, linux_gid_t *gidset); }
|
||||
81 STD { int linux_sys_setgroups16(u_int gidsetsize, linux_gid_t *gidset); }
|
||||
80 STD { int linux_sys_getgroups16(int gidsetsize, \
|
||||
linux_gid16_t *gidset); }
|
||||
81 STD { int linux_sys_setgroups16(int gidsetsize, \
|
||||
linux_gid16_t *gidset); }
|
||||
82 STD { int linux_sys_oldselect(struct linux_oldselect *lsp); }
|
||||
83 NOARGS { int sys_symlink(const char *path, const char *to); }
|
||||
#if !defined(_KERNEL) || defined(COMPAT_43)
|
||||
|
@ -195,7 +199,8 @@
|
|||
93 UNIMPL compat_43_sys_ftruncate
|
||||
#endif
|
||||
94 NOARGS { int sys_fchmod(int fd, int mode); }
|
||||
95 STD { int linux_sys_fchown16(int fd, int uid, int gid); }
|
||||
95 STD { int linux_sys_fchown16(int fd, linux_uid16_t uid, \
|
||||
linux_gid16_t gid); }
|
||||
96 STD { int linux_sys_getpriority(int which, int who); }
|
||||
97 NOARGS { int sys_setpriority(int which, int who, int prio); }
|
||||
98 NOARGS { int sys_profil(void *samples, u_int size, \
|
||||
|
@ -289,19 +294,19 @@
|
|||
struct timespec *rmtp); }
|
||||
163 STD { void *linux_sys_mremap(void *old_address, \
|
||||
size_t old_size, size_t new_size, u_long flags); }
|
||||
164 STD { int linux_sys_setresuid16(uid_t ruid, uid_t euid, \
|
||||
uid_t suid); }
|
||||
165 NOARGS linux_getresuid16 { int linux_sys_getresuid( \
|
||||
uid_t *ruid, uid_t *euid, uid_t *suid); }
|
||||
164 STD { int linux_sys_setresuid16(linux_uid16_t ruid, \
|
||||
linux_uid16_t euid, linux_uid16_t suid); }
|
||||
165 STD { int linux_sys_getresuid16(linux_uid16_t *ruid, \
|
||||
linux_uid16_t *euid, linux_uid16_t *suid); }
|
||||
166 UNIMPL vm86
|
||||
167 UNIMPL query_module
|
||||
168 NOARGS { int sys_poll(struct pollfd *fds, u_int nfds, \
|
||||
int timeout); }
|
||||
169 UNIMPL nfsservctl
|
||||
170 STD { int linux_sys_setresgid16(gid_t rgid, gid_t egid, \
|
||||
gid_t sgid); }
|
||||
171 NOARGS linux_getresgid16 { int linux_sys_getresgid( \
|
||||
gid_t *rgid, gid_t *egid, gid_t *sgid); }
|
||||
170 STD { int linux_sys_setresgid16(linux_gid16_t rgid, \
|
||||
linux_gid16_t egid, linux_gid16_t sgid); }
|
||||
171 STD { int linux_sys_getresgid16(linux_gid16_t *rgid, \
|
||||
linux_gid16_t *egid, linux_gid16_t *sgid); }
|
||||
172 UNIMPL prctl
|
||||
173 STD { int linux_sys_rt_sigreturn(void); }
|
||||
174 STD { int linux_sys_rt_sigaction(int signum, \
|
||||
|
@ -326,8 +331,8 @@
|
|||
181 STD { int linux_sys_pwrite(int fd, char *buf, \
|
||||
size_t nbyte, linux_off_t offset); }
|
||||
;182 chown on i386; lchown on m68k.
|
||||
182 STD { int linux_sys_lchown16(const char *path, int uid, \
|
||||
int gid); }
|
||||
182 STD { int linux_sys_lchown16(const char *path, \
|
||||
linux_uid16_t uid, linux_gid16_t gid); }
|
||||
183 NOARGS { int sys___getcwd(char *bufp, size_t length); }
|
||||
184 UNIMPL capget
|
||||
185 UNIMPL capset
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_file.c,v 1.90 2007/12/20 23:02:54 dsl Exp $ */
|
||||
/* $NetBSD: linux_file.c,v 1.91 2008/01/15 22:38:34 njoly Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.90 2007/12/20 23:02:54 dsl Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.91 2008/01/15 22:38:34 njoly Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -623,66 +623,6 @@ linux_sys_mknod(struct lwp *l, const struct linux_sys_mknod_args *uap, register_
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(__i386__) || defined(__m68k__) || \
|
||||
defined(__arm__)
|
||||
int
|
||||
linux_sys_chown16(struct lwp *l, const struct linux_sys_chown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(const char *) path;
|
||||
syscallarg(int) uid;
|
||||
syscallarg(int) gid;
|
||||
} */
|
||||
struct sys___posix_chown_args bca;
|
||||
|
||||
SCARG(&bca, path) = SCARG(uap, path);
|
||||
SCARG(&bca, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, uid);
|
||||
SCARG(&bca, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
|
||||
(gid_t)-1 : SCARG(uap, gid);
|
||||
|
||||
return sys___posix_chown(l, &bca, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_fchown16(struct lwp *l, const struct linux_sys_fchown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) fd;
|
||||
syscallarg(int) uid;
|
||||
syscallarg(int) gid;
|
||||
} */
|
||||
struct sys___posix_fchown_args bfa;
|
||||
|
||||
SCARG(&bfa, fd) = SCARG(uap, fd);
|
||||
SCARG(&bfa, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, uid);
|
||||
SCARG(&bfa, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
|
||||
(gid_t)-1 : SCARG(uap, gid);
|
||||
|
||||
return sys___posix_fchown(l, &bfa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_lchown16(struct lwp *l, const struct linux_sys_lchown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(char *) path;
|
||||
syscallarg(int) uid;
|
||||
syscallarg(int) gid;
|
||||
} */
|
||||
struct sys___posix_lchown_args bla;
|
||||
|
||||
SCARG(&bla, path) = SCARG(uap, path);
|
||||
SCARG(&bla, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, uid);
|
||||
SCARG(&bla, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
|
||||
(gid_t)-1 : SCARG(uap, gid);
|
||||
|
||||
return sys___posix_lchown(l, &bla, retval);
|
||||
}
|
||||
#endif /* __i386__ || __m68k__ || __arm__ || __amd64__ */
|
||||
|
||||
/*
|
||||
* This is just fsync() for now (just as it is in the Linux kernel)
|
||||
* Note: this is not implemented under Linux on Alpha and Arm
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_misc.c,v 1.192 2007/12/24 14:17:18 njoly Exp $ */
|
||||
/* $NetBSD: linux_misc.c,v 1.193 2008/01/15 22:38:34 njoly Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -64,7 +64,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.192 2007/12/24 14:17:18 njoly Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.193 2008/01/15 22:38:34 njoly Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ptrace.h"
|
||||
|
@ -960,166 +960,7 @@ linux_sys_personality(struct lwp *l, const struct linux_sys_personality_args *ua
|
|||
retval[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif /* !COMPAT_LINUX32 */
|
||||
|
||||
#if defined(__i386__) || defined(__m68k__) || defined(COMPAT_LINUX32)
|
||||
/*
|
||||
* The calls are here because of type conversions.
|
||||
*/
|
||||
#ifndef COMPAT_LINUX32
|
||||
int
|
||||
linux_sys_setreuid16(struct lwp *l, const struct linux_sys_setreuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) ruid;
|
||||
syscallarg(int) euid;
|
||||
} */
|
||||
struct sys_setreuid_args bsa;
|
||||
|
||||
SCARG(&bsa, ruid) = ((linux_uid_t)SCARG(uap, ruid) == (linux_uid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, ruid);
|
||||
SCARG(&bsa, euid) = ((linux_uid_t)SCARG(uap, euid) == (linux_uid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, euid);
|
||||
|
||||
return sys_setreuid(l, &bsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_setregid16(struct lwp *l, const struct linux_sys_setregid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) rgid;
|
||||
syscallarg(int) egid;
|
||||
} */
|
||||
struct sys_setregid_args bsa;
|
||||
|
||||
SCARG(&bsa, rgid) = ((linux_gid_t)SCARG(uap, rgid) == (linux_gid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, rgid);
|
||||
SCARG(&bsa, egid) = ((linux_gid_t)SCARG(uap, egid) == (linux_gid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, egid);
|
||||
|
||||
return sys_setregid(l, &bsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_setresuid16(struct lwp *l, const struct linux_sys_setresuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(uid_t) ruid;
|
||||
syscallarg(uid_t) euid;
|
||||
syscallarg(uid_t) suid;
|
||||
} */
|
||||
struct linux_sys_setresuid_args lsa;
|
||||
|
||||
SCARG(&lsa, ruid) = ((linux_uid_t)SCARG(uap, ruid) == (linux_uid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, ruid);
|
||||
SCARG(&lsa, euid) = ((linux_uid_t)SCARG(uap, euid) == (linux_uid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, euid);
|
||||
SCARG(&lsa, suid) = ((linux_uid_t)SCARG(uap, suid) == (linux_uid_t)-1) ?
|
||||
(uid_t)-1 : SCARG(uap, suid);
|
||||
|
||||
return linux_sys_setresuid(l, &lsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_setresgid16(struct lwp *l, const struct linux_sys_setresgid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(gid_t) rgid;
|
||||
syscallarg(gid_t) egid;
|
||||
syscallarg(gid_t) sgid;
|
||||
} */
|
||||
struct linux_sys_setresgid_args lsa;
|
||||
|
||||
SCARG(&lsa, rgid) = ((linux_gid_t)SCARG(uap, rgid) == (linux_gid_t)-1) ?
|
||||
(gid_t)-1 : SCARG(uap, rgid);
|
||||
SCARG(&lsa, egid) = ((linux_gid_t)SCARG(uap, egid) == (linux_gid_t)-1) ?
|
||||
(gid_t)-1 : SCARG(uap, egid);
|
||||
SCARG(&lsa, sgid) = ((linux_gid_t)SCARG(uap, sgid) == (linux_gid_t)-1) ?
|
||||
(gid_t)-1 : SCARG(uap, sgid);
|
||||
|
||||
return linux_sys_setresgid(l, &lsa, retval);
|
||||
}
|
||||
#endif /* COMPAT_LINUX32 */
|
||||
|
||||
int
|
||||
linux_sys_getgroups16(struct lwp *l, const struct linux_sys_getgroups16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux_gid_t *) gidset;
|
||||
} */
|
||||
linux_gid_t lset[16];
|
||||
linux_gid_t *gidset;
|
||||
unsigned int ngrps;
|
||||
int i, n, j;
|
||||
int error;
|
||||
|
||||
ngrps = kauth_cred_ngroups(l->l_cred);
|
||||
*retval = ngrps;
|
||||
if (SCARG(uap, gidsetsize) == 0)
|
||||
return 0;
|
||||
if (SCARG(uap, gidsetsize) < ngrps)
|
||||
return EINVAL;
|
||||
|
||||
gidset = SCARG(uap, gidset);
|
||||
for (i = 0; i < (n = ngrps); i += n, gidset += n) {
|
||||
n -= i;
|
||||
if (n > __arraycount(lset))
|
||||
n = __arraycount(lset);
|
||||
for (j = 0; j < n; j++)
|
||||
lset[j] = kauth_cred_group(l->l_cred, i + j);
|
||||
error = copyout(lset, gidset, n * sizeof(lset[0]));
|
||||
if (error != 0)
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* It is very unlikly that any problem using 16bit groups is written
|
||||
* to allow for more than 16 of them, so don't bother trying to
|
||||
* support that.
|
||||
*/
|
||||
#define COMPAT_NGROUPS16 16
|
||||
|
||||
int
|
||||
linux_sys_setgroups16(struct lwp *l, const struct linux_sys_setgroups16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux_gid_t *) gidset;
|
||||
} */
|
||||
linux_gid_t lset[COMPAT_NGROUPS16];
|
||||
kauth_cred_t ncred;
|
||||
int error;
|
||||
gid_t grbuf[COMPAT_NGROUPS16];
|
||||
unsigned int i, ngroups = SCARG(uap, gidsetsize);
|
||||
|
||||
if (ngroups > COMPAT_NGROUPS16)
|
||||
return EINVAL;
|
||||
error = copyin(SCARG(uap, gidset), lset, ngroups);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
for (i = 0; i < ngroups; i++)
|
||||
grbuf[i] = lset[i];
|
||||
|
||||
ncred = kauth_cred_alloc();
|
||||
error = kauth_cred_setgroups(ncred, grbuf, SCARG(uap, gidsetsize),
|
||||
-1, UIO_SYSSPACE);
|
||||
if (error != 0) {
|
||||
kauth_cred_free(ncred);
|
||||
return error;
|
||||
}
|
||||
|
||||
return kauth_proc_setgroups(l, ncred);
|
||||
}
|
||||
|
||||
#endif /* __i386__ || __m68k__ || COMPAT_LINUX32 */
|
||||
|
||||
#ifndef COMPAT_LINUX32
|
||||
/*
|
||||
* We have nonexistent fsuid equal to uid.
|
||||
* If modification is requested, refuse.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_types.h,v 1.26 2007/03/23 04:16:14 mrg Exp $ */
|
||||
/* $NetBSD: linux_types.h,v 1.27 2008/01/15 22:38:35 njoly Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -58,6 +58,9 @@ typedef unsigned long linux_clock_t;
|
|||
typedef unsigned long linux_time_t;
|
||||
#endif
|
||||
|
||||
typedef unsigned short linux_gid16_t;
|
||||
typedef unsigned short linux_uid16_t;
|
||||
|
||||
/*
|
||||
* From Linux include/asm-.../posix_types.h
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,307 @@
|
|||
/* $NetBSD: linux_uid16.c,v 1.1 2008/01/15 22:38:35 njoly Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Frank van der Linden and Eric Haszlakiewicz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux_uid16.c,v 1.1 2008/01/15 22:38:35 njoly Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kauth.h>
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <compat/linux/common/linux_types.h>
|
||||
#include <compat/linux/common/linux_signal.h>
|
||||
#include <compat/linux/linux_syscallargs.h>
|
||||
|
||||
#define LINUXTOBSD_UID(u) \
|
||||
(((u) == (linux_uid16_t)-1) ? -1 : (u))
|
||||
#define LINUXTOBSD_GID(g) \
|
||||
(((g) == (linux_gid16_t)-1) ? -1 : (g))
|
||||
|
||||
#define BSDTOLINUX_UID(u) \
|
||||
(((u) & ~0xffff) ? (linux_uid16_t)65534 : (linux_uid16_t)(u))
|
||||
#define BSDTOLINUX_GID(g) \
|
||||
(((g) & ~0xffff) ? (linux_gid16_t)65534 : (linux_gid16_t)(g))
|
||||
|
||||
#ifndef COMPAT_LINUX32
|
||||
int
|
||||
linux_sys_chown16(struct lwp *l, const struct linux_sys_chown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(const char *) path;
|
||||
syscallarg(linux_uid16_t) uid;
|
||||
syscallarg(linux_gid16_t) gid;
|
||||
} */
|
||||
struct sys___posix_chown_args bca;
|
||||
|
||||
SCARG(&bca, path) = SCARG(uap, path);
|
||||
SCARG(&bca, uid) = LINUXTOBSD_UID(SCARG(uap, uid));
|
||||
SCARG(&bca, gid) = LINUXTOBSD_GID(SCARG(uap, gid));
|
||||
|
||||
return sys___posix_chown(l, &bca, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_fchown16(struct lwp *l, const struct linux_sys_fchown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) fd;
|
||||
syscallarg(linux_uid16_t) uid;
|
||||
syscallarg(linux_gid16_t) gid;
|
||||
} */
|
||||
struct sys___posix_fchown_args bfa;
|
||||
|
||||
SCARG(&bfa, fd) = SCARG(uap, fd);
|
||||
SCARG(&bfa, uid) = LINUXTOBSD_UID(SCARG(uap, uid));
|
||||
SCARG(&bfa, gid) = LINUXTOBSD_GID(SCARG(uap, gid));
|
||||
|
||||
return sys___posix_fchown(l, &bfa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_lchown16(struct lwp *l, const struct linux_sys_lchown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(char *) path;
|
||||
syscallarg(linux_uid16_t) uid;
|
||||
syscallarg(linux_gid16_t) gid;
|
||||
} */
|
||||
struct sys___posix_lchown_args bla;
|
||||
|
||||
SCARG(&bla, path) = SCARG(uap, path);
|
||||
SCARG(&bla, uid) = LINUXTOBSD_UID(SCARG(uap, uid));
|
||||
SCARG(&bla, gid) = LINUXTOBSD_GID(SCARG(uap, gid));
|
||||
|
||||
return sys___posix_lchown(l, &bla, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_setreuid16(struct lwp *l, const struct linux_sys_setreuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux_uid16_t) ruid;
|
||||
syscallarg(linux_uid16_t) euid;
|
||||
} */
|
||||
struct sys_setreuid_args bsa;
|
||||
|
||||
SCARG(&bsa, ruid) = LINUXTOBSD_UID(SCARG(uap, ruid));
|
||||
SCARG(&bsa, euid) = LINUXTOBSD_UID(SCARG(uap, euid));
|
||||
|
||||
return sys_setreuid(l, &bsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_setregid16(struct lwp *l, const struct linux_sys_setregid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux_gid16_t) rgid;
|
||||
syscallarg(linux_gid16_t) egid;
|
||||
} */
|
||||
struct sys_setregid_args bsa;
|
||||
|
||||
SCARG(&bsa, rgid) = LINUXTOBSD_GID(SCARG(uap, rgid));
|
||||
SCARG(&bsa, egid) = LINUXTOBSD_GID(SCARG(uap, egid));
|
||||
|
||||
return sys_setregid(l, &bsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_setresuid16(struct lwp *l, const struct linux_sys_setresuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux_uid16_t) ruid;
|
||||
syscallarg(linux_uid16_t) euid;
|
||||
syscallarg(linux_uid16_t) suid;
|
||||
} */
|
||||
struct linux_sys_setresuid_args lsa;
|
||||
|
||||
SCARG(&lsa, ruid) = LINUXTOBSD_UID(SCARG(uap, ruid));
|
||||
SCARG(&lsa, euid) = LINUXTOBSD_UID(SCARG(uap, euid));
|
||||
SCARG(&lsa, suid) = LINUXTOBSD_UID(SCARG(uap, suid));
|
||||
|
||||
return linux_sys_setresuid(l, &lsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_setresgid16(struct lwp *l, const struct linux_sys_setresgid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux_gid16_t) rgid;
|
||||
syscallarg(linux_gid16_t) egid;
|
||||
syscallarg(linux_gid16_t) sgid;
|
||||
} */
|
||||
struct linux_sys_setresgid_args lsa;
|
||||
|
||||
SCARG(&lsa, rgid) = LINUXTOBSD_GID(SCARG(uap, rgid));
|
||||
SCARG(&lsa, egid) = LINUXTOBSD_GID(SCARG(uap, egid));
|
||||
SCARG(&lsa, sgid) = LINUXTOBSD_GID(SCARG(uap, sgid));
|
||||
|
||||
return linux_sys_setresgid(l, &lsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_getresuid16(struct lwp *l, const struct linux_sys_getresuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux_uid16_t) ruid;
|
||||
syscallarg(linux_uid16_t) euid;
|
||||
syscallarg(linux_uid16_t) suid;
|
||||
} */
|
||||
kauth_cred_t pc = l->l_cred;
|
||||
int error;
|
||||
uid_t buid;
|
||||
linux_uid16_t luid;
|
||||
|
||||
buid = kauth_cred_getuid(pc);
|
||||
luid = BSDTOLINUX_UID(buid);
|
||||
if ((error = copyout(&luid, SCARG(uap, ruid), sizeof(luid))) != 0)
|
||||
return error;
|
||||
|
||||
buid = kauth_cred_geteuid(pc);
|
||||
luid = BSDTOLINUX_UID(buid);
|
||||
if ((error = copyout(&luid, SCARG(uap, euid), sizeof(luid))) != 0)
|
||||
return error;
|
||||
|
||||
buid = kauth_cred_getsvuid(pc);
|
||||
luid = BSDTOLINUX_UID(buid);
|
||||
return (copyout(&luid, SCARG(uap, suid), sizeof(luid)));
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_getresgid16(struct lwp *l, const struct linux_sys_getresgid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux_gid16_t) rgid;
|
||||
syscallarg(linux_gid16_t) egid;
|
||||
syscallarg(linux_gid16_t) sgid;
|
||||
} */
|
||||
kauth_cred_t pc = l->l_cred;
|
||||
int error;
|
||||
gid_t bgid;
|
||||
linux_gid16_t lgid;
|
||||
|
||||
bgid = kauth_cred_getgid(pc);
|
||||
lgid = BSDTOLINUX_GID(bgid);
|
||||
if ((error = copyout(&lgid, SCARG(uap, rgid), sizeof(lgid))) != 0)
|
||||
return error;
|
||||
|
||||
bgid = kauth_cred_getegid(pc);
|
||||
lgid = BSDTOLINUX_GID(bgid);
|
||||
if ((error = copyout(&lgid, SCARG(uap, egid), sizeof(lgid))) != 0)
|
||||
return error;
|
||||
|
||||
bgid = kauth_cred_getsvgid(pc);
|
||||
lgid = BSDTOLINUX_GID(bgid);
|
||||
return (copyout(&lgid, SCARG(uap, sgid), sizeof(lgid)));
|
||||
}
|
||||
#endif /* !COMPAT_LINUX32 */
|
||||
|
||||
int
|
||||
linux_sys_getgroups16(struct lwp *l, const struct linux_sys_getgroups16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux_gid16_t *) gidset;
|
||||
} */
|
||||
linux_gid16_t lset[16];
|
||||
linux_gid16_t *gidset;
|
||||
unsigned int ngrps;
|
||||
int i, n, j;
|
||||
int error;
|
||||
|
||||
ngrps = kauth_cred_ngroups(l->l_cred);
|
||||
*retval = ngrps;
|
||||
if (SCARG(uap, gidsetsize) == 0)
|
||||
return 0;
|
||||
if (SCARG(uap, gidsetsize) < ngrps)
|
||||
return EINVAL;
|
||||
|
||||
gidset = SCARG(uap, gidset);
|
||||
for (i = 0; i < (n = ngrps); i += n, gidset += n) {
|
||||
n -= i;
|
||||
if (n > __arraycount(lset))
|
||||
n = __arraycount(lset);
|
||||
for (j = 0; j < n; j++)
|
||||
lset[j] = kauth_cred_group(l->l_cred, i + j);
|
||||
error = copyout(lset, gidset, n * sizeof(lset[0]));
|
||||
if (error != 0)
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* It is very unlikly that any problem using 16bit groups is written
|
||||
* to allow for more than 16 of them, so don't bother trying to
|
||||
* support that.
|
||||
*/
|
||||
#define COMPAT_NGROUPS16 16
|
||||
|
||||
int
|
||||
linux_sys_setgroups16(struct lwp *l, const struct linux_sys_setgroups16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux_gid16_t *) gidset;
|
||||
} */
|
||||
linux_gid16_t lset[COMPAT_NGROUPS16];
|
||||
kauth_cred_t ncred;
|
||||
int error;
|
||||
gid_t grbuf[COMPAT_NGROUPS16];
|
||||
unsigned int i, ngroups = SCARG(uap, gidsetsize);
|
||||
|
||||
if (ngroups > COMPAT_NGROUPS16)
|
||||
return EINVAL;
|
||||
error = copyin(SCARG(uap, gidset), lset, ngroups);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
for (i = 0; i < ngroups; i++)
|
||||
grbuf[i] = lset[i];
|
||||
|
||||
ncred = kauth_cred_alloc();
|
||||
error = kauth_cred_setgroups(ncred, grbuf, SCARG(uap, gidsetsize),
|
||||
-1, UIO_SYSSPACE);
|
||||
if (error != 0) {
|
||||
kauth_cred_free(ncred);
|
||||
return error;
|
||||
}
|
||||
|
||||
return kauth_proc_setgroups(l, ncred);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.linux32_amd64,v 1.1 2006/02/09 19:18:57 manu Exp $
|
||||
# $NetBSD: files.linux32_amd64,v 1.2 2008/01/15 22:38:35 njoly Exp $
|
||||
#
|
||||
# Config file description for amd64-dependent Linux 32 bit compat code.
|
||||
|
||||
|
@ -7,4 +7,6 @@ file compat/linux32/arch/amd64/linux32_sysent.c compat_linux32
|
|||
file compat/linux32/arch/amd64/linux32_machdep.c compat_linux32
|
||||
file compat/linux32/arch/amd64/linux32_missing.c compat_linux32
|
||||
|
||||
file compat/linux32/common/linux32_uid16.c compat_linux32
|
||||
|
||||
file compat/linux/common/linux_oldmmap.c compat_linux32
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux32_missing.c,v 1.3 2007/07/19 22:17:23 dsl Exp $ */
|
||||
/* $NetBSD: linux32_missing.c,v 1.4 2008/01/15 22:38:35 njoly Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
|
@ -25,3 +25,4 @@
|
|||
#include <compat/linux/common/linux_llseek.c>
|
||||
#include <compat/linux/common/linux_misc_notalpha.c>
|
||||
#include <compat/linux/common/linux_misc.c>
|
||||
#include <compat/linux/common/linux_uid16.c>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux32_missing.h,v 1.4 2007/12/20 23:02:57 dsl Exp $ */
|
||||
/* $NetBSD: linux32_missing.h,v 1.5 2008/01/15 22:38:35 njoly Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
|
||||
|
@ -78,12 +78,12 @@ struct linux_sys_nice_args {
|
|||
|
||||
struct linux_sys_getgroups16_args {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux_gid_t *) gidset;
|
||||
syscallarg(linux_gid16_t *) gidset;
|
||||
};
|
||||
|
||||
struct linux_sys_setgroups16_args {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux_gid_t *) gidset;
|
||||
syscallarg(linux_gid16_t *) gidset;
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: syscalls.master,v 1.26 2008/01/07 12:11:52 njoly Exp $
|
||||
$NetBSD: syscalls.master,v 1.27 2008/01/15 22:38:35 njoly Exp $
|
||||
|
||||
; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file.
|
||||
; (See syscalls.conf to see what it is processed into.)
|
||||
|
@ -86,7 +86,7 @@
|
|||
int mode, int dev); }
|
||||
15 NOARGS { int netbsd32_chmod(const netbsd32_charp path, int mode); }
|
||||
16 STD { int linux32_sys_lchown16(const netbsd32_charp path, \
|
||||
int uid, int gid); }
|
||||
linux32_uid16_t uid, linux32_gid16_t gid); }
|
||||
17 STD { int linux32_sys_break(netbsd32_charp nsize); }
|
||||
18 OBSOL ostat
|
||||
19 NOARGS { netbsd32_long compat_43_netbsd32_olseek(int fd, \
|
||||
|
@ -148,8 +148,10 @@
|
|||
67 UNIMPL sigaction
|
||||
68 UNIMPL siggetmask
|
||||
69 UNIMPL sigsetmask
|
||||
70 STD { int linux32_sys_setreuid16(int ruid, int euid); }
|
||||
71 STD { int linux32_sys_setregid16(int rgid, int egid); }
|
||||
70 STD { int linux32_sys_setreuid16(linux32_uid16_t ruid, \
|
||||
linux32_uid16_t euid); }
|
||||
71 STD { int linux32_sys_setregid16(linux32_gid16_t rgid, \
|
||||
linux32_gid16_t egid); }
|
||||
72 UNIMPL sigsuspend
|
||||
73 UNIMPL sigpending
|
||||
74 NOARGS { int compat_43_netbsd32_osethostname(netbsd32_charp hostname, \
|
||||
|
@ -165,9 +167,9 @@
|
|||
79 STD { int linux32_sys_settimeofday(netbsd32_timevalp_t tp, \
|
||||
netbsd32_timezonep_t tzp); }
|
||||
80 STD { int linux32_sys_getgroups16(int gidsetsize, \
|
||||
linux32_gidp_t gidset); }
|
||||
linux32_gid16p_t gidset); }
|
||||
81 STD { int linux32_sys_setgroups16(int gidsetsize, \
|
||||
linux32_gidp_t gidset); }
|
||||
linux32_gid16p_t gidset); }
|
||||
82 STD { int linux32_sys_oldselect(linux32_oldselectp_t lsp); }
|
||||
83 NOARGS { int netbsd32_symlink(netbsd32_charp path, \
|
||||
const netbsd32_charp link); }
|
||||
|
@ -188,7 +190,8 @@
|
|||
93 NOARGS { int compat_43_netbsd32_oftruncate(int fd, \
|
||||
netbsd32_long length); }
|
||||
94 NOARGS { int netbsd32_fchmod(int fd, int mode); }
|
||||
95 STD { int linux32_sys_fchown16(int fd, int uid, int gid); }
|
||||
95 STD { int linux32_sys_fchown16(int fd, linux32_uid16_t uid, \
|
||||
linux32_gid16_t gid); }
|
||||
96 STD { int linux32_sys_getpriority(int which, int who); }
|
||||
97 STD { int linux32_sys_setpriority(int which, int who, int prio); }
|
||||
98 UNIMPL profil
|
||||
|
@ -276,17 +279,19 @@
|
|||
163 STD { int linux32_sys_mremap(netbsd32_voidp old_address, \
|
||||
netbsd32_size_t old_size , netbsd32_size_t new_size, \
|
||||
netbsd32_u_long flags); }
|
||||
164 STD { int linux32_sys_setresuid16(uid_t ruid, uid_t euid, \
|
||||
uid_t suid); }
|
||||
165 UNIMPL getresuid16
|
||||
164 STD { int linux32_sys_setresuid16(linux32_uid16_t ruid, \
|
||||
linux32_uid16_t euid, linux32_uid16_t suid); }
|
||||
165 STD { int linux32_sys_getresuid16(linux32_uid16p_t ruid, \
|
||||
linux32_uid16p_t euid, linux32_uid16p_t suid); }
|
||||
166 UNIMPL vm86
|
||||
167 UNIMPL query_module
|
||||
168 NOARGS { int netbsd32_poll(netbsd32_pollfdp_t fds, u_int nfds, \
|
||||
int timeout); }
|
||||
int timeout); }
|
||||
169 UNIMPL nfsservctl
|
||||
170 STD { int linux32_sys_setresgid16(gid_t rgid, gid_t egid, \
|
||||
gid_t sgid); }
|
||||
171 UNIMPL int
|
||||
170 STD { int linux32_sys_setresgid16(linux32_gid16_t rgid, \
|
||||
linux32_gid16_t egid, linux32_gid16_t sgid); }
|
||||
171 STD { int linux32_sys_getresgid16(linux32_gid16p_t rgid, \
|
||||
linux32_gid16p_t egid, linux32_gid16p_t sgid); }
|
||||
172 UNIMPL prctl
|
||||
173 STD { int linux32_sys_rt_sigreturn(linux32_ucontextp_t ucp); }
|
||||
174 STD { int linux32_sys_rt_sigaction(int signum, \
|
||||
|
@ -305,7 +310,7 @@
|
|||
180 UNIMPL pread
|
||||
181 UNIMPL pwrite
|
||||
182 STD { int linux32_sys_chown16(const netbsd32_charp path, \
|
||||
int uid, int gid); }
|
||||
linux32_uid16_t uid, linux32_gid16_t gid); }
|
||||
183 NOARGS { int netbsd32___getcwd(netbsd32_charp bufp, \
|
||||
netbsd32_size_t length); }
|
||||
184 UNIMPL capget
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux32_types.h,v 1.5 2007/12/24 15:56:21 njoly Exp $ */
|
||||
/* $NetBSD: linux32_types.h,v 1.6 2008/01/15 22:38:35 njoly Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
|
||||
|
@ -38,6 +38,9 @@
|
|||
#include <compat/linux32/arch/amd64/linux32_types.h>
|
||||
#endif
|
||||
|
||||
typedef unsigned short linux32_gid16_t;
|
||||
typedef unsigned short linux32_uid16_t;
|
||||
|
||||
typedef netbsd32_pointer_t linux32_oldmmapp;
|
||||
typedef netbsd32_pointer_t linux32_utsnamep;
|
||||
typedef netbsd32_pointer_t linux32_stat64p;
|
||||
|
@ -53,7 +56,8 @@ typedef netbsd32_pointer_t linux32_tmsp_t;
|
|||
typedef netbsd32_pointer_t linux32_sched_paramp_t;
|
||||
typedef netbsd32_pointer_t linux32_utimbufp_t;
|
||||
typedef netbsd32_pointer_t linux32_oldold_utsnamep_t;
|
||||
typedef netbsd32_pointer_t linux32_gidp_t;
|
||||
typedef netbsd32_pointer_t linux32_uid16p_t;
|
||||
typedef netbsd32_pointer_t linux32_gid16p_t;
|
||||
typedef netbsd32_pointer_t linux32_oldselectp_t;
|
||||
typedef netbsd32_pointer_t linux32_sysinfop_t;
|
||||
typedef netbsd32_pointer_t linux32_oldutsnamep_t;
|
||||
|
|
|
@ -0,0 +1,262 @@
|
|||
/* $NetBSD: linux32_uid16.c,v 1.1 2008/01/15 22:38:35 njoly Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
|
||||
* Copyright (c) 2008 Nicolas Joly, all rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Emmanuel Dreyfus
|
||||
* 4. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux32_uid16.c,v 1.1 2008/01/15 22:38:35 njoly Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kauth.h>
|
||||
|
||||
#include <compat/netbsd32/netbsd32.h>
|
||||
|
||||
#include <compat/linux/common/linux_types.h>
|
||||
#include <compat/linux/common/linux_signal.h>
|
||||
#include <compat/linux/linux_syscallargs.h>
|
||||
|
||||
#include <compat/linux32/common/linux32_types.h>
|
||||
#include <compat/linux32/common/linux32_signal.h>
|
||||
#include <compat/linux32/common/linux32_machdep.h>
|
||||
#include <compat/linux32/linux32_syscallargs.h>
|
||||
|
||||
#define LINUX32TOBSD_UID(u) \
|
||||
(((u) == (linux32_uid16_t)-1) ? -1 : (u))
|
||||
#define LINUX32TOBSD_GID(g) \
|
||||
(((g) == (linux32_gid16_t)-1) ? -1 : (g))
|
||||
|
||||
#define BSDTOLINUX32_UID(u) \
|
||||
(((u) & ~0xffff) ? (linux32_uid16_t)65534 : (linux32_uid16_t)(u))
|
||||
#define BSDTOLINUX32_GID(g) \
|
||||
(((g) & ~0xffff) ? (linux32_gid16_t)65534 : (linux32_gid16_t)(g))
|
||||
|
||||
int
|
||||
linux32_sys_chown16(struct lwp *l, const struct linux32_sys_chown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(const netbsd32_charp) path;
|
||||
syscallarg(linux32_uid16_t) uid;
|
||||
syscallarg(linux32_gid16_t) gid;
|
||||
} */
|
||||
struct sys___posix_chown_args ua;
|
||||
|
||||
NETBSD32TOP_UAP(path, const char);
|
||||
SCARG(&ua, uid) = LINUX32TOBSD_UID(SCARG(uap, uid));
|
||||
SCARG(&ua, gid) = LINUX32TOBSD_GID(SCARG(uap, gid));
|
||||
|
||||
return sys___posix_chown(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_lchown16(struct lwp *l, const struct linux32_sys_lchown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(const netbsd32_charp) path;
|
||||
syscallarg(linux32_uid16_t) uid;
|
||||
syscallarg(linux32_gid16_t) gid;
|
||||
} */
|
||||
struct sys___posix_lchown_args ua;
|
||||
|
||||
NETBSD32TOP_UAP(path, const char);
|
||||
SCARG(&ua, uid) = LINUX32TOBSD_UID(SCARG(uap, uid));
|
||||
SCARG(&ua, gid) = LINUX32TOBSD_GID(SCARG(uap, gid));
|
||||
|
||||
return sys___posix_lchown(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_fchown16(struct lwp *l, const struct linux32_sys_fchown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) fd;
|
||||
syscallarg(linux32_uid16_t) uid;
|
||||
syscallarg(linux32_gid16_t) gid;
|
||||
} */
|
||||
struct sys___posix_fchown_args ua;
|
||||
|
||||
SCARG(&ua, fd) = SCARG(uap, fd);
|
||||
SCARG(&ua, uid) = LINUX32TOBSD_UID(SCARG(uap, uid));
|
||||
SCARG(&ua, gid) = LINUX32TOBSD_GID(SCARG(uap, gid));
|
||||
|
||||
return sys___posix_fchown(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_getgroups16(struct lwp *l, const struct linux32_sys_getgroups16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux32_gid16p_t) gidset;
|
||||
} */
|
||||
struct linux_sys_getgroups16_args ua;
|
||||
|
||||
NETBSD32TO64_UAP(gidsetsize);
|
||||
NETBSD32TOP_UAP(gidset, linux_gid16_t);
|
||||
|
||||
return linux_sys_getgroups16(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setgroups16(struct lwp *l, const struct linux32_sys_setgroups16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux32_gid16p_t) gidset;
|
||||
} */
|
||||
struct linux_sys_setgroups16_args ua;
|
||||
|
||||
NETBSD32TO64_UAP(gidsetsize);
|
||||
NETBSD32TOP_UAP(gidset, linux_gid16_t);
|
||||
|
||||
return linux_sys_setgroups16(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setreuid16(struct lwp *l, const struct linux32_sys_setreuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux32_uid16_t) ruid;
|
||||
syscallarg(linux32_uid16_t) euid;
|
||||
} */
|
||||
struct sys_setreuid_args bsa;
|
||||
|
||||
SCARG(&bsa, ruid) = LINUX32TOBSD_UID(SCARG(uap, ruid));
|
||||
SCARG(&bsa, euid) = LINUX32TOBSD_UID(SCARG(uap, euid));
|
||||
|
||||
return sys_setreuid(l, &bsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setregid16(struct lwp *l, const struct linux32_sys_setregid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux32_gid16_t) rgid;
|
||||
syscallarg(linux32_gid16_t) egid;
|
||||
} */
|
||||
struct sys_setregid_args bsa;
|
||||
|
||||
SCARG(&bsa, rgid) = LINUX32TOBSD_GID(SCARG(uap, rgid));
|
||||
SCARG(&bsa, egid) = LINUX32TOBSD_GID(SCARG(uap, egid));
|
||||
|
||||
return sys_setregid(l, &bsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setresuid16(struct lwp *l, const struct linux32_sys_setresuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux32_uid16_t) ruid;
|
||||
syscallarg(linux32_uid16_t) euid;
|
||||
syscallarg(linux32_uid16_t) suid;
|
||||
} */
|
||||
struct linux32_sys_setresuid_args lsa;
|
||||
|
||||
SCARG(&lsa, ruid) = LINUX32TOBSD_UID(SCARG(uap, ruid));
|
||||
SCARG(&lsa, euid) = LINUX32TOBSD_UID(SCARG(uap, euid));
|
||||
SCARG(&lsa, suid) = LINUX32TOBSD_UID(SCARG(uap, suid));
|
||||
|
||||
return linux32_sys_setresuid(l, &lsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setresgid16(struct lwp *l, const struct linux32_sys_setresgid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux32_gid16_t) rgid;
|
||||
syscallarg(linux32_gid16_t) egid;
|
||||
syscallarg(linux32_gid16_t) sgid;
|
||||
} */
|
||||
struct linux32_sys_setresgid_args lsa;
|
||||
|
||||
SCARG(&lsa, rgid) = LINUX32TOBSD_GID(SCARG(uap, rgid));
|
||||
SCARG(&lsa, egid) = LINUX32TOBSD_GID(SCARG(uap, egid));
|
||||
SCARG(&lsa, sgid) = LINUX32TOBSD_GID(SCARG(uap, sgid));
|
||||
|
||||
return linux32_sys_setresgid(l, &lsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_getresuid16(struct lwp *l, const struct linux32_sys_getresuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux32_uid16p_t) ruid;
|
||||
syscallarg(linux32_uid16p_t) euid;
|
||||
syscallarg(linux32_uid16p_t) suid;
|
||||
} */
|
||||
kauth_cred_t pc = l->l_cred;
|
||||
int error;
|
||||
uid_t buid;
|
||||
linux32_uid16_t luid;
|
||||
|
||||
buid = kauth_cred_getuid(pc);
|
||||
luid = BSDTOLINUX32_UID(buid);
|
||||
if ((error = copyout(&luid, SCARG_P32(uap, ruid), sizeof(luid))) != 0)
|
||||
return error;
|
||||
|
||||
buid = kauth_cred_geteuid(pc);
|
||||
luid = BSDTOLINUX32_UID(buid);
|
||||
if ((error = copyout(&luid, SCARG_P32(uap, euid), sizeof(luid))) != 0)
|
||||
return error;
|
||||
|
||||
buid = kauth_cred_getsvuid(pc);
|
||||
luid = BSDTOLINUX32_UID(buid);
|
||||
return (copyout(&luid, SCARG_P32(uap, suid), sizeof(luid)));
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_getresgid16(struct lwp *l, const struct linux32_sys_getresgid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(linux32_gid16p_t) rgid;
|
||||
syscallarg(linux32_gid16p_t) egid;
|
||||
syscallarg(linux32_gid16p_t) sgid;
|
||||
} */
|
||||
kauth_cred_t pc = l->l_cred;
|
||||
int error;
|
||||
gid_t bgid;
|
||||
linux32_gid16_t lgid;
|
||||
|
||||
bgid = kauth_cred_getgid(pc);
|
||||
lgid = BSDTOLINUX32_GID(bgid);
|
||||
if ((error = copyout(&lgid, SCARG_P32(uap, rgid), sizeof(lgid))) != 0)
|
||||
return error;
|
||||
|
||||
bgid = kauth_cred_getegid(pc);
|
||||
lgid = BSDTOLINUX32_GID(bgid);
|
||||
if ((error = copyout(&lgid, SCARG_P32(uap, egid), sizeof(lgid))) != 0)
|
||||
return error;
|
||||
|
||||
bgid = kauth_cred_getsvgid(pc);
|
||||
lgid = BSDTOLINUX32_GID(bgid);
|
||||
return (copyout(&lgid, SCARG_P32(uap, sgid), sizeof(lgid)));
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux32_unistd.c,v 1.18 2007/12/21 22:26:22 njoly Exp $ */
|
||||
/* $NetBSD: linux32_unistd.c,v 1.19 2008/01/15 22:38:36 njoly Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.18 2007/12/21 22:26:22 njoly Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.19 2008/01/15 22:38:36 njoly Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -292,56 +292,6 @@ linux32_sys_mknod(struct lwp *l, const struct linux32_sys_mknod_args *uap, regis
|
|||
return linux_sys_mknod(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_chown16(struct lwp *l, const struct linux32_sys_chown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(const netbsd32_charp) path;
|
||||
syscallarg(int) uid;
|
||||
syscallarg(int) gid;
|
||||
} */
|
||||
struct sys___posix_chown_args ua;
|
||||
|
||||
NETBSD32TOP_UAP(path, const char);
|
||||
|
||||
if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
|
||||
SCARG(&ua, uid) = (uid_t)-1;
|
||||
else
|
||||
SCARG(&ua, uid) = SCARG(uap, uid);
|
||||
|
||||
if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
|
||||
SCARG(&ua, gid) = (gid_t)-1;
|
||||
else
|
||||
SCARG(&ua, gid) = SCARG(uap, gid);
|
||||
|
||||
return sys___posix_chown(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_lchown16(struct lwp *l, const struct linux32_sys_lchown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(const netbsd32_charp) path;
|
||||
syscallarg(int) uid;
|
||||
syscallarg(int) gid;
|
||||
} */
|
||||
struct sys___posix_lchown_args ua;
|
||||
|
||||
NETBSD32TOP_UAP(path, const char);
|
||||
|
||||
if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
|
||||
SCARG(&ua, uid) = (uid_t)-1;
|
||||
else
|
||||
SCARG(&ua, uid) = SCARG(uap, uid);
|
||||
|
||||
if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
|
||||
SCARG(&ua, gid) = (gid_t)-1;
|
||||
else
|
||||
SCARG(&ua, gid) = SCARG(uap, gid);
|
||||
|
||||
return sys___posix_lchown(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_break(struct lwp *l, const struct linux32_sys_break_args *uap, register_t *retval)
|
||||
{
|
||||
|
@ -369,36 +319,6 @@ linux32_sys_rename(struct lwp *l, const struct linux32_sys_rename_args *uap, reg
|
|||
return sys___posix_rename(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_getgroups16(struct lwp *l, const struct linux32_sys_getgroups16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux32_gidp_t) gidset;
|
||||
} */
|
||||
struct linux_sys_getgroups16_args ua;
|
||||
|
||||
NETBSD32TO64_UAP(gidsetsize);
|
||||
NETBSD32TOP_UAP(gidset, linux_gid_t);
|
||||
|
||||
return linux_sys_getgroups16(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setgroups16(struct lwp *l, const struct linux32_sys_setgroups16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) gidsetsize;
|
||||
syscallarg(linux32_gidp_t) gidset;
|
||||
} */
|
||||
struct linux_sys_setgroups16_args ua;
|
||||
|
||||
NETBSD32TO64_UAP(gidsetsize);
|
||||
NETBSD32TOP_UAP(gidset, linux_gid_t);
|
||||
|
||||
return linux_sys_setgroups16(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_swapon(struct lwp *l, const struct linux32_sys_swapon_args *uap, register_t *retval)
|
||||
{
|
||||
|
@ -463,31 +383,6 @@ linux32_sys_truncate(struct lwp *l, const struct linux32_sys_truncate_args *uap,
|
|||
return compat_43_sys_truncate(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_fchown16(struct lwp *l, const struct linux32_sys_fchown16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) fd;
|
||||
syscallarg(int) uid;
|
||||
syscallarg(int) gid;
|
||||
} */
|
||||
struct sys___posix_fchown_args ua;
|
||||
|
||||
SCARG(&ua, fd) = SCARG(uap, fd);
|
||||
|
||||
if ((linux32_uid_t)SCARG(uap, uid) == (linux32_uid_t)-1)
|
||||
SCARG(&ua, uid) = (uid_t)-1;
|
||||
else
|
||||
SCARG(&ua, uid) = SCARG(uap, uid);
|
||||
|
||||
if ((linux32_gid_t)SCARG(uap, gid) == (linux32_gid_t)-1)
|
||||
SCARG(&ua, gid) = (gid_t)-1;
|
||||
else
|
||||
SCARG(&ua, gid) = SCARG(uap, gid);
|
||||
|
||||
return sys___posix_fchown(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setresuid(struct lwp *l, const struct linux32_sys_setresuid_args *uap, register_t *retval)
|
||||
{
|
||||
|
@ -588,97 +483,3 @@ linux32_sys_setfsgid(struct lwp *l, const struct linux32_sys_setfsgid_args *uap,
|
|||
|
||||
return linux_sys_setfsgid(l, &ua, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setreuid16(struct lwp *l, const struct linux32_sys_setreuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) ruid;
|
||||
syscallarg(int) euid;
|
||||
} */
|
||||
struct sys_setreuid_args bsa;
|
||||
|
||||
if ((linux32_uid_t)SCARG(uap, ruid) == (linux32_uid_t)-1)
|
||||
SCARG(&bsa, ruid) = (uid_t)-1;
|
||||
else
|
||||
SCARG(&bsa, ruid) = SCARG(uap, ruid);
|
||||
if ((linux32_uid_t)SCARG(uap, euid) == (linux32_uid_t)-1)
|
||||
SCARG(&bsa, euid) = (uid_t)-1;
|
||||
else
|
||||
SCARG(&bsa, euid) = SCARG(uap, euid);
|
||||
|
||||
return sys_setreuid(l, &bsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setregid16(struct lwp *l, const struct linux32_sys_setregid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(int) rgid;
|
||||
syscallarg(int) egid;
|
||||
} */
|
||||
struct sys_setregid_args bsa;
|
||||
|
||||
if ((linux32_gid_t)SCARG(uap, rgid) == (linux32_gid_t)-1)
|
||||
SCARG(&bsa, rgid) = (gid_t)-1;
|
||||
else
|
||||
SCARG(&bsa, rgid) = SCARG(uap, rgid);
|
||||
if ((linux32_gid_t)SCARG(uap, egid) == (linux32_gid_t)-1)
|
||||
SCARG(&bsa, egid) = (gid_t)-1;
|
||||
else
|
||||
SCARG(&bsa, egid) = SCARG(uap, egid);
|
||||
|
||||
return sys_setregid(l, &bsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setresuid16(struct lwp *l, const struct linux32_sys_setresuid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(uid_t) ruid;
|
||||
syscallarg(uid_t) euid;
|
||||
syscallarg(uid_t) suid;
|
||||
} */
|
||||
struct linux32_sys_setresuid_args lsa;
|
||||
|
||||
if ((linux32_uid_t)SCARG(uap, ruid) == (linux32_uid_t)-1)
|
||||
SCARG(&lsa, ruid) = (uid_t)-1;
|
||||
else
|
||||
SCARG(&lsa, ruid) = SCARG(uap, ruid);
|
||||
if ((linux32_uid_t)SCARG(uap, euid) == (linux32_uid_t)-1)
|
||||
SCARG(&lsa, euid) = (uid_t)-1;
|
||||
else
|
||||
SCARG(&lsa, euid) = SCARG(uap, euid);
|
||||
if ((linux32_uid_t)SCARG(uap, suid) == (linux32_uid_t)-1)
|
||||
SCARG(&lsa, suid) = (uid_t)-1;
|
||||
else
|
||||
SCARG(&lsa, suid) = SCARG(uap, euid);
|
||||
|
||||
return linux32_sys_setresuid(l, &lsa, retval);
|
||||
}
|
||||
|
||||
int
|
||||
linux32_sys_setresgid16(struct lwp *l, const struct linux32_sys_setresgid16_args *uap, register_t *retval)
|
||||
{
|
||||
/* {
|
||||
syscallarg(gid_t) rgid;
|
||||
syscallarg(gid_t) egid;
|
||||
syscallarg(gid_t) sgid;
|
||||
} */
|
||||
struct linux32_sys_setresgid_args lsa;
|
||||
|
||||
if ((linux32_gid_t)SCARG(uap, rgid) == (linux32_gid_t)-1)
|
||||
SCARG(&lsa, rgid) = (gid_t)-1;
|
||||
else
|
||||
SCARG(&lsa, rgid) = SCARG(uap, rgid);
|
||||
if ((linux32_gid_t)SCARG(uap, egid) == (linux32_gid_t)-1)
|
||||
SCARG(&lsa, egid) = (gid_t)-1;
|
||||
else
|
||||
SCARG(&lsa, egid) = SCARG(uap, egid);
|
||||
if ((linux32_gid_t)SCARG(uap, sgid) == (linux32_gid_t)-1)
|
||||
SCARG(&lsa, sgid) = (gid_t)-1;
|
||||
else
|
||||
SCARG(&lsa, sgid) = SCARG(uap, sgid);
|
||||
|
||||
return linux32_sys_setresgid(l, &lsa, retval);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue