#include <mysql/client_plugin.h>
-
+#include <mysql.h>
/**
Callback type for functions that prompt the user for (echoed or silent) input
and return it. Should returns a pointer to malloc-allocated string, the
caller is responsible for freeing it. Should return NULL in the case of a
memory allocation or I/O error. */
typedef char* (*prompt_fn)(const char *);
+typedef char* (*prompt_fn_off)(const char *, MYSQL *);
/**
Callback type for functions that show user some info (error or notification).
@@ -68,7 +69,7 @@
*/
int authenticate_user_with_pam_client_common (MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql,
- prompt_fn echoless_prompt_fn,
+ prompt_fn_off echoless_prompt_fn, prompt_fn echo_prompt_fn, info_fn show_error_fn, info_fn show_info_fn);
--- test_auth_pam_client.c 2012-01-06 15:50:52.000000000 -0500
+++ ../mysql-pam-auth-plugin.new/test_auth_pam_client.c 2012-01-23 13:43:18.000000000 -0500
@@ -55,7 +55,7 @@
{
}
-static int test_pam_auth_client (MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql)
+static int test_pam_auth_client (MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
{
return authenticate_user_with_pam_client_common (vio, mysql, &test_prompt_echo_off,
Here is my hack to make it work with the clients.
--- auth_pam.c 2012-01-23 14:08:16.000000000 -0500 pam-auth- plugin. new/auth_ pam.c 2012-01-23 14:02:18.000000000 -0500
+++ ../mysql-
@@ -320,11 +320,16 @@
/* The client plugin */
+#include <mysql.h> mysql-> passwd) > 0 ) { mysql-> passwd) ; getpass_ input);
+
/* Returns malloc-allocated string, NULL in case of memory error. */
-static char * prompt_echo_off (const char * prompt)
+static char * prompt_echo_off (const char * prompt, MYSQL *mysql)
{
/* TODO: getpass not thread safe. Probably not a big deal in the mysql
client program, but may be missing on non-glibc systems. */
+ if ( strlen(
+ return strdup(
+ }
char* getpass_input= getpass(prompt);
return strdup(
}
@@ -362,7 +367,7 @@
}
static int authenticate_ user_with_ pam_client (MYSQL_PLUGIN_VIO *vio, user_with_ pam_client_ common (vio, mysql,
&prompt_ echo_off, pam_client. c 2012-01-23 14:12:53.000000000 -0500 pam-auth- plugin. new/lib_ auth_pam_ client. c 2012-01-23 14:11:58.000000000 -0500
- struct st_mysql *mysql)
+ MYSQL *mysql)
{
return authenticate_
--- lib_auth_
+++ ../mysql-
@@ -27,11 +27,13 @@
#include <assert.h>
#include <string.h>
+ UNREACHABLE( ) assert(0)
#define MY_ASSERT_
int authenticate_ user_with_ pam_client_ common (MYSQL_PLUGIN_VIO *vio, _((unused) ), _((unused) ), */
prompt_ fn echo_prompt_fn,
info_ fn show_error_fn,
info_ fn show_info_fn) ECHO_OFF, '\3' - PAM_PROMPT_ECHO_ON */ prompt_ fn(&buf[ 1]) : echo_prompt_ fn(&buf[ 1]); prompt_ fn(&buf[ 1], mysql) : echo_prompt_ fn(&buf[ 1]); packet( vio, (unsigned char *)reply, strlen(reply) + 1))
show_error_ fn(&buf[ 1]);
show_info_ fn(&buf[ 1]); authorization */ authorization */ pam_client. h 2012-01-06 15:50:52.000000000 -0500 pam-auth- plugin. new/lib_ auth_pam_ client. h 2012-01-23 11:47:04.000000000 -0500
- struct st_mysql *mysql __attribute_
- prompt_fn echoless_prompt_fn,
+ /* struct st_mysql *mysql __attribute_
+ MYSQL *mysql,
+ prompt_fn_off echoless_prompt_fn,
@@ -50,7 +52,7 @@
{
/* '\2' - PAM_PROMPT_
char *reply = (buf[0] == '\2')
- ? echoless_
+ ? echoless_
if (!reply)
return CR_ERROR;
if (vio->write_
@@ -64,7 +66,7 @@
else if (buf[0] == '\5') /* PAM_TEXT_INFO */
- else if (buf[0] == '\0') /* end-of-
+ else if (buf[0] == '\0') /* end-of-
return CR_OK;
else
return CR_ERROR; /* Unknown! */
--- lib_auth_
+++ ../mysql-
@@ -28,13 +28,14 @@
#define STDCALL
#include <mysql/ client_ plugin. h> fn_off) (const char *, MYSQL *);
-
+#include <mysql.h>
/**
Callback type for functions that prompt the user for (echoed or silent) input
and return it. Should returns a pointer to malloc-allocated string, the
caller is responsible for freeing it. Should return NULL in the case of a
memory allocation or I/O error. */
typedef char* (*prompt_fn)(const char *);
+typedef char* (*prompt_
/** user_with_ pam_client_ common (MYSQL_PLUGIN_VIO *vio,
struct st_mysql *mysql,
prompt_ fn echo_prompt_fn,
info_ fn show_error_fn,
info_ fn show_info_fn); pam_client. c 2012-01-06 15:50:52.000000000 -0500 pam-auth- plugin. new/test_ auth_pam_ client. c 2012-01-23 13:43:18.000000000 -0500
Callback type for functions that show user some info (error or notification).
@@ -68,7 +69,7 @@
*/
int authenticate_
- prompt_fn echoless_prompt_fn,
+ prompt_fn_off echoless_prompt_fn,
--- test_auth_
+++ ../mysql-
@@ -55,7 +55,7 @@
{
}
-static int test_pam_ auth_client (MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql) auth_client (MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) user_with_ pam_client_ common (vio, mysql,
&test_ prompt_ echo_off,
+static int test_pam_
{
return authenticate_