xref: /openbsd/usr.bin/doas/doas.conf.5 (revision 264ca280)
1.\" $OpenBSD: doas.conf.5,v 1.29 2016/06/27 17:36:33 jmc 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: June 27 2016 $
17.Dt DOAS.CONF 5
18.Os
19.Sh NAME
20.Nm doas.conf
21.Nd doas configuration file
22.Sh SYNOPSIS
23.Nm /etc/doas.conf
24.Sh DESCRIPTION
25The
26.Xr doas 1
27utility executes commands as other users according to the rules
28in the
29.Nm
30configuration file.
31.Pp
32The rules have the following format:
33.Bd -ragged -offset indent
34.Ic permit Ns | Ns Ic deny
35.Op Ar options
36.Ar identity
37.Op Ic as Ar target
38.Op Ic cmd Ar command Op Ic args ...
39.Ed
40.Pp
41Rules consist of the following parts:
42.Bl -tag -width 11n
43.It Ic permit Ns | Ns Ic deny
44The action to be taken if this rule matches.
45.It Ar options
46Options are:
47.Bl -tag -width keepenv
48.It Ic nopass
49The user is not required to enter a password.
50.It Ic keepenv
51The user's environment is maintained.
52The default is to reset the environment, except for the variables
53.Ev DISPLAY ,
54.Ev HOME ,
55.Ev LOGNAME ,
56.Ev MAIL ,
57.Ev PATH ,
58.Ev TERM ,
59.Ev USER
60and
61.Ev USERNAME .
62.It Ic setenv { Oo Ar variable ... Oc Oo Ar variable=value ... Oc Ic }
63In addition to the variables mentioned above, keep the space-separated
64specified variables.
65Variables may also be removed with a leading
66.Sq -
67or set using the latter syntax.
68If the first character of
69.Ar value
70is a
71.Ql $
72then the value to be set is taken from the existing environment
73variable of the same name.
74.El
75.It Ar identity
76The username to match.
77Groups may be specified by prepending a colon
78.Pq Sq \&: .
79Numeric IDs are also accepted.
80.It Ic as Ar target
81The target user the running user is allowed to run the command as.
82The default is all users.
83.It Ic cmd Ar command
84The command the user is allowed or denied to run.
85The default is all commands.
86Be advised that it is best to specify absolute paths.
87If a relative path is specified, only a restricted
88.Ev PATH
89will be searched.
90.It Ic args ...
91Arguments to command.
92The command arguments provided by the user need to match those specified.
93The keyword
94.Ic args
95alone means that command must be run without any arguments.
96.El
97.Pp
98The last matching rule determines the action taken.
99If no rule matches, the action is denied.
100.Pp
101Comments can be put anywhere in the file using a hash mark
102.Pq Sq # ,
103and extend to the end of the current line.
104.Pp
105The following quoting rules apply:
106.Bl -dash
107.It
108The text between a pair of double quotes
109.Pq Sq \&"
110is taken as is.
111.It
112The backslash character
113.Pq Sq \e
114escapes the next character, including new line characters, outside comments;
115as a result, comments may not be extended over multiple lines.
116.It
117If quotes or backslashes are used in a word,
118it is not considered a keyword.
119.El
120.Sh EXAMPLES
121The following example permits users in group wsrc to build ports;
122wheel to execute commands as any user while keeping the environment
123variables
124.Ev PS1
125and
126.Ev SSH_AUTH_SOCK
127and
128unsetting
129.Ev ENV ;
130permits tedu to run procmap as root without a password;
131and additionally permits root to run unrestricted commands as itself.
132.Bd -literal -offset indent
133# Non-exhaustive list of variables needed to
134# build release(8) and ports(7)
135permit nopass setenv { \e
136        FTPMODE PKG_CACHE PKG_PATH SM_PATH SSH_AUTH_SOCK \e
137        DESTDIR DISTDIR FETCH_CMD FLAVOR GROUP MAKE MAKECONF \e
138        MULTI_PACKAGES NOMAN OKAY_FILES OWNER PKG_DBDIR \e
139        PKG_DESTDIR PKG_TMPDIR PORTSDIR RELEASEDIR SHARED_ONLY \e
140        SUBPACKAGE WRKOBJDIR SUDO_PORT_V1 } :wsrc
141permit setenv { -ENV PS1=$DOAS_PS1 SSH_AUTH_SOCK } :wheel
142permit nopass tedu as root cmd /usr/sbin/procmap
143permit nopass keepenv root as root
144.Ed
145.Sh SEE ALSO
146.Xr doas 1
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