Blame


1 ee814429 2020-06-29 xhr IMPORTANT
2 ee814429 2020-06-29 xhr =========
3 ee814429 2020-06-29 xhr
4 ee814429 2020-06-29 xhr This is a copy of garotosopa's xodo repository since he deleted the repo. Do not bother him with pull requests, bugs, etc! Of course, the original copyright stays intact!
5 ee814429 2020-06-29 xhr
6 97695aca 2020-06-29 xhr xodo
7 97695aca 2020-06-29 xhr ====
8 97695aca 2020-06-29 xhr
9 97695aca 2020-06-29 xhr Execute commands in Xorg as another user.
10 97695aca 2020-06-29 xhr
11 97695aca 2020-06-29 xhr ## Getting started
12 97695aca 2020-06-29 xhr
13 98157dba 2020-06-29 xhr $ ftp https://raw.githubusercontent.com/garotosopa/xodo/master/xodo.sh
14 98157dba 2020-06-29 xhr $ chmod +x xodo.sh
15 98157dba 2020-06-29 xhr $ doas mv -i xodo.sh /usr/local/bin/xodo
16 97695aca 2020-06-29 xhr
17 8ad21e87 2020-06-29 xhr If you don't have `doas` privilege for this, become `root` and copy the file accordingly.
18 97695aca 2020-06-29 xhr
19 97695aca 2020-06-29 xhr ## Usage
20 97695aca 2020-06-29 xhr
21 98157dba 2020-06-29 xhr $ doas xodo --setup firefox
22 98157dba 2020-06-29 xhr $ xodo firefox
23 97695aca 2020-06-29 xhr
24 8ad21e87 2020-06-29 xhr If you don't have `doas` privilege for the initial setup, become `root` and setup `xodo` with the `--for` option as described further below.
25 97695aca 2020-06-29 xhr
26 97695aca 2020-06-29 xhr ## Command-line options
27 97695aca 2020-06-29 xhr
28 98157dba 2020-06-29 xhr xodo <command> [--as <user>]
29 98157dba 2020-06-29 xhr xodo --setup <command> [--as <user>] [--for <user>]
30 98157dba 2020-06-29 xhr xodo --help
31 97695aca 2020-06-29 xhr
32 97695aca 2020-06-29 xhr ## Description
33 97695aca 2020-06-29 xhr
34 8ad21e87 2020-06-29 xhr 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.
35 97695aca 2020-06-29 xhr
36 8ad21e87 2020-06-29 xhr Essentially, all `xodo` does is call `xauth` and `doas`, and it can also configure new users automatically with the `--setup` option.
37 97695aca 2020-06-29 xhr
38 8ad21e87 2020-06-29 xhr 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 `<user>-<command>`.
39 97695aca 2020-06-29 xhr
40 98157dba 2020-06-29 xhr 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.
41 97695aca 2020-06-29 xhr
42 8ad21e87 2020-06-29 xhr Supported options are as follows:
43 97695aca 2020-06-29 xhr
44 97695aca 2020-06-29 xhr ### --as <user>
45 97695aca 2020-06-29 xhr
46 8ad21e87 2020-06-29 xhr 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.
47 97695aca 2020-06-29 xhr
48 8ad21e87 2020-06-29 xhr When ommitted, the convention assumes `<user>-<command>`. During setup, the username part can be overriden with the `--for` option. Otherwrise, the `$USER` environment variable is used.
49 97695aca 2020-06-29 xhr
50 97695aca 2020-06-29 xhr ### --for <user>
51 97695aca 2020-06-29 xhr
52 8ad21e87 2020-06-29 xhr 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`.
53 97695aca 2020-06-29 xhr
54 8ad21e87 2020-06-29 xhr When ommitted, the current username in the `$USER` environment variable is used.
55 97695aca 2020-06-29 xhr
56 98157dba 2020-06-29 xhr ### --help<br>-h
57 97695aca 2020-06-29 xhr
58 97695aca 2020-06-29 xhr Display basic usage syntax.
59 97695aca 2020-06-29 xhr
60 97695aca 2020-06-29 xhr ### --setup <command>
61 97695aca 2020-06-29 xhr
62 8ad21e87 2020-06-29 xhr 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.
63 97695aca 2020-06-29 xhr
64 98157dba 2020-06-29 xhr 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.
65 97695aca 2020-06-29 xhr
66 8ad21e87 2020-06-29 xhr Options `--as` and `--for` overrides the username being created and the existing user that will be allowed to execute the command, respectively.
67 97695aca 2020-06-29 xhr
68 8ad21e87 2020-06-29 xhr This option must be used as `root`, as it calls `useradd` and `usermod`, and writes to `/etc/doas.conf`.
69 97695aca 2020-06-29 xhr
70 97695aca 2020-06-29 xhr ## Examples
71 97695aca 2020-06-29 xhr
72 8ad21e87 2020-06-29 xhr Configure a separate user for Mike to execute Firefox:
73 97695aca 2020-06-29 xhr
74 98157dba 2020-06-29 xhr mike$ doas xodo --setup firefox
75 97695aca 2020-06-29 xhr
76 8ad21e87 2020-06-29 xhr 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:
77 97695aca 2020-06-29 xhr
78 98157dba 2020-06-29 xhr root# xodo --setup firefox --for mike
79 97695aca 2020-06-29 xhr
80 98157dba 2020-06-29 xhr Either way, now Mike can execute Firefox as the user **mike-firefox**, so
81 97695aca 2020-06-29 xhr that any vulnerability in Firefox wouldn't compromise Mike's files:
82 97695aca 2020-06-29 xhr
83 98157dba 2020-06-29 xhr mike$ xodo firefox
84 97695aca 2020-06-29 xhr
85 8ad21e87 2020-06-29 xhr To create a user different than the `<user>-<command>` convention, use the `--as` option during setup:
86 97695aca 2020-06-29 xhr
87 8ad21e87 2020-06-29 xhr root# xodo --setup firefox --for mike --as mike-web
88 97695aca 2020-06-29 xhr
89 98157dba 2020-06-29 xhr Then specify this different user when executing `xodo`:
90 97695aca 2020-06-29 xhr
91 8ad21e87 2020-06-29 xhr mike$ xodo firefox --as mike-web
92 97695aca 2020-06-29 xhr
93 97695aca 2020-06-29 xhr ## See also
94 97695aca 2020-06-29 xhr
95 97695aca 2020-06-29 xhr * [doas(1)](http://man.openbsd.org/OpenBSD-current/man1/doas.1)
96 97695aca 2020-06-29 xhr * [doas.conf(5)](http://man.openbsd.org/OpenBSD-current/man5/doas.conf.5)
97 97695aca 2020-06-29 xhr * [xauth(1)](http://man.openbsd.org/OpenBSD-current/man1/xauth.1)