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

RFE/Linux: polkit integration #13585

Open
1 task done
joebonrichie opened this issue Jun 27, 2024 · 2 comments · May be fixed by #22045
Open
1 task done

RFE/Linux: polkit integration #13585

joebonrichie opened this issue Jun 27, 2024 · 2 comments · May be fixed by #22045
Labels

Comments

@joebonrichie
Copy link
Contributor

Check for existing issues

  • Completed

Describe the feature

Currently on linux, zed has no way to prompt for elevated permissions (root) if the user does not have the permissions to write/read a file.

This is traditionally done with a request to polkit over dbus which will then prompt the user to input the superuser password in order to successfully perform the operation.

This is useful when attempting to use zed to update config files in the /etc/ directory, or, attempting to open files the user doesn't have read permission on, as some examples.

#10423 is a tangibly related issue for macos, however this request is for linux.

If applicable, add mockups / screenshots to help present your vision of the feature

Example of a polkit prompt
Screenshot from 2024-06-27 11-15-04

@joebonrichie joebonrichie added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Jun 27, 2024
@notpeter notpeter added linux and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Jun 27, 2024
@notpeter
Copy link
Member

Here's a similar issue for MacOS:

@ReillyBrogan
Copy link

For reference, this sort of thing is generally accomplished in the following way on most Linux distributions (IE, using systemd/dbus/polkit)

  • The application tries to perform a file operation, receives EPERM/EACCES
  • The application sends a request to polkit containing subject (Information about the user performing the action and the calling process) and action1 information (over dbus, which polkit bindings usually abstract for you)
  • Polkit compares the subject/action against system policy and decides to either deny, allow, or require user intervention
  • If polkit decides that user intervention is needed it creates a prompt using an appropriate polkit helper (Joey's screenshot above shows the GNOME-specific one which integrates with GNOME and looks native on that platform, Plasma users will see the Plasma dialog etc)
  • Depending on what the user enters the "requires user intervention" will either evaluate to an allow or a deny
  • If the action is "deny" the denial will be returned to the application
  • If the action is "allow" then polkit will basically forward the subject/action over dbus to a dbus system service
  • This dbus system service is typically start-on-demand, and the dbus service can only be connected to by root
  • Dbus buffers the dbus call and starts the binary as specified in the dbus service file to handle it
  • The binary processes the call and presumably does the encoded action as superuser, returning a reply to the calling application and exiting
  • The calling application then processes the reply for whether it succeeded/failed and any necessary context information and then updates the UI accordingly

So from the perspective of Zed, what needs to be changed to handle this is the following:

  • Create a new libexec helper binary (note that technically these dbus interfaces could be implemented into the zed-editor libexec binary but for latency and security reasons creating a highly minimal separate binary is a better option).
  • Create dbus service files that basically state that the dbus service is ran as root and that only root can own the interface (IE only root processes can connect to it over dbus)
  • Create a polkit policy document
  • Implement a wrapper around file writing operations on Linux that catches EPERM/EACCES and handles the appropriate polkit action.
  • Try to engage with the SUSE security team to review the design of all of this since they have numerous experts and tend to be responsive to open source projects

References:

And this is how it's implemented in Kate:

Footnotes

  1. Some applications have fine-grained actions which allow an administrator/packager to create more sophisticated policies. Others just use a single action for everything and do everything application-side through that one overloaded action. Policies then break down to "can do super-user things" or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants