From a311cc4ec3cecdbaf83ba66985efa82137e37cc0 Mon Sep 17 00:00:00 2001 From: Michael Grunder Date: Wed, 24 Jun 2020 17:00:01 -0700 Subject: Support for Redis 6 ACLs (#1791) Add support for Redis 6 ACLs in the `Redis`, `RedisCluster`, and `RedisArray` classes. On a related note, it adds a mechanism for users to customize how we generate persistent connection IDs such that they can be grouped in different ways depending on the specific use case required (e.g. it would allow connections to be grouped by username, or by user-defined persistent_id, or both). --- php_redis.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'php_redis.h') diff --git a/php_redis.h b/php_redis.h index af77ea00..a4ff9f4b 100644 --- a/php_redis.h +++ b/php_redis.h @@ -27,6 +27,7 @@ PHP_METHOD(Redis, __construct); PHP_METHOD(Redis, __destruct); +PHP_METHOD(Redis, acl); PHP_METHOD(Redis, append); PHP_METHOD(Redis, auth); PHP_METHOD(Redis, bgSave); @@ -252,6 +253,18 @@ PHP_METHOD(Redis, getPersistentID); PHP_METHOD(Redis, getAuth); PHP_METHOD(Redis, getMode); +/* For convenience we store the salt as a printable hex string which requires 2 + * characters per byte + 1 for the NULL terminator */ +#define REDIS_SALT_BYTES 32 +#define REDIS_SALT_SIZE ((2 * REDIS_SALT_BYTES) + 1) + +ZEND_BEGIN_MODULE_GLOBALS(redis) + char salt[REDIS_SALT_SIZE]; +ZEND_END_MODULE_GLOBALS(redis) + +ZEND_EXTERN_MODULE_GLOBALS(redis) +#define REDIS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(redis, v) + #ifdef ZTS #include "TSRM.h" #endif @@ -261,8 +274,9 @@ PHP_MSHUTDOWN_FUNCTION(redis); PHP_MINFO_FUNCTION(redis); /* Redis response handler function callback prototype */ -typedef void (*ResultCallback)(INTERNAL_FUNCTION_PARAMETERS, - RedisSock *redis_sock, zval *z_tab, void *ctx); +typedef void (*ResultCallback)(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); + +typedef int (*FailableResultCallback)(INTERNAL_FUNCTION_PARAMETERS, RedisSock*, zval*, void*); PHP_REDIS_API int redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent); -- cgit v1.2.3