1 .\" $OpenBSD: doas.conf.5,v 1.45 2020/10/09 10:24:33 jmc Exp $
3 .\"Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
5 .\"Permission to use, copy, modify, and distribute this software for any
6 .\"purpose with or without fee is hereby granted, provided that the above
7 .\"copyright notice and this permission notice appear in all copies.
9 .\"THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\"WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\"MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\"ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\"WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\"ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\"OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .Dd $Mdocdate: October 9 2020 $
21 .Nd doas configuration file
25 utility executes commands as other users according to the rules
30 The rules have the following format:
31 .Bd -ragged -offset indent
32 .Ic permit Ns | Ns Ic deny
36 .Op Ic cmd Ar command Op Ic args No ...
39 Rules consist of the following parts:
41 .It Ic permit Ns | Ns Ic deny
42 The action to be taken if this rule matches.
45 .Bl -tag -width keepenv
47 The user is not required to enter a password.
49 Do not log successful command execution to
52 After the user successfully authenticates, do not ask for a password
55 Environment variables other than those listed in
57 are retained when creating the environment for the new process.
58 .It Ic setenv { Oo Ar variable ... Oc Oo Ar variable=value ... Oc Ic }
59 Keep or set the space-separated specified variables.
60 Variables may also be removed with a leading
62 or set using the latter syntax.
63 If the first character of
67 then the value to be set is taken from the existing environment
68 variable of the indicated name.
69 This option is processed after the default environment has been created.
71 Insult the user when they get their password wrong.
74 The username to match.
75 Groups may be specified by prepending a colon
77 Numeric IDs are also accepted.
79 The target user the running user is allowed to run the command as.
80 The default is all users.
82 The command the user is allowed or denied to run.
83 The default is all commands.
84 Be advised that it is best to specify absolute paths.
85 If a relative path is specified, only a restricted
88 .It Ic args Op Ar argument ...
90 The command arguments provided by the user need to match those specified.
93 alone means that command must be run without any arguments.
96 The last matching rule determines the action taken.
97 If no rule matches, the action is denied.
99 Comments can be put anywhere in the file using a hash mark
101 and extend to the end of the current line.
103 The following quoting rules apply:
106 The text between a pair of double quotes
110 The backslash character
112 escapes the next character, including new line characters, outside comments;
113 as a result, comments may not be extended over multiple lines.
115 If quotes or backslashes are used in a word,
116 it is not considered a keyword.
119 .Bl -tag -width /etc/examples/doas.conf -compact
120 .It Pa /etc/doas.conf
123 .It Pa /etc/examples/doas.conf
124 Example configuration file.
127 The following example permits user aja to install packages
128 from a preferred mirror;
129 group wheel to execute commands as any user while keeping the environment
137 permits tedu to run procmap as root without a password;
138 and additionally permits root to run unrestricted commands as itself
139 while retaining the original PATH.
140 .Bd -literal -offset indent
141 permit persist setenv { PKG_CACHE PKG_PATH } aja cmd pkg_add
142 permit setenv { -ENV PS1=$DOAS_PS1 SSH_AUTH_SOCK } :wheel
143 permit nopass tedu as root cmd /usr/sbin/procmap
144 permit nopass keepenv setenv { PATH } root as root
152 configuration file first appeared in
155 .An Ted Unangst Aq Mt tedu@openbsd.org