The Surreal Horror of PAM (2021)
xeiaso.net
xeiaso.net
The reason is actually very straightforward: if you can’t read /etc/password, you don’t know who anyone is! Reading this file is (or was, prior to the introduction of nsswitch et al) the way you mapped a UID to a login name, so if you couldn’t read it then anything that needed to show a user (ps, who, ls -l, etc) would just show numbers instead.
Putting the actual password hash in it was, in hindsight, a mistake[1]; this was corrected pretty quickly with /etc/shadow but the file had to stick around with the same name because of all the things that were reading it already. (This is the same reason the “GECOS” field stuck around long after Bell Labs stopped using a GE computer for their print spooler.)
[1] I’m sure it made sense at the time—the fact that the password wasn’t just stored in plaintext was a novelty in its own right and nobody was going to spend that much CPU time trying to crack hashes when there were better things to do with the computer.
We're doing this for a very long time on 500+ machines, and it just works. If you want to sync configs, you can do this with another "femtoservice" running somewhere.
I understand the concerns, but just badmouthing things because they're evolving for decades instead of built from top to bottom every three years is bad to put it mildly.
Not sure about "pretty quickly". If we peg the start of Unix at 1975, we then have Julie Hugh writing the Shadow Password Suite in 1987, thirteen years into the game, and the adoption of shadow didn't take place overnight.
Maybe systemd will streamline it someday.
Beyond that, PAM has been saddled with a whole slew of responsibilities which go beyond user authentication, like supporting anonymous FTP (pam_ftp), maintaining /var/log/lastlog (pam_lastlog), or telling shell users that they have new mail when they log in (pam_mail). A lot of it is pretty specific to supporting traditional shell login workflows on shared machines, and is rarely used in most installs.
I was going to object but you are absolutely right. Most Linux installs are instances of something that are created and destroyed without a human ever touching them. However, I wouldn't go so far as to characterize these features as technical debt. A fully functional Linux system should be able to tell users if they have mail, for instance.
I'm not just talking about containers or managed servers, though. Most Linux desktop systems rarely or never have a user perform a PAM login in a situation where the mail message would be seen. (Opening a terminal emulator doesn't go through PAM; it starts the shell directly, and logging into X / Wayland might use PAM, but doesn't display login messages.) And, of course, it isn't relevant at all on embedded systems; a lot of those probably aren't even running a getty.
> A fully functional Linux system should be able to tell users if they have mail, for instance.
Hot take: storing and processing email shouldn't be a required function of the OS. It should be an optional feature, just like serving web pages over HTTP or having a graphical desktop.
Oh dear god I hope not. Systemd has added immense complication, has sinplified nothing, and is massive bloat.
And yes, systemd shouldn't touch to that.
What does PAM actually do? It allows you to specify different authentication flows depending on the agent (authorizing application) and the intended action/flow. The resulting ruleset is effectively a determination tree, but there is no way to either input your ruleset as a tree structure, nor is there a way to get PAM to dump its abstract syntax tree for debugging.
I suppose I could set an ACL to only make Tailscale SSH intercept logins to nyanpasu64, and not other users like root or gitea (I haven't tested if Tailscale will reject other users or passthrough to gitea). I'm not sure if I should only approve my account, all nonroot, or "all but root and gitea" (unsure if possible with current syntax).
Gitea should not be exposed to the web, and a port knock sequence is highly recommended to keep private projects private. ;)
The Surreal Horror of Pam - https://news.ycombinator.com/item?id=29167560 - Nov 2021 (137 comments)
> It ain’t easy.
VMWare workstation has a built-in gdb stub that can debug guest kernel, or any Linux guest userspace process quite easily. There is also support for windows guests, and even a visual studio plugin for that. I am surprised this did not come up as a very simple option to do this.
It is not easy in the slightest. PAM has aged like bottled milk in a desert.
Aside from the config language, this sounds mostly like "it's a pre-login modular C library, and that's alien territory".
(I imagine you could say that sshd forks for each user, but some of the legacy systems like ftpd/ircd wouldn't have that as an option..)
It was a learning experience, a rather enjoyable one though. While going down the rabbit hole, I feel even deeper when my module kept halting in openssh, due to a bug[2] from 2018.
I didn't really feel the pain of debugging the author had, most likely just because my application was simple enough to be tested via log statements though.
[1] https://github.com/anowell/pam-rs [2] https://bugzilla.mindrot.org/show_bug.cgi?id=2876
password is for workflows that change passwords. It is not used for TOTP, that is an `auth` module. From the Google Authenticator PAM module docs:
> Add this line to your PAM configuration file: `auth required pam_google_authenticator.so no_increment_hotp`
Of the top of my head it promotes a continuous coherent narrative not full of annoying deletions and comments that don't differ wildly from original posts. No posting something incredibly inflammatory, waiting for the conflagration, and then replacing original post with something milder.
On the other hand I have definitely posted something from my phone and cursed when I realized I couldn't fix a typo or decided something could have been communicated better.
It feels like the edit window could at least be a little longer.
Sure. Needing an external debug rig instead of just hitting f5 in your ide does tend to scare some people. No safety blanket.