| 1 |
.\" Automatically generated by Pandoc 3.6.3 |
| 2 |
.\" |
| 3 |
.TH "SUDOERS" "5" "" "sudo\-rs 0.2.14" "sudo\-rs" |
| 4 |
.SH NAME |
| 5 |
\f[CR]sudoers\f[R] \- sudo\-compatible security configuration |
| 6 |
.SH DESCRIPTION |
| 7 |
The \f[CR]sudo\-rs\f[R] policy determines a user\[cq]s sudo privileges. |
| 8 |
The policy is driven by the \f[I]/etc/sudoers file\f[R]. |
| 9 |
The policy format is described in detail in the \f[B]SUDOERS FILE |
| 10 |
FORMAT\f[R] section. |
| 11 |
.PP |
| 12 |
The format used by sudo\-rs is a subset of the one used by the |
| 13 |
sudo\-project as maintained by Todd Miller, but syntax\-compatible. |
| 14 |
.SS User Authentication |
| 15 |
The sudoers security policy requires that most users authenticate |
| 16 |
themselves before they can use sudo. |
| 17 |
A password is not required if the invoking user is root, if the target |
| 18 |
user is the same as the invoking user, or if the policy has disabled |
| 19 |
authentication for the user or command. |
| 20 |
Unlike \f[CR]su\f[R], when \f[CR]sudo\-rs\f[R] requires authentication, |
| 21 |
it validates the invoking user\[cq]s credentials, not the target |
| 22 |
user\[cq]s (or root\[cq]s) credentials. |
| 23 |
This can be changed via the \f[I]rootpw\f[R] flag, described later. |
| 24 |
.PP |
| 25 |
\f[CR]sudo\-rs\f[R] uses per\-user timestamp files for credential |
| 26 |
caching. |
| 27 |
Once a user has been authenticated, a record is written containing the |
| 28 |
user\-ID that was used to authenticate, the terminal session ID, the |
| 29 |
start time of the session leader (or parent process) and a timestamp |
| 30 |
(using a monotonic clock if one is available). |
| 31 |
The user may then use sudo without a password for a short period of time |
| 32 |
(15 minutes unless overridden by the timestamp_timeout option). |
| 33 |
\f[CR]sudo\-rs\f[R] uses a separate record for each terminal, which |
| 34 |
means that a user\[cq]s login sessions are authenticated separately. |
| 35 |
.SS Logging |
| 36 |
By default, \f[CR]sudo\-rs\f[R] logs both successful and unsuccessful |
| 37 |
attempts (as well as errors). |
| 38 |
Messages are logged to syslog(3). |
| 39 |
.SS Command environment |
| 40 |
Since environment variables can influence program behavior, |
| 41 |
\f[CR]sudo\-rs\f[R] restricts which variables from the user\[cq]s |
| 42 |
environment are inherited by the command to be run. |
| 43 |
.PP |
| 44 |
In \f[CR]sudo\-rs\f[R], the \f[I]env_reset\f[R] flag cannot be disabled. |
| 45 |
This causes commands to be executed with a new, minimal environment. |
| 46 |
The \f[CR]HOME\f[R], \f[CR]SHELL\f[R], \f[CR]LOGNAME\f[R] and |
| 47 |
\f[CR]USER\f[R] environment variables are initialized based on the |
| 48 |
target user and the \f[CR]SUDO_*\f[R] variables are set based on the |
| 49 |
invoking user. |
| 50 |
Additional variables, such as \f[CR]DISPLAY\f[R], \f[CR]PATH\f[R] and |
| 51 |
\f[CR]TERM\f[R], are preserved from the invoking user\[cq]s environment |
| 52 |
if permitted by the \f[I]env_check\f[R] or \f[I]env_keep\f[R] options. |
| 53 |
A few environment variables are treated specially. |
| 54 |
If the \f[CR]PATH\f[R] and \f[CR]TERM\f[R] variables are not preserved |
| 55 |
from the user\[cq]s environment, they will be set to default values. |
| 56 |
The \f[CR]LOGNAME\f[R] and \f[CR]USER\f[R] are handled as a single |
| 57 |
entity. |
| 58 |
If one of them is preserved (or removed) from the user\[cq]s |
| 59 |
environment, the other will be as well. |
| 60 |
If \f[CR]LOGNAME\f[R] and \f[CR]USER\f[R] are to be preserved but only |
| 61 |
one of them is present in the user\[cq]s environment, the other will be |
| 62 |
set to the same value. |
| 63 |
This avoids an inconsistent environment where one of the variables |
| 64 |
describing the user name is set to the invoking user and one is set to |
| 65 |
the target user. |
| 66 |
Environment variables with a value beginning with \f[CR]()\f[R] are |
| 67 |
removed, as they may be interpreted as functions by the bash shell. |
| 68 |
.PP |
| 69 |
Environment variables specified by \f[I]env_check\f[R] or |
| 70 |
\f[I]env_keep\f[R] may include one or more `*' characters which will |
| 71 |
match zero or more characters. |
| 72 |
No other wildcard characters are supported. |
| 73 |
Other sudoers options may influence the command environment, such as |
| 74 |
\f[I]secure_path\f[R]. |
| 75 |
.PP |
| 76 |
Variables in the PAM environment may be merged in to the environment. |
| 77 |
If a variable in the PAM environment is already present in the |
| 78 |
user\[cq]s environment, the value will only be overridden if the |
| 79 |
variable was not preserved by \f[CR]sudo\-rs\f[R]. |
| 80 |
Variables preserved from the invoking user\[cq]s environment by the |
| 81 |
\f[I]env_keep\f[R] list take precedence over those in the PAM |
| 82 |
environment. |
| 83 |
.PP |
| 84 |
Note that the dynamic linker on most operating systems will remove |
| 85 |
variables that can control dynamic linking from the environment of |
| 86 |
set\-user\-ID executables, including sudo. |
| 87 |
Depending on the operating system this may include \f[CR]_RLD*\f[R], |
| 88 |
\f[CR]DYLD_*\f[R], \f[CR]LD_*\f[R], \f[CR]LDR_*\f[R], |
| 89 |
\f[CR]LIBPATH\f[R], \f[CR]SHLIB_PATH\f[R], and others. |
| 90 |
These type of variables are removed from the environment before sudo |
| 91 |
even begins execution and, as such, it is not possible for sudo to |
| 92 |
preserve them. |
| 93 |
.SS Resource limits |
| 94 |
sudo uses the operating system\[cq]s native method of setting resource |
| 95 |
limits for the target user. |
| 96 |
On Linux systems, resource limits are usually set by the |
| 97 |
\f[I]pam_limits.so\f[R] PAM module. |
| 98 |
On some BSD systems, the \f[I]/etc/login.conf\f[R] file specifies |
| 99 |
resource limits for the user. |
| 100 |
If there is no system mechanism to set per\-user resource limits, the |
| 101 |
command will run with the same limits as the invoking user. |
| 102 |
.SH SUDOERS FILE FORMAT |
| 103 |
The sudoers file is composed of two types of entries: aliases (basically |
| 104 |
variables) and user specifications (which specify who may run what). |
| 105 |
.PP |
| 106 |
When multiple entries match for a user, they are applied in order. |
| 107 |
Where there are multiple matches, the last match is used (which is not |
| 108 |
necessarily the most specific match). |
| 109 |
.PP |
| 110 |
The sudoers file grammar will be described below in Extended |
| 111 |
Backus\-Naur Form (EBNF) borrowed from Todd Miller\[cq]s sudoers |
| 112 |
documentation. |
| 113 |
.SS Quick guide to EBNF |
| 114 |
EBNF is a concise and exact way of describing the grammar of a language. |
| 115 |
Each EBNF definition is made up of production rules. |
| 116 |
E.g., |
| 117 |
.IP |
| 118 |
.EX |
| 119 |
symbol ::= definition | alternate1 | alternate2 ... |
| 120 |
.EE |
| 121 |
.PP |
| 122 |
Each production rule references others and thus makes up a grammar for |
| 123 |
the language. |
| 124 |
EBNF also contains the following operators, which many readers will |
| 125 |
recognize from regular expressions. |
| 126 |
Do not, however, confuse them with \[lq]wildcard\[rq] characters, which |
| 127 |
have different meanings. |
| 128 |
.IP |
| 129 |
.EX |
| 130 |
? Means that the preceding symbol (or group of symbols) is optional. That is, it may appear once or not at all. |
| 131 |
|
| 132 |
* Means that the preceding symbol (or group of symbols) may appear zero or more times. |
| 133 |
|
| 134 |
+ Means that the preceding symbol (or group of symbols) may appear one or more times. |
| 135 |
.EE |
| 136 |
.PP |
| 137 |
Parentheses may be used to group symbols together. |
| 138 |
For clarity, we will use single quotes (\[cq]\[cq]) to designate what is |
| 139 |
a verbatim character string (as opposed to a symbol name). |
| 140 |
.SS Aliases |
| 141 |
There are four kinds of aliases: User_Alias, Runas_Alias, Host_Alias and |
| 142 |
Cmnd_Alias. |
| 143 |
.IP |
| 144 |
.EX |
| 145 |
Alias ::= \[aq]User_Alias\[aq] User_Alias_Spec (\[aq]:\[aq] User_Alias_Spec)* | |
| 146 |
\[aq]Runas_Alias\[aq] Runas_Alias_Spec (\[aq]:\[aq] Runas_Alias_Spec)* | |
| 147 |
\[aq]Host_Alias\[aq] Host_Alias_Spec (\[aq]:\[aq] Host_Alias_Spec)* | |
| 148 |
\[aq]Cmnd_Alias\[aq] Cmnd_Alias_Spec (\[aq]:\[aq] Cmnd_Alias_Spec)* | |
| 149 |
\[aq]Cmd_Alias\[aq] Cmnd_Alias_Spec (\[aq]:\[aq] Cmnd_Alias_Spec)* |
| 150 |
|
| 151 |
User_Alias ::= NAME |
| 152 |
|
| 153 |
User_Alias_Spec ::= User_Alias \[aq]=\[aq] User_List |
| 154 |
|
| 155 |
Runas_Alias ::= NAME |
| 156 |
|
| 157 |
Runas_Alias_Spec ::= Runas_Alias \[aq]=\[aq] Runas_List |
| 158 |
|
| 159 |
Host_Alias ::= NAME |
| 160 |
|
| 161 |
Host_Alias_Spec ::= Host_Alias \[aq]=\[aq] Host_List |
| 162 |
|
| 163 |
Cmnd_Alias ::= NAME |
| 164 |
|
| 165 |
Cmnd_Alias_Spec ::= Cmnd_Alias \[aq]=\[aq] Cmnd_List |
| 166 |
|
| 167 |
NAME ::= [A\-Z]([A\-Z][0\-9]_)* |
| 168 |
.EE |
| 169 |
.PP |
| 170 |
Each alias definition is of the form |
| 171 |
.IP |
| 172 |
.EX |
| 173 |
Alias_Type NAME = item1, item2, ... |
| 174 |
.EE |
| 175 |
.PP |
| 176 |
where \f[I]Alias_Type\f[R] is one of User_Alias, Runas_Alias, |
| 177 |
Host_Alias, or Cmnd_Alias. |
| 178 |
A NAME is a string of uppercase letters, numbers, and underscore |
| 179 |
characters (\[cq]_\[cq]). |
| 180 |
A NAME must start with an uppercase letter. |
| 181 |
It is possible to put several alias definitions of the same type on a |
| 182 |
single line, joined by a colon (`:'). |
| 183 |
E.g., |
| 184 |
.IP |
| 185 |
.EX |
| 186 |
Alias_Type NAME = item1, item2, item3 : NAME = item4, item5 |
| 187 |
.EE |
| 188 |
.PP |
| 189 |
The definitions of what constitutes a valid alias member follow. |
| 190 |
.IP |
| 191 |
.EX |
| 192 |
User_List ::= User | |
| 193 |
User \[aq],\[aq] User_List |
| 194 |
|
| 195 |
User ::= \[aq]!\[aq]* user name | |
| 196 |
\[aq]!\[aq]* #user\-ID | |
| 197 |
\[aq]!\[aq]* %group | |
| 198 |
\[aq]!\[aq]* %#group\-ID | |
| 199 |
\[aq]!\[aq]* User_Alias |
| 200 |
.EE |
| 201 |
.PP |
| 202 |
A User_List is made up of one or more user names, user\-IDs (prefixed |
| 203 |
with `#'), system group names and IDs (prefixed with `%' and `%#' |
| 204 |
respectively) and User_Aliases. |
| 205 |
Each list item may be prefixed with zero or more `!' operators. |
| 206 |
An odd number of `!' operators negate the value of the item; an even |
| 207 |
number just cancel each other out. |
| 208 |
.IP |
| 209 |
.EX |
| 210 |
Runas_List ::= Runas_Member | |
| 211 |
Runas_Member \[aq],\[aq] Runas_List |
| 212 |
|
| 213 |
Runas_Member ::= \[aq]!\[aq]* user name | |
| 214 |
\[aq]!\[aq]* #user\-ID | |
| 215 |
\[aq]!\[aq]* %group | |
| 216 |
\[aq]!\[aq]* %#group\-ID | |
| 217 |
\[aq]!\[aq]* Runas_Alias |
| 218 |
.EE |
| 219 |
.PP |
| 220 |
A Runas_List is similar to a User_List except that instead of |
| 221 |
User_Aliases it can contain Runas_Aliases. |
| 222 |
Note that user names and groups are matched as strings. |
| 223 |
In other words, two users (groups) with the same user (group) ID are |
| 224 |
considered to be distinct. |
| 225 |
If you wish to match all user names with the same user\-ID (e.g., root |
| 226 |
and toor), you can use a user\-ID instead of a name (\f[CR]#0\f[R] in |
| 227 |
the example given). |
| 228 |
.IP |
| 229 |
.EX |
| 230 |
Host_List ::= Host | |
| 231 |
Host \[aq],\[aq] Host_List |
| 232 |
|
| 233 |
Host ::= \[aq]!\[aq]* host name | |
| 234 |
\[aq]!\[aq]* Host_Alias |
| 235 |
.EE |
| 236 |
.PP |
| 237 |
A Host_List is made up of one or more host names. |
| 238 |
Again, the value of an item may be negated with the `!' operator. |
| 239 |
.IP |
| 240 |
.EX |
| 241 |
Cmnd_List ::= Cmnd | |
| 242 |
Cmnd \[aq],\[aq] Cmnd_List |
| 243 |
|
| 244 |
command name ::= file name | |
| 245 |
file name args [\[aq]*\[aq]] | |
| 246 |
file name \[aq]\[dq]\[dq]\[aq] |
| 247 |
|
| 248 |
Cmnd ::= \[aq]!\[aq]* command name | |
| 249 |
\[aq]!\[aq]* directory | |
| 250 |
\[aq]!\[aq]* Cmnd_Alias |
| 251 |
\[aq]!\[aq]* \[dq]list\[dq] |
| 252 |
\[aq]!\[aq]* \[dq]sudoedit\[dq] [file name] |
| 253 |
.EE |
| 254 |
.PP |
| 255 |
A Cmnd_List is a list of one or more command names, directories, and |
| 256 |
other aliases. |
| 257 |
A command name is a fully qualified file name which may include |
| 258 |
shell\-style wildcards (see the \f[I]Wildcards\f[R] section below). |
| 259 |
A simple file name allows the user to run the command with any arguments |
| 260 |
they wish. |
| 261 |
However, you may also specify command line arguments that have to be |
| 262 |
used, in which case the command line has to match exactly. |
| 263 |
You can use the special argument \[lq]\[rq] to indicate that the command |
| 264 |
may only be run \f[I]without\f[R] command line arguments, or the |
| 265 |
argument \[cq]*\[cq] to match any trailing arguments. |
| 266 |
You cannot use wildcards inside the argument list. |
| 267 |
A directory is a fully qualified path name ending in a `/'. |
| 268 |
When you specify a directory in a Cmnd_List, the user will be able to |
| 269 |
run any file within that directory (but not in any sub\-directories |
| 270 |
therein). |
| 271 |
.PP |
| 272 |
If a Cmnd has associated command line arguments, then the arguments in |
| 273 |
the Cmnd must match exactly those given by the user on the command line. |
| 274 |
Note that the following characters must be escaped with a `\[rs]' if |
| 275 |
they are used in command arguments: `,', `:', `=', `\[rs]'. |
| 276 |
.PP |
| 277 |
There are two commands built into sudo itself: \[lq]list\[rq] and |
| 278 |
\[lq]sudoedit\[rq]. |
| 279 |
Unlike other commands, these two must be specified in the sudoers file |
| 280 |
without a leading path. |
| 281 |
.PP |
| 282 |
The \[lq]list\[rq] built\-in can be used to permit a user to list |
| 283 |
another user\[cq]s privileges with sudo\[cq]s \-U option. |
| 284 |
For example, \[lq]sudo \-l \-U otheruser\[rq]. |
| 285 |
A user with the \[lq]list\[rq] privilege is able to list another |
| 286 |
user\[cq]s privileges even if they don\[cq]t have permission to run |
| 287 |
commands as that user. |
| 288 |
By default, only root or a user with the ability to run any command as |
| 289 |
either root or the specified user on the current host may use the \-U |
| 290 |
option. |
| 291 |
No command line arguments may be specified with the \[lq]list\[rq] |
| 292 |
built\-in. |
| 293 |
.PP |
| 294 |
The \[lq]sudoedit\[rq] built\-in is used to permit a user to run sudo |
| 295 |
with the \-e option (or as sudoedit). |
| 296 |
It may take command line arguments just as a normal command does. |
| 297 |
Unlike other commands, \[lq]sudoedit\[rq] is built into sudo itself and |
| 298 |
must be specified in the sudoers file without a leading path. |
| 299 |
If a leading path is present, for example /usr/bin/sudoedit, this will |
| 300 |
not give the user permissions to use sudoedit. |
| 301 |
If no arguments are provided, \[lq]sudoedit\[rq] will give the user the |
| 302 |
permission to edit any files; if an argument is present it must be an |
| 303 |
absolute path name that does not contain symbolic links, or the command |
| 304 |
will not be matched. |
| 305 |
.SS Defaults |
| 306 |
Certain configuration options may be changed from their default values |
| 307 |
at run\-time via one or more Default_Entry lines. |
| 308 |
These may affect all users on any host, all users on a specific host, a |
| 309 |
specific user, a specific command, or commands being run as a specific |
| 310 |
user. |
| 311 |
Note that per\-command entries may not include command line arguments. |
| 312 |
If you need to specify arguments, define a Cmnd_Alias and reference that |
| 313 |
instead. |
| 314 |
.IP |
| 315 |
.EX |
| 316 |
Default_Type ::= \[aq]Defaults\[aq] | |
| 317 |
\[aq]Defaults\[aq] \[aq]\[at]\[aq] Host_List | |
| 318 |
\[aq]Defaults\[aq] \[aq]:\[aq] User_List | |
| 319 |
\[aq]Defaults\[aq] \[aq]!\[aq] Cmnd_List | |
| 320 |
\[aq]Defaults\[aq] \[aq]>\[aq] Runas_List |
| 321 |
|
| 322 |
Default_Entry ::= Default_Type Parameter_List |
| 323 |
|
| 324 |
Parameter_List ::= Parameter | |
| 325 |
Parameter \[aq],\[aq] Parameter_List |
| 326 |
|
| 327 |
Parameter ::= Parameter \[aq]=\[aq] Value | |
| 328 |
Parameter \[aq]+=\[aq] Value | |
| 329 |
Parameter \[aq]\-=\[aq] Value | |
| 330 |
\[aq]!\[aq]* Parameter |
| 331 |
.EE |
| 332 |
.PP |
| 333 |
Parameters may be flags, integer values, strings, or lists. |
| 334 |
Flags are implicitly boolean and can be turned off via the `!' operator. |
| 335 |
Some integer, string and list parameters may also be used in a boolean |
| 336 |
context to disable them. |
| 337 |
Values may be enclosed in double quotes (\[lq]\[lq]) when they contain |
| 338 |
multiple words. |
| 339 |
Special characters may be escaped with a backslash (`\[rs]'). |
| 340 |
.PP |
| 341 |
To include a literal backslash character in a command line argument you |
| 342 |
must escape the backslash twice. |
| 343 |
For example, to match `\[rs]n' as part of a command line argument, you |
| 344 |
must use `\[rs]\[rs]\[rs]\[rs]n' in the sudoers file. |
| 345 |
This is due to there being two levels of escaping, one in the sudoers |
| 346 |
parser itself and another when command line arguments are matched by the |
| 347 |
fnmatch(3) function. |
| 348 |
.PP |
| 349 |
Lists have two additional assignment operators, \f[I]+=\f[R] and |
| 350 |
\f[I]\-=\f[R]. |
| 351 |
These operators are used to add to and delete from a list respectively. |
| 352 |
It is not an error to use the \-= operator to remove an element that |
| 353 |
does not exist in a list. |
| 354 |
.PP |
| 355 |
Defaults entries are parsed in the following order: generic, host, user, |
| 356 |
and runas Defaults are processed in the order they appear, with |
| 357 |
per\-command defaults being processed in a second pass after that. |
| 358 |
.PP |
| 359 |
See \f[B]SUDOERS OPTIONS\f[R] for a list of supported Defaults |
| 360 |
parameters. |
| 361 |
.SS User specification |
| 362 |
.IP |
| 363 |
.EX |
| 364 |
User_Spec ::= User_List Host_List \[aq]=\[aq] Cmnd_Spec_List \[rs] |
| 365 |
(\[aq]:\[aq] Host_List \[aq]=\[aq] Cmnd_Spec_List)* |
| 366 |
|
| 367 |
Cmnd_Spec_List ::= Cmnd_Spec | |
| 368 |
Cmnd_Spec \[aq],\[aq] Cmnd_Spec_List |
| 369 |
|
| 370 |
Cmnd_Spec ::= Runas_Spec? Chdir_Spec? Tag_Spec* Cmnd |
| 371 |
|
| 372 |
Runas_Spec ::= \[aq](\[aq] Runas_List? (\[aq]:\[aq] Runas_List)? \[aq])\[aq] |
| 373 |
|
| 374 |
Chdir_Spec ::= \[aq]CWD=directory\[aq] |
| 375 |
|
| 376 |
Tag_Spec ::= (\[aq]PASSWD:\[aq] | \[aq]NOPASSWD:\[aq] | |
| 377 |
\[aq]SETENV:\[aq] | \[aq]NOSETENV:\[aq] |
| 378 |
\[aq]EXEC:\[aq] | \[aq]NOEXEC\[aq]) |
| 379 |
|
| 380 |
AppArmor_Spec ::= \[aq]APPARMOR_PROFILE=profile\[aq] |
| 381 |
.EE |
| 382 |
.PP |
| 383 |
A user specification determines which commands a user may run (and as |
| 384 |
what user) on specified hosts. |
| 385 |
By default, commands are run as root, but this can be changed on a |
| 386 |
per\-command basis. |
| 387 |
.PP |
| 388 |
The basic structure of a user specification is \[lq]who where = |
| 389 |
(as_whom) what\[rq]. |
| 390 |
Let\[cq]s break that down into its constituent parts: |
| 391 |
.SS Runas_Spec |
| 392 |
A Runas_Spec determines the user and/or the group that a command may be |
| 393 |
run as. |
| 394 |
A fully\-specified Runas_Spec consists of two Runas_Lists (as defined |
| 395 |
above) separated by a colon (`:') and enclosed in a set of parentheses. |
| 396 |
The first Runas_List indicates which users the command may be run as via |
| 397 |
the \-u option. |
| 398 |
The second defines a list of groups that may be specified via the \-g |
| 399 |
option (in addition to any of the target user\[cq]s groups). |
| 400 |
If both Runas_Lists are specified, the command may be run with any |
| 401 |
combination of users and groups listed in their respective Runas_Lists. |
| 402 |
If only the first is specified, the command may be run as any user in |
| 403 |
the list and, optionally, with any group the target user belongs to. |
| 404 |
If the first Runas_List is empty but the second is specified, the |
| 405 |
command may be run as the invoking user with the group set to any listed |
| 406 |
in the Runas_List. |
| 407 |
If both Runas_Lists are empty, the command may only be run as the |
| 408 |
invoking user and the group, if specified, must be one that the invoking |
| 409 |
user is a member of. |
| 410 |
If no Runas_Spec is specified, the command may only be run as root and |
| 411 |
the group, if specified, must be one that root is a member of. |
| 412 |
.PP |
| 413 |
A Runas_Spec sets the default for the commands that follow it. |
| 414 |
What this means is that for the entry: |
| 415 |
.IP |
| 416 |
.EX |
| 417 |
dgb boulder = (operator) /bin/ls, /bin/kill, /usr/bin/lprm |
| 418 |
.EE |
| 419 |
.PP |
| 420 |
The user dgb may run /bin/ls, /bin/kill, and /usr/bin/lprm on the host |
| 421 |
boulder\[em]but only as operator. |
| 422 |
E.g., |
| 423 |
.IP |
| 424 |
.EX |
| 425 |
$ sudo \-u operator /bin/ls |
| 426 |
.EE |
| 427 |
.PP |
| 428 |
It is also possible to override a Runas_Spec later on in an entry. |
| 429 |
If we modify the entry like so: |
| 430 |
.IP |
| 431 |
.EX |
| 432 |
dgb boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm |
| 433 |
.EE |
| 434 |
.PP |
| 435 |
Then user dgb is now allowed to run /bin/ls as operator, but /bin/kill |
| 436 |
and /usr/bin/lprm as root. |
| 437 |
.PP |
| 438 |
We can extend this to allow dgb to run /bin/ls with either the user or |
| 439 |
group set to operator: |
| 440 |
.IP |
| 441 |
.EX |
| 442 |
dgb boulder = (operator : operator) /bin/ls, (root) /bin/kill,\[rs] |
| 443 |
/usr/bin/lprm |
| 444 |
.EE |
| 445 |
.PP |
| 446 |
Note that while the group portion of the Runas_Spec permits the user to |
| 447 |
run as command with that group, it does not force the user to do so. |
| 448 |
If no group is specified on the command line, the command will run with |
| 449 |
the group listed in the target user\[cq]s password database entry. |
| 450 |
The following would all be permitted by the sudoers entry above: |
| 451 |
.IP |
| 452 |
.EX |
| 453 |
$ sudo \-u operator /bin/ls |
| 454 |
$ sudo \-u operator \-g operator /bin/ls |
| 455 |
$ sudo \-g operator /bin/ls |
| 456 |
.EE |
| 457 |
.PP |
| 458 |
In the following example, user tcm may run commands that access a modem |
| 459 |
device file with the dialer group. |
| 460 |
.IP |
| 461 |
.EX |
| 462 |
tcm boulder = (:dialer) /usr/bin/tip, /usr/bin/cu,\[rs] |
| 463 |
/usr/local/bin/minicom |
| 464 |
.EE |
| 465 |
.PP |
| 466 |
Note that in this example only the group will be set, the command still |
| 467 |
runs as user tcm. |
| 468 |
E.g. |
| 469 |
.IP |
| 470 |
.EX |
| 471 |
$ sudo \-g dialer /usr/bin/cu |
| 472 |
.EE |
| 473 |
.PP |
| 474 |
Multiple users and groups may be present in a Runas_Spec, in which case |
| 475 |
the user may select any combination of users and groups via the \-u and |
| 476 |
\-g options. |
| 477 |
In this example: |
| 478 |
.IP |
| 479 |
.EX |
| 480 |
alan ALL = (root, bin : operator, system) ALL |
| 481 |
.EE |
| 482 |
.PP |
| 483 |
user alan may run any command as either user root or bin, optionally |
| 484 |
setting the group to operator or system. |
| 485 |
.SS Chdir_Spec |
| 486 |
The working directory that the command will be run in can be specified |
| 487 |
using the CWD setting. |
| 488 |
The directory must be a fully\-qualified path name beginning with a `/' |
| 489 |
or `\[ti]' character, or the special value \[lq]*\[rq]. |
| 490 |
A value of \[lq]*\[rq] indicates that the user may specify the working |
| 491 |
directory by running sudo with the \-D option. |
| 492 |
By default, commands are run from the invoking user\[cq]s current |
| 493 |
working directory, unless the \-i option is given. |
| 494 |
Path names of the form \[ti]user/path/name are interpreted as being |
| 495 |
relative to the named user\[cq]s home directory. |
| 496 |
If the user name is omitted, the path will be relative to the runas |
| 497 |
user\[cq]s home directory. |
| 498 |
.SS Tag_Spec |
| 499 |
A command may have zero or more tags associated with it. |
| 500 |
The following tag values are supported: PASSWD, NOPASSWD, SETENV, and |
| 501 |
NOSETENV. |
| 502 |
Once a tag is set on a Cmnd, subsequent Cmnds in the Cmnd_Spec_List, |
| 503 |
inherit the tag unless it is overridden by the opposite tag (in other |
| 504 |
words, PASSWD overrides NOPASSWD and NOSETENV overrides SETENV). |
| 505 |
.SS EXEC and NOEXEC |
| 506 |
On Linux systems, the NOEXEC tag can be used to prevent an executable |
| 507 |
from running further commands itself. |
| 508 |
.PP |
| 509 |
In the following example, user aaron may run /usr/bin/more and |
| 510 |
/usr/bin/vi but shell escapes will be disabled. |
| 511 |
.IP |
| 512 |
.EX |
| 513 |
aaron shanty = NOEXEC: /usr/bin/more, /usr/bin/vi |
| 514 |
.EE |
| 515 |
.PP |
| 516 |
See the \f[I]Preventing shell escapes\f[R] section below for more |
| 517 |
details on how NOEXEC works and whether or not it suits your purpose. |
| 518 |
.SS PASSWD and NOPASSWD |
| 519 |
By default, sudo requires that a user authenticate before running a |
| 520 |
command. |
| 521 |
This behavior can be modified via the NOPASSWD tag. |
| 522 |
Like a Runas_Spec, the NOPASSWD tag sets a default for the commands that |
| 523 |
follow it in the Cmnd_Spec_List. |
| 524 |
Conversely, the PASSWD tag can be used to reverse things. |
| 525 |
For example: |
| 526 |
.IP |
| 527 |
.EX |
| 528 |
queen rushmore = NOPASSWD: /bin/kill, /bin/ls, /usr/bin/lprm |
| 529 |
.EE |
| 530 |
.PP |
| 531 |
would allow the user queen to run /bin/kill, /bin/ls, and /usr/bin/lprm |
| 532 |
as root on the machine \[lq]rushmore\[rq] without authenticating |
| 533 |
himself. |
| 534 |
If we only want queen to be able to run /bin/kill without a password the |
| 535 |
entry would be: |
| 536 |
.IP |
| 537 |
.EX |
| 538 |
queen rushmore = NOPASSWD: /bin/kill, PASSWD: /bin/ls, /usr/bin/lprm |
| 539 |
.EE |
| 540 |
.PP |
| 541 |
By default, if the NOPASSWD tag is applied to any of a user\[cq]s |
| 542 |
entries for the current host, the user will be able to run \[lq]sudo |
| 543 |
\-l\[rq] without a password. |
| 544 |
Additionally, a user may only run \[lq]sudo \-v\[rq] without a password |
| 545 |
if all of the user\[cq]s entries for the current host have the NOPASSWD |
| 546 |
tag. |
| 547 |
.SS SETENV and NOSETENV |
| 548 |
These tags override the value of the setenv flag on a per\-command |
| 549 |
basis. |
| 550 |
Note that if SETENV has been set for a command, the user may disable the |
| 551 |
env_reset flag from the command line via the \-E option. |
| 552 |
Additionally, environment variables set on the command line are not |
| 553 |
subject to the restrictions imposed by env_check, env_delete, or |
| 554 |
env_keep. |
| 555 |
As such, only trusted users should be allowed to set variables in this |
| 556 |
manner. |
| 557 |
If the command matched is ALL, the SETENV tag is implied for that |
| 558 |
command; this default may be overridden by use of the NOSETENV tag. |
| 559 |
.SS AppArmor_Spec |
| 560 |
When sudo\-rs is built with support for AppArmor, sudoers file entries |
| 561 |
may specify an AppArmor profile that should be used to confine a |
| 562 |
command. |
| 563 |
.PP |
| 564 |
If an AppArmor profile is specified with the command, it will override |
| 565 |
any default values specified in sudoers. |
| 566 |
Appropriate profile transition rules must be defined to support the |
| 567 |
profile change specified for a user. |
| 568 |
.PP |
| 569 |
AppArmor profiles can be specified in any way that complies with the |
| 570 |
rules of \f[CR]aa_change_profile(2)\f[R]. |
| 571 |
.SS Wildcards |
| 572 |
sudo allows shell\-style wildcards (aka meta or glob characters) to be |
| 573 |
used in host names, path names, and command line arguments in the |
| 574 |
sudoers file. |
| 575 |
Wildcard matching is done via the glob(3) and fnmatch(3) functions as |
| 576 |
specified by IEEE Std 1003.1 (\[lq]POSIX.1\[rq]). |
| 577 |
.IP |
| 578 |
.EX |
| 579 |
* Matches any set of zero or more characters (including white space). |
| 580 |
|
| 581 |
? Matches any single character (including white space). |
| 582 |
|
| 583 |
[...] Matches any character in the specified range. |
| 584 |
|
| 585 |
[!...] Matches any character not in the specified range. |
| 586 |
|
| 587 |
\[rs]x For any character \[oq]x\[cq], evaluates to \[oq]x\[cq]. This is used to escape special characters such as: \[oq]*\[cq], \[oq]?\[cq], \[oq][\[cq], and \[oq]]\[cq]. |
| 588 |
.EE |
| 589 |
.PP |
| 590 |
Note that these are not regular expressions. |
| 591 |
Unlike a regular expression there is no way to match one or more |
| 592 |
characters within a range. |
| 593 |
.PP |
| 594 |
Wildcards in command line arguments are not supported\[em]using these in |
| 595 |
original versions of sudo was usually a sign of mis\-configuration and |
| 596 |
consequently sudo\-rs simply forbids using them. |
| 597 |
The only supported use is \[cq]*\[cq] as the final argument to indicate |
| 598 |
\[lq]zero or more subsequent arguments\[rq] as noted above. |
| 599 |
.SS Including other files from within sudoers |
| 600 |
It is possible to include other sudoers files from within the sudoers |
| 601 |
file currently being parsed using the \f[I]\[at]include\f[R] and |
| 602 |
\f[I]\[at]includedir\f[R] directives; or the contents provided by an |
| 603 |
application over a unix domain socket using the \f[I]\[at]socket\f[R] |
| 604 |
directive. |
| 605 |
For compatibility with Todd Miller\[cq]s sudo versions prior to 1.9.1, |
| 606 |
\f[I]#include\f[R] and \f[I]#includedir\f[R] are also accepted. |
| 607 |
.PP |
| 608 |
An include file can be used, for example, to keep a site\-wide sudoers |
| 609 |
file in addition to a local, per\-machine file. |
| 610 |
For the sake of this example the site\-wide sudoers file will be |
| 611 |
/etc/sudoers and the per\-machine one will be /etc/sudoers.local. |
| 612 |
To include /etc/sudoers.local from within /etc/sudoers one would use the |
| 613 |
following line in /etc/sudoers: |
| 614 |
.IP |
| 615 |
.EX |
| 616 |
\[at]include /etc/sudoers.local |
| 617 |
.EE |
| 618 |
.PP |
| 619 |
When sudo reaches this line it will suspend processing of the current |
| 620 |
file (/etc/sudoers) and switch to /etc/sudoers.local. |
| 621 |
Upon reaching the end of /etc/sudoers.local, the rest of /etc/sudoers |
| 622 |
will be processed. |
| 623 |
Files that are included may themselves include other files. |
| 624 |
A hard limit of 128 nested include files is enforced to prevent include |
| 625 |
file loops. |
| 626 |
.PP |
| 627 |
The path to the include file may contain white space if it is escaped |
| 628 |
with a backslash (`\[rs]'). |
| 629 |
Alternately, the entire path may be enclosed in double quotes |
| 630 |
(\[lq]\[lq]), in which case no escaping is necessary. |
| 631 |
To include a literal backslash in the path, `\[rs]\[rs]' should be used. |
| 632 |
If the path to the include file is not fully\-qualified (does not begin |
| 633 |
with a `/'), it must be located in the same directory as the sudoers |
| 634 |
file it was included from. |
| 635 |
For example, if /etc/sudoers contains the line: |
| 636 |
.IP |
| 637 |
.EX |
| 638 |
\[at]include sudoers.local |
| 639 |
.EE |
| 640 |
.PP |
| 641 |
The \[at]includedir directive can be used to create a sudoers.d |
| 642 |
directory that the system package manager can drop sudoers file rules |
| 643 |
into as part of package installation. |
| 644 |
For example, given: |
| 645 |
.IP |
| 646 |
.EX |
| 647 |
\[at]includedir /etc/sudoers.d |
| 648 |
.EE |
| 649 |
.PP |
| 650 |
sudo will suspend processing of the current file and read each file in |
| 651 |
/etc/sudoers.d, skipping file names that end in `\[ti]' or contain a `.' |
| 652 |
character to avoid causing problems with package manager or editor |
| 653 |
temporary/backup files. |
| 654 |
Files are parsed in sorted lexical order. |
| 655 |
That is, /etc/sudoers.d/01_first will be parsed before |
| 656 |
/etc/sudoers.d/10_second. |
| 657 |
Be aware that because the sorting is lexical, not numeric, |
| 658 |
/etc/sudoers.d/1_whoops would be loaded after /etc/sudoers.d/10_second. |
| 659 |
Using a consistent number of leading zeroes in the file names can be |
| 660 |
used to avoid such problems. |
| 661 |
After parsing the files in the directory, control returns to the file |
| 662 |
that contained the \[at]includedir directive. |
| 663 |
.PP |
| 664 |
Note that unlike files included via \[at]include, visudo will not edit |
| 665 |
the files in a \[at]includedir directory unless one of them contains a |
| 666 |
syntax error. |
| 667 |
It is still possible to run visudo with the \-f flag to edit the files |
| 668 |
directly, but this will not catch the redefinition of an alias that is |
| 669 |
also present in a different file. |
| 670 |
.PP |
| 671 |
When managing enterprise\-wide sudoers rules, it is sometimes preferable |
| 672 |
to store them in a centralized repository. |
| 673 |
The \[at]socket directive can be used to include the contents provided |
| 674 |
by a server application over a unix domain socket. |
| 675 |
For example, providing: |
| 676 |
.IP |
| 677 |
.EX |
| 678 |
\[at]socket /var/run/providers/sudoers.socket |
| 679 |
.EE |
| 680 |
.PP |
| 681 |
will make sudo open that socket, read the rules and close it, as if it |
| 682 |
was an included file. |
| 683 |
The rules must follow the same syntax used in the sudoers files. |
| 684 |
There is, however, one exception: when reading from a socket, the |
| 685 |
\[at]include, \[at]includedir and \[at]socket directives are not |
| 686 |
accepted. |
| 687 |
.PP |
| 688 |
Please note that the contents read from a socket are immutable from |
| 689 |
sudo\[cq]s point of view and visudo will not be able to edit them. |
| 690 |
.SS Other special characters and reserved words |
| 691 |
The pound sign (`#') is used to indicate a comment (unless it is part of |
| 692 |
a #include directive or unless it occurs in the context of a user name |
| 693 |
and is followed by one or more digits, in which case it is treated as a |
| 694 |
user\-ID). |
| 695 |
Both the comment character and any text after it, up to the end of the |
| 696 |
line, are ignored. |
| 697 |
.PP |
| 698 |
The reserved word \f[I]ALL\f[R] is a built\-in alias that always causes |
| 699 |
a match to succeed. |
| 700 |
It can be used wherever one might otherwise use a Cmnd_Alias, |
| 701 |
User_Alias, Runas_Alias, or Host_Alias. |
| 702 |
Attempting to define an alias named ALL will result in a syntax error. |
| 703 |
Please note that using ALL can be dangerous since in a command context, |
| 704 |
it allows the user to run any command on the system. |
| 705 |
.PP |
| 706 |
An exclamation point (`!') can be used as a logical not operator in a |
| 707 |
list or alias as well as in front of a Cmnd. |
| 708 |
This allows one to exclude certain values. |
| 709 |
For the `!' operator to be effective, there must be something for it to |
| 710 |
exclude. |
| 711 |
For example, to match all users except for root one would use: |
| 712 |
.IP |
| 713 |
.EX |
| 714 |
ALL,!root |
| 715 |
.EE |
| 716 |
.PP |
| 717 |
If the ALL, is omitted, as in: |
| 718 |
.IP |
| 719 |
.EX |
| 720 |
!root |
| 721 |
.EE |
| 722 |
.PP |
| 723 |
it would explicitly deny root but not match any other users. |
| 724 |
This is different from a true \[lq]negation\[rq] operator. |
| 725 |
.PP |
| 726 |
Note, however, that using a `!' in conjunction with the built\-in ALL |
| 727 |
alias to allow a user to run \[lq]all but a few\[rq] commands rarely |
| 728 |
works as intended (see SECURITY NOTES below). |
| 729 |
.PP |
| 730 |
White space between elements in a list as well as special syntactic |
| 731 |
characters in a User Specification (`=', `:', `(', `)') is optional. |
| 732 |
.PP |
| 733 |
The following characters must be escaped with a backslash (`\[rs]') when |
| 734 |
used as part of a word (e.g., a user name or host name): `!', `=', `:', |
| 735 |
`,', `(', `)', `\[rs]'. |
| 736 |
.SS SUDOERS OPTIONS |
| 737 |
sudo\[cq]s behavior can be modified by Default_Entry lines, as explained |
| 738 |
earlier. |
| 739 |
A list of all supported Defaults parameters, grouped by type, are listed |
| 740 |
below. |
| 741 |
.SS Boolean Flags: |
| 742 |
.IP \[bu] 2 |
| 743 |
noexec |
| 744 |
.RS 2 |
| 745 |
.PP |
| 746 |
If set, all commands run via sudo will behave as if the NOEXEC tag has |
| 747 |
been set, unless overridden by an EXEC tag. |
| 748 |
See the description of EXEC and NOEXEC as well as the \f[I]Preventing |
| 749 |
shell escapes\f[R] section at the end of this manual. |
| 750 |
This flag is off by default. |
| 751 |
.RE |
| 752 |
.IP \[bu] 2 |
| 753 |
noninteractive_auth If set, authentication will be attempted even in |
| 754 |
non\-interactive mode (when sudo\[cq]s \-n option is specified). |
| 755 |
This allows authentication methods that don\[cq]t require user |
| 756 |
interaction to succeed. |
| 757 |
Authentication methods that require input from the user\[cq]s terminal |
| 758 |
will still fail. |
| 759 |
If disabled, authentication will not be attempted in non\-interactive |
| 760 |
mode. |
| 761 |
This flag is off by default. |
| 762 |
.IP \[bu] 2 |
| 763 |
env_editor |
| 764 |
.RS 2 |
| 765 |
.PP |
| 766 |
If set, visudo will use the value of the SUDO_EDITOR, VISUAL or EDITOR |
| 767 |
environment variables before falling back on the default editor list. |
| 768 |
Note that visudo is typically run as root so this flag may allow a user |
| 769 |
with visudo privileges to run arbitrary commands as root without |
| 770 |
logging. |
| 771 |
An alternative is to place a colon\-separated list of \[lq]safe\[rq] |
| 772 |
editors int the editor setting. |
| 773 |
visudo will then only use SUDO_EDITOR, VISUAL or EDITOR if they match a |
| 774 |
value specified in editor. |
| 775 |
If the env_reset flag is enabled, the SUDO_EDITOR, VISUAL and/or EDITOR |
| 776 |
environment variables must be present in the env_keep list for the |
| 777 |
env_editor flag to function when visudo is invoked via sudo. |
| 778 |
This flag is on by default. |
| 779 |
.RE |
| 780 |
.IP \[bu] 2 |
| 781 |
pwfeedback |
| 782 |
.RS 2 |
| 783 |
.PP |
| 784 |
By default, sudo reads the password like most other Unix programs, by |
| 785 |
turning off echo until the user hits the return (or enter) key. |
| 786 |
Some users become confused by this as it appears to them that sudo has |
| 787 |
hung at this point. |
| 788 |
When pwfeedback is set, sudo will provide visual feedback when the user |
| 789 |
presses a key. |
| 790 |
Feedback can always be turned off by using the TAB key. |
| 791 |
This flag is on by default. |
| 792 |
.RE |
| 793 |
.IP \[bu] 2 |
| 794 |
rootpw |
| 795 |
.RS 2 |
| 796 |
.PP |
| 797 |
If set, sudo will prompt for the root password instead of the password |
| 798 |
of the invoking user when running a command or editing a file. |
| 799 |
This flag is off by default. |
| 800 |
.RE |
| 801 |
.IP \[bu] 2 |
| 802 |
setenv |
| 803 |
.RS 2 |
| 804 |
.PP |
| 805 |
Allow the user to set environment variables set via the command line |
| 806 |
that are not subject to the restrictions imposed by env_check, |
| 807 |
env_delete, or env_keep. |
| 808 |
As such, only trusted users should be allowed to set variables in this |
| 809 |
manner. |
| 810 |
This flag is off by default. |
| 811 |
.RE |
| 812 |
.IP \[bu] 2 |
| 813 |
targetpw |
| 814 |
.RS 2 |
| 815 |
.PP |
| 816 |
If set, sudo will prompt for the password of the user specified by the |
| 817 |
\-u option (defaults to root) instead of the password of the invoking |
| 818 |
user when running a command or editing a file. |
| 819 |
Note that this flag precludes the use of a user\-ID not listed in the |
| 820 |
passwd database as an argument to the \-u option. |
| 821 |
This flag is off by default. |
| 822 |
.RE |
| 823 |
.IP \[bu] 2 |
| 824 |
umask_override |
| 825 |
.RS 2 |
| 826 |
.PP |
| 827 |
If set, sudo will set the umask as specified in the sudoers file without |
| 828 |
modification. |
| 829 |
This makes it possible to specify a umask in the sudoers file that is |
| 830 |
more permissive than the user\[cq]s own umask. |
| 831 |
If umask_override is not set, sudo will set the umask to be the union of |
| 832 |
the user\[cq]s umask and what is specified in sudoers. |
| 833 |
This flag is off by default. |
| 834 |
.RE |
| 835 |
.IP \[bu] 2 |
| 836 |
use_pty |
| 837 |
.RS 2 |
| 838 |
.PP |
| 839 |
If set, and sudo is running in a terminal, the command will be run in a |
| 840 |
pseudo\-terminal (even if no I/O logging is being done). |
| 841 |
If the sudo process is not attached to a terminal, use_pty has no |
| 842 |
effect. |
| 843 |
.PP |
| 844 |
A malicious program run under sudo may be capable of injecting commands |
| 845 |
into the user\[cq]s terminal or running a background process that |
| 846 |
retains access to the user\[cq]s terminal device even after the main |
| 847 |
program has finished executing. |
| 848 |
By running the command in a separate pseudo\-terminal, this attack is no |
| 849 |
longer possible. |
| 850 |
This flag is on by default. |
| 851 |
.RE |
| 852 |
.SS Integers: |
| 853 |
.IP \[bu] 2 |
| 854 |
passwd_tries |
| 855 |
.RS 2 |
| 856 |
.PP |
| 857 |
The number of tries a user gets to enter his/her password before sudo |
| 858 |
logs the failure and exits. |
| 859 |
The default is 3. |
| 860 |
.RE |
| 861 |
.SS Integers that can be used in a boolean context: |
| 862 |
.IP \[bu] 2 |
| 863 |
timestamp_timeout |
| 864 |
.RS 2 |
| 865 |
.PP |
| 866 |
Number of minutes that can elapse before sudo will ask for a passwd |
| 867 |
again. |
| 868 |
The timeout may include a fractional component if minute granularity is |
| 869 |
insufficient, for example 2.5. |
| 870 |
The default is 15. |
| 871 |
Set this to 0 to always prompt for a password. |
| 872 |
.RE |
| 873 |
.IP \[bu] 2 |
| 874 |
umask |
| 875 |
.RS 2 |
| 876 |
.PP |
| 877 |
File mode creation mask to use when running the command. |
| 878 |
Negate this option or set it to 0777 to prevent sudo from changing the |
| 879 |
umask. |
| 880 |
Unless the umask_override flag is set, the actual umask will be the |
| 881 |
union of the user\[cq]s umask and the value of the umask setting, which |
| 882 |
defaults to 0022. |
| 883 |
This guarantees that sudo never lowers the umask when running a command. |
| 884 |
.PP |
| 885 |
If umask is explicitly set, it will override any umask setting in PAM. |
| 886 |
If umask is not set, the umask specified by PAM will take precedence. |
| 887 |
The umask setting in PAM is not used for sudoedit, which does not create |
| 888 |
a new PAM session. |
| 889 |
.RE |
| 890 |
.SS Strings |
| 891 |
.IP \[bu] 2 |
| 892 |
editor |
| 893 |
.RS 2 |
| 894 |
.PP |
| 895 |
A colon (`:') separated list of editor path names used by |
| 896 |
\f[B]sudoedit\f[R] and \f[B]visudo\f[R]. |
| 897 |
For \f[B]sudoedit\f[R], this list is used to find an editor when none of |
| 898 |
the SUDO_EDITOR, VISUAL or EDITOR environment variables are set to an |
| 899 |
editor that exists and is executable. |
| 900 |
For \f[B]visudo\f[R], it is used as a white list of allowed editors; |
| 901 |
\f[B]visudo\f[R] will choose the editor that matches the user\[cq]s |
| 902 |
SUDO_EDITOR, VISUAL or EDITOR environment variable if possible, or the |
| 903 |
first editor in the list that exists and is executable if not. |
| 904 |
Unless invoked as \f[B]sudoedit\f[R], sudo does not preserve the |
| 905 |
SUDO_EDITOR, VISUAL or EDITOR environment variables unless they are |
| 906 |
present in the \f[B]env_keep\f[R] list. |
| 907 |
The default on Linux is |
| 908 |
\f[I]/usr/bin/editor:/usr/bin/nano:/usr/bin/vi\f[R]. |
| 909 |
On FreeBSD the default is \f[I]/usr/bin/vi\f[R]. |
| 910 |
.RE |
| 911 |
.SS Strings that can be used in a boolean context: |
| 912 |
.IP \[bu] 2 |
| 913 |
apparmor_profile |
| 914 |
.RS 2 |
| 915 |
.PP |
| 916 |
The default AppArmor profile to transition into when executing a |
| 917 |
command. |
| 918 |
The default apparmor_profile can be overridden for individual sudoers |
| 919 |
entries by specifying the APPARMOR_PROFILE option. |
| 920 |
This option is only available when sudo\-rs is built with AppArmor |
| 921 |
support. |
| 922 |
This option is not set by default. |
| 923 |
.RE |
| 924 |
.IP \[bu] 2 |
| 925 |
runcwd |
| 926 |
.RS 2 |
| 927 |
.PP |
| 928 |
If set, sudo will use this value for the working directory when running |
| 929 |
a command. |
| 930 |
The special value \[lq]*\[rq] will allow the user to specify the working |
| 931 |
directory via sudo\[cq]s \-D option. |
| 932 |
See the \f[I]Chdir_Spec\f[R] section for more details. |
| 933 |
.RE |
| 934 |
.IP \[bu] 2 |
| 935 |
secure_path |
| 936 |
.RS 2 |
| 937 |
.PP |
| 938 |
If set, sudo will use this value in place of the user\[cq]s PATH |
| 939 |
environment variable. |
| 940 |
This option can be used to reset the PATH to a known good value that |
| 941 |
contains directories for system administrator commands such as |
| 942 |
/usr/sbin. |
| 943 |
This option is not set by default. |
| 944 |
.RE |
| 945 |
.SS Lists that can be used in a boolean context: |
| 946 |
.IP \[bu] 2 |
| 947 |
env_check |
| 948 |
.RS 2 |
| 949 |
.PP |
| 950 |
Environment variables to be removed from the user\[cq]s environment |
| 951 |
unless they are considered \[lq]safe\[rq]. |
| 952 |
For all variables except TZ, \[lq]safe\[rq] means that the |
| 953 |
variable\[cq]s value does not contain any `%' or `/' characters. |
| 954 |
This can be used to guard against printf\-style format vulnerabilities |
| 955 |
in poorly\-written programs. |
| 956 |
The TZ variable is considered unsafe if any of the following are true: |
| 957 |
.IP |
| 958 |
.EX |
| 959 |
• It consists of a fully\-qualified path name, optionally prefixed with a colon (\[oq]:\[cq]), that does not match the location of the zoneinfo directory. |
| 960 |
|
| 961 |
• It contains a .. path element. |
| 962 |
|
| 963 |
• It contains white space or non\-printable characters. |
| 964 |
|
| 965 |
• It is longer than the value of PATH_MAX. |
| 966 |
.EE |
| 967 |
.RE |
| 968 |
.PP |
| 969 |
The argument may be a double\-quoted, space\-separated list or a single |
| 970 |
value without double\-quotes. |
| 971 |
The list can be replaced, added to, deleted from, or disabled by using |
| 972 |
the =, +=, \-=, and ! |
| 973 |
operators respectively. |
| 974 |
Regardless of whether the env_reset option is enabled or disabled, |
| 975 |
variables specified by env_check will be preserved in the environment if |
| 976 |
they pass the aforementioned check. |
| 977 |
The global list of environment variables to check is displayed when sudo |
| 978 |
is run by root with the \-V option. |
| 979 |
.IP \[bu] 2 |
| 980 |
env_keep |
| 981 |
.RS 2 |
| 982 |
.PP |
| 983 |
Environment variables to be preserved in the user\[cq]s environment when |
| 984 |
the env_reset option is in effect. |
| 985 |
This allows fine\-grained control over the environment sudo\-spawned |
| 986 |
processes will receive. |
| 987 |
The argument may be a double\-quoted, space\-separated list or a single |
| 988 |
value without double\-quotes. |
| 989 |
The list can be replaced, added to, deleted from, or disabled by using |
| 990 |
the =, +=, \-=, and ! |
| 991 |
operators respectively. |
| 992 |
The global list of variables to keep is displayed when sudo is run by |
| 993 |
root with the \-V option. |
| 994 |
.PP |
| 995 |
Preserving the HOME environment variable has security implications since |
| 996 |
many programs use it when searching for configuration or data files. |
| 997 |
Adding HOME to env_keep may enable a user to run unrestricted commands |
| 998 |
via sudo and is strongly discouraged. |
| 999 |
Users wishing to edit files with sudo should run \f[B]sudoedit\f[R] (or |
| 1000 |
\f[B]sudo \-e\f[R]) to get their accustomed editor configuration instead |
| 1001 |
of invoking the editor directly. |
| 1002 |
.RE |
| 1003 |
.SS LOG FORMAT |
| 1004 |
sudo\-rs logs events via syslog(3). |
| 1005 |
.SS FILES |
| 1006 |
.IP |
| 1007 |
.EX |
| 1008 |
/etc/sudoers\-rs List of who can run what (for co\-existence of sudo\-rs and Todd Miller\[aq]s sudo) |
| 1009 |
|
| 1010 |
/etc/sudoers List of who can run what (sudo\-compatible) |
| 1011 |
|
| 1012 |
/run/sudo/ts Directory containing timestamps for the sudoers security policy |
| 1013 |
.EE |
| 1014 |
.SS SECURITY NOTES |
| 1015 |
.SS Limitations of the `!' operator |
| 1016 |
It is generally not effective to \[lq]subtract\[rq] commands from ALL |
| 1017 |
using the `!' operator. |
| 1018 |
A user can trivially circumvent this by copying the desired command to a |
| 1019 |
different name and then executing that. |
| 1020 |
For example: |
| 1021 |
.IP |
| 1022 |
.EX |
| 1023 |
bill ALL = ALL, !SU, !SHELLS |
| 1024 |
.EE |
| 1025 |
.PP |
| 1026 |
Doesn\[cq]t really prevent bill from running the commands listed in SU |
| 1027 |
or SHELLS since he can simply copy those commands to a different name, |
| 1028 |
or use a shell escape from an editor or other program. |
| 1029 |
Therefore, these kind of restrictions should be considered advisory at |
| 1030 |
best (and reinforced by policy). |
| 1031 |
.PP |
| 1032 |
In general, if a user has sudo ALL there is nothing to prevent them from |
| 1033 |
creating their own program that gives them a root shell (or making their |
| 1034 |
own copy of a shell) regardless of any `!' elements in the user |
| 1035 |
specification. |
| 1036 |
.SS Security implications of \f[CR]fast_glob\f[R] |
| 1037 |
sudo\-rs uses \[ga]fast_glob, which further means it is not possible to |
| 1038 |
reliably negate commands where the path name includes globbing (aka |
| 1039 |
wildcard) characters. |
| 1040 |
This is because the Rust library\[cq]s fnmatch function cannot resolve |
| 1041 |
relative paths. |
| 1042 |
While this is typically only an inconvenience for rules that grant |
| 1043 |
privileges, it can result in a security issue for rules that subtract or |
| 1044 |
revoke privileges. |
| 1045 |
.PP |
| 1046 |
For example, given the following sudoers file entry: |
| 1047 |
.IP |
| 1048 |
.EX |
| 1049 |
john ALL = /usr/bin/passwd [a\-zA\-Z0\-9]*, /usr/bin/chsh [a\-zA\-Z0\-9]*,\[rs] |
| 1050 |
/usr/bin/chfn [a\-zA\-Z0\-9]*, !/usr/bin/* root |
| 1051 |
.EE |
| 1052 |
.PP |
| 1053 |
User john can still run /usr/bin/passwd root if fast_glob is enabled by |
| 1054 |
changing to /usr/bin and running ./passwd root instead. |
| 1055 |
.SS Preventing shell escapes |
| 1056 |
Once sudo executes a program, that program is free to do whatever it |
| 1057 |
pleases, including run other programs. |
| 1058 |
This can be a security issue since it is not uncommon for a program to |
| 1059 |
allow shell escapes, which lets a user bypass sudo\[cq]s access control |
| 1060 |
and logging. |
| 1061 |
Common programs that permit shell escapes include shells (obviously), |
| 1062 |
editors, paginators (such as \f[I]less\f[R]), mail, and terminal |
| 1063 |
programs. |
| 1064 |
.PP |
| 1065 |
On Linux, sudo\-rs has sudo\[cq]s \f[B]noexec\f[R] functionality, based |
| 1066 |
on a seccomp() filter. |
| 1067 |
Programs that are run in \f[B]noexec\f[R] mode cannot run other |
| 1068 |
programs. |
| 1069 |
The implementation in sudo\-rs is different than in Todd Miller\[cq]s |
| 1070 |
sudo, and should also work on statically linked binaries. |
| 1071 |
.PP |
| 1072 |
Note that restricting shell escapes is not a panacea. |
| 1073 |
Programs running as root are still capable of many potentially hazardous |
| 1074 |
operations (such as changing or overwriting files) that could lead to |
| 1075 |
unintended privilege escalation. |
| 1076 |
NOEXEC is also not a protection against malicious programs. |
| 1077 |
It doesn\[cq]t prevent mapping memory as executable, nor does it protect |
| 1078 |
against future syscalls that can do an exec() like the proposed |
| 1079 |
\f[CR]io_uring\f[R] exec feature in Linux. |
| 1080 |
And it also doesn\[cq]t protect against honest programs that |
| 1081 |
intentionally or not allow the user to write to /proc/self/mem for the |
| 1082 |
same reasons as that it doesn\[cq]t protect against malicious programs. |
| 1083 |
You should always try out if \f[B]noexec\f[R] indeed prevents shell |
| 1084 |
escapes for the programs it is intended to be used with. |
| 1085 |
.SS Timestamp file checks |
| 1086 |
sudo\-rs will check the ownership of its timestamp directory |
| 1087 |
(/run/sudo/ts by default) and ignore the directory\[cq]s contents if it |
| 1088 |
is not owned by root or if it is writable by a user other than root. |
| 1089 |
.PP |
| 1090 |
While the timestamp directory should be cleared at reboot time, to avoid |
| 1091 |
potential problems, sudo\-rs will ignore timestamp files that date from |
| 1092 |
before the machine booted on systems where the boot time is available. |
| 1093 |
.PP |
| 1094 |
Some systems with graphical desktop environments allow unprivileged |
| 1095 |
users to change the system clock. |
| 1096 |
Since sudo\-rs relies on the system clock for timestamp validation, it |
| 1097 |
may be possible on such systems for a user to run sudo for longer than |
| 1098 |
\f[I]timestamp_timeout\f[R] by setting the clock back. |
| 1099 |
To combat this, \f[CR]sudo\-rs\f[R] uses a monotonic clock (which never |
| 1100 |
moves backwards) for its timestamps if the system supports it. |
| 1101 |
sudo\-rs will not honor timestamps set far in the future. |
| 1102 |
.SS SEE ALSO |
| 1103 |
su(1), fnmatch(3), glob(3), sudo(8), visudo(8) |
| 1104 |
.SS CAVEATS |
| 1105 |
The sudoers file should always be edited by the visudo utility which |
| 1106 |
locks the file and checks for syntax errors. |
| 1107 |
If sudoers contains syntax errors, you may lock yourself out of being |
| 1108 |
able to use sudo. |
| 1109 |
.SS BUGS |
| 1110 |
If you feel you have found a bug in sudo\-rs, please submit a bug report |
| 1111 |
at https://github.com/trifectatechfoundation/sudo\-rs/issues/ |
| 1112 |
.SH AUTHORS |
| 1113 |
This man page is a modified version of the sudoers(5) documentation |
| 1114 |
written by Todd Miller; see https://www.sudo.ws/ for the original. |
| 1115 |
.SS DISCLAIMER |
| 1116 |
sudo\-rs is provided \[lq]AS IS\[rq] and any express or implied |
| 1117 |
warranties, including, but not limited to, the implied warranties of |
| 1118 |
merchantability and fitness for a particular purpose are disclaimed. |