5 ms·
Doas – Dedicated OpenBSD application subexecutor
- ghshephard 11y agoCompare the code in doas: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/doas/ http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/doas/ to the epic beast that was sudo: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sudo/ http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/sudo/ Amazingly - for such a tiny bit of code, it still has 100% of the functionality I've ever used with sudo: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/doas.conf.5?query=doas%2econf&sec=5 http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/... And you just have to love a man page like this: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/doas.1?query=doas http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/... I really, really like the direction OpenBSD is going. Bit by bit the base operating system is becoming a leaner animal, rid of a lot of cruft that has the potential to bite people in the future. And, note - for anyone who is wondering how one can get by without sudo for backwards compatibility - sudo isn't going away, it's just being moved out of base into ports. If you want to install it in your system - it's just a pkg_add away.
- danieldk 11y agoto the epic beast that was sudo: I don't want to defend sudo, but by definition any C utility that is multi-platform is going to be larger. Also, sudo has features that are required in some enviroments, like LDAP or PAM support. I definitely agree that the direction they are going in is great: a lean base system that has as little attack surface as possible and covers 95% of the use cases. If you do need extra functionality, get it from ports. One thing I wonder about though is: why does a system which goal is security still use C for utilities/programs that are not really CPU-bound? Maybe it's time to slowly ditch C for a safer language where possible? (There are languages that would fit in quite well with OpenBSD, except that they require some portability work.)
- zamalek 11y ago> why does a system which goal is security still use C for utilities/programs that are not really CPU-bound? I think it has something to do with compiler ubiquity. Let's use Python as a good example of "get shit done if you don't care too much about perf." The source tarball for Python is 18MB - even the Windows binaries are 25MB. TCC[1] is 100KB. We can use that as a bad estimate of how hard the platform/runtime is to port. Let's say you wanted to get Doas working on some pet Unix OS that you are writing. If it was written in Python you'd have to first get the entirety (25MB) of Python working; if it was written in C you'd simply cross-compile as you would be already doing for everything else. I'd put good money on you wanting to get Doas/Sudo working before you get Python working or the bajillion different runtimes that all the utils are written in. In that way C has this very peculiar portability: it's not write-once-run-everywhere but it can be write-once-compile-everywhere. It's a common denominator. I could be completely wrong and it could just come down to: old habits die hard. [1]: http://bellard.org/tcc/ http://bellard.org/tcc/
- ghshephard 11y agoRe: Multiplatform Sudo - you bring up a really good point, which is that sudo, a multi-platform utility; It really didn't belong in base. I wonder how many other targets there are that will yield to the wonderful minimalist that is Ted Unangst (who also wrote the signify tools). I'd be interesting in knowing what their thinking is as well. If I had to totally guess - it would be that the OpenBSD team has 15+ years of world-class expertise in writing safe/secure C code, and that switching to a different language would (A) mean having to learn how to do this all over in another language (albeit in a much, much easier manner) and (B) dealing with the abstractions that a language might bring, that didn't exist when you were writing in C. Presumably the advantages of having a memory safe language don't have the benefits for the OpenBSD team that outweigh the negatives. Yet. I guess time will tell.
- MeNotMe 11y agoThis opens you up for disruption, if others with less expertise can write the same secure code using e.g. Rust (I have no clue about Rust)
- leni536 11y agoDoes anybody can use sudo in a way that it adds additional but limited privileges to certain user groups securely? I'm sure it's used only for giving admin privileges to the admin group 99% of the time. If your OS needs a tool that allows users to run processes as another user then maybe your OS needs finer access controls instead. And for the 99% use case I think a few lines long C code would suffice.
- ghshephard 11y agosudo (at least everywhere I've used it) - is typically used to (A) allow me to run code as root without having to type my password, and (B) give select groups of people the rights to run a few specific commands. In terms of number-of-time executed, in a recent environment that I was in, in which approximately 100 or so people had sudo rights, 90+% of the time it was to allow people in various group to run commands like "tcpdump" or "netstat", without giving them full root rights to the system.
- wooger 11y agoYes. One example I've used was setting up some non-technical windows users with a shortcut they could click which would: do a key-based, passwordless ssh login to the server rotate a proxy log, specific to their test machine The logrotate config for these logs included code to move a copy to a mapped network share. So clicking the shortcut caused the log for their most recent bout of testing to magically appear in a folder on their desktop. The sudoers file allowed only this command to be run by these users. They did not get shell access at any stage.
- thaumaturgy 11y agoThe correct way to set up BackupPC to run full disk backups against a remote system is to create a backuppc user on that system and then add an entry to your sudoers file for the most restrictive possible backuppc command. Here's an example from one of my servers: backuppc ALL=(root) NOPASSWD: /usr/bin/rsync --server --sender ?* This primarily is to help limit the amount of damage that backuppc can do if something very strange happens and it decides to try to eat the filesystem.
- gnoway 11y agoThis tool exec's, and its return status reflects whether the command could be launched. Sudo waits and returns the exit code of the process. I'm surprised this wasn't mentioned in the blog post, it's probably the most important difference.
- caf 11y agoIf the exec is successful, it will be replaced by the exec'd program, and its exit code will then be whatever the exit code of that is.
- deleted 11y ago[deleted]