pam.3.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
  4. <refentry id='pam3'>
  5. <refmeta>
  6. <refentrytitle>pam</refentrytitle>
  7. <manvolnum>3</manvolnum>
  8. <refmiscinfo class='setdesc'>Linux-PAM Manual</refmiscinfo>
  9. </refmeta>
  10. <refnamediv id='pam3-name'>
  11. <refname>pam</refname>
  12. <refpurpose>Pluggable Authentication Modules Library</refpurpose>
  13. </refnamediv>
  14. <refsynopsisdiv id='pam3-synopsis'>
  15. <funcsynopsis>
  16. <funcsynopsisinfo>#include &lt;security/pam_appl.h&gt;</funcsynopsisinfo>
  17. <funcsynopsisinfo>#include &lt;security/pam_modules.h&gt;</funcsynopsisinfo>
  18. <funcsynopsisinfo>#include &lt;security/pam_ext.h&gt;</funcsynopsisinfo>
  19. </funcsynopsis>
  20. </refsynopsisdiv>
  21. <refsect1 id='pam3-description'>
  22. <title>DESCRIPTION</title>
  23. <para>
  24. <emphasis remap='B'>PAM</emphasis> is a system of libraries
  25. that handle the authentication tasks of applications (services)
  26. on the system. The library provides a stable general interface
  27. (Application Programming Interface - API) that privilege granting
  28. programs (such as
  29. <citerefentry>
  30. <refentrytitle>login</refentrytitle><manvolnum>1</manvolnum>
  31. </citerefentry> and <citerefentry>
  32. <refentrytitle>su</refentrytitle><manvolnum>1</manvolnum>
  33. </citerefentry>)
  34. defer to to perform standard authentication tasks.
  35. </para>
  36. <refsect2 id='pam3-initialization_and_cleanup'>
  37. <title>Initialization and Cleanup</title>
  38. <para>
  39. The
  40. <citerefentry>
  41. <refentrytitle>pam_start</refentrytitle><manvolnum>3</manvolnum>
  42. </citerefentry> function creates the PAM context and initiates the
  43. PAM transaction. It is the first of the PAM functions that needs to
  44. be called by an application. The transaction state is contained
  45. entirely within the structure identified by this handle, so it is
  46. possible to have multiple transactions in parallel. But it is not
  47. possible to use the same handle for different transactions, a new
  48. one is needed for every new context.
  49. </para>
  50. <para>
  51. The
  52. <citerefentry>
  53. <refentrytitle>pam_end</refentrytitle><manvolnum>3</manvolnum>
  54. </citerefentry> function terminates the PAM transaction and is the last
  55. function an application should call in the PAM context. Upon return
  56. the handle pamh is no longer valid and all memory associated with it
  57. will be invalid. It can be called at any time to terminate a PAM
  58. transaction.
  59. </para>
  60. </refsect2>
  61. <refsect2 id='pam3-authentication'>
  62. <title>Authentication</title>
  63. <para>
  64. The
  65. <citerefentry>
  66. <refentrytitle>pam_authenticate</refentrytitle><manvolnum>3</manvolnum>
  67. </citerefentry>
  68. function is used to
  69. authenticate the user. The user is required to provide an
  70. authentication token depending upon the authentication service,
  71. usually this is a password, but could also be a finger print.
  72. </para>
  73. <para>
  74. The
  75. <citerefentry>
  76. <refentrytitle>pam_setcred</refentrytitle><manvolnum>3</manvolnum>
  77. </citerefentry>
  78. function manages the user's credentials.
  79. </para>
  80. </refsect2>
  81. <refsect2 id='pam3-account_management'>
  82. <title>Account Management</title>
  83. <para>
  84. The
  85. <citerefentry>
  86. <refentrytitle>pam_acct_mgmt</refentrytitle><manvolnum>3</manvolnum>
  87. </citerefentry> function is used to determine if the user's account is
  88. valid. It checks for authentication token and account expiration and
  89. verifies access restrictions. It is typically called after the user
  90. has been authenticated.
  91. </para>
  92. </refsect2>
  93. <refsect2 id='pam3-password_management'>
  94. <title>Password Management</title>
  95. <para>
  96. The
  97. <citerefentry>
  98. <refentrytitle>pam_chauthtok</refentrytitle><manvolnum>3</manvolnum>
  99. </citerefentry> function is used to change the authentication token
  100. for a given user on request or because the token has expired.
  101. </para>
  102. </refsect2>
  103. <refsect2 id='pam3-session_management'>
  104. <title>Session Management</title>
  105. <para>
  106. The
  107. <citerefentry>
  108. <refentrytitle>pam_open_session</refentrytitle><manvolnum>3</manvolnum>
  109. </citerefentry> function sets up a user session for a previously
  110. successful authenticated user. The session should later be terminated
  111. with a call to
  112. <citerefentry>
  113. <refentrytitle>pam_close_session</refentrytitle><manvolnum>3</manvolnum>
  114. </citerefentry>.
  115. </para>
  116. </refsect2>
  117. <refsect2 id='pam3-conversation'>
  118. <title>Conversation</title>
  119. <para>
  120. The PAM library uses an application-defined callback to allow
  121. a direct communication between a loaded module and the application.
  122. This callback is specified by the
  123. <emphasis>struct pam_conv</emphasis> passed to
  124. <citerefentry>
  125. <refentrytitle>pam_start</refentrytitle><manvolnum>3</manvolnum>
  126. </citerefentry> at the start of the transaction. See
  127. <citerefentry>
  128. <refentrytitle>pam_conv</refentrytitle><manvolnum>3</manvolnum>
  129. </citerefentry>
  130. for details.
  131. </para>
  132. </refsect2>
  133. <refsect2 id='pam3-data'>
  134. <title>Data Objects</title>
  135. <para>
  136. The
  137. <citerefentry>
  138. <refentrytitle>pam_set_item</refentrytitle><manvolnum>3</manvolnum>
  139. </citerefentry>
  140. and
  141. <citerefentry>
  142. <refentrytitle>pam_get_item</refentrytitle><manvolnum>3</manvolnum>
  143. </citerefentry>
  144. functions allows applications and PAM service modules to set and
  145. retrieve PAM information.
  146. </para>
  147. <para>
  148. The
  149. <citerefentry>
  150. <refentrytitle>pam_get_user</refentrytitle><manvolnum>3</manvolnum>
  151. </citerefentry>
  152. function is the preferred method to obtain the username.
  153. </para>
  154. <para>
  155. The
  156. <citerefentry>
  157. <refentrytitle>pam_set_data</refentrytitle><manvolnum>3</manvolnum>
  158. </citerefentry>
  159. and
  160. <citerefentry>
  161. <refentrytitle>pam_get_data</refentrytitle><manvolnum>3</manvolnum>
  162. </citerefentry>
  163. functions allows PAM service modules to set and retrieve free-form
  164. data from one invocation to another.
  165. </para>
  166. </refsect2>
  167. <refsect2 id='pam3-miscellaneous'>
  168. <title>Environment and Error Management</title>
  169. <para>
  170. The
  171. <citerefentry>
  172. <refentrytitle>pam_putenv</refentrytitle><manvolnum>3</manvolnum>
  173. </citerefentry>,
  174. <citerefentry>
  175. <refentrytitle>pam_getenv</refentrytitle><manvolnum>3</manvolnum>
  176. </citerefentry> and
  177. <citerefentry>
  178. <refentrytitle>pam_getenvlist</refentrytitle><manvolnum>3</manvolnum>
  179. </citerefentry>
  180. functions are for maintaining a set of private environment variables.
  181. </para>
  182. <para>
  183. The
  184. <citerefentry>
  185. <refentrytitle>pam_strerror</refentrytitle><manvolnum>3</manvolnum>
  186. </citerefentry> function returns a pointer to a string describing the
  187. given PAM error code.
  188. </para>
  189. </refsect2>
  190. </refsect1>
  191. <refsect1 id='pam3-return_values'>
  192. <title>RETURN VALUES</title>
  193. <para>
  194. The following return codes are known by PAM:
  195. </para>
  196. <variablelist>
  197. <varlistentry>
  198. <term>PAM_ABORT</term>
  199. <listitem>
  200. <para>Critical error, immediate abort.</para>
  201. </listitem>
  202. </varlistentry>
  203. <varlistentry>
  204. <term>PAM_ACCT_EXPIRED</term>
  205. <listitem>
  206. <para>User account has expired.</para>
  207. </listitem>
  208. </varlistentry>
  209. <varlistentry>
  210. <term>PAM_AUTHINFO_UNAVAIL</term>
  211. <listitem>
  212. <para>
  213. Authentication service cannot retrieve authentication info.
  214. </para>
  215. </listitem>
  216. </varlistentry>
  217. <varlistentry>
  218. <term>PAM_AUTHTOK_DISABLE_AGING</term>
  219. <listitem>
  220. <para>Authentication token aging disabled.</para>
  221. </listitem>
  222. </varlistentry>
  223. <varlistentry>
  224. <term>PAM_AUTHTOK_ERR</term>
  225. <listitem>
  226. <para>Authentication token manipulation error.</para>
  227. </listitem>
  228. </varlistentry>
  229. <varlistentry>
  230. <term>PAM_AUTHTOK_EXPIRED</term>
  231. <listitem>
  232. <para>Authentication token expired.</para>
  233. </listitem>
  234. </varlistentry>
  235. <varlistentry>
  236. <term>PAM_AUTHTOK_LOCK_BUSY</term>
  237. <listitem>
  238. <para>Authentication token lock busy.</para>
  239. </listitem>
  240. </varlistentry>
  241. <varlistentry>
  242. <term>PAM_AUTHTOK_RECOVERY_ERR</term>
  243. <listitem>
  244. <para>Authentication information cannot be recovered.</para>
  245. </listitem>
  246. </varlistentry>
  247. <varlistentry>
  248. <term>PAM_AUTH_ERR</term>
  249. <listitem>
  250. <para>Authentication failure.</para>
  251. </listitem>
  252. </varlistentry>
  253. <varlistentry>
  254. <term>PAM_BUF_ERR</term>
  255. <listitem>
  256. <para>Memory buffer error.</para>
  257. </listitem>
  258. </varlistentry>
  259. <varlistentry>
  260. <term>PAM_CONV_ERR</term>
  261. <listitem>
  262. <para>Conversation failure.</para>
  263. </listitem>
  264. </varlistentry>
  265. <varlistentry>
  266. <term>PAM_CRED_ERR</term>
  267. <listitem>
  268. <para>Failure setting user credentials.</para>
  269. </listitem>
  270. </varlistentry>
  271. <varlistentry>
  272. <term>PAM_CRED_EXPIRED</term>
  273. <listitem>
  274. <para>User credentials expired.</para>
  275. </listitem>
  276. </varlistentry>
  277. <varlistentry>
  278. <term>PAM_CRED_INSUFFICIENT</term>
  279. <listitem>
  280. <para>Insufficient credentials to access authentication data.</para>
  281. </listitem>
  282. </varlistentry>
  283. <varlistentry>
  284. <term>PAM_CRED_UNAVAIL</term>
  285. <listitem>
  286. <para>Authentication service cannot retrieve user credentials.</para>
  287. </listitem>
  288. </varlistentry>
  289. <varlistentry>
  290. <term>PAM_IGNORE</term>
  291. <listitem>
  292. <para>The return value should be ignored by PAM dispatch.</para>
  293. </listitem>
  294. </varlistentry>
  295. <varlistentry>
  296. <term>PAM_MAXTRIES</term>
  297. <listitem>
  298. <para>Have exhausted maximum number of retries for service.</para>
  299. </listitem>
  300. </varlistentry>
  301. <varlistentry>
  302. <term>PAM_MODULE_UNKNOWN</term>
  303. <listitem>
  304. <para>Module is unknown.</para>
  305. </listitem>
  306. </varlistentry>
  307. <varlistentry>
  308. <term>PAM_NEW_AUTHTOK_REQD</term>
  309. <listitem>
  310. <para>
  311. Authentication token is no longer valid; new one required.
  312. </para>
  313. </listitem>
  314. </varlistentry>
  315. <varlistentry>
  316. <term>PAM_NO_MODULE_DATA</term>
  317. <listitem>
  318. <para>No module specific data is present.</para>
  319. </listitem>
  320. </varlistentry>
  321. <varlistentry>
  322. <term>PAM_OPEN_ERR</term>
  323. <listitem>
  324. <para>Failed to load module.</para>
  325. </listitem>
  326. </varlistentry>
  327. <varlistentry>
  328. <term>PAM_PERM_DENIED</term>
  329. <listitem>
  330. <para>Permission denied.</para>
  331. </listitem>
  332. </varlistentry>
  333. <varlistentry>
  334. <term>PAM_SERVICE_ERR</term>
  335. <listitem>
  336. <para>Error in service module.</para>
  337. </listitem>
  338. </varlistentry>
  339. <varlistentry>
  340. <term>PAM_SESSION_ERR</term>
  341. <listitem>
  342. <para>Cannot make/remove an entry for the specified session.</para>
  343. </listitem>
  344. </varlistentry>
  345. <varlistentry>
  346. <term>PAM_SUCCESS</term>
  347. <listitem>
  348. <para>Success.</para>
  349. </listitem>
  350. </varlistentry>
  351. <varlistentry>
  352. <term>PAM_SYMBOL_ERR</term>
  353. <listitem>
  354. <para>Symbol not found.</para>
  355. </listitem>
  356. </varlistentry>
  357. <varlistentry>
  358. <term>PAM_SYSTEM_ERR</term>
  359. <listitem>
  360. <para>System error.</para>
  361. </listitem>
  362. </varlistentry>
  363. <varlistentry>
  364. <term>PAM_TRY_AGAIN</term>
  365. <listitem>
  366. <para>Failed preliminary check by password service.</para>
  367. </listitem>
  368. </varlistentry>
  369. <varlistentry>
  370. <term>PAM_USER_UNKNOWN</term>
  371. <listitem>
  372. <para>User not known to the underlying authentication module.</para>
  373. </listitem>
  374. </varlistentry>
  375. </variablelist>
  376. </refsect1>
  377. <refsect1 id='see_also'><title>SEE ALSO</title>
  378. <para>
  379. <citerefentry>
  380. <refentrytitle>pam_acct_mgmt</refentrytitle><manvolnum>3</manvolnum>
  381. </citerefentry>, <citerefentry>
  382. <refentrytitle>pam_authenticate</refentrytitle><manvolnum>3</manvolnum>
  383. </citerefentry>, <citerefentry>
  384. <refentrytitle>pam_chauthtok</refentrytitle><manvolnum>3</manvolnum>
  385. </citerefentry>, <citerefentry>
  386. <refentrytitle>pam_close_session</refentrytitle><manvolnum>3</manvolnum>
  387. </citerefentry>, <citerefentry>
  388. <refentrytitle>pam_conv</refentrytitle><manvolnum>3</manvolnum>
  389. </citerefentry>, <citerefentry>
  390. <refentrytitle>pam_end</refentrytitle><manvolnum>3</manvolnum>
  391. </citerefentry>, <citerefentry>
  392. <refentrytitle>pam_get_data</refentrytitle><manvolnum>3</manvolnum>
  393. </citerefentry>, <citerefentry>
  394. <refentrytitle>pam_getenv</refentrytitle><manvolnum>3</manvolnum>
  395. </citerefentry>, <citerefentry>
  396. <refentrytitle>pam_getenvlist</refentrytitle><manvolnum>3</manvolnum>
  397. </citerefentry>, <citerefentry>
  398. <refentrytitle>pam_get_item</refentrytitle><manvolnum>3</manvolnum>
  399. </citerefentry>, <citerefentry>
  400. <refentrytitle>pam_get_user</refentrytitle><manvolnum>3</manvolnum>
  401. </citerefentry>, <citerefentry>
  402. <refentrytitle>pam_open_session</refentrytitle><manvolnum>3</manvolnum>
  403. </citerefentry>, <citerefentry>
  404. <refentrytitle>pam_putenv</refentrytitle><manvolnum>3</manvolnum>
  405. </citerefentry>, <citerefentry>
  406. <refentrytitle>pam_set_data</refentrytitle><manvolnum>3</manvolnum>
  407. </citerefentry>, <citerefentry>
  408. <refentrytitle>pam_set_item</refentrytitle><manvolnum>3</manvolnum>
  409. </citerefentry>, <citerefentry>
  410. <refentrytitle>pam_setcred</refentrytitle><manvolnum>3</manvolnum>
  411. </citerefentry>, <citerefentry>
  412. <refentrytitle>pam_start</refentrytitle><manvolnum>3</manvolnum>
  413. </citerefentry>, <citerefentry>
  414. <refentrytitle>pam_strerror</refentrytitle><manvolnum>3</manvolnum>
  415. </citerefentry>
  416. </para>
  417. </refsect1>
  418. <refsect1 id='pam3-notes'><title>NOTES</title>
  419. <para>
  420. The <emphasis>libpam</emphasis> interfaces are only thread-safe if each
  421. thread within the multithreaded application uses its own PAM handle.
  422. </para>
  423. </refsect1>
  424. </refentry>