PAM.CONF(5)

๐Ÿ’… PAM.CONF(5)

okay bestie, welcome to the Linux-PAM Manual โœจ this is section 5, the file-formats girlies. We're talking pam.conf, pam.d โ€” the config files that decide who gets in and who does not. ๐Ÿ’–


๐ŸŽ€ NAME ๐ŸŽ€

pam.conf, pam.d โ€” the PAM configuration files. that's it, that's the name. ๐Ÿ’…


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so when a PAM-aware privilege-granting application starts up, it activates its attachment to the PAM-API. that activation does a whole bunch of tasks, and the most important one is reading the configuration file(s): /etc/pam.conf. Alternatively and preferably, the config can be set by individual configuration files living in a pam.d directory. and here's the tea: the moment that directory exists, Linux-PAM will straight up ignore /etc/pam.conf. periodt. ๐Ÿซถ

these files list the PAMs that are gonna do the authentication tasks your service needs, plus how the PAM-API should behave when individual PAMs fail. ๐Ÿ˜ญ

the syntax of the /etc/pam.conf config file goes like this: the file is made up of a list of rules, and each rule is typically on a single line โ€” but it can be extended with an escaped end of line: \<LF>. comments are preceded with # marks and run all the way to the next end of line. ๐ŸŽ€

the format of each rule is a space-separated collection of tokens, and the first three are case-insensitive:

service type control module-path module-arguments

the syntax of files inside the /etc/pam.d/ directory is identical, except there's no service field. in that case the service is the name of the file in the /etc/pam.d/ directory. and that filename must be in lower case. no shouting in the directory, bestie. ๐Ÿ™ˆ

an important feature of PAM is that a number of rules can be stacked to combine the services of a number of PAMs for a given authentication task. stacking is iconic, we love her. ๐Ÿ‘‘

the service is typically the familiar name of the corresponding application: login and su are good examples. the service-name other is reserved for giving default rules. only lines that mention the current service (or, in the absence of such, the other entries) will be associated with the given service-application. โœจ

the type is the management group that the rule corresponds to. it's used to specify which of the management groups the subsequent module gets associated with. valid entries are:

  • account โ€” this module type performs non-authentication-based account management. it's typically used to restrict/permit access to a service based on the time of day, currently available system resources (like the maximum number of users), or maybe the location of the applicant user โ€” you know, root login only on the console energy. ๐Ÿ’…
  • auth โ€” this module type provides two aspects of authenticating the user. first, it establishes that the user is who they claim to be, by instructing the application to prompt the user for a password or other means of identification. second, the module can grant group membership or other privileges through its credential-granting properties. main character behaviour fr. โœจ
  • password โ€” this module type is required for updating the authentication token associated with the user. typically there's one module for each challenge/response-based authentication (auth) type. ๐ŸŽ€
  • session โ€” this module type is associated with doing things that need to be done for the user before/after they can be given service. such things include logging information concerning the opening/closing of some data exchange with a user, mounting directories, etc. ๐Ÿฆ‹
if the type value from that list above gets prepended with a - character, the PAM library will not log to the system log if it's not possible to load the module because it's missing in the system. this is useful especially for modules which aren't always installed on the system and aren't required for correct authentication and authorization of the login session. lowkey a lifesaver. ๐Ÿ˜Œ

the third field, control, indicates the behaviour of the PAM-API should the module fail to succeed in its authentication task. there are two types of syntax for this control field: the simple one has a single simple keyword, and the more complicated one involves a square-bracketed selection of value=action pairs. ๐Ÿซถ

for the simple (historical) syntax, valid control values are:

  • required โ€” failure of such a PAM will ultimately lead to the PAM-API returning failure, but only after the remaining stacked modules (for this service and type) have been invoked. she waits her turn, respectfully. ๐Ÿ’…
  • requisite โ€” like required, except in the case that such a module returns a failure, control is directly returned to the application or to the superior PAM stack. the return value is the one associated with the first required or requisite module to fail. note, this flag can be used to protect against the possibility of a user getting the opportunity to enter a password over an unsafe medium. it's conceivable that such behaviour might inform an attacker of valid accounts on a system. this possibility should be weighed against the not-insignificant concerns of exposing a sensitive password in a hostile environment. ๐Ÿ˜ญ
  • sufficient โ€” if such a module succeeds and no prior required module has failed, the PAM framework returns success to the application or to the superior PAM stack immediately, without calling any further modules in the stack. a failure of a sufficient module is ignored and processing of the PAM module stack continues unaffected. she said "not my problem" and moved on. ๐Ÿ™ˆ
  • optional โ€” the success or failure of this module is only important if it's the only module in the stack associated with this service+type. ๐Ÿ˜Œ
  • include โ€” include all lines of given type from the configuration file specified as an argument to this control. ๐ŸŽ€
  • substack โ€” include all lines of given type from the configuration file specified as an argument to this control. this differs from include in that evaluation of the done and die actions in a substack does not cause skipping the rest of the complete module stack โ€” only of the substack. jumps in a substack also can not make evaluation jump out of it, and the whole substack is counted as one module when the jump is done in a parent stack. the reset action will reset the state of a module stack to the state it was in as of the beginning of the substack evaluation. it's giving nested, but make it contained. ๐Ÿ’…

for the more complicated syntax, valid control values have this form:

[value1=action1 value2=action2 ...]

where valueN corresponds to the return code from the function invoked in the module for which the line is defined. it's selected from one of these: success, open_err, symbol_err, service_err, system_err, buf_err, perm_denied, auth_err, cred_insufficient, authinfo_unavail, user_unknown, maxtries, new_authtok_reqd, acct_expired, session_err, cred_unavail, cred_expired, cred_err, no_module_data, conv_err, authtok_err, authtok_recover_err, authtok_lock_busy, authtok_disable_aging, try_again, ignore, abort, authtok_expired, module_unknown, bad_item, conv_again, incomplete, and default. that's the whole roster, bestie, don't skip anyone. ๐ŸŒธ

the last of these, default, implies "all valueNs not mentioned explicitly". note, the full list of PAM errors is available in /usr/include/security/_pam_types.h. ๐Ÿ“‚

the actionN can take one of the following forms:

  • ignore โ€” when used with a stack of modules, the module's return status will not contribute to the return code the application obtains. she's just here for the vibes. ๐Ÿ’…
  • bad โ€” this action indicates that the return code should be thought of as indicative of the module failing. if this module is the first in the stack to fail, its status value will be used for that of the whole stack. this is the default action for all return codes. ๐Ÿ‘‘
  • die โ€” equivalent to bad, with the side effect of terminating the module stack and PAM immediately returning to the application. dramatic exit, we stan. ๐Ÿ’€
  • ok โ€” this tells PAM that the administrator thinks this return code should contribute directly to the return code of the full stack of modules. in other words, if the former state of the stack would lead to a return of PAM_SUCCESS, the module's return code will override this value. note, if the former state of the stack holds some value that's indicative of a modules failure, this ok value will not be used to override that value. ๐Ÿ˜ญ
  • done โ€” equivalent to ok, with the side effect of terminating the module stack and PAM immediately returning to the application, unless there was a non-ignored module failure before. ๐ŸŽ€
  • N (an unsigned integer) โ€” jump over the next N modules in the stack. note that N equal to 0 is not allowed, it would be treated as ignore in such case. the side effect depends on the PAM function call: for pam_authenticate, pam_acct_mgmt, pam_chauthtok, and pam_open_session it is ignore; for pam_setcred and pam_close_session it is one of ignore, ok, or bad depending on the module's return value. ๐Ÿฆ‹
  • reset โ€” clear all memory of the state of the module stack and start again with the next stacked module. factory reset energy. โœจ

if a return code's action isn't specifically defined via a valueN token, and the default value isn't specified, that return code's action defaults to bad. no cap. ๐Ÿ˜ญ

each of the four keywords โ€” required, requisite, sufficient, and optional โ€” has an equivalent expression in terms of the [...] syntax. they go like this:

  • required โ€” [success=ok new_authtok_reqd=ok ignore=ignore default=bad]
  • requisite โ€” [success=ok new_authtok_reqd=ok ignore=ignore default=die]
  • sufficient โ€” [success=done new_authtok_reqd=done default=ignore]
  • optional โ€” [success=ok new_authtok_reqd=ok default=ignore]

module-path is either the full filename of the PAM to be used by the application (it begins with a /), or a relative pathname from the default module location: /lib/security/ or /lib64/security/, depending on the architecture. ๐Ÿงš

module-arguments are a space-separated list of tokens that can be used to modify the specific behaviour of the given PAM. such arguments will be documented for each individual module. note, if you wish to include spaces in an argument, you should surround that argument with square brackets. like so, bestie:

squid auth required pam_mysql.so user=passwd_query passwd=mada \
      db=eminence [query=select user_name from internet_service \
      where user_name='%u' and password=PASSWORD('%p') and \
    service='web_proxy']

when you're using this convention, you can include [ characters inside the string. and if you wish to include a ] character inside the string that will survive the argument parsing, you should use \]. in other words:

[..[..\]..]    -->   ..[..]..
any line in (one of) the configuration file(s) that is not formatted correctly will generally tend โ€” erring on the side of caution โ€” to make the authentication process fail. a corresponding error is written to the system log files with a call to syslog(3). so like. don't be sloppy with your syntax, it's literally not the vibe. ๐Ÿ’€

okay so here's the โœจglow-upโœจ version of configuring PAM โ€” the whole pam.d directory situation, which is so much more flexible than that one single lonely config file. Instead of cramming everything into one file, you configure libpam by filling up the pam.d directories with files. Each file's name is literally equal to a service-name (in lower-case, bestie, don't get cute with it) โ€” and that file becomes the personal, bespoke configuration file for that named service. It's giving custom fit, tailored, main character energy. ๐Ÿ’…


and here's the vendor tea โ˜• โ€” vendor-supplied PAM configuration files might be installed in the system directory /usr/lib/pam.d/, or in a configurable vendor specific directory, instead of the machine configuration directory /etc/pam.d/. If no machine configuration file is found, the vendor-supplied file gets used. And every single file in /etc/pam.d/ overrides files with the same name in other directories. Your machine's files run the group chat, periodt. ๐Ÿ‘‘

The syntax of each file in pam.d is similar to that of the /etc/pam.conf file, and it's made up of lines that look exactly like this:

type  control  module-path  module-arguments

The only difference? The service-name is not present. The service-name is, of course, the name of the given configuration file itself. For example, /etc/pam.d/login contains the configuration for the login service. no cap, that's the whole trick ๐ŸŽ€


โœจ FILES โœจ ๐Ÿฆ‹

  • /etc/pam.conf โ€” the configuration file ๐ŸŒธ
  • /etc/pam.d โ€” the Linux-PAM configuration directory. Generally, if this directory is present, the /etc/pam.conf file is ignored. ๐Ÿ’€
  • /usr/lib/pam.d โ€” the Linux-PAM vendor configuration directory. Files in /etc/pam.d override files with the same name in this directory. ๐Ÿ”ฅ

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

like, go read those too, i'm literally begging ๐Ÿซถ


okay bestie that's the whole page, you ate that ๐Ÿ’– This was Linux-PAM, dated 09/27/2026, filed under PAM.CONF(5) โ€” iconic behavior honestly, obsessed with her โœจ๐Ÿงšโ€โ™€๏ธ๐Ÿ’œ

๐Ÿ“ฆ where this page comes from