PAM_ENV(8)

โœจ PAM_ENV ๐Ÿ’–

okay bestie, this is a page from the Linux-PAM Manual โ€” it's the pam_env(8) situation and it's literally the module that handles your environment variables. sit with me, we're doing this together ๐Ÿซถ


๐ŸŒธ NAME ๐ŸŒธ

pam_env โ€” the PAM module that sets and unsets environment variables. that's the whole job. iconic, honestly.


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

pam_env.so [debug] [conffile=conf-file] [envfile=env-file] [readenv=0|1]
           [user_envfile=env-file] [user_readenv=0|1]

๐Ÿ’… DESCRIPTION ๐Ÿ’…

so the pam_env PAM module is the one that lets you (un)set environment variables. and yes, it supports using variables that were already set, plus PAM_ITEMs like PAM_RHOST. it's giving resourceful ๐Ÿ’โ™€๏ธ

By default, the rules for (un)setting variables come from the config file /etc/security/pam_env.conf. wanna use a different one? the conffile option has you covered, no cap.

Second thing it does: it reads a file (/etc/environment by default) full of simple KEY=VAL pairs, each one on its own separate line. the envfile option lets you point at a different file, and the readenv option lets you shut this whole thing off completely.

Third: it reads a user configuration file ($HOME/.pam_environment by default). you can swap that default out with the user_envfile option, and you can turn it on and off with user_readenv.

โš ๏ธ okay so real talk โ€” because setting PAM environment variables can have side effects on other modules, this module should be the last one on the stack. periodt.

also super important: this module only actually runs if the main application calls pam_setcred(3) or pam_open_session(3). if it gets called by pam_authenticate(3), it does nothing and just returns PAM_IGNORE. it's literally minding its own business ๐Ÿ˜Œ


โœจ OPTIONS โœจ

  • conffile=/path/to/pam_env.conf โ€” point at an alternate pam_env.conf-style configuration file to override the default. lowkey so useful when different services need different environments.
  • debug โ€” prints a lot of debug information via syslog(3). it's giving chatty ๐Ÿ’ฌ
  • envfile=/path/to/environment โ€” point at an alternate environment file to override the default. the syntax is simple KEY=VAL pairs on separate lines. the export instruction can be specified for bash compatibility, but heads up โ€” it will be ignored. again, great for when different services need different environments.
  • readenv=0|1 โ€” turns the reading of the file specified by envfile on or off (0 is off, 1 is on). by default this option is on.
  • user_envfile=filename โ€” point at an alternate .pam_environment file to override the default. same syntax as /etc/security/pam_env.conf. the filename is relative to the user home directory. yes bestie, different services, different environments, you know the vibe.
  • user_readenv=0|1 โ€” turns the reading of the user specific environment file on or off. 0 is off, 1 is on. by default this option is off, because user supplied environment variables in the PAM environment could affect the behavior of subsequent modules in the stack without the consent of the system administrator. and likeโ€ฆ yeah. ๐Ÿ˜ญ
๐Ÿšจ okay serious moment: due to problematic security, user_readenv functionality is deprecated since the 1.5.0 version and will be removed completely at some point in the future. don't build your whole personality around it, bestie.

๐ŸŒˆ MODULE TYPES PROVIDED ๐ŸŒˆ

The auth and session module types are provided. that's it, that's the list ๐ŸŽ€


๐Ÿฆ‹ RETURN VALUES ๐Ÿฆ‹

  • PAM_ABORT โ€” not all relevant data or options could be gotten. it's giving incomplete info ๐Ÿ’€
  • PAM_BUF_ERR โ€” memory buffer error. oop.
  • PAM_IGNORE โ€” no pam_env.conf and environment file was found, or the module got called by pam_authenticate(3).
  • PAM_SUCCESS โ€” environment variables were set. slay! โœจ

๐Ÿ“ FILES ๐Ÿ“

  • /etc/security/pam_env.conf โ€” default configuration file
  • /etc/environment โ€” default environment file
  • $HOME/.pam_environment โ€” user specific environment file

๐Ÿ’œ SEE ALSO ๐Ÿ’œ

pam_env.conf(5), pam.d(5), pam(8), environ(7).


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

pam_env was written by Dave Kinchlea <kinch@kinch.ark.com>. king behavior, we love to see it ๐Ÿ’–


and that's the whole page bestie!! this was the pam_env(8) manual from Linux-PAM, dated 09/27/2026 โ€” tysm for reading, go forth and configure responsibly ๐Ÿงš โœจ ๐ŸŒธ

๐Ÿ“ฆ where this page comes from