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.
On the one hand, doas is simpler. Less code means less bugs, and lower chance someone manages to hack it and gain admin rights. On the other hand, sudo is more popular, and so has a lot more people double-checking its security. Ultimately, I don’t think it matters - when someone unauthorized gains admin rights, usually it’s not due to bug in sudo or doas, but other problems.
Well said. Check your firewalls, check your ssh config, liberally use user repositories, and always tip the guard (donate to GNU)
Doas is more secure, sudo has had a few critical vulnerabilities in the past, because the codebase is much larger. Sudo has like a million features that most people don’t need, but they significantly increase attack surface.
Doas has about 90% of features with 10% of code size of sudo.
And rdo/ssu have ~140 lines of C code. Anyone knows similiar?
I find the config syntax cleaner.
I just use doas because sudo has a bunch of features i don’t care about or use, and doas does everything i need while being significantly smaller.
6,054.0 kB, not 6 vs 14.0 kB
No, but it’s cleaner and designed for my usecase, and no real work to setup for me, all I had to do was add an alias
Less lines of code needed means less chances of errors and potential vulnerabilities (if number and quality of eyeballs were the same)
Also only really applies if you are comparing programs in the same programming language as some programs have lines that are significantly more expressive than others. Conversely, some languages have constructs that are significantly more bug-prone than others (e.g. for loops with explicit integer indices instead of higher order functions like map or iterators to iterate over a collection).
Sure, I was just speaking in general.
Well, i believe in all showcased cases from people here, they are NOT replacing sudo entirely (Except if some are from BSD or if I’m incorrect with this assumption). They are just replacing their user habit with doas and use that command instead. In the end, all unix scripts or apps expect using sudo (If not, su) so… ### What’s even the need to ?
- Size : Installed on top of the already system present sudo.
- Security : Only perhaps if you made a sudo alias to doas (But since it isn’t entirely 1:1 identical, if anyone have a cleaner way of implementing that, I’m all hear)
- Simplicity : You now have two tools. A easy to use keycard, and a key. The second is more complicated to use, so you use it rarely but it’s still two tools instead of one.
- Less dependencies : Again, unless you can actually replace it ENTIRELY, it’s just an added tool (Still almost dependency free)
Really looking to corrections if i do some
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.
Why would a system update need privileges? What is the privileged action in pulling and applying updates your distro ships?
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?
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
orrpm-ostree update
.Installing software and updating the already existing is very different.
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.
Does the user have that access? In my case with rpm-ostree they can just execute 2 commands
rpm-ostree refresh-md
(get updates) andrpm-ostree update
.rpm-ostree rebase
is used for system upgrades afaik, that one needs a password.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?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.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!
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.
BTW I use
pkexec
Well, I use
sudo-rs
, so…From what I hear, doas is more secure. I don’t think it matters though, as long as you keep your system updated. I use sudo still.
How is it more secure?
Afaik much smaller code base and as such easier to audit.
I think it’s because sudo only requires a password the first time on each shell.
It’s entirely configurable but I think by default sudo will “cache” your authentication for a period of time so multiple commands in the same session only need the password entered once. You can even configure sudo to not need a password for certain commands (although obviously you need to be careful you’re not opening a hole in your security).
doas is likewise configurable; though the mechanism that keeps track of the timeout is different on OpenBSD (where doas originated) & Linux ---- and there used to be some reservations about the latter implementation.
sudo maintains ‘sudo state’ for 15 minutes. After that you need to enter the password again.
15 minutes that’s good to know thanks.
It is a configurable value so don’t rely on it being 15 minutes everywhere.