|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-10-22 05:58 UTC] roberto at spadim dot com dot br
Description: ------------ Hi guys, i'm testing mysql connect with a mariadb server using a dialog auth plugin (server side) i didn't found functions to execute dialog with server a full example of what i want but using heidisql can be found here: http://www.heidisql.com/forum.php?t=9752 --- here the php files (download only .php files): https://github.com/rspadim/server/blob/otp_plugin/plugin/auth_otp/ here the today output using mysql_connect: (using otp_auth_example.php php file) ============================== MYSQL_CONNECT: PHP Warning: mysql_connect(): The server requested authentication method unknown to the client [dialog] in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_e xample.php on line 50 Warning: mysql_connect(): The server requested authentication method unknown to the client [dialog] in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_exampl e.php on line 50 PHP Warning: mysql_connect(): The server requested authentication method umknown to the client in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_example.ph p on line 50 Warning: mysql_connect(): The server requested authentication method umknown to the client in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_example.php on line 50 Error: The server requested authentication method >>>umknown<<< to the client (CHECK A TYPO ERROR) ============================== MYSQI_CONNECT: C:\GIT\mariadb-tmp\server\plugin\auth_otp>php otp_auth_example.php PHP Warning: mysqli_connect(): The server requested authentication method unknown to the client [dialog] in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_ example.php on line 60 Warning: mysqli_connect(): The server requested authentication method unknown to the client [dialog] in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_examp le.php on line 60 PHP Warning: mysqli_connect(): (HY000/2054): The server requested authentication method umknown to the client in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_ auth_example.php on line 60 Warning: mysqli_connect(): (HY000/2054): The server requested authentication method umknown to the client in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_ example.php on line 60 PHP Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_example.php on line 62 Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_example.php on line 62 Error: =============================== PDO: C:\GIT\mariadb-tmp\server\plugin\auth_otp>php otp_auth_example.php PHP Warning: PDO::__construct(): The server requested authentication method unknown to the client [dialog] in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_aut h_example.php on line 68 Warning: PDO::__construct(): The server requested authentication method unknown to the client [dialog] in C:\GIT\mariadb-tmp\server\plugin\auth_otp\otp_auth_exa mple.php on line 68 Error: SQLSTATE[HY000] [2054] The server requested authentication method umknown to the client Test script: --------------- https://github.com/rspadim/server/blob/otp_plugin/plugin/auth_otp/ download all .php files otp_auth_example.php at mariadb server: INSTALL PLUGIN three_attempts SONAME 'dialog_examples.so'; CREATE USER test_dialog IDENTIFIED VIA three_attempts USING 'SECRET'; try to connect using username = test_dialog, and password='SECRET' Expected result: ---------------- implement a new feature of dialog connection three functions must be implemented for <mysql> and <mysqli> extension: mysql_auth_dialog_received() mysql_auth_dialog_receive() mysql_auth_dialog_send() and maybe at mysql_connect we will need a parameter to call a mysql function, for example $link = mysql_connect($HOST, $USER, $PASSWORD); if(mysql_auth_dialog_received($link)){ $tmp=mysql_auth_dialog_receive($link); /* array(type=>'pass/text',message=>'any message') */ mysql_auth_dialog_send($link,"any message"); } if($link){ // ok good connection }else{ // die("can't connect"); } ------------- with mysqli we could use mysqli_init, mysqli_options, mysqli_realconnect $db = mysqli_init(); $test = $db->options(MYSQLI_DIALOG_FUNCTION,function(){}); or $test = $db->options(MYSQLI_DIALOG_FUNCTION,"an_callback_function"); function an_callback_function($db,$type,$message){ return true; /* wait other message */ return false; /* disconnect */ mysqli_auth_dialog_send($db,"message"); } ------------ PDO: $dbh = new PDO("mysql:host=$HOST;port=$HOST_PORT;dbname=$DB", $USER, $PASSWORD, array( "MYSQL_DIALOG_AUTH_CALLBACK_FUNCTION" => function(){} )); or $dbh = new PDO("mysql:host=$HOST;port=$HOST_PORT;dbname=$DB", $USER, $PASSWORD, array( "MYSQL_DIALOG_AUTH_CALLBACK_FUNCTION" => "an_callback_function" )); function an_callback_function($db,$type,$message){ return true; /* wait other message */ return false; /* disconnect */ $db->mysqli_auth_dialog_send($db,"message"); } Actual result: -------------- no client side auth dialog interface PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
Reading examples from mariadb client/server auth dialog plugin at php side, we must include a function as callback to builtin_ask function: MYSQL_PLUGIN_EXPORT char *mysql_authentication_dialog_ask(MYSQL *mysql, int type,const char *prompt,char *buf, int buf_len) and the return of this function is the 'mysql_auth_dialog_send' in other words at php side we have: mysql_set_callback('any_function'); mysql_connect(); if we got dialog, any_function will be called, the problem is... at what connect we are? maybe "struct st_mysql *mysql" solve this problem, if not at least we can call a function and php user must know what he is doing at mysqli and pdo we could pass this callback function name as a mysqli_option or a array parameter (pdo) well i think that's all for now (04:22AM i didn't sleep yet, good night)