PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/mysqlnd - mysqlnd_auth.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 122 192 63.5 %
Date: 2014-09-29 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   +----------------------------------------------------------------------+
       3             :   | PHP Version 5                                                        |
       4             :   +----------------------------------------------------------------------+
       5             :   | Copyright (c) 2006-2014 The PHP Group                                |
       6             :   +----------------------------------------------------------------------+
       7             :   | This source file is subject to version 3.01 of the PHP license,      |
       8             :   | that is bundled with this package in the file LICENSE, and is        |
       9             :   | available through the world-wide-web at the following url:           |
      10             :   | http://www.php.net/license/3_01.txt                                  |
      11             :   | If you did not receive a copy of the PHP license and are unable to   |
      12             :   | obtain it through the world-wide-web, please send a note to          |
      13             :   | license@php.net so we can mail you a copy immediately.               |
      14             :   +----------------------------------------------------------------------+
      15             :   | Authors: Georg Richter <georg@mysql.com>                             |
      16             :   |          Andrey Hristov <andrey@mysql.com>                           |
      17             :   |          Ulf Wendel <uwendel@mysql.com>                              |
      18             :   +----------------------------------------------------------------------+
      19             : */
      20             : 
      21             : /* $Id: mysqlnd.c 307377 2011-01-11 13:02:57Z andrey $ */
      22             : #include "php.h"
      23             : #include "mysqlnd.h"
      24             : #include "mysqlnd_structs.h"
      25             : #include "mysqlnd_wireprotocol.h"
      26             : #include "mysqlnd_priv.h"
      27             : #include "mysqlnd_result.h"
      28             : #include "mysqlnd_charset.h"
      29             : #include "mysqlnd_debug.h"
      30             : 
      31             : 
      32             : /* {{{ mysqlnd_auth_handshake */
      33             : enum_func_status
      34        1834 : mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
      35             :                                                           const char * const user,
      36             :                                                           const char * const passwd,
      37             :                                                           const size_t passwd_len,
      38             :                                                           const char * const db,
      39             :                                                           const size_t db_len,
      40             :                                                           const MYSQLND_OPTIONS * const options,
      41             :                                                           unsigned long mysql_flags,
      42             :                                                           unsigned int server_charset_no,
      43             :                                                           zend_bool use_full_blown_auth_packet,
      44             :                                                           const char * const auth_protocol,
      45             :                                                           const zend_uchar * const auth_plugin_data,
      46             :                                                           const size_t auth_plugin_data_len,
      47             :                                                           char ** switch_to_auth_protocol,
      48             :                                                           size_t * switch_to_auth_protocol_len,
      49             :                                                           zend_uchar ** switch_to_auth_protocol_data,
      50             :                                                           size_t * switch_to_auth_protocol_data_len
      51             :                                                           TSRMLS_DC)
      52             : {
      53        1834 :         enum_func_status ret = FAIL;
      54        1834 :         const MYSQLND_CHARSET * charset = NULL;
      55        1834 :         MYSQLND_PACKET_CHANGE_AUTH_RESPONSE * change_auth_resp_packet = NULL;
      56        1834 :         MYSQLND_PACKET_AUTH_RESPONSE * auth_resp_packet = NULL;
      57        1834 :         MYSQLND_PACKET_AUTH * auth_packet = NULL;
      58             : 
      59        1834 :         DBG_ENTER("mysqlnd_auth_handshake");
      60             : 
      61        1834 :         auth_resp_packet = conn->protocol->m.get_auth_response_packet(conn->protocol, FALSE TSRMLS_CC);
      62             : 
      63        1834 :         if (!auth_resp_packet) {
      64           0 :                 SET_OOM_ERROR(*conn->error_info);
      65           0 :                 goto end;
      66             :         }
      67             : 
      68        1834 :         if (use_full_blown_auth_packet != TRUE) {
      69           0 :                 change_auth_resp_packet = conn->protocol->m.get_change_auth_response_packet(conn->protocol, FALSE TSRMLS_CC);
      70           0 :                 if (!change_auth_resp_packet) {
      71           0 :                         SET_OOM_ERROR(*conn->error_info);
      72           0 :                         goto end;
      73             :                 }
      74             : 
      75           0 :                 change_auth_resp_packet->auth_data = auth_plugin_data;
      76           0 :                 change_auth_resp_packet->auth_data_len = auth_plugin_data_len;
      77             : 
      78           0 :                 if (!PACKET_WRITE(change_auth_resp_packet, conn)) {
      79           0 :                         CONN_SET_STATE(conn, CONN_QUIT_SENT);
      80           0 :                         SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
      81           0 :                         goto end;
      82             :                 }
      83             :         } else {
      84        1834 :                 auth_packet = conn->protocol->m.get_auth_packet(conn->protocol, FALSE TSRMLS_CC);
      85             : 
      86        1834 :                 auth_packet->client_flags = mysql_flags;
      87        1834 :                 auth_packet->max_packet_size = options->max_allowed_packet;
      88        1838 :                 if (options->charset_name && (charset = mysqlnd_find_charset_name(options->charset_name))) {
      89           4 :                         auth_packet->charset_no      = charset->nr;
      90             :                 } else {
      91             : #if MYSQLND_UNICODE
      92             :                         auth_packet->charset_no      = 200;/* utf8 - swedish collation, check mysqlnd_charset.c */
      93             : #else
      94        1830 :                         auth_packet->charset_no      = server_charset_no;
      95             : #endif
      96             :                 }
      97             : 
      98        1834 :                 auth_packet->send_auth_data = TRUE;
      99        1834 :                 auth_packet->user            = user;
     100        1834 :                 auth_packet->db                      = db;
     101        1834 :                 auth_packet->db_len          = db_len;
     102             : 
     103        1834 :                 auth_packet->auth_data = auth_plugin_data;
     104        1834 :                 auth_packet->auth_data_len = auth_plugin_data_len;
     105        1834 :                 auth_packet->auth_plugin_name = auth_protocol;
     106             : 
     107        1834 :                 if (!PACKET_WRITE(auth_packet, conn)) {
     108           0 :                         goto end;
     109             :                 }
     110             :         }
     111        1834 :         if (use_full_blown_auth_packet == TRUE) {
     112        1834 :                 conn->charset = mysqlnd_find_charset_nr(auth_packet->charset_no);
     113             :         }
     114             : 
     115        1834 :         if (FAIL == PACKET_READ(auth_resp_packet, conn) || auth_resp_packet->response_code >= 0xFE) {
     116          34 :                 if (auth_resp_packet->response_code == 0xFE) {
     117             :                         /* old authentication with new server  !*/
     118           0 :                         if (!auth_resp_packet->new_auth_protocol) {
     119           0 :                                 DBG_ERR(mysqlnd_old_passwd);
     120           0 :                                 SET_CLIENT_ERROR(*conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd);
     121             :                         } else {
     122           0 :                                 *switch_to_auth_protocol = mnd_pestrndup(auth_resp_packet->new_auth_protocol, auth_resp_packet->new_auth_protocol_len, FALSE);
     123           0 :                                 *switch_to_auth_protocol_len = auth_resp_packet->new_auth_protocol_len;
     124           0 :                                 if (auth_resp_packet->new_auth_protocol_data) {
     125           0 :                                         *switch_to_auth_protocol_data_len = auth_resp_packet->new_auth_protocol_data_len;
     126           0 :                                         *switch_to_auth_protocol_data = mnd_emalloc(*switch_to_auth_protocol_data_len);
     127           0 :                                         memcpy(*switch_to_auth_protocol_data, auth_resp_packet->new_auth_protocol_data, *switch_to_auth_protocol_data_len);
     128             :                                 } else {
     129           0 :                                         *switch_to_auth_protocol_data = NULL;
     130           0 :                                         *switch_to_auth_protocol_data_len = 0;
     131             :                                 }                               
     132             :                         }
     133          34 :                 } else if (auth_resp_packet->response_code == 0xFF) {
     134          34 :                         if (auth_resp_packet->sqlstate[0]) {
     135          34 :                                 strlcpy(conn->error_info->sqlstate, auth_resp_packet->sqlstate, sizeof(conn->error_info->sqlstate));
     136          34 :                                 DBG_ERR_FMT("ERROR:%u [SQLSTATE:%s] %s", auth_resp_packet->error_no, auth_resp_packet->sqlstate, auth_resp_packet->error);
     137             :                         }
     138          34 :                         SET_CLIENT_ERROR(*conn->error_info, auth_resp_packet->error_no, UNKNOWN_SQLSTATE, auth_resp_packet->error);
     139             :                 }
     140          34 :                 goto end;
     141             :         }
     142             : 
     143        1800 :         SET_NEW_MESSAGE(conn->last_message, conn->last_message_len, auth_resp_packet->message, auth_resp_packet->message_len, conn->persistent);
     144        1800 :         ret = PASS;
     145             : end:
     146        1834 :         PACKET_FREE(change_auth_resp_packet);
     147        1834 :         PACKET_FREE(auth_packet);
     148        1834 :         PACKET_FREE(auth_resp_packet);
     149        1834 :         DBG_RETURN(ret);
     150             : }
     151             : /* }}} */
     152             : 
     153             : 
     154             : /* {{{ mysqlnd_auth_change_user */
     155             : enum_func_status
     156          68 : mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn,
     157             :                                                                 const char * const user,
     158             :                                                                 const size_t user_len,
     159             :                                                                 const char * const passwd,
     160             :                                                                 const size_t passwd_len,
     161             :                                                                 const char * const db,
     162             :                                                                 const size_t db_len,
     163             :                                                                 const zend_bool silent,
     164             :                                                                 zend_bool use_full_blown_auth_packet,
     165             :                                                                 const char * const auth_protocol,
     166             :                                                                 zend_uchar * auth_plugin_data,
     167             :                                                                 size_t auth_plugin_data_len,
     168             :                                                                 char ** switch_to_auth_protocol,
     169             :                                                                 size_t * switch_to_auth_protocol_len,
     170             :                                                                 zend_uchar ** switch_to_auth_protocol_data,
     171             :                                                                 size_t * switch_to_auth_protocol_data_len
     172             :                                                                 TSRMLS_DC)
     173             : {
     174          68 :         enum_func_status ret = FAIL;
     175          68 :         const MYSQLND_CHARSET * old_cs = conn->charset;
     176          68 :         MYSQLND_PACKET_CHANGE_AUTH_RESPONSE * change_auth_resp_packet = NULL;
     177          68 :         MYSQLND_PACKET_CHG_USER_RESPONSE * chg_user_resp = NULL;
     178          68 :         MYSQLND_PACKET_AUTH * auth_packet = NULL;
     179             : 
     180          68 :         DBG_ENTER("mysqlnd_auth_change_user");
     181             : 
     182          68 :         chg_user_resp = conn->protocol->m.get_change_user_response_packet(conn->protocol, FALSE TSRMLS_CC);
     183             : 
     184          68 :         if (!chg_user_resp) {
     185           0 :                 SET_OOM_ERROR(*conn->error_info);
     186           0 :                 goto end;
     187             :         }
     188             : 
     189          68 :         if (use_full_blown_auth_packet != TRUE) {
     190           0 :                 change_auth_resp_packet = conn->protocol->m.get_change_auth_response_packet(conn->protocol, FALSE TSRMLS_CC);
     191           0 :                 if (!change_auth_resp_packet) {
     192           0 :                         SET_OOM_ERROR(*conn->error_info);
     193           0 :                         goto end;
     194             :                 }
     195             : 
     196           0 :                 change_auth_resp_packet->auth_data = auth_plugin_data;
     197           0 :                 change_auth_resp_packet->auth_data_len = auth_plugin_data_len;
     198             : 
     199           0 :                 if (!PACKET_WRITE(change_auth_resp_packet, conn)) {
     200           0 :                         CONN_SET_STATE(conn, CONN_QUIT_SENT);
     201           0 :                         SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
     202           0 :                         goto end;
     203             :                 }       
     204             :         } else {
     205          68 :                 auth_packet = conn->protocol->m.get_auth_packet(conn->protocol, FALSE TSRMLS_CC);
     206             : 
     207          68 :                 if (!auth_packet) {
     208           0 :                         SET_OOM_ERROR(*conn->error_info);
     209           0 :                         goto end;
     210             :                 }
     211             : 
     212          68 :                 auth_packet->is_change_user_packet = TRUE;
     213          68 :                 auth_packet->user            = user;
     214          68 :                 auth_packet->db                      = db;
     215          68 :                 auth_packet->db_len          = db_len;
     216          68 :                 auth_packet->silent          = silent;
     217             : 
     218          68 :                 auth_packet->auth_data = auth_plugin_data;
     219          68 :                 auth_packet->auth_data_len = auth_plugin_data_len;
     220          68 :                 auth_packet->auth_plugin_name = auth_protocol;
     221             : 
     222             : 
     223          68 :                 if (conn->m->get_server_version(conn TSRMLS_CC) >= 50123) {
     224          68 :                         auth_packet->charset_no      = conn->charset->nr;
     225             :                 }
     226             :         
     227          68 :                 if (!PACKET_WRITE(auth_packet, conn)) {
     228           1 :                         CONN_SET_STATE(conn, CONN_QUIT_SENT);
     229           1 :                                 SET_CLIENT_ERROR(*conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
     230           1 :                         goto end;
     231             :                 }
     232             :         }
     233             : 
     234          67 :         ret = PACKET_READ(chg_user_resp, conn);
     235          67 :         COPY_CLIENT_ERROR(*conn->error_info, chg_user_resp->error_info);
     236             : 
     237          67 :         if (0xFE == chg_user_resp->response_code) {
     238           0 :                 ret = FAIL;
     239           0 :                 if (!chg_user_resp->new_auth_protocol) {
     240           0 :                         DBG_ERR(mysqlnd_old_passwd);
     241           0 :                         SET_CLIENT_ERROR(*conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd);
     242             :                 } else {
     243           0 :                         *switch_to_auth_protocol = mnd_pestrndup(chg_user_resp->new_auth_protocol, chg_user_resp->new_auth_protocol_len, FALSE);
     244           0 :                         *switch_to_auth_protocol_len = chg_user_resp->new_auth_protocol_len;
     245           0 :                         if (chg_user_resp->new_auth_protocol_data) {
     246           0 :                                 *switch_to_auth_protocol_data_len = chg_user_resp->new_auth_protocol_data_len;
     247           0 :                                 *switch_to_auth_protocol_data = mnd_emalloc(*switch_to_auth_protocol_data_len);
     248           0 :                                 memcpy(*switch_to_auth_protocol_data, chg_user_resp->new_auth_protocol_data, *switch_to_auth_protocol_data_len);
     249             :                         } else {
     250           0 :                                 *switch_to_auth_protocol_data = NULL;
     251           0 :                                 *switch_to_auth_protocol_data_len = 0;
     252             :                         }                               
     253             :                 }
     254             :         }
     255             : 
     256          67 :         if (conn->error_info->error_no) {
     257          12 :                 ret = FAIL;
     258             :                 /*
     259             :                   COM_CHANGE_USER is broken in 5.1. At least in 5.1.15 and 5.1.14, 5.1.11 is immune.
     260             :                   bug#25371 mysql_change_user() triggers "packets out of sync"
     261             :                   When it gets fixed, there should be one more check here
     262             :                 */
     263          12 :                 if (conn->m->get_server_version(conn TSRMLS_CC) > 50113L &&conn->m->get_server_version(conn TSRMLS_CC) < 50118L) {
     264           0 :                         MYSQLND_PACKET_OK * redundant_error_packet = conn->protocol->m.get_ok_packet(conn->protocol, FALSE TSRMLS_CC);
     265           0 :                         if (redundant_error_packet) {
     266           0 :                                 PACKET_READ(redundant_error_packet, conn);
     267           0 :                                 PACKET_FREE(redundant_error_packet);
     268           0 :                                 DBG_INF_FMT("Server is %u, buggy, sends two ERR messages", conn->m->get_server_version(conn TSRMLS_CC));
     269             :                         } else {
     270           0 :                                 SET_OOM_ERROR(*conn->error_info);
     271             :                         }
     272             :                 }
     273             :         }
     274          67 :         if (ret == PASS) {
     275          55 :                 char * tmp = NULL;
     276             :                 /* if we get conn->user as parameter and then we first free it, then estrndup it, we will crash */
     277          55 :                 tmp = mnd_pestrndup(user, user_len, conn->persistent);
     278          55 :                 if (conn->user) {
     279          55 :                         mnd_pefree(conn->user, conn->persistent);
     280             :                 }
     281          55 :                 conn->user = tmp;
     282             : 
     283          55 :                 tmp = mnd_pestrdup(passwd, conn->persistent);
     284          55 :                 if (conn->passwd) {
     285          55 :                         mnd_pefree(conn->passwd, conn->persistent);
     286             :                 }
     287          55 :                 conn->passwd = tmp;
     288             : 
     289          55 :                 if (conn->last_message) {
     290           0 :                         mnd_pefree(conn->last_message, conn->persistent);
     291           0 :                         conn->last_message = NULL;
     292             :                 }
     293          55 :                 memset(conn->upsert_status, 0, sizeof(*conn->upsert_status));
     294             :                 /* set charset for old servers */
     295          55 :                 if (conn->m->get_server_version(conn TSRMLS_CC) < 50123) {
     296           0 :                         ret = conn->m->set_charset(conn, old_cs->name TSRMLS_CC);
     297             :                 }
     298          12 :         } else if (ret == FAIL && chg_user_resp->server_asked_323_auth == TRUE) {
     299             :                 /* old authentication with new server  !*/
     300           0 :                 DBG_ERR(mysqlnd_old_passwd);
     301           0 :                 SET_CLIENT_ERROR(*conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd);
     302             :         }
     303             : end:
     304          68 :         PACKET_FREE(change_auth_resp_packet);
     305          68 :         PACKET_FREE(auth_packet);
     306          68 :         PACKET_FREE(chg_user_resp);
     307          68 :         DBG_RETURN(ret);
     308             : }
     309             : /* }}} */
     310             : 
     311             : 
     312             : /******************************************* MySQL Native Password ***********************************/
     313             : 
     314             : #include "ext/standard/sha1.h"
     315             : 
     316             : /* {{{ php_mysqlnd_crypt */
     317             : static void
     318        1886 : php_mysqlnd_crypt(zend_uchar *buffer, const zend_uchar *s1, const zend_uchar *s2, size_t len)
     319             : {
     320        1886 :         const zend_uchar *s1_end = s1 + len;
     321       41492 :         while (s1 < s1_end) {
     322       37720 :                 *buffer++= *s1++ ^ *s2++;
     323             :         }
     324        1886 : }
     325             : /* }}} */
     326             : 
     327             : 
     328             : /* {{{ php_mysqlnd_scramble */
     329        1886 : void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const password, size_t password_len)
     330             : {
     331             :         PHP_SHA1_CTX context;
     332             :         zend_uchar sha1[SHA1_MAX_LENGTH];
     333             :         zend_uchar sha2[SHA1_MAX_LENGTH];
     334             : 
     335             :         /* Phase 1: hash password */
     336        1886 :         PHP_SHA1Init(&context);
     337        1886 :         PHP_SHA1Update(&context, password, password_len);
     338        1886 :         PHP_SHA1Final(sha1, &context);
     339             : 
     340             :         /* Phase 2: hash sha1 */
     341        1886 :         PHP_SHA1Init(&context);
     342        1886 :         PHP_SHA1Update(&context, (zend_uchar*)sha1, SHA1_MAX_LENGTH);
     343        1886 :         PHP_SHA1Final(sha2, &context);
     344             : 
     345             :         /* Phase 3: hash scramble + sha2 */
     346        1886 :         PHP_SHA1Init(&context);
     347        1886 :         PHP_SHA1Update(&context, scramble, SCRAMBLE_LENGTH);
     348        1886 :         PHP_SHA1Update(&context, (zend_uchar*)sha2, SHA1_MAX_LENGTH);
     349        1886 :         PHP_SHA1Final(buffer, &context);
     350             : 
     351             :         /* let's crypt buffer now */
     352        1886 :         php_mysqlnd_crypt(buffer, (const zend_uchar *)buffer, (const zend_uchar *)sha1, SHA1_MAX_LENGTH);
     353        1886 : }
     354             : /* }}} */
     355             : 
     356             : 
     357             : /* {{{ mysqlnd_native_auth_get_auth_data */
     358             : static zend_uchar *
     359        1902 : mysqlnd_native_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
     360             :                                                                   size_t * auth_data_len,
     361             :                                                                   MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
     362             :                                                                   const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
     363             :                                                                   const MYSQLND_OPTIONS * const options, unsigned long mysql_flags
     364             :                                                                   TSRMLS_DC)
     365             : {
     366        1902 :         zend_uchar * ret = NULL;
     367        1902 :         DBG_ENTER("mysqlnd_native_auth_get_auth_data");
     368        1902 :         *auth_data_len = 0;
     369             : 
     370             :         /* 5.5.x reports 21 as scramble length because it needs to show the length of the data before the plugin name */
     371        1902 :         if (auth_plugin_data_len < SCRAMBLE_LENGTH) {
     372             :                 /* mysql_native_password only works with SCRAMBLE_LENGTH scramble */
     373           0 :                 SET_CLIENT_ERROR(*conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "The server sent wrong length for scramble");
     374           0 :                 DBG_ERR_FMT("The server sent wrong length for scramble %u. Expected %u", auth_plugin_data_len, SCRAMBLE_LENGTH);
     375           0 :                 DBG_RETURN(NULL);
     376             :         }
     377             : 
     378             :         /* copy scrambled pass*/
     379        1902 :         if (passwd && passwd_len) {
     380        1886 :                 ret = malloc(SCRAMBLE_LENGTH);
     381        1886 :                 *auth_data_len = SCRAMBLE_LENGTH;
     382             :                 /* In 4.1 we use CLIENT_SECURE_CONNECTION and thus the len of the buf should be passed */
     383        1886 :                 php_mysqlnd_scramble((zend_uchar*)ret, auth_plugin_data, (zend_uchar*)passwd, passwd_len);
     384             :         }
     385        1902 :         DBG_RETURN(ret);
     386             : }
     387             : /* }}} */
     388             : 
     389             : 
     390             : static struct st_mysqlnd_authentication_plugin mysqlnd_native_auth_plugin =
     391             : {
     392             :         {
     393             :                 MYSQLND_PLUGIN_API_VERSION,
     394             :                 "auth_plugin_mysql_native_password",
     395             :                 MYSQLND_VERSION_ID,
     396             :                 MYSQLND_VERSION,
     397             :                 "PHP License 3.01",
     398             :                 "Andrey Hristov <andrey@mysql.com>,  Ulf Wendel <uwendel@mysql.com>, Georg Richter <georg@mysql.com>",
     399             :                 {
     400             :                         NULL, /* no statistics , will be filled later if there are some */
     401             :                         NULL, /* no statistics */
     402             :                 },
     403             :                 {
     404             :                         NULL /* plugin shutdown */
     405             :                 }
     406             :         },
     407             :         {/* methods */
     408             :                 mysqlnd_native_auth_get_auth_data
     409             :         }
     410             : };
     411             : 
     412             : 
     413             : /******************************************* PAM Authentication ***********************************/
     414             : 
     415             : /* {{{ mysqlnd_pam_auth_get_auth_data */
     416             : static zend_uchar *
     417           0 : mysqlnd_pam_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
     418             :                                                            size_t * auth_data_len,
     419             :                                                            MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd,
     420             :                                                            const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len,
     421             :                                                            const MYSQLND_OPTIONS * const options, unsigned long mysql_flags
     422             :                                                            TSRMLS_DC)
     423             : {
     424           0 :         zend_uchar * ret = NULL;
     425             : 
     426             :         /* copy pass*/
     427           0 :         if (passwd && passwd_len) {
     428           0 :                 ret = (zend_uchar*) zend_strndup(passwd, passwd_len);
     429             :         }
     430           0 :         *auth_data_len = passwd_len;
     431             : 
     432           0 :         return ret;
     433             : }
     434             : /* }}} */
     435             : 
     436             : 
     437             : static struct st_mysqlnd_authentication_plugin mysqlnd_pam_authentication_plugin =
     438             : {
     439             :         {
     440             :                 MYSQLND_PLUGIN_API_VERSION,
     441             :                 "auth_plugin_mysql_clear_password",
     442             :                 MYSQLND_VERSION_ID,
     443             :                 MYSQLND_VERSION,
     444             :                 "PHP License 3.01",
     445             :                 "Andrey Hristov <andrey@mysql.com>,  Ulf Wendel <uwendel@mysql.com>, Georg Richter <georg@mysql.com>",
     446             :                 {
     447             :                         NULL, /* no statistics , will be filled later if there are some */
     448             :                         NULL, /* no statistics */
     449             :                 },
     450             :                 {
     451             :                         NULL /* plugin shutdown */
     452             :                 }
     453             :         },
     454             :         {/* methods */
     455             :                 mysqlnd_pam_auth_get_auth_data
     456             :         }
     457             : };
     458             : 
     459             : 
     460             : /* {{{ mysqlnd_register_builtin_authentication_plugins */
     461             : void
     462       20225 : mysqlnd_register_builtin_authentication_plugins(TSRMLS_D)
     463             : {
     464       20225 :         mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_native_auth_plugin TSRMLS_CC);
     465       20225 :         mysqlnd_plugin_register_ex((struct st_mysqlnd_plugin_header *) &mysqlnd_pam_authentication_plugin TSRMLS_CC);
     466       20225 : }
     467             : /* }}} */
     468             : 
     469             : 
     470             : /*
     471             :  * Local variables:
     472             :  * tab-width: 4
     473             :  * c-basic-offset: 4
     474             :  * End:
     475             :  * vim600: noet sw=4 ts=4 fdm=marker
     476             :  * vim<600: noet sw=4 ts=4
     477             :  */

Generated by: LCOV version 1.10

Generated at Mon, 29 Sep 2014 14:26:24 +0000 (2 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.