From 025e56fd4c48b42c8de63da4b1ad0d1e01d2337b Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Fri, 8 Jul 2016 13:52:02 +0100 Subject: [PATCH] New mosquitto_auth_psk_key_get() --- src/mosquitto_broker_internal.h | 4 ++-- src/mosquitto_plugin.h | 2 +- src/net.c | 2 +- src/plugin_defer.c | 2 +- src/security.c | 6 +++--- test/broker/c/auth_plugin.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mosquitto_broker_internal.h b/src/mosquitto_broker_internal.h index 7d673221..bb16b490 100644 --- a/src/mosquitto_broker_internal.h +++ b/src/mosquitto_broker_internal.h @@ -315,7 +315,7 @@ struct mosquitto__auth_plugin{ int (*security_cleanup)(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload); int (*acl_check)(void *user_data, int access, const struct mosquitto *client, struct mosquitto_acl_msg *msg); int (*unpwd_check)(void *user_data, const struct mosquitto *client, const char *username, const char *password); - int (*psk_key_get)(void *user_data, const char *hint, const char *identity, char *key, int max_key_len); + int (*psk_key_get)(void *user_data, const struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len); }; struct mosquitto_db{ @@ -559,7 +559,7 @@ int mosquitto_security_apply(struct mosquitto_db *db); int mosquitto_security_cleanup(struct mosquitto_db *db, bool reload); int mosquitto_acl_check(struct mosquitto_db *db, struct mosquitto *context, const char *topic, int access); int mosquitto_unpwd_check(struct mosquitto_db *db, struct mosquitto *context, const char *username, const char *password); -int mosquitto_psk_key_get(struct mosquitto_db *db, const char *hint, const char *identity, char *key, int max_key_len); +int mosquitto_psk_key_get(struct mosquitto_db *db, struct mosquitto *context, const char *hint, const char *identity, char *key, int max_key_len); int mosquitto_security_init_default(struct mosquitto_db *db, bool reload); int mosquitto_security_apply_default(struct mosquitto_db *db); diff --git a/src/mosquitto_plugin.h b/src/mosquitto_plugin.h index 41e1490c..2df94589 100644 --- a/src/mosquitto_plugin.h +++ b/src/mosquitto_plugin.h @@ -223,6 +223,6 @@ int mosquitto_auth_unpwd_check(void *user_data, const struct mosquitto *client, * Return >0 on failure. * Return MOSQ_ERR_PLUGIN_DEFER if your plugin does not wish to handle this check. */ -int mosquitto_auth_psk_key_get(void *user_data, const char *hint, const char *identity, char *key, int max_key_len); +int mosquitto_auth_psk_key_get(void *user_data, const struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len); #endif diff --git a/src/net.c b/src/net.c index 37b6d65d..6d03fc02 100644 --- a/src/net.c +++ b/src/net.c @@ -226,7 +226,7 @@ static unsigned int psk_server_callback(SSL *ssl, const char *identity, unsigned psk_key = mosquitto__calloc(1, max_psk_len*2 + 1); if(!psk_key) return 0; - if(mosquitto_psk_key_get(db, psk_hint, identity, psk_key, max_psk_len*2) != MOSQ_ERR_SUCCESS){ + if(mosquitto_psk_key_get(db, context, psk_hint, identity, psk_key, max_psk_len*2) != MOSQ_ERR_SUCCESS){ mosquitto__free(psk_key); return 0; } diff --git a/src/plugin_defer.c b/src/plugin_defer.c index 6b74bff2..5bdf755e 100644 --- a/src/plugin_defer.c +++ b/src/plugin_defer.c @@ -58,7 +58,7 @@ int mosquitto_auth_unpwd_check(void *user_data, const struct mosquitto *client, return MOSQ_ERR_PLUGIN_DEFER; } -int mosquitto_auth_psk_key_get(void *user_data, const char *hint, const char *identity, char *key, int max_key_len) +int mosquitto_auth_psk_key_get(void *user_data, const struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len) { return MOSQ_ERR_PLUGIN_DEFER; } diff --git a/src/security.c b/src/security.c index cb1737df..4aa79f93 100644 --- a/src/security.c +++ b/src/security.c @@ -31,7 +31,7 @@ typedef int (*FUNC_auth_plugin_security_init)(void *, struct mosquitto_auth_opt typedef int (*FUNC_auth_plugin_security_cleanup)(void *, struct mosquitto_auth_opt *, int, bool); typedef int (*FUNC_auth_plugin_acl_check)(void *, int, const struct mosquitto *, struct mosquitto_acl_msg *); typedef int (*FUNC_auth_plugin_unpwd_check)(void *, const struct mosquitto *, const char *, const char *); -typedef int (*FUNC_auth_plugin_psk_key_get)(void *, const char *, const char *, char *, int); +typedef int (*FUNC_auth_plugin_psk_key_get)(void *, const struct mosquitto *, const char *, const char *, char *, int); void LIB_ERROR(void) { @@ -294,7 +294,7 @@ int mosquitto_unpwd_check(struct mosquitto_db *db, struct mosquitto *context, co return rc; } -int mosquitto_psk_key_get(struct mosquitto_db *db, const char *hint, const char *identity, char *key, int max_key_len) +int mosquitto_psk_key_get(struct mosquitto_db *db, struct mosquitto *context, const char *hint, const char *identity, char *key, int max_key_len) { int rc; int i; @@ -308,7 +308,7 @@ int mosquitto_psk_key_get(struct mosquitto_db *db, const char *hint, const char * If no plugins exist we should accept at this point so set rc to success. */ for(i=0; iauth_plugin_count; i++){ - rc = db->auth_plugins[i].psk_key_get(db->auth_plugins[i].user_data, hint, identity, key, max_key_len); + rc = db->auth_plugins[i].psk_key_get(db->auth_plugins[i].user_data, context, hint, identity, key, max_key_len); if(rc != MOSQ_ERR_PLUGIN_DEFER){ return rc; } diff --git a/test/broker/c/auth_plugin.c b/test/broker/c/auth_plugin.c index 5b980c47..b51035b9 100644 --- a/test/broker/c/auth_plugin.c +++ b/test/broker/c/auth_plugin.c @@ -52,7 +52,7 @@ int mosquitto_auth_unpwd_check(void *user_data, const struct mosquitto *client, } } -int mosquitto_auth_psk_key_get(void *user_data, const char *hint, const char *identity, char *key, int max_key_len) +int mosquitto_auth_psk_key_get(void *user_data, const struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len) { return MOSQ_ERR_AUTH; }