1 .\" $OpenBSD: doas.conf.5,v 1.31 2016/12/05 10:58:07 schwarze 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: December 5 2016 $
21 .Nd doas configuration file
23 .Nm /usr/local/etc/doas.conf
27 utility executes commands as other users according to the rules
32 The rules have the following format:
33 .Bd -ragged -offset indent
34 .Ic permit Ns | Ns Ic deny
38 .Op Ic cmd Ar command Op Ic args No ...
41 Rules consist of the following parts:
43 .It Ic permit Ns | Ns Ic deny
44 The action to be taken if this rule matches.
47 .Bl -tag -width keepenv
49 The user is not required to enter a password.
51 After the user successfully authenticates, do not ask for a password
52 again for some time. Works on OpenBSD only, persist is not available on Linux or FreeBSD.
54 The user's environment is maintained.
55 The default is to reset the environment, except for the variables
65 .It Ic setenv { Oo Ar variable ... Oc Oo Ar variable=value ... Oc Ic }
66 In addition to the variables mentioned above, keep the space-separated
68 Variables may also be removed with a leading
70 or set using the latter syntax.
71 If the first character of
75 then the value to be set is taken from the existing environment
76 variable of the same name.
79 The username to match.
80 Groups may be specified by prepending a colon
82 Numeric IDs are also accepted.
84 The target user the running user is allowed to run the command as.
85 The default is all users.
87 The command the user is allowed or denied to run.
88 The default is all commands.
89 Be advised that it is best to specify absolute paths.
90 If a relative path is specified, only a restricted
93 .It Ic args Op Ar argument ...
95 The command arguments provided by the user need to match those specified.
98 alone means that command must be run without any arguments.
101 The last matching rule determines the action taken.
102 If no rule matches, the action is denied.
104 Comments can be put anywhere in the file using a hash mark
106 and extend to the end of the current line.
108 The following quoting rules apply:
111 The text between a pair of double quotes
115 The backslash character
117 escapes the next character, including new line characters, outside comments;
118 as a result, comments may not be extended over multiple lines.
120 If quotes or backslashes are used in a word,
121 it is not considered a keyword.
124 The following example permits users in group wsrc to build ports;
125 wheel to execute commands as any user while keeping the environment
133 permits tedu to run procmap as root without a password;
134 and additionally permits root to run unrestricted commands as itself.
135 .Bd -literal -offset indent
136 # Non-exhaustive list of variables needed to
137 # build release(8) and ports(7)
138 permit nopass setenv { \e
139 FTPMODE PKG_CACHE PKG_PATH SM_PATH SSH_AUTH_SOCK \e
140 DESTDIR DISTDIR FETCH_CMD FLAVOR GROUP MAKE MAKECONF \e
141 MULTI_PACKAGES NOMAN OKAY_FILES OWNER PKG_DBDIR \e
142 PKG_DESTDIR PKG_TMPDIR PORTSDIR RELEASEDIR SHARED_ONLY \e
143 SUBPACKAGE WRKOBJDIR SUDO_PORT_V1 } :wsrc
144 permit setenv { -ENV PS1=$DOAS_PS1 SSH_AUTH_SOCK } :wheel
145 permit nopass tedu as root cmd /usr/sbin/procmap
146 permit nopass keepenv root as root
153 configuration file first appeared in
156 .An Ted Unangst Aq Mt tedu@openbsd.org