From ecc8a52f8259d58fe5ccc66e7a28502f54ced094 Mon Sep 17 00:00:00 2001 From: Thomas Veerman Date: Thu, 15 Jul 2010 13:24:57 +0000 Subject: [PATCH] Add getnucred system call. Contributed by Thomas Cort --- include/minix/com.h | 3 +++ lib/libc/other/Makefile.inc | 1 + lib/libc/other/_getnucred.c | 29 +++++++++++++++++++++++++++++ lib/libc/syscall/Makefile.inc | 1 + lib/libc/syscall/getnucred.S | 7 +++++++ 5 files changed, 41 insertions(+) create mode 100644 lib/libc/other/_getnucred.c create mode 100644 lib/libc/syscall/getnucred.S diff --git a/include/minix/com.h b/include/minix/com.h index 8596ba853..16526b20d 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -876,6 +876,9 @@ #define PM_ENDPT m1_i1 #define PM_PENDPT m1_i2 +#define PM_NUID m2_i1 +#define PM_NGID m2_i2 + /* Field names for GETSYSINFO_UP (PM). */ #define SIU_WHAT m2_i1 #define SIU_LEN m2_i2 diff --git a/lib/libc/other/Makefile.inc b/lib/libc/other/Makefile.inc index 14a63ab78..ffe2a0bef 100644 --- a/lib/libc/other/Makefile.inc +++ b/lib/libc/other/Makefile.inc @@ -13,6 +13,7 @@ SRCS+= \ _getdents.c \ _getdma.c \ _getnpid.c \ + _getnucred.c \ _getnuid.c \ _getngid.c \ _getnprocnr.c \ diff --git a/lib/libc/other/_getnucred.c b/lib/libc/other/_getnucred.c new file mode 100644 index 000000000..4c71aa70f --- /dev/null +++ b/lib/libc/other/_getnucred.c @@ -0,0 +1,29 @@ +#include +#define getnucred _getnucred +#include +#include +#include + +PUBLIC int getnucred(endpoint_t proc_ep, struct ucred *ucred) +{ + message m; + pid_t pid; + + if (ucred == NULL) { + errno = EFAULT; + return -1; + } + + m.m1_i1 = proc_ep; /* search for this process */ + + pid = _syscall(PM_PROC_NR, GETEPINFO, &m); + if (pid < 0) { + return -1; + } + + ucred->pid = pid; + ucred->uid = m.PM_NUID; + ucred->gid = m.PM_NGID; + + return 0; +} diff --git a/lib/libc/syscall/Makefile.inc b/lib/libc/syscall/Makefile.inc index f0d177fb0..05ed54ebf 100644 --- a/lib/libc/syscall/Makefile.inc +++ b/lib/libc/syscall/Makefile.inc @@ -46,6 +46,7 @@ SRCS+= \ getgroups.S \ getitimer.S \ getnpid.S \ + getnucred.S \ getnuid.S \ getngid.S \ getnprocnr.S \ diff --git a/lib/libc/syscall/getnucred.S b/lib/libc/syscall/getnucred.S new file mode 100644 index 000000000..4e436e649 --- /dev/null +++ b/lib/libc/syscall/getnucred.S @@ -0,0 +1,7 @@ +.text +.extern __getnucred +.globl _getnucred +.balign 2 + +_getnucred: + jmp __getnucred -- 2.44.0