pam_faillock.8.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <?xml version="1.0" encoding='UTF-8'?>
  2. <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
  4. <refentry id="pam_faillock">
  5. <refmeta>
  6. <refentrytitle>pam_faillock</refentrytitle>
  7. <manvolnum>8</manvolnum>
  8. <refmiscinfo class="sectdesc">Linux-PAM Manual</refmiscinfo>
  9. </refmeta>
  10. <refnamediv id="pam_faillock-name">
  11. <refname>pam_faillock</refname>
  12. <refpurpose>Module counting authentication failures during a specified interval</refpurpose>
  13. </refnamediv>
  14. <refsynopsisdiv>
  15. <cmdsynopsis id="pam_faillock-cmdsynopsisauth">
  16. <command>auth ... pam_faillock.so</command>
  17. <arg choice="req">
  18. preauth|authfail|authsucc
  19. </arg>
  20. <arg choice="opt">
  21. conf=<replaceable>/path/to/config-file</replaceable>
  22. </arg>
  23. <arg choice="opt">
  24. dir=<replaceable>/path/to/tally-directory</replaceable>
  25. </arg>
  26. <arg choice="opt">
  27. even_deny_root
  28. </arg>
  29. <arg choice="opt">
  30. deny=<replaceable>n</replaceable>
  31. </arg>
  32. <arg choice="opt">
  33. fail_interval=<replaceable>n</replaceable>
  34. </arg>
  35. <arg choice="opt">
  36. unlock_time=<replaceable>n</replaceable>
  37. </arg>
  38. <arg choice="opt">
  39. root_unlock_time=<replaceable>n</replaceable>
  40. </arg>
  41. <arg choice="opt">
  42. admin_group=<replaceable>name</replaceable>
  43. </arg>
  44. <arg choice="opt">
  45. audit
  46. </arg>
  47. <arg choice="opt">
  48. silent
  49. </arg>
  50. <arg choice="opt">
  51. no_log_info
  52. </arg>
  53. </cmdsynopsis>
  54. <cmdsynopsis id="pam_faillock-cmdsynopsisacct">
  55. <command>account ... pam_faillock.so</command>
  56. <arg choice="opt">
  57. dir=<replaceable>/path/to/tally-directory</replaceable>
  58. </arg>
  59. <arg choice="opt">
  60. no_log_info
  61. </arg>
  62. </cmdsynopsis>
  63. </refsynopsisdiv>
  64. <refsect1 id="pam_faillock-description">
  65. <title>DESCRIPTION</title>
  66. <para>
  67. This module maintains a list of failed authentication attempts per
  68. user during a specified interval and locks the account in case
  69. there were more than <replaceable>deny</replaceable> consecutive
  70. failed authentications.
  71. </para>
  72. <para>
  73. Normally, failed attempts to authenticate <emphasis>root</emphasis> will
  74. <emphasis remap='B'>not</emphasis> cause the root account to become
  75. blocked, to prevent denial-of-service: if your users aren't given
  76. shell accounts and root may only login via <command>su</command> or
  77. at the machine console (not telnet/rsh, etc), this is safe.
  78. </para>
  79. </refsect1>
  80. <refsect1 id="pam_faillock-options">
  81. <title>OPTIONS</title>
  82. <variablelist>
  83. <varlistentry>
  84. <term>
  85. <option>{preauth|authfail|authsucc}</option>
  86. </term>
  87. <listitem>
  88. <para>
  89. This argument must be set accordingly to the position of this module
  90. instance in the PAM stack.
  91. </para>
  92. <para>
  93. The <emphasis>preauth</emphasis> argument must be used when the module
  94. is called before the modules which ask for the user credentials such
  95. as the password. The module just examines whether the user should
  96. be blocked from accessing the service in case there were anomalous
  97. number of failed consecutive authentication attempts recently. This
  98. call is optional if <emphasis>authsucc</emphasis> is used.
  99. </para>
  100. <para>
  101. The <emphasis>authfail</emphasis> argument must be used when the module
  102. is called after the modules which determine the authentication outcome,
  103. failed. Unless the user is already blocked due to previous authentication
  104. failures, the module will record the failure into the appropriate user
  105. tally file.
  106. </para>
  107. <para>
  108. The <emphasis>authsucc</emphasis> argument must be used when the module
  109. is called after the modules which determine the authentication outcome,
  110. succeeded. Unless the user is already blocked due to previous authentication
  111. failures, the module will then clear the record of the failures in the
  112. respective user tally file. Otherwise it will return authentication error.
  113. If this call is not done, the pam_faillock will not distinguish between
  114. consecutive and non-consecutive failed authentication attempts. The
  115. <emphasis>preauth</emphasis> call must be used in such case. Due to
  116. complications in the way the PAM stack can be configured it is also
  117. possible to call <emphasis>pam_faillock</emphasis> as an account module.
  118. In such configuration the module must be also called in the
  119. <emphasis>preauth</emphasis> stage.
  120. </para>
  121. </listitem>
  122. </varlistentry>
  123. <varlistentry>
  124. <term>
  125. <option>conf=/path/to/config-file</option>
  126. </term>
  127. <listitem>
  128. <para>
  129. Use another configuration file instead of the default
  130. <filename>/etc/security/faillock.conf</filename>.
  131. </para>
  132. </listitem>
  133. </varlistentry>
  134. </variablelist>
  135. <para>
  136. The options for configuring the module behavior are described in the
  137. <citerefentry><refentrytitle>faillock.conf</refentrytitle><manvolnum>5</manvolnum>
  138. </citerefentry> manual page. The options specified on the module command
  139. line override the values from the configuration file.
  140. </para>
  141. </refsect1>
  142. <refsect1 id="pam_faillock-types">
  143. <title>MODULE TYPES PROVIDED</title>
  144. <para>
  145. The <option>auth</option> and <option>account</option> module types are
  146. provided.
  147. </para>
  148. </refsect1>
  149. <refsect1 id='pam_faillock-return_values'>
  150. <title>RETURN VALUES</title>
  151. <variablelist>
  152. <varlistentry>
  153. <term>PAM_AUTH_ERR</term>
  154. <listitem>
  155. <para>
  156. An invalid option was given, the module was not able
  157. to retrieve the user name, no valid counter file
  158. was found, or too many failed logins.
  159. </para>
  160. </listitem>
  161. </varlistentry>
  162. <varlistentry>
  163. <term>PAM_BUF_ERR</term>
  164. <listitem>
  165. <para>
  166. Memory buffer error.
  167. </para>
  168. </listitem>
  169. </varlistentry>
  170. <varlistentry>
  171. <term>PAM_CONV_ERR</term>
  172. <listitem>
  173. <para>
  174. The conversation method supplied by the application
  175. failed to obtain the username.
  176. </para>
  177. </listitem>
  178. </varlistentry>
  179. <varlistentry>
  180. <term>PAM_INCOMPLETE</term>
  181. <listitem>
  182. <para>
  183. The conversation method supplied by the application
  184. returned PAM_CONV_AGAIN.
  185. </para>
  186. </listitem>
  187. </varlistentry>
  188. <varlistentry>
  189. <term>PAM_SUCCESS</term>
  190. <listitem>
  191. <para>
  192. Everything was successful.
  193. </para>
  194. </listitem>
  195. </varlistentry>
  196. <varlistentry>
  197. <term>PAM_IGNORE</term>
  198. <listitem>
  199. <para>
  200. User not present in passwd database.
  201. </para>
  202. </listitem>
  203. </varlistentry>
  204. </variablelist>
  205. </refsect1>
  206. <refsect1 id='pam_faillock-notes'>
  207. <title>NOTES</title>
  208. <para>
  209. Configuring options on the module command line is not recommend. The
  210. <filename>/etc/security/faillock.conf</filename> should be used instead.
  211. </para>
  212. <para>
  213. The setup of <emphasis>pam_faillock</emphasis> in the PAM stack is different
  214. from the <emphasis>pam_tally2</emphasis> module setup.
  215. </para>
  216. <para>
  217. Individual files with the failure records are created as owned by
  218. the user. This allows <emphasis remap='B'>pam_faillock.so</emphasis> module
  219. to work correctly when it is called from a screensaver.
  220. </para>
  221. <para>
  222. Note that using the module in <option>preauth</option> without the
  223. <option>silent</option> option specified in <filename>/etc/security/faillock.conf</filename>
  224. or with <emphasis>requisite</emphasis> control field leaks an information about
  225. existence or non-existence of a user account in the system because
  226. the failures are not recorded for the unknown users. The message
  227. about the user account being locked is never displayed for non-existing
  228. user accounts allowing the adversary to infer that a particular account
  229. is not existing on a system.
  230. </para>
  231. </refsect1>
  232. <refsect1 id='pam_faillock-examples'>
  233. <title>EXAMPLES</title>
  234. <para>
  235. Here are two possible configuration examples for <filename>/etc/pam.d/login</filename>.
  236. They make <emphasis>pam_faillock</emphasis> to lock the account after 4 consecutive
  237. failed logins during the default interval of 15 minutes. Root account will be locked
  238. as well. The accounts will be automatically unlocked after 20 minutes.
  239. </para>
  240. <para>
  241. In the first example the module is called only in the <emphasis>auth</emphasis>
  242. phase and the module does not print any information about the account being blocked
  243. by <emphasis>pam_faillock</emphasis>. The <emphasis>preauth</emphasis> call can
  244. be added to tell users that their logins are blocked by the module and also to abort
  245. the authentication without even asking for password in such case.
  246. </para>
  247. <para>
  248. <filename>/etc/security/faillock.conf</filename> file example:
  249. </para>
  250. <programlisting>
  251. deny=4
  252. unlock_time=1200
  253. silent
  254. </programlisting>
  255. <para>
  256. /etc/pam.d/config file example:
  257. </para>
  258. <programlisting>
  259. auth required pam_securetty.so
  260. auth required pam_env.so
  261. auth required pam_nologin.so
  262. # optionally call: auth requisite pam_faillock.so preauth
  263. # to display the message about account being locked
  264. auth [success=1 default=bad] pam_unix.so
  265. auth [default=die] pam_faillock.so authfail
  266. auth sufficient pam_faillock.so authsucc
  267. auth required pam_deny.so
  268. account required pam_unix.so
  269. password required pam_unix.so shadow
  270. session required pam_selinux.so close
  271. session required pam_loginuid.so
  272. session required pam_unix.so
  273. session required pam_selinux.so open
  274. </programlisting>
  275. <para>
  276. In the second example the module is called both in the <emphasis>auth</emphasis>
  277. and <emphasis>account</emphasis> phases and the module informs the authenticating
  278. user when the account is locked if <option>silent</option> option is not
  279. specified in the <filename>faillock.conf</filename>.
  280. </para>
  281. <programlisting>
  282. auth required pam_securetty.so
  283. auth required pam_env.so
  284. auth required pam_nologin.so
  285. auth required pam_faillock.so preauth
  286. # optionally use requisite above if you do not want to prompt for the password
  287. # on locked accounts
  288. auth sufficient pam_unix.so
  289. auth [default=die] pam_faillock.so authfail
  290. auth required pam_deny.so
  291. account required pam_faillock.so
  292. # if you drop the above call to pam_faillock.so the lock will be done also
  293. # on non-consecutive authentication failures
  294. account required pam_unix.so
  295. password required pam_unix.so shadow
  296. session required pam_selinux.so close
  297. session required pam_loginuid.so
  298. session required pam_unix.so
  299. session required pam_selinux.so open
  300. </programlisting>
  301. </refsect1>
  302. <refsect1 id="pam_faillock-files">
  303. <title>FILES</title>
  304. <variablelist>
  305. <varlistentry>
  306. <term><filename>/var/run/faillock/*</filename></term>
  307. <listitem>
  308. <para>the files logging the authentication failures for users</para>
  309. </listitem>
  310. </varlistentry>
  311. <varlistentry>
  312. <term><filename>/etc/security/faillock.conf</filename></term>
  313. <listitem>
  314. <para>the config file for pam_faillock options</para>
  315. </listitem>
  316. </varlistentry>
  317. </variablelist>
  318. </refsect1>
  319. <refsect1 id='pam_faillock-see_also'>
  320. <title>SEE ALSO</title>
  321. <para>
  322. <citerefentry>
  323. <refentrytitle>faillock</refentrytitle><manvolnum>8</manvolnum>
  324. </citerefentry>,
  325. <citerefentry>
  326. <refentrytitle>faillock.conf</refentrytitle><manvolnum>5</manvolnum>
  327. </citerefentry>,
  328. <citerefentry>
  329. <refentrytitle>pam.conf</refentrytitle><manvolnum>5</manvolnum>
  330. </citerefentry>,
  331. <citerefentry>
  332. <refentrytitle>pam.d</refentrytitle><manvolnum>5</manvolnum>
  333. </citerefentry>,
  334. <citerefentry>
  335. <refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum>
  336. </citerefentry>
  337. </para>
  338. </refsect1>
  339. <refsect1 id='pam_faillock-author'>
  340. <title>AUTHOR</title>
  341. <para>
  342. pam_faillock was written by Tomas Mraz.
  343. </para>
  344. </refsect1>
  345. </refentry>