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 from stdin(3). only the first PAM_MAX_RESP_SIZE bytes 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: the log option is ignored. periodt.
  • quiet โ€” per default pam_exec.so will echo the exit status of the external command if it fails. specifying this option will suppress the message. shhh. ๐Ÿคซ
  • quiet_log โ€” per default pam_exec.so will 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 default pam_exec.so will 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 returned PAM_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_setcred was called, which does not execute the command. or, the value given for the type= 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 โœจ

pam.conf(5), pam.d(5), pam(8)


โœจ 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