PAM_SET_ITEM(3)
π PAM_SET_ITEM(3) β set and update PAM information
okay so this is from the Linux-PAM Manual, and bestie, it's the pam_set_item page π it's literally the function that lets you peek at and rewrite the little info tags the PAM stack carries around. lowkey iconic.
β¨ NAME β¨
pam_set_item β set and update PAM information π
πΈ SYNOPSIS πΈ
#include <security/pam_modules.h>
int pam_set_item(pam_handle_t *pamh, int item_type, const void *item);
π¦ DESCRIPTION π¦
So pam_set_item is the function that lets applications and PAM service modules access and update PAM information of item_type. π«Ά The way it works: a copy of the object pointed to by the item argument gets created. (yes, a copy, not a "here take my pointer" situation, slay for safety π
)
Here are all the item_types it supports, no cap, every single one:
PAM_SERVICEβ the service name, i.e. the thing that identifies which PAM stack the PAM functions will use to authenticate the program. main character energy for the whole stack tbh πPAM_USERβ the username of the entity under whose identity the service will be given. like, after authentication,PAM_USERidentifies the local entity that gets to use the service. β οΈ heads up though: this value can get mapped from something (eg.,"anonymous") to something else (eg."guest119") by any module in the PAM stack. so an application should literally consult the value ofPAM_USERafter each call to a PAM function. fr fr, don't cache it and ghost it πPAM_USER_PROMPTβ the string used when prompting for a user's name. default value is a localized version of"login: ". cute πPAM_TTYβ the terminal name prefixed by/dev/for device files. ngl, back in the day graphical X-based applications used to store the$DISPLAYvariable here, but with the introduction ofPAM_XDISPLAYthat usage is deprecated. it's giving legacy π«PAM_RUSERβ the requesting user name: a local name for a locally requesting user, or a remote user name for a remote requesting user.- generally an application or module will attempt to supply the value that is most strongly authenticated (a local account before a remote one). the level of trust in this value is embodied in the actual authentication stack associated with the application, so it's ultimately at the discretion of the system administrator. π§
PAM_RUSER@PAM_RHOSTshould always identify the requesting user. in some cases,PAM_RUSERmay beNULL. in such situations, it is unclear who the requesting entity is. π mystery user, we don't know her
PAM_RHOSTβ the requesting hostname (the hostname of the machine from which thePAM_RUSERentity is requesting service). that is,PAM_RUSER@PAM_RHOSTdoes identify the requesting user. in some applications,PAM_RHOSTmay beNULL. in such situations, it is unclear where the authentication request is originating from. πPAM_AUTHTOKβ the authentication token (often a password). π₯ this token should be ignored by all module functions besidespam_sm_authenticate(3)andpam_sm_chauthtok(3). in the former function it's used to pass the most recent authentication token from one stacked module to another. in the latter function the token is used for another purpose β it contains the currently active authentication token.PAM_OLDAUTHTOKβ the old authentication token. this token should be ignored by all module functions exceptpam_sm_chauthtok(3). periodt.PAM_CONVβ thepam_convstructure. seepam_conv(3). π
π the Linux-PAM exclusives (iykyk)
the following additional items are specific to Linux-PAM and should not be used in portable applications:
PAM_FAIL_DELAYβ a function pointer to redirect centrally managed failure delays. seepam_fail_delay(3).PAM_XDISPLAYβ the name of the X display. for graphical, X-based applications the value for this item should be the$DISPLAYvariable. this value may be used independently ofPAM_TTYfor passing the name of the display. β¨PAM_XAUTHDATAβ a pointer to a structure containing the X authentication data required to make a connection to the display specified byPAM_XDISPLAY, if such information is necessary. seepam_xauth_data(3).PAM_AUTHTOK_TYPEβ the default action is for the module to use the following prompts when requesting passwords:"New UNIX password: "and"Retype UNIX password: ". the example wordUNIXcan be replaced with this item, and by default it is empty. this item is used bypam_get_authtok(3). π
β what even is item, though
for all item_types, other than PAM_CONV and PAM_FAIL_DELAY, item is a pointer to a <NUL> terminated character string. π
in the case of PAM_CONV, item points to an initialized pam_conv structure.
in the case of PAM_FAIL_DELAY, item is a function pointer:
void (*delay_fn)(int retval, unsigned usec_delay, void *appdata_ptr)
π big mood warning: bothPAM_AUTHTOKandPAM_OLDAUTHTOKwill be reset before returning to the application. which means an application is literally not able to access the authentication tokens. no cap, they're gone. π«Ά
π₯ RETURN VALUES π₯
PAM_BAD_ITEMβ the application attempted to set an undefined or inaccessible item. π«PAM_BUF_ERRβ memory buffer error. πPAM_SUCCESSβ data was successful updated. β slayPAM_SYSTEM_ERRβ thepam_handle_tpassed as first argument was invalid. π invalid handle, not the vibe
π SEE ALSO π
okay that's the whole page bestie, you ate that π β¨ this lil love letter to you came from Linux-PAM, dated 07/08/2026 β go forth and set those items, mwah ππ¦π
π¦ 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