draft-morgan-pam.raw 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. Open-PAM working group ## A.G. Morgan
  2. Internet Draft: ## Dec 8, 2001
  3. Document: draft-morgan-pam-08.txt ##
  4. Expires: June 8, 2002 ##
  5. Obsoletes: draft-morgan-pam-07.txt##
  6. ## Pluggable Authentication Modules (PAM) ##
  7. #$ Status of this memo
  8. This document is a draft specification. Its contents are subject to
  9. change with revision. The latest version of this draft may be obtained
  10. from here:
  11. http://www.kernel.org/pub/linux/libs/pam/pre/doc/
  12. As
  13. Linux-PAM-'version'-docs.tar.gz
  14. It is also contained in the Linux-PAM tar ball.
  15. #$ Abstract
  16. This document is concerned with the definition of a general
  17. infrastructure for module based authentication. The infrastructure is
  18. named Pluggable Authentication Modules (PAM for short).
  19. #$ Introduction
  20. Computers are tools. They provide services to people and other
  21. computers (collectively we shall call these _users_ entities). In
  22. order to provide convenient, reliable and individual service to
  23. different entities, it is common for entities to be labelled. Having
  24. defined a label as referring to a some specific entity, the label is
  25. used for the purpose of protecting and allocating data resources.
  26. All modern operating systems have a notion of labelled entities and
  27. all modern operating systems face a common problem: how to
  28. authenticate the association of a predefined label with applicant
  29. entities.
  30. There are as many authentication methods as one might care to count.
  31. None of them are perfect and none of them are invulnerable. In
  32. general, any given authentication method becomes weaker over time. It
  33. is common then for new authentication methods to be developed in
  34. response to newly discovered weaknesses in the old authentication
  35. methods.
  36. The problem with inventing new authentication methods is the fact that
  37. old applications do not support them. This contributes to an inertia
  38. that discourages the overhaul of weakly protected systems. Another
  39. problem is that individuals (people) are frequently powerless to layer
  40. the protective authentication around their systems. They are forced
  41. to rely on single (lowest common denominator) authentication schemes
  42. even in situations where this is far from appropriate.
  43. PAM, as discussed in this document, is a generalization of the
  44. approach first introduced in [#$R#{OSF_RFC_PAM}]. In short, it is a
  45. general framework of interfaces that abstract the process of
  46. authentication. With PAM, a service provider can custom protect
  47. individual services to the level that they deem is appropriate.
  48. PAM has nothing explicit to say about transport layer encryption.
  49. Within the context of this document encryption and/or compression of
  50. data exchanges are application specific (strictly between client and
  51. server) and orthogonal to the process of authentication.
  52. #$ Definitions
  53. Here we pose the authentication problem as one of configuring defined
  54. interfaces between two entities.
  55. #$$#{players} Players in the authentication process
  56. PAM reserves the following words to specify unique entities in the
  57. authentication process:
  58. applicant
  59. the entity (user) initiating an application for service
  60. [PAM associates the PAM_RUSER _item_ with this requesting user].
  61. arbitrator
  62. the entity (user) under whose identity the service application
  63. is negotiated and with whose authority service is granted.
  64. user
  65. the entity (user) whose identity is being authenticated
  66. [PAM associates the PAM_USER _item_ with this identity].
  67. server
  68. the application that provides service, or acts as an
  69. authenticated gateway to the requested service. This
  70. application is completely responsible for the server end of
  71. the transport layer connecting the server to the client.
  72. PAM makes no assumptions about how data is encapsulated for
  73. exchanges between the server and the client, only that full
  74. octet sequences can be freely exchanged without corruption.
  75. client
  76. application providing the direct/primary interface to
  77. applicant. This application is completely responsible
  78. for the client end of the transport layer connecting the
  79. server to the client. PAM makes no assumptions about how data
  80. is encapsulated for exchanges between the server and the
  81. client, only that full octet sequences can be freely
  82. exchanged without corruption.
  83. module
  84. authentication binary that provides server-side support for
  85. some (arbitrary) authentication method.
  86. agent
  87. authentication binary that provides client-side support for
  88. some (arbitrary) authentication method.
  89. Here is a diagram to help orient the reader:
  90. ## +-------+ +--------+ ##
  91. ## . . . . .| agent | .| module | ##
  92. ## . +-------+ .+--------+ ##
  93. ## V | . | ##
  94. ## . | V | ##
  95. ## +---------+ +-------+ . +------+ ##
  96. ## | | |libpamc| . |libpam| ##
  97. ## | | +-------+ . +------+ ##
  98. ## |applicant| | . | ##
  99. ## | | +--------+ +----------+ ##
  100. ## | |---| client |-----------| server | ##
  101. ## +---------+ +--------+ +----------+ ##
  102. Solid lines connecting the boxes represent two-way interaction. The
  103. dotted-directed lines indicate an optional connection between the
  104. plugin module (agent) and the server (applicant). In the case of the
  105. module, this represents the module invoking the 'conversation'
  106. callback function provided to libpam by the server application when it
  107. initializes the libpam library. In the case of the agent, this may
  108. be some out-of-PAM API interaction (for example directly displaying a
  109. dialog box under X).
  110. #$$ Defined Data Types
  111. In this draft, we define two composite data types, the text string and
  112. the binary prompt. They are the data types used to communicate
  113. authentication requests and responses.
  114. #$$$#{text_string} text string
  115. The text string is a simple sequence of non-NUL (NUL = 0x00)
  116. octets. Terminated with a single NUL (0x00) octet. The character set
  117. employed in the octet sequence may be negotiated out of band, but
  118. defaults to utf-8.
  119. ## --------------------------- ##
  120. ## [ character data | NUL ] ##
  121. ## [ octet sequence | 0x00 ] ##
  122. ## --------------------------- ##
  123. Within the rest of this text, PAM text strings are delimited with a
  124. pair of double quotes. Example, "this" = {'t';'h';'i';'s';0x00}.
  125. #$$$#{binary_prompt} binary prompt
  126. A binary prompt consists of a stream of octets arranged as follows:
  127. ## ---------------------------------------- ##
  128. ## [ u32 | u8 | (length-5 octets) ] ##
  129. ## [ length | control | data ] ##
  130. ## ---------------------------------------- ##
  131. That is, a 32-bit unsigned integer in network byte order, a single
  132. unsigned byte of control information and a sequence of octets of
  133. length (length-5). The composition of the _data_ is context dependent
  134. but is generally not a concern for either the server or the client. It
  135. is very much the concern of modules and agents.
  136. For purposes of interoperability, we define the following control
  137. characters as legal.
  138. ## value symbol description ##
  139. ## ------------------------------------------------- ##
  140. ## 0x01 PAM_BPC_OK - continuation packet ##
  141. ## 0x02 PAM_BPC_SELECT - initialization packet ##
  142. ## 0x03 PAM_BPC_DONE - termination packet ##
  143. ## 0x04 PAM_BPC_FAIL - unable to execute ##
  144. The following control characters are only legal for exchanges between
  145. an agent and a client (it is the responsibility of the client to
  146. enforce this rule in the face of a rogue server):
  147. ## 0x41 PAM_BPC_GETENV - obtain client env.var ##
  148. ## 0x42 PAM_BPC_PUTENV - set client env.var ##
  149. ## 0x43 PAM_BPC_TEXT - display message ##
  150. ## 0x44 PAM_BPC_ERROR - display error message ##
  151. ## 0x45 PAM_BPC_PROMPT - echo'd text prompt ##
  152. ## 0x46 PAM_BPC_PASS - non-echo'd text prompt ##
  153. ## 0x46 PAM_BPC_STATUS - ping all active clients##
  154. ## 0x47 PAM_BPC_ABORT - please abort session ##
  155. Note, length is always equal to the total length of the binary
  156. prompt and represented by a network ordered unsigned 32 bit integer.
  157. #$$$$#{agent_ids} PAM_BPC_SELECT binary prompts
  158. Binary prompts of control type PAM_BPC_SELECT have a defined
  159. data part. It is composed of three elements:
  160. {agent_id;'/';data}
  161. The agent_id is a sequence of characters satisfying the following
  162. regexp:
  163. /^[a-z0-9\_]+(@[a-z0-9\_.]+)?$/
  164. and has a specific form for each independent agent.
  165. o Agent_ids that do not contain an at-sign (@) are to be considered as
  166. representing some authentication mode that is a "public
  167. standard" see reference [#$R#{PAM_STD_AGENTIDS}]. Registered names
  168. MUST NOT contain an at-sign (@).
  169. o Anyone can define additional agents by using names in the format
  170. name@domainname, e.g. "ouragent@example.com". The part following
  171. the at-sign MUST be a valid fully qualified internet domain name
  172. [RFC-1034] controlled by the person or organization defining the
  173. name. (Said another way, if you control the email address that
  174. your agent has as an identifier, they you are entitled to use
  175. this identifier.) It is up to each domain how it manages its local
  176. namespace.
  177. The '/' character is a mandatory delimiter, indicating the end of the
  178. agent_id. The trailing data is of a format specific to the agent with
  179. the given agent_id.
  180. #$$ Special cases
  181. In a previous section (#{players}) we identified the most general
  182. selection of authentication participants. In the case of network
  183. authentication, it is straightforward to ascribe identities to the
  184. defined participants. However, there are also special (less general)
  185. cases that we recognize here.
  186. The primary authentication step, when a user is directly introduced
  187. into a computer system (log's on to a workstation) is a special case.
  188. In this situation, the client and the server are generally one
  189. application. Before authenticating such a user, the applicant is
  190. formally unknown: PAM_RUSER is NULL.
  191. Some client-server implementations (telnet for example) provide
  192. effective full tty connections. In these cases, the four simple text
  193. string prompting cases (see below) can be handled as in the primary
  194. login step. In other words, the server absorbs most of the overhead of
  195. propagating authentication messages. In these cases, there needs to be
  196. special client/server support for handling binary prompts.
  197. In some circumstances, a legacy network transfer protocol can carry
  198. authentication information. In such cases, a desire to support legacy
  199. clients (with no client-side support for PAM) will neccessitate the
  200. 'hardcoding' of an agent protocol into the server application. Whilst
  201. against the spirit of PAM, this special casing can be managed by the
  202. server's 'conversation function' (see below). The guiding principle
  203. when implementing such support is for the application developer to
  204. relegate the authentication process to the PAM module -- simply
  205. performing a transcription of data from binary-prompt to legacy
  206. network 'packet' and visa-versa for propagating replies back to the
  207. driving PAM module. A common case of this is with network protocols
  208. that define an initialization packet of "user+password". In such cases
  209. one should attempt to support the "userpass" agent-id and its defined
  210. protocol.
  211. #$ Defined interfaces for information flow
  212. Here, we discuss the information exchange interfaces between the
  213. players in the authentication process. It should be understood that
  214. the server side is responsible for driving the authentication of the
  215. applicant. Notably, every request received by the client from the
  216. server must be matched with a single response from the client to the
  217. server.
  218. #$$#{applicant_client} Applicant <-> client
  219. Once the client is invoked, requests to the applicant entity are
  220. initiated by the client application. General clients are able to make
  221. the following requests directly to an applicant:
  222. echo text string
  223. echo error text string
  224. prompt with text string for echo'd text string input
  225. prompt with text string for concealed text string input
  226. the nature of the interface provided by the client for the benefit of
  227. the applicant entity is client specific and not defined by PAM.
  228. #$$#{client_agent} Client <-> agent
  229. In general, authentication schemes require more modes of exchange than
  230. the four defined in the previous section (#{applicant_client}). This
  231. provides a role for client-loadable agents. The client and agent
  232. exchange binary-messages that can have one of the following forms:
  233. client -> agent
  234. binary prompt agent expecting binary prompt reply to client
  235. agent -> client
  236. binary prompt reply from agent to clients binary prompt
  237. Following the acceptance of a binary prompt by the agent, the agent
  238. may attempt to exchange information with the client before returning
  239. its binary prompt reply. Permitted exchanges are binary prompts of the
  240. following types:
  241. agent -> client
  242. set environment variable (A)
  243. get environment variable (B)
  244. echo text string (C)
  245. echo error text string (D)
  246. prompt for echo'd text string input (E)
  247. prompt for concealed text string input (F)
  248. In response to these prompts, the client must legitimately respond
  249. with a corresponding binary prompt reply. We list a complete set of
  250. example exchanges, including each type of legitimate response (passes
  251. and a single fail):
  252. ## Type | Agent request | Client response ##
  253. ## --------------------------------------------------------------- ##
  254. ## (A) | {13;PAM_BPC_PUTENV;"FOO=BAR"} | {5;PAM_BPC_OK;} ##
  255. ## | {10;PAM_BPC_PUTENV;"FOO="} | {5;PAM_BPC_OK;} ##
  256. ## | {9;PAM_BPC_PUTENV;"FOO"} (*) | {5;PAM_BPC_OK;} ##
  257. ## | {9;PAM_BPC_PUTENV;"BAR"} (*) | {5;PAM_BPC_FAIL;} ##
  258. ## --------------------------------------------------------------- ##
  259. ## (B) | {10;PAM_BPC_GETENV;"TERM"} | {11;PAM_BPC_OK;"vt100"} ##
  260. ## | {9;PAM_BPC_GETENV;"FOO"} | {5;PAM_BPC_FAIL;} ##
  261. ## --------------------------------------------------------------- ##
  262. ## (C) | {12;PAM_BPC_TEXT;"hello!"} | {5;PAM_BPC_OK;} ##
  263. ## | {12;PAM_BPC_TEXT;"hello!"} | {5;PAM_BPC_FAIL;} ##
  264. ## --------------------------------------------------------------- ##
  265. ## (D) | {11;PAM_BPC_ERROR;"ouch!"} | {5;PAM_BPC_OK;} ##
  266. ## | {11;PAM_BPC_ERROR;"ouch!"} | {5;PAM_BPC_FAIL;} ##
  267. ## --------------------------------------------------------------- ##
  268. ## (E) | {13;PAM_BPC_PROMPT;"login: "} | {9;PAM_BPC_OK;"joe"} ##
  269. ## | {13;PAM_BPC_PROMPT;"login: "} | {6;PAM_BPC_OK;""} ##
  270. ## | {13;PAM_BPC_PROMPT;"login: "} | {5;PAM_BPC_FAIL;} ##
  271. ## --------------------------------------------------------------- ##
  272. ## (F) | {16;PAM_BPC_PASS;"password: "} | {9;PAM_BPC_OK;"XYZ"} ##
  273. ## | {16;PAM_BPC_PASS;"password: "} | {6;PAM_BPC_OK;""} ##
  274. ## | {16;PAM_BPC_PASS;"password: "} | {5;PAM_BPC_FAIL;} ##
  275. (*) Used to attempt the removal of a pre-existing environment
  276. variable.
  277. #$$ Client <-> server
  278. Once the client has established a connection with the server (the
  279. nature of the transport protocol is not specified by PAM), the server
  280. is responsible for driving the authentication process.
  281. General servers can request the following from the client:
  282. (to be forwarded by the client to the applicant)
  283. echo text string
  284. echo error text string
  285. prompt for echo'd text string response
  286. prompt for concealed text string response
  287. (to be forwarded by the client to the appropriate agent)
  288. binary prompt for a binary prompt response
  289. Client side agents are required to process binary prompts. The
  290. agents' binary prompt responses are returned to the server.
  291. #$$ Server <-> module
  292. Modules drive the authentication process. The server provides a
  293. conversation function with which it encapsulates module-generated
  294. requests and exchanges them with the client. Every message sent by a
  295. module should be acknowledged.
  296. General conversation functions can support the following five
  297. conversation requests:
  298. echo text string
  299. echo error string
  300. prompt for echo'd text string response
  301. prompt for concealed text string response
  302. binary prompt for binary prompt response
  303. The server is responsible for redirecting these requests to the
  304. client.
  305. #$ C API for application interfaces (client and server)
  306. #$$ Applicant <-> client
  307. No API is defined for this interface. The interface is considered to
  308. be specific to the client application. Example applications include
  309. terminal login, (X)windows login, machine file transfer applications.
  310. All that is important is that the client application is able to
  311. present the applicant with textual output and to receive textual
  312. input from the applicant. The forms of textual exchange are listed
  313. in an earlier section (#{applicant_client}). Other methods of
  314. data input/output are better suited to being handled via an
  315. authentication agent.
  316. #$$ Client <-> agent
  317. The client makes use of a general API for communicating with
  318. agents. The client is not required to communicate directly with
  319. available agents, instead a layer of abstraction (in the form of a
  320. library: libpamc) takes care of loading and maintaining communication
  321. with all requested agents. This layer of abstraction will choose which
  322. agents to interact with based on the content of binary prompts it
  323. receives that have the control type PAM_BPC_SELECT.
  324. #$$$ Client <-> libpamc
  325. #$$$$ Compilation information
  326. The C-header file provided for client-agent abstraction is included
  327. with the following source line:
  328. \#include <security/pam_client.h>
  329. The library providing the corresponding client-agent abstraction
  330. functions is, libpamc.
  331. cc .... -lpamc
  332. #$$$$ Initializing libpamc
  333. The libpamc library is initialized with a call to the following
  334. function:
  335. pamc_handle_t pamc_start(void);
  336. This function is responsible for configuring the library and
  337. registering the location of available agents. The location of the
  338. available agents on the system is implementation specific.
  339. pamc_start() function returns NULL on failure. Otherwise, the return
  340. value is a pointer to an opaque data type which provides a handle to
  341. the libpamc library. On systems where threading is available, the
  342. libpamc libraray is thread safe provided a single (pamc_handler_t *)
  343. is used by each thread.
  344. #$$$$ Client (Applicant) selection of agents
  345. For the purpose of applicant and client review of available agents,
  346. the following function is provided.
  347. char **pamc_list_agents(pamc_handle_t pch);
  348. This returns a list of pointers to the agent_id's of the agents which
  349. are available on the system. The list is terminated by a NULL pointer.
  350. It is the clients responsibility to free this memory area by calling
  351. free() on each agent id and the block of agent_id pointers in the
  352. result.
  353. PAM represents a server-driven authentication model, so by default
  354. any available agent may be invoked in the authentication process.
  355. #$$$$$ Client demands agent
  356. If the client requires that a specific authentication agent is
  357. satisfied during the authentication process, then the client should
  358. call the following function, immediately after obtaining a
  359. pamc_handle_t from pamc_start().
  360. int pamc_load(pamc_handle_t pch, const char *agent_id);
  361. agent_id is a PAM text string (see section #{agent_ids}) and is not
  362. suffixed with a '/' delimiter. The return value for this function is:
  363. PAM_BPC_TRUE - agent located and loaded.
  364. PAM_BPC_FALSE - agent is not available.
  365. Note, although the agent is loaded, no data is fed to it. The agent's
  366. opportunity to inform the client that it does not trust the server is
  367. when the agent is shutdown.
  368. #$$$$$ Client marks agent as unusable
  369. The applicant might prefer that a named agent is marked as not
  370. available. To do this, the client would invoke the following function
  371. immediately after obtaining a pamc_handle_t from pam_start().
  372. int pamc_disable(pamc_handle_t pch, const char *agent_id);
  373. here agent_id is a PAM text string containing an agent_id (section
  374. #{agent_ids}).
  375. The return value for this function is:
  376. PAM_BPC_TRUE - agent is disabled. This is the response
  377. independent of whether the agent is locally
  378. available.
  379. PAM_BPC_FALSE - agent cannot be disabled (this may be because
  380. it has already been invoked).
  381. #$$$$ Allocating and manipulating binary prompts
  382. All conversation between an client and an agent takes place with
  383. respect to binary prompts. A binary prompt (see section #{binary_prompt}), is
  384. obtained, resized and deleted via the following C-macro:
  385. CREATION of a binary prompt with control X1 and data length Y1:
  386. pamc_bp_t prompt = NULL;
  387. PAM_BP_RENEW(&prompt, X1, Y1);
  388. REPLACEMENT of a binary prompt with a control X2 and data length Y2:
  389. PAM_BP_RENEW(&prompt, X2, Y2);
  390. DELETION of a binary prompt (the referenced prompt is scrubbed):
  391. PAM_BP_RENEW(&prompt, 0, 0);
  392. Note, the PAM_BP_RENEW macro always overwrites any prompt that you
  393. call it with, deleting and liberating the old contents in a secure
  394. fashion. Also note that PAM_BP_RENEW, when returning a prompt of data
  395. size Y1>0, will always append a '\0' byte to the end of the prompt (at
  396. data offset Y1). It is thus, by definition, acceptable to treat the
  397. data contents of a binary packet as a text string (see #{text_string}).
  398. FILLING a binary prompt from a memory pointer U1 from offset O1 of
  399. length L1:
  400. PAM_BP_FILL(prompt, O1, L1, U1);
  401. the CONTROL type for the packet can be obtained as follows:
  402. control = PAM_PB_CONTROL(prompt);
  403. the LENGTH of a data within the prompt (_excluding_ its header
  404. information) can be obtained as follows:
  405. length = PAM_BP_LENGTH(prompt);
  406. the total SIZE of the prompt (_including_ its header information)
  407. can be obtained as follows:
  408. size = PAM_BP_SIZE(prompt);
  409. EXTRACTING data from a binary prompt from offset O2 of length L2 to
  410. a memory pointer U2:
  411. PAM_BP_EXTRACT(prompt, O2, L2, U2);
  412. If you require direct access to the raw prompt DATA, you should use
  413. the following macro:
  414. __u8 *raw_data = PAM_BP_DATA(prompt);
  415. #$$$$ Client<->agent conversations
  416. All exchanges of binary prompts with agents are handled with the
  417. single function:
  418. int pamc_converse(pamc_handle_t *pch, pamc_bp_t *prompt_p);
  419. The return value for pamc_converse(...) is PAM_BPC_TRUE when there is
  420. a response packet and PAM_BPC_FALSE when the client is unable to
  421. handle the request represented by the original prompt. In this latter
  422. case, *prompt_p is set to NULL.
  423. This function takes a binary prompt and returns a replacement binary
  424. prompt that is either a request from an agent to be acted upon by the
  425. client or the 'result' which should be forwarded to the server. In the
  426. former case, the following macro will return 1 (PAM_BPC_TRUE) and in
  427. all other cases, 0 (PAM_BPC_FALSE):
  428. PAM_BPC_FOR_CLIENT(/* pamc_bp_t */ prompt)
  429. Note, all non-NULL binary prompts returned by pamc_converse(...), are
  430. terminated with a '\0', even when the full length of the prompt (as
  431. returned by the agent) does not contain this delimiter. This is a
  432. defined property of the PAM_BP_RENEW macro, and can be relied upon.
  433. Important security note: in certain implementations, agents are
  434. implemented by executable binaries, which are transparently loaded and
  435. managed by the PAM client library. To ensure there is never a leakage
  436. of elevated privilege to an unprivileged agent, the client application
  437. should go to some effort to lower its level of privilege. It remains
  438. the responsibility of the applicant and the client to ensure that it
  439. is not compromised by a rogue agent.
  440. #$$$$ Status of agents
  441. int pamc_status(pamc_handle_t *pch, pamc_bp_t *prompt_p);
  442. At any time, the client may ping all active agents for their status
  443. (with a PAM_BPC_STATUS binary prompt). If any agent replies with
  444. PAM_BPC_ABORT, the client is responsible for terminating the
  445. connection to the server and then terminating all agents with a call
  446. to pamc_end(). In such cases, the return value of pamc_status() is
  447. PAM_BPC_FALSE.
  448. If the return status of pamc_status() is PAM_BPC_TRUE and *prompt_p is
  449. non-NULL, then an agent is requesting access to a server module.
  450. XXX - how this information gets propagated to the server, and
  451. ultimately to the server's module is yet to be determined.
  452. #$$$$ Termination of agents
  453. When closing the authentication session and severing the connection
  454. between a client and a selection of agents, the following function is
  455. used:
  456. int pamc_end(pamc_handle_t *pch);
  457. Following a call to pamc_end, the pamc_handle_t will be invalid.
  458. The return value for this function is one of the following:
  459. PAM_BPC_TRUE - all invoked agents are content with
  460. authentication (the server is _not_ judged
  461. _un_trustworthy by any agent)
  462. PAM_BPC_FALSE - one or more agents were unsatisfied at
  463. being terminated. In general, the client
  464. should terminate its connection to the
  465. server and indicate to the applicant that
  466. the server is untrusted.
  467. #$$$ libpamc <-> agents
  468. The agents are manipulated from within libpamc. Each agent is an
  469. executable in its own right. This permits the agent to have access to
  470. sensitive data not accessible directly from the client. The mode of
  471. communication between libpamc and an agent is through a pair of
  472. pipes. The agent reads binary prompts (section #{binary_prompt})
  473. through its standard input file descriptor and writes response (to the
  474. server) binary prompts and instruction binary prompts (instructions
  475. for the client) through its standard output file descriptor.
  476. #$$ Client <-> server
  477. This interface is concerned with the exchange of text and binary
  478. prompts between the client application and the server application. No
  479. API is provided for this as it is considered specific to the transport
  480. protocol shared by the client and the server.
  481. #$$ Server <-> modules
  482. The server makes use of a general API for communicating with
  483. modules. The client is not required to communicate directly with
  484. available modules. By abstracting the authentication interface, it
  485. becomes possible for the local administrator to make a run time
  486. decision about the authentication method adopted by the server.
  487. #$$$ Functions and definitions available to servers and modules
  488. [This section will document the following functions
  489. pam_set_item()
  490. pam_get_item()
  491. pam_fail_delay(pam_handle_t *pamh, unsigned int micro_sec)
  492. pam_get_env(pam_handle_t *pamh, const char *varname)
  493. pam_strerror(pam_handle_t *pamh, int pam_errno)
  494. Event driven support (XXX work in progress)
  495. pam_register_event() - app or module associates an event poller/handler
  496. pam_select_event() - query for any outstanding event and act on any
  497. ]
  498. #$$$ Server <-> libpam
  499. [This section will document the following pam_ calls:
  500. pam_start
  501. pam_end
  502. pam_authenticate (*)
  503. pam_setcred
  504. pam_acct_mgmt
  505. pam_open_session
  506. pam_close_session
  507. pam_chauthtok (*)
  508. The asterisked functions may return PAM_INCOMPLETE. In such cases, the
  509. application should be aware that the conversation function was called
  510. and that it returned PAM_CONV_AGAIN to a module. The correct action
  511. for the application to take in response to receiving PAM_INCOMPLETE,
  512. is to acquire the replies so that the next time the conversation
  513. function is called it will be able to provide the desired
  514. responses. And then recall pam_authenticate (pam_chauthtok) with the
  515. same arguments. Libpam will arrange that the module stack is resumed
  516. from the module that returned before. This functionality is required
  517. for programs whose user interface is maintained by an event loop. ]
  518. #$$$ libpam <-> modules
  519. [This section will document the following pam_ and pam_sm_ calls:
  520. functions provided by libpam
  521. pam_set_data
  522. pam_get_data
  523. functions provided to libpam by each module
  524. groups:
  525. AUTHENTICATION
  526. pam_sm_authenticate
  527. pam_sm_setcred
  528. ACCOUNT
  529. pam_sm_acct_mgmt
  530. SESSION
  531. pam_sm_open_session
  532. pam_sm_close_session
  533. AUTHENTICATION TOKEN MANAGEMENT
  534. pam_sm_chauthtok
  535. ]
  536. #$$$ The conversation function
  537. The server application, as part of its initialization of libpam,
  538. provides a conversation function for use by modules and libpam. The
  539. purpose of the conversation function is to enable direct communication
  540. to the applicant ultimately via the client and selected agents.
  541. [ this section will contain a definition for the conversation
  542. function, the conversation structure (appdata etc), and legitimate
  543. return codes for the application supplied function.
  544. PAM_SUCCESS - ok conversation completed
  545. PAM_CONV_ERR - conversation failed
  546. PAM_CONV_AGAIN - application needs control to complete conv
  547. PAM_CONV_RECONSIDER - application believes module should check if
  548. it still needs to converse for this info
  549. ]
  550. #$ Security considerations
  551. This document is devoted to standardizing authentication
  552. infrastructure: everything in this document has implications for
  553. security.
  554. #$ Contact
  555. The email list for discussing issues related to this document is
  556. <pam-list@redhat.com>.
  557. #$ References
  558. [#{OSF_RFC_PAM}] OSF RFC 86.0, "Unified Login with Pluggable Authentication
  559. Modules (PAM)", October 1995
  560. [#{PAM_STD_AGENTIDS}] Definitions for standard agents, "REGISTERED
  561. AGENTS AND THEIR AGENT-ID'S", to be found here:
  562. ## http://www.kernel.org/pub/linux/libs/pam/pre/doc/std-agent-ids.txt ##
  563. #$ Author's Address
  564. Andrew G. Morgan
  565. Email: morgan@kernel.org
  566. ## $Id$ ##