PAM_SETCRED(3)
β¨ PAM_SETCRED(3) β¨
okay bestie, we're in the Linux-PAM Manual today and this one's about credentials β literally the stuff that makes you you on a system π
π NAME π
pam_setcred β establish / delete user credentials
πΈ SYNOPSIS πΈ
#include <security/pam_appl.h>
int pam_setcred(pam_handle_t *pamh, int flags);
π¦ DESCRIPTION π¦
So the pam_setcred function is the one you call to establish, maintain and delete the credentials of a user, fr fr. Like, here's the timeline bestie: the user gets authenticated, then you set their credentials, and then a session is opened for them (with pam_open_session(3)). And when the session is closed (with pam_close_session(3)), the credentials get deleted after that. Order matters, no cap π«Ά
And what even is a credential? Great question. A credential is something the user possesses β like some property of theirs, e.g. a Kerberos ticket, or a supplementary group membership, that makes up the uniqueness of a given user. Iconic user-specific vibes β¨
On a Linux system the user's UID and GID's are credentials too. BUT (and this is the plot twist π) it's been decided that these properties β along with the default supplementary groups the user is a member of β are credentials that should be set directly by the application and not by PAM. So those ones should be established by the application prior to a call to this function. Like, initgroups(2) (or equivalent) should already have been performed by then. Do not skip this step bestie π
Now the valid flags β any one of which may be logically OR'd with PAM_SILENT β are:
PAM_ESTABLISH_CREDβ Initialize the credentials for the user.PAM_DELETE_CREDβ Delete the user's credentials.PAM_REINITIALIZE_CREDβ Fully reinitialize the user's credentials.PAM_REFRESH_CREDβ Extend the lifetime of the existing credentials.
π RETURN VALUES π
PAM_BUF_ERRβ Memory buffer error πPAM_CRED_ERRβ Failed to set user credentials.PAM_CRED_EXPIREDβ User credentials are expired (the tragedy).PAM_CRED_UNAVAILβ Failed to retrieve user credentials.PAM_SUCCESSβ Data was successful stored. slay β¨PAM_SYSTEM_ERRβ ANULLpointer was submitted as PAM handle, the function was called by a module, or another system error occurred. messy πPAM_USER_UNKNOWNβ User is not known to an authentication module.
π SEE ALSO π
pam_authenticate(3), pam_open_session(3), pam_close_session(3), pam_strerror(3)
heads up bestie: credentials get set after auth and before the session opens, deleted after the session closes, and the UID/GID/group stuff is the application's job, not PAM's. iykyk π
okay that's the whole page and honestly? ate. this was Linux-PAM, dated 07/08/2026 β go forth and set those creds, main character ππ¦π
π¦ where this page comes from
- fedora 44: pam-devel 1.7.2-2.fc44 Β· BSD-3-Clause AND GPL-2.0-or-later
- fedora 44: pam-devel 1.7.2-2.fc44 Β· BSD-3-Clause AND GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms