Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: elevate command #29199

Closed
AdrianVovk opened this issue Sep 17, 2023 · 6 comments · Fixed by #30547
Closed

RFC: elevate command #29199

AdrianVovk opened this issue Sep 17, 2023 · 6 comments · Fixed by #30547
Labels
RFE 🎁 Request for Enhancement, i.e. a feature request run

Comments

@AdrianVovk
Copy link
Contributor

AdrianVovk commented Sep 17, 2023

Component

other

Is your feature request related to a problem? Please describe

Elevating privileges in Linux currently requires setuid. These tools thus need to be careful to distrust their input (where any bug == root access on system), isolate their environments, etc etc etc

Describe the solution you'd like

systemd introduces a new tool, elevate, that's basically behaves like systemd-run w/ a more palatable CLI. This lets this elevate tool be unprivileged, and it just asks a privileged client (systemd) to take some action for it.

Describe alternatives you've considered

Discussed w/ @poettering @ ASG, and this is basically what we converged on

Name-wise: most things are named *ctl or systemd-*. This would break with the form. The name might be worth it, though 👀

The systemd version you checked that didn't have the feature you are asking for

254

@AdrianVovk AdrianVovk added the RFE 🎁 Request for Enhancement, i.e. a feature request label Sep 17, 2023
@poettering
Copy link
Member

Yeah, I think this would make sense to add as a multi-call thingy. Probably on systemd-run. (but could also be on machinectl shell).

Should probably follow syntax of sudo a bit, i.e. support -u, -s, -i, and it should some recognizable env vars about the logic being used, similar to how SUDO does it.

@Winterhuman
Copy link
Contributor

Firstly, this sounds amazing! Not needing setuid is a huge advantage.

But second, how would allow-listing users work? Is it still based on a user's membership to the wheel/sudo group, or different authentication entirely?

@poettering
Copy link
Member

We'd defer that to PK, i.e. similar to pkexec in that sense. And I#d assume the default policy we install would bind this to "wheel".

@yuwata yuwata added the run label Sep 21, 2023
@pothos
Copy link
Contributor

pothos commented Oct 4, 2023

FYI, I played with this 2 years ago: https://gist.github.com/pothos/73dd4f7694acc3b6bbed614438f6e2b1 (Note the "known issue" which you might run into as well)

That said, Polkit still uses a setuid binary polkit-agent-helper-1 which gets spawned by systemd-run in the end. I wonder if that could be replaced with some IPC first to make Polkit non-setuid.

@poettering
Copy link
Member

polkit-agent-helper-1

Hmm, how is that actually used? Is that something actually forked off client side? or is this something forked off by polkitd to be able to verify passwords?

I can't find a clear explanation what it actually does and how it is used.

poettering added a commit to poettering/systemd that referenced this issue Dec 20, 2023
This turns "systemd-run" into a multi-call binary. When invoked under
the name "uid0", then it behaves a bit more like traditional "sudo".
This mostly means defaults appropriuate for that, for example a PAM
stack, interactivity and more.

Fixes: systemd#29199
poettering added a commit to poettering/systemd that referenced this issue Dec 20, 2023
This turns "systemd-run" into a multi-call binary. When invoked under
the name "uid0", then it behaves a bit more like traditional "sudo".
This mostly means defaults appropriuate for that, for example a PAM
stack, interactivity and more.

Fixes: systemd#29199
@YHNdnzj
Copy link
Member

YHNdnzj commented Dec 20, 2023

I can't find a clear explanation what it actually does and how it is used.

The polkit agent prompts for password and passes it to polkit-agent-helper-1, the latter of which does pam authentication and returns the result through https://www.freedesktop.org/software/polkit/docs/latest/PolkitAuthority.html#polkit-authority-authentication-agent-response (privileged dbus method)

See also: https://gitlab.freedesktop.org/polkit/polkit/-/issues/168

poettering added a commit to poettering/systemd that referenced this issue Dec 20, 2023
This turns "systemd-run" into a multi-call binary. When invoked under
the name "uid0", then it behaves a bit more like traditional "sudo".
This mostly means defaults appropriuate for that, for example a PAM
stack, interactivity and more.

Fixes: systemd#29199
poettering added a commit to poettering/systemd that referenced this issue Dec 21, 2023
This turns "systemd-run" into a multi-call binary. When invoked under
the name "uid0", then it behaves a bit more like traditional "sudo".
This mostly means defaults appropriuate for that, for example a PAM
stack, interactivity and more.

Fixes: systemd#29199
poettering added a commit to poettering/systemd that referenced this issue Dec 21, 2023
This turns "systemd-run" into a multi-call binary. When invoked under
the name "uid0", then it behaves a bit more like traditional "sudo".
This mostly means defaults appropriuate for that, for example a PAM
stack, interactivity and more.

Fixes: systemd#29199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFE 🎁 Request for Enhancement, i.e. a feature request run
6 participants