Annotation of src/usr.bin/sudo/sudo.8, Revision 1.3
1.1 millert 1: .rn '' }`
1.3 ! millert 2: ''' $RCSfile: sudo.man.in,v $$Revision: 1.3 $$Date: 2000/03/27 03:26:23 $
1.1 millert 3: '''
1.3 ! millert 4: ''' $Log: sudo.man.in,v $
! 5: ''' Revision 1.3 2000/03/27 03:26:23 millert
! 6: ''' Use 8 and 5 in the man page bodies as well.
1.1 millert 7: '''
8: '''
9: .de Sh
10: .br
11: .if t .Sp
12: .ne 5
13: .PP
14: \fB\\$1\fR
15: .PP
16: ..
17: .de Sp
18: .if t .sp .5v
19: .if n .sp
20: ..
21: .de Ip
22: .br
23: .ie \\n(.$>=3 .ne \\$3
24: .el .ne 3
25: .IP "\\$1" \\$2
26: ..
27: .de Vb
28: .ft CW
29: .nf
30: .ne \\$1
31: ..
32: .de Ve
33: .ft R
34:
35: .fi
36: ..
37: '''
38: '''
39: ''' Set up \*(-- to give an unbreakable dash;
40: ''' string Tr holds user defined translation string.
41: ''' Bell System Logo is used as a dummy character.
42: '''
43: .tr \(*W-|\(bv\*(Tr
44: .ie n \{\
45: .ds -- \(*W-
46: .ds PI pi
47: .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
48: .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
49: .ds L" ""
50: .ds R" ""
51: ''' \*(M", \*(S", \*(N" and \*(T" are the equivalent of
52: ''' \*(L" and \*(R", except that they are used on ".xx" lines,
53: ''' such as .IP and .SH, which do another additional levels of
54: ''' double-quote interpretation
55: .ds M" """
56: .ds S" """
57: .ds N" """""
58: .ds T" """""
59: .ds L' '
60: .ds R' '
61: .ds M' '
62: .ds S' '
63: .ds N' '
64: .ds T' '
65: 'br\}
66: .el\{\
67: .ds -- \(em\|
68: .tr \*(Tr
69: .ds L" ``
70: .ds R" ''
71: .ds M" ``
72: .ds S" ''
73: .ds N" ``
74: .ds T" ''
75: .ds L' `
76: .ds R' '
77: .ds M' `
78: .ds S' '
79: .ds N' `
80: .ds T' '
81: .ds PI \(*p
82: 'br\}
83: .\" If the F register is turned on, we'll generate
84: .\" index entries out stderr for the following things:
85: .\" TH Title
86: .\" SH Header
87: .\" Sh Subsection
88: .\" Ip Item
89: .\" X<> Xref (embedded
90: .\" Of course, you have to process the output yourself
91: .\" in some meaninful fashion.
92: .if \nF \{
93: .de IX
94: .tm Index:\\$1\t\\n%\t"\\$2"
95: ..
96: .nr % 0
97: .rr F
98: .\}
1.3 ! millert 99: .TH sudo 8 "1.6.3" "26/Mar/2000" "MAINTENANCE COMMANDS"
1.1 millert 100: .UC
101: .if n .hy 0
102: .if n .na
103: .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
104: .de CQ \" put $1 in typewriter font
105: .ft CW
106: 'if n "\c
107: 'if t \\&\\$1\c
108: 'if n \\&\\$1\c
109: 'if n \&"
110: \\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
111: '.ft R
112: ..
113: .\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
114: . \" AM - accent mark definitions
115: .bd B 3
116: . \" fudge factors for nroff and troff
117: .if n \{\
118: . ds #H 0
119: . ds #V .8m
120: . ds #F .3m
121: . ds #[ \f1
122: . ds #] \fP
123: .\}
124: .if t \{\
125: . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
126: . ds #V .6m
127: . ds #F 0
128: . ds #[ \&
129: . ds #] \&
130: .\}
131: . \" simple accents for nroff and troff
132: .if n \{\
133: . ds ' \&
134: . ds ` \&
135: . ds ^ \&
136: . ds , \&
137: . ds ~ ~
138: . ds ? ?
139: . ds ! !
140: . ds /
141: . ds q
142: .\}
143: .if t \{\
144: . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
145: . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
146: . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
147: . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
148: . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
149: . ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
150: . ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
151: . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
152: . ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
153: .\}
154: . \" troff and (daisy-wheel) nroff accents
155: .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
156: .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
157: .ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
158: .ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
159: .ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
160: .ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
161: .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
162: .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
163: .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
164: .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
165: .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
166: .ds ae a\h'-(\w'a'u*4/10)'e
167: .ds Ae A\h'-(\w'A'u*4/10)'E
168: .ds oe o\h'-(\w'o'u*4/10)'e
169: .ds Oe O\h'-(\w'O'u*4/10)'E
170: . \" corrections for vroff
171: .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
172: .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
173: . \" for low resolution devices (crt and lpr)
174: .if \n(.H>23 .if \n(.V>19 \
175: \{\
176: . ds : e
177: . ds 8 ss
178: . ds v \h'-1'\o'\(aa\(ga'
179: . ds _ \h'-1'^
180: . ds . \h'-1'.
181: . ds 3 3
182: . ds o a
183: . ds d- d\h'-1'\(ga
184: . ds D- D\h'-1'\(hy
185: . ds th \o'bp'
186: . ds Th \o'LP'
187: . ds ae ae
188: . ds Ae AE
189: . ds oe oe
190: . ds Oe OE
191: .\}
192: .rm #[ #] #H #V #F C
193: .SH "NAME"
194: sudo \- execute a command as another user
195: .SH "SYNOPSIS"
1.3 ! millert 196: \fBsudo\fR \fB\-V\fR | \fB\-h\fR | \fB\-l\fR | \fB\-L\fR | \fB\-v\fR | \fB\-k\fR | \fB\-K\fR | \fB\-s\fR |
! 197: [ \fB\-H\fR ] [\fB\-S\fR ] [ \fB\-b\fR ] | [ \fB\-p\fR prompt ]
! 198: [ \fB\-u\fR username/#uid ] \fIcommand\fR
1.1 millert 199: .SH "DESCRIPTION"
200: \fBsudo\fR allows a permitted user to execute a \fIcommand\fR as the
201: superuser or another user, as specified in the sudoers file. The
202: real and effective uid and gid are set to match those of the target
203: user as specified in the passwd file (the group vector is also
1.2 millert 204: initialized when the target user is not root). By default, \fBsudo\fR
205: requires that users authenticate themselves with a password
206: (NOTE: this is the user's password, not the root password). Once
207: a user has been authenticated, a timestamp is updated and the
208: user may then use sudo without a password for a short period of time
209: (five minutes by default).
1.1 millert 210: .PP
211: \fBsudo\fR determines who is an authorized user by consulting the
212: file \fI/etc/sudoers\fR. By giving \fBsudo\fR the \f(CW-v\fR flag a user
213: can update the time stamp without running a \fIcommand.\fR
214: The password prompt itself will also time out if the user's password is
215: not entered with N minutes (again, this is defined at configure
216: time and defaults to 5 minutes).
217: .PP
218: If a user that is not listed in the \fIsudoers\fR file tries to run
219: a command via \fBsudo\fR, mail is sent to the proper authorities,
220: as defined at configure time (defaults to root). Note that the
221: mail will not be sent if an unauthorized user tries to run sudo
222: with the \f(CW-l\fR or \f(CW-v\fR flags. This allows users to determine
223: for themselves whether or not they are allowed to use \fBsudo\fR.
224: .PP
225: \fBsudo\fR can log both successful an unsuccessful attempts (as well
226: as errors) to \fIsyslog\fR\|(3), a log file, or both. By default \fBsudo\fR
227: will log via \fIsyslog\fR\|(3) but this is changeable at configure time.
228: .SH "OPTIONS"
229: \fBsudo\fR accepts the following command line options:
230: .Ip "-V" 4
231: The \f(CW-V\fR (\fIversion\fR) option causes \fBsudo\fR to print the
232: version number and exit.
233: .Ip "-l" 4
234: The \f(CW-l\fR (\fIlist\fR) option will list out the allowed (and
235: forbidden) commands for the user on the current host.
236: .Ip "-L" 4
237: The \f(CW-L\fR (\fIlist\fR defaults) option will list out the parameters
238: that may be set in a \fIDefaults\fR line along with a short description
239: for each. This option is useful in conjunction with \fIgrep\fR\|(1).
240: .Ip "-h" 4
241: The \f(CW-h\fR (\fIhelp\fR) option causes \fBsudo\fR to print a usage message and exit.
242: .Ip "-v" 4
243: If given the \f(CW-v\fR (\fIvalidate\fR) option, \fBsudo\fR will update the
244: user's timestamp, prompting for the user's password if necessary.
245: This extends the \fBsudo\fR timeout to for another N minutes
246: (where N is defined at installation time and defaults to 5
247: minutes) but does not run a command.
248: .Ip "-k" 4
249: The \f(CW-k\fR (\fIkill\fR) option to \fBsudo\fR invalidates the user's timestamp
250: by setting the time on it to the epoch. The next time \fBsudo\fR is
251: run a password will be required. This option does not require a password
252: and was added to allow a user to revoke \fBsudo\fR permissions from a .logout
253: file.
254: .Ip "-K" 4
255: The \f(CW-K\fR (sure \fIkill\fR) option to \fBsudo\fR removes the user's timestamp
256: entirely. This option does not require a password.
257: .Ip "-b" 4
258: The \f(CW-b\fR (\fIbackground\fR) option tells \fBsudo\fR to run the given
259: command in the background. Note that if you use the \f(CW-b\fR
260: option you cannot use shell job control to manipulate the command.
261: .Ip "-p" 4
262: The \f(CW-p\fR (\fIprompt\fR) option allows you to override the default
263: password prompt and use a custom one. If the password prompt
264: contains the \f(CW%u\fR escape, \f(CW%u\fR will be replaced with the user's
265: login name. Similarly, \f(CW%h\fR will be replaced with the local
266: hostname.
267: .Ip "-u" 4
1.3 ! millert 268: The \f(CW-u\fR (\fIuser\fR) option causes \fBsudo\fR to run the specified command
1.1 millert 269: as a user other than \fIroot\fR. To specify a \fIuid\fR instead of a
270: \fIusername\fR, use \*(L"#uid\*(R".
271: .Ip "-s" 4
272: The \f(CW-s\fR (\fIshell\fR) option runs the shell specified by the \fI\s-1SHELL\s0\fR
273: environment variable if it is set or the shell as specified
274: in \fIpasswd\fR\|(5).
275: .Ip "-H" 4
276: The \f(CW-H\fR (\fI\s-1HOME\s0\fR) option sets the \fI\s-1HOME\s0\fR environment variable
277: to the homedir of the target user (root by default) as specified
278: in \fIpasswd\fR\|(5). By default, \fBsudo\fR does not modify \fI\s-1HOME\s0\fR.
1.3 ! millert 279: .Ip "-S" 4
! 280: The \f(CW-S\fR (\fIstdin\fR) option causes \fBsudo\fR to read the password from
! 281: standard input instead of the terminal device.
1.1 millert 282: .Ip "--" 4
283: The \f(CW--\fR flag indicates that \fBsudo\fR should stop processing command
284: line arguments. It is most useful in conjunction with the \f(CW-s\fR flag.
285: .SH "RETURN VALUES"
286: \fBsudo\fR quits with an exit value of 1 if there is a
287: configuration/permission problem or if \fBsudo\fR cannot execute the
288: given command. In the latter case the error string is printed to
289: stderr. If \fBsudo\fR cannot \fIstat\fR\|(2) one or more entries in the user's
290: \f(CWPATH\fR an error is printed on stderr. (If the directory does not
291: exist or if it is not really a directory, the entry is ignored and
292: no error is printed.) This should not happen under normal
293: circumstances. The most common reason for \fIstat\fR\|(2) to return
294: \*(L"permission denied\*(R" is if you are running an automounter and one
295: of the directories in your \f(CWPATH\fR is on a machine that is currently
296: unreachable.
297: .SH "SECURITY NOTES"
298: \fBsudo\fR tries to be safe when executing external commands. Variables
299: that control how dynamic loading and binding is done can be used
300: to subvert the program that \fBsudo\fR runs. To combat this the
301: \f(CWLD_*\fR, \f(CW_RLD_*\fR, \f(CWSHLIB_PATH\fR (HP\-UX only), and \f(CWLIBPATH\fR (AIX
302: only) environment variables are removed from the environment passed
303: on to all commands executed. \fBsudo\fR will also remove the \f(CWIFS\fR,
304: \f(CWENV\fR, \f(CWBASH_ENV\fR, \f(CWKRB_CONF\fR, \f(CWKRB5_CONFIG\fR, \f(CWLOCALDOMAIN\fR,
305: \f(CWRES_OPTIONS\fR and \f(CWHOSTALIASES\fR variables as they too can pose a
306: threat.
307: .PP
308: To prevent command spoofing, \fBsudo\fR checks "." and "" (both denoting
309: current directory) last when searching for a command in the user's
310: PATH (if one or both are in the PATH). Note, however, that the
311: actual \f(CWPATH\fR environment variable is \fInot\fR modified and is passed
312: unchanged to the program that \fBsudo\fR executes.
313: .PP
314: For security reasons, if your OS supports shared libraries and does
315: not disable user-defined library search paths for setuid programs
316: (most do), you should either use a linker option that disables this
317: behavior or link \fBsudo\fR statically.
318: .PP
319: \fBsudo\fR will check the ownership of its timestamp directory
1.3 ! millert 320: (\fI/var/run/sudo\fR by default) and ignore the directory's contents if
! 321: it is not owned by root and only writable by root. On systems that
! 322: allow non-root users to give away files via \fIchown\fR\|(2), if the timestamp
! 323: directory is located in a directory writable by anyone (eg: \fI/tmp\fR),
! 324: it is possible for a user to create the timestamp directory before
! 325: \fBsudo\fR is run. However, because \fBsudo\fR checks the ownership and
! 326: mode of the directory and its contents, the only damage that can
! 327: be done is to \*(L"hide\*(R" files by putting them in the timestamp dir.
! 328: This is unlikely to happen since once the timestamp dir is owned
! 329: by root and inaccessible by any other user the user placing files
! 330: there would be unable to get them back out. To get around this
! 331: issue you can use a directory that is not world-writable for the
! 332: timestamps (\fI/var/adm/sudo\fR for instance) or create \fI/var/run/sudo\fR
! 333: with the appropriate owner (root) and permissions (0700) in the
! 334: system startup files.
1.1 millert 335: .PP
336: \fBsudo\fR will not honor timestamps set far in the future.
337: Timestamps with a date greater than current_time + 2 * \f(CWTIMEOUT\fR
338: will be ignored and sudo will log and complain. This is done to
339: keep a user from creating his/her own timestamp with a bogus
340: date on system that allow users to give away files.
341: .SH "EXAMPLES"
342: Note: the following examples assume suitable \fIsudoers\fR\|(5) entries.
343: .PP
344: To get a file listing of an unreadable directory:
345: .PP
346: .Vb 1
347: \& % sudo ls /usr/local/protected
348: .Ve
349: To list the home directory of user yazza on a machine where the
350: filesystem holding ~yazza is not exported as root:
351: .PP
352: .Vb 1
353: \& % sudo -u yazza ls ~yazza
354: .Ve
355: To edit the \fIindex.html\fR file as user www:
356: .PP
357: .Vb 1
358: \& % sudo -u www vi ~www/htdocs/index.html
359: .Ve
360: To shutdown a machine:
361: .PP
362: .Vb 1
363: \& % sudo shutdown -r +15 "quick reboot"
364: .Ve
365: To make a usage listing of the directories in the /home
366: partition. Note that this runs the commands in a sub-shell
367: to make the \f(CWcd\fR and file redirection work.
368: .PP
369: .Vb 1
370: \& % sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"
371: .Ve
372: .SH "ENVIRONMENT"
373: \fBsudo\fR utilizes the following environment variables:
374: .PP
375: .Vb 13
376: \& PATH Set to a sane value if SECURE_PATH is set
377: \& SHELL Used to determine shell to run with -s option
378: \& USER Set to the target user (root unless the -u option
379: \& is specified)
380: \& HOME In -s or -H mode (or if sudo was configured with
381: \& the --enable-shell-sets-home option), set to
382: \& homedir of the target user.
383: \& SUDO_PROMPT Used as the default password prompt
384: \& SUDO_COMMAND Set to the command run by sudo
385: \& SUDO_USER Set to the login of the user who invoked sudo
386: \& SUDO_UID Set to the uid of the user who invoked sudo
387: \& SUDO_GID Set to the gid of the user who invoked sudo
388: \& SUDO_PS1 If set, PS1 will be set to its value
389: .Ve
390: .SH "FILES"
391: .PP
392: .Vb 2
393: \& /etc/sudoers List of who can run what
1.3 ! millert 394: \& /var/run/sudo Directory containing timestamps
1.1 millert 395: .Ve
396: .SH "AUTHORS"
397: Many people have worked on \fBsudo\fR over the years, this
398: version consists of code written primarily by:
399: .PP
400: .Vb 2
401: \& Todd Miller
402: \& Chris Jepeway
403: .Ve
404: See the HISTORY file in the \fBsudo\fR distribution for a short history
405: of \fBsudo\fR.
406: .SH "BUGS"
407: If you feel you have found a bug in sudo, please submit a bug report
1.2 millert 408: at http://www.courtesan.com/sudo/bugs/
1.1 millert 409: .SH "DISCLAIMER"
410: \fBSudo\fR is provided ``AS IS'\*(R' and any express or implied warranties,
411: including, but not limited to, the implied warranties of merchantability
412: and fitness for a particular purpose are disclaimed.
413: See the LICENSE file distributed with \fBsudo\fR for complete details.
414: .SH "CAVEATS"
415: There is no easy way to prevent a user from gaining a root shell if
416: that user has access to commands allowing shell escapes.
417: .PP
418: If users have sudo \f(CWALL\fR there is nothing to prevent them from creating
419: their own program that gives them a root shell regardless of any \*(L'!\*(R'
420: elements in the user specification.
421: .PP
422: Running shell scripts via \fBsudo\fR can expose the same kernel bugs
423: that make setuid shell scripts unsafe on some operating systems
424: (if your OS supports the /dev/fd/ directory, setuid shell scripts
425: are generally safe).
426: .SH "SEE ALSO"
1.3 ! millert 427: \\fIsudoers\fR\|(5), \fIvisudo\fR\|(8), \fIsu\fR\|(1).
1.1 millert 428:
429: .rn }` ''
430: .IX Title "sudo 8"
431: .IX Name "sudo - execute a command as another user"
432:
433: .IX Header "NAME"
434:
435: .IX Header "SYNOPSIS"
436:
437: .IX Header "DESCRIPTION"
438:
439: .IX Header "OPTIONS"
440:
441: .IX Item "-V"
442:
443: .IX Item "-l"
444:
445: .IX Item "-L"
446:
447: .IX Item "-h"
448:
449: .IX Item "-v"
450:
451: .IX Item "-k"
452:
453: .IX Item "-K"
454:
455: .IX Item "-b"
456:
457: .IX Item "-p"
458:
459: .IX Item "-u"
460:
461: .IX Item "-s"
462:
463: .IX Item "-H"
464:
1.3 ! millert 465: .IX Item "-S"
! 466:
1.1 millert 467: .IX Item "--"
468:
469: .IX Header "RETURN VALUES"
470:
471: .IX Header "SECURITY NOTES"
472:
473: .IX Header "EXAMPLES"
474:
475: .IX Header "ENVIRONMENT"
476:
477: .IX Header "FILES"
478:
479: .IX Header "AUTHORS"
480:
481: .IX Header "BUGS"
482:
483: .IX Header "DISCLAIMER"
484:
485: .IX Header "CAVEATS"
486:
487: .IX Header "SEE ALSO"
488: