]> git.armaanb.net Git - opendoas.git/blob - doas.conf.5
more precisely describe what happens to the environment without keepenv; OK tedu@
[opendoas.git] / doas.conf.5
1 .\" $OpenBSD: doas.conf.5,v 1.13 2015/07/27 21:44:11 tedu 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: July 27 2015 $
17 .Dt DOAS.CONF 5
18 .Os
19 .Sh NAME
20 .Nm doas.conf
21 .Nd doas configuration file
22 .Sh DESCRIPTION
23 The
24 .Xr doas 1
25 utility executes commands as other users according to the rules
26 in the
27 .Nm
28 configuration file.
29 .Pp
30 The 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
39 Rules consist of the following parts:
40 .Bl -tag -width 11n
41 .It Ic permit Ns | Ns Ic deny
42 The action to be taken if this rule matches.
43 .It Ar options
44 Options are:
45 .Bl -tag -width keepenv
46 .It Ic nopass
47 The user is not required to enter a password.
48 .It Ic persist
49 After the user successfully authenticates, do not ask for a password
50 again for some time.
51 .It Ic keepenv
52 The user's environment is maintained.
53 The default is to retain the variables
54 .Ev DISPLAY
55 and
56 .Ev TERM
57 from the invoking process, reset
58 .Ev HOME ,
59 .Ev LOGNAME ,
60 .Ev PATH ,
61 .Ev SHELL ,
62 and
63 .Ev USER
64 as appropriate for the target user, and discard the rest of the environment.
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
67 specified variables.
68 Variables may also be removed with a leading
69 .Sq -
70 or set using the latter syntax.
71 If the first character of
72 .Ar value
73 is a
74 .Ql $
75 then the value to be set is taken from the existing environment
76 variable of the indicated name.
77 .El
78 .It Ar identity
79 The username to match.
80 Groups may be specified by prepending a colon
81 .Pq Sq \&: .
82 Numeric IDs are also accepted.
83 .It Ic as Ar target
84 The target user the running user is allowed to run the command as.
85 The default is all users.
86 .It Ic cmd Ar command
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
91 .Ev PATH
92 will be searched.
93 .It Ic args Op Ar argument ...
94 Arguments to command.
95 The command arguments provided by the user need to match those specified.
96 The keyword
97 .Ic args
98 alone means that command must be run without any arguments.
99 .El
100 .Pp
101 The last matching rule determines the action taken.
102 If no rule matches, the action is denied.
103 .Pp
104 Comments can be put anywhere in the file using a hash mark
105 .Pq Sq # ,
106 and extend to the end of the current line.
107 .Pp
108 The following quoting rules apply:
109 .Bl -dash
110 .It
111 The text between a pair of double quotes
112 .Pq Sq \&"
113 is taken as is.
114 .It
115 The backslash character
116 .Pq Sq \e
117 escapes the next character, including new line characters, outside comments;
118 as a result, comments may not be extended over multiple lines.
119 .It
120 If quotes or backslashes are used in a word,
121 it isn't considered a keyword.
122 .El
123 .Sh FILES
124 .Bl -tag -width "/etc/doas.conf"
125 .It Pa /etc/doas.conf
126 doas configuration file.
127 .El
128 .Sh EXAMPLES
129 The following example permits user aja to install packages
130 from a preferred mirror;
131 group wheel to execute commands as any user while keeping the environment
132 variables
133 .Ev PS1
134 and
135 .Ev SSH_AUTH_SOCK
136 and
137 unsetting
138 .Ev ENV ;
139 permits tedu to run procmap as root without a password;
140 and additionally permits root to run unrestricted commands as itself.
141 .Bd -literal -offset indent
142 permit persist setenv { PKG_CACHE PKG_PATH } aja cmd pkg_add
143 permit setenv { -ENV PS1=$DOAS_PS1 SSH_AUTH_SOCK } :wheel
144 permit nopass tedu as root cmd /usr/sbin/procmap
145 .Ed
146 .Sh SEE ALSO
147 .Xr doas 1
148 .Sh HISTORY
149 The
150 .Nm
151 configuration file first appeared in
152 .Ox 5.8 .
153 .Sh AUTHORS
154 .An Ted Unangst Aq Mt tedu@openbsd.org