commit 8ad21e87e796dfd3d9d2774b56d83193b6dd84a9 from: Diogo Galvão via: the xhr date: Mon Jun 29 15:38:39 2020 UTC Wording commit - 98157dbaa1dec16f4062ab9726794bcc8e7e6cba commit + 8ad21e87e796dfd3d9d2774b56d83193b6dd84a9 blob - b73bf08ed6389f7f1f5a0cac9af7231534f949bc blob + f214161a1736425b3ccdbc0c55174be53b761f97 --- readme.md +++ readme.md @@ -9,14 +9,14 @@ Execute commands in Xorg as another user. $ chmod +x xodo.sh $ doas mv -i xodo.sh /usr/local/bin/xodo -If your user doesn't have `doas` privileges, become `root` and copy the file accordingly. +If you don't have `doas` privilege for this, become `root` and copy the file accordingly. ## Usage $ doas xodo --setup firefox $ xodo firefox -If your user doesn't have `doas` privileges, become `root` and setup `xodo` with the `--for` option as described further below. +If you don't have `doas` privilege for the initial setup, become `root` and setup `xodo` with the `--for` option as described further below. ## Command-line options @@ -26,27 +26,27 @@ If your user doesn't have `doas` privileges, become `r ## Description -The `xodo` utility authorizes a conventioned user in the form of `$user-$command` to connect to the active Xorg display, then executes the given command as this other user. +The `xodo` utility authorizes another user to connect to the active Xorg display, then executes the given command as this other user. It's been developed to ease the steps for running desktop programs with different privileges than your own, so that a vulnerability doesn't compromise anything other than the program itself. -This script has been developed to avoid a potential vulnerability in a desktop program to compromise anything else other than the program itself. To accomplish this, each program is executed as a different user that connects to the active Xorg display, using an Xauthority cookie file that's setup automatically by `xodo`. +Essentially, all `xodo` does is call `xauth` and `doas`, and it can also configure new users automatically with the `--setup` option. -Before using `xodo` to execute commands, the unprivileged user must be created first, either manually or using the `--setup` option. Besides adding the new user, the main user that's going to execute `xodo` must be allowed in `doas.conf` to execute the given command as the other user. This is already taken care of when using `xodo`'s `--setup` option. +Before using `xodo` for executing a program, another user must exist, preferably for the sole purpose of running said program. It can be created either manually or using the `--setup` option, and the main user that's going to execute `xodo` must be allowed in `doas.conf` to execute the given command as this other user. This is already taken care of when using `xodo`'s `--setup` option. Unless told otherwise, this other user defaults to `-`. The command argument is mandatory and can either be an absolute or relative path, or just the command basename. In this latter case, the command is assumed to be in the current `PATH`. Arguments to the command being executed are not supported yet. -The options are as follows: +Supported options are as follows: ### --as -When specified, this is the unprivileged user as which the command is going to be executed, or the user that's going to be created when invoked with the `--setup` option. +When specified, this is the user as which the command is going to be executed, or the user that's going to be created when invoked with the `--setup` option. -When ommitted, the convention assumes `$user-$command` instead. In this case, `$USER` environment variable is assumed. During setup, this can be overridden with the `--for` option. +When ommitted, the convention assumes `-`. During setup, the username part can be overriden with the `--for` option. Otherwrise, the `$USER` environment variable is used. ### --for -When specified, this is the user that will be allowed to execute the command as another user. This options is only used with `--setup`. +When specified, this is the user that will be allowed to execute the command as another user. This options is only used with `--setup` for adding an entry to `doas.conf`. -When ommitted, the `$USER` environment variable is used. +When ommitted, the current username in the `$USER` environment variable is used. ### --help
-h @@ -54,21 +54,21 @@ Display basic usage syntax. ### --setup -Adds a new user and authorizes the current user in `doas.conf` to execute the given command as the new unprivileged user. The current user is also added to the new user's group. +Adds a new user and authorizes the current user to execute the given command as this new user, by appending an entry to `doas.conf`. The current user is also added to the new user's own group, in order to have access to its files. If the new user already exists, no user is added and the current user is not added to any group, but `doas.conf` still gets a new entry. -Options `--as` and `--for` overrides the username being created, and the existing user that will be allowed to execute the command, respectively. +Options `--as` and `--for` overrides the username being created and the existing user that will be allowed to execute the command, respectively. -This option must be used as `root`, as it calls `useradd` and `usermod`, and also appends an entry to `doas.conf`. +This option must be used as `root`, as it calls `useradd` and `usermod`, and writes to `/etc/doas.conf`. ## Examples -Configure an unprivileged user for Mike to execute Firefox: +Configure a separate user for Mike to execute Firefox: mike$ doas xodo --setup firefox -This assumes that Mike is permitted in `doas.conf` to execute `xodo` as ` root`. Otherwise, `root` should be used directly for setting this up for Mike: +This assumes that Mike is permitted in `doas.conf` to execute `xodo` as ` root`. If that's not so, `root` should be used directly for setting this up for Mike: root# xodo --setup firefox --for mike @@ -77,13 +77,13 @@ that any vulnerability in Firefox wouldn't compromise mike$ xodo firefox -To create an unprivileged user different than the `$user-$command` convetion, use the `--as` option during setup: +To create a user different than the `-` convention, use the `--as` option during setup: - root# xodo --setup firefox --for mike --as mike-work + root# xodo --setup firefox --for mike --as mike-web Then specify this different user when executing `xodo`: - mike$ xodo firefox --as mike-work + mike$ xodo firefox --as mike-web ## See also