pam.conf.5 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. '\" t
  2. .\" Title: pam.conf
  3. .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
  5. .\" Date: 09/03/2021
  6. .\" Manual: Linux-PAM Manual
  7. .\" Source: Linux-PAM Manual
  8. .\" Language: English
  9. .\"
  10. .TH "PAM\&.CONF" "5" "09/03/2021" "Linux-PAM Manual" "Linux-PAM Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. pam.conf, pam.d \- PAM configuration files
  32. .SH "DESCRIPTION"
  33. .PP
  34. When a
  35. \fIPAM\fR
  36. aware privilege granting application is started, it activates its attachment to the PAM\-API\&. This activation performs a number of tasks, the most important being the reading of the configuration file(s):
  37. /etc/pam\&.conf\&. Alternatively, this may be the contents of the
  38. /etc/pam\&.d/
  39. directory\&. The presence of this directory will cause Linux\-PAM to ignore
  40. /etc/pam\&.conf\&.
  41. .PP
  42. These files list the
  43. \fIPAM\fRs that will do the authentication tasks required by this service, and the appropriate behavior of the PAM\-API in the event that individual
  44. \fIPAM\fRs fail\&.
  45. .PP
  46. The syntax of the
  47. /etc/pam\&.conf
  48. configuration file is as follows\&. The file is made up of a list of rules, each rule is typically placed on a single line, but may be extended with an escaped end of line: `\e<LF>\*(Aq\&. Comments are preceded with `#\*(Aq marks and extend to the next end of line\&.
  49. .PP
  50. The format of each rule is a space separated collection of tokens, the first three being case\-insensitive:
  51. .PP
  52. \fB service type control module\-path module\-arguments\fR
  53. .PP
  54. The syntax of files contained in the
  55. /etc/pam\&.d/
  56. directory, are identical except for the absence of any
  57. \fIservice\fR
  58. field\&. In this case, the
  59. \fIservice\fR
  60. is the name of the file in the
  61. /etc/pam\&.d/
  62. directory\&. This filename must be in lower case\&.
  63. .PP
  64. An important feature of
  65. \fIPAM\fR, is that a number of rules may be
  66. \fIstacked\fR
  67. to combine the services of a number of PAMs for a given authentication task\&.
  68. .PP
  69. The
  70. \fIservice\fR
  71. is typically the familiar name of the corresponding application:
  72. \fIlogin\fR
  73. and
  74. \fIsu\fR
  75. are good examples\&. The
  76. \fIservice\fR\-name,
  77. \fIother\fR, is reserved for giving
  78. \fIdefault\fR
  79. rules\&. Only lines that mention the current service (or in the absence of such, the
  80. \fIother\fR
  81. entries) will be associated with the given service\-application\&.
  82. .PP
  83. The
  84. \fItype\fR
  85. is the management group that the rule corresponds to\&. It is used to specify which of the management groups the subsequent module is to be associated with\&. Valid entries are:
  86. .PP
  87. account
  88. .RS 4
  89. this module type performs non\-authentication based account management\&. It is typically used to restrict/permit access to a service based on the time of day, currently available system resources (maximum number of users) or perhaps the location of the applicant user \-\- \*(Aqroot\*(Aq login only on the console\&.
  90. .RE
  91. .PP
  92. auth
  93. .RS 4
  94. this module type provides two aspects of authenticating the user\&. Firstly, 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\&. Secondly, the module can grant group membership or other privileges through its credential granting properties\&.
  95. .RE
  96. .PP
  97. password
  98. .RS 4
  99. this module type is required for updating the authentication token associated with the user\&. Typically, there is one module for each \*(Aqchallenge/response\*(Aq based authentication (auth) type\&.
  100. .RE
  101. .PP
  102. session
  103. .RS 4
  104. 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 the logging of information concerning the opening/closing of some data exchange with a user, mounting directories, etc\&.
  105. .RE
  106. .PP
  107. If the
  108. \fItype\fR
  109. value from the list above is prepended with a
  110. \fI\-\fR
  111. character the PAM library will not log to the system log if it is not possible to load the module because it is missing in the system\&. This can be useful especially for modules which are not always installed on the system and are not required for correct authentication and authorization of the login session\&.
  112. .PP
  113. The third field,
  114. \fIcontrol\fR, indicates the behavior 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; the more complicated one involves a square\-bracketed selection of
  115. \fIvalue=action\fR
  116. pairs\&.
  117. .PP
  118. For the simple (historical) syntax valid
  119. \fIcontrol\fR
  120. values are:
  121. .PP
  122. required
  123. .RS 4
  124. failure of such a PAM will ultimately lead to the PAM\-API returning failure but only after the remaining
  125. \fIstacked\fR
  126. modules (for this
  127. \fIservice\fR
  128. and
  129. \fItype\fR) have been invoked\&.
  130. .RE
  131. .PP
  132. requisite
  133. .RS 4
  134. like
  135. \fIrequired\fR, however, 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 that 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 is conceivable that such behavior 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\&.
  136. .RE
  137. .PP
  138. sufficient
  139. .RS 4
  140. if such a module succeeds and no prior
  141. \fIrequired\fR
  142. 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
  143. \fIsufficient\fR
  144. module is ignored and processing of the PAM module stack continues unaffected\&.
  145. .RE
  146. .PP
  147. optional
  148. .RS 4
  149. the success or failure of this module is only important if it is the only module in the stack associated with this
  150. \fIservice\fR+\fItype\fR\&.
  151. .RE
  152. .PP
  153. include
  154. .RS 4
  155. include all lines of given type from the configuration file specified as an argument to this control\&.
  156. .RE
  157. .PP
  158. substack
  159. .RS 4
  160. include all lines of given type from the configuration file specified as an argument to this control\&. This differs from
  161. \fIinclude\fR
  162. in that evaluation of the
  163. \fIdone\fR
  164. and
  165. \fIdie\fR
  166. actions in a substack does not cause skipping the rest of the complete module stack, but 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
  167. \fIreset\fR
  168. action will reset the state of a module stack to the state it was in as of beginning of the substack evaluation\&.
  169. .RE
  170. .PP
  171. For the more complicated syntax valid
  172. \fIcontrol\fR
  173. values have the following form:
  174. .sp
  175. .if n \{\
  176. .RS 4
  177. .\}
  178. .nf
  179. [value1=action1 value2=action2 \&.\&.\&.]
  180. .fi
  181. .if n \{\
  182. .RE
  183. .\}
  184. .PP
  185. Where
  186. \fIvalueN\fR
  187. corresponds to the return code from the function invoked in the module for which the line is defined\&. It is selected from one of these:
  188. \fIsuccess\fR,
  189. \fIopen_err\fR,
  190. \fIsymbol_err\fR,
  191. \fIservice_err\fR,
  192. \fIsystem_err\fR,
  193. \fIbuf_err\fR,
  194. \fIperm_denied\fR,
  195. \fIauth_err\fR,
  196. \fIcred_insufficient\fR,
  197. \fIauthinfo_unavail\fR,
  198. \fIuser_unknown\fR,
  199. \fImaxtries\fR,
  200. \fInew_authtok_reqd\fR,
  201. \fIacct_expired\fR,
  202. \fIsession_err\fR,
  203. \fIcred_unavail\fR,
  204. \fIcred_expired\fR,
  205. \fIcred_err\fR,
  206. \fIno_module_data\fR,
  207. \fIconv_err\fR,
  208. \fIauthtok_err\fR,
  209. \fIauthtok_recover_err\fR,
  210. \fIauthtok_lock_busy\fR,
  211. \fIauthtok_disable_aging\fR,
  212. \fItry_again\fR,
  213. \fIignore\fR,
  214. \fIabort\fR,
  215. \fIauthtok_expired\fR,
  216. \fImodule_unknown\fR,
  217. \fIbad_item\fR,
  218. \fIconv_again\fR,
  219. \fIincomplete\fR, and
  220. \fIdefault\fR\&.
  221. .PP
  222. The last of these,
  223. \fIdefault\fR, implies \*(Aqall
  224. \fIvalueN\fR\*(Aqs not mentioned explicitly\&. Note, the full list of PAM errors is available in
  225. /usr/include/security/_pam_types\&.h\&. The
  226. \fIactionN\fR
  227. can take one of the following forms:
  228. .PP
  229. ignore
  230. .RS 4
  231. when used with a stack of modules, the module\*(Aqs return status will not contribute to the return code the application obtains\&.
  232. .RE
  233. .PP
  234. bad
  235. .RS 4
  236. 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\&.
  237. .RE
  238. .PP
  239. die
  240. .RS 4
  241. equivalent to
  242. \fIbad\fR
  243. with the side effect of terminating the module stack and PAM immediately returning to the application\&.
  244. .RE
  245. .PP
  246. ok
  247. .RS 4
  248. 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
  249. \fIPAM_SUCCESS\fR, the module\*(Aqs return code will override this value\&. Note, if the former state of the stack holds some value that is indicative of a modules failure, this \*(Aqok\*(Aq value will not be used to override that value\&.
  250. .RE
  251. .PP
  252. done
  253. .RS 4
  254. equivalent to
  255. \fIok\fR
  256. 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\&.
  257. .RE
  258. .PP
  259. N (an unsigned integer)
  260. .RS 4
  261. jump over the next N modules in the stack\&. Note that N equal to 0 is not allowed, it would be treated as
  262. \fIignore\fR
  263. in such case\&. The side effect depends on the PAM function call: for
  264. \fIpam_authenticate\fR,
  265. \fIpam_acct_mgmt\fR,
  266. \fIpam_chauthtok\fR, and
  267. \fIpam_open_session\fR
  268. it is
  269. \fIignore\fR; for
  270. \fIpam_setcred\fR
  271. and
  272. \fIpam_close_session\fR
  273. it is one of
  274. \fIignore\fR,
  275. \fIok\fR, or
  276. \fIbad\fR
  277. depending on the module\*(Aqs return value\&.
  278. .RE
  279. .PP
  280. reset
  281. .RS 4
  282. clear all memory of the state of the module stack and start again with the next stacked module\&.
  283. .RE
  284. .PP
  285. If a return code\*(Aqs action is not specifically defined via a
  286. \fIvalueN\fR
  287. token, and the
  288. \fIdefault\fR
  289. value is not specified, that return code\*(Aqs action defaults to
  290. \fIbad\fR\&.
  291. .PP
  292. Each of the four keywords: required; requisite; sufficient; and optional, have an equivalent expression in terms of the [\&.\&.\&.] syntax\&. They are as follows:
  293. .PP
  294. required
  295. .RS 4
  296. [success=ok new_authtok_reqd=ok ignore=ignore default=bad]
  297. .RE
  298. .PP
  299. requisite
  300. .RS 4
  301. [success=ok new_authtok_reqd=ok ignore=ignore default=die]
  302. .RE
  303. .PP
  304. sufficient
  305. .RS 4
  306. [success=done new_authtok_reqd=done default=ignore]
  307. .RE
  308. .PP
  309. optional
  310. .RS 4
  311. [success=ok new_authtok_reqd=ok default=ignore]
  312. .RE
  313. .PP
  314. \fImodule\-path\fR
  315. is either the full filename of the PAM to be used by the application (it begins with a \*(Aq/\*(Aq), or a relative pathname from the default module location:
  316. /lib/security/
  317. or
  318. /lib64/security/, depending on the architecture\&.
  319. .PP
  320. \fImodule\-arguments\fR
  321. are a space separated list of tokens that can be used to modify the specific behavior 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\&.
  322. .sp
  323. .if n \{\
  324. .RS 4
  325. .\}
  326. .nf
  327. squid auth required pam_mysql\&.so user=passwd_query passwd=mada \e
  328. db=eminence [query=select user_name from internet_service \e
  329. where user_name=\*(Aq%u\*(Aq and password=PASSWORD(\*(Aq%p\*(Aq) and \e
  330. service=\*(Aqweb_proxy\*(Aq]
  331. .fi
  332. .if n \{\
  333. .RE
  334. .\}
  335. .PP
  336. When using this convention, you can include `[\*(Aq characters inside the string, and if you wish to include a `]\*(Aq character inside the string that will survive the argument parsing, you should use `\e]\*(Aq\&. In other words:
  337. .sp
  338. .if n \{\
  339. .RS 4
  340. .\}
  341. .nf
  342. [\&.\&.[\&.\&.\e]\&.\&.] \-\-> \&.\&.[\&.\&.]\&.\&.
  343. .fi
  344. .if n \{\
  345. .RE
  346. .\}
  347. .PP
  348. 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
  349. \fBsyslog\fR(3)\&.
  350. .PP
  351. More flexible than the single configuration file is it to configure libpam via the contents of the
  352. /etc/pam\&.d/
  353. directory\&. In this case the directory is filled with files each of which has a filename equal to a service\-name (in lower\-case): it is the personal configuration file for the named service\&.
  354. .PP
  355. The syntax of each file in /etc/pam\&.d/ is similar to that of the
  356. /etc/pam\&.conf
  357. file and is made up of lines of the following form:
  358. .sp
  359. .if n \{\
  360. .RS 4
  361. .\}
  362. .nf
  363. type control module\-path module\-arguments
  364. .fi
  365. .if n \{\
  366. .RE
  367. .\}
  368. .PP
  369. The only difference being that the service\-name is not present\&. The service\-name is of course the name of the given configuration file\&. For example,
  370. /etc/pam\&.d/login
  371. contains the configuration for the
  372. \fBlogin\fR
  373. service\&.
  374. .SH "SEE ALSO"
  375. .PP
  376. \fBpam\fR(3),
  377. \fBPAM\fR(8),
  378. \fBpam_start\fR(3)