]> git.ipfire.org Git - thirdparty/util-linux.git/blame - sys-utils/setpriv.1
Manual pages: use the term "exit status"
[thirdparty/util-linux.git] / sys-utils / setpriv.1
CommitLineData
cf8e0bae 1.TH SETPRIV 1 "July 2014" "util-linux" "User Commands"
5600c405
AL
2.SH NAME
3setpriv \- run a program with different Linux privilege settings
4.SH SYNOPSIS
5.B setpriv
cf8e0bae
BS
6[options]
7.I program
5600c405
AL
8.RI [ arguments ]
9.SH DESCRIPTION
10Sets or queries various Linux privilege settings that are inherited across
11.BR execve (2).
c424fd83 12.PP
64eca640
SM
13In comparison to
14.BR su (1)
15and
16.BR runuser (1),
17.BR setpriv (1)
18neither uses PAM, nor does it prompt for a password.
1aed71e5 19It is a simple, non-set-user-ID wrapper around
64eca640
SM
20.BR execve (2),
21and can be used to drop privileges in the same way as
22.BR setuidgid (8)
23from
24.BR daemontools ,
25.BR chpst (8)
26from
27.BR runit ,
28or similar tools shipped by other service managers.
8715ec4d 29.SH OPTIONS
5600c405 30.TP
5e43af7e
BS
31.B \-\-clear\-groups
32Clear supplementary groups.
33.TP
34.BR \-d , " \-\-dump"
cf8e0bae
BS
35Dump current privilege state. Can be specified more than once to show extra,
36mostly useless, information. Incompatible with all other options.
5600c405 37.TP
5e43af7e 38.B \-\-groups \fIgroup\fR...
85c15c1f 39Set supplementary groups. The argument is a comma-separated list of GIDs or names.
5600c405 40.TP
0c92194e
PS
41.BR \-\-inh\-caps " (" + | \- ) \fIcap "... or " \-\-ambient-caps " (" + | \- ) \fIcap "... or " \-\-bounding\-set " (" + | \- ) \fIcap ...
42Set the inheritable capabilities, ambient capabilities or the capability bounding set. See
5600c405
AL
43.BR capabilities (7).
44The argument is a comma-separated list of
cf8e0bae 45.BI + cap
5600c405 46and
cf8e0bae 47.BI \- cap
55b3fe78
PS
48entries, which add or remove an entry respectively. \fIcap\fR can either be a
49human-readable name as seen in
50.BR capabilities (7)
51without the \fIcap_\fR prefix or of the format
52.BI cap_N ,
53where \fIN\fR is the internal capability index used by Linux.
cf8e0bae 54.B +all
5600c405 55and
cf8e0bae 56.B \-all
5600c405
AL
57can be used to add or remove all caps. The set of capabilities starts out as
58the current inheritable set for
0c92194e
PS
59.BR \-\-inh\-caps ,
60the current ambient set for
61.B \-\-ambient\-caps
5600c405 62and the current bounding set for
cf8e0bae 63.BR \-\-bounding\-set .
5600c405
AL
64If you drop something from the bounding set without also dropping it from the
65inheritable set, you are likely to become confused. Do not do that.
66.TP
5e43af7e
BS
67.B \-\-keep\-groups
68Preserve supplementary groups. Only useful in conjunction with
69.BR \-\-rgid ,
70.BR \-\-egid ", or"
71.BR \-\-regid .
72.TP
94826d0d
SS
73.B \-\-init\-groups
74Initialize supplementary groups using
75.BR initgroups "(3)."
76Only useful in conjunction with
0bb7e904 77.B \-\-ruid
94826d0d
SS
78or
79.BR \-\-reuid .
80.TP
0bb7e904 81.B \-\-list\-caps
cf8e0bae 82List all known capabilities. This option must be specified alone.
5600c405 83.TP
b06c1ca6 84.B \-\-no\-new\-privs
5e43af7e
BS
85Set the
86.I no_new_privs
87bit. With this bit set,
88.BR execve (2)
aedd46f6
MK
89will not grant new privileges.
90For example, the set-user-ID and set-group-ID bits as well
5e43af7e
BS
91as file capabilities will be disabled. (Executing binaries with these bits set
92will still work, but they will not gain privileges. Certain LSMs, especially
93AppArmor, may result in failures to execute certain programs.) This bit is
94inherited by child processes and cannot be unset. See
95.BR prctl (2)
96and
0bb7e904 97.I Documentation/\:prctl/\:no_\:new_\:privs.txt
5e43af7e
BS
98in the Linux kernel source.
99.sp
100The no_new_privs bit is supported since Linux 3.5.
101.TP
102.BI \-\-rgid " gid\fR, " \-\-egid " gid\fR, " \-\-regid " gid"
a72fa61a 103Set the real, effective, or both GIDs. The \fIgid\fR argument can be
5e43af7e
BS
104given as textual group name.
105.sp
106For safety, you must specify one of
b06c1ca6 107.BR \-\-clear\-groups ,
a7e6a6b4
SM
108.BR \-\-groups ,
109.BR \-\-keep\-groups ", or"
0bb7e904 110.B \-\-init\-groups
5e43af7e
BS
111if you set any primary
112.IR gid .
113.TP
114.BI \-\-ruid " uid\fR, " \-\-euid " uid\fR, " \-\-reuid " uid"
a72fa61a 115Set the real, effective, or both UIDs. The \fIuid\fR argument can be
637fa4c6 116given as textual login name.
5e43af7e
BS
117.sp
118Setting a
5600c405
AL
119.I uid
120or
121.I gid
122does not change capabilities, although the exec call at the end might change
123capabilities. This means that, if you are root, you probably want to do
124something like:
5e43af7e 125.sp
35e953e0 126.B " setpriv \-\-reuid=1000 \-\-regid=1000 \-\-inh\-caps=\-all"
5600c405 127.TP
5e43af7e 128.BR \-\-securebits " (" + | \- ) \fIsecurebit ...
cf8e0bae
BS
129Set or clear securebits. The argument is a comma-separated list.
130The valid securebits are
5600c405 131.IR noroot ,
cf8e0bae
BS
132.IR noroot_locked ,
133.IR no_setuid_fixup ,
134.IR no_setuid_fixup_locked ,
5600c405 135and
cf8e0bae
BS
136.IR keep_caps_locked .
137.I keep_caps
5600c405
AL
138is cleared by
139.BR execve (2)
140and is therefore not allowed.
141.TP
23f54ce7
PS
142.BR "\-\-pdeathsig keep" | clear | <signal>
143Keep, clear or set the parent death signal. Some LSMs, most notably SELinux and
144AppArmor, clear the signal when the process' credentials change. Using
1c4c6024 145\fB\-\-pdeathsig keep\fR will restore the parent death signal after changing
23f54ce7
PS
146credentials to remedy that situation.
147.TP
b06c1ca6 148.BI \-\-selinux\-label " label"
cf8e0bae 149Request a particular SELinux transition (using a transition on exec, not
5600c405
AL
150dyntrans). This will fail and cause
151.BR setpriv (1)
152to abort if SELinux is not in use, and the transition may be ignored or cause
153.BR execve (2)
154to fail at SELinux's whim. (In particular, this is unlikely to work in
155conjunction with
cf8e0bae 156.IR no_new_privs .)
5600c405
AL
157This is similar to
158.BR runcon (1).
159.TP
b06c1ca6 160.BI \-\-apparmor\-profile " profile"
cf8e0bae 161Request a particular AppArmor profile (using a transition on exec). This will
5600c405
AL
162fail and cause
163.BR setpriv (1)
164to abort if AppArmor is not in use, and the transition may be ignored or cause
165.BR execve (2)
166to fail at AppArmor's whim.
167.TP
2fb684f0 168.B \-\-reset\-env
89f95425
KZ
169Clears all the environment variables except TERM; initializes the environment variables HOME, SHELL, USER, LOGNAME
170according to the user's passwd entry; sets PATH to \fI/usr/local/bin:/bin:/usr/bin\fR for a regual user and to
171\fI/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\fR for root.
172.sp
173The environment variable PATH may be different on systems where /bin and /sbin
174are merged into /usr. The environment variable SHELL defaults to \fI/bin/sh\fR if none is given in the user's
175passwd entry.
176.TP
5e43af7e 177.BR \-V , " \-\-version"
5600c405
AL
178Display version information and exit.
179.TP
5e43af7e 180.BR \-h , " \-\-help"
b4362b6f 181Display help text and exit.
5600c405
AL
182.SH NOTES
183If applying any specified option fails,
184.I program
185will not be run and
186.B setpriv
a87f49f6 187will return with exit status 127.
5600c405
AL
188.PP
189Be careful with this tool \-\- it may have unexpected security consequences.
cf8e0bae
BS
190For example, setting no_new_privs and then execing a program that is
191SELinux\-confined (as this tool would do) may prevent the SELinux
5600c405 192restrictions from taking effect.
1aed71e5
SM
193.SH EXAMPLE
194If you're looking for behaviour similar to
195.BR su (1)/ runuser "(1), or " sudo (8)
196(without the
1c4c6024 197.B \-g
1aed71e5
SM
198option), try something like:
199.sp
200.B " setpriv \-\-reuid=1000 \-\-regid=1000 \-\-init\-groups"
201.PP
202If you want to mimic daemontools'
203.BR setuid (8),
204try:
205.sp
206.B " setpriv \-\-reuid=1000 \-\-regid=1000 \-\-clear\-groups"
5600c405 207.SH SEE ALSO
c424fd83 208.BR runuser (1),
f053ff1e 209.BR su (1),
66083665 210.BR prctl (2),
4a2ec98b 211.BR capabilities (7)
a8d0d330 212.SH AUTHORS
5600c405
AL
213.MT luto@amacapital.net
214Andy Lutomirski
215.ME
216.SH AVAILABILITY
217The
218.B setpriv
219command is part of the util-linux package and is available from
d673b74e 220.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
5600c405
AL
221Linux Kernel Archive
222.UE .