Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Add pgid_in_session() for validating TIOCSPGRP requ...
details: https://anonhg.NetBSD.org/src/rev/13fac1cb4b73
branches: trunk
changeset: 544138:13fac1cb4b73
user: dsl <dsl%NetBSD.org@localhost>
date: Wed Mar 12 22:54:44 2003 +0000
description:
Add pgid_in_session() for validating TIOCSPGRP requests
(approved by christos)
diffstat:
sys/kern/kern_proc.c | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diffs (51 lines):
diff -r d18e309ab5cd -r 13fac1cb4b73 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Wed Mar 12 22:46:25 2003 +0000
+++ b/sys/kern/kern_proc.c Wed Mar 12 22:54:44 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.59 2003/03/12 16:39:01 dsl Exp $ */
+/* $NetBSD: kern_proc.c,v 1.60 2003/03/12 22:54:44 dsl Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.59 2003/03/12 16:39:01 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.60 2003/03/12 22:54:44 dsl Exp $");
#include "opt_kstack.h"
@@ -329,6 +329,32 @@
}
/*
+ * Check that the specifies process group in in the session of the
+ * specified process.
+ * Treats -ve ids as process ids.
+ * Used to validate TIOCSPGRP requests.
+ */
+int
+pgid_in_session(struct proc *p, pid_t pg_id)
+{
+ struct pgrp *pgrp;
+
+ if (pg_id < 0) {
+ struct proc *p1 = pfind(-pg_id);
+ if (p1 == NULL)
+ return EINVAL;
+ pgrp = p1->p_pgrp;
+ } else {
+ pgrp = pgfind(pg_id);
+ if (pgrp == NULL)
+ return EINVAL;
+ }
+ if (pgrp->pg_session != p->p_pgrp->pg_session)
+ return EPERM;
+ return 0;
+}
+
+/*
* Is p an inferior of q?
*/
int
Home |
Main Index |
Thread Index |
Old Index