Skip to content

Commit

Permalink
New mosquitto_auth_psk_key_get()
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Jul 8, 2016
1 parent 1a6d23f commit 025e56f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/mosquitto_broker_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/mosquitto_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugin_defer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion test/broker/c/auth_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 025e56f

Please sign in to comment.