I agree with you - the linux ecosystem is very impressive, up until the user-space (with many exceptions of course). I usually never recommend starting from scratch, and we should definitely strive for proper backwards compatibility, but I don’t feel much would be lost by leaving behind the whole, unsecure C programs of contemporary linux distros.
Like, why does it still have to be C, didn’t we learn a bit from all those vulnerabilities?!
The problem with PAM isn’t (IMO) that it’s written in C. The problems are that the entire design is horrible, the configuration abilities are horrible, the maintenance seems pretty bad (not much changes these days), and the ability to actually interact with PAM during authentication is quite weak.
The latter is a functionality weakness (e.g. doing anything useful using PAM when accessing a system over SSH or HTTPS or really anything else is a mess and not terribly useful, but it also makes the fact that PAM is written in C be less of a problem: there is so little untrusted input available to PAM that it’s not a very easy target.
What PAM needs is a redesign. A different language would just be icing on the cake.
Like, why does it still have to be C, didn’t we learn a bit from all those vulnerabilities?!