KIO Admin

I’ve gotten annoyed with the inability to manage system files so I’ve made a KIO worker that enables Dolphin to view and edit files as root.

This is dolphin viewing the system root with administrative access.

The way this works is actually fairly exciting. It’s pulling off worker chaining: The admin worker itself contains gloriously little logic, all it does is translate all worker calls to dbus calls, and those dbus calls go out to a privileged polkit helper. The polkit helper then translates the URIs from admin:///foo to file:///foo and uses the regular KIO API to recreate the request in root-scope. KIO then, behind the scenes, acts just like it would in dolphin proper, using the existing file worker code to execute the file operations.

The advantages are amazing! It’s fairly little actual code (albeit a lot of boilerplate). Since it’s an ordinary worker on the Dolphin side we can expect all file operations to just work™ because really admin:// is just like trash:// or desktop://. Because ultimately the file worker is actually in charge of doing the work, all things are generally expected to work (it’s the same code that powers regular file operations).

Disadvantageously it’s a fair large portal into root-scope, meaning the worker should really only be used in trusted environments (e.g. with only sandboxed applications on the system ;)). Even with polkit guarding the entrance, once you have given permissions you have to trust the application (e.g. dolphin) to not get exploited.

“But why a dedicated worker instead of integrated polkit support in the file worker?” Why, I’m glad you asked! Integrated polkit support sounds simple but is really rocket science. For example there is currently no good architectural way to “catch” operations that had gone wrong – you try to copy a file to `/srv` and that fails with 🤖PERMISSION DENIED🤖 but there is no consistent way to then go “well, let’s retry this entire operation with privileges then” so without huge code refactoring first, we’d end up tucking fallback logic onto every which error scenario… it’s messy and also easy to miss or mess up edge cases. There are also user experience problems. You’d not want to have every internal operation require dedicated permission, so you kind of have to bundle them up and then request permission for the bundle; but how do you know when a bundle is complete? It’s really frightfully complicated.

In conclusion admin:// is awesome today. Maybe one day integrated polkit will also be awesome.

Reviews and testing appreciated https://invent.kde.org/sitter/kio-admin (mind the readme – this currently wants some patching elsewhere in the stack).

Advertisement

17 thoughts on “KIO Admin

  1. Alleluia!!! Thank You!!!
    You don’t mention on the post, however, if we’ll get this on *next framework release, *next dolphin release, *next plasma release, *have to install as service or something like that or *if we really have to compile it…

    • I can’t say yet when it will be generally available because we first need to land some changes to frameworks. It shouldn’t be too long though.

      • OK. But please, when you get some time line let the rest of us – mere mortals – know of it.

        This keeps me from doing some of my work

      • so, let me ask you another question:

        After Frameworks / KIO 5.98 gets released, will this be native (e.g.: comes as default with the whole KIO package ready for everyone to use) or will we still have to install it manually?

  2. I was under the impression that Polkit integration is there since ages, since that was the justification to remove Dolphin-as-root (which was patched back in by openSUSE).

  3. What is the advantage compared to the existing Polkit integration? Is it that all file operations are supported and Polkit is only focusing on editing?

      • The current polkit integration of Dolphin. In Plasma 5.25 and Frameworks 5.97 I can navigate as a regular user to, e.g., /etc/fstab (having no user write permissions), left click to edit it, change it in the now-open kwrite, hit save and Polkit (or PolicyKit) opens a dialog to check for my (root) password in order to save it.

        Therefore the question: What is the advantage of the new solution compared to this existing solution?

        • Sorry for jumping in the discussion…
          I’m on Neon and i can’t do what you are saying!!!

          I’ll assume that is a Distro-Specific feature, like openSUSE, for example, has the possibility to run dolphin as root…

          What distro are you in?

          • I now went looking for your file specifically!
            (until now i’ve been trying with some openvpn files – which is where my problem relies)

            But, in my station, that file ain’t locked. I can edit it with no problems either with dolphin or with kate.
            No root privileges required apparently (No “Lock icon” over the application icon)!

            instead, try to edit any file that has a lock on it a see if you can alter it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s