104
submitted 7 months ago by whyisthesheep@thelemmy.club to c/linux@lemmy.ml

I see people talking about doas saying it's just like sudo but with less features. I'm just wondering if there is any situation where you should use doas or if it's just personal preference.

you are viewing a single comment's thread
view the rest of the comments
[-] matcha_addict@lemy.lol 12 points 7 months ago

When I thought about this question, I decided to ditch both sudo and doas entirely. I am certain this is an unpopular opinion, but I preferred setting up a granular permission + user system instead, and keeping root privileges for only a handful of use cases (primarily for system updates and package installations).

For anything else, a dedicated user is created, and given only permissions to do that exact thing only. Many of these users have no shell access at all, and for the ones that do, I use a password manager so I don't have to memorize passwords for all of these users.

[-] atzanteol@sh.itjust.works 23 points 7 months ago

Did you know that you can configure sudo to only grant access to specific programs?

[-] matcha_addict@lemy.lol 6 points 7 months ago

Yes I did, and that's a very good point. What sudo does not allow me to do is grant a user access to modify or read specific files or directories. I can get both that and access to executing specific programs using a users/groups permission system.

Another thing I don't like about sudo is that you end up using the same password for everything, which is also the password for logging in. Putting higher privileges behind my same login password opens me to a single point of failure.

[-] Pantherina@feddit.de 1 points 7 months ago

Why would a system update need privileges? What is the privileged action in pulling and applying updates your distro ships?

[-] billgamesh@lemmy.ml 4 points 7 months ago

I mean, that's one of the things that definitely needs permissions, right? You're overwriting system config and executables for all users on your system. Otherwise a malicious actor could just replace firewall configs, or embed malicious code into your executables. If not /bin and /etc what else should need privileges?

[-] Pantherina@feddit.de 4 points 7 months ago

On a mutable distro maybe but also no. You need to update your system, always. The updates come from the distro, and you only invoke your privileged package manager to do these changes for you. Its not privileged.

If a malicious actor is able to replace package repos that your package manager uses, for example an infected server in the same network, this would be the only way to inject arbitrary stuff by using dnf update or rpm-ostree update.

Installing software and updating the already existing is very different.

[-] matcha_addict@lemy.lol 2 points 7 months ago

The short answer is that my distro did not let me do this easily. But that was for good reason.

A system update would require too many privileges that it would be almost indistinguishable from root.

Currently, every user I have is restricted in what files it has access to. A system update user would need access to so many files, including install locations of all binaries, and non-binary installation paths of all current and future programs I install (some package installs modify /var, many modify /etc, and so on).

This user will also have access to all these programs, down to system applications. It can trivially break a permission system I come up with.

It may be possible to restrict system updates to a user, but it would be such a powerful user that its not really worth it.

[-] Pantherina@feddit.de 1 points 7 months ago

Does the user have that access? In my case with rpm-ostree they can just execute 2 commands rpm-ostree refresh-md (get updates) and rpm-ostree update. rpm-ostree rebase is used for system upgrades afaik, that one needs a password.

[-] matcha_addict@lemy.lol 1 points 7 months ago

Only the root user has access to system updates on my system currently.

What does rpm-ostree update do exactly? Does it execute the update? Or is that the rebase command only?

[-] Pantherina@feddit.de 1 points 7 months ago

No rpm-ostree downloads the diffs, applies existing changes (added or removed packages) and builds a new image that gets staged as first boot target. After reboot you are on an updated system.

[-] taladar@sh.itjust.works 3 points 7 months ago

If it builds a new image that replaces the entire system it could be compromised to give full access to the entire system just as easily as sudo, possibly more easily.

[-] Pantherina@feddit.de 1 points 7 months ago

No it just pulls the ostree / OCI image from the fedora image registry and applies changes that need sudo privileges to change, remove etc.

Deploying a different image is not allowed.

See this issue for details

[-] taladar@sh.itjust.works 2 points 7 months ago

The component that is like sudo in this case is polkit. Of course an unprivileged user can be used to run sudo commands as well, limited by the rules in the sudo config file, just as these polkit rules limit what the user can do...as long as there is no security issue in sudo and polkit respectively but the actual work is done by a privileged process that is merely controlled by the commands given by the unprivileged user.

[-] Pantherina@feddit.de 1 points 7 months ago

Yes thats the point, the specific actions are a good way to act like a firewall for the access to the privileged process, invoked by anyone.

This is brilliant, as unprivileged users over ssh, or not even logged in, can invoke the updates in that case, making a "grandma pc" that is immutable and autoupdating possible.

See this discussion on how it would eventually be implemented

[-] matcha_addict@lemy.lol 2 points 7 months ago

I see. I have little knowledge, but I bet that the "root privileges" part of this process is the reboot. Upon rebooting, system updates are applied from the new image via some privileged process.

That's pretty neat. Unfortunately I haven't ventured deeply enough into that type of system yet (was it called immutable distro or something?). I use gentoo, which doesn't support this out of the box.

Thanks for showing me something new!

[-] Pantherina@feddit.de 1 points 7 months ago

Rebooting does not need root privileges either, on no system. There really is nothing privileged about updating already existing software. Android is completely rootless and updates are automatic, but can be done manually too.

You can read a bit into OSTree, its very cool. But seems to be very complex and somehow they want to switch to OCI images now, idk.

But the way ublue builds their systems is astonishing, elegant, simple, structured and fully automated.

[-] corsicanguppy@lemmy.ca -1 points 7 months ago

What is the privileged action in pulling and applying updates your distro ships

Tell me again how you want to write system files with a non-admin account, and I'm going to show you my friend Lumpy, who will walk all over your machine so fucking fast. Fuck that, Lumpy's a genius. One of his underlings (he manages now) will do it on a lunch break.

[-] Pantherina@feddit.de 2 points 7 months ago
this post was submitted on 23 Mar 2024
104 points (95.6% liked)

Linux

48056 readers
836 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS