Add getres{uid,gid} syscalls.

This commit is contained in:
njoly 2008-12-05 23:30:19 +00:00
parent ba7207e4b2
commit 533a52241a
3 changed files with 59 additions and 6 deletions

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.41 2008/12/01 14:18:44 njoly Exp $
$NetBSD: syscalls.master,v 1.42 2008/12/05 23:30:19 njoly Exp $
; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file.
; (See syscalls.conf to see what it is processed into.)
@ -355,10 +355,12 @@
207 NOARGS { int netbsd32___posix_fchown(int fd, uid_t uid, gid_t gid); }
208 STD { int linux32_sys_setresuid(uid_t ruid, uid_t euid, \
uid_t suid); }
209 UNIMPL getresuid
209 STD { int linux32_sys_getresuid(linux32_uidp_t ruid, \
linux32_uidp_t euid, linux32_uidp_t suid); }
210 STD { int linux32_sys_setresgid(gid_t rgid, gid_t egid, \
gid_t sgid); }
211 UNIMPL getresgid
211 STD { int linux32_sys_getresgid(linux32_gidp_t rgid, \
linux32_gidp_t egid, linux32_gidp_t sgid); }
212 NOARGS { int netbsd32___posix_chown(netbsd32_charp path, \
uid_t uid, gid_t gid); }
213 NOARGS { int netbsd32_setuid(uid_t uid); }

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux32_types.h,v 1.8 2008/09/04 17:45:00 njoly Exp $ */
/* $NetBSD: linux32_types.h,v 1.9 2008/12/05 23:30:19 njoly Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@ -56,6 +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_uidp_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;

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux32_unistd.c,v 1.25 2008/11/19 18:36:04 ad Exp $ */
/* $NetBSD: linux32_unistd.c,v 1.26 2008/12/05 23:30:19 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.25 2008/11/19 18:36:04 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.26 2008/12/05 23:30:19 njoly Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.25 2008/11/19 18:36:04 ad Exp $
#include <sys/proc.h>
#include <sys/ucred.h>
#include <sys/swap.h>
#include <sys/kauth.h>
#include <machine/types.h>
@ -370,6 +371,30 @@ linux32_sys_setresuid(struct lwp *l, const struct linux32_sys_setresuid_args *ua
return linux_sys_setresuid(l, &ua, retval);
}
int
linux32_sys_getresuid(struct lwp *l, const struct linux32_sys_getresuid_args *uap, register_t *retval)
{
/* {
syscallarg(linux32_uidp_t) ruid;
syscallarg(linux32_uidp_t) euid;
syscallarg(linux32_uidp_t) suid;
} */
kauth_cred_t pc = l->l_cred;
int error;
uid_t uid;
uid = kauth_cred_getuid(pc);
if ((error = copyout(&uid, SCARG_P32(uap, ruid), sizeof(uid_t))) != 0)
return error;
uid = kauth_cred_geteuid(pc);
if ((error = copyout(&uid, SCARG_P32(uap, euid), sizeof(uid_t))) != 0)
return error;
uid = kauth_cred_getsvuid(pc);
return copyout(&uid, SCARG_P32(uap, suid), sizeof(uid_t));
}
int
linux32_sys_setresgid(struct lwp *l, const struct linux32_sys_setresgid_args *uap, register_t *retval)
{
@ -387,6 +412,30 @@ linux32_sys_setresgid(struct lwp *l, const struct linux32_sys_setresgid_args *ua
return linux_sys_setresgid(l, &ua, retval);
}
int
linux32_sys_getresgid(struct lwp *l, const struct linux32_sys_getresgid_args *uap, register_t *retval)
{
/* {
syscallarg(linux32_gidp_t) rgid;
syscallarg(linux32_gidp_t) egid;
syscallarg(linux32_gidp_t) sgid;
} */
kauth_cred_t pc = l->l_cred;
int error;
gid_t gid;
gid = kauth_cred_getgid(pc);
if ((error = copyout(&gid, SCARG_P32(uap, rgid), sizeof(gid_t))) != 0)
return error;
gid = kauth_cred_getegid(pc);
if ((error = copyout(&gid, SCARG_P32(uap, egid), sizeof(gid_t))) != 0)
return error;
gid = kauth_cred_getsvgid(pc);
return copyout(&gid, SCARG_P32(uap, sgid), sizeof(gid_t));
}
int
linux32_sys_nice(struct lwp *l, const struct linux32_sys_nice_args *uap, register_t *retval)
{