Igor Sarkisov | 9335adb | 2020-10-06 13:23:33 -0700 | [diff] [blame^] | 1 | |
| 2 | |
| 3 | |
| 4 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 5 | |
| 6 | |
| 7 | NNAAMMEE |
| 8 | sudo, sudoedit - execute a command as another user |
| 9 | |
| 10 | SSYYNNOOPPSSIISS |
| 11 | ssuuddoo --hh | --KK | --kk | --LL | --VV |
| 12 | |
| 13 | ssuuddoo --vv [--AAkknnSS] [--aa _a_u_t_h___t_y_p_e] [--gg _g_r_o_u_p _n_a_m_e|_#_g_i_d] [--pp _p_r_o_m_p_t] |
| 14 | [--uu _u_s_e_r_n_a_m_e|_#_u_i_d] |
| 15 | |
| 16 | ssuuddoo --ll[[ll]] [--AAkknnSS] [--aa _a_u_t_h___t_y_p_e] [--gg _g_r_o_u_p _n_a_m_e|_#_g_i_d] [--pp _p_r_o_m_p_t] |
| 17 | [--UU _u_s_e_r _n_a_m_e] [--uu _u_s_e_r _n_a_m_e|_#_u_i_d] [_c_o_m_m_a_n_d] |
| 18 | |
| 19 | ssuuddoo [--AAbbEEHHnnPPSS] [--aa _a_u_t_h___t_y_p_e] [--CC _f_d] [--cc _c_l_a_s_s|_-] |
| 20 | [--gg _g_r_o_u_p _n_a_m_e|_#_g_i_d] [--pp _p_r_o_m_p_t] [--rr _r_o_l_e] [--tt _t_y_p_e] |
| 21 | [--uu _u_s_e_r _n_a_m_e|_#_u_i_d] [VVAARR=_v_a_l_u_e] [--ii | --ss] [_c_o_m_m_a_n_d] |
| 22 | |
| 23 | ssuuddooeeddiitt [--AAnnSS] [--aa _a_u_t_h___t_y_p_e] [--CC _f_d] [--cc _c_l_a_s_s|_-] |
| 24 | [--gg _g_r_o_u_p _n_a_m_e|_#_g_i_d] [--pp _p_r_o_m_p_t] [--uu _u_s_e_r _n_a_m_e|_#_u_i_d] file ... |
| 25 | |
| 26 | DDEESSCCRRIIPPTTIIOONN |
| 27 | ssuuddoo allows a permitted user to execute a _c_o_m_m_a_n_d as the superuser or |
| 28 | another user, as specified in the _s_u_d_o_e_r_s file. The real and effective |
| 29 | uid and gid are set to match those of the target user as specified in |
| 30 | the passwd file and the group vector is initialized based on the group |
| 31 | file (unless the --PP option was specified). If the invoking user is |
| 32 | root or if the target user is the same as the invoking user, no |
| 33 | password is required. Otherwise, ssuuddoo requires that users authenticate |
| 34 | themselves with a password by default (NOTE: in the default |
| 35 | configuration this is the user's password, not the root password). |
| 36 | Once a user has been authenticated, a time stamp is updated and the |
| 37 | user may then use sudo without a password for a short period of time (5 |
| 38 | minutes unless overridden in _s_u_d_o_e_r_s). |
| 39 | |
| 40 | When invoked as ssuuddooeeddiitt, the --ee option (described below), is implied. |
| 41 | |
| 42 | ssuuddoo determines who is an authorized user by consulting the file |
| 43 | _/_e_t_c_/_s_u_d_o_e_r_s. By running ssuuddoo with the --vv option, a user can update |
| 44 | the time stamp without running a _c_o_m_m_a_n_d. If a password is required, |
| 45 | ssuuddoo will exit if the user's password is not entered within a |
| 46 | configurable time limit. The default password prompt timeout is 5 |
| 47 | minutes. |
| 48 | |
| 49 | If a user who is not listed in the _s_u_d_o_e_r_s file tries to run a command |
| 50 | via ssuuddoo, mail is sent to the proper authorities, as defined at |
| 51 | configure time or in the _s_u_d_o_e_r_s file (defaults to root). Note that |
| 52 | the mail will not be sent if an unauthorized user tries to run sudo |
| 53 | with the --ll or --vv option. This allows users to determine for |
| 54 | themselves whether or not they are allowed to use ssuuddoo. |
| 55 | |
| 56 | If ssuuddoo is run by root and the SUDO_USER environment variable is set, |
| 57 | ssuuddoo will use this value to determine who the actual user is. This can |
| 58 | be used by a user to log commands through sudo even when a root shell |
| 59 | has been invoked. It also allows the --ee option to remain useful even |
| 60 | when being run via a sudo-run script or program. Note however, that |
| 61 | |
| 62 | |
| 63 | |
| 64 | 1.7.4 July 19, 2010 1 |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 71 | |
| 72 | |
| 73 | the sudoers lookup is still done for root, not the user specified by |
| 74 | SUDO_USER. |
| 75 | |
| 76 | ssuuddoo can log both successful and unsuccessful attempts (as well as |
| 77 | errors) to _s_y_s_l_o_g(3), a log file, or both. By default ssuuddoo will log |
| 78 | via _s_y_s_l_o_g(3) but this is changeable at configure time or via the |
| 79 | _s_u_d_o_e_r_s file. |
| 80 | |
| 81 | OOPPTTIIOONNSS |
| 82 | ssuuddoo accepts the following command line options: |
| 83 | |
| 84 | -A Normally, if ssuuddoo requires a password, it will read it from |
| 85 | the current terminal. If the --AA (_a_s_k_p_a_s_s) option is |
| 86 | specified, a (possibly graphical) helper program is |
| 87 | executed to read the user's password and output the |
| 88 | password to the standard output. If the SUDO_ASKPASS |
| 89 | environment variable is set, it specifies the path to the |
| 90 | helper program. Otherwise, the value specified by the |
| 91 | _a_s_k_p_a_s_s option in _s_u_d_o_e_r_s(4) is used. |
| 92 | |
| 93 | -a _t_y_p_e The --aa (_a_u_t_h_e_n_t_i_c_a_t_i_o_n _t_y_p_e) option causes ssuuddoo to use the |
| 94 | specified authentication type when validating the user, as |
| 95 | allowed by _/_e_t_c_/_l_o_g_i_n_._c_o_n_f. The system administrator may |
| 96 | specify a list of sudo-specific authentication methods by |
| 97 | adding an "auth-sudo" entry in _/_e_t_c_/_l_o_g_i_n_._c_o_n_f. This |
| 98 | option is only available on systems that support BSD |
| 99 | authentication. |
| 100 | |
| 101 | -b The --bb (_b_a_c_k_g_r_o_u_n_d) option tells ssuuddoo to run the given |
| 102 | command in the background. Note that if you use the --bb |
| 103 | option you cannot use shell job control to manipulate the |
| 104 | process. |
| 105 | |
| 106 | -C _f_d Normally, ssuuddoo will close all open file descriptors other |
| 107 | than standard input, standard output and standard error. |
| 108 | The --CC (_c_l_o_s_e _f_r_o_m) option allows the user to specify a |
| 109 | starting point above the standard error (file descriptor |
| 110 | three). Values less than three are not permitted. This |
| 111 | option is only available if the administrator has enabled |
| 112 | the _c_l_o_s_e_f_r_o_m___o_v_e_r_r_i_d_e option in _s_u_d_o_e_r_s(4). |
| 113 | |
| 114 | -c _c_l_a_s_s The --cc (_c_l_a_s_s) option causes ssuuddoo to run the specified |
| 115 | command with resources limited by the specified login |
| 116 | class. The _c_l_a_s_s argument can be either a class name as |
| 117 | defined in _/_e_t_c_/_l_o_g_i_n_._c_o_n_f, or a single '-' character. |
| 118 | Specifying a _c_l_a_s_s of - indicates that the command should |
| 119 | be run restricted by the default login capabilities for the |
| 120 | user the command is run as. If the _c_l_a_s_s argument |
| 121 | specifies an existing user class, the command must be run |
| 122 | as root, or the ssuuddoo command must be run from a shell that |
| 123 | is already root. This option is only available on systems |
| 124 | with BSD login classes. |
| 125 | |
| 126 | -E The --EE (_p_r_e_s_e_r_v_e _e_n_v_i_r_o_n_m_e_n_t) option will override the |
| 127 | |
| 128 | |
| 129 | |
| 130 | 1.7.4 July 19, 2010 2 |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 137 | |
| 138 | |
| 139 | _e_n_v___r_e_s_e_t option in _s_u_d_o_e_r_s(4)). It is only available when |
| 140 | either the matching command has the SETENV tag or the |
| 141 | _s_e_t_e_n_v option is set in _s_u_d_o_e_r_s(4). |
| 142 | |
| 143 | -e The --ee (_e_d_i_t) option indicates that, instead of running a |
| 144 | command, the user wishes to edit one or more files. In |
| 145 | lieu of a command, the string "sudoedit" is used when |
| 146 | consulting the _s_u_d_o_e_r_s file. If the user is authorized by |
| 147 | _s_u_d_o_e_r_s the following steps are taken: |
| 148 | |
| 149 | 1. Temporary copies are made of the files to be edited |
| 150 | with the owner set to the invoking user. |
| 151 | |
| 152 | 2. The editor specified by the SUDO_EDITOR, VISUAL or |
| 153 | EDITOR environment variables is run to edit the |
| 154 | temporary files. If none of SUDO_EDITOR, VISUAL or |
| 155 | EDITOR are set, the first program listed in the _e_d_i_t_o_r |
| 156 | _s_u_d_o_e_r_s variable is used. |
| 157 | |
| 158 | 3. If they have been modified, the temporary files are |
| 159 | copied back to their original location and the |
| 160 | temporary versions are removed. |
| 161 | |
| 162 | If the specified file does not exist, it will be created. |
| 163 | Note that unlike most commands run by ssuuddoo, the editor is |
| 164 | run with the invoking user's environment unmodified. If, |
| 165 | for some reason, ssuuddoo is unable to update a file with its |
| 166 | edited version, the user will receive a warning and the |
| 167 | edited copy will remain in a temporary file. |
| 168 | |
| 169 | -g _g_r_o_u_p Normally, ssuuddoo sets the primary group to the one specified |
| 170 | by the passwd database for the user the command is being |
| 171 | run as (by default, root). The --gg (_g_r_o_u_p) option causes |
| 172 | ssuuddoo to run the specified command with the primary group |
| 173 | set to _g_r_o_u_p. To specify a _g_i_d instead of a _g_r_o_u_p _n_a_m_e, |
| 174 | use _#_g_i_d. When running commands as a _g_i_d, many shells |
| 175 | require that the '#' be escaped with a backslash ('\'). If |
| 176 | no --uu option is specified, the command will be run as the |
| 177 | invoking user (not root). In either case, the primary |
| 178 | group will be set to _g_r_o_u_p. |
| 179 | |
| 180 | -H The --HH (_H_O_M_E) option sets the HOME environment variable to |
| 181 | the homedir of the target user (root by default) as |
| 182 | specified in _p_a_s_s_w_d(4). The default handling of the HOME |
| 183 | environment variable depends on _s_u_d_o_e_r_s(4) settings. By |
| 184 | default, ssuuddoo will set HOME if _e_n_v___r_e_s_e_t or _a_l_w_a_y_s___s_e_t___h_o_m_e |
| 185 | are set, or if _s_e_t___h_o_m_e is set and the --ss option is |
| 186 | specified on the command line. |
| 187 | |
| 188 | -h The --hh (_h_e_l_p) option causes ssuuddoo to print a usage message |
| 189 | and exit. |
| 190 | |
| 191 | -i [command] |
| 192 | The --ii (_s_i_m_u_l_a_t_e _i_n_i_t_i_a_l _l_o_g_i_n) option runs the shell |
| 193 | |
| 194 | |
| 195 | |
| 196 | 1.7.4 July 19, 2010 3 |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 203 | |
| 204 | |
| 205 | specified in the _p_a_s_s_w_d(4) entry of the target user as a |
| 206 | login shell. This means that login-specific resource files |
| 207 | such as .profile or .login will be read by the shell. If a |
| 208 | command is specified, it is passed to the shell for |
| 209 | execution. Otherwise, an interactive shell is executed. |
| 210 | ssuuddoo attempts to change to that user's home directory |
| 211 | before running the shell. It also initializes the |
| 212 | environment, leaving _D_I_S_P_L_A_Y and _T_E_R_M unchanged, setting |
| 213 | _H_O_M_E, _M_A_I_L, _S_H_E_L_L, _U_S_E_R, _L_O_G_N_A_M_E, and _P_A_T_H, as well as the |
| 214 | contents of _/_e_t_c_/_e_n_v_i_r_o_n_m_e_n_t on Linux and AIX systems. All |
| 215 | other environment variables are removed. |
| 216 | |
| 217 | -K The --KK (sure _k_i_l_l) option is like --kk except that it removes |
| 218 | the user's time stamp entirely and may not be used in |
| 219 | conjunction with a command or other option. This option |
| 220 | does not require a password. |
| 221 | |
| 222 | -k When used by itself, the --kk (_k_i_l_l) option to ssuuddoo |
| 223 | invalidates the user's time stamp by setting the time on it |
| 224 | to the Epoch. The next time ssuuddoo is run a password will be |
| 225 | required. This option does not require a password and was |
| 226 | added to allow a user to revoke ssuuddoo permissions from a |
| 227 | .logout file. |
| 228 | |
| 229 | When used in conjunction with a command or an option that |
| 230 | may require a password, the --kk option will cause ssuuddoo to |
| 231 | ignore the user's time stamp file. As a result, ssuuddoo will |
| 232 | prompt for a password (if one is required by _s_u_d_o_e_r_s) and |
| 233 | will not update the user's time stamp file. |
| 234 | |
| 235 | -L The --LL (_l_i_s_t defaults) option will list the parameters that |
| 236 | may be set in a _D_e_f_a_u_l_t_s line along with a short |
| 237 | description for each. This option will be removed from a |
| 238 | future version of ssuuddoo. |
| 239 | |
| 240 | -l[l] [_c_o_m_m_a_n_d] |
| 241 | If no _c_o_m_m_a_n_d is specified, the --ll (_l_i_s_t) option will list |
| 242 | the allowed (and forbidden) commands for the invoking user |
| 243 | (or the user specified by the --UU option) on the current |
| 244 | host. If a _c_o_m_m_a_n_d is specified and is permitted by |
| 245 | _s_u_d_o_e_r_s, the fully-qualified path to the command is |
| 246 | displayed along with any command line arguments. If |
| 247 | _c_o_m_m_a_n_d is specified but not allowed, ssuuddoo will exit with a |
| 248 | status value of 1. If the --ll option is specified with an ll |
| 249 | argument (i.e. --llll), or if --ll is specified multiple times, |
| 250 | a longer list format is used. |
| 251 | |
| 252 | -n The --nn (_n_o_n_-_i_n_t_e_r_a_c_t_i_v_e) option prevents ssuuddoo from |
| 253 | prompting the user for a password. If a password is |
| 254 | required for the command to run, ssuuddoo will display an error |
| 255 | messages and exit. |
| 256 | |
| 257 | -P The --PP (_p_r_e_s_e_r_v_e _g_r_o_u_p _v_e_c_t_o_r) option causes ssuuddoo to |
| 258 | preserve the invoking user's group vector unaltered. By |
| 259 | |
| 260 | |
| 261 | |
| 262 | 1.7.4 July 19, 2010 4 |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 269 | |
| 270 | |
| 271 | default, ssuuddoo will initialize the group vector to the list |
| 272 | of groups the target user is in. The real and effective |
| 273 | group IDs, however, are still set to match the target user. |
| 274 | |
| 275 | -p _p_r_o_m_p_t The --pp (_p_r_o_m_p_t) option allows you to override the default |
| 276 | password prompt and use a custom one. The following |
| 277 | percent (`%') escapes are supported: |
| 278 | |
| 279 | %H expanded to the local host name including the domain |
| 280 | name (on if the machine's host name is fully qualified |
| 281 | or the _f_q_d_n _s_u_d_o_e_r_s option is set) |
| 282 | |
| 283 | %h expanded to the local host name without the domain name |
| 284 | |
| 285 | %p expanded to the user whose password is being asked for |
| 286 | (respects the _r_o_o_t_p_w, _t_a_r_g_e_t_p_w and _r_u_n_a_s_p_w flags in |
| 287 | _s_u_d_o_e_r_s) |
| 288 | |
| 289 | %U expanded to the login name of the user the command will |
| 290 | be run as (defaults to root) |
| 291 | |
| 292 | %u expanded to the invoking user's login name |
| 293 | |
| 294 | %% two consecutive % characters are collapsed into a |
| 295 | single % character |
| 296 | |
| 297 | The prompt specified by the --pp option will override the |
| 298 | system password prompt on systems that support PAM unless |
| 299 | the _p_a_s_s_p_r_o_m_p_t___o_v_e_r_r_i_d_e flag is disabled in _s_u_d_o_e_r_s. |
| 300 | |
| 301 | -r _r_o_l_e The --rr (_r_o_l_e) option causes the new (SELinux) security |
| 302 | context to have the role specified by _r_o_l_e. |
| 303 | |
| 304 | -S The --SS (_s_t_d_i_n) option causes ssuuddoo to read the password from |
| 305 | the standard input instead of the terminal device. The |
| 306 | password must be followed by a newline character. |
| 307 | |
| 308 | -s [command] |
| 309 | The --ss (_s_h_e_l_l) option runs the shell specified by the _S_H_E_L_L |
| 310 | environment variable if it is set or the shell as specified |
| 311 | in _p_a_s_s_w_d(4). If a command is specified, it is passed to |
| 312 | the shell for execution. Otherwise, an interactive shell |
| 313 | is executed. |
| 314 | |
| 315 | -t _t_y_p_e The --tt (_t_y_p_e) option causes the new (SELinux) security |
| 316 | context to have the type specified by _t_y_p_e. If no type is |
| 317 | specified, the default type is derived from the specified |
| 318 | role. |
| 319 | |
| 320 | -U _u_s_e_r The --UU (_o_t_h_e_r _u_s_e_r) option is used in conjunction with the |
| 321 | --ll option to specify the user whose privileges should be |
| 322 | listed. Only root or a user with ssuuddoo ALL on the current |
| 323 | host may use this option. |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | 1.7.4 July 19, 2010 5 |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 335 | |
| 336 | |
| 337 | -u _u_s_e_r The --uu (_u_s_e_r) option causes ssuuddoo to run the specified |
| 338 | command as a user other than _r_o_o_t. To specify a _u_i_d |
| 339 | instead of a _u_s_e_r _n_a_m_e, use _#_u_i_d. When running commands as |
| 340 | a _u_i_d, many shells require that the '#' be escaped with a |
| 341 | backslash ('\'). Note that if the _t_a_r_g_e_t_p_w Defaults option |
| 342 | is set (see _s_u_d_o_e_r_s(4)) it is not possible to run commands |
| 343 | with a uid not listed in the password database. |
| 344 | |
| 345 | -V The --VV (_v_e_r_s_i_o_n) option causes ssuuddoo to print the version |
| 346 | number and exit. If the invoking user is already root the |
| 347 | --VV option will print out a list of the defaults ssuuddoo was |
| 348 | compiled with as well as the machine's local network |
| 349 | addresses. |
| 350 | |
| 351 | -v If given the --vv (_v_a_l_i_d_a_t_e) option, ssuuddoo will update the |
| 352 | user's time stamp, prompting for the user's password if |
| 353 | necessary. This extends the ssuuddoo timeout for another 5 |
| 354 | minutes (or whatever the timeout is set to in _s_u_d_o_e_r_s) but |
| 355 | does not run a command. |
| 356 | |
| 357 | -- The ---- option indicates that ssuuddoo should stop processing |
| 358 | command line arguments. |
| 359 | |
| 360 | Environment variables to be set for the command may also be passed on |
| 361 | the command line in the form of VVAARR=_v_a_l_u_e, e.g. |
| 362 | LLDD__LLIIBBRRAARRYY__PPAATTHH=_/_u_s_r_/_l_o_c_a_l_/_p_k_g_/_l_i_b. Variables passed on the command |
| 363 | line are subject to the same restrictions as normal environment |
| 364 | variables with one important exception. If the _s_e_t_e_n_v option is set in |
| 365 | _s_u_d_o_e_r_s, the command to be run has the SETENV tag set or the command |
| 366 | matched is ALL, the user may set variables that would overwise be |
| 367 | forbidden. See _s_u_d_o_e_r_s(4) for more information. |
| 368 | |
| 369 | RREETTUURRNN VVAALLUUEESS |
| 370 | Upon successful execution of a program, the exit status from ssuuddoo will |
| 371 | simply be the exit status of the program that was executed. |
| 372 | |
| 373 | Otherwise, ssuuddoo quits with an exit value of 1 if there is a |
| 374 | configuration/permission problem or if ssuuddoo cannot execute the given |
| 375 | command. In the latter case the error string is printed to stderr. If |
| 376 | ssuuddoo cannot _s_t_a_t(2) one or more entries in the user's PATH an error is |
| 377 | printed on stderr. (If the directory does not exist or if it is not |
| 378 | really a directory, the entry is ignored and no error is printed.) |
| 379 | This should not happen under normal circumstances. The most common |
| 380 | reason for _s_t_a_t(2) to return "permission denied" is if you are running |
| 381 | an automounter and one of the directories in your PATH is on a machine |
| 382 | that is currently unreachable. |
| 383 | |
| 384 | SSEECCUURRIITTYY NNOOTTEESS |
| 385 | ssuuddoo tries to be safe when executing external commands. |
| 386 | |
| 387 | There are two distinct ways to deal with environment variables. By |
| 388 | default, the _e_n_v___r_e_s_e_t _s_u_d_o_e_r_s option is enabled. This causes commands |
| 389 | to be executed with a minimal environment containing TERM, PATH, HOME, |
| 390 | SHELL, LOGNAME, USER and USERNAME in addition to variables from the |
| 391 | |
| 392 | |
| 393 | |
| 394 | 1.7.4 July 19, 2010 6 |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 401 | |
| 402 | |
| 403 | invoking process permitted by the _e_n_v___c_h_e_c_k and _e_n_v___k_e_e_p _s_u_d_o_e_r_s |
| 404 | options. There is effectively a whitelist for environment variables. |
| 405 | |
| 406 | If, however, the _e_n_v___r_e_s_e_t option is disabled in _s_u_d_o_e_r_s, any variables |
| 407 | not explicitly denied by the _e_n_v___c_h_e_c_k and _e_n_v___d_e_l_e_t_e options are |
| 408 | inherited from the invoking process. In this case, _e_n_v___c_h_e_c_k and |
| 409 | _e_n_v___d_e_l_e_t_e behave like a blacklist. Since it is not possible to |
| 410 | blacklist all potentially dangerous environment variables, use of the |
| 411 | default _e_n_v___r_e_s_e_t behavior is encouraged. |
| 412 | |
| 413 | In all cases, environment variables with a value beginning with () are |
| 414 | removed as they could be interpreted as bbaasshh functions. The list of |
| 415 | environment variables that ssuuddoo allows or denies is contained in the |
| 416 | output of sudo -V when run as root. |
| 417 | |
| 418 | Note that the dynamic linker on most operating systems will remove |
| 419 | variables that can control dynamic linking from the environment of |
| 420 | setuid executables, including ssuuddoo. Depending on the operating system |
| 421 | this may include _RLD*, DYLD_*, LD_*, LDR_*, LIBPATH, SHLIB_PATH, and |
| 422 | others. These type of variables are removed from the environment |
| 423 | before ssuuddoo even begins execution and, as such, it is not possible for |
| 424 | ssuuddoo to preserve them. |
| 425 | |
| 426 | To prevent command spoofing, ssuuddoo checks "." and "" (both denoting |
| 427 | current directory) last when searching for a command in the user's PATH |
| 428 | (if one or both are in the PATH). Note, however, that the actual PATH |
| 429 | environment variable is _n_o_t modified and is passed unchanged to the |
| 430 | program that ssuuddoo executes. |
| 431 | |
| 432 | ssuuddoo will check the ownership of its time stamp directory |
| 433 | (_/_v_a_r_/_a_d_m_/_s_u_d_o by default) and ignore the directory's contents if it is |
| 434 | not owned by root or if it is writable by a user other than root. On |
| 435 | systems that allow non-root users to give away files via _c_h_o_w_n(2), if |
| 436 | the time stamp directory is located in a directory writable by anyone |
| 437 | (e.g., _/_t_m_p), it is possible for a user to create the time stamp |
| 438 | directory before ssuuddoo is run. However, because ssuuddoo checks the |
| 439 | ownership and mode of the directory and its contents, the only damage |
| 440 | that can be done is to "hide" files by putting them in the time stamp |
| 441 | dir. This is unlikely to happen since once the time stamp dir is owned |
| 442 | by root and inaccessible by any other user, the user placing files |
| 443 | there would be unable to get them back out. To get around this issue |
| 444 | you can use a directory that is not world-writable for the time stamps |
| 445 | (_/_v_a_r_/_a_d_m_/_s_u_d_o for instance) or create _/_v_a_r_/_a_d_m_/_s_u_d_o with the |
| 446 | appropriate owner (root) and permissions (0700) in the system startup |
| 447 | files. |
| 448 | |
| 449 | ssuuddoo will not honor time stamps set far in the future. Timestamps with |
| 450 | a date greater than current_time + 2 * TIMEOUT will be ignored and sudo |
| 451 | will log and complain. This is done to keep a user from creating |
| 452 | his/her own time stamp with a bogus date on systems that allow users to |
| 453 | give away files. |
| 454 | |
| 455 | On systems where the boot time is available, ssuuddoo will also not honor |
| 456 | time stamps from before the machine booted. |
| 457 | |
| 458 | |
| 459 | |
| 460 | 1.7.4 July 19, 2010 7 |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 467 | |
| 468 | |
| 469 | Since time stamp files live in the file system, they can outlive a |
| 470 | user's login session. As a result, a user may be able to login, run a |
| 471 | command with ssuuddoo after authenticating, logout, login again, and run |
| 472 | ssuuddoo without authenticating so long as the time stamp file's |
| 473 | modification time is within 5 minutes (or whatever the timeout is set |
| 474 | to in _s_u_d_o_e_r_s). When the _t_t_y___t_i_c_k_e_t_s option is enabled in _s_u_d_o_e_r_s, the |
| 475 | time stamp has per-tty granularity but still may outlive the user's |
| 476 | session. On Linux systems where the devpts filesystem is used, Solaris |
| 477 | systems with the devices filesystem, as well as other systems that |
| 478 | utilize a devfs filesystem that monotonically increase the inode number |
| 479 | of devices as they are created (such as Mac OS X), ssuuddoo is able to |
| 480 | determine when a tty-based time stamp file is stale and will ignore it. |
| 481 | Administrators should not rely on this feature as it is not universally |
| 482 | available. |
| 483 | |
| 484 | Please note that ssuuddoo will normally only log the command it explicitly |
| 485 | runs. If a user runs a command such as sudo su or sudo sh, subsequent |
| 486 | commands run from that shell will _n_o_t be logged, nor will ssuuddoo's access |
| 487 | control affect them. The same is true for commands that offer shell |
| 488 | escapes (including most editors). Because of this, care must be taken |
| 489 | when giving users access to commands via ssuuddoo to verify that the |
| 490 | command does not inadvertently give the user an effective root shell. |
| 491 | For more information, please see the PREVENTING SHELL ESCAPES section |
| 492 | in _s_u_d_o_e_r_s(4). |
| 493 | |
| 494 | EENNVVIIRROONNMMEENNTT |
| 495 | ssuuddoo utilizes the following environment variables: |
| 496 | |
| 497 | EDITOR Default editor to use in --ee (sudoedit) mode if neither |
| 498 | SUDO_EDITOR nor VISUAL is set |
| 499 | |
| 500 | MAIL In --ii mode or when _e_n_v___r_e_s_e_t is enabled in _s_u_d_o_e_r_s, set |
| 501 | to the mail spool of the target user |
| 502 | |
| 503 | HOME Set to the home directory of the target user if --ii or |
| 504 | --HH are specified, _e_n_v___r_e_s_e_t or _a_l_w_a_y_s___s_e_t___h_o_m_e are set |
| 505 | in _s_u_d_o_e_r_s, or when the --ss option is specified and |
| 506 | _s_e_t___h_o_m_e is set in _s_u_d_o_e_r_s |
| 507 | |
| 508 | PATH Set to a sane value if the _s_e_c_u_r_e___p_a_t_h sudoers option |
| 509 | is set. |
| 510 | |
| 511 | SHELL Used to determine shell to run with -s option |
| 512 | |
| 513 | SUDO_ASKPASS Specifies the path to a helper program used to read the |
| 514 | password if no terminal is available or if the -A |
| 515 | option is specified. |
| 516 | |
| 517 | SUDO_COMMAND Set to the command run by sudo |
| 518 | |
| 519 | SUDO_EDITOR Default editor to use in --ee (sudoedit) mode |
| 520 | |
| 521 | SUDO_GID Set to the group ID of the user who invoked sudo |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | 1.7.4 July 19, 2010 8 |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 533 | |
| 534 | |
| 535 | SUDO_PROMPT Used as the default password prompt |
| 536 | |
| 537 | SUDO_PS1 If set, PS1 will be set to its value for the program |
| 538 | being run |
| 539 | |
| 540 | SUDO_UID Set to the user ID of the user who invoked sudo |
| 541 | |
| 542 | SUDO_USER Set to the login of the user who invoked sudo |
| 543 | |
| 544 | USER Set to the target user (root unless the --uu option is |
| 545 | specified) |
| 546 | |
| 547 | VISUAL Default editor to use in --ee (sudoedit) mode if |
| 548 | SUDO_EDITOR is not set |
| 549 | |
| 550 | FFIILLEESS |
| 551 | _/_e_t_c_/_s_u_d_o_e_r_s List of who can run what |
| 552 | |
| 553 | _/_v_a_r_/_a_d_m_/_s_u_d_o Directory containing time stamps |
| 554 | |
| 555 | _/_e_t_c_/_e_n_v_i_r_o_n_m_e_n_t Initial environment for --ii mode on Linux and |
| 556 | AIX |
| 557 | |
| 558 | EEXXAAMMPPLLEESS |
| 559 | Note: the following examples assume suitable _s_u_d_o_e_r_s(4) entries. |
| 560 | |
| 561 | To get a file listing of an unreadable directory: |
| 562 | |
| 563 | $ sudo ls /usr/local/protected |
| 564 | |
| 565 | To list the home directory of user yaz on a machine where the file |
| 566 | system holding ~yaz is not exported as root: |
| 567 | |
| 568 | $ sudo -u yaz ls ~yaz |
| 569 | |
| 570 | To edit the _i_n_d_e_x_._h_t_m_l file as user www: |
| 571 | |
| 572 | $ sudo -u www vi ~www/htdocs/index.html |
| 573 | |
| 574 | To view system logs only accessible to root and users in the adm group: |
| 575 | |
| 576 | $ sudo -g adm view /var/log/syslog |
| 577 | |
| 578 | To run an editor as jim with a different primary group: |
| 579 | |
| 580 | $ sudo -u jim -g audio vi ~jim/sound.txt |
| 581 | |
| 582 | To shutdown a machine: |
| 583 | |
| 584 | $ sudo shutdown -r +15 "quick reboot" |
| 585 | |
| 586 | To make a usage listing of the directories in the /home partition. |
| 587 | Note that this runs the commands in a sub-shell to make the cd and file |
| 588 | redirection work. |
| 589 | |
| 590 | |
| 591 | |
| 592 | 1.7.4 July 19, 2010 9 |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | |
| 598 | SUDO(1m) MAINTENANCE COMMANDS SUDO(1m) |
| 599 | |
| 600 | |
| 601 | $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE" |
| 602 | |
| 603 | SSEEEE AALLSSOO |
| 604 | _g_r_e_p(1), _s_u(1), _s_t_a_t(2), _l_o_g_i_n___c_a_p(3), _p_a_s_s_w_d(4), _s_u_d_o_e_r_s(5), |
| 605 | _v_i_s_u_d_o(1m) |
| 606 | |
| 607 | AAUUTTHHOORRSS |
| 608 | Many people have worked on ssuuddoo over the years; this version consists |
| 609 | of code written primarily by: |
| 610 | |
| 611 | Todd C. Miller |
| 612 | |
| 613 | See the HISTORY file in the ssuuddoo distribution or visit |
| 614 | http://www.sudo.ws/sudo/history.html for a short history of ssuuddoo. |
| 615 | |
| 616 | CCAAVVEEAATTSS |
| 617 | There is no easy way to prevent a user from gaining a root shell if |
| 618 | that user is allowed to run arbitrary commands via ssuuddoo. Also, many |
| 619 | programs (such as editors) allow the user to run commands via shell |
| 620 | escapes, thus avoiding ssuuddoo's checks. However, on most systems it is |
| 621 | possible to prevent shell escapes with ssuuddoo's _n_o_e_x_e_c functionality. |
| 622 | See the _s_u_d_o_e_r_s(4) manual for details. |
| 623 | |
| 624 | It is not meaningful to run the cd command directly via sudo, e.g., |
| 625 | |
| 626 | $ sudo cd /usr/local/protected |
| 627 | |
| 628 | since when the command exits the parent process (your shell) will still |
| 629 | be the same. Please see the EXAMPLES section for more information. |
| 630 | |
| 631 | If users have sudo ALL there is nothing to prevent them from creating |
| 632 | their own program that gives them a root shell regardless of any '!' |
| 633 | elements in the user specification. |
| 634 | |
| 635 | Running shell scripts via ssuuddoo can expose the same kernel bugs that |
| 636 | make setuid shell scripts unsafe on some operating systems (if your OS |
| 637 | has a /dev/fd/ directory, setuid shell scripts are generally safe). |
| 638 | |
| 639 | BBUUGGSS |
| 640 | If you feel you have found a bug in ssuuddoo, please submit a bug report at |
| 641 | http://www.sudo.ws/sudo/bugs/ |
| 642 | |
| 643 | SSUUPPPPOORRTT |
| 644 | Limited free support is available via the sudo-users mailing list, see |
| 645 | http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search |
| 646 | the archives. |
| 647 | |
| 648 | DDIISSCCLLAAIIMMEERR |
| 649 | ssuuddoo is provided ``AS IS'' and any express or implied warranties, |
| 650 | including, but not limited to, the implied warranties of |
| 651 | merchantability and fitness for a particular purpose are disclaimed. |
| 652 | See the LICENSE file distributed with ssuuddoo or |
| 653 | http://www.sudo.ws/sudo/license.html for complete details. |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | 1.7.4 July 19, 2010 10 |
| 659 | |
| 660 | |