1 .TH SETPRIV 1 "July 2014" "util-linux" "User Commands"
3 setpriv \- run a program with different Linux privilege settings
10 Sets or queries various Linux privilege settings that are inherited across
18 neither uses PAM, nor does it prompt for a password.
19 It is a simple, non-set-user-ID wrapper around
21 and can be used to drop privileges in the same way as
28 or similar tools shipped by other service managers.
32 Clear supplementary groups.
35 Dump current privilege state. Can be specified more than once to show extra,
36 mostly useless, information. Incompatible with all other options.
38 .B \-\-groups \fIgroup\fR...
39 Set supplementary groups. The argument is a comma-separated list of GIDs or names.
41 .BR \-\-inh\-caps " (" + | \- ) \fIcap "... or " \-\-ambient-caps " (" + | \- ) \fIcap "... or " \-\-bounding\-set " (" + | \- ) \fIcap ...
42 Set the inheritable capabilities, ambient capabilities or the capability bounding set. See
44 The argument is a comma-separated list of
48 entries, which add or remove an entry respectively. \fIcap\fR can either be a
49 human-readable name as seen in
51 without the \fIcap_\fR prefix or of the format
53 where \fIN\fR is the internal capability index used by Linux.
57 can be used to add or remove all caps. The set of capabilities starts out as
58 the current inheritable set for
60 the current ambient set for
62 and the current bounding set for
63 .BR \-\-bounding\-set .
64 If you drop something from the bounding set without also dropping it from the
65 inheritable set, you are likely to become confused. Do not do that.
68 Preserve supplementary groups. Only useful in conjunction with
74 Initialize supplementary groups using
76 Only useful in conjunction with
82 List all known capabilities. This option must be specified alone.
87 bit. With this bit set,
89 will not grant new privileges.
90 For example, the set-user-ID and set-group-ID bits as well
91 as file capabilities will be disabled. (Executing binaries with these bits set
92 will still work, but they will not gain privileges. Certain LSMs, especially
93 AppArmor, may result in failures to execute certain programs.) This bit is
94 inherited by child processes and cannot be unset. See
97 .I Documentation/\:prctl/\:no_\:new_\:privs.txt
98 in the Linux kernel source.
100 The no_new_privs bit is supported since Linux 3.5.
102 .BI \-\-rgid " gid\fR, " \-\-egid " gid\fR, " \-\-regid " gid"
103 Set the real, effective, or both GIDs. The \fIgid\fR argument can be
104 given as textual group name.
106 For safety, you must specify one of
107 .BR \-\-clear\-groups ,
109 .BR \-\-keep\-groups ", or"
111 if you set any primary
114 .BI \-\-ruid " uid\fR, " \-\-euid " uid\fR, " \-\-reuid " uid"
115 Set the real, effective, or both UIDs. The \fIuid\fR argument can be
116 given as textual login name.
122 does not change capabilities, although the exec call at the end might change
123 capabilities. This means that, if you are root, you probably want to do
126 .B " setpriv \-\-reuid=1000 \-\-regid=1000 \-\-inh\-caps=\-all"
128 .BR \-\-securebits " (" + | \- ) \fIsecurebit ...
129 Set or clear securebits. The argument is a comma-separated list.
130 The valid securebits are
133 .IR no_setuid_fixup ,
134 .IR no_setuid_fixup_locked ,
136 .IR keep_caps_locked .
140 and is therefore not allowed.
142 .BR "\-\-pdeathsig keep" | clear | <signal>
143 Keep, clear or set the parent death signal. Some LSMs, most notably SELinux and
144 AppArmor, clear the signal when the process' credentials change. Using
145 \fB--pdeathsig keep\fR will restore the parent death signal after changing
146 credentials to remedy that situation.
148 .BI \-\-selinux\-label " label"
149 Request a particular SELinux transition (using a transition on exec, not
150 dyntrans). This will fail and cause
152 to abort if SELinux is not in use, and the transition may be ignored or cause
154 to fail at SELinux's whim. (In particular, this is unlikely to work in
160 .BI \-\-apparmor\-profile " profile"
161 Request a particular AppArmor profile (using a transition on exec). This will
164 to abort if AppArmor is not in use, and the transition may be ignored or cause
166 to fail at AppArmor's whim.
169 Clears all the environment variables except TERM; initializes the environment variables HOME, SHELL, USER, LOGNAME
170 according 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.
173 The environment variable PATH may be different on systems where /bin and /sbin
174 are merged into /usr. The environment variable SHELL defaults to \fI/bin/sh\fR if none is given in the user's
177 .BR \-V , " \-\-version"
178 Display version information and exit.
180 .BR \-h , " \-\-help"
181 Display help text and exit.
183 If applying any specified option fails,
187 will return with exit code 127.
189 Be careful with this tool \-\- it may have unexpected security consequences.
190 For example, setting no_new_privs and then execing a program that is
191 SELinux\-confined (as this tool would do) may prevent the SELinux
192 restrictions from taking effect.
194 If you're looking for behaviour similar to
195 .BR su (1)/ runuser "(1), or " sudo (8)
198 option), try something like:
200 .B " setpriv \-\-reuid=1000 \-\-regid=1000 \-\-init\-groups"
202 If you want to mimic daemontools'
206 .B " setpriv \-\-reuid=1000 \-\-regid=1000 \-\-clear\-groups"
213 .MT luto@amacapital.net
219 command is part of the util-linux package and is available from
220 .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/