summaryrefslogtreecommitdiffstats
path: root/doc/visudo.mdoc.in
blob: 140d5d6f8a8b97d777e5fde8e4f12192e0e4be30 (plain)
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
.\"
.\" Copyright (c) 1996,1998-2005, 2007-2018
.\"	Todd C. Miller <Todd.Miller@sudo.ws>
.\"
.\" 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.
.\"
.\" 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.
.\"
.Dd December 24, 2018
.Dt VISUDO @mansectsu@
.Os Sudo @PACKAGE_VERSION@
.Sh NAME
.Nm visudo
.Nd edit the sudoers file
.Sh SYNOPSIS
.Nm visudo
.Op Fl chqsV
.Op Bo Fl f Bc Ar sudoers
.Sh DESCRIPTION
.Nm
edits the
.Em sudoers
file in a safe fashion, analogous to
.Xr vipw @mansectsu@ .
.Nm
locks the
.Em sudoers
file against multiple simultaneous edits, provides basic sanity checks,
and checks for parse errors.
If the
.Em sudoers
file is currently being edited you will receive a message to try again later.
.Pp
.Nm
parses the
.Em sudoers
file after editing and will not save the changes if there is a syntax error.
Upon finding an error,
.Nm
will print a message stating the line number(s)
where the error occurred and the user will receive the
.Dq What now?
prompt.
At this point the user may enter
.Ql e
to re-edit the
.Em sudoers
file,
.Ql x
to exit without saving the changes, or
.Ql Q
to quit and save changes.
The
.Ql Q
option should be used with extreme caution because if
.Nm
believes there to be a parse error, so will
.Nm sudo
and no one
will be able to run
.Nm sudo
again until the error is fixed.
If
.Ql e
is typed to edit the
.Em 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).
.Pp
There are two
.Em sudoers
settings that determine which editor
.Nm visudo
will run.
.Bl -tag -width 8n
.It editor
A colon
.Pq Ql :\&
separated list of editors allowed to be used with
.Nm .
.Nm
will choose the editor that matches the user's
.Ev SUDO_EDITOR ,
.Ev VISUAL
or
.Ev EDITOR
environment variable if possible, or the first editor in the
list that exists and is executable.
Note that the
.Ev SUDO_EDITOR ,
.Ev VISUAL
and
.Ev EDITOR
environment variables are not preserved by default when the
.Em env_reset
.Em sudoers
option is enabled.
The default editor path is
.Pa @editor@
which can be set at compile time via the
.Li --with-editor
configure option.
.It env_editor
If set,
.Nm
will use the value of the
.Ev SUDO_EDITOR ,
.Ev VISUAL
or
.Ev EDITOR
environment variables before falling back on the default editor list.
Note that this may create a security hole as it allows the user to
run any arbitrary command as root without logging.
A safer alternative is to place a colon-separated list of editors
in the
.Em editor
variable.
.Nm
will then only use
.Ev SUDO_EDITOR ,
.Ev VISUAL
or
.Ev EDITOR
if they match a value specified in
.Em editor .
If the
.Em env_reset
flag is enabled, the
.Ev SUDO_EDITOR ,
.Ev VISUAL
and/or
.Ev EDITOR
environment variables must be present in the
.Em env_keep
list for the
.Em env_editor
flag to function when
.Nm
is invoked via
.Nm sudo .
The default value is
.Em @env_editor@ ,
which can be set at compile time via the
.Li --with-env-editor
configure option.
.El
.Pp
The options are as follows:
.Bl -tag -width Fl
.It Fl c , -check
Enable
.Em check-only
mode.
The existing
.Em sudoers
file (and any other files it includes) will be
checked for syntax errors.
If the path to the
.Em sudoers
file was not specified,
.Nm
will also check the file owner and mode.
A message will be printed to the standard output describing the status of
.Em sudoers
unless the
.Fl q
option was specified.
If the check completes successfully,
.Nm
will exit with a value of 0.
If an error is encountered,
.Nm
will exit with a value of 1.
.It Fl f Ar sudoers , Fl -file Ns = Ns Ar sudoers
Specify an alternate
.Em sudoers
file location, see below.
As of version 1.8.27, the
.Em sudoers
path can be specified without using the
.Fl f
option.
.It Fl h , -help
Display a short help message to the standard output and exit.
.It Fl q , -quiet
Enable
.Em quiet
mode.
In this mode details about syntax errors are not printed.
This option is only useful when combined with
the
.Fl c
option.
.It Fl s , -strict
Enable
.Em strict
checking of the
.Em sudoers
file.
If an alias is referenced but not actually defined
or if there is a cycle in an alias,
.Nm
will consider this a parse error.
Note that it is not possible to differentiate between an
alias and a host name or user name that consists solely of uppercase
letters, digits, and the underscore
.Pq Ql _
character.
.It Fl V , -version
Print the
.Nm
and
.Em sudoers
grammar versions and exit.
.El
.Pp
A
.Em sudoers
file may be specified instead of the default,
.Pa @sysconfdir@/sudoers .
The lock file used is the specified
.Em sudoers
file with
.Dq \.tmp
appended to it.
In
.Em check-only
mode only,
.Ql -
may be used to indicate that
.Em sudoers
will be read from the standard input.
Because the policy is evaluated in its entirety, it is not sufficient
to check an individual
.Em sudoers
include file for syntax errors.
.Ss Debugging and sudoers plugin arguments
.Nm
versions 1.8.4 and higher support a flexible debugging framework
that is configured via
.Li Debug
lines in the
.Xr sudo.conf @mansectform@
file.
.Pp
Starting with
.Nm sudo
1.8.12,
.Nm
will also parse the arguments to the
.Em sudoers
plugin to override the default
.Em sudoers
path name, UID, GID and file mode.
These arguments, if present, should be listed after the path to the plugin
(i.e., after
.Pa sudoers.so ) .
Multiple arguments may be specified, separated by white space.
For example:
.Bd -literal -offset indent
Plugin sudoers_policy sudoers.so sudoers_mode=0400
.Ed
.Pp
The following arguments are supported:
.Bl -tag -width 8n
.It sudoers_file=pathname
The
.Em sudoers_file
argument can be used to override the default path to the
.Em sudoers
file.
.It sudoers_uid=uid
The
.Em sudoers_uid
argument can be used to override the default owner of the sudoers file.
It should be specified as a numeric user ID.
.It sudoers_gid=gid
The
.Em sudoers_gid
argument can be used to override the default group of the sudoers file.
It must be specified as a numeric group ID (not a group name).
.It sudoers_mode=mode
The
.Em sudoers_mode
argument can be used to override the default file mode for the sudoers file.
It should be specified as an octal value.
.El
.Pp
For more information on configuring
.Xr sudo.conf @mansectform@ ,
please refer to its manual.
.Sh ENVIRONMENT
The following environment variables may be consulted depending on
the value of the
.Em editor
and
.Em env_editor
.Em sudoers
settings:
.Bl -tag -width 15n
.It Ev SUDO_EDITOR
Invoked by
.Nm
as the editor to use
.It Ev VISUAL
Used by
.Nm
if
.Ev SUDO_EDITOR
is not set
.It Ev EDITOR
Used by
.Nm
if neither
.Ev SUDO_EDITOR
nor
.Ev VISUAL
is set
.El
.Sh FILES
.Bl -tag -width 24n
.It Pa @sysconfdir@/sudo.conf
Sudo front end configuration
.It Pa @sysconfdir@/sudoers
List of who can run what
.It Pa @sysconfdir@/sudoers.tmp
Lock file for visudo
.El
.Sh DIAGNOSTICS
In addition to reporting
.Em sudoers
parse errors,
.Nm
may produce the following messages:
.Bl -tag -width 4n
.It Li sudoers file busy, try again later.
Someone else is currently editing the
.Em sudoers
file.
.It Li @sysconfdir@/sudoers.tmp: Permission denied
You didn't run
.Nm
as root.
.It Li you do not exist in the passwd database
Your user ID does not appear in the system passwd database.
.It Li Warning: {User,Runas,Host,Cmnd}_Alias referenced but not defined
Either you are trying to use an undeclared {User,Runas,Host,Cmnd}_Alias
or you have a user or host name listed that consists solely of
uppercase letters, digits, and the underscore
.Pq Ql _
character.
In the latter case, you can ignore the warnings
.Po
.Nm sudo
will not complain
.Pc .
The message is prefixed with the path name of the
.Em sudoers
file and the line number where the undefined alias was used.
In
.Fl s
(strict) mode these are errors, not warnings.
.It Li Warning: unused {User,Runas,Host,Cmnd}_Alias
The specified {User,Runas,Host,Cmnd}_Alias was defined but never
used.
The message is prefixed with the path name of the
.Em sudoers
file and the line number where the unused alias was defined.
You may wish to comment out or remove the unused alias.
.It Li Warning: cycle in {User,Runas,Host,Cmnd}_Alias
The specified {User,Runas,Host,Cmnd}_Alias includes a reference to
itself, either directly or through an alias it includes.
The message is prefixed with the path name of the
.Em sudoers
file and the line number where the cycle was detected.
This is only a warning unless
.Nm
is run in
.Fl s
(strict) mode as
.Nm sudo
will ignore cycles when parsing
the
.Em sudoers
file.
.It Li unknown defaults entry \&"name\&"
The
.Em sudoers
file contains a
.Li Defaults
setting not recognized by
.Nm .
.El
.Sh SEE ALSO
.Xr vi 1 ,
.Xr sudo.conf @mansectform@ ,
.Xr sudoers @mansectform@ ,
.Xr sudo @mansectsu@ ,
.Xr vipw @mansectsu@
.Sh AUTHORS
Many people have worked on
.Nm sudo
over the years; this version consists of code written primarily by:
.Bd -ragged -offset indent
.An Todd C. Miller
.Ed
.Pp
See the CONTRIBUTORS file in the
.Nm sudo
distribution (https://www.sudo.ws/contributors.html) for an
exhaustive list of people who have contributed to
.Nm sudo .
.Sh CAVEATS
There is no easy way to prevent a user from gaining a root shell if
the editor used by
.Nm
allows shell escapes.
.Sh BUGS
If you feel you have found a bug in
.Nm ,
please submit a bug report at https://bugzilla.sudo.ws/
.Sh SUPPORT
Limited free support is available via the sudo-users mailing list,
see https://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or
search the archives.
.Sh DISCLAIMER
.Nm
is provided
.Dq 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
.Nm sudo
or https://www.sudo.ws/license.html for complete details.