TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Sudo-rs dependencies: when less is better

93 pointsby marbuabout 1 year ago

9 comments

epageabout 1 year ago
For some more detail on the choices that went into this, see <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;rust&#x2F;comments&#x2F;1b92j0k&#x2F;sudors_dependencies_when_less_is_better&#x2F;ktuf2t2&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;rust&#x2F;comments&#x2F;1b92j0k&#x2F;sudors_depend...</a><p>For myself, I think people focus too much on &quot;dependency count&quot; and not what those dependencies represent. For example<p>- If a subset of a package is pulled out, it is no longer a &quot;zero dependency&quot; package and some people look down on it.<p>- Whether you use a dependency or write your own, the logic has to exist. The main question is if there is a difference in priorities.<p>Applying those<p>- I really wonder about their claim that using clap took more code than doing it themselves. I also wonder about &quot;not using many features&quot; as there are a lot of usability features in clap that aren&#x27;t items you check off on a list. If dropping clap, it should have been replaced with <a href="https:&#x2F;&#x2F;docs.rs&#x2F;lexopt&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;lexopt&#x2F;</a> rather than rolling their own<p>- While rpassword had its problems, it would have been better to work upstream or create your own competition to upstream, rather than locking away the improvements within sudo-rs<p>- I think its the right choice to keep glob. So long as it implements the spec of interest, bringing it in doesn&#x27;t buy you much while keeping it external gives you the whole &quot;many eyes&quot; situation<p>- I agree about dropping `thiserror`. It can be nice for prototyping or high churn code but if you write-and-forget your errors, you are carrying around that weight for nothing.<p>- Its unclear why they merged all of the sudo-* packages into sudo-rs. I wonder if those would have been cases where they benefit everyone for being split out for reuse.
评论 #39844352 未加载
评论 #39844092 未加载
评论 #39843478 未加载
评论 #39853398 未加载
评论 #39852939 未加载
anonacct37about 1 year ago
I really think that they bury the lede:<p>&gt; As a setuid program meant for elevating privileges, all code that is compiled into sudo-rs has the potential to accidentally (or intentionally) give access to system resources to people who should not have that access. The setuid context additionally puts some constraints on how code is executed, and dependencies might not have accounted for that context. We could not expect any of our dependencies to take into account such a context either.<p>This is the real problem. I&#x27;ve come to the conclusion that setuid programs basically shouldn&#x27;t be using most libraries. The setuid environment is just fundamentally different. A normal library can have a debug output file who&#x27;s location is controlled by an environment variable without that being a security risk. But the instant that program becomes setuid, that&#x27;s an arbitrary file overwrite security bug. Most libraries aren&#x27;t built with that in mind. They shouldn&#x27;t have to be. Setuid is poorly designed.
sebazzzabout 1 year ago
If they don’t link libc statically it can become a problem if the system-installed libc is corrupt or incompatible. My Arch install broke once and I wasn’t able to run pacman to correct it, because the libc installed was not compatible with pacman. If sudo wouldn’t run, I would not even have a chance to repair the install without booting to live cd.
评论 #39843402 未加载
评论 #39842641 未加载
评论 #39843682 未加载
评论 #39853049 未加载
评论 #39843671 未加载
photonbucketabout 1 year ago
Is there any tooling which can tell you exactly which parts of a crate that you actually use and produce a minimized version for vendoring&#x2F;auditing?
评论 #39834340 未加载
评论 #39844189 未加载
评论 #39842661 未加载
评论 #39845564 未加载
dathinababout 1 year ago
There is also cargo vendor (which turns dependencies into path dependencies).<p>Sometimes if you do security sensitive stuff it can be a good option to either:<p>1. pin dependencies and give each dependency a review for suspicious code<p>2. vendor them in some cases (e.g. applying patches, or if pinning seems to not be good enough for whatever reason likely related to offline building)<p>If you are not a very security sensitive project but still worry about the supply chain then it may also be an option to pin&#x2F;vendor some dependencies but e.g. trust `tokio`, `regex` or similar.<p>E.g. not pin some more trusted dependencies but then pin some small utility crate from a random person which you don&#x27;t want to write yourself and is trivial&#x2F;self contained enough so that you likely might not care about any updates to it (still include it into security scans check why it was updated etc.).
ecliptikabout 1 year ago
How does this compare to OpenBSD doas[1][2]?<p>1. <a href="https:&#x2F;&#x2F;man.openbsd.org&#x2F;doas" rel="nofollow">https:&#x2F;&#x2F;man.openbsd.org&#x2F;doas</a><p>2. <a href="https:&#x2F;&#x2F;cvsweb.openbsd.org&#x2F;src&#x2F;usr.bin&#x2F;doas&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cvsweb.openbsd.org&#x2F;src&#x2F;usr.bin&#x2F;doas&#x2F;</a>
评论 #39844328 未加载
awoimbeeabout 1 year ago
&gt; In the end, we chose the potential dangers of reimplementing command line parsing over the potential issues of including clap<p>Have you considered using argh ? Seems like it has the upsides without the downsides.
评论 #39842328 未加载
评论 #39842892 未加载
评论 #39843054 未加载
thevidelabout 1 year ago
&gt; including crates for platforms such as Windows, which we obviously would not require as a Unix utility.<p>Probably a little less obvious now that Windows has their sudo?<p><a href="https:&#x2F;&#x2F;learn.microsoft.com&#x2F;fr-fr&#x2F;windows&#x2F;sudo&#x2F;" rel="nofollow">https:&#x2F;&#x2F;learn.microsoft.com&#x2F;fr-fr&#x2F;windows&#x2F;sudo&#x2F;</a>
评论 #39842213 未加载
评论 #39842216 未加载
MuffinFlavoredabout 1 year ago
&gt; We replaced it with our own argument parsing once we noticed that adopting clap was taking more code than doing it ourselves.<p>I feel like it&#x27;s obvious that there are two sides to this echoed throughout the &quot;programming&quot; community:<p>1. Don&#x27;t pull a package in for what you can do yourself because it might have 500 dependenices for no good reason<p>2. Don&#x27;t roll your own, use something off-the-shelf third-party that is actively maintained, open-source, well written&#x2F;easily usable&#x2F;fleshed out, etc.<p>They conflict...
评论 #39842448 未加载
评论 #39842884 未加载
评论 #39842416 未加载
评论 #39842561 未加载
评论 #39842934 未加载