Repository navigation
Replies: 4 comments
|
Thanks for starting this discussion, @rafaelm7o, and sharing an initial approach in the draft PR!
Dumping my brain below for transparency and posterity as I go through the details. Not as decisions yet, more like thinking out loud, noting important bits and recording any questions.
Overall, what I wonder the most about a long-term maintenance perspective: would a single pluggable privilege escalation interface mean less total work than two parallel interfaces? 🤔 I often find it a good exercise to check how other similar projects approach the same challenge to collect inspiration and alternatives. For example Ansible opted for a pluggable |
|
Great idea! enabling a modular approach for this would be really useful! - name: Install package
become: true
become_method: sudo
become_user: rootor globally [privilege_escalation]
become = True
become_method = doas
become_ask_pass = FalseReference: https://docs.ansible.com/projects/ansible/latest/plugins/become.html Puppet Bolt (in the config file): targets:
- uri: server.example.com
config:
ssh:
user: deploy
run-as: root
run-as-command:
- doas
- -n
- -uReference: https://help.puppet.com/bolt/current/topics/privilege_escalation.htm Salt SSH (only supports sudo): web1:
host: server.example.com
user: deploy
sudo: true
sudo_user: rootReference: https://docs.saltproject.io/en/3006/topics/ssh/roster.html Others, like Chef and Puppet, use identity switching, which I consider a completely different approach |
|
Thanks for collecting those examples, @rafaelm7o! To summarize our main findings from our previous chat:
The initial expected major todo items we collected to enable a decision:
And then for an implementation:
We initially envisioned such sample code to inspire/explore alternatives as an interface we aim for: use Rex -feature => qw[1.4 exec_autodie];
# global syntax sugar
sudo TRUE;
become TRUE;
become_method 'sudo';
# config interface
Rex::Config->become(1);
Rex::Config->become_method('doas');
# sample usage
task 'test', sub {
# direct run
run 'whoami';
# run with sudo/doas
sudo 'whoami';
doas 'whoami';
# unified run
become('whoami');
become(
cmd => 'whoami',
user => 'another',
);
# alternative
run_privileged(…);
};The most of the above covers the convenience sugar syntax around privilege escalation, and not the core feature itself. Therefore I took a closer look of what a minimal initial implementation could target. That means the least amount of changes needed to lay the foundations for a better integrated privilee escalation mechanism. First, I found this for running commands (and not Fs/File/similar management yet), which may help others as a workaround today: sub doas {
my $command = shift; # optionally accept a user argument too
run "doas -n $command";
};
task 'test', sub {
doas 'whoami';
};Then I realized that the built-in run $command,
privileges_with => 'doas'; # or sudoWe can grow that interface later for other options around privilege escalation: run $command,
privileges_with => 'doas'; # or sudo
# as_user => 'root', # optional in truly minimal approach, though we likely need to handle a user parameter in general
# privilege_password => $pass; # optional for current doas target, though we likely need to handle a password for privilege escalationAlternatively as a single option bundle for all privilege escalation: run $command,
run_as => {
user => 'root',
with => 'doas'
pass => $password,
};It looks like enough initial examples to consider, though feel free to add more into the pool of ideas, so we can get further inspired about how such an interface could look like. Just to make sure this is now here to give us enough options and ideas for a decision, not the decision itself yet. What do you folks think: which one feels the most natural to write? What do I miss as an alternative syntax? Can we make it even simpler as a first experiment? |
|
I like the idea of extending run() rather than introducing a separate command just for privilege escalation Since run() already accepts options, I'd gravitate around a single privilege parameter supporting both a short form and an explicit one: run 'id', privilege => 'doas';
run 'id',
privilege => {
method => 'sudo',
user => 'root',
};This keeps a common case without limiting us if we need additional config later I would still favor a small backend interface for sudo, doas and other, so the execution logic doesn't need to know the details of each mechanism Since |
Uh oh!
There was an error while loading. Please reload this page.
User story
OpenBSD uses doas by default. Add support for using doas to run commands.
Describe the solution you would like
Use the SUDO implementation as the basis for DOAS, except for the password option, since DOAS doesn't support it
I've been enabling DOAS support, and it works. The files I have modified or added are:
Additional context
No response
All reactions