Nsss: A secure NSS-like implementation for static linking
skarnet.org
skarnet.org
One of the reasons why nsswitch runs in the client process is that the modules may very well need access to files that are only readable by the user (kerberos tickets...) or in other ways depend on the authority of the user process. Running this as a system-wide daemon makes such things hard to do as it requires reimplementing security checks that simply work in the in-process case and may very well lead to the daemon having to run with particularly high privileges (read arbitrary files, inspect arbitrary processes...).
ISTM that this should be fixed in Musl, that it should only check `files` first when it comes first in `/etc/nsswitch.conf`.
Also, if IPC to `nscd` were fast enough, then maybe nss should just always call `nscd`. Maybe this should be configurable in `/etc/nsswitch.conf`, then nss should only ever look in `files` when `nscd` is unreachable.
TFA essentially is this, but not in Musl. It's a fine workaround, but it ought to be implemented in Musl.
> - The nscd protocol does not support enumeration, so primitives such as getpwent() cannot be implemented over nscd.
Backend-agnostic enumeration isn't really useful. If you need to enumerate then you need code to talk to the specific backend(s) that you care about (e.g., files, LDAP, etc.).
s6 version 2.12.0.0 or later. It's a run-time requirement only, to run the nsssd service (and can be done without if you have a suitable replacement for s6-ipcserver).
I love that the anti-systemd crowd is implementing their own systemd.
i am glad they stopped complaining and do their own thing. i mean, this is opensource and free software about.
A most striking example is their time approach - they refuse to acknowledge 64-bit timeval and claim "those APIs will become obsolete in 2038" [0]; instead, they promote the TAI time, which is uses Unix epoch, except with bit 63 set and adjusted by leap seconds offset (whose value changes every few years or so, so old code needs to be patched or all timestamps would be a few seconds off). And this is not just internals; it's visible to users for example in log file names [1]
Now, I don't care if it's TAI or UTC, but I do think the working well with others is very important. And choosing a timestamp which is incompatible with basically every other piece of software out there is.. suboptimal.
If this were compatible with the nscd protocol, you could use the daemon with unmodified musl (or appropriately configured glibc)… feels a bit like a missed opportunity?
Making a new, properly documented protocol, independent from That One Libc You Want To Get Rid Of Anyway, is probably a good idea.
The protocol has a version number (so no fundamental limitation), and is implemented in 500 + 170 lines of code:
https://github.com/pikhq/musl-nscd/blob/master/src/socket_ha...
https://github.com/pikhq/musl-nscd/blob/master/src/write_val...
Code isn't docs, but reading 670 lines of code is not "woefully underdocumented". Yes, a spec would be great. So, write one.
Especially since the work for the "new" protocol is the same - or is that equally underdocumented?
systemd uses nss like everything else.
> since the fundamental problem is fairly easy
Very insightful. The problem is actually pretty complicated and requires runtime initialization, unless you forego all of the services NSS provides.
systemd has an nss alternative: https://systemd.io/USER_GROUP_API/
It's only an alternative if you connect to it directly (and why would you?). It's more an alternative to writing another nsswitch backend.