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