Update the DELAY(9) manual page about the header file where
[dragonfly.git] / share / man / man9 / suser.9
1 .\"
2 .\" Copyright (c) 1996 Julian R Elischer
3 .\" All rights reserved.
4 .\"
5 .\" This code is derived from software contributed by Kenneth Stailey.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\"    must display the following acknowledgement:
17 .\"     This product includes software developed for the FreeBSD Project
18 .\"     by Julian R Elischer
19 .\" 4. The name of the author may not be used to endorse or promote products
20 .\"    derived from this software without specific prior written permission.
21 .\"
22 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" SUCH DAMAGE.
33 .\"
34 .\" $FreeBSD: src/share/man/man9/suser.9,v 1.9.2.5 2001/12/17 11:30:19 ru Exp $
35 .\" $DragonFly: src/share/man/man9/suser.9,v 1.2 2003/06/17 04:37:01 dillon Exp $
36 .\"
37 .Dd October 15, 1996
38 .Dt SUSER 9
39 .Os
40 .Sh NAME
41 .Nm suser
42 .Nd check if we are superuser and note
43 .Sh SYNOPSIS
44 .In sys/param.h
45 .In sys/proc.h
46 .In sys/ucred.h
47 .Ft int
48 .Fn suser "struct proc *proc"
49 .Ft int
50 .Fn suser_xxx "struct ucred *cred" "struct proc *proc" "int flags"
51 .Sh DESCRIPTION
52 The
53 .Nm
54 and
55 .Nm suser_xxx
56 functions checks if the credentials given include superuser powers.
57 .Pp
58 The
59 .Nm
60 function is the most common, and should be used unless special
61 circumstances dictate otherwise.
62 .Pp
63 The
64 .Nm suser_xxx
65 function should be used when the credentials to be checked are
66 not the process' own, when there is no process or when superuser
67 powers should be extended to imprisoned roots.
68 .Pp
69 By default a process does not command superuser powers if it has
70 been imprisoned by the
71 .Xr jail 2
72 system call.
73 There are cases however where this is appropriate, and this can
74 be done by setting the
75 .Dv PRISON_ROOT
76 bit in the flags argument to the
77 .Nm suser_xxx
78 function.  It is important to review carefully in each case that
79 this does not weaken the prison.  Generally only where the action
80 is protected by the
81 .Xr chroot 2
82 implicit in
83 .Xr jail 2
84 call should such powers be granted.
85 .Pp
86 The
87 .Nm
88 and
89 .Nm suser_xxx
90 functions note the fact that superuser powers have been used in the
91 process structure of the process specified.
92 Because part of their function is to notice
93 whether superuser powers have been used,
94 the functions should only be called after other permission
95 possibilities have been exhausted.
96 .Sh RETURN VALUES
97 The
98 .Nm
99 and
100 .Nm suser_xxx
101 functions return 0 if the user has superuser powers and
102 .Er EPERM
103 otherwise.
104 This is the
105 .Em reverse logic
106 of some other implementations of
107 .Nm
108 in which a TRUE response indicates superuser powers.