pam.conf-syntax.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
  4. <section id='pam.conf-syntax'>
  5. <para>
  6. The syntax of the <filename>/etc/pam.conf</filename>
  7. configuration file is as follows. The file is made up of a list
  8. of rules, each rule is typically placed on a single line,
  9. but may be extended with an escaped end of line: `\&lt;LF&gt;'.
  10. Comments are preceded with `#' marks and extend to the next end of
  11. line.
  12. </para>
  13. <para>
  14. The format of each rule is a space separated collection of tokens,
  15. the first three being case-insensitive:
  16. </para>
  17. <para>
  18. <emphasis remap='B'> service type control module-path module-arguments</emphasis>
  19. </para>
  20. <para>
  21. The syntax of files contained in the <filename>/etc/pam.d/</filename>
  22. directory, are identical except for the absence of any
  23. <emphasis>service</emphasis> field. In this case, the
  24. <emphasis>service</emphasis> is the name of the file in the
  25. <filename>/etc/pam.d/</filename> directory. This filename must be
  26. in lower case.
  27. </para>
  28. <para>
  29. An important feature of <emphasis>PAM</emphasis>, is that a
  30. number of rules may be <emphasis>stacked</emphasis> to combine
  31. the services of a number of PAMs for a given authentication task.
  32. </para>
  33. <para>
  34. The <emphasis>service</emphasis> is typically the familiar name of
  35. the corresponding application: <emphasis>login</emphasis> and
  36. <emphasis>su</emphasis> are good examples. The
  37. <emphasis>service</emphasis>-name, <emphasis>other</emphasis>,
  38. is reserved for giving <emphasis>default</emphasis> rules.
  39. Only lines that mention the current service (or in the absence
  40. of such, the <emphasis>other</emphasis> entries) will be associated
  41. with the given service-application.
  42. </para>
  43. <para>
  44. The <emphasis>type</emphasis> is the management group that the rule
  45. corresponds to. It is used to specify which of the management groups
  46. the subsequent module is to be associated with. Valid entries are:
  47. </para>
  48. <variablelist>
  49. <varlistentry>
  50. <term>account</term>
  51. <listitem>
  52. <para>
  53. this module type performs non-authentication based account
  54. management. It is typically used to restrict/permit access
  55. to a service based on the time of day, currently available
  56. system resources (maximum number of users) or perhaps the
  57. location of the applicant user -- 'root' login only on the
  58. console.
  59. </para>
  60. </listitem>
  61. </varlistentry>
  62. <varlistentry>
  63. <term>auth</term>
  64. <listitem>
  65. <para>
  66. this module type provides two aspects of authenticating
  67. the user. Firstly, it establishes that the user is who they
  68. claim to be, by instructing the application to prompt the user
  69. for a password or other means of identification. Secondly, the
  70. module can grant group membership or other privileges through
  71. its credential granting properties.
  72. </para>
  73. </listitem>
  74. </varlistentry>
  75. <varlistentry>
  76. <term>password</term>
  77. <listitem>
  78. <para>
  79. this module type is required for updating the authentication
  80. token associated with the user. Typically, there is one module
  81. for each 'challenge/response' based authentication (auth) type.
  82. </para>
  83. </listitem>
  84. </varlistentry>
  85. <varlistentry>
  86. <term>session</term>
  87. <listitem>
  88. <para>
  89. this module type is associated with doing things that need to
  90. be done for the user before/after they can be given service.
  91. Such things include the logging of information concerning the
  92. opening/closing of some data exchange with a user, mounting
  93. directories, etc.
  94. </para>
  95. </listitem>
  96. </varlistentry>
  97. </variablelist>
  98. <para>
  99. If the <emphasis>type</emphasis> value from the list above is prepended
  100. with a <emphasis>-</emphasis> character the PAM library will not log to
  101. the system log if it is not possible to load the module because it is
  102. missing in the system. This can be useful especially for modules which
  103. are not always installed on the system and are not required for correct
  104. authentication and authorization of the login session.
  105. </para>
  106. <para>
  107. The third field, <emphasis>control</emphasis>, indicates the
  108. behavior of the PAM-API should the module fail to succeed in its
  109. authentication task. There are two types of syntax for this control
  110. field: the simple one has a single simple keyword; the more
  111. complicated one involves a square-bracketed selection of
  112. <emphasis>value=action</emphasis> pairs.
  113. </para>
  114. <para>
  115. For the simple (historical) syntax valid <emphasis>control</emphasis>
  116. values are:
  117. </para>
  118. <variablelist>
  119. <varlistentry>
  120. <term>required</term>
  121. <listitem>
  122. <para>
  123. failure of such a PAM will ultimately lead to the PAM-API
  124. returning failure but only after the remaining
  125. <emphasis>stacked</emphasis> modules (for this
  126. <emphasis>service</emphasis> and <emphasis>type</emphasis>)
  127. have been invoked.
  128. </para>
  129. </listitem>
  130. </varlistentry>
  131. <varlistentry>
  132. <term>requisite</term>
  133. <listitem>
  134. <para>
  135. like <emphasis>required</emphasis>, however, in the case that
  136. such a module returns a failure, control is directly returned
  137. to the application or to the superior PAM stack.
  138. The return value is that associated with
  139. the first required or requisite module to fail. Note, this flag
  140. can be used to protect against the possibility of a user getting
  141. the opportunity to enter a password over an unsafe medium. It is
  142. conceivable that such behavior might inform an attacker of valid
  143. accounts on a system. This possibility should be weighed against
  144. the not insignificant concerns of exposing a sensitive password
  145. in a hostile environment.
  146. </para>
  147. </listitem>
  148. </varlistentry>
  149. <varlistentry>
  150. <term>sufficient</term>
  151. <listitem>
  152. <para>
  153. if such a module succeeds and no prior <emphasis>required</emphasis>
  154. module has failed the PAM framework returns success to
  155. the application or to the superior PAM stack immediately without
  156. calling any further modules in the stack. A failure of a
  157. <emphasis>sufficient</emphasis> module is ignored and processing
  158. of the PAM module stack continues unaffected.
  159. </para>
  160. </listitem>
  161. </varlistentry>
  162. <varlistentry>
  163. <term>optional</term>
  164. <listitem>
  165. <para>
  166. the success or failure of this module is only important if
  167. it is the only module in the stack associated with this
  168. <emphasis>service</emphasis>+<emphasis>type</emphasis>.
  169. </para>
  170. </listitem>
  171. </varlistentry>
  172. <varlistentry>
  173. <term>include</term>
  174. <listitem>
  175. <para>
  176. include all lines of given type from the configuration
  177. file specified as an argument to this control.
  178. </para>
  179. </listitem>
  180. </varlistentry>
  181. <varlistentry>
  182. <term>substack</term>
  183. <listitem>
  184. <para>
  185. include all lines of given type from the configuration
  186. file specified as an argument to this control. This differs from
  187. <emphasis>include</emphasis> in that evaluation of the
  188. <emphasis>done</emphasis> and <emphasis>die</emphasis> actions
  189. in a substack does not cause skipping the rest of the complete
  190. module stack, but only of the substack. Jumps in a substack
  191. also can not make evaluation jump out of it, and the whole substack
  192. is counted as one module when the jump is done in a parent stack.
  193. The <emphasis>reset</emphasis> action will reset the state of a
  194. module stack to the state it was in as of beginning of the substack
  195. evaluation.
  196. </para>
  197. </listitem>
  198. </varlistentry>
  199. </variablelist>
  200. <para>
  201. For the more complicated syntax valid <emphasis>control</emphasis>
  202. values have the following form:
  203. </para>
  204. <programlisting>
  205. [value1=action1 value2=action2 ...]
  206. </programlisting>
  207. <para>
  208. Where <emphasis>valueN</emphasis> corresponds to the return code
  209. from the function invoked in the module for which the line is
  210. defined. It is selected from one of these:
  211. <emphasis>success</emphasis>, <emphasis>open_err</emphasis>,
  212. <emphasis>symbol_err</emphasis>, <emphasis>service_err</emphasis>,
  213. <emphasis>system_err</emphasis>, <emphasis>buf_err</emphasis>,
  214. <emphasis>perm_denied</emphasis>, <emphasis>auth_err</emphasis>,
  215. <emphasis>cred_insufficient</emphasis>,
  216. <emphasis>authinfo_unavail</emphasis>,
  217. <emphasis>user_unknown</emphasis>, <emphasis>maxtries</emphasis>,
  218. <emphasis>new_authtok_reqd</emphasis>,
  219. <emphasis>acct_expired</emphasis>, <emphasis>session_err</emphasis>,
  220. <emphasis>cred_unavail</emphasis>, <emphasis>cred_expired</emphasis>,
  221. <emphasis>cred_err</emphasis>, <emphasis>no_module_data</emphasis>,
  222. <emphasis>conv_err</emphasis>, <emphasis>authtok_err</emphasis>,
  223. <emphasis>authtok_recover_err</emphasis>,
  224. <emphasis>authtok_lock_busy</emphasis>,
  225. <emphasis>authtok_disable_aging</emphasis>,
  226. <emphasis>try_again</emphasis>, <emphasis>ignore</emphasis>,
  227. <emphasis>abort</emphasis>, <emphasis>authtok_expired</emphasis>,
  228. <emphasis>module_unknown</emphasis>, <emphasis>bad_item</emphasis>,
  229. <emphasis>conv_again</emphasis>, <emphasis>incomplete</emphasis>,
  230. and <emphasis>default</emphasis>.
  231. </para>
  232. <para>
  233. The last of these, <emphasis>default</emphasis>, implies 'all
  234. <emphasis>valueN</emphasis>'s not mentioned explicitly. Note, the
  235. full list of PAM errors is available in
  236. <filename>/usr/include/security/_pam_types.h</filename>. The
  237. <emphasis>actionN</emphasis> can take one of the following forms:
  238. </para>
  239. <variablelist>
  240. <varlistentry>
  241. <term>ignore</term>
  242. <listitem>
  243. <para>
  244. when used with a stack of modules, the module's return
  245. status will not contribute to the return code the application
  246. obtains.
  247. </para>
  248. </listitem>
  249. </varlistentry>
  250. <varlistentry>
  251. <term>bad</term>
  252. <listitem>
  253. <para>
  254. this action indicates that the return code should be thought
  255. of as indicative of the module failing. If this module is the
  256. first in the stack to fail, its status value will be used for
  257. that of the whole stack. This is the default action for
  258. all return codes.
  259. </para>
  260. </listitem>
  261. </varlistentry>
  262. <varlistentry>
  263. <term>die</term>
  264. <listitem>
  265. <para>
  266. equivalent to <emphasis>bad</emphasis> with the side effect of
  267. terminating the module stack and PAM immediately returning to
  268. the application.
  269. </para>
  270. </listitem>
  271. </varlistentry>
  272. <varlistentry>
  273. <term>ok</term>
  274. <listitem>
  275. <para>
  276. this tells PAM that the administrator thinks this return code
  277. should contribute directly to the return code of the full
  278. stack of modules. In other words, if the former state of the
  279. stack would lead to a return of <emphasis>PAM_SUCCESS</emphasis>,
  280. the module's return code will override this value. Note, if
  281. the former state of the stack holds some value that is
  282. indicative of a modules failure, this 'ok' value will not be
  283. used to override that value.
  284. </para>
  285. </listitem>
  286. </varlistentry>
  287. <varlistentry>
  288. <term>done</term>
  289. <listitem>
  290. <para>
  291. equivalent to <emphasis>ok</emphasis> with the side effect of
  292. terminating the module stack and PAM immediately returning to the
  293. application unless there was a non-ignored module failure before.
  294. </para>
  295. </listitem>
  296. </varlistentry>
  297. <varlistentry>
  298. <term>N (an unsigned integer)</term>
  299. <listitem>
  300. <para>
  301. jump over the next N modules in the stack.
  302. Note that N equal to 0 is not allowed,
  303. it would be treated as <emphasis>ignore</emphasis> in such case.
  304. The side effect depends on the PAM function call:
  305. for <emphasis>pam_authenticate</emphasis>,
  306. <emphasis>pam_acct_mgmt</emphasis>,
  307. <emphasis>pam_chauthtok</emphasis>, and
  308. <emphasis>pam_open_session</emphasis>
  309. it is <emphasis>ignore</emphasis>;
  310. for <emphasis>pam_setcred</emphasis> and
  311. <emphasis>pam_close_session</emphasis> it is
  312. one of <emphasis>ignore</emphasis>, <emphasis>ok</emphasis>,
  313. or <emphasis>bad</emphasis> depending on the module's return value.
  314. </para>
  315. </listitem>
  316. </varlistentry>
  317. <varlistentry>
  318. <term>reset</term>
  319. <listitem>
  320. <para>
  321. clear all memory of the state of the module stack and
  322. start again with the next stacked module.
  323. </para>
  324. </listitem>
  325. </varlistentry>
  326. </variablelist>
  327. <para>
  328. If a return code's action is not specifically defined via a
  329. <emphasis>valueN</emphasis> token, and the
  330. <emphasis>default</emphasis> value is not specified, that return
  331. code's action defaults to <emphasis>bad</emphasis>.
  332. </para>
  333. <para>
  334. Each of the four keywords: required; requisite; sufficient; and
  335. optional, have an equivalent expression in terms of the [...]
  336. syntax. They are as follows:
  337. </para>
  338. <variablelist>
  339. <varlistentry>
  340. <term>required</term>
  341. <listitem>
  342. <para>
  343. [success=ok new_authtok_reqd=ok ignore=ignore default=bad]
  344. </para>
  345. </listitem>
  346. </varlistentry>
  347. <varlistentry>
  348. <term>requisite</term>
  349. <listitem>
  350. <para>
  351. [success=ok new_authtok_reqd=ok ignore=ignore default=die]
  352. </para>
  353. </listitem>
  354. </varlistentry>
  355. <varlistentry>
  356. <term>sufficient</term>
  357. <listitem>
  358. <para>
  359. [success=done new_authtok_reqd=done default=ignore]
  360. </para>
  361. </listitem>
  362. </varlistentry>
  363. <varlistentry>
  364. <term>optional</term>
  365. <listitem>
  366. <para>
  367. [success=ok new_authtok_reqd=ok default=ignore]
  368. </para>
  369. </listitem>
  370. </varlistentry>
  371. </variablelist>
  372. <para>
  373. <emphasis>module-path</emphasis> is either the full filename
  374. of the PAM to be used by the application (it begins with a '/'),
  375. or a relative pathname from the default module location:
  376. <filename>/lib/security/</filename> or
  377. <filename>/lib64/security/</filename>, depending on the architecture.
  378. </para>
  379. <para>
  380. <emphasis>module-arguments</emphasis> are a space separated list
  381. of tokens that can be used to modify the specific behavior of the
  382. given PAM. Such arguments will be documented for each individual
  383. module. Note, if you wish to include spaces in an argument, you
  384. should surround that argument with square brackets.
  385. </para>
  386. <programlisting>
  387. squid auth required pam_mysql.so user=passwd_query passwd=mada \
  388. db=eminence [query=select user_name from internet_service \
  389. where user_name='%u' and password=PASSWORD('%p') and \
  390. service='web_proxy']
  391. </programlisting>
  392. <para>
  393. When using this convention, you can include `[' characters
  394. inside the string, and if you wish to include a `]' character
  395. inside the string that will survive the argument parsing, you
  396. should use `\]'. In other words:
  397. </para>
  398. <programlisting>
  399. [..[..\]..] --> ..[..]..
  400. </programlisting>
  401. <para>
  402. Any line in (one of) the configuration file(s), that is not formatted
  403. correctly, will generally tend (erring on the side of caution) to make
  404. the authentication process fail. A corresponding error is written to
  405. the system log files with a call to
  406. <citerefentry>
  407. <refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum>
  408. </citerefentry>.
  409. </para>
  410. </section>