Live data from Hacker News

🥺: the best sudo replacement

xeiaso.net

11–20 of 559 posts

Re: 🥺: the best sudo replacement

#11
post #6

Wait? it doesn't make any sense. So any userspace program can call `setuid(0)` and `execv()`? Why is there sudo in the first place? I am not getting it.

Any userspace can call it, but unless you have the SUID bit set on the binary and have it owned by root, it won’t really do much.

Re: 🥺: the best sudo replacement

#12
post #6

Wait? it doesn't make any sense. So any userspace program can call `setuid(0)` and `execv()`? Why is there sudo in the first place? I am not getting it.

Presuming charitably that you mean the more interesting question of "why is this a program rather than a thing other programs do internally when they realize they need elevation": well, two reasons:

1. any program can call fopen(2) and fwrite(2), and yet cat(1) exists. Unix plumbing is mostly there for cases where you're linking programs together in ways those programs didn't expect.

2. Privilege separation. You don't want big, complex programs running as root. You want big, complex programs running as your user, speaking to tiny little well-hardened programs running as root over a pipe, where the tiny-little program can only do one thing.

For example, you might have seen the pattern of piping things into `sudo tee [file owned by root]` in order to be able to write to a file that's owned by root. This fits both of the above considerations: moving the privilege into "tee" rather than having whatever command is generating the text, exposes less of a vulnerability surface; and also, it's `sudo tee` rather than tee(1) itself performing elevation, because tee(1) itself was written a decade or two before this pattern emerged, and so has no idea it could be used this way.

Re: 🥺: the best sudo replacement

#16
post #15

[flagged]

I'm pretty sure the (as far as I can tell) was about not intending to rewrite in rust. > (as far as I can tell) have no intention of rewriting it in Rust,

Ahh, yes, your right. That part is certainly my misunderstanding.

Re: 🥺: the best sudo replacement

#17
post #9
post #6

Wait? it doesn't make any sense. So any userspace program can call `setuid(0)` and `execv()`? Why is there sudo in the first place? I am not getting it.

The program needs to have the setuid bits set on its inode (chmod u+s), and be owned by root. https://en.wikipedia.org/wiki/Setuid Sudo exists as an elaborate ACL scheme implemented in user-space which takes advantage of the setuid+root permission scheme implemented in the Unix kernel to allow granularly granting root access to non-root users. But any program can be setuid and/or setgid to any user/group and it will…

Understood. Thanks.

Re: 🥺: the best sudo replacement

#18

[flagged]

We've banned this account for posting flamebait and unsubstantive comments and generally breaking the site guidelines a lot.

Please don't create accounts to do that with; it will eventually get your main account banned as well.

https://news.ycombinator.com/newsguidelines.html

Re: 🥺: the best sudo replacement

#19
post #2

The actual title is supposed to be "🥺: the best sudo replacement", but I'm not surprised that Hacker News stripped the emoji.

I've put it back for you.

HN is plain-text-obsessive by design but occasional exceptions make life interesting.

Post reply on HN