1SETPRIV(1) User Commands SETPRIV(1)
2
3
4
6 setpriv - run a program with different Linux privilege settings
7
9 setpriv [options] program [arguments]
10
12 Sets or queries various Linux privilege settings that are inherited
13 across execve(2).
14
16 -d, --dump
17 Dumps current privilege state. Specify more than once to show
18 extra, mostly useless, information. Incompatible with all other
19 options.
20
21 --no-new-privs
22 Sets the no_new_privs bit. With this bit set, execve(2) will
23 not grant new privileges. For example, the setuid and setgid
24 bits as well as file capabilities will be disabled. (Executing
25 binaries with these bits set will still work, but they will not
26 gain privilege. Certain LSMs, especially AppArmor, may result
27 in failures to execute certain programs.) This bit is inherited
28 by child processes and cannot be unset. See prctl(2) and Docu‐
29 mentation/prctl/no_new_privs.txt in the Linux kernel source.
30
31 The no_new_privs bit is supported since Linux 3.5.
32
33 --inh-caps (+|-)cap,... or --bounding-set (+|-)cap,...
34 Sets inheritable capabilities or capability bounding set. See
35 capabilities(7). The argument is a comma-separated list of +cap
36 and -cap entries, which add or remove an entry respectively.
37 +all and -all can be used to add or remove all caps. The set of
38 capabilities starts out as the current inheritable set for --
39 inh-caps and the current bounding set for --bounding-set. If
40 you drop something from the bounding set without also dropping
41 it from the inheritable set, you are likely to become confused.
42 Do not do that.
43
44 --list-caps
45 Lists all known capabilities. Must be specified alone.
46
47 --ruid uid, --euid uid, --reuid uid
48 Sets the real, effective, or both uids.
49
50 Setting uid or gid does not change capabilities, although the
51 exec call at the end might change capabilities. This means
52 that, if you are root, you probably want to do something like:
53
54 --reuid=1000 --regid=1000 --caps=-all
55
56 --rgid gid, --egid gid, --regid gid
57 Sets the real, effective, or both gids.
58
59 For safety, you must specify one of --keep-groups, --clear-
60 groups, or --groups if you set any primary gid.
61
62 --clear-groups
63 Clears supplementary groups.
64
65 --keep-groups
66 Preserves supplementary groups. Only useful in conjunction with
67 --rgid, --egid, or --regid.
68
69 --groups group,...
70 Sets supplementary groups.
71
72 --securebits (+|-)securebit,...
73 Sets or clears securebits. The valid securebits are noroot,
74 noroot_locked, no_setuid_fixup, no_setuid_fixup_locked, and
75 keep_caps_locked. keep_caps is cleared by execve(2) and is
76 therefore not allowed.
77
78 --selinux-label label
79 Requests a particular SELinux transition (using a transition on
80 exec, not dyntrans). This will fail and cause setpriv(1) to
81 abort if SELinux is not in use, and the transition may be
82 ignored or cause execve(2) to fail at SELinux's whim. (In par‐
83 ticular, this is unlikely to work in conjunction with no_new_
84 privs.) This is similar to runcon(1).
85
86 --apparmor-profile profile
87 Requests a particular AppArmor profile (using a transition on
88 exec). This will fail and cause setpriv(1) to abort if AppArmor
89 is not in use, and the transition may be ignored or cause
90 execve(2) to fail at AppArmor's whim.
91
92 -V, --version
93 Display version information and exit.
94
95 -h, --help
96 Display help and exit.
97
99 If applying any specified option fails, program will not be run and
100 setpriv will return with exit code 127.
101
102 Be careful with this tool -- it may have unexpected security conse‐
103 quences. For example, setting no_new_privs and then execing a program
104 that is SELinux-confined (as this tool would do) may prevent the
105 SELinux restrictions from taking effect.
106
108 prctl(2), capability(7)
109
111 Andy Lutomirski ⟨luto@amacapital.net⟩
112
114 The setpriv command is part of the util-linux package and is available
115 from Linux Kernel Archive ⟨ftp://ftp.kernel.org/pub/linux/utils/util-
116 linux/⟩.
117
118
119
120util-linux January 2013 SETPRIV(1)