xref: /netbsd-src/external/bsd/openpam/dist/doc/man/pam_conv.3 (revision 0d9d0fd8a30be9a1924e715bbcf67a4a83efd262)
1*0d9d0fd8Schristos.\"	$NetBSD: pam_conv.3,v 1.10 2023/06/30 21:46:20 christos Exp $
244269bb5Schristos.\"
344269bb5Schristos.\"-
444269bb5Schristos.\" Copyright (c) 2002-2003 Networks Associates Technology, Inc.
54cb4af11Schristos.\" Copyright (c) 2004-2017 Dag-Erling Smørgrav
644269bb5Schristos.\" All rights reserved.
744269bb5Schristos.\"
844269bb5Schristos.\" This software was developed for the FreeBSD Project by ThinkSec AS and
944269bb5Schristos.\" Network Associates Laboratories, the Security Research Division of
1044269bb5Schristos.\" Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
1144269bb5Schristos.\" ("CBOSS"), as part of the DARPA CHATS research program.
1244269bb5Schristos.\"
1344269bb5Schristos.\" Redistribution and use in source and binary forms, with or without
1444269bb5Schristos.\" modification, are permitted provided that the following conditions
1544269bb5Schristos.\" are met:
1644269bb5Schristos.\" 1. Redistributions of source code must retain the above copyright
1744269bb5Schristos.\"    notice, this list of conditions and the following disclaimer.
1844269bb5Schristos.\" 2. Redistributions in binary form must reproduce the above copyright
1944269bb5Schristos.\"    notice, this list of conditions and the following disclaimer in the
2044269bb5Schristos.\"    documentation and/or other materials provided with the distribution.
2144269bb5Schristos.\" 3. The name of the author may not be used to endorse or promote
2244269bb5Schristos.\"    products derived from this software without specific prior written
2344269bb5Schristos.\"    permission.
2444269bb5Schristos.\"
2544269bb5Schristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2644269bb5Schristos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2744269bb5Schristos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2844269bb5Schristos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2944269bb5Schristos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3044269bb5Schristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3144269bb5Schristos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3244269bb5Schristos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3344269bb5Schristos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3444269bb5Schristos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3544269bb5Schristos.\" SUCH DAMAGE.
3644269bb5Schristos.\"
37*0d9d0fd8Schristos.Dd June 27, 2023
3844269bb5Schristos.Dt PAM_CONV 3
3944269bb5Schristos.Os
4044269bb5Schristos.Sh NAME
4144269bb5Schristos.Nm pam_conv
4244269bb5Schristos.Nd PAM conversation system
4344269bb5Schristos.Sh LIBRARY
4444269bb5Schristos.Lb libpam
4544269bb5Schristos.Sh SYNOPSIS
4644269bb5Schristos.In security/pam_appl.h
4744269bb5Schristos.Bd -literal
4844269bb5Schristosstruct pam_message {
4944269bb5Schristos	int      msg_style;
5044269bb5Schristos	char    *msg;
5144269bb5Schristos};
5244269bb5Schristos
5344269bb5Schristosstruct pam_response {
5444269bb5Schristos	char    *resp;
5544269bb5Schristos	int      resp_retcode;
5644269bb5Schristos};
5744269bb5Schristos
5844269bb5Schristosstruct pam_conv {
5944269bb5Schristos	int     (*conv)(int, const struct pam_message **,
6044269bb5Schristos	    struct pam_response **, void *);
6144269bb5Schristos	void    *appdata_ptr;
6244269bb5Schristos};
6344269bb5Schristos.Ed
6444269bb5Schristos.Sh DESCRIPTION
6544269bb5SchristosThe PAM library uses an application-defined callback to communicate
6644269bb5Schristoswith the user.
6744269bb5SchristosThis callback is specified by the
6844269bb5Schristos.Vt struct pam_conv
6944269bb5Schristospassed to
7044269bb5Schristos.Fn pam_start
7144269bb5Schristosat the start of the transaction.
7244269bb5SchristosIt is also possible to set or change the conversation function at any
7344269bb5Schristospoint during a PAM transaction by changing the value of the
7444269bb5Schristos.Dv PAM_CONV
7544269bb5Schristositem.
7644269bb5Schristos.Pp
7744269bb5SchristosThe conversation function's first argument specifies the number of
7844269bb5Schristosmessages (up to
79201780c4Schristos.Dv PAM_MAX_NUM_MSG )
8044269bb5Schristosto process.
8144269bb5SchristosThe second argument is a pointer to an array of pointers to
8244269bb5Schristos.Vt pam_message
8344269bb5Schristosstructures containing the actual messages.
8444269bb5Schristos.Pp
8544269bb5SchristosEach message can have one of four types, specified by the
8644269bb5Schristos.Va msg_style
8744269bb5Schristosmember of
8844269bb5Schristos.Vt struct pam_message :
8944269bb5Schristos.Bl -tag -width 18n
9044269bb5Schristos.It Dv PAM_PROMPT_ECHO_OFF
9144269bb5SchristosDisplay a prompt and accept the user's response without echoing it to
9244269bb5Schristosthe terminal.
9344269bb5SchristosThis is commonly used for passwords.
9444269bb5Schristos.It Dv PAM_PROMPT_ECHO_ON
9544269bb5SchristosDisplay a prompt and accept the user's response, echoing it to the
9644269bb5Schristosterminal.
9744269bb5SchristosThis is commonly used for login names and one-time passphrases.
9844269bb5Schristos.It Dv PAM_ERROR_MSG
9944269bb5SchristosDisplay an error message.
10044269bb5Schristos.It Dv PAM_TEXT_INFO
10144269bb5SchristosDisplay an informational message.
10244269bb5Schristos.El
10344269bb5Schristos.Pp
10444269bb5SchristosIn each case, the prompt or message to display is pointed to by the
10544269bb5Schristos.Va msg
10644269bb5Schristosmember of
10744269bb5Schristos.Vt struct pam_message .
10844269bb5SchristosIt can be up to
10944269bb5Schristos.Dv PAM_MAX_MSG_SIZE
11044269bb5Schristoscharacters long, including the terminating NUL.
11144269bb5Schristos.Pp
11244269bb5SchristosOn success, the conversation function should allocate and fill a
11344269bb5Schristoscontiguous array of
11444269bb5Schristos.Vt struct pam_response ,
11544269bb5Schristosone for each message that was passed in.
11644269bb5SchristosA pointer to the user's response to each message (or
11744269bb5Schristos.Dv NULL
11844269bb5Schristosin the case of informational or error messages) should be stored in
11944269bb5Schristosthe
12044269bb5Schristos.Va resp
12144269bb5Schristosmember of the corresponding
12244269bb5Schristos.Vt struct pam_response .
12344269bb5SchristosEach response can be up to
12444269bb5Schristos.Dv PAM_MAX_RESP_SIZE
12544269bb5Schristoscharacters long, including the terminating NUL.
12644269bb5Schristos.Pp
12744269bb5SchristosThe
12844269bb5Schristos.Va resp_retcode
12944269bb5Schristosmember of
13044269bb5Schristos.Vt struct pam_response
13144269bb5Schristosis unused and should be set to zero.
13244269bb5Schristos.Pp
13344269bb5SchristosThe conversation function should store a pointer to this array in the
13444269bb5Schristoslocation pointed to by its third argument.
13544269bb5SchristosIt is the caller's responsibility to release both this array and the
13644269bb5Schristosresponses themselves, using
13744269bb5Schristos.Xr free 3 .
13844269bb5SchristosIt is the conversation function's responsibility to ensure that it is
13944269bb5Schristoslegal to do so.
14044269bb5Schristos.Pp
14144269bb5SchristosThe
14244269bb5Schristos.Va appdata_ptr
14344269bb5Schristosmember of
14444269bb5Schristos.Vt struct pam_conv
14544269bb5Schristosis passed unmodified to the conversation function as its fourth and
14644269bb5Schristosfinal argument.
14744269bb5Schristos.Pp
14844269bb5SchristosOn failure, the conversation function should release any resources it
14944269bb5Schristoshas allocated, and return one of the predefined PAM error codes.
15044269bb5Schristos.Sh RETURN VALUES
15144269bb5SchristosThe conversation function should return one of the following values:
15244269bb5Schristos.Bl -tag -width 18n
15344269bb5Schristos.It Bq Er PAM_BUF_ERR
15444269bb5SchristosMemory buffer error.
15544269bb5Schristos.It Bq Er PAM_CONV_ERR
15644269bb5SchristosConversation failure.
15744269bb5Schristos.It Bq Er PAM_SUCCESS
15844269bb5SchristosSuccess.
15944269bb5Schristos.It Bq Er PAM_SYSTEM_ERR
16044269bb5SchristosSystem error.
16144269bb5Schristos.El
16244269bb5Schristos.Sh SEE ALSO
16344269bb5Schristos.Xr openpam_nullconv 3 ,
16444269bb5Schristos.Xr openpam_ttyconv 3 ,
16544269bb5Schristos.Xr pam 3 ,
16644269bb5Schristos.Xr pam_error 3 ,
16744269bb5Schristos.Xr pam_get_item 3 ,
16844269bb5Schristos.Xr pam_info 3 ,
16944269bb5Schristos.Xr pam_prompt 3 ,
17044269bb5Schristos.Xr pam_set_item 3 ,
17144269bb5Schristos.Xr pam_start 3
17244269bb5Schristos.Sh STANDARDS
17344269bb5Schristos.Rs
17444269bb5Schristos.%T "X/Open Single Sign-On Service (XSSO) - Pluggable Authentication Modules"
17544269bb5Schristos.%D "June 1997"
17644269bb5Schristos.Re
17744269bb5Schristos.Sh AUTHORS
17844269bb5SchristosThe OpenPAM library and this manual page were developed for the
1791ae23164Schristos.Fx
1801ae23164SchristosProject by ThinkSec AS and Network Associates Laboratories,
1811ae23164Schristosthe Security Research Division of Network Associates, Inc. under
18244269bb5SchristosDARPA/SPAWAR contract N66001-01-C-8035
18344269bb5Schristos.Pq Dq CBOSS ,
18444269bb5Schristosas part of the DARPA CHATS research program.
185e1b25b17Schristos.Pp
186e1b25b17SchristosThe OpenPAM library is maintained by
187a5684d07Swiz.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no .
188