1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
=cut
Copyright (c) 1996,1998-2005, 2007 Todd C. Miller <Todd.Miller@courtesan.com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sponsored in part by the Defense Advanced Research Projects
Agency (DARPA) and Air Force Research Laboratory, Air Force
Materiel Command, USAF, under agreement number F39502-99-1-0512.
$Sudo: visudo.pod,v 1.38.2.9 2007/08/13 16:23:31 millert Exp $
=pod
=head1 NAME
visudo - edit the sudoers file
=head1 SYNOPSIS
B<visudo> [B<-c>] [B<-q>] [B<-s>] [B<-V>] [B<-f> I<sudoers>]
=head1 DESCRIPTION
B<visudo> edits the I<sudoers> file in a safe fashion, analogous to
L<vipw(8)>. B<visudo> locks the I<sudoers> file against multiple
simultaneous edits, provides basic sanity checks, and checks
for parse errors. If the I<sudoers> file is currently being
edited you will receive a message to try again later.
There is a hard-coded list of editors that B<visudo> will use set
at compile-time that may be overridden via the I<editor> I<sudoers>
C<Default> variable. This list defaults to the path to L<vi(1)> on
your system, as determined by the I<configure> script. Normally,
B<visudo> does not honor the C<VISUAL> or C<EDITOR> environment
variables unless they contain an editor in the aforementioned editors
list. However, if B<visudo> is configured with the I<--with-enveditor>
flag or the I<env_editor> C<Default> variable is set in I<sudoers>,
B<visudo> will use any the editor defines by C<VISUAL> or C<EDITOR>.
Note that this can be a security hole since it allows the user to
execute any program they wish simply by setting C<VISUAL> or C<EDITOR>.
B<visudo> parses the I<sudoers> file after the edit and will
not save the changes if there is a syntax error. Upon finding
an error, B<visudo> will print a message stating the line number(s)
where the error occurred and the user will receive the
"What now?" prompt. At this point the user may enter "e"
to re-edit the I<sudoers> file, "x" to exit without
saving the changes, or "Q" to quit and save changes. The
"Q" option should be used with extreme care because if B<visudo>
believes there to be a parse error, so will B<sudo> and no one
will be able to B<sudo> again until the error is fixed.
If "e" is typed to edit the I<sudoers> file after a parse error
has been detected, the cursor will be placed on the line where the
error occurred (if the editor supports this feature).
=head1 OPTIONS
B<visudo> accepts the following command line options:
=over 4
=item -c
Enable B<check-only> mode. The existing I<sudoers> file will be
checked for syntax and a message will be printed to the
standard output detailing the status of I<sudoers>.
If the syntax check completes successfully, B<visudo> will
exit with a value of 0. If a syntax error is encountered,
B<visudo> will exit with a value of 1.
=item -f
Specify and alternate I<sudoers> file location. With this option
B<visudo> will edit (or check) the I<sudoers> file of your choice,
instead of the default, F<@sysconfdir@/sudoers>. The lock file used
is the specified I<sudoers> file with ".tmp" appended to it.
=item -q
Enable B<quiet> mode. In this mode details about syntax errors
are not printed. This option is only useful when combined with
the B<-c> flag.
=item -s
Enable B<strict> checking of the I<sudoers> file. If an alias is
used before it is defined, B<visudo> will consider this a parse
error. Note that it is not possible to differentiate between an
alias and a hostname or username that consists solely of uppercase
letters, digits, and the underscore ('_') character.
=item -V
The B<-V> (version) option causes B<visudo> to print its version number
and exit.
=back
=head1 ENVIRONMENT
The following environment variables are used only if B<visudo>
was configured with the I<--with-env-editor> option:
=over 16
=item C<VISUAL>
Invoked by visudo as the editor to use
=item C<EDITOR>
Used by visudo if VISUAL is not set
=back
=head1 FILES
=over 4
=item F<@sysconfdir@/sudoers>C< >List of who can run what
=item F<@sysconfdir@/sudoers.tmp>C< >Lock file for visudo
=back
=head1 DIAGNOSTICS
=over 4
=item sudoers file busy, try again later.
Someone else is currently editing the I<sudoers> file.
=item @sysconfdir@/sudoers.tmp: Permission denied
You didn't run B<visudo> as root.
=item Can't find you in the passwd database
Your userid does not appear in the system passwd file.
=item Warning: undeclared Alias referenced near ...
Either you are using a {User,Runas,Host,Cmnd}_Alias before
defining it or you have a user or hostname listed that
consists solely of uppercase letters, digits, and the
underscore ('_') character. If the latter, you can ignore
the warnings (B<sudo> will not complain). In B<-s> (strict)
mode these are errors, not warnings.
=item Warning: runas_default set after old value is in use ...
You have a I<runas_default> Defaults setting listed in the I<sudoers>
file after its value has already been used. This means that entries
prior to the I<runas_default> setting will match based on the default
value of I<runas_default> (C<@runas_default@>) whereas entries
B<after> the I<runas_default> setting will match based on the new
value. This is usually unintentional and in most cases the
<runas_default> setting should be placed before any C<Runas_Alias>
or User specifications. In B<-s> (strict) mode this is an error,
not a warning.
=back
=head1 SEE ALSO
L<vi(1)>, L<sudoers(5)>, L<sudo(8)>, L<vipw(8)>
=head1 AUTHOR
Many people have worked on I<sudo> over the years; this version of
B<visudo> was written by:
Todd Miller
See the HISTORY file in the sudo distribution or visit
http://www.sudo.ws/sudo/history.html for more details.
=head1 CAVEATS
There is no easy way to prevent a user from gaining a root shell if
the editor used by B<visudo> allows shell escapes.
=head1 BUGS
If you feel you have found a bug in B<visudo>, please submit a bug report
at http://www.sudo.ws/sudo/bugs/
=head1 SUPPORT
Limited free support is available via the sudo-users mailing list,
see http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or
search the archives.
=head1 DISCLAIMER
B<visudo> is provided ``AS IS'' and any express or implied warranties,
including, but not limited to, the implied warranties of merchantability
and fitness for a particular purpose are disclaimed. See the LICENSE
file distributed with B<sudo> or http://www.sudo.ws/sudo/license.html
for complete details.
|