DOAS.CONF(5)

πŸ“¦
version 6.8.2 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– doas.conf β€” the config file that tells doas who's allowed to do what ✨

okay so bestie, welcome to the doas.conf manual page, aka the file-formats girlies' edition of the manual DOAS.CONF(5). pull up a chair, grab a boba, we're gonna read this whole thing together and it's gonna eat. πŸ’…


🌸 NAME 🌸

doas.conf β€” the doas configuration file. that's it. that's the name. iconic.


πŸ¦‹ DESCRIPTION πŸ¦‹

so. the doas(1) utility runs commands as other users, right? and it decides who gets to run what based on the rules in the doas.conf configuration file. she's the boss. she's the gatekeeper. she's giving main character energy. πŸ‘‘

the rules look like this:

permit|deny [options] identity [as target] [cmd command [args ...]]

and now let's break down every single part, no skips, no cap:

  • permit|deny β€” the action to be taken if this rule matches. simple as that, girl.
  • options β€” the little extras. here's the full lineup:
    • nopass β€” the user is not required to enter a password. no password prompt, we just vibe. πŸ™ˆ
    • nolog β€” do not log successful command execution to syslogd(8). keep it quiet, keep it mysterious.
    • persist β€” after the user successfully authenticates, do not ask for a password again for some time. bestie logged in once and now she's free. ✨
    • keepenv β€” environment variables other than those listed in doas(1) are retained when creating the environment for the new process. keep the vibes, keep the env. 🫢
    • setenv { [variable ...] [variable=value ...] } β€” keep or set the space-separated specified variables. variables may also be removed with a leading - or set using the latter syntax. if the first character of value is a $ then the value to be set is taken from the existing environment variable of the indicated name. this option is processed after the default environment has been created. (yes that ordering matters, don't come for me.)
  • identity β€” the username to match. groups may be specified by prepending a colon (:). numeric IDs are also accepted. so like, :wheel is a whole group, slay.
  • as target β€” the target user the running user is allowed to run the command as. the default is all users. generous queen. πŸ‘‘
  • cmd command β€” the command the user is allowed or denied to run. the default is all commands. > be advised that it is best to specify absolute paths. if a relative path is specified, only a restricted PATH will be searched. (lowkey a trap, watch out.)
  • args [argument ...] β€” arguments to command. the command arguments provided by the user need to match those specified. the keyword args alone means that command must be run without any arguments. periodt.

okay so here's the big rule, the one that actually decides everything:

the last matching rule determines the action taken. and if no rule matches, the action is denied. πŸ’€ like, default is no. always no until proven yes.

comments can be put anywhere in the file using a hash mark (#), and extend to the end of the current line. go off, annotate your config, i support you.

and now, the quoting rules, which are very much giving ✨fine print✨:

  • the text between a pair of double quotes (") is taken as is.
  • the backslash character (\) escapes the next character, including new line characters, outside comments; as a result, comments may not be extended over multiple lines. (so no, you cannot make a comment span lines. she said no. 🚫)
  • if quotes or backslashes are used in a word, it is not considered a keyword. iykyk.

πŸŽ€ FILES πŸŽ€

  • /etc/doas.conf β€” doas(1) configuration file. the main girl.
  • /usr/share/doc/opendoas/examples/doas.conf β€” example configuration file. for when you need inspo. 🌈

πŸ”₯ EXAMPLES πŸ”₯

okay here's the whole example, and it is so good, watch this. the following example:

  • permits user aja to install packages from a preferred mirror;
  • permits group wheel to execute commands as any user while keeping the environment variables PS1 and SSH_AUTH_SOCK and unsetting ENV;
  • permits tedu to run procmap as root without a password;
  • and additionally permits root to run unrestricted commands as itself while retaining the original PATH.

and here's the actual config, verbatim, copy it exactly bestie:

permit persist setenv { PKG_CACHE PKG_PATH } aja cmd pkg_add
permit setenv { -ENV PS1=$DOAS_PS1 SSH_AUTH_SOCK } :wheel
permit nopass tedu as root cmd /usr/sbin/procmap
permit nopass keepenv setenv { PATH } root as root

ate. no crumbs. πŸ“


πŸ‘€ SEE ALSO πŸ‘€

doas(1), syslogd(8) β€” go read these too, they're the supporting cast and they understood the assignment.


⭐ HISTORY ⭐

the doas.conf configuration file first appeared in OpenBSD 5.8. a legend from day one, fr fr. 🧚


πŸ’œ AUTHORS πŸ’œ

Ted Unangst <tedu@openbsd.org> β€” the author, the icon, the moment. thank you for your service. 🫑


okay and finally, the cute little sign-off at the bottom: this is from the Debian crowd, dated October 9, 2020, and it's the DOAS.CONF(5) page. love that for us. stay slay, stay permitted, and remember β€” if no rule matches, you're denied. bye bestie!! πŸ’–βœ¨πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from