0

I have multiple files in /etc/pam.d. I think they slightly differ in name between different distributions. And I also do not see a direct connection between process-name and configuration (e.g. chpasswd vs. passwd).

Is somewhere or somehow defined which application uses which pam-files?

1

TL;DR: there's no rule, it totally depends on implementation done by developper who implemented the software.

LONG VERSION:

When a program uses PAM for authentication, it have to call pam_start() function. Prototype of pam_start() is the following:

int pam_start(const char *service_name, const char *user, const struct pam_conv *pam_conversation, pam_handle_t **pamh); 

(See manpage for more details).

The first argument, service_name is the one used.

When having a look to OpenSSH source code, you may see the following in file auth_pam.c:

    debug("PAM: initializing for \"%s\"", user);
    sshpam_err =
        pam_start(SSHD_PAM_SERVICE, user, &store_conv, &sshpam_handle);
    sshpam_authctxt = authctxt;

And if you search (in the same file) for constant SSH_PAM_SERVICE you would see:

#if !defined(SSHD_PAM_SERVICE)
extern char *__progname;
# define SSHD_PAM_SERVICE       __progname
#endif

Next step is getting value of __progname. Let's grep the whole OpenSSH source code and ... wait:

ssh.c:  __progname = ssh_get_progname(av[0]);

As you may know, av[0] in C is the name of the binary. So, in my system, the service name will be sshd since this is the name of the OpenSSH daemon binary.

NOTE: I took some shortcuts because i ignore the content of ssh_get_progname()... but i think this small study is enough to illustrate my answer :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.