Go to file
Jesse Smith 8e9c2bde06 Removed the transfer of most environment variables, such as USER, HOME,
and PATH from the original user to the target user. This could cause
files in the wrogn path or home directory to be read (or written to),
which resulted in potential security problems.

This has been changed so that only DISPLAY and TERM are passed to the
new environment. This is fine for running command line programs. When
GUI programs need to be run, "keepenv" can be added to the user's
doas.conf entry. This results in variables like HOME being copied
to the target user, allowing GUI programs to run.

Many thanks to Sander Bos for reporting this issue and explaining
how it can be exploited.

This commit also adds the ability to pass a customized PATH to
target users. The new PATH can be set at compile time in the
Makefile. The default path is provided in the Makefile and commented
out.
2019-08-03 17:39:15 -03:00
doas.1 Updated documentation to include -- paramter and to make it clear 2017-02-17 11:24:29 -04:00
doas.c Removed the transfer of most environment variables, such as USER, HOME, 2019-08-03 17:39:15 -03:00
doas.conf.5 Removed the transfer of most environment variables, such as USER, HOME, 2019-08-03 17:39:15 -03:00
doas.h Removed the transfer of most environment variables, such as USER, HOME, 2019-08-03 17:39:15 -03:00
env.c Removed the transfer of most environment variables, such as USER, HOME, 2019-08-03 17:39:15 -03:00
execvpe.c Removed unused variable assignment in execvpe.c 2019-07-21 20:13:56 -03:00
LICENSE Updated license file. 2017-02-24 10:46:46 -04:00
Makefile Removed the transfer of most environment variables, such as USER, HOME, 2019-08-03 17:39:15 -03:00
parse.y Updated documentation to include -- paramter and to make it clear 2017-02-17 11:24:29 -04:00
README.md Create README.md 2019-06-24 20:22:33 -03:00
reallocarray.c Fix reallocarray.c compilation on FreeBSD 2016-06-24 13:25:03 +02:00
strlcat.c Fixed issue with port of doas searching the user's full path for 2017-09-05 21:40:47 -03:00
strlcpy.c Fixed issue with port of doas searching the user's full path for 2017-09-05 21:40:47 -03:00
tree.h This commit allows doas to compile on Linux. Does not authenticate yet. 2016-06-26 11:41:31 -03:00

doas

A port of OpenBSD's doas which runs on FreeBSD, Linux and NetBSD

The doas utility is a program originally written for OpenBSD which allows a user to run a command as though they were another user. Typically doas is used to allow non-privleged users to run commands as though they were the root user. The doas program acts as an alternative to sudo, which is a popular method in the Linux ccommunity for granting admin access to specific users.

The doas program offers two benefits over sudo: its configuration file has a simple syntax and it is smaller, requiring less effort to audit the code. This makes it harder for both admins and coders to make mistakes that potentially open security holes in the system.

This port of doas has been made to work on FreeBSD 11.x and newer, most distributions of Linux, and NetBSD 8.x and newer.

Installing doas is accomplished in three steps:

  1. Installing build tools.
  2. Compiling and installing the doas utility.
  3. Creating a configuration file for doas.

1 - The doas program has virtually no dependencies. So long as you have a compiler (such as the GNU Compiler or Clang) installed and GNU make (gmake on NetBSD and FreeBSD).

2 - To install doas, download the source code and, in the source code's directory, run the command

 make (on Linux)

or gmake (on FreeBSD and NetBSD).

This builds the source code. Then, as the root user, run

 make install (on Linux)

or

 gmake install (on FreeBSD and NetBSD).

Note: The doas command is in FreeBSD's ports collection and may be installed by simply running the following command as the root user:

  pkg install doas 

3 - The doas configuration file is located at /usr/local/etc/doas.conf. To create a rule allowing a user to perform admin actions, add a line to the configuration file. Details on how to do this are covered in the doas.conf manual page. However, most of the time a rule is as simple as

  permit <user> as root

Where is the username of the person who is being granted root access. For instance:

  permit jesse as root

Additional users can be added to the file, one per line.

To make use of doas, run it in front of any command. Here are some examples:

Confirm doas is working by printing our effective user ID:

 doas id

Create a new file in the root user's home:

 doas touch /root/new-file

On Linux commands with arguments should be prefixed by a double-dash (--). Here we remove a directory owned by root:

 doas -- rm -rf old-directory