Invalid/unsupported plugin tests.
parent
677aa2cc8d
commit
8a6bb872fe
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from mosq_test_helper import *
|
||||
|
||||
# Check whether incomplete plugins are handled ok
|
||||
|
||||
def write_config(filename, port, plugver, num):
|
||||
with open(filename, 'w') as f:
|
||||
f.write(f"listener {port}\n")
|
||||
f.write(f"auth_plugin c/bad_v{plugver}_{num}.so\n")
|
||||
f.write("allow_anonymous false\n")
|
||||
|
||||
def do_test(plugver, num):
|
||||
port = mosq_test.get_port()
|
||||
conf_file = os.path.basename(__file__).replace('.py', '.conf')
|
||||
write_config(conf_file, port, plugver, num)
|
||||
|
||||
try:
|
||||
rc = 1
|
||||
broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port, check_port=False)
|
||||
broker.wait(1)
|
||||
broker.terminate()
|
||||
if broker.returncode == 13:
|
||||
rc = 0
|
||||
except mosq_test.TestError:
|
||||
pass
|
||||
finally:
|
||||
os.remove(conf_file)
|
||||
(stdo, stde) = broker.communicate()
|
||||
if rc:
|
||||
print(stde.decode('utf-8'))
|
||||
exit(rc)
|
||||
|
||||
do_test("none", 1)
|
||||
|
||||
for i in range(1,8):
|
||||
do_test(2, i)
|
||||
|
||||
for i in range(1,8):
|
||||
do_test(3, i)
|
||||
|
||||
for i in range(1,5):
|
||||
do_test(4, i)
|
||||
|
||||
do_test(5, 1)
|
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from mosq_test_helper import *
|
||||
|
||||
# Check whether unsupported plugin versions are handled ok
|
||||
|
||||
def write_config(filename, port, plugver):
|
||||
with open(filename, 'w') as f:
|
||||
f.write(f"listener {port}\n")
|
||||
f.write(f"auth_plugin c/bad_v{plugver}.so\n")
|
||||
f.write("allow_anonymous false\n")
|
||||
|
||||
def do_test(plugver):
|
||||
port = mosq_test.get_port()
|
||||
conf_file = os.path.basename(__file__).replace('.py', '.conf')
|
||||
write_config(conf_file, port, plugver)
|
||||
|
||||
try:
|
||||
rc = 1
|
||||
broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port, check_port=False)
|
||||
broker.wait(1)
|
||||
broker.terminate()
|
||||
if broker.returncode == 13:
|
||||
rc = 0
|
||||
except mosq_test.TestError:
|
||||
pass
|
||||
finally:
|
||||
os.remove(conf_file)
|
||||
(stdo, stde) = broker.communicate()
|
||||
if rc:
|
||||
print(stde.decode('utf-8'))
|
||||
exit(rc)
|
||||
|
||||
do_test(1)
|
||||
do_test(6)
|
@ -0,0 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(1);
|
@ -0,0 +1,96 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "mosquitto_plugin_v2.h"
|
||||
|
||||
/*
|
||||
* Following constant come from mosquitto.h
|
||||
*
|
||||
* They are copied here to fix value of those constant at the time of MOSQ_AUTH_PLUGIN_VERSION == 2
|
||||
*/
|
||||
enum mosq_err_t {
|
||||
MOSQ_ERR_SUCCESS = 0,
|
||||
MOSQ_ERR_AUTH = 11,
|
||||
MOSQ_ERR_ACL_DENIED = 12
|
||||
};
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_init(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_acl_check(void *user_data, const char *clientid, const char *username, const char *topic, int access)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)clientid;
|
||||
(void)topic;
|
||||
|
||||
if(access != MOSQ_ACL_READ && access != MOSQ_ACL_WRITE){
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}else if(username && !strcmp(username, "readonly") && access == MOSQ_ACL_READ){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else if(username && !strcmp(username, "readwrite")){
|
||||
if((!strcmp(topic, "readonly") && access == MOSQ_ACL_READ)
|
||||
|| !strcmp(topic, "writeable")){
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else{
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}
|
||||
|
||||
}else{
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
int mosquitto_auth_unpwd_check(void *user_data, const char *username, const char *password)
|
||||
{
|
||||
(void)user_data;
|
||||
|
||||
if(!strcmp(username, "test-username") && password && !strcmp(password, "cnwTICONIURW")){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else if(!strcmp(username, "readonly") || !strcmp(username, "readwrite")){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else if(!strcmp(username, "test-username@v2")){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else{
|
||||
return MOSQ_ERR_AUTH;
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "mosquitto_plugin_v2.h"
|
||||
|
||||
/*
|
||||
* Following constant come from mosquitto.h
|
||||
*
|
||||
* They are copied here to fix value of those constant at the time of MOSQ_AUTH_PLUGIN_VERSION == 2
|
||||
*/
|
||||
enum mosq_err_t {
|
||||
MOSQ_ERR_SUCCESS = 0,
|
||||
MOSQ_ERR_AUTH = 11,
|
||||
MOSQ_ERR_ACL_DENIED = 12
|
||||
};
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_init(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_acl_check(void *user_data, const char *clientid, const char *username, const char *topic, int access)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)clientid;
|
||||
(void)topic;
|
||||
|
||||
if(access != MOSQ_ACL_READ && access != MOSQ_ACL_WRITE){
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}else if(username && !strcmp(username, "readonly") && access == MOSQ_ACL_READ){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else if(username && !strcmp(username, "readwrite")){
|
||||
if((!strcmp(topic, "readonly") && access == MOSQ_ACL_READ)
|
||||
|| !strcmp(topic, "writeable")){
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else{
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}
|
||||
|
||||
}else{
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "mosquitto_plugin_v2.h"
|
||||
|
||||
/*
|
||||
* Following constant come from mosquitto.h
|
||||
*
|
||||
* They are copied here to fix value of those constant at the time of MOSQ_AUTH_PLUGIN_VERSION == 2
|
||||
*/
|
||||
enum mosq_err_t {
|
||||
MOSQ_ERR_SUCCESS = 0,
|
||||
MOSQ_ERR_AUTH = 11,
|
||||
MOSQ_ERR_ACL_DENIED = 12
|
||||
};
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_init(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "mosquitto_plugin_v2.h"
|
||||
|
||||
/*
|
||||
* Following constant come from mosquitto.h
|
||||
*
|
||||
* They are copied here to fix value of those constant at the time of MOSQ_AUTH_PLUGIN_VERSION == 2
|
||||
*/
|
||||
enum mosq_err_t {
|
||||
MOSQ_ERR_SUCCESS = 0,
|
||||
MOSQ_ERR_AUTH = 11,
|
||||
MOSQ_ERR_ACL_DENIED = 12
|
||||
};
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_init(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "mosquitto_plugin_v2.h"
|
||||
|
||||
/*
|
||||
* Following constant come from mosquitto.h
|
||||
*
|
||||
* They are copied here to fix value of those constant at the time of MOSQ_AUTH_PLUGIN_VERSION == 2
|
||||
*/
|
||||
enum mosq_err_t {
|
||||
MOSQ_ERR_SUCCESS = 0,
|
||||
MOSQ_ERR_AUTH = 11,
|
||||
MOSQ_ERR_ACL_DENIED = 12
|
||||
};
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "mosquitto_plugin_v2.h"
|
||||
|
||||
/*
|
||||
* Following constant come from mosquitto.h
|
||||
*
|
||||
* They are copied here to fix value of those constant at the time of MOSQ_AUTH_PLUGIN_VERSION == 2
|
||||
*/
|
||||
enum mosq_err_t {
|
||||
MOSQ_ERR_SUCCESS = 0,
|
||||
MOSQ_ERR_AUTH = 11,
|
||||
MOSQ_ERR_ACL_DENIED = 12
|
||||
};
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_auth_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "mosquitto_plugin_v2.h"
|
||||
|
||||
/*
|
||||
* Following constant come from mosquitto.h
|
||||
*
|
||||
* They are copied here to fix value of those constant at the time of MOSQ_AUTH_PLUGIN_VERSION == 2
|
||||
*/
|
||||
enum mosq_err_t {
|
||||
MOSQ_ERR_SUCCESS = 0,
|
||||
MOSQ_ERR_AUTH = 11,
|
||||
MOSQ_ERR_ACL_DENIED = 12
|
||||
};
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)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)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_acl_check(void *user_data, int access, struct mosquitto *client, const struct mosquitto_acl_msg *msg)
|
||||
{
|
||||
const char *username = mosquitto_client_username(client);
|
||||
|
||||
(void)user_data;
|
||||
|
||||
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 if(username && !strcmp(username, "readwrite")){
|
||||
if((!strcmp(msg->topic, "readonly") && access == MOSQ_ACL_READ)
|
||||
|| !strcmp(msg->topic, "writeable")){
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else{
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}
|
||||
|
||||
}else{
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}
|
||||
}
|
||||
|
||||
int mosquitto_auth_unpwd_check(void *user_data, struct mosquitto *client, const char *username, const char *password)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)client;
|
||||
|
||||
if(!strcmp(username, "test-username") && password && !strcmp(password, "cnwTICONIURW")){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else if(!strcmp(username, "readonly") || !strcmp(username, "readwrite")){
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else if(!strcmp(username, "test-username@v2")){
|
||||
return MOSQ_ERR_PLUGIN_DEFER;
|
||||
}else{
|
||||
return MOSQ_ERR_AUTH;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)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)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_acl_check(void *user_data, int access, struct mosquitto *client, const struct mosquitto_acl_msg *msg)
|
||||
{
|
||||
const char *username = mosquitto_client_username(client);
|
||||
|
||||
(void)user_data;
|
||||
|
||||
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 if(username && !strcmp(username, "readwrite")){
|
||||
if((!strcmp(msg->topic, "readonly") && access == MOSQ_ACL_READ)
|
||||
|| !strcmp(msg->topic, "writeable")){
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}else{
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}
|
||||
|
||||
}else{
|
||||
return MOSQ_ERR_ACL_DENIED;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)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)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count, bool reload)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)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)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 3;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)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)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
(void)reload;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *auth_opts, int auth_opt_count)
|
||||
{
|
||||
(void)user_data;
|
||||
(void)auth_opts;
|
||||
(void)auth_opt_count;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
int mosquitto_auth_plugin_version(void)
|
||||
{
|
||||
return 4;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(5);
|
@ -0,0 +1,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mosquitto.h>
|
||||
#include <mosquitto_broker.h>
|
||||
#include <mosquitto_plugin.h>
|
||||
|
||||
MOSQUITTO_PLUGIN_DECLARE_VERSION(6);
|
@ -0,0 +1,4 @@
|
||||
int dummy(void)
|
||||
{
|
||||
return 4;
|
||||
}
|
Loading…
Reference in New Issue