From d2279fb6e2482b1a5f7780b7a6bf0f393e6040f3 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Thu, 13 Nov 1997 07:11:15 +0000 Subject: add getsid(2), XPG4 --- sys/kern/kern_prot.c | 23 +++++++++++++++++++++-- sys/kern/syscalls.master | 3 ++- 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'sys') diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 49edc5f2f86..d14fc931dac 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_prot.c,v 1.10 1997/09/02 08:48:32 downsj Exp $ */ +/* $OpenBSD: kern_prot.c,v 1.11 1997/11/13 07:11:11 deraadt Exp $ */ /* $NetBSD: kern_prot.c,v 1.33 1996/02/09 18:59:42 christos Exp $ */ /* @@ -119,6 +119,25 @@ found: return 0; } +int +sys_getsid(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + register struct sys_getsid_args /* { + syscallarg(pid_t) pid; + } */ *uap = v; + + if (SCARG(uap, pid) == 0) + goto found; + if ((p == pfind(SCARG(uap, pid))) == 0) + return (ESRCH); +found: + *retval = p->p_pgrp->pg_session->s_leader->p_pid; + return 0; +} + /* ARGSUSED */ int sys_getuid(p, v, retval) @@ -289,7 +308,7 @@ sys_setpgid(curp, v, retval) SCARG(uap, pgid) = targp->p_pid; else if (SCARG(uap, pgid) != targp->p_pid) if ((pgrp = pgfind(SCARG(uap, pgid))) == 0 || - pgrp->pg_session != curp->p_session) + pgrp->pg_session != curp->p_session) return (EPERM); return (enterpgrp(targp, SCARG(uap, pgid), 0)); } diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index d0ea958d481..8794f0f6483 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ - $OpenBSD: syscalls.master,v 1.16 1997/08/29 20:44:24 kstailey Exp $ + $OpenBSD: syscalls.master,v 1.17 1997/11/13 07:11:12 deraadt Exp $ ; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -463,3 +463,4 @@ unsigned long nfds, int timeout); } 253 STD { int sys_issetugid(void); } 254 STD { int sys_lchown(char *path, int uid, int gid); } +255 STD { int sys_getsid(pid_t pid); } -- cgit v1.2.3