MySQL 9.1.0
Source Code Documentation
|
dialog client authentication plugin with examples More...
#include "my_config.h"
#include <mysql.h>
#include <mysql/client_plugin.h>
#include <mysql/plugin_auth.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "my_compiler.h"
#include <dlfcn.h>
Macros | |
#define | _GNU_SOURCE /* for RTLD_DEFAULT */ |
#define | ORDINARY_QUESTION "\2" |
first byte of the question string is the question "type". More... | |
#define | LAST_QUESTION "\3" |
#define | PASSWORD_QUESTION "\4" |
#define | LAST_PASSWORD "\5" |
Typedefs | |
typedef char *(* | mysql_authentication_dialog_ask_t) (MYSQL *mysql, int type, const char *prompt, char *buf, int buf_len) |
type of the mysql_authentication_dialog_ask function More... | |
Functions | |
static int | two_questions (MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) |
dialog demo with two questions, one password and one, the last, ordinary. More... | |
static int | generate_auth_string_hash (char *outbuf, unsigned int *buflen, const char *inbuf, unsigned int inbuflen) |
static int | validate_auth_string_hash (char *const inbuf, unsigned int buflen) |
static int | set_salt (const char *password, unsigned int password_len, unsigned char *salt, unsigned char *salt_len) |
static int | three_attempts (MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) |
mysql_declare_plugin (dialog) | |
static char * | builtin_ask (MYSQL *mysql, int type, const char *prompt, char *buf, int buf_len) |
static int | perform_dialog (MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) |
The main function of the dialog plugin. More... | |
static int | init_dialog (char *unused1, size_t unused2, int unused3, va_list unused4) |
initialization function of the dialog plugin More... | |
mysql_declare_client_plugin (AUTHENTICATION) "dialog" | |
Variables | |
static struct st_mysql_auth | two_handler |
static struct st_mysql_auth | three_handler |
static mysql_authentication_dialog_ask_t | ask |
MYSQL_CLIENT_PLUGIN_AUTHOR_ORACLE | |
Dialog Client Authentication | Plugin |
Dialog Client Authentication | GPL |
Dialog Client Authentication | nullptr |
Dialog Client Authentication | init_dialog |
Dialog Client Authentication | perform_dialog |
Dialog Client Authentication | mysql_end_client_plugin |
dialog client authentication plugin with examples
dialog is a general purpose client authentication plugin, it simply asks the user the question, as provided by the server and reports the answer back to the server. No encryption is involved, the answers are sent in clear text.
Two examples are provided: two_questions server plugin, that asks the password and an "Are you sure?" question with a reply "yes, of course". It demonstrates the usage of "password" (input is hidden) and "ordinary" (input can be echoed) questions, and how to mark the last question, to avoid an extra roundtrip.
And three_attempts plugin that gives the user three attempts to enter a correct password. It shows the situation when a number of questions is not known in advance.
#define _GNU_SOURCE /* for RTLD_DEFAULT */ |
#define LAST_PASSWORD "\5" |
#define LAST_QUESTION "\3" |
#define ORDINARY_QUESTION "\2" |
first byte of the question string is the question "type".
It can be an "ordinary" or a "password" question. The last bit set marks a last question in the authentication exchange.
#define PASSWORD_QUESTION "\4" |
typedef char *(* mysql_authentication_dialog_ask_t) (MYSQL *mysql, int type, const char *prompt, char *buf, int buf_len) |
type of the mysql_authentication_dialog_ask function
mysql | mysql |
type | type of the input 1 - ordinary string input 2 - password string |
prompt | prompt |
buf | a buffer to store the use input |
buf_len | the length of the buffer |
a | pointer to the user input string. It may be equal to 'buf' or to 'mysql->password'. In all other cases it is assumed to be an allocated string, and the "dialog" plugin will free() it. |
|
static |
|
static |
|
static |
initialization function of the dialog plugin
Pick up the client's authentication_dialog_ask() function, if exists, or fall back to the default implementation.
mysql_declare_client_plugin | ( | AUTHENTICATION | ) |
mysql_declare_plugin | ( | dialog | ) |
|
static |
The main function of the dialog plugin.
Read the prompt, ask the question, send the reply, repeat until the server is satisfied.
|
static |
|
static |
|
static |
dialog demo with two questions, one password and one, the last, ordinary.
|
static |
|
static |
Dialog Client Authentication GPL |
Dialog Client Authentication init_dialog |
MYSQL_CLIENT_PLUGIN_AUTHOR_ORACLE |
Dialog Client Authentication mysql_end_client_plugin |
Dialog Client Authentication nullptr |
Dialog Client Authentication perform_dialog |
Dialog Client Authentication Plugin |
|
static |
|
static |