diff --git a/src/subs.c b/src/subs.c index bdc84cd8..58e4551c 100644 --- a/src/subs.c +++ b/src/subs.c @@ -491,8 +491,6 @@ int sub__remove(struct mosquitto_db *db, struct mosquitto *context, const char * HASH_FIND(hh, root, UHPA_ACCESS_TOPIC(tokens), tokens->topic_len, subhier); if(subhier){ rc = sub__remove_recurse(db, context, subhier, tokens); - }else{ - printf("nope\n"); } sub__topic_tokens_free(tokens); diff --git a/test/broker/c/Makefile b/test/broker/c/Makefile index ba31167a..ff11318b 100644 --- a/test/broker/c/Makefile +++ b/test/broker/c/Makefile @@ -2,7 +2,7 @@ CFLAGS=-I../../../lib -I../../../src -Wall -Werror -all : auth_plugin.so auth_plugin_pwd.so auth_plugin_acl.so acl_plugin_v2.so 08 +all : auth_plugin.so auth_plugin_pwd.so auth_plugin_acl.so auth_plugin_v2.so 08 08 : 08-tls-psk-pub.test 08-tls-psk-bridge.test diff --git a/test/broker/c/auth_plugin.c b/test/broker/c/auth_plugin.c index 13d444c0..ddb098b2 100644 --- a/test/broker/c/auth_plugin.c +++ b/test/broker/c/auth_plugin.c @@ -33,7 +33,6 @@ int mosquitto_auth_acl_check(void *user_data, int access, const struct mosquitto { const char *username = mosquitto_client_username(client); - printf("%s\n", username); if(username && !strcmp(username, "readonly") && access == MOSQ_ACL_READ){ return MOSQ_ERR_SUCCESS; }else if(username && !strcmp(username, "readonly") && access == MOSQ_ACL_SUBSCRIBE &&!strchr(msg->topic, '#') && !strchr(msg->topic, '+')) { diff --git a/test/broker/c/auth_plugin_acl.c b/test/broker/c/auth_plugin_acl.c new file mode 100644 index 00000000..4a89eedb --- /dev/null +++ b/test/broker/c/auth_plugin_acl.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include + +int mosquitto_auth_plugin_version(void) +{ + return MOSQ_AUTH_PLUGIN_VERSION; +} + +int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count) +{ + return MOSQ_ERR_SUCCESS; +} + +int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count) +{ + return MOSQ_ERR_SUCCESS; +} + +int mosquitto_auth_security_init(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload) +{ + return MOSQ_ERR_SUCCESS; +} + +int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload) +{ + return MOSQ_ERR_SUCCESS; +} + +int mosquitto_auth_acl_check(void *user_data, int access, const struct mosquitto *client, const struct mosquitto_acl_msg *msg) +{ + const char *username = mosquitto_client_username(client); + + if(username && !strcmp(username, "readonly") && access == MOSQ_ACL_READ){ + return MOSQ_ERR_SUCCESS; + }else if(username && !strcmp(username, "readonly") && access == MOSQ_ACL_SUBSCRIBE &&!strchr(msg->topic, '#') && !strchr(msg->topic, '+')) { + return MOSQ_ERR_SUCCESS; + }else{ + return MOSQ_ERR_ACL_DENIED; + } +} + +int mosquitto_auth_unpwd_check(void *user_data, const struct mosquitto *client, const char *username, const char *password) +{ + return MOSQ_ERR_PLUGIN_DEFER; +} + +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; +} + diff --git a/test/broker/c/auth_plugin_pwd.c b/test/broker/c/auth_plugin_pwd.c new file mode 100644 index 00000000..27476387 --- /dev/null +++ b/test/broker/c/auth_plugin_pwd.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include + +int mosquitto_auth_plugin_version(void) +{ + return MOSQ_AUTH_PLUGIN_VERSION; +} + +int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count) +{ + return MOSQ_ERR_SUCCESS; +} + +int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count) +{ + return MOSQ_ERR_SUCCESS; +} + +int mosquitto_auth_security_init(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload) +{ + return MOSQ_ERR_SUCCESS; +} + +int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload) +{ + return MOSQ_ERR_SUCCESS; +} + +int mosquitto_auth_acl_check(void *user_data, int access, const struct mosquitto *client, const struct mosquitto_acl_msg *msg) +{ + return MOSQ_ERR_PLUGIN_DEFER; +} + +int mosquitto_auth_unpwd_check(void *user_data, const struct mosquitto *client, const char *username, const char *password) +{ + if(!strcmp(username, "test-username") && password && !strcmp(password, "cnwTICONIURW")){ + return MOSQ_ERR_SUCCESS; + }else if(!strcmp(username, "readonly")){ + return MOSQ_ERR_SUCCESS; + }else if(!strcmp(username, "test-username@v2")){ + return MOSQ_ERR_PLUGIN_DEFER; + }else{ + return MOSQ_ERR_AUTH; + } +} + +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; +} +