1 #ifndef LIB_AUTH_PAM_CLIENT_INCLUDED
2 #define LIB_AUTH_PAM_CLIENT_INCLUDED
3 /*
4   (C) 2011 Percona Inc.
5 
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; version 2 of the License.
9 
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18 */
19 
20 /**
21  @file
22 
23  PAM authentication for MySQL, common definitions for client-side plugins.
24 
25  For the general description, see the top comment in auth_pam.c.
26 */
27 
28 #define STDCALL
29 
30 #include <mysql/client_plugin.h>
31 
32 /**
33  Callback type for functions that prompt the user for (echoed or silent) input
34  and return it.  Should returns a pointer to malloc-allocated string, the
35  caller is responsible for freeing it.  Should return NULL in the case of a
36  memory allocation or I/O error. */
37 typedef char* (*prompt_fn)(const char *);
38 
39 /**
40  Callback type for functions that show user some info (error or notification).
41 */
42 typedef void (*info_fn)(const char *);
43 
44 struct st_mysql;
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /**
51  Client-side PAM auth plugin implementation.
52 
53  Communicates with the server-side plugin and does user interaction using the
54  provided callbacks.
55 
56  @param vio TODO
57  @param mysql TODO
58  @param echoless_prompt_fn callback to use to prompt the user for non-echoed
59                            input (e.g. password)
60  @param echo_prompt_fn callback to use to prompt the user for echoed input
61                        (e.g. user name)
62  @param show_error_fn callback to use to show the user an error message
63  @param show_info_fn callback to use to show the user an informational message
64 
65  @return Authentication conversation status
66    @retval CR_OK the authentication dialog is completed successfully
67    @retval CR_ERROR the authentication dialog is aborted due to error
68 */
69 int authenticate_user_with_pam_client_common (MYSQL_PLUGIN_VIO *vio,
70                                               struct st_mysql *mysql,
71                                               prompt_fn echoless_prompt_fn,
72                                               prompt_fn echo_prompt_fn,
73                                               info_fn show_error_fn,
74                                               info_fn show_info_fn);
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif
81