summaryrefslogtreecommitdiff
path: root/sys/kern/kern_prot.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_prot.c')
-rw-r--r--sys/kern/kern_prot.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index 38a789ffc9d..6eb98c91f4c 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_prot.c,v 1.14 2000/11/08 21:27:03 art Exp $ */
+/* $OpenBSD: kern_prot.c,v 1.15 2001/06/18 13:18:36 art Exp $ */
/* $NetBSD: kern_prot.c,v 1.33 1996/02/09 18:59:42 christos Exp $ */
/*
@@ -53,6 +53,7 @@
#include <sys/timeb.h>
#include <sys/times.h>
#include <sys/malloc.h>
+#include <sys/filedesc.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
@@ -655,3 +656,20 @@ sys_setlogin(p, v, retval)
error = EINVAL;
return (error);
}
+
+/*
+ * Check if a process is allowed to raise its privileges.
+ */
+int
+proc_cansugid(struct proc *p)
+{
+ /* ptrace(2)d processes shouldn't. */
+ if ((p->p_flag & P_TRACED) != 0)
+ return (EPERM);
+
+ /* proceses with shared filedescriptors shouldn't. */
+ if (p->p_fd->fd_refcnt > 1)
+ return (EPERM);
+
+ return (0);
+}