PAM_EXEC(8)
๐ PAM_EXEC โ the manual page bestie (pam_exec, from the Linux-PAM Manual)
okay so. you clicked on pam_exec(8). iconic of you. let's get into it ๐
โจ NAME โจ
pam_exec โ a PAM module which calls an external command. that's it. that's the whole vibe. it runs a command for you. ๐ซถ
โจ SYNOPSIS โจ
pam_exec.so [debug] [expose_authtok] [seteuid] [quiet] [quiet_log]
[stdout] [log=file] [type=type] command [...]
โจ DESCRIPTION โจ
so pam_exec is a PAM module that can be used to run an external command. literally its whole personality. ๐
the child's environment is set to the current PAM environment list, as returned by pam_getenvlist(3). and on top of that, these PAM items get exported as environment variables: PAM_RHOST, PAM_RUSER, PAM_SERVICE, PAM_TTY, PAM_USER and PAM_TYPE โ and PAM_TYPE holds one of the module types: account, auth, password, open_session and close_session. slay, all the deets are right there. ๐
โ ๏ธ real talk though: commands called by pam_exec need to be aware of that the user can have control over the environment. not me warning you, the manpage is warning you. ๐
โจ OPTIONS โจ
debugโ print debug information. for when you need to see everything. ๐expose_authtokโ during authentication and password change, the calling command can read the password fromstdin(3). only the firstPAM_MAX_RESP_SIZEbytes of a password are provided to the command. that's the cap, bestie, don't ask for more.log=fileโ the output of the command is appended to file. it appends, it does not overwrite. ๐type=typeโ only run the command if the module type matches the given type. very "you have to match my energy" of it.stdoutโ per default the output of the executed command is written to/dev/null(bye ๐). with this option, the stdout output of the executed command is redirected to the calling application. it's in the responsibility of this application what happens with the output. also: thelogoption is ignored. periodt.quietโ per defaultpam_exec.sowill echo the exit status of the external command if it fails. specifying this option will suppress the message. shhh. ๐คซquiet_logโ per defaultpam_exec.sowill log the exit status of the external command if it fails. specifying this option will suppress the log message. also shhh, but for the log file this time. ๐seteuidโ per defaultpam_exec.sowill execute the external command with the real user ID of the calling process. specifying this option means the command is run with the effective user ID. read that twice, it matters. ๐ฅ
โจ MODULE TYPES PROVIDED โจ
all of them. auth, account, password and session. the whole squad is here. ๐
โจ RETURN VALUES โจ
PAM_SUCCESSโ the external command was run successfully. we love a happy ending. ๐PAM_BUF_ERRโ memory buffer error. ๐ญPAM_CONV_ERRโ the conversation method supplied by the application failed to obtain the username. it's giving "couldn't get their name". ๐PAM_INCOMPLETEโ the conversation method supplied by the application returnedPAM_CONV_AGAIN.PAM_SERVICE_ERRโ no argument or a wrong number of arguments were given. bestie, you gotta pass the args. ๐คPAM_SYSTEM_ERRโ a system error occurred or the command to execute failed.PAM_IGNOREโpam_setcredwas called, which does not execute the command. or, the value given for thetype=parameter did not match the module type. either way, we're not doing anything today. ๐
โจ EXAMPLES โจ
add the following line to /etc/pam.d/passwd to rebuild the NIS database after each local password change:
password optional pam_exec.so seteuid /usr/bin/make -C /var/yp
this will execute the command
make -C /var/yp
with effective user ID. yup, that's the seteuid doing its thing. ๐ฅ
โจ SEE ALSO โจ
โจ AUTHOR โจ
pam_exec was written by Thorsten Kukuk <kukuk@thkukuk.de> and Josh Triplett <josh@joshtriplett.org>. absolute legends, we stan. ๐
and that's the whole page, bestie!! ๐ this came to you from the Linux-PAM crew, dated 09/27/2026 โ so like, keep that version in mind, okay? go run your little external commands. slay. ๐ฆ๐
โจ
๐ฆ where this page comes from
- arch rolling: pam 1.7.3-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms