2 .\" Copyright (c) 1996 Julian R Elischer
3 .\" All rights reserved.
5 .\" This code is derived from software contributed by Kenneth Stailey.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
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.
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
42 .Nd check if credentials have superuser privileges
47 .Fn suser "struct thread *td"
49 .Fn suser_cred "struct ucred *cred" "int flag"
55 functions check if the credentials given include superuser powers.
59 function is the most common, and should be used unless special
60 circumstances dictate otherwise.
64 function should be used when the credentials to be checked are
65 not the thread's own, when there is no thread, when superuser
66 powers should be extended to imprisoned roots, or when the credential
67 to be checked is the real user rather than the effective user.
69 By default, a process does not command superuser powers if it has
70 been imprisoned by the
73 There are cases however where this is appropriate, and this can
81 It is important to review carefully in each case that
82 this does not weaken the prison.
83 Generally, only where the action is protected by
87 call should such powers be granted.
89 By default, the credential checked is the effective user.
91 where it is instead necessary to check the real user (for example, when
92 determining if resource limits should be applied), and this can be done
105 functions note the fact that superuser powers have been used in the
106 process structure of the process specified.
107 Because part of their function is to notice
108 whether superuser powers have been used,
109 the functions should only be called after other permission
110 possibilities have been exhausted.
116 functions return 0 if the user has superuser powers and
121 of some other implementations of
123 in which a TRUE response indicates superuser powers.
132 functions do not, in fact, record that superuser privileges have been
133 used, and have not done so since August 2000.