This file is indexed.

/usr/share/doc/libpam-doc/html/adg-interface-by-app-expected.html is in libpam-doc 1.1.3-7ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>3.1. What can be expected by the application</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="Linux-PAM_ADG.html" title="The Linux-PAM Application Developers' Guide"><link rel="up" href="adg-interface.html" title="Chapter 3.  The public interface to Linux-PAM"><link rel="prev" href="adg-interface.html" title="Chapter 3.  The public interface to Linux-PAM"><link rel="next" href="adg-interface-of-app-expected.html" title="3.2. What is expected of an application"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.1. What can be expected by the application</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="adg-interface.html">Prev</a> </td><th width="60%" align="center">Chapter 3. 
      The public interface to <span class="emphasis"><em>Linux-PAM</em></span>
    </th><td width="20%" align="right"> <a accesskey="n" href="adg-interface-of-app-expected.html">Next</a></td></tr></table><hr></div><div class="section" title="3.1. What can be expected by the application"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="adg-interface-by-app-expected"></a>3.1. What can be expected by the application</h2></div></div></div><div class="section" title="3.1.1. Initialization of PAM transaction"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_start"></a>3.1.1. Initialization of PAM transaction</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_start</b>(</code></td><td><var class="pdparam">service_name</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">user</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">pam_conversation</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">pamh</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>const char *<var class="pdparam">service_name</var></code>;<br><code>const char *<var class="pdparam">user</var></code>;<br><code>const struct pam_conv *<var class="pdparam">pam_conversation</var></code>;<br><code>pam_handle_t **<var class="pdparam">pamh</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.1.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_start-description"></a>3.1.1.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_start</code> function creates the PAM context
      and initiates the PAM transaction. It is the first of the PAM
      functions that needs to be called by an application. The transaction
      state is contained entirely within the structure identified by this
      handle, so it is possible to have multiple transactions in parallel.
      But it is not possible to use the same handle for different
      transactions, a new one is needed for every new context.
    </p><p>
      The <span class="emphasis"><em>service_name</em></span> argument specifies the name
      of the service to apply and will be stored as PAM_SERVICE item in
      the new context. The policy for the service will be read from the
      file <code class="filename">/etc/pam.d/service_name</code> or, if that file
      does not exist, from <code class="filename">/etc/pam.conf</code>.
    </p><p>
       The <span class="emphasis"><em>user</em></span> argument can specify the name
       of the target user and will be stored as PAM_USER item. If
       the argument is NULL, the module has to ask for this item if
       necessary.
    </p><p>
       The <span class="emphasis"><em>pam_conversation</em></span> argument points to
       a <span class="emphasis"><em>struct pam_conv</em></span> describing the
       conversation function to use. An application must provide this
       for direct communication between a loaded module and the
       application.
    </p><p>
       Following a successful return (PAM_SUCCESS) the contents of
       <span class="emphasis"><em>pamh</em></span> is a handle that contains the PAM
       context for successive calls to the PAM functions. In an error
       case is the content of <span class="emphasis"><em>pamh</em></span> undefined.
    </p><p>
      The <span class="emphasis"><em>pam_handle_t</em></span> is a blind structure and
      the application should not attempt to probe it directly for
      information. Instead the PAM library provides the functions
      <span class="citerefentry"><span class="refentrytitle">pam_set_item</span>(3)</span> and
      <span class="citerefentry"><span class="refentrytitle">pam_get_item</span>(3)</span>.
      The PAM handle cannot be used for mulitiple authentications at the
      same time as long as <code class="function">pam_end</code> was not called on
      it before.
    </p></div><div class="section" title="3.1.1.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_start-return_values"></a>3.1.1.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_ABORT</span></dt><dd><p>
              General failure.
          </p></dd><dt><span class="term">PAM_BUF_ERR</span></dt><dd><p>
              Memory buffer error.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             Transaction was successful created.
          </p></dd><dt><span class="term">PAM_SYSTEM_ERR</span></dt><dd><p>
              System error, for example a NULL pointer was submitted
              instead of a pointer to data.
          </p></dd></dl></div></div></div><div class="section" title="3.1.2. Termination of PAM transaction"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_end"></a>3.1.2. Termination of PAM transaction</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_end</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">pam_status</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">pam_status</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.2.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_end-description"></a>3.1.2.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_end</code> function terminates the PAM
      transaction and is the last function an application should call
      in the PAM context.  Upon return the handle <span class="emphasis"><em>pamh</em></span>
      is no longer valid and all memory associated with it will be
      invalid.
    </p><p>
      The <span class="emphasis"><em>pam_status</em></span> argument should be set to
      the value returned to the application by the last PAM
      library call.
    </p><p>
      The value taken by <span class="emphasis"><em>pam_status</em></span> is used as
      an argument to the module specific callback function,
      <code class="function">cleanup()</code>
      (See <span class="citerefentry"><span class="refentrytitle">pam_set_data</span>(3)</span> and
      <span class="citerefentry"><span class="refentrytitle">pam_get_data</span>(3)</span>). In this way the module can be given notification
      of the pass/fail nature of the tear-down process, and perform any
      last minute tasks that are appropriate to the module before it is
      unlinked. This argument can be logically OR'd with
      <span class="emphasis"><em>PAM_DATA_SILENT</em></span> to indicate to indicate that
      the module should not treat the call too seriously. It is generally
      used to indicate that the current closing of the library is in a
      <span class="citerefentry"><span class="refentrytitle">fork</span>(2)</span>ed
      process, and that the parent will take care of cleaning up things
      that exist outside of the current process space (files etc.).
    </p><p>
      This function <span class="emphasis"><em>free</em></span>'s all memory for items
      associated with the
      <span class="citerefentry"><span class="refentrytitle">pam_set_item</span>(3)</span> and
      <span class="citerefentry"><span class="refentrytitle">pam_get_item</span>(3)</span> functions. Pointers associated with such objects
      are not valid anymore after <code class="function">pam_end</code> was called.
    </p></div><div class="section" title="3.1.2.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_end-return_values"></a>3.1.2.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             Transaction was successful terminated.
          </p></dd><dt><span class="term">PAM_SYSTEM_ERR</span></dt><dd><p>
              System error, for example a NULL pointer was submitted
              as PAM handle or the function was called by a module.
          </p></dd></dl></div></div></div><div class="section" title="3.1.3. Setting PAM items"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_set_item"></a>3.1.3. Setting PAM items</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_modules.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_set_item</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">item_type</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">item</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">item_type</var></code>;<br><code>const void *<var class="pdparam">item</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.3.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_set_item-description"></a>3.1.3.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_set_item</code> function allows applications
      and PAM service modules to access and to update PAM informations
      of <span class="emphasis"><em>item_type</em></span>. For this a copy
      of the object pointed to by the <span class="emphasis"><em>item</em></span> argument
      is created. The following <span class="emphasis"><em>item_type</em></span>s are
      supported:
   </p><div class="variablelist"><dl><dt><span class="term">PAM_SERVICE</span></dt><dd><p>
            The service name (which identifies that PAM stack that
            the PAM functions will use to authenticate the program).
          </p></dd><dt><span class="term">PAM_USER</span></dt><dd><p>
            The username of the entity under whose identity service
            will be given. That is, following authentication,
            <span class="emphasis"><em>PAM_USER</em></span> identifies the local entity
            that gets to use the service. Note, this value can be mapped
            from something (eg., "anonymous") to something else (eg.
            "guest119") by any module in the PAM stack. As such an
            application should consult the value of
            <span class="emphasis"><em>PAM_USER</em></span> after each call to a PAM function.
          </p></dd><dt><span class="term">PAM_USER_PROMPT</span></dt><dd><p>
            The string used when prompting for a user's name. The default
            value for this string is a localized version of "login: ".
          </p></dd><dt><span class="term">PAM_TTY</span></dt><dd><p>
            The terminal name: prefixed by <code class="filename">/dev/</code> if
            it is a device file; for graphical, X-based, applications the
            value for this item should be the
            <span class="emphasis"><em>$DISPLAY</em></span> variable.
          </p></dd><dt><span class="term">PAM_RUSER</span></dt><dd><p>
            The requesting user name: local name for a locally
            requesting user or a remote user name for a remote
            requesting user.
          </p><p>
            Generally an application or module will attempt to supply
            the value that is most strongly authenticated (a local account
            before a remote one. The level of trust in this value is
            embodied in the actual authentication stack associated with
            the application, so it is ultimately at the discretion of the
            system administrator.
          </p><p>
            <span class="emphasis"><em>PAM_RUSER@PAM_RHOST</em></span> should always identify
             the requesting user. In some cases,
             <span class="emphasis"><em>PAM_RUSER</em></span> may be NULL. In such situations,
             it is unclear who the requesting entity is.
          </p></dd><dt><span class="term">PAM_RHOST</span></dt><dd><p>
            The requesting hostname (the hostname of the machine from
            which the <span class="emphasis"><em>PAM_RUSER</em></span> entity is requesting
            service). That is <span class="emphasis"><em>PAM_RUSER@PAM_RHOST</em></span>
            does identify the requesting user. In some applications,
            <span class="emphasis"><em>PAM_RHOST</em></span> may be NULL. In such situations,
            it is unclear where the authentication request is originating
            from.
          </p></dd><dt><span class="term">PAM_AUTHTOK</span></dt><dd><p>
            The authentication token (often a password). This token
            should be ignored by all module functions besides
            <span class="citerefentry"><span class="refentrytitle">pam_sm_authenticate</span>(3)</span> and
            <span class="citerefentry"><span class="refentrytitle">pam_sm_chauthtok</span>(3)</span>.
            In the former function it is used to pass the most recent
            authentication token from one stacked module to another. In
            the latter function the token is used for another purpose.
            It contains the currently active authentication token.
          </p></dd><dt><span class="term">PAM_OLDAUTHTOK</span></dt><dd><p>
            The old authentication token. This token should be ignored
            by all module functions except
            <span class="citerefentry"><span class="refentrytitle">pam_sm_chauthtok</span>(3)</span>.
          </p></dd><dt><span class="term">PAM_CONV</span></dt><dd><p>
            The pam_conv structure. See
            <span class="citerefentry"><span class="refentrytitle">pam_conv</span>(3)</span>.
          </p></dd></dl></div><p>
     The following additional items are specific to Linux-PAM and should not be used in
     portable applications:
   </p><div class="variablelist"><dl><dt><span class="term">PAM_FAIL_DELAY</span></dt><dd><p>
            A function pointer to redirect centrally managed
            failure delays. See
            <span class="citerefentry"><span class="refentrytitle">pam_fail_delay</span>(3)</span>.
          </p></dd><dt><span class="term">PAM_XDISPLAY</span></dt><dd><p>
            The name of the X display.  For graphical, X-based applications the
	    value for this item should be the <span class="emphasis"><em>$DISPLAY</em></span>
	    variable.  This value may be used independently of
	    <span class="emphasis"><em>PAM_TTY</em></span> for passing the
	    name of the display.
          </p></dd><dt><span class="term">PAM_XAUTHDATA</span></dt><dd><p>
            A pointer to a structure containing the X authentication data
	    required to make a connection to the display specified by
	    <span class="emphasis"><em>PAM_XDISPLAY</em></span>, if such information is
	    necessary.  See
            <span class="citerefentry"><span class="refentrytitle">pam_xauth_data</span>(3)</span>.
          </p></dd><dt><span class="term">PAM_AUTHTOK_TYPE</span></dt><dd><p>
            The default action is for the module to use the
            following prompts when requesting passwords:
            "New UNIX password: " and "Retype UNIX password: ".
            The example word <span class="emphasis"><em>UNIX</em></span> can
            be replaced with this item, by default it is empty.
            This item is used by <span class="citerefentry"><span class="refentrytitle">pam_get_authtok</span>(3)</span>.
          </p></dd></dl></div><p>
      For all <span class="emphasis"><em>item_type</em></span>s, other than PAM_CONV and
      PAM_FAIL_DELAY, <span class="emphasis"><em>item</em></span> is a pointer to a &lt;NUL&gt;
      terminated character string. In the case of PAM_CONV,
      <span class="emphasis"><em>item</em></span> points to an initialized
      <span class="emphasis"><em>pam_conv</em></span> structure. In the case of
      PAM_FAIL_DELAY, <span class="emphasis"><em>item</em></span> is a function pointer:
      <code class="function">void (*delay_fn)(int retval, unsigned usec_delay, void *appdata_ptr)</code>
    </p><p>
      Both, PAM_AUTHTOK and PAM_OLDAUTHTOK, will be reseted before
      returning to the application. Which means an application is not
      able to access the authentication tokens.
    </p></div><div class="section" title="3.1.3.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_set_item-return_values"></a>3.1.3.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_BAD_ITEM</span></dt><dd><p>
             The application attempted to set an undefined or inaccessible
             item.
          </p></dd><dt><span class="term">PAM_BUF_ERR</span></dt><dd><p>
              Memory buffer error.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             Data was successful updated.
          </p></dd><dt><span class="term">PAM_SYSTEM_ERR</span></dt><dd><p>
             The <span class="emphasis"><em>pam_handle_t</em></span> passed as first
             argument was invalid.
          </p></dd></dl></div></div></div><div class="section" title="3.1.4. Getting PAM items"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_get_item"></a>3.1.4. Getting PAM items</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_modules.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_get_item</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">item_type</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">item</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>const pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">item_type</var></code>;<br><code>const void **<var class="pdparam">item</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.4.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_get_item-description"></a>3.1.4.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_get_item</code> function allows applications
      and PAM service modules to access and retrieve PAM informations
      of <span class="emphasis"><em>item_type</em></span>. Upon successful return,
      <span class="emphasis"><em>item</em></span> contains a pointer to the value of the
      corresponding item. Note, this is a pointer to the
      <span class="emphasis"><em>actual</em></span> data and should
      <span class="emphasis"><em>not</em></span> be <span class="emphasis"><em>free()</em></span>'ed or
      over-written! The following values are supported for
      <span class="emphasis"><em>item_type</em></span>:
   </p><div class="variablelist"><dl><dt><span class="term">PAM_SERVICE</span></dt><dd><p>
            The service name (which identifies that PAM stack that
            the PAM functions will use to authenticate the program).
          </p></dd><dt><span class="term">PAM_USER</span></dt><dd><p>
            The username of the entity under whose identity service
            will be given. That is, following authentication,
            <span class="emphasis"><em>PAM_USER</em></span> identifies the local entity
            that gets to use the service. Note, this value can be mapped
            from something (eg., "anonymous") to something else (eg.
            "guest119") by any module in the PAM stack. As such an
            application should consult the value of
            <span class="emphasis"><em>PAM_USER</em></span> after each call to a PAM function.
          </p></dd><dt><span class="term">PAM_USER_PROMPT</span></dt><dd><p>
            The string used when prompting for a user's name. The default
            value for this string is a localized version of "login: ".
          </p></dd><dt><span class="term">PAM_TTY</span></dt><dd><p>
            The terminal name: prefixed by <code class="filename">/dev/</code> if
            it is a device file; for graphical, X-based, applications the
            value for this item should be the
            <span class="emphasis"><em>$DISPLAY</em></span> variable.
          </p></dd><dt><span class="term">PAM_RUSER</span></dt><dd><p>
            The requesting user name: local name for a locally
            requesting user or a remote user name for a remote
            requesting user.
          </p><p>
            Generally an application or module will attempt to supply
            the value that is most strongly authenticated (a local account
            before a remote one. The level of trust in this value is
            embodied in the actual authentication stack associated with
            the application, so it is ultimately at the discretion of the
            system administrator.
          </p><p>
            <span class="emphasis"><em>PAM_RUSER@PAM_RHOST</em></span> should always identify
             the requesting user. In some cases,
             <span class="emphasis"><em>PAM_RUSER</em></span> may be NULL. In such situations,
             it is unclear who the requesting entity is.
          </p></dd><dt><span class="term">PAM_RHOST</span></dt><dd><p>
            The requesting hostname (the hostname of the machine from
            which the <span class="emphasis"><em>PAM_RUSER</em></span> entity is requesting
            service). That is <span class="emphasis"><em>PAM_RUSER@PAM_RHOST</em></span>
            does identify the requesting user. In some applications,
            <span class="emphasis"><em>PAM_RHOST</em></span> may be NULL. In such situations,
            it is unclear where the authentication request is originating
            from.
          </p></dd><dt><span class="term">PAM_AUTHTOK</span></dt><dd><p>
            The authentication token (often a password). This token
            should be ignored by all module functions besides
            <span class="citerefentry"><span class="refentrytitle">pam_sm_authenticate</span>(3)</span> and
            <span class="citerefentry"><span class="refentrytitle">pam_sm_chauthtok</span>(3)</span>.
            In the former function it is used to pass the most recent
            authentication token from one stacked module to another. In
            the latter function the token is used for another purpose.
            It contains the currently active authentication token.
          </p></dd><dt><span class="term">PAM_OLDAUTHTOK</span></dt><dd><p>
            The old authentication token. This token should be ignored
            by all module functions except
            <span class="citerefentry"><span class="refentrytitle">pam_sm_chauthtok</span>(3)</span>.
          </p></dd><dt><span class="term">PAM_CONV</span></dt><dd><p>
            The pam_conv structure. See
            <span class="citerefentry"><span class="refentrytitle">pam_conv</span>(3)</span>.
          </p></dd></dl></div><p>
     The following additional items are specific to Linux-PAM and should not be used in
     portable applications:
   </p><div class="variablelist"><dl><dt><span class="term">PAM_FAIL_DELAY</span></dt><dd><p>
            A function pointer to redirect centrally managed
            failure delays. See
            <span class="citerefentry"><span class="refentrytitle">pam_fail_delay</span>(3)</span>.
          </p></dd><dt><span class="term">PAM_XDISPLAY</span></dt><dd><p>
            The name of the X display.  For graphical, X-based applications the
	    value for this item should be the <span class="emphasis"><em>$DISPLAY</em></span>
	    variable.  This value may be used independently of
	    <span class="emphasis"><em>PAM_TTY</em></span> for passing the
	    name of the display.
          </p></dd><dt><span class="term">PAM_XAUTHDATA</span></dt><dd><p>
            A pointer to a structure containing the X authentication data
	    required to make a connection to the display specified by
	    <span class="emphasis"><em>PAM_XDISPLAY</em></span>, if such information is
	    necessary.  See
            <span class="citerefentry"><span class="refentrytitle">pam_xauth_data</span>(3)</span>.
          </p></dd><dt><span class="term">PAM_AUTHTOK_TYPE</span></dt><dd><p>
            The default action is for the module to use the
            following prompts when requesting passwords:
            "New UNIX password: " and "Retype UNIX password: ".
            The example word <span class="emphasis"><em>UNIX</em></span> can
            be replaced with this item, by default it is empty.
            This item is used by <span class="citerefentry"><span class="refentrytitle">pam_get_authtok</span>(3)</span>.
          </p></dd></dl></div><p>
      If a service module wishes to obtain the name of the user,
      it should not use this function, but instead perform a call to
      <span class="citerefentry"><span class="refentrytitle">pam_get_user</span>(3)</span>.
    </p><p>
      Only a service module is privileged to read the
      authentication tokens, PAM_AUTHTOK and PAM_OLDAUTHTOK.
    </p></div><div class="section" title="3.1.4.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_get_item-return_values"></a>3.1.4.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_BAD_ITEM</span></dt><dd><p>
             The application attempted to set an undefined or inaccessible
             item.
          </p></dd><dt><span class="term">PAM_BUF_ERR</span></dt><dd><p>
              Memory buffer error.
          </p></dd><dt><span class="term">PAM_PERM_DENIED</span></dt><dd><p>
             The value of <span class="emphasis"><em>item</em></span> was NULL.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             Data was successful updated.
          </p></dd><dt><span class="term">PAM_SYSTEM_ERR</span></dt><dd><p>
             The <span class="emphasis"><em>pam_handle_t</em></span> passed as first
             argument was invalid.
          </p></dd></dl></div></div></div><div class="section" title="3.1.5. Strings describing PAM error codes"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_strerror"></a>3.1.5. Strings describing PAM error codes</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">const char *<b class="fsfunc">pam_strerror</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">errnum</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">errnum</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.5.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_strerror-description"></a>3.1.5.1. DESCRIPTION</h4></div></div></div><p>
       The <code class="function">pam_strerror</code> function returns a pointer to
       a string describing the error code passed in the argument
       <span class="emphasis"><em>errnum</em></span>, possibly using the LC_MESSAGES part of
       the current locale to select the appropriate language. This string
       must not be modified by the application. No library function will
       modify this string.
    </p></div><div class="section" title="3.1.5.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_strerror-return_values"></a>3.1.5.2. RETURN VALUES</h4></div></div></div><p>
       This function returns always a pointer to a string.
    </p></div></div><div class="section" title="3.1.6. Request a delay on failure"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_fail_delay"></a>3.1.6. Request a delay on failure</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_fail_delay</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">usec</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>unsigned int <var class="pdparam">usec</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.6.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_fail_delay-description"></a>3.1.6.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_fail_delay</code> function provides a
      mechanism by which an application or module can suggest a minimum
      delay of <span class="emphasis"><em>usec</em></span> micro-seconds. The
      function  keeps a record of the longest time requested with this
      function. Should
      <span class="citerefentry"><span class="refentrytitle">pam_authenticate</span>(3)</span> fail, the failing return to the application is
      delayed by an amount of time randomly distributed (by up to 25%)
      about this longest value.
    </p><p>
      Independent of success, the delay time is reset to its zero
      default value when the PAM service module returns control to
      the application. The delay occurs <span class="emphasis"><em>after</em></span> all
      authentication modules have been called, but <span class="emphasis"><em>before</em></span>
      control is returned to the service application.
    </p><p>
      When using this function the programmer should check if it is
      available with:
    </p><pre class="programlisting">
#ifdef HAVE_PAM_FAIL_DELAY
    ....
#endif /* HAVE_PAM_FAIL_DELAY */
      </pre><p>
      For applications written with a single thread that are event
      driven in nature, generating this delay may be undesirable.
      Instead, the application may want to register the delay in some
      other way. For example, in a single threaded server that serves
      multiple authentication requests from a single event loop, the
      application might want to simply mark a given connection as
      blocked until an application timer expires. For this reason
      the delay function can be changed with the
      <span class="emphasis"><em>PAM_FAIL_DELAY</em></span> item. It can be queried and
      set with
      <span class="citerefentry"><span class="refentrytitle">pam_get_item</span>(3)</span>
      and
      <span class="citerefentry"><span class="refentrytitle">pam_set_item </span>(3)</span>  respectively. The value used to set it should be
      a function pointer of the following prototype:
      </p><pre class="programlisting">
void (*delay_fn)(int retval, unsigned usec_delay, void *appdata_ptr);
      </pre><p>
      The arguments being the <span class="emphasis"><em>retval</em></span> return code
      of the module stack, the <span class="emphasis"><em>usec_delay</em></span>
      micro-second delay that libpam is requesting and the
      <span class="emphasis"><em>appdata_ptr</em></span> that the application has associated
      with the current <span class="emphasis"><em>pamh</em></span>. This last value was set
      by the application when it called
      <span class="citerefentry"><span class="refentrytitle">pam_start</span>(3)</span> or explicitly with
      <span class="citerefentry"><span class="refentrytitle">pam_set_item</span>(3)</span>.
      Note, if PAM_FAIL_DELAY item is unset (or set to NULL), then no delay
      will be performed.
    </p></div><div class="section" title="3.1.6.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_fail_delay-return_values"></a>3.1.6.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
            Delay was successful adjusted.
          </p></dd><dt><span class="term">PAM_SYSTEM_ERR</span></dt><dd><p>
             A NULL pointer was submitted as PAM handle.
          </p></dd></dl></div></div></div><div class="section" title="3.1.7. Authenticating the user"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_authenticate"></a>3.1.7. Authenticating the user</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_authenticate</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">flags</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">flags</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.7.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_authenticate-description"></a>3.1.7.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_authenticate</code> function is used to
      authenticate the user. The user is required to provide an
      authentication token depending upon the authentication service,
      usually this is a password, but could also be a finger print.
    </p><p>
      The PAM service module may request that the user enter their
      username vio the the conversation mechanism (see
      <span class="citerefentry"><span class="refentrytitle">pam_start</span>(3)</span> and
      <span class="citerefentry"><span class="refentrytitle">pam_conv</span>(3)</span>). The name of the authenticated user
       will be present in the PAM item PAM_USER. This item may be
       recovered with a call to
      <span class="citerefentry"><span class="refentrytitle">pam_get_item</span>(3)</span>.
    </p><p>
      The <span class="emphasis"><em>pamh</em></span> argument is an authentication
      handle obtained by a prior call to pam_start().
      The flags argument is the binary or of zero or more of the
      following values:
    </p><div class="variablelist"><dl><dt><span class="term">PAM_SILENT</span></dt><dd><p>
             Do not emit any messages.
          </p></dd><dt><span class="term">PAM_DISALLOW_NULL_AUTHTOK</span></dt><dd><p>
            The PAM module service should return PAM_AUTH_ERR
            if the user does not have a registered authentication token.
          </p></dd></dl></div></div><div class="section" title="3.1.7.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_authenticate-return_values"></a>3.1.7.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_ABORT</span></dt><dd><p>
            The application should exit immediately after calling
            <span class="citerefentry"><span class="refentrytitle">pam_end</span>(3)</span> first.
          </p></dd><dt><span class="term">PAM_AUTH_ERR</span></dt><dd><p>
            The user was not authenticated.
          </p></dd><dt><span class="term">PAM_CRED_INSUFFICIENT</span></dt><dd><p>
            For some reason the application does not have sufficient
            credentials to authenticate the user.
          </p></dd><dt><span class="term">PAM_AUTHINFO_UNVAIL</span></dt><dd><p>
            The modules were not able to access the authentication
            information. This might be due to a network or hardware
            failure etc.
          </p></dd><dt><span class="term">PAM_MAXTRIES</span></dt><dd><p>
            One or more of the authentication modules has reached its
            limit of tries authenticating the user. Do not try again.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             The user was successfully authenticated.
          </p></dd><dt><span class="term">PAM_USER_UNKNOWN</span></dt><dd><p>
            User unknown to authentication service.
          </p></dd></dl></div></div></div><div class="section" title="3.1.8. Setting user credentials"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_setcred"></a>3.1.8. Setting user credentials</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_setcred</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">flags</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">flags</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.8.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_setcred-description"></a>3.1.8.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_setcred</code> function is used to establish,
      maintain and delete the credentials of a user. It should be called
      to set the credentials after a user has been authenticated and before
      a session is opened for the user (with
      <span class="citerefentry"><span class="refentrytitle">pam_open_session</span>(3)</span>). The credentials should be deleted after the session
      has been closed (with
      <span class="citerefentry"><span class="refentrytitle">pam_close_session</span>(3)</span>).
     </p><p>
       A credential is something that the user possesses. It is some
       property, such as a <span class="emphasis"><em>Kerberos</em></span> ticket, or a
       supplementary group membership that make up the uniqueness of a
       given user. On a Linux system the user's <span class="emphasis"><em>UID</em></span>
       and <span class="emphasis"><em>GID</em></span>'s are credentials too. However, it
       has been decided that these properties (along with the default
       supplementary groups of which the user is a member) are credentials
       that should be set directly by the application and not by PAM.
       Such credentials should be established, by the application, prior
       to a call to this function.  For example,
       <span class="citerefentry"><span class="refentrytitle">initgroups</span>(2)</span> (or equivalent) should have been performed.
      </p><p>
        Valid <span class="emphasis"><em>flags</em></span>, any one of which, may be
        logically OR'd with <code class="option">PAM_SILENT</code>, are:
      </p><div class="variablelist"><dl><dt><span class="term">PAM_ESTABLISH_CRED</span></dt><dd><p>Initialize the credentials for the user.</p></dd><dt><span class="term">PAM_DELETE_CRED</span></dt><dd><p>Delete the user's credentials.</p></dd><dt><span class="term">PAM_REINITIALIZE_CRED</span></dt><dd><p>Fully reinitialize the user's credentials.</p></dd><dt><span class="term">PAM_REFRESH_CRED</span></dt><dd><p>Extend the lifetime of the existing credentials.</p></dd></dl></div></div><div class="section" title="3.1.8.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_setcred-return_values"></a>3.1.8.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_BUF_ERR</span></dt><dd><p>
              Memory buffer error.
          </p></dd><dt><span class="term">PAM_CRED_ERR</span></dt><dd><p>
              Failed to set user credentials.
          </p></dd><dt><span class="term">PAM_CRED_EXPIRED</span></dt><dd><p>
             User credentials are expired.
          </p></dd><dt><span class="term">PAM_CRED_UNAVAIL</span></dt><dd><p>
              Failed to retrieve user credentials.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             Data was successful stored.
          </p></dd><dt><span class="term">PAM_SYSTEM_ERR</span></dt><dd><p>
             A NULL pointer was submitted as PAM handle, the
             function was called by a module or another system
             error occured.
          </p></dd><dt><span class="term">PAM_USER_UNKNOWN</span></dt><dd><p>
              User is not known to an authentication module.
          </p></dd></dl></div></div></div><div class="section" title="3.1.9. Account validation management"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_acct_mgmt"></a>3.1.9. Account validation management</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_acct_mgmt</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">flags</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">flags</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.9.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_acct_mgmt-description"></a>3.1.9.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_acct_mgmt</code> function is used to determine
      if the users account is valid. It checks for authentication token
      and account expiration and verifies access restrictions. It is
      typically called after the user has been authenticated.
    </p><p>
      The <span class="emphasis"><em>pamh</em></span> argument is an authentication
      handle obtained by a prior call to pam_start().
      The flags argument is the binary or of zero or more of the
      following values:
    </p><div class="variablelist"><dl><dt><span class="term">PAM_SILENT</span></dt><dd><p>
             Do not emit any messages.
          </p></dd><dt><span class="term">PAM_DISALLOW_NULL_AUTHTOK</span></dt><dd><p>
            The PAM module service should return PAM_NEW_AUTHTOK_REQD
            if the user has a null authentication token.
          </p></dd></dl></div></div><div class="section" title="3.1.9.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_acct_mgmt-return_values"></a>3.1.9.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_ACCT_EXPIRED</span></dt><dd><p>
             User account has expired.
          </p></dd><dt><span class="term">PAM_AUTH_ERR</span></dt><dd><p>
            Authentication failure.
          </p></dd><dt><span class="term">PAM_NEW_AUTHTOK_REQD</span></dt><dd><p>
            The user account is valid but their authentication token
            is <span class="emphasis"><em>expired</em></span>. The correct response to
            this return-value is to require that the user satisfies
            the <code class="function">pam_chauthtok()</code> function before
            obtaining service. It may not be possible for some
            applications to do this. In such cases, the user should be
            denied access until such time as they can update their password.
          </p></dd><dt><span class="term">PAM_PERM_DENIED</span></dt><dd><p>
            Permission denied.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             The authentication token was successfully updated.
          </p></dd><dt><span class="term">PAM_USER_UNKNOWN</span></dt><dd><p>
            User unknown to password service.
          </p></dd></dl></div></div></div><div class="section" title="3.1.10. Updating authentication tokens"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_chauthtok"></a>3.1.10. Updating authentication tokens</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_chauthtok</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">flags</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">flags</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.10.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_chauthtok-description"></a>3.1.10.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_chauthtok</code> function is used to change the
      authentication token for a given user (as indicated by the state
      associated with the handle <span class="emphasis"><em>pamh</em></span>).
    </p><p>
      The <span class="emphasis"><em>pamh</em></span> argument is an authentication 
      handle obtained by a prior call to pam_start().
      The flags argument is the binary or of zero or more of the
      following values:
    </p><div class="variablelist"><dl><dt><span class="term">PAM_SILENT</span></dt><dd><p>
             Do not emit any messages.
          </p></dd><dt><span class="term">PAM_CHANGE_EXPIRED_AUTHTOK</span></dt><dd><p>
            This argument indicates to the modules that the users
            authentication token (password) should only be changed
            if it has expired.
            If this argument is not passed, the application requires
            that all authentication tokens are to be changed.
          </p></dd></dl></div></div><div class="section" title="3.1.10.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_chauthtok-return_values"></a>3.1.10.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_AUTHTOK_ERR</span></dt><dd><p>
             A module was unable to obtain the new authentication token.
          </p></dd><dt><span class="term">PAM_AUTHTOK_RECOVERY_ERR</span></dt><dd><p>
             A module was unable to obtain the old authentication token.
          </p></dd><dt><span class="term">PAM_AUTHTOK_LOCK_BUSY</span></dt><dd><p>
             One or more of the modules was unable to change the
             authentication token since it is currently locked.
          </p></dd><dt><span class="term">PAM_AUTHTOK_DISABLE_AGING</span></dt><dd><p>
             Authentication token aging has been disabled for at least
             one of the modules.
          </p></dd><dt><span class="term">PAM_PERM_DENIED</span></dt><dd><p>
             Permission denied.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             The authentication token was successfully updated.
          </p></dd><dt><span class="term">PAM_TRY_AGAIN</span></dt><dd><p>
             Not all of the modules were in a position to update the
             authentication token(s). In such a case none of the user's
             authentication tokens are updated.
          </p></dd><dt><span class="term">PAM_USER_UNKNOWN</span></dt><dd><p>
             User unknown to password service.
          </p></dd></dl></div></div></div><div class="section" title="3.1.11. Start PAM session management"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_open_session"></a>3.1.11. Start PAM session management</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_open_session</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">flags</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">flags</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.11.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_open_session-description"></a>3.1.11.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_open_session</code> function sets up a
      user session for a previously successful authenticated user.
      The session should later be terminated with a call to
      <span class="citerefentry"><span class="refentrytitle">pam_close_session</span>(3)</span>.
    </p><p>
      It should be noted that the effective uid,
      <span class="citerefentry"><span class="refentrytitle">geteuid</span>(2)</span>. of the application should be of sufficient
      privilege to perform such tasks as creating or mounting the
      user's home directory for example.
    </p><p>
      The flags argument is the binary or of zero or more of the
      following values:
    </p><div class="variablelist"><dl><dt><span class="term">PAM_SILENT</span></dt><dd><p>
             Do not emit any messages.
          </p></dd></dl></div></div><div class="section" title="3.1.11.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_open_session-return_values"></a>3.1.11.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_ABORT</span></dt><dd><p>
              General failure.
          </p></dd><dt><span class="term">PAM_BUF_ERR</span></dt><dd><p>
              Memory buffer error.
          </p></dd><dt><span class="term">PAM_SESSION_ERR</span></dt><dd><p>
             Session failure.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             Session was successful created.
          </p></dd></dl></div></div></div><div class="section" title="3.1.12. terminating PAM session management"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_close_session"></a>3.1.12. terminating PAM session management</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_close_session</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">flags</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>int <var class="pdparam">flags</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.12.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_close_session-description"></a>3.1.12.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_close_session</code> function is used
      to indicate that an authenticated session has ended.
      The session should have been created with a call to
      <span class="citerefentry"><span class="refentrytitle">pam_open_session</span>(3)</span>.
    </p><p>
      It should be noted that the effective uid,
      <span class="citerefentry"><span class="refentrytitle">geteuid</span>(2)</span>. of the application should be of sufficient
      privilege to perform such tasks as unmounting the
      user's home directory for example.
    </p><p>
      The flags argument is the binary or of zero or more of the
      following values:
    </p><div class="variablelist"><dl><dt><span class="term">PAM_SILENT</span></dt><dd><p>
             Do not emit any messages.
          </p></dd></dl></div></div><div class="section" title="3.1.12.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_close_session-return_values"></a>3.1.12.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_ABORT</span></dt><dd><p>
              General failure.
          </p></dd><dt><span class="term">PAM_BUF_ERR</span></dt><dd><p>
              Memory buffer error.
          </p></dd><dt><span class="term">PAM_SESSION_ERR</span></dt><dd><p>
             Session failure.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             Session was successful terminated.
          </p></dd></dl></div></div></div><div class="section" title="3.1.13. Set or change PAM environment variable"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_putenv"></a>3.1.13. Set or change PAM environment variable</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">pam_putenv</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">name_value</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>const char *<var class="pdparam">name_value</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.13.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_putenv-description"></a>3.1.13.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_putenv</code> function is used to
      add or change the value of PAM environment variables as
      associated with the <span class="emphasis"><em>pamh</em></span> handle.
    </p><p>
      The <span class="emphasis"><em>pamh</em></span> argument is an authentication
      handle obtained by a prior call to pam_start().
      The <span class="emphasis"><em>name_value</em></span> argument is a single NUL
      terminated string of one of the following forms:
    </p><div class="variablelist"><dl><dt><span class="term">NAME=value of variable</span></dt><dd><p>
             In this case the environment variable of the given NAME
             is set to the indicated value:
             <span class="emphasis"><em>value of variable</em></span>. If this variable
             is already known, it is overwritten. Otherwise it is added
             to the PAM environment.
          </p></dd><dt><span class="term">NAME=</span></dt><dd><p>
            This function sets the variable to an empty value. It is
            listed separately to indicate that this is the correct way
            to achieve such a setting.
          </p></dd><dt><span class="term">NAME</span></dt><dd><p>
            Without an '=' the <code class="function">pam_putenv</code>() function
            will delete the
            corresponding variable from the PAM environment.
          </p></dd></dl></div><p>
      <code class="function">pam_putenv</code>() operates on a copy of
      <span class="emphasis"><em>name_value</em></span>, which means in contrast to
      <span class="citerefentry"><span class="refentrytitle">putenv</span>(3)</span>, the application is responsible to free the data.
    </p></div><div class="section" title="3.1.13.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_putenv-return_values"></a>3.1.13.2. RETURN VALUES</h4></div></div></div><div class="variablelist"><dl><dt><span class="term">PAM_PERM_DENIED</span></dt><dd><p>
             Argument <span class="emphasis"><em>name_value</em></span> given is a NULL pointer.
          </p></dd><dt><span class="term">PAM_BAD_ITEM</span></dt><dd><p>
             Variable requested (for deletion) is not currently set.
          </p></dd><dt><span class="term">PAM_ABORT</span></dt><dd><p>
             The <span class="emphasis"><em>pamh</em></span> handle is corrupt.
          </p></dd><dt><span class="term">PAM_BUF_ERR</span></dt><dd><p>
             Memory buffer error.
          </p></dd><dt><span class="term">PAM_SUCCESS</span></dt><dd><p>
             The environment variable was successfully updated.
          </p></dd></dl></div></div></div><div class="section" title="3.1.14. Get a PAM environment variable"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_getenv"></a>3.1.14. Get a PAM environment variable</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">const char *<b class="fsfunc">pam_getenv</b>(</code></td><td><var class="pdparam">pamh</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">name</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;<br><code>const char *<var class="pdparam">name</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.14.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_getenv-description"></a>3.1.14.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_getenv</code> function searches the
      PAM environment list as associated with the handle
      <span class="emphasis"><em>pamh</em></span> for an item that matches the string
      pointed to by <span class="emphasis"><em>name</em></span> and returns a pointer
      to the value of the environment variable. The application is
      not allowed to free the data.
    </p></div><div class="section" title="3.1.14.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_getenv-return_values"></a>3.1.14.2. RETURN VALUES</h4></div></div></div><p>
      The <code class="function">pam_getenv</code> function returns NULL
      on failure.
    </p></div></div><div class="section" title="3.1.15. Getting the PAM environment"><div class="titlepage"><div><div><h3 class="title"><a name="adg-pam_getenvlist"></a>3.1.15. Getting the PAM environment</h3></div></div></div><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;security/pam_appl.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">char **<b class="fsfunc">pam_getenvlist</b>(</code></td><td><var class="pdparam">pamh</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>pam_handle_t *<var class="pdparam">pamh</var></code>;</div><div class="funcprototype-spacer"> </div></div><div class="section" title="3.1.15.1. DESCRIPTION"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_getenvlist-description"></a>3.1.15.1. DESCRIPTION</h4></div></div></div><p>
      The <code class="function">pam_getenvlist</code> function returns a complete
      copy of the PAM environment as associated with the handle
      <span class="emphasis"><em>pamh</em></span>. The PAM environment variables
      represent the contents of the regular environment variables of the
      authenticated user when service is granted.
    </p><p>
      The format of the memory is a malloc()'d array of char pointers,
      the last element of which is set to NULL. Each of the non-NULL
      entries in this array point to a NUL terminated and malloc()'d
      char string of the form: "<span class="emphasis"><em>name=value</em></span>".
    </p><p>
      It should be noted that this memory will never be free()'d by
      libpam. Once obtained by a call to
      <code class="function">pam_getenvlist</code>, it is the responsibility of
      the calling application to free() this memory.
    </p><p>
      It is by design, and not a coincidence, that the format and contents
      of the returned array matches that required for the third argument of
      the
      <span class="citerefentry"><span class="refentrytitle">execle</span>(3)</span> function call.
    </p></div><div class="section" title="3.1.15.2. RETURN VALUES"><div class="titlepage"><div><div><h4 class="title"><a name="adg-pam_getenvlist-return_values"></a>3.1.15.2. RETURN VALUES</h4></div></div></div><p>
      The <code class="function">pam_getenvlist</code> function returns NULL
      on failure.
    </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="adg-interface.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="adg-interface.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="adg-interface-of-app-expected.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 3. 
      The public interface to <span class="emphasis"><em>Linux-PAM</em></span>
     </td><td width="20%" align="center"><a accesskey="h" href="Linux-PAM_ADG.html">Home</a></td><td width="40%" align="right" valign="top"> 3.2. What is expected of an application</td></tr></table></div></body></html>