com pecl/caching/memcache: enable sasl authentification, enabled automatically (PLAIN Only for now) if setSaslData has been called and data has been
set correctly: memcache.c

From: Date: Sun, 13 Oct 2013 18:41:39 +0000
Subject: com pecl/caching/memcache: enable sasl authentification, enabled automatically (PLAIN Only for now) if setSaslData has been called and data has been
set correctly: memcache.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-19878@lists.php.net to get a copy of this message
Commit: c0fa31a0d11c193e3141f3688e4ffdeb374a3362 Author: unknown <pajoye@php.net> Sun, 13 Oct 2013 20:41:39 +0200 Parents: c2ced03619b4ccbdcb4ceff3f578df8a99d3ef79 Branches: nio Link: http://git.php.net/?p=pecl/caching/memcache.git;a=commitdiff;h=c0fa31a0d11c193e3141f3688e4ffdeb374a3362 Log: enable sasl authentification, enabled automatically (PLAIN Only for now) if setSaslData has been called and data has been set correctly Changed paths: M memcache.c Diff: diff --git a/memcache.c b/memcache.c index adcadf4..d732f3e 100644 --- a/memcache.c +++ b/memcache.c @@ -791,8 +791,9 @@ static mmc_t *php_mmc_pool_addserver( pool->failure_callback = &php_mmc_failure_callback; list_id = MEMCACHE_LIST_INSERT(pool, le_memcache_pool); add_property_resource(mmc_object, "connection", list_id); - add_property_null(mmc_object, "username"); - add_property_null(mmc_object, "password"); + + zend_declare_property_null(memcache_pool_ce, "username", strlen("username"), ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_null(memcache_pool_ce, "password", strlen("password"), ZEND_ACC_PUBLIC TSRMLS_CC); } else { pool = (mmc_pool_t *)zend_list_find(Z_LVAL_PP(connection), &resource_type); @@ -837,8 +838,7 @@ static void php_mmc_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool persistent) zval *mmc_object = getThis(); mmc_pool_t *pool; mmc_t *mmc; - mmc_request_t *request; - + zval *username, *password; char *host; int host_len; long tcp_port = MEMCACHE_G(default_port); @@ -881,6 +881,23 @@ static void php_mmc_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool persistent) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't connect to %s:%d, %s (%d)", host, mmc->tcp.port, mmc->error ? mmc->error : "Unknown error", mmc->errnum); RETURN_FALSE; } + username = zend_read_property(memcache_ce, mmc_object, "username", strlen("username"), 1); + password = zend_read_property(memcache_ce, mmc_object, "password", strlen("password"), 1); + + if (Z_TYPE_P(username) == IS_STRING && Z_TYPE_P(password) == IS_STRING) { + mmc_request_t *request; + + /* allocate request */ + request = mmc_pool_request(pool, MMC_PROTO_TCP, mmc_stored_handler, return_value, mmc_pool_failover_handler, NULL TSRMLS_CC); + pool->protocol->set_sasl_auth_data(pool, request, Z_STRVAL_P(username), Z_STRVAL_P(password) TSRMLS_CC); + + /* schedule request */ + if (mmc_pool_schedule_key(pool, request->key, request->key_len, request, MEMCACHE_G(redundancy) TSRMLS_CC) != MMC_OK) { + RETURN_FALSE; + } + + mmc_pool_select(pool TSRMLS_CC); + } } /* }}} */ @@ -2026,8 +2043,8 @@ PHP_FUNCTION(memcache_set_sasl_data) if (user_length < 1 || password_length < 1) { RETURN_FALSE; } - add_property_stringl(mmc_object, "username", user, user_length, 1); - add_property_stringl(mmc_object, "password", password, password_length, 1); + zend_update_property_stringl(memcache_pool_ce, mmc_object, "username", strlen("username"), user, user_length TSRMLS_CC); + zend_update_property_stringl(memcache_pool_ce, mmc_object, "password", strlen("password"), password, password_length TSRMLS_CC); RETURN_TRUE; } /* }}} */

« previous php.pecl.cvs (#19878) next »