]> granicus.if.org Git - linux-pam/blob - doc/man/pam_conv.3
Relevant BUGIDs:
[linux-pam] / doc / man / pam_conv.3
1 .\"     Title: pam_conv
2 .\"    Author: 
3 .\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
4 .\"      Date: 06/19/2006
5 .\"    Manual: Linux\-PAM Manual
6 .\"    Source: Linux\-PAM Manual
7 .\"
8 .TH "PAM_CONV" "3" "06/19/2006" "Linux\-PAM Manual" "Linux\-PAM Manual"
9 .\" disable hyphenation
10 .nh
11 .\" disable justification (adjust text to left margin only)
12 .ad l
13 .SH "NAME"
14 pam_conv \- PAM conversation function
15 .SH "SYNOPSIS"
16 .sp
17 .ft B
18 .nf
19 #include <security/pam_appl.h>
20 .fi
21 .ft
22 .sp
23 .RS 3n
24 .nf
25 struct pam_message {
26     int msg_style;
27     const char *msg;
28 };
29
30 struct pam_response {
31     char *resp;
32     int resp_retcode;
33 };
34
35 struct pam_conv {
36     int (*conv)(int num_msg, const struct pam_message **msg,
37                 struct pam_response **resp, void *appdata_ptr);
38     void *appdata_ptr;
39 };
40     
41 .fi
42 .RE
43 .SH "DESCRIPTION"
44 .PP
45 The PAM library uses an application\-defined callback to allow a direct communication between a loaded module and the application. This callback is specified by the
46 \fIstruct pam_conv\fR
47 passed to
48 \fBpam_start\fR(3)
49 at the start of the transaction.
50 .PP
51 When a module calls the referenced conv() function, the argument
52 \fIappdata_ptr\fR
53 is set to the second element of this structure.
54 .PP
55 The other arguments of a call to conv() concern the information exchanged by module and application. That is to say,
56 \fInum_msg\fR
57 holds the length of the array of pointers,
58 \fImsg\fR. After a successful return, the pointer
59 \fIresp\fR
60 points to an array of pam_response structures, holding the application supplied text. The
61 \fIresp_retcode\fR
62 member of this struct is unused and should be set to zero. It is the caller's responsibility to release both, this array and the responses themselves, using
63 \fBfree\fR(3). Note,
64 \fI*resp\fR
65 is a
66 \fIstruct pam_response\fR
67 array and not an array of pointers.
68 .PP
69 The number of responses is always equal to the
70 \fInum_msg\fR
71 conversation function argument. This does require that the response array is
72 \fBfree\fR(3)'d after every call to the conversation function. The index of the responses corresponds directly to the prompt index in the pam_message array.
73 .PP
74 On failure, the conversation function should release any resources it has allocated, and return one of the predefined PAM error codes.
75 .PP
76 Each message can have one of four types, specified by the
77 \fImsg_style\fR
78 member of
79 \fIstruct pam_message\fR:
80 .TP 3n
81 PAM_PROMPT_ECHO_OFF
82 Obtain a string without echoing any text.
83 .TP 3n
84 PAM_PROMPT_ECHO_ON
85 Obtain a string whilst echoing text.
86 .TP 3n
87 PAM_ERROR_MSG
88 Display an error message.
89 .TP 3n
90 PAM_TEXT_INFO
91 Display some text.
92 .PP
93 The point of having an array of messages is that it becomes possible to pass a number of things to the application in a single call from the module. It can also be convenient for the application that related things come at once: a windows based application can then present a single form with many messages/prompts on at once.
94 .PP
95 In passing, it is worth noting that there is a descrepency between the way Linux\-PAM handles the const struct pam_message **msg conversation function argument from the way that Solaris' PAM (and derivitives, known to include HP/UX, are there others?) does. Linux\-PAM interprets the msg argument as entirely equivalent to the following prototype const struct pam_message *msg[] (which, in spirit, is consistent with the commonly used prototypes for argv argument to the familiar main() function: char **argv; and char *argv[]). Said another way Linux\-PAM interprets the msg argument as a pointer to an array of num_meg read only 'struct pam_message' pointers. Solaris' PAM implementation interprets this argument as a pointer to a pointer to an array of num_meg pam_message structures. Fortunately, perhaps, for most module/application developers when num_msg has a value of one these two definitions are entirely equivalent. Unfortunately, casually raising this number to two has led to unanticipated compatibility problems.
96 .PP
97 For what its worth the two known module writer work\-arounds for trying to maintain source level compatibility with both PAM implementations are:
98 .TP 3n
99 \(bu
100 never call the conversation function with num_msg greater than one.
101 .TP 3n
102 \(bu
103 set up msg as doubly referenced so both types of conversation function can find the messages. That is, make
104 .sp
105 .RS 3n
106 .nf
107        msg[n] = & (( *msg )[n])
108        
109 .fi
110 .RE
111 .SH "RETURN VALUES"
112 .TP 3n
113 PAM_BUF_ERR
114 Memory buffer error.
115 .TP 3n
116 PAM_CONV_ERR
117 Conversation failure. The application should not set
118 \fI*resp\fR.
119 .TP 3n
120 PAM_SUCCESS
121 Success.
122 .SH "SEE ALSO"
123 .PP
124
125 \fBpam_start\fR(3),
126 \fBpam_set_item\fR(3),
127 \fBpam_get_item\fR(3),
128 \fBpam_strerror\fR(3),
129 \fBpam\fR(8)