1.\" $OpenBSD: doas.conf.5,v 1.46 2023/05/03 14:29:57 kn Exp $ 2.\" 3.\"Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> 4.\" 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. 8.\" 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: May 3 2023 $ 17.Dt DOAS.CONF 5 18.Os 19.Sh NAME 20.Nm doas.conf 21.Nd doas configuration file 22.Sh DESCRIPTION 23The 24.Xr doas 1 25utility executes commands as other users according to the rules 26in the 27.Nm 28configuration file. 29.Pp 30The rules have the following format: 31.Bd -ragged -offset indent 32.Ic permit Ns | Ns Ic deny 33.Op Ar options 34.Ar identity 35.Op Ic as Ar target 36.Op Ic cmd Ar command Op Ic args No ... 37.Ed 38.Pp 39Rules consist of the following parts: 40.Bl -tag -width 11n 41.It Ic permit Ns | Ns Ic deny 42The action to be taken if this rule matches. 43.It Ar options 44Options are: 45.Bl -tag -width keepenv 46.It Ic nopass 47The user is not required to enter a password. 48.It Ic nolog 49Do not log successful command execution to 50.Xr syslogd 8 . 51.It Ic persist 52After the user successfully authenticates, do not ask for a password 53again for some time. 54.It Ic keepenv 55Environment variables other than those listed in 56.Xr doas 1 57are retained when creating the environment for the new process. 58.It Ic setenv Brq Oo Ar variable ... Oc Oo Ar variable Ns = Ns Ar value ... Oc 59Keep or set the space-separated specified variables. 60Variables may also be removed with a leading 61.Sq - 62or set using the latter syntax. 63If the first character of 64.Ar value 65is a 66.Ql $ 67then the value to be set is taken from the existing environment 68variable of the indicated name. 69This option is processed after the default environment has been created. 70.El 71.It Ar identity 72The username to match. 73Groups may be specified by prepending a colon 74.Pq Sq \&: . 75Numeric IDs are also accepted. 76.It Ic as Ar target 77The target user the running user is allowed to run the command as. 78The default is all users. 79.It Ic cmd Ar command 80The command the user is allowed or denied to run. 81The default is all commands. 82Be advised that it is best to specify absolute paths. 83If a relative path is specified, only a restricted 84.Ev PATH 85will be searched. 86.It Ic args Op Ar argument ... 87Arguments to command. 88The command arguments provided by the user need to match those specified. 89The keyword 90.Ic args 91alone means that command must be run without any arguments. 92.El 93.Pp 94The last matching rule determines the action taken. 95If no rule matches, the action is denied. 96.Pp 97Comments can be put anywhere in the file using a hash mark 98.Pq Sq # , 99and extend to the end of the current line. 100.Pp 101The following quoting rules apply: 102.Bl -dash 103.It 104The text between a pair of double quotes 105.Pq Sq \&" 106is taken as is. 107.It 108The backslash character 109.Pq Sq \e 110escapes the next character, including new line characters, outside comments; 111as a result, comments may not be extended over multiple lines. 112.It 113If quotes or backslashes are used in a word, 114it is not considered a keyword. 115.El 116.Sh FILES 117.Bl -tag -width /etc/examples/doas.conf -compact 118.It Pa /etc/doas.conf 119.Xr doas 1 120configuration file. 121.It Pa /etc/examples/doas.conf 122Example configuration file. 123.El 124.Sh EXAMPLES 125The following example permits user aja to install packages 126from a preferred mirror; 127group wheel to execute commands as any user while keeping the environment 128variables 129.Ev PS1 130and 131.Ev SSH_AUTH_SOCK 132and 133unsetting 134.Ev ENV ; 135permits tedu to run procmap as root without a password; 136and additionally permits root to run unrestricted commands as itself 137while retaining the original PATH. 138.Bd -literal -offset indent 139permit persist setenv { PKG_CACHE PKG_PATH } aja cmd pkg_add 140permit setenv { -ENV PS1=$DOAS_PS1 SSH_AUTH_SOCK } :wheel 141permit nopass tedu as root cmd /usr/sbin/procmap 142permit nopass keepenv setenv { PATH } root as root 143.Ed 144.Sh SEE ALSO 145.Xr doas 1 , 146.Xr syslogd 8 147.Sh HISTORY 148The 149.Nm 150configuration file first appeared in 151.Ox 5.8 . 152.Sh AUTHORS 153.An Ted Unangst Aq Mt tedu@openbsd.org 154