Skip to content

Comment on Sudo-rs dependencies: when less is better

Comments

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.

If the system-provided libc is corrupt, isn't sudo the least of your concern? What else is going to work?

What else is going to work?

Everything that was statically compiled.

A statically-linked busybox, which is often enough.

What distros are there that normally dynamically link everything but statically link sudo? OpenSUSE, Debian and Ubuntu (the distros I have on hand) do not, at least.

I just checked on NixOs, and ldd reports sudo is not dynamic.

Did you check the real sudo binary, or the setuid wrapper?

On my system sudo is `/run/wrappers/bin/sudo` but that is a setuid wrapper for `/nix/store/z008bzqrl2zc848gjhh04012jhxpl72q-sudo-1.9.15p5/bin/sudo` which is dynamically linked.

Ah, I guess I just checked the wrapper.

That's what I get for doing it on my phone over ssh. I would have probably looked deeper with a real keyboard.

Funnily enough something similar happened to me after doing a partial update. Doing a partial update are not supported in arch linux for this very reason.

sudo broke as well as many others command. ssh worked for a bit and then segfaulted. I edited my PATH to have a healthy version of libc but things kept breaking in different ways (version mismatches) In the end I had to use a live usb drive as I couldn't write to /usr/lib

This only works on Linux of course since the Linux kernel and libc are not tightly coupled, on any other OS dynamically linking against libc is a necessity. Also, I've never seen anyone statically linking against glibc? Is that even something people do? I'd consider your system provided libc being broken is a similar situation to an unbootable kernel: you just need a rescue stick/partition to fix it, or reinstall your OS.

I'd invest $10 into a rescue USB stick regardless. I like putting Ventoy on it and having a large number of different distribution ISOs on there, just in case.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.