New mosquitto_auth_psk_key_get()

pull/215/head
Roger A. Light 9 years ago
parent 1a6d23feff
commit 025e56fd4c

@ -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);

@ -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

@ -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;
}

@ -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;
}

@ -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; i<db->auth_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;
}

@ -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;
}

Loading…
Cancel
Save