1PAM_CONV(3)                    Linux-PAM Manual                    PAM_CONV(3)
2
3
4

NAME

6       pam_conv - PAM conversation function
7

SYNOPSIS

9       #include <security/pam_appl.h>
10
11       struct pam_message {
12           int msg_style;
13           const char *msg;
14       };
15
16       struct pam_response {
17           char *resp;
18           int resp_retcode;
19       };
20
21       struct pam_conv {
22           int (*conv)(int num_msg, const struct pam_message **msg,
23                       struct pam_response **resp, void *appdata_ptr);
24           void *appdata_ptr;
25       };
26
27

DESCRIPTION

29       The PAM library uses an application-defined callback to allow a direct
30       communication between a loaded module and the application. This
31       callback is specified by the struct pam_conv passed to pam_start(3) at
32       the start of the transaction.
33
34       When a module calls the referenced conv() function, the argument
35       appdata_ptr is set to the second element of this structure.
36
37       The other arguments of a call to conv() concern the information
38       exchanged by module and application. That is to say, num_msg holds the
39       length of the array of pointers, msg. After a successful return, the
40       pointer resp points to an array of pam_response structures, holding the
41       application supplied text. The resp_retcode member of this struct is
42       unused and should be set to zero. It is the caller's responsibility to
43       release both, this array and the responses themselves, using free(3).
44       Note, *resp is a struct pam_response array and not an array of
45       pointers.
46
47       The number of responses is always equal to the num_msg conversation
48       function argument. This does require that the response array is
49       free(3)'d after every call to the conversation function. The index of
50       the responses corresponds directly to the prompt index in the
51       pam_message array.
52
53       On failure, the conversation function should release any resources it
54       has allocated, and return one of the predefined PAM error codes.
55
56       Each message can have one of four types, specified by the msg_style
57       member of struct pam_message:
58
59       PAM_PROMPT_ECHO_OFF
60           Obtain a string without echoing any text.
61
62       PAM_PROMPT_ECHO_ON
63           Obtain a string whilst echoing text.
64
65       PAM_ERROR_MSG
66           Display an error message.
67
68       PAM_TEXT_INFO
69           Display some text.
70
71       The point of having an array of messages is that it becomes possible to
72       pass a number of things to the application in a single call from the
73       module. It can also be convenient for the application that related
74       things come at once: a windows based application can then present a
75       single form with many messages/prompts on at once.
76
77       In passing, it is worth noting that there is a discrepancy between the
78       way Linux-PAM handles the const struct pam_message **msg conversation
79       function argument and the way that Solaris' PAM (and derivatives, known
80       to include HP/UX, are there others?) does. Linux-PAM interprets the msg
81       argument as entirely equivalent to the following prototype const struct
82       pam_message *msg[] (which, in spirit, is consistent with the commonly
83       used prototypes for argv argument to the familiar main() function: char
84       **argv; and char *argv[]). Said another way Linux-PAM interprets the
85       msg argument as a pointer to an array of num_msg read only 'struct
86       pam_message' pointers. Solaris' PAM implementation interprets this
87       argument as a pointer to a pointer to an array of num_msg pam_message
88       structures. Fortunately, perhaps, for most module/application
89       developers when num_msg has a value of one these two definitions are
90       entirely equivalent. Unfortunately, casually raising this number to two
91       has led to unanticipated compatibility problems.
92
93       For what its worth the two known module writer work-arounds for trying
94       to maintain source level compatibility with both PAM implementations
95       are:
96
97       •   never call the conversation function with num_msg greater than one.
98
99       •   set up msg as doubly referenced so both types of conversation
100           function can find the messages. That is, make
101
102                      msg[n] = & (( *msg )[n])
103
104

RETURN VALUES

106       PAM_BUF_ERR
107           Memory buffer error.
108
109       PAM_CONV_ERR
110           Conversation failure. The application should not set *resp.
111
112       PAM_SUCCESS
113           Success.
114

SEE ALSO

116       pam_start(3), pam_set_item(3), pam_get_item(3), pam_strerror(3), pam(8)
117
118
119
120Linux-PAM                         05/07/2023                       PAM_CONV(3)
Impressum