Debian Codegraph @

upstream/debian-unstable/man3/pam_conv.3

raw
1 '\" t
2 .\" Title: pam_conv
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
5 .\" Date: 06/29/2025
6 .\" Manual: Linux-PAM Manual
7 .\" Source: Linux-PAM
8 .\" Language: English
9 .\"
10 .TH "PAM_CONV" "3" "06/29/2025" "Linux\-PAM" "Linux\-PAM Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 pam_conv \- PAM conversation function
32 .SH "SYNOPSIS"
33 .sp
34 .ft B
35 .nf
36 #include <security/pam_appl\&.h>
37 .fi
38 .ft
39 .sp
40 .nf
41 struct pam_message {
42 int msg_style;
43 const char *msg;
44 };
45
46 struct pam_response {
47 char *resp;
48 int resp_retcode;
49 };
50
51 struct pam_conv {
52 int (*conv)(int num_msg, const struct pam_message **msg,
53 struct pam_response **resp, void *appdata_ptr);
54 void *appdata_ptr;
55 };
56
57 .fi
58 .SH "DESCRIPTION"
59 .PP
60 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
61 \fIstruct pam_conv\fR
62 passed to
63 \fBpam_start\fR(3)
64 at the start of the transaction\&.
65 .PP
66 When a module calls the referenced conv() function, the argument
67 \fIappdata_ptr\fR
68 is set to the second element of this structure\&.
69 .PP
70 The other arguments of a call to conv() concern the information exchanged by module and application\&. That is to say,
71 \fInum_msg\fR
72 holds the length of the array of pointers,
73 \fImsg\fR\&. After a successful return, the pointer
74 \fIresp\fR
75 points to an array of pam_response structures, holding the application supplied text\&. The
76 \fIresp_retcode\fR
77 member of this struct is unused and should be set to zero\&. It is the caller\*(Aqs responsibility to release both, this array and the responses themselves, using
78 \fBfree\fR(3)\&. Note,
79 \fI*resp\fR
80 is a
81 \fIstruct pam_response\fR
82 array and not an array of pointers\&.
83 .PP
84 The number of responses is always equal to the
85 \fInum_msg\fR
86 conversation function argument\&. This does require that the response array is
87 \fBfree\fR(3)\*(Aqd after every call to the conversation function\&. The index of the responses corresponds directly to the prompt index in the pam_message array\&.
88 .PP
89 On failure, the conversation function should release any resources it has allocated, and return one of the predefined PAM error codes\&.
90 .PP
91 Each message can have one of four types, specified by the
92 \fImsg_style\fR
93 member of
94 \fIstruct pam_message\fR:
95 .PP
96 PAM_PROMPT_ECHO_OFF
97 .RS 4
98 Obtain a string without echoing any text\&.
99 .RE
100 .PP
101 PAM_PROMPT_ECHO_ON
102 .RS 4
103 Obtain a string whilst echoing text\&.
104 .RE
105 .PP
106 PAM_ERROR_MSG
107 .RS 4
108 Display an error message\&.
109 .RE
110 .PP
111 PAM_TEXT_INFO
112 .RS 4
113 Display some text\&.
114 .RE
115 .PP
116 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\&.
117 .PP
118 In passing, it is worth noting that there is a discrepancy between the way Linux\-PAM handles the const struct pam_message **msg conversation function argument and the way that Solaris\*(Aq PAM (and derivatives, 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_msg read only \*(Aqstruct pam_message\*(Aq pointers\&. Solaris\*(Aq PAM implementation interprets this argument as a pointer to a pointer to an array of num_msg 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\&.
119 .PP
120 For what its worth the two known module writer work\-arounds for trying to maintain source level compatibility with both PAM implementations are:
121 .sp
122 .RS 4
123 .ie n \{\
124 \h'-04'\(bu\h'+03'\c
125 .\}
126 .el \{\
127 .sp -1
128 .IP \(bu 2.3
129 .\}
130 never call the conversation function with num_msg greater than one\&.
131 .RE
132 .sp
133 .RS 4
134 .ie n \{\
135 \h'-04'\(bu\h'+03'\c
136 .\}
137 .el \{\
138 .sp -1
139 .IP \(bu 2.3
140 .\}
141 set up msg as doubly referenced so both types of conversation function can find the messages\&. That is, make
142 .sp
143 .if n \{\
144 .RS 4
145 .\}
146 .nf
147 msg[n] = & (( *msg )[n])
148
149 .fi
150 .if n \{\
151 .RE
152 .\}
153 .RE
154 .SH "RETURN VALUES"
155 .PP
156 PAM_BUF_ERR
157 .RS 4
158 Memory buffer error\&.
159 .RE
160 .PP
161 PAM_CONV_ERR
162 .RS 4
163 Conversation failure\&. The application should not set
164 \fI*resp\fR\&.
165 .RE
166 .PP
167 PAM_SUCCESS
168 .RS 4
169 Success\&.
170 .RE
171 .SH "SEE ALSO"
172 .PP
173 \fBpam_start\fR(3),
174 \fBpam_set_item\fR(3),
175 \fBpam_get_item\fR(3),
176 \fBpam_strerror\fR(3),
177 \fBpam\fR(7)