mirror of
https://github.com/eclipse/mosquitto.git
synced 2025-05-08 16:52:13 +08:00
Fixes for lots of minor build warnings highlighted by Visual Studio.
This commit is contained in:
parent
e717b7f42c
commit
370cec5edd
@ -16,6 +16,7 @@ Broker:
|
|||||||
Build:
|
Build:
|
||||||
- `install` Makefile target should depend on `all`, not `mosquitto`, to ensure
|
- `install` Makefile target should depend on `all`, not `mosquitto`, to ensure
|
||||||
that man pages are always built. Closes #1989.
|
that man pages are always built. Closes #1989.
|
||||||
|
- Fixes for lots of minor build warnings highlighted by Visual Studio.
|
||||||
|
|
||||||
Apps:
|
Apps:
|
||||||
- Disallow control characters in mosquitto_passwd usernames.
|
- Disallow control characters in mosquitto_passwd usernames.
|
||||||
|
@ -36,6 +36,8 @@ static void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto
|
|||||||
{
|
{
|
||||||
struct mosq_ctrl *ctrl = obj;
|
struct mosq_ctrl *ctrl = obj;
|
||||||
|
|
||||||
|
UNUSED(properties);
|
||||||
|
|
||||||
if(ctrl->payload_callback){
|
if(ctrl->payload_callback){
|
||||||
ctrl->payload_callback(ctrl, msg->payloadlen, msg->payload);
|
ctrl->payload_callback(ctrl, msg->payloadlen, msg->payload);
|
||||||
}
|
}
|
||||||
@ -47,6 +49,10 @@ static void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto
|
|||||||
|
|
||||||
static void on_publish(struct mosquitto *mosq, void *obj, int mid, int reason_code, const mosquitto_property *properties)
|
static void on_publish(struct mosquitto *mosq, void *obj, int mid, int reason_code, const mosquitto_property *properties)
|
||||||
{
|
{
|
||||||
|
UNUSED(obj);
|
||||||
|
UNUSED(mid);
|
||||||
|
UNUSED(properties);
|
||||||
|
|
||||||
if(reason_code > 127){
|
if(reason_code > 127){
|
||||||
fprintf(stderr, "Publish error: %s\n", mosquitto_reason_string(reason_code));
|
fprintf(stderr, "Publish error: %s\n", mosquitto_reason_string(reason_code));
|
||||||
run = 0;
|
run = 0;
|
||||||
@ -59,6 +65,9 @@ static void on_subscribe(struct mosquitto *mosq, void *obj, int mid, int qos_cou
|
|||||||
{
|
{
|
||||||
struct mosq_ctrl *ctrl = obj;
|
struct mosq_ctrl *ctrl = obj;
|
||||||
|
|
||||||
|
UNUSED(mid);
|
||||||
|
UNUSED(properties);
|
||||||
|
|
||||||
if(qos_count == 1){
|
if(qos_count == 1){
|
||||||
if(granted_qos[0] < 128){
|
if(granted_qos[0] < 128){
|
||||||
/* Success */
|
/* Success */
|
||||||
@ -87,6 +96,9 @@ static void on_connect(struct mosquitto *mosq, void *obj, int reason_code, int f
|
|||||||
{
|
{
|
||||||
struct mosq_ctrl *ctrl = obj;
|
struct mosq_ctrl *ctrl = obj;
|
||||||
|
|
||||||
|
UNUSED(flags);
|
||||||
|
UNUSED(properties);
|
||||||
|
|
||||||
if(reason_code == 0){
|
if(reason_code == 0){
|
||||||
if(ctrl->response_topic){
|
if(ctrl->response_topic){
|
||||||
mosquitto_subscribe(mosq, NULL, ctrl->response_topic, ctrl->cfg.qos);
|
mosquitto_subscribe(mosq, NULL, ctrl->response_topic, ctrl->cfg.qos);
|
||||||
|
@ -124,7 +124,7 @@ static void print_list(cJSON *j_response, const char *arrayname, const char *key
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void print_roles(cJSON *j_roles, int slen)
|
static void print_roles(cJSON *j_roles, size_t slen)
|
||||||
{
|
{
|
||||||
bool first;
|
bool first;
|
||||||
cJSON *j_elem, *jtmp;
|
cJSON *j_elem, *jtmp;
|
||||||
@ -136,9 +136,9 @@ static void print_roles(cJSON *j_roles, int slen)
|
|||||||
if(jtmp && cJSON_IsString(jtmp)){
|
if(jtmp && cJSON_IsString(jtmp)){
|
||||||
if(first){
|
if(first){
|
||||||
first = false;
|
first = false;
|
||||||
printf("%-*s %s", slen, "Roles:", jtmp->valuestring);
|
printf("%-*s %s", (int)slen, "Roles:", jtmp->valuestring);
|
||||||
}else{
|
}else{
|
||||||
printf("%-*s %s", slen, "", jtmp->valuestring);
|
printf("%-*s %s", (int)slen, "", jtmp->valuestring);
|
||||||
}
|
}
|
||||||
jtmp = cJSON_GetObjectItem(j_elem, "priority");
|
jtmp = cJSON_GetObjectItem(j_elem, "priority");
|
||||||
if(jtmp && cJSON_IsNumber(jtmp)){
|
if(jtmp && cJSON_IsNumber(jtmp)){
|
||||||
@ -383,7 +383,13 @@ static void dynsec__payload_callback(struct mosq_ctrl *ctrl, long payloadlen, co
|
|||||||
{
|
{
|
||||||
cJSON *tree, *j_responses, *j_response, *j_command, *j_error;
|
cJSON *tree, *j_responses, *j_response, *j_command, *j_error;
|
||||||
|
|
||||||
|
UNUSED(ctrl);
|
||||||
|
|
||||||
|
#if CJSON_VERSION_FULL < 1007013
|
||||||
tree = cJSON_Parse(payload);
|
tree = cJSON_Parse(payload);
|
||||||
|
#else
|
||||||
|
tree = cJSON_ParseWithLength(payload, payloadlen);
|
||||||
|
#endif
|
||||||
if(tree == NULL){
|
if(tree == NULL){
|
||||||
fprintf(stderr, "Error: Payload not JSON.\n");
|
fprintf(stderr, "Error: Payload not JSON.\n");
|
||||||
return;
|
return;
|
||||||
@ -492,6 +498,9 @@ static int dynsec__set_default_acl_access(int argc, char *argv[], cJSON *j_comma
|
|||||||
|
|
||||||
static int dynsec__get_default_acl_access(int argc, char *argv[], cJSON *j_command)
|
static int dynsec__get_default_acl_access(int argc, char *argv[], cJSON *j_command)
|
||||||
{
|
{
|
||||||
|
UNUSED(argc);
|
||||||
|
UNUSED(argv);
|
||||||
|
|
||||||
if(cJSON_AddStringToObject(j_command, "command", "getDefaultACLAccess") == NULL
|
if(cJSON_AddStringToObject(j_command, "command", "getDefaultACLAccess") == NULL
|
||||||
){
|
){
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ SPDX-License-Identifier: EPL-2.0 OR EDL-1.0
|
|||||||
Contributors:
|
Contributors:
|
||||||
Roger Light - initial implementation and documentation.
|
Roger Light - initial implementation and documentation.
|
||||||
*/
|
*/
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <cjson/cJSON.h>
|
#include <cjson/cJSON.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -66,6 +68,9 @@ int dynsec_group__delete(int argc, char *argv[], cJSON *j_command)
|
|||||||
|
|
||||||
int dynsec_group__get_anonymous(int argc, char *argv[], cJSON *j_command)
|
int dynsec_group__get_anonymous(int argc, char *argv[], cJSON *j_command)
|
||||||
{
|
{
|
||||||
|
UNUSED(argc);
|
||||||
|
UNUSED(argv);
|
||||||
|
|
||||||
if(cJSON_AddStringToObject(j_command, "command", "getAnonymousGroup") == NULL
|
if(cJSON_AddStringToObject(j_command, "command", "getAnonymousGroup") == NULL
|
||||||
){
|
){
|
||||||
|
|
||||||
|
@ -241,6 +241,10 @@ static int pwfile_iterate(FILE *fptr, FILE *ftmp,
|
|||||||
* ====================================================================== */
|
* ====================================================================== */
|
||||||
static int delete_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const char *password, const char *line, struct cb_helper *helper)
|
static int delete_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const char *password, const char *line, struct cb_helper *helper)
|
||||||
{
|
{
|
||||||
|
UNUSED(fptr);
|
||||||
|
UNUSED(password);
|
||||||
|
UNUSED(line);
|
||||||
|
|
||||||
if(strcmp(username, helper->username)){
|
if(strcmp(username, helper->username)){
|
||||||
/* If this isn't the username to delete, write it to the new file */
|
/* If this isn't the username to delete, write it to the new file */
|
||||||
fprintf(ftmp, "%s", line);
|
fprintf(ftmp, "%s", line);
|
||||||
@ -274,6 +278,9 @@ int delete_pwuser(FILE *fptr, FILE *ftmp, const char *username)
|
|||||||
* ====================================================================== */
|
* ====================================================================== */
|
||||||
static int update_file_cb(FILE *fptr, FILE *ftmp, const char *username, const char *password, const char *line, struct cb_helper *helper)
|
static int update_file_cb(FILE *fptr, FILE *ftmp, const char *username, const char *password, const char *line, struct cb_helper *helper)
|
||||||
{
|
{
|
||||||
|
UNUSED(fptr);
|
||||||
|
UNUSED(line);
|
||||||
|
|
||||||
if(helper){
|
if(helper){
|
||||||
return output_new_password(ftmp, username, password, helper->iterations);
|
return output_new_password(ftmp, username, password, helper->iterations);
|
||||||
}else{
|
}else{
|
||||||
@ -294,6 +301,9 @@ static int update_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
UNUSED(fptr);
|
||||||
|
UNUSED(password);
|
||||||
|
|
||||||
if(strcmp(username, helper->username)){
|
if(strcmp(username, helper->username)){
|
||||||
/* If this isn't the matching user, then writing out the exiting line */
|
/* If this isn't the matching user, then writing out the exiting line */
|
||||||
fprintf(ftmp, "%s", line);
|
fprintf(ftmp, "%s", line);
|
||||||
|
@ -54,7 +54,7 @@ extern struct mosq_config cfg;
|
|||||||
|
|
||||||
bool process_messages = true;
|
bool process_messages = true;
|
||||||
int msg_count = 0;
|
int msg_count = 0;
|
||||||
struct mosquitto *mosq = NULL;
|
struct mosquitto *g_mosq = NULL;
|
||||||
static bool timed_out = false;
|
static bool timed_out = false;
|
||||||
static int connack_result = 0;
|
static int connack_result = 0;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ void my_signal_handler(int signum)
|
|||||||
{
|
{
|
||||||
if(signum == SIGALRM){
|
if(signum == SIGALRM){
|
||||||
process_messages = false;
|
process_messages = false;
|
||||||
mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
mosquitto_disconnect_v5(g_mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
||||||
timed_out = true;
|
timed_out = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,6 +82,10 @@ int my_publish(struct mosquitto *mosq, int *mid, const char *topic, int payloadl
|
|||||||
|
|
||||||
void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message, const mosquitto_property *properties)
|
void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message, const mosquitto_property *properties)
|
||||||
{
|
{
|
||||||
|
UNUSED(mosq);
|
||||||
|
UNUSED(obj);
|
||||||
|
UNUSED(properties);
|
||||||
|
|
||||||
print_message(&cfg, message, properties);
|
print_message(&cfg, message, properties);
|
||||||
switch(cfg.pub_mode){
|
switch(cfg.pub_mode){
|
||||||
case MSGMODE_CMD:
|
case MSGMODE_CMD:
|
||||||
@ -125,6 +129,10 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit
|
|||||||
|
|
||||||
void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags, const mosquitto_property *properties)
|
void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags, const mosquitto_property *properties)
|
||||||
{
|
{
|
||||||
|
UNUSED(obj);
|
||||||
|
UNUSED(flags);
|
||||||
|
UNUSED(properties);
|
||||||
|
|
||||||
connack_result = result;
|
connack_result = result;
|
||||||
if(!result){
|
if(!result){
|
||||||
client_state = rr_s_connected;
|
client_state = rr_s_connected;
|
||||||
@ -145,6 +153,10 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag
|
|||||||
|
|
||||||
void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos)
|
void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos)
|
||||||
{
|
{
|
||||||
|
UNUSED(obj);
|
||||||
|
UNUSED(mid);
|
||||||
|
UNUSED(qos_count);
|
||||||
|
|
||||||
if(granted_qos[0] < 128){
|
if(granted_qos[0] < 128){
|
||||||
client_state = rr_s_ready_to_publish;
|
client_state = rr_s_ready_to_publish;
|
||||||
}else{
|
}else{
|
||||||
@ -157,6 +169,12 @@ void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_c
|
|||||||
|
|
||||||
void my_publish_callback(struct mosquitto *mosq, void *obj, int mid, int reason_code, const mosquitto_property *properties)
|
void my_publish_callback(struct mosquitto *mosq, void *obj, int mid, int reason_code, const mosquitto_property *properties)
|
||||||
{
|
{
|
||||||
|
UNUSED(mosq);
|
||||||
|
UNUSED(obj);
|
||||||
|
UNUSED(mid);
|
||||||
|
UNUSED(reason_code);
|
||||||
|
UNUSED(properties);
|
||||||
|
|
||||||
client_state = rr_s_wait_for_response;
|
client_state = rr_s_wait_for_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,8 +346,8 @@ int main(int argc, char *argv[])
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
mosq = mosquitto_new(cfg.id, cfg.clean_session, &cfg);
|
g_mosq = mosquitto_new(cfg.id, cfg.clean_session, &cfg);
|
||||||
if(!mosq){
|
if(!g_mosq){
|
||||||
switch(errno){
|
switch(errno){
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
err_printf(&cfg, "Error: Out of memory.\n");
|
err_printf(&cfg, "Error: Out of memory.\n");
|
||||||
@ -340,17 +358,17 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if(client_opts_set(mosq, &cfg)){
|
if(client_opts_set(g_mosq, &cfg)){
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if(cfg.debug){
|
if(cfg.debug){
|
||||||
mosquitto_log_callback_set(mosq, my_log_callback);
|
mosquitto_log_callback_set(g_mosq, my_log_callback);
|
||||||
}
|
}
|
||||||
mosquitto_connect_v5_callback_set(mosq, my_connect_callback);
|
mosquitto_connect_v5_callback_set(g_mosq, my_connect_callback);
|
||||||
mosquitto_subscribe_callback_set(mosq, my_subscribe_callback);
|
mosquitto_subscribe_callback_set(g_mosq, my_subscribe_callback);
|
||||||
mosquitto_message_v5_callback_set(mosq, my_message_callback);
|
mosquitto_message_v5_callback_set(g_mosq, my_message_callback);
|
||||||
|
|
||||||
rc = client_connect(mosq, &cfg);
|
rc = client_connect(g_mosq, &cfg);
|
||||||
if(rc){
|
if(rc){
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -371,17 +389,17 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
do{
|
do{
|
||||||
rc = mosquitto_loop(mosq, -1, 1);
|
rc = mosquitto_loop(g_mosq, -1, 1);
|
||||||
if(client_state == rr_s_ready_to_publish){
|
if(client_state == rr_s_ready_to_publish){
|
||||||
client_state = rr_s_wait_for_response;
|
client_state = rr_s_wait_for_response;
|
||||||
switch(cfg.pub_mode){
|
switch(cfg.pub_mode){
|
||||||
case MSGMODE_CMD:
|
case MSGMODE_CMD:
|
||||||
case MSGMODE_FILE:
|
case MSGMODE_FILE:
|
||||||
case MSGMODE_STDIN_FILE:
|
case MSGMODE_STDIN_FILE:
|
||||||
rc = my_publish(mosq, &mid_sent, cfg.topic, cfg.msglen, cfg.message, cfg.qos, cfg.retain);
|
rc = my_publish(g_mosq, &mid_sent, cfg.topic, cfg.msglen, cfg.message, cfg.qos, cfg.retain);
|
||||||
break;
|
break;
|
||||||
case MSGMODE_NULL:
|
case MSGMODE_NULL:
|
||||||
rc = my_publish(mosq, &mid_sent, cfg.topic, 0, NULL, cfg.qos, cfg.retain);
|
rc = my_publish(g_mosq, &mid_sent, cfg.topic, 0, NULL, cfg.qos, cfg.retain);
|
||||||
break;
|
break;
|
||||||
case MSGMODE_STDIN_LINE:
|
case MSGMODE_STDIN_LINE:
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
@ -390,7 +408,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}while(rc == MOSQ_ERR_SUCCESS && client_state != rr_s_disconnect);
|
}while(rc == MOSQ_ERR_SUCCESS && client_state != rr_s_disconnect);
|
||||||
|
|
||||||
mosquitto_destroy(mosq);
|
mosquitto_destroy(g_mosq);
|
||||||
mosquitto_lib_cleanup();
|
mosquitto_lib_cleanup();
|
||||||
|
|
||||||
if(cfg.msg_count>0 && rc == MOSQ_ERR_NO_CONN){
|
if(cfg.msg_count>0 && rc == MOSQ_ERR_NO_CONN){
|
||||||
|
@ -41,7 +41,7 @@ Contributors:
|
|||||||
struct mosq_config cfg;
|
struct mosq_config cfg;
|
||||||
bool process_messages = true;
|
bool process_messages = true;
|
||||||
int msg_count = 0;
|
int msg_count = 0;
|
||||||
struct mosquitto *mosq = NULL;
|
struct mosquitto *g_mosq = NULL;
|
||||||
int last_mid = 0;
|
int last_mid = 0;
|
||||||
static bool timed_out = false;
|
static bool timed_out = false;
|
||||||
static int connack_result = 0;
|
static int connack_result = 0;
|
||||||
@ -53,7 +53,7 @@ void my_signal_handler(int signum)
|
|||||||
if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){
|
if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){
|
||||||
if(connack_received){
|
if(connack_received){
|
||||||
process_messages = false;
|
process_messages = false;
|
||||||
mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
mosquitto_disconnect_v5(g_mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
||||||
}else{
|
}else{
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
@ -358,8 +358,8 @@ int main(int argc, char *argv[])
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
mosq = mosquitto_new(cfg.id, cfg.clean_session, &cfg);
|
g_mosq = mosquitto_new(cfg.id, cfg.clean_session, &cfg);
|
||||||
if(!mosq){
|
if(!g_mosq){
|
||||||
switch(errno){
|
switch(errno){
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
err_printf(&cfg, "Error: Out of memory.\n");
|
err_printf(&cfg, "Error: Out of memory.\n");
|
||||||
@ -370,17 +370,17 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if(client_opts_set(mosq, &cfg)){
|
if(client_opts_set(g_mosq, &cfg)){
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if(cfg.debug){
|
if(cfg.debug){
|
||||||
mosquitto_log_callback_set(mosq, my_log_callback);
|
mosquitto_log_callback_set(g_mosq, my_log_callback);
|
||||||
}
|
}
|
||||||
mosquitto_subscribe_callback_set(mosq, my_subscribe_callback);
|
mosquitto_subscribe_callback_set(g_mosq, my_subscribe_callback);
|
||||||
mosquitto_connect_v5_callback_set(mosq, my_connect_callback);
|
mosquitto_connect_v5_callback_set(g_mosq, my_connect_callback);
|
||||||
mosquitto_message_v5_callback_set(mosq, my_message_callback);
|
mosquitto_message_v5_callback_set(g_mosq, my_message_callback);
|
||||||
|
|
||||||
rc = client_connect(mosq, &cfg);
|
rc = client_connect(g_mosq, &cfg);
|
||||||
if(rc){
|
if(rc){
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -410,9 +410,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = mosquitto_loop_forever(mosq, -1, 1);
|
rc = mosquitto_loop_forever(g_mosq, -1, 1);
|
||||||
|
|
||||||
mosquitto_destroy(mosq);
|
mosquitto_destroy(g_mosq);
|
||||||
mosquitto_lib_cleanup();
|
mosquitto_lib_cleanup();
|
||||||
|
|
||||||
if(cfg.msg_count>0 && rc == MOSQ_ERR_NO_CONN){
|
if(cfg.msg_count>0 && rc == MOSQ_ERR_NO_CONN){
|
||||||
@ -432,7 +432,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
mosquitto_destroy(mosq);
|
mosquitto_destroy(g_mosq);
|
||||||
mosquitto_lib_cleanup();
|
mosquitto_lib_cleanup();
|
||||||
client_config_cleanup(&cfg);
|
client_config_cleanup(&cfg);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -443,7 +443,7 @@ static void formatted_print_percent(const struct mosq_config *lcfg, const struct
|
|||||||
uint8_t i8value;
|
uint8_t i8value;
|
||||||
uint16_t i16value;
|
uint16_t i16value;
|
||||||
uint32_t i32value;
|
uint32_t i32value;
|
||||||
char *binvalue, *strname, *strvalue;
|
char *binvalue = NULL, *strname, *strvalue;
|
||||||
const mosquitto_property *prop;
|
const mosquitto_property *prop;
|
||||||
|
|
||||||
|
|
||||||
@ -627,8 +627,8 @@ static void formatted_print(const struct mosq_config *lcfg, const struct mosquit
|
|||||||
size_t len;
|
size_t len;
|
||||||
int i;
|
int i;
|
||||||
struct tm *ti = NULL;
|
struct tm *ti = NULL;
|
||||||
long ns;
|
long ns = 0;
|
||||||
char strf[3];
|
char strf[3] = {0, 0 ,0};
|
||||||
char buf[100];
|
char buf[100];
|
||||||
char align, pad;
|
char align, pad;
|
||||||
int field_width, precision;
|
int field_width, precision;
|
||||||
@ -769,7 +769,7 @@ void rand_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void print_message(struct mosq_config *cfg, const struct mosquitto_message *message, const mosquitto_property *properties)
|
void print_message(struct mosq_config *lcfg, const struct mosquitto_message *message, const mosquitto_property *properties)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
unsigned int r = 0;
|
unsigned int r = 0;
|
||||||
@ -777,27 +777,27 @@ void print_message(struct mosq_config *cfg, const struct mosquitto_message *mess
|
|||||||
long r = 0;
|
long r = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(cfg->random_filter < 10000){
|
if(lcfg->random_filter < 10000){
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
rand_s(&r);
|
rand_s(&r);
|
||||||
#else
|
#else
|
||||||
r = random();
|
r = random();
|
||||||
#endif
|
#endif
|
||||||
if((r%10000) >= cfg->random_filter){
|
if((long)(r%10000) >= lcfg->random_filter){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(cfg->format){
|
if(lcfg->format){
|
||||||
formatted_print(cfg, message, properties);
|
formatted_print(lcfg, message, properties);
|
||||||
}else if(cfg->verbose){
|
}else if(lcfg->verbose){
|
||||||
if(message->payloadlen){
|
if(message->payloadlen){
|
||||||
printf("%s ", message->topic);
|
printf("%s ", message->topic);
|
||||||
write_payload(message->payload, message->payloadlen, false, 0, 0, 0, 0);
|
write_payload(message->payload, message->payloadlen, false, 0, 0, 0, 0);
|
||||||
if(cfg->eol){
|
if(lcfg->eol){
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(cfg->eol){
|
if(lcfg->eol){
|
||||||
printf("%s (null)\n", message->topic);
|
printf("%s (null)\n", message->topic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -805,7 +805,7 @@ void print_message(struct mosq_config *cfg, const struct mosquitto_message *mess
|
|||||||
}else{
|
}else{
|
||||||
if(message->payloadlen){
|
if(message->payloadlen){
|
||||||
write_payload(message->payload, message->payloadlen, false, 0, 0, 0, 0);
|
write_payload(message->payload, message->payloadlen, false, 0, 0, 0, 0);
|
||||||
if(cfg->eol){
|
if(lcfg->eol){
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -39,7 +39,7 @@ int handle__publish(struct mosquitto *mosq)
|
|||||||
uint8_t header;
|
uint8_t header;
|
||||||
struct mosquitto_message_all *message;
|
struct mosquitto_message_all *message;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
uint16_t mid;
|
uint16_t mid = 0;
|
||||||
uint16_t slen;
|
uint16_t slen;
|
||||||
mosquitto_property *properties = NULL;
|
mosquitto_property *properties = NULL;
|
||||||
|
|
||||||
|
@ -393,9 +393,6 @@ static int net__try_connect_tcp(const char *host, uint16_t port, mosq_sock_t *so
|
|||||||
struct addrinfo *ainfo_bind, *rp_bind;
|
struct addrinfo *ainfo_bind, *rp_bind;
|
||||||
int s;
|
int s;
|
||||||
int rc = MOSQ_ERR_SUCCESS;
|
int rc = MOSQ_ERR_SUCCESS;
|
||||||
#ifdef WIN32
|
|
||||||
uint32_t val = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ainfo_bind = NULL;
|
ainfo_bind = NULL;
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg)
|
|||||||
X509_STORE *st = NULL;
|
X509_STORE *st = NULL;
|
||||||
STACK_OF(X509) *ch = NULL;
|
STACK_OF(X509) *ch = NULL;
|
||||||
|
|
||||||
|
UNUSED(ssl);
|
||||||
|
|
||||||
long len = SSL_get_tlsext_status_ocsp_resp(mosq->ssl, &p);
|
long len = SSL_get_tlsext_status_ocsp_resp(mosq->ssl, &p);
|
||||||
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: SSL_get_tlsext_status_ocsp_resp returned %ld bytes", len);
|
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: SSL_get_tlsext_status_ocsp_resp returned %ld bytes", len);
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ int mosquitto_loop_start(struct mosquitto *mosq)
|
|||||||
return MOSQ_ERR_ERRNO;
|
return MOSQ_ERR_ERRNO;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
UNUSED(mosq);
|
||||||
return MOSQ_ERR_NOT_SUPPORTED;
|
return MOSQ_ERR_NOT_SUPPORTED;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -91,6 +92,8 @@ int mosquitto_loop_stop(struct mosquitto *mosq, bool force)
|
|||||||
|
|
||||||
return MOSQ_ERR_SUCCESS;
|
return MOSQ_ERR_SUCCESS;
|
||||||
#else
|
#else
|
||||||
|
UNUSED(mosq);
|
||||||
|
UNUSED(force);
|
||||||
return MOSQ_ERR_NOT_SUPPORTED;
|
return MOSQ_ERR_NOT_SUPPORTED;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ typedef int (*MOSQ_FUNC_acl_check)(struct mosquitto_evt_acl_check *, struct dyns
|
|||||||
|
|
||||||
static int acl_check_publish_c_recv(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
static int acl_check_publish_c_recv(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
||||||
{
|
{
|
||||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||||
struct dynsec__acl *acl, *acl_tmp;
|
struct dynsec__acl *acl, *acl_tmp = NULL;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
HASH_ITER(hh, base_rolelist, rolelist, rolelist_tmp){
|
HASH_ITER(hh, base_rolelist, rolelist, rolelist_tmp){
|
||||||
@ -63,8 +63,8 @@ static int acl_check_publish_c_recv(struct mosquitto_evt_acl_check *ed, struct d
|
|||||||
|
|
||||||
static int acl_check_publish_c_send(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
static int acl_check_publish_c_send(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
||||||
{
|
{
|
||||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||||
struct dynsec__acl *acl, *acl_tmp;
|
struct dynsec__acl *acl, *acl_tmp = NULL;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
HASH_ITER(hh, base_rolelist, rolelist, rolelist_tmp){
|
HASH_ITER(hh, base_rolelist, rolelist, rolelist_tmp){
|
||||||
@ -91,8 +91,8 @@ static int acl_check_publish_c_send(struct mosquitto_evt_acl_check *ed, struct d
|
|||||||
|
|
||||||
static int acl_check_subscribe(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
static int acl_check_subscribe(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
||||||
{
|
{
|
||||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||||
struct dynsec__acl *acl, *acl_tmp;
|
struct dynsec__acl *acl, *acl_tmp = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = strlen(ed->topic);
|
len = strlen(ed->topic);
|
||||||
@ -128,8 +128,8 @@ static int acl_check_subscribe(struct mosquitto_evt_acl_check *ed, struct dynsec
|
|||||||
|
|
||||||
static int acl_check_unsubscribe(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
static int acl_check_unsubscribe(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
||||||
{
|
{
|
||||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||||
struct dynsec__acl *acl, *acl_tmp;
|
struct dynsec__acl *acl, *acl_tmp = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = strlen(ed->topic);
|
len = strlen(ed->topic);
|
||||||
@ -163,10 +163,10 @@ static int acl_check_unsubscribe(struct mosquitto_evt_acl_check *ed, struct dyns
|
|||||||
* #
|
* #
|
||||||
* ################################################################ */
|
* ################################################################ */
|
||||||
|
|
||||||
static int acl_check(struct mosquitto_evt_acl_check *ed, MOSQ_FUNC_acl_check check, bool default_access)
|
static int acl_check(struct mosquitto_evt_acl_check *ed, MOSQ_FUNC_acl_check check, bool acl_default_access)
|
||||||
{
|
{
|
||||||
struct dynsec__client *client;
|
struct dynsec__client *client;
|
||||||
struct dynsec__grouplist *grouplist, *grouplist_tmp;
|
struct dynsec__grouplist *grouplist, *grouplist_tmp = NULL;
|
||||||
const char *username;
|
const char *username;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ static int acl_check(struct mosquitto_evt_acl_check *ed, MOSQ_FUNC_acl_check che
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(default_access == false){
|
if(acl_default_access == false){
|
||||||
return MOSQ_ERR_PLUGIN_DEFER;
|
return MOSQ_ERR_PLUGIN_DEFER;
|
||||||
}else{
|
}else{
|
||||||
if(!strncmp(ed->topic, "$CONTROL", strlen("$CONTROL"))){
|
if(!strncmp(ed->topic, "$CONTROL", strlen("$CONTROL"))){
|
||||||
@ -220,6 +220,9 @@ int dynsec__acl_check_callback(int event, void *event_data, void *userdata)
|
|||||||
{
|
{
|
||||||
struct mosquitto_evt_acl_check *ed = event_data;
|
struct mosquitto_evt_acl_check *ed = event_data;
|
||||||
|
|
||||||
|
UNUSED(event);
|
||||||
|
UNUSED(userdata);
|
||||||
|
|
||||||
/* ACL checks are made in the order below until a match occurs, at which
|
/* ACL checks are made in the order below until a match occurs, at which
|
||||||
* point the decision is made.
|
* point the decision is made.
|
||||||
*
|
*
|
||||||
|
@ -37,7 +37,7 @@ Contributors:
|
|||||||
int dynsec_auth__base64_encode(unsigned char *in, int in_len, char **encoded)
|
int dynsec_auth__base64_encode(unsigned char *in, int in_len, char **encoded)
|
||||||
{
|
{
|
||||||
BIO *bmem, *b64;
|
BIO *bmem, *b64;
|
||||||
BUF_MEM *bptr;
|
BUF_MEM *bptr = NULL;
|
||||||
|
|
||||||
if(in_len < 0) return 1;
|
if(in_len < 0) return 1;
|
||||||
|
|
||||||
@ -178,6 +178,9 @@ int dynsec_auth__basic_auth_callback(int event, void *event_data, void *userdata
|
|||||||
unsigned char password_hash[64]; /* For SHA512 */
|
unsigned char password_hash[64]; /* For SHA512 */
|
||||||
const char *clientid;
|
const char *clientid;
|
||||||
|
|
||||||
|
UNUSED(event);
|
||||||
|
UNUSED(userdata);
|
||||||
|
|
||||||
if(ed->username == NULL || ed->password == NULL) return MOSQ_ERR_PLUGIN_DEFER;
|
if(ed->username == NULL || ed->password == NULL) return MOSQ_ERR_PLUGIN_DEFER;
|
||||||
|
|
||||||
client = dynsec_clients__find(ed->username);
|
client = dynsec_clients__find(ed->username);
|
||||||
|
@ -170,7 +170,7 @@ int dynsec_groups__process_add_role(cJSON *j_responses, struct mosquitto *contex
|
|||||||
|
|
||||||
void dynsec_groups__cleanup(void)
|
void dynsec_groups__cleanup(void)
|
||||||
{
|
{
|
||||||
struct dynsec__group *group, *group_tmp;
|
struct dynsec__group *group, *group_tmp = NULL;
|
||||||
|
|
||||||
HASH_ITER(hh, local_groups, group, group_tmp){
|
HASH_ITER(hh, local_groups, group, group_tmp){
|
||||||
group__free_item(group);
|
group__free_item(group);
|
||||||
@ -300,7 +300,7 @@ int dynsec_groups__config_load(cJSON *tree)
|
|||||||
|
|
||||||
static int dynsec__config_add_groups(cJSON *j_groups)
|
static int dynsec__config_add_groups(cJSON *j_groups)
|
||||||
{
|
{
|
||||||
struct dynsec__group *group, *group_tmp;
|
struct dynsec__group *group, *group_tmp = NULL;
|
||||||
cJSON *j_group, *j_clients, *j_roles;
|
cJSON *j_group, *j_clients, *j_roles;
|
||||||
|
|
||||||
HASH_ITER(hh, local_groups, group, group_tmp){
|
HASH_ITER(hh, local_groups, group, group_tmp){
|
||||||
@ -572,7 +572,7 @@ int dynsec_groups__process_add_client(cJSON *j_responses, struct mosquitto *cont
|
|||||||
|
|
||||||
static int dynsec__remove_all_clients_from_group(struct dynsec__group *group)
|
static int dynsec__remove_all_clients_from_group(struct dynsec__group *group)
|
||||||
{
|
{
|
||||||
struct dynsec__clientlist *clientlist, *clientlist_tmp;
|
struct dynsec__clientlist *clientlist, *clientlist_tmp = NULL;
|
||||||
|
|
||||||
HASH_ITER(hh, group->clientlist, clientlist, clientlist_tmp){
|
HASH_ITER(hh, group->clientlist, clientlist, clientlist_tmp){
|
||||||
/* Remove client stored group reference */
|
/* Remove client stored group reference */
|
||||||
@ -587,7 +587,7 @@ static int dynsec__remove_all_clients_from_group(struct dynsec__group *group)
|
|||||||
|
|
||||||
static int dynsec__remove_all_roles_from_group(struct dynsec__group *group)
|
static int dynsec__remove_all_roles_from_group(struct dynsec__group *group)
|
||||||
{
|
{
|
||||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||||
|
|
||||||
HASH_ITER(hh, group->rolelist, rolelist, rolelist_tmp){
|
HASH_ITER(hh, group->rolelist, rolelist, rolelist_tmp){
|
||||||
dynsec_rolelist__group_remove(group, rolelist->role);
|
dynsec_rolelist__group_remove(group, rolelist->role);
|
||||||
@ -670,7 +670,7 @@ int dynsec_groups__process_remove_client(cJSON *j_responses, struct mosquitto *c
|
|||||||
static cJSON *add_group_to_json(struct dynsec__group *group)
|
static cJSON *add_group_to_json(struct dynsec__group *group)
|
||||||
{
|
{
|
||||||
cJSON *j_group, *jtmp, *j_clientlist, *j_client, *j_rolelist;
|
cJSON *j_group, *jtmp, *j_clientlist, *j_client, *j_rolelist;
|
||||||
struct dynsec__clientlist *clientlist, *clientlist_tmp;
|
struct dynsec__clientlist *clientlist, *clientlist_tmp = NULL;
|
||||||
|
|
||||||
j_group = cJSON_CreateObject();
|
j_group = cJSON_CreateObject();
|
||||||
if(j_group == NULL){
|
if(j_group == NULL){
|
||||||
@ -718,7 +718,7 @@ int dynsec_groups__process_list(cJSON *j_responses, struct mosquitto *context, c
|
|||||||
{
|
{
|
||||||
bool verbose;
|
bool verbose;
|
||||||
cJSON *tree, *j_groups, *j_group, *j_data;
|
cJSON *tree, *j_groups, *j_group, *j_data;
|
||||||
struct dynsec__group *group, *group_tmp;
|
struct dynsec__group *group, *group_tmp = NULL;
|
||||||
int i, count, offset;
|
int i, count, offset;
|
||||||
const char *admin_clientid, *admin_username;
|
const char *admin_clientid, *admin_username;
|
||||||
|
|
||||||
@ -1042,6 +1042,8 @@ int dynsec_groups__process_get_anonymous_group(cJSON *j_responses, struct mosqui
|
|||||||
const char *groupname;
|
const char *groupname;
|
||||||
const char *admin_clientid, *admin_username;
|
const char *admin_clientid, *admin_username;
|
||||||
|
|
||||||
|
UNUSED(command);
|
||||||
|
|
||||||
tree = cJSON_CreateObject();
|
tree = cJSON_CreateObject();
|
||||||
if(tree == NULL){
|
if(tree == NULL){
|
||||||
dynsec__command_reply(j_responses, context, "getAnonymousGroup", "Internal error", correlation_data);
|
dynsec__command_reply(j_responses, context, "getAnonymousGroup", "Internal error", correlation_data);
|
||||||
|
@ -41,6 +41,8 @@ void dynsec__command_reply(cJSON *j_responses, struct mosquitto *context, const
|
|||||||
{
|
{
|
||||||
cJSON *j_response;
|
cJSON *j_response;
|
||||||
|
|
||||||
|
UNUSED(context);
|
||||||
|
|
||||||
j_response = cJSON_CreateObject();
|
j_response = cJSON_CreateObject();
|
||||||
if(j_response == NULL) return;
|
if(j_response == NULL) return;
|
||||||
|
|
||||||
@ -82,6 +84,9 @@ static int dynsec_control_callback(int event, void *event_data, void *userdata)
|
|||||||
cJSON *tree, *commands;
|
cJSON *tree, *commands;
|
||||||
cJSON *j_response_tree, *j_responses;
|
cJSON *j_response_tree, *j_responses;
|
||||||
|
|
||||||
|
UNUSED(event);
|
||||||
|
UNUSED(userdata);
|
||||||
|
|
||||||
/* Create object for responses */
|
/* Create object for responses */
|
||||||
j_response_tree = cJSON_CreateObject();
|
j_response_tree = cJSON_CreateObject();
|
||||||
if(j_response_tree == NULL){
|
if(j_response_tree == NULL){
|
||||||
@ -174,6 +179,8 @@ int dynsec__process_get_default_acl_access(cJSON *j_responses, struct mosquitto
|
|||||||
cJSON *tree, *jtmp, *j_data, *j_acls, *j_acl;
|
cJSON *tree, *jtmp, *j_data, *j_acls, *j_acl;
|
||||||
const char *admin_clientid, *admin_username;
|
const char *admin_clientid, *admin_username;
|
||||||
|
|
||||||
|
UNUSED(command);
|
||||||
|
|
||||||
tree = cJSON_CreateObject();
|
tree = cJSON_CreateObject();
|
||||||
if(tree == NULL){
|
if(tree == NULL){
|
||||||
dynsec__command_reply(j_responses, context, "getDefaultACLAccess", "Internal error", correlation_data);
|
dynsec__command_reply(j_responses, context, "getDefaultACLAccess", "Internal error", correlation_data);
|
||||||
@ -465,6 +472,8 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
UNUSED(user_data);
|
||||||
|
|
||||||
for(i=0; i<option_count; i++){
|
for(i=0; i<option_count; i++){
|
||||||
if(!strcasecmp(options[i].key, "config_file")){
|
if(!strcasecmp(options[i].key, "config_file")){
|
||||||
config_file = mosquitto_strdup(options[i].value);
|
config_file = mosquitto_strdup(options[i].value);
|
||||||
@ -491,6 +500,10 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
|
|||||||
|
|
||||||
int mosquitto_plugin_cleanup(void *user_data, struct mosquitto_opt *options, int option_count)
|
int mosquitto_plugin_cleanup(void *user_data, struct mosquitto_opt *options, int option_count)
|
||||||
{
|
{
|
||||||
|
UNUSED(user_data);
|
||||||
|
UNUSED(options);
|
||||||
|
UNUSED(option_count);
|
||||||
|
|
||||||
if(plg_id){
|
if(plg_id){
|
||||||
mosquitto_callback_unregister(plg_id, MOSQ_EVT_CONTROL, dynsec_control_callback, "$CONTROL/dynamic-security/v1");
|
mosquitto_callback_unregister(plg_id, MOSQ_EVT_CONTROL, dynsec_control_callback, "$CONTROL/dynamic-security/v1");
|
||||||
mosquitto_callback_unregister(plg_id, MOSQ_EVT_BASIC_AUTH, dynsec_auth__basic_auth_callback, NULL);
|
mosquitto_callback_unregister(plg_id, MOSQ_EVT_BASIC_AUTH, dynsec_auth__basic_auth_callback, NULL);
|
||||||
|
@ -66,7 +66,7 @@ static void role__free_acl(struct dynsec__acl **acl, struct dynsec__acl *item)
|
|||||||
|
|
||||||
static void role__free_all_acls(struct dynsec__acl **acl)
|
static void role__free_all_acls(struct dynsec__acl **acl)
|
||||||
{
|
{
|
||||||
struct dynsec__acl *iter, *tmp;
|
struct dynsec__acl *iter, *tmp = NULL;
|
||||||
|
|
||||||
HASH_ITER(hh, *acl, iter, tmp){
|
HASH_ITER(hh, *acl, iter, tmp){
|
||||||
role__free_acl(acl, iter);
|
role__free_acl(acl, iter);
|
||||||
@ -105,7 +105,7 @@ struct dynsec__role *dynsec_roles__find(const char *rolename)
|
|||||||
|
|
||||||
void dynsec_roles__cleanup(void)
|
void dynsec_roles__cleanup(void)
|
||||||
{
|
{
|
||||||
struct dynsec__role *role, *role_tmp;
|
struct dynsec__role *role, *role_tmp = NULL;
|
||||||
|
|
||||||
HASH_ITER(hh, local_roles, role, role_tmp){
|
HASH_ITER(hh, local_roles, role, role_tmp){
|
||||||
role__free_item(role, true);
|
role__free_item(role, true);
|
||||||
@ -115,7 +115,7 @@ void dynsec_roles__cleanup(void)
|
|||||||
|
|
||||||
static void role__kick_all(struct dynsec__role *role)
|
static void role__kick_all(struct dynsec__role *role)
|
||||||
{
|
{
|
||||||
struct dynsec__grouplist *grouplist, *grouplist_tmp;
|
struct dynsec__grouplist *grouplist, *grouplist_tmp = NULL;
|
||||||
|
|
||||||
dynsec_clientlist__kick_all(role->clientlist);
|
dynsec_clientlist__kick_all(role->clientlist);
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ static void role__kick_all(struct dynsec__role *role)
|
|||||||
|
|
||||||
static int add_single_acl_to_json(cJSON *j_array, const char *acl_type, struct dynsec__acl *acl)
|
static int add_single_acl_to_json(cJSON *j_array, const char *acl_type, struct dynsec__acl *acl)
|
||||||
{
|
{
|
||||||
struct dynsec__acl *iter, *tmp;
|
struct dynsec__acl *iter, *tmp = NULL;
|
||||||
cJSON *j_acl;
|
cJSON *j_acl;
|
||||||
|
|
||||||
HASH_ITER(hh, acl, iter, tmp){
|
HASH_ITER(hh, acl, iter, tmp){
|
||||||
@ -185,7 +185,7 @@ static int add_acls_to_json(cJSON *j_role, struct dynsec__role *role)
|
|||||||
int dynsec_roles__config_save(cJSON *tree)
|
int dynsec_roles__config_save(cJSON *tree)
|
||||||
{
|
{
|
||||||
cJSON *j_roles, *j_role;
|
cJSON *j_roles, *j_role;
|
||||||
struct dynsec__role *role, *role_tmp;
|
struct dynsec__role *role, *role_tmp = NULL;
|
||||||
|
|
||||||
if((j_roles = cJSON_AddArrayToObject(tree, "roles")) == NULL){
|
if((j_roles = cJSON_AddArrayToObject(tree, "roles")) == NULL){
|
||||||
return 1;
|
return 1;
|
||||||
@ -433,7 +433,7 @@ error:
|
|||||||
|
|
||||||
static void role__remove_all_clients(struct dynsec__role *role)
|
static void role__remove_all_clients(struct dynsec__role *role)
|
||||||
{
|
{
|
||||||
struct dynsec__clientlist *clientlist, *clientlist_tmp;
|
struct dynsec__clientlist *clientlist, *clientlist_tmp = NULL;
|
||||||
|
|
||||||
HASH_ITER(hh, role->clientlist, clientlist, clientlist_tmp){
|
HASH_ITER(hh, role->clientlist, clientlist, clientlist_tmp){
|
||||||
mosquitto_kick_client_by_username(clientlist->client->username, false);
|
mosquitto_kick_client_by_username(clientlist->client->username, false);
|
||||||
@ -444,7 +444,7 @@ static void role__remove_all_clients(struct dynsec__role *role)
|
|||||||
|
|
||||||
static void role__remove_all_groups(struct dynsec__role *role)
|
static void role__remove_all_groups(struct dynsec__role *role)
|
||||||
{
|
{
|
||||||
struct dynsec__grouplist *grouplist, *grouplist_tmp;
|
struct dynsec__grouplist *grouplist, *grouplist_tmp = NULL;
|
||||||
|
|
||||||
HASH_ITER(hh, role->grouplist, grouplist, grouplist_tmp){
|
HASH_ITER(hh, role->grouplist, grouplist, grouplist_tmp){
|
||||||
if(grouplist->group == dynsec_anonymous_group){
|
if(grouplist->group == dynsec_anonymous_group){
|
||||||
@ -526,7 +526,7 @@ static cJSON *add_role_to_json(struct dynsec__role *role, bool verbose)
|
|||||||
int dynsec_roles__process_list(cJSON *j_responses, struct mosquitto *context, cJSON *command, char *correlation_data)
|
int dynsec_roles__process_list(cJSON *j_responses, struct mosquitto *context, cJSON *command, char *correlation_data)
|
||||||
{
|
{
|
||||||
bool verbose;
|
bool verbose;
|
||||||
struct dynsec__role *role, *role_tmp;
|
struct dynsec__role *role, *role_tmp = NULL;
|
||||||
cJSON *tree, *j_roles, *j_role, *j_data;
|
cJSON *tree, *j_roles, *j_role, *j_data;
|
||||||
int i, count, offset;
|
int i, count, offset;
|
||||||
const char *admin_clientid, *admin_username;
|
const char *admin_clientid, *admin_username;
|
||||||
|
@ -32,8 +32,6 @@ Contributors:
|
|||||||
*
|
*
|
||||||
* Note that this only works on Mosquitto 2.0 or later.
|
* Note that this only works on Mosquitto 2.0 or later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -42,6 +40,8 @@ Contributors:
|
|||||||
#include "mosquitto.h"
|
#include "mosquitto.h"
|
||||||
#include "mqtt_protocol.h"
|
#include "mqtt_protocol.h"
|
||||||
|
|
||||||
|
#define UNUSED(A) (void)(A)
|
||||||
|
|
||||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||||
|
|
||||||
static int callback_message(int event, void *event_data, void *userdata)
|
static int callback_message(int event, void *event_data, void *userdata)
|
||||||
@ -50,6 +50,9 @@ static int callback_message(int event, void *event_data, void *userdata)
|
|||||||
char *new_payload;
|
char *new_payload;
|
||||||
uint32_t new_payloadlen;
|
uint32_t new_payloadlen;
|
||||||
|
|
||||||
|
UNUSED(event);
|
||||||
|
UNUSED(userdata);
|
||||||
|
|
||||||
/* This simply adds "hello " to the front of every payload. You can of
|
/* This simply adds "hello " to the front of every payload. You can of
|
||||||
* course do much more complicated message processing if needed. */
|
* course do much more complicated message processing if needed. */
|
||||||
|
|
||||||
@ -91,11 +94,19 @@ int mosquitto_plugin_version(int supported_version_count, const int *supported_v
|
|||||||
|
|
||||||
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count)
|
||||||
{
|
{
|
||||||
|
UNUSED(user_data);
|
||||||
|
UNUSED(opts);
|
||||||
|
UNUSED(opt_count);
|
||||||
|
|
||||||
mosq_pid = identifier;
|
mosq_pid = identifier;
|
||||||
return mosquitto_callback_register(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL, NULL);
|
return mosquitto_callback_register(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mosquitto_plugin_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count)
|
int mosquitto_plugin_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count)
|
||||||
{
|
{
|
||||||
|
UNUSED(user_data);
|
||||||
|
UNUSED(opts);
|
||||||
|
UNUSED(opt_count);
|
||||||
|
|
||||||
return mosquitto_callback_unregister(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL);
|
return mosquitto_callback_unregister(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ int bridge__new(struct mosquitto__bridge *bridge)
|
|||||||
mosquitto__free(local_id);
|
mosquitto__free(local_id);
|
||||||
}else{
|
}else{
|
||||||
/* id wasn't found, so generate a new context */
|
/* id wasn't found, so generate a new context */
|
||||||
new_context = context__init(-1);
|
new_context = context__init(INVALID_SOCKET);
|
||||||
if(!new_context){
|
if(!new_context){
|
||||||
mosquitto__free(local_id);
|
mosquitto__free(local_id);
|
||||||
return MOSQ_ERR_NOMEM;
|
return MOSQ_ERR_NOMEM;
|
||||||
|
@ -2047,7 +2047,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|||||||
token = strtok_r(NULL, " ", &saveptr);
|
token = strtok_r(NULL, " ", &saveptr);
|
||||||
if(token){
|
if(token){
|
||||||
if (token[0] == '#'){
|
if (token[0] == '#'){
|
||||||
strtok_r(NULL, "", &saveptr);
|
(void)strtok_r(NULL, "", &saveptr);
|
||||||
}
|
}
|
||||||
qos = (uint8_t)atoi(token);
|
qos = (uint8_t)atoi(token);
|
||||||
if(qos > 2){
|
if(qos > 2){
|
||||||
@ -2060,7 +2060,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
|||||||
if(!strcmp(token, "\"\"") || token[0] == '#'){
|
if(!strcmp(token, "\"\"") || token[0] == '#'){
|
||||||
local_prefix = NULL;
|
local_prefix = NULL;
|
||||||
if (token[0] == '#'){
|
if (token[0] == '#'){
|
||||||
strtok_r(NULL, "", &saveptr);
|
(void)strtok_r(NULL, "", &saveptr);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
local_prefix = token;
|
local_prefix = token;
|
||||||
@ -2275,7 +2275,7 @@ static int config__check(struct mosquitto__config *config)
|
|||||||
if(!config->listeners[i].security_options.auto_id_prefix){
|
if(!config->listeners[i].security_options.auto_id_prefix){
|
||||||
return MOSQ_ERR_NOMEM;
|
return MOSQ_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
config->listeners[i].security_options.auto_id_prefix_len = strlen("auto-");
|
config->listeners[i].security_options.auto_id_prefix_len = (uint16_t)strlen("auto-");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -2284,7 +2284,7 @@ static int config__check(struct mosquitto__config *config)
|
|||||||
if(!config->security_options.auto_id_prefix){
|
if(!config->security_options.auto_id_prefix){
|
||||||
return MOSQ_ERR_NOMEM;
|
return MOSQ_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
config->security_options.auto_id_prefix_len = strlen("auto-");
|
config->security_options.auto_id_prefix_len = (uint16_t)strlen("auto-");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ int scmp_p(const void *p1, const void *p2)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int config__get_dir_files(const char *include_dir, char ***files, int *file_count)
|
int config__get_dir_files(const char *include_dir, char ***files, int *file_count)
|
||||||
{
|
{
|
||||||
int len;
|
size_t len;
|
||||||
int i;
|
int i;
|
||||||
char **l_files = NULL;
|
char **l_files = NULL;
|
||||||
int l_file_count = 0;
|
int l_file_count = 0;
|
||||||
|
@ -124,7 +124,7 @@ int control__unregister_callback(struct mosquitto__security_options *opts, MOSQ_
|
|||||||
if(strncmp(topic, "$CONTROL/", strlen("$CONTROL/"))) return MOSQ_ERR_INVAL;
|
if(strncmp(topic, "$CONTROL/", strlen("$CONTROL/"))) return MOSQ_ERR_INVAL;
|
||||||
|
|
||||||
HASH_FIND(hh, opts->plugin_callbacks.control, topic, topic_len, cb_found);
|
HASH_FIND(hh, opts->plugin_callbacks.control, topic, topic_len, cb_found);
|
||||||
if(cb_found){
|
if(cb_found && cb_found->cb == cb_func){
|
||||||
HASH_DELETE(hh, opts->plugin_callbacks.control, cb_found);
|
HASH_DELETE(hh, opts->plugin_callbacks.control, cb_found);
|
||||||
mosquitto__free(cb_found->data);
|
mosquitto__free(cb_found->data);
|
||||||
mosquitto__free(cb_found);
|
mosquitto__free(cb_found);
|
||||||
|
@ -90,8 +90,8 @@ bool db__ready_for_queue(struct mosquitto *context, int qos, struct mosquitto_ms
|
|||||||
{
|
{
|
||||||
int source_count;
|
int source_count;
|
||||||
int adjust_count;
|
int adjust_count;
|
||||||
unsigned long source_bytes;
|
size_t source_bytes;
|
||||||
unsigned long adjust_bytes = db.config->max_inflight_bytes;
|
size_t adjust_bytes = db.config->max_inflight_bytes;
|
||||||
bool valid_bytes;
|
bool valid_bytes;
|
||||||
bool valid_count;
|
bool valid_count;
|
||||||
|
|
||||||
@ -148,10 +148,10 @@ int db__open(struct mosquitto__config *config)
|
|||||||
|
|
||||||
db.subs = NULL;
|
db.subs = NULL;
|
||||||
|
|
||||||
subhier = sub__add_hier_entry(NULL, &db.subs, "", strlen(""));
|
subhier = sub__add_hier_entry(NULL, &db.subs, "", 0);
|
||||||
if(!subhier) return MOSQ_ERR_NOMEM;
|
if(!subhier) return MOSQ_ERR_NOMEM;
|
||||||
|
|
||||||
subhier = sub__add_hier_entry(NULL, &db.subs, "$SYS", strlen("$SYS"));
|
subhier = sub__add_hier_entry(NULL, &db.subs, "$SYS", (uint16_t)strlen("$SYS"));
|
||||||
if(!subhier) return MOSQ_ERR_NOMEM;
|
if(!subhier) return MOSQ_ERR_NOMEM;
|
||||||
|
|
||||||
retain__init();
|
retain__init();
|
||||||
@ -312,6 +312,8 @@ void db__message_dequeue_first(struct mosquitto *context, struct mosquitto_msg_d
|
|||||||
{
|
{
|
||||||
struct mosquitto_client_msg *msg;
|
struct mosquitto_client_msg *msg;
|
||||||
|
|
||||||
|
UNUSED(context);
|
||||||
|
|
||||||
msg = msg_data->queued;
|
msg = msg_data->queued;
|
||||||
DL_DELETE(msg_data->queued, msg);
|
DL_DELETE(msg_data->queued, msg);
|
||||||
DL_APPEND(msg_data->inflight, msg);
|
DL_APPEND(msg_data->inflight, msg);
|
||||||
|
@ -33,7 +33,7 @@ int handle__unsubscribe(struct mosquitto *context)
|
|||||||
char *sub;
|
char *sub;
|
||||||
uint16_t slen;
|
uint16_t slen;
|
||||||
int rc;
|
int rc;
|
||||||
uint8_t reason;
|
uint8_t reason = 0;
|
||||||
int reason_code_count = 0;
|
int reason_code_count = 0;
|
||||||
int reason_code_max;
|
int reason_code_max;
|
||||||
uint8_t *reason_codes = NULL, *reason_tmp;
|
uint8_t *reason_codes = NULL, *reason_tmp;
|
||||||
|
@ -27,6 +27,8 @@ static time_t last_keepalive_check = 0;
|
|||||||
|
|
||||||
int keepalive__add(struct mosquitto *context)
|
int keepalive__add(struct mosquitto *context)
|
||||||
{
|
{
|
||||||
|
UNUSED(context);
|
||||||
|
|
||||||
return MOSQ_ERR_SUCCESS;
|
return MOSQ_ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +60,8 @@ void keepalive__check(void)
|
|||||||
|
|
||||||
int keepalive__remove(struct mosquitto *context)
|
int keepalive__remove(struct mosquitto *context)
|
||||||
{
|
{
|
||||||
|
UNUSED(context);
|
||||||
|
|
||||||
return MOSQ_ERR_SUCCESS;
|
return MOSQ_ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,8 @@ int drop_privileges(struct mosquitto__config *config)
|
|||||||
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Mosquitto should not be run as root/administrator.");
|
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Mosquitto should not be run as root/administrator.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UNUSED(config);
|
||||||
#endif
|
#endif
|
||||||
return MOSQ_ERR_SUCCESS;
|
return MOSQ_ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -237,7 +239,7 @@ int listeners__start_single_mqtt(struct mosquitto__listener *listener)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef WITH_WEBSOCKETS
|
#ifdef WITH_WEBSOCKETS
|
||||||
void listeners__add_websockets(struct lws_context *ws_context, int fd)
|
void listeners__add_websockets(struct lws_context *ws_context, mosq_sock_t fd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct mosquitto__listener *listener = NULL;
|
struct mosquitto__listener *listener = NULL;
|
||||||
@ -624,6 +626,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
char *saveptr = NULL;
|
char *saveptr = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
UNUSED(hInstance);
|
||||||
|
UNUSED(hPrevInstance);
|
||||||
|
UNUSED(nCmdShow);
|
||||||
|
|
||||||
argv = mosquitto__malloc(sizeof(char *)*1);
|
argv = mosquitto__malloc(sizeof(char *)*1);
|
||||||
argv[0] = "mosquitto";
|
argv[0] = "mosquitto";
|
||||||
token = strtok_r(lpCmdLine, " ", &saveptr);
|
token = strtok_r(lpCmdLine, " ", &saveptr);
|
||||||
|
@ -747,7 +747,7 @@ int mux__cleanup(void);
|
|||||||
void listener__set_defaults(struct mosquitto__listener *listener);
|
void listener__set_defaults(struct mosquitto__listener *listener);
|
||||||
void listeners__reload_all_certificates(void);
|
void listeners__reload_all_certificates(void);
|
||||||
#ifdef WITH_WEBSOCKETS
|
#ifdef WITH_WEBSOCKETS
|
||||||
void listeners__add_websockets(struct lws_context *ws_context, int fd);
|
void listeners__add_websockets(struct lws_context *ws_context, mosq_sock_t fd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
|
@ -56,7 +56,7 @@ Contributors:
|
|||||||
#include "util_mosq.h"
|
#include "util_mosq.h"
|
||||||
#include "mux.h"
|
#include "mux.h"
|
||||||
|
|
||||||
static void loop_handle_reads_writes(struct pollfd *pollfds);
|
static void loop_handle_reads_writes(void);
|
||||||
|
|
||||||
static struct pollfd *pollfds = NULL;
|
static struct pollfd *pollfds = NULL;
|
||||||
static size_t pollfd_max, pollfd_current_max;
|
static size_t pollfd_max, pollfd_current_max;
|
||||||
@ -235,7 +235,7 @@ int mux_poll__handle(struct mosquitto__listener_sock *listensock, int listensock
|
|||||||
log__printf(NULL, MOSQ_LOG_ERR, "Error in poll: %s.", strerror(errno));
|
log__printf(NULL, MOSQ_LOG_ERR, "Error in poll: %s.", strerror(errno));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
loop_handle_reads_writes(pollfds);
|
loop_handle_reads_writes();
|
||||||
|
|
||||||
for(i=0; i<listensock_count; i++){
|
for(i=0; i<listensock_count; i++){
|
||||||
if(pollfds[i].revents & POLLIN){
|
if(pollfds[i].revents & POLLIN){
|
||||||
@ -267,7 +267,7 @@ int mux_poll__cleanup(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void loop_handle_reads_writes(struct pollfd *pollfds)
|
static void loop_handle_reads_writes(void)
|
||||||
{
|
{
|
||||||
struct mosquitto *context, *ctxt_tmp;
|
struct mosquitto *context, *ctxt_tmp;
|
||||||
int err;
|
int err;
|
||||||
|
@ -54,7 +54,7 @@ static struct mosquitto *persist__find_or_add_context(const char *client_id, uin
|
|||||||
context = NULL;
|
context = NULL;
|
||||||
HASH_FIND(hh_id, db.contexts_by_id, client_id, strlen(client_id), context);
|
HASH_FIND(hh_id, db.contexts_by_id, client_id, strlen(client_id), context);
|
||||||
if(!context){
|
if(!context){
|
||||||
context = context__init(-1);
|
context = context__init(INVALID_SOCKET);
|
||||||
if(!context) return NULL;
|
if(!context) return NULL;
|
||||||
context->id = mosquitto__strdup(client_id);
|
context->id = mosquitto__strdup(client_id);
|
||||||
if(!context->id){
|
if(!context->id){
|
||||||
|
@ -62,10 +62,10 @@ int retain__init(void)
|
|||||||
{
|
{
|
||||||
struct mosquitto__retainhier *retainhier;
|
struct mosquitto__retainhier *retainhier;
|
||||||
|
|
||||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "", (int)strlen(""));
|
retainhier = retain__add_hier_entry(NULL, &db.retains, "", 0);
|
||||||
if(!retainhier) return MOSQ_ERR_NOMEM;
|
if(!retainhier) return MOSQ_ERR_NOMEM;
|
||||||
|
|
||||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "$SYS", (int)strlen("$SYS"));
|
retainhier = retain__add_hier_entry(NULL, &db.retains, "$SYS", (uint16_t)strlen("$SYS"));
|
||||||
if(!retainhier) return MOSQ_ERR_NOMEM;
|
if(!retainhier) return MOSQ_ERR_NOMEM;
|
||||||
|
|
||||||
return MOSQ_ERR_SUCCESS;
|
return MOSQ_ERR_SUCCESS;
|
||||||
|
@ -47,7 +47,7 @@ int mosquitto_security_init_default(bool reload)
|
|||||||
int rc;
|
int rc;
|
||||||
int i;
|
int i;
|
||||||
char *pwf;
|
char *pwf;
|
||||||
char *pskf;
|
char *pskf = NULL;
|
||||||
|
|
||||||
UNUSED(reload);
|
UNUSED(reload);
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ int mosquitto_security_init_default(bool reload)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
char *pskf = db.config->security_options.psk_file;
|
pskf = db.config->security_options.psk_file;
|
||||||
if(pskf){
|
if(pskf){
|
||||||
rc = psk__file_parse(&db.config->security_options.psk_id, pskf);
|
rc = psk__file_parse(&db.config->security_options.psk_id, pskf);
|
||||||
if(rc){
|
if(rc){
|
||||||
@ -372,6 +372,9 @@ static int mosquitto_acl_check_default(int event, void *event_data, void *userda
|
|||||||
char *s;
|
char *s;
|
||||||
struct mosquitto__security_options *security_opts = NULL;
|
struct mosquitto__security_options *security_opts = NULL;
|
||||||
|
|
||||||
|
UNUSED(event);
|
||||||
|
UNUSED(userdata);
|
||||||
|
|
||||||
if(ed->client->bridge) return MOSQ_ERR_SUCCESS;
|
if(ed->client->bridge) return MOSQ_ERR_SUCCESS;
|
||||||
if(ed->access == MOSQ_ACL_SUBSCRIBE || ed->access == MOSQ_ACL_UNSUBSCRIBE) return MOSQ_ERR_SUCCESS; /* FIXME - implement ACL subscription strings. */
|
if(ed->access == MOSQ_ACL_SUBSCRIBE || ed->access == MOSQ_ACL_UNSUBSCRIBE) return MOSQ_ERR_SUCCESS; /* FIXME - implement ACL subscription strings. */
|
||||||
|
|
||||||
@ -667,7 +670,7 @@ static void acl__cleanup_single(struct mosquitto__security_options *security_opt
|
|||||||
|
|
||||||
static int acl__cleanup(bool reload)
|
static int acl__cleanup(bool reload)
|
||||||
{
|
{
|
||||||
struct mosquitto *context, *ctxt_tmp;
|
struct mosquitto *context, *ctxt_tmp = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
UNUSED(reload);
|
UNUSED(reload);
|
||||||
@ -833,7 +836,7 @@ void unpwd__free_item(struct mosquitto__unpwd **unpwd, struct mosquitto__unpwd *
|
|||||||
#ifdef WITH_TLS
|
#ifdef WITH_TLS
|
||||||
static int unpwd__decode_passwords(struct mosquitto__unpwd **unpwd)
|
static int unpwd__decode_passwords(struct mosquitto__unpwd **unpwd)
|
||||||
{
|
{
|
||||||
struct mosquitto__unpwd *u, *tmp;
|
struct mosquitto__unpwd *u, *tmp = NULL;
|
||||||
char *token;
|
char *token;
|
||||||
unsigned char *salt;
|
unsigned char *salt;
|
||||||
unsigned int salt_len;
|
unsigned int salt_len;
|
||||||
@ -939,7 +942,7 @@ static int unpwd__file_parse(struct mosquitto__unpwd **unpwd, const char *passwo
|
|||||||
static int psk__file_parse(struct mosquitto__unpwd **psk_id, const char *psk_file)
|
static int psk__file_parse(struct mosquitto__unpwd **psk_id, const char *psk_file)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct mosquitto__unpwd *u, *tmp;
|
struct mosquitto__unpwd *u, *tmp = NULL;
|
||||||
|
|
||||||
if(!db.config || !psk_id) return MOSQ_ERR_INVAL;
|
if(!db.config || !psk_id) return MOSQ_ERR_INVAL;
|
||||||
|
|
||||||
@ -993,6 +996,9 @@ static int mosquitto_unpwd_check_default(int event, void *event_data, void *user
|
|||||||
int rc;
|
int rc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
UNUSED(event);
|
||||||
|
UNUSED(userdata);
|
||||||
|
|
||||||
if(ed->client->username == NULL){
|
if(ed->client->username == NULL){
|
||||||
return MOSQ_ERR_PLUGIN_DEFER;
|
return MOSQ_ERR_PLUGIN_DEFER;
|
||||||
}
|
}
|
||||||
@ -1038,7 +1044,7 @@ static int mosquitto_unpwd_check_default(int event, void *event_data, void *user
|
|||||||
|
|
||||||
static int unpwd__cleanup(struct mosquitto__unpwd **root, bool reload)
|
static int unpwd__cleanup(struct mosquitto__unpwd **root, bool reload)
|
||||||
{
|
{
|
||||||
struct mosquitto__unpwd *u, *tmp;
|
struct mosquitto__unpwd *u, *tmp = NULL;
|
||||||
|
|
||||||
UNUSED(reload);
|
UNUSED(reload);
|
||||||
|
|
||||||
@ -1079,7 +1085,7 @@ static void security__disconnect_auth(struct mosquitto *context)
|
|||||||
*/
|
*/
|
||||||
int mosquitto_security_apply_default(void)
|
int mosquitto_security_apply_default(void)
|
||||||
{
|
{
|
||||||
struct mosquitto *context, *ctxt_tmp;
|
struct mosquitto *context, *ctxt_tmp = NULL;
|
||||||
struct mosquitto__acl_user *acl_user_tail;
|
struct mosquitto__acl_user *acl_user_tail;
|
||||||
bool allow_anonymous;
|
bool allow_anonymous;
|
||||||
struct mosquitto__security_options *security_opts = NULL;
|
struct mosquitto__security_options *security_opts = NULL;
|
||||||
@ -1289,7 +1295,7 @@ int mosquitto_security_apply_default(void)
|
|||||||
|
|
||||||
int mosquitto_psk_key_get_default(struct mosquitto *context, const char *hint, const char *identity, char *key, int max_key_len)
|
int mosquitto_psk_key_get_default(struct mosquitto *context, const char *hint, const char *identity, char *key, int max_key_len)
|
||||||
{
|
{
|
||||||
struct mosquitto__unpwd *u, *tmp;
|
struct mosquitto__unpwd *u, *tmp = NULL;
|
||||||
struct mosquitto__unpwd *psk_id_ref = NULL;
|
struct mosquitto__unpwd *psk_id_ref = NULL;
|
||||||
|
|
||||||
if(!hint || !identity || !key) return MOSQ_ERR_INVAL;
|
if(!hint || !identity || !key) return MOSQ_ERR_INVAL;
|
||||||
|
@ -31,7 +31,7 @@ int main(int argc, char *argv[]);
|
|||||||
|
|
||||||
static void print_error(void)
|
static void print_error(void)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf = NULL;
|
||||||
|
|
||||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
NULL, GetLastError(), LANG_NEUTRAL, (LPTSTR)&buf, 0, NULL);
|
NULL, GetLastError(), LANG_NEUTRAL, (LPTSTR)&buf, 0, NULL);
|
||||||
@ -70,6 +70,9 @@ void __stdcall service_main(DWORD dwArgc, LPTSTR *lpszArgv)
|
|||||||
char conf_path[MAX_PATH + 20];
|
char conf_path[MAX_PATH + 20];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
UNUSED(dwArgc);
|
||||||
|
UNUSED(lpszArgv);
|
||||||
|
|
||||||
service_handle = RegisterServiceCtrlHandler("mosquitto", service_handler);
|
service_handle = RegisterServiceCtrlHandler("mosquitto", service_handler);
|
||||||
if(service_handle){
|
if(service_handle){
|
||||||
memset(conf_path, 0, sizeof(conf_path));
|
memset(conf_path, 0, sizeof(conf_path));
|
||||||
|
@ -92,6 +92,8 @@ DWORD WINAPI SigThreadProc(void* data)
|
|||||||
static HANDLE evt[3];
|
static HANDLE evt[3];
|
||||||
int pid = GetCurrentProcessId();
|
int pid = GetCurrentProcessId();
|
||||||
|
|
||||||
|
UNUSED(data);
|
||||||
|
|
||||||
sprintf_s(evt_name, MAX_PATH, "mosq%d_shutdown", pid);
|
sprintf_s(evt_name, MAX_PATH, "mosq%d_shutdown", pid);
|
||||||
evt[0] = CreateEvent(NULL, TRUE, FALSE, evt_name);
|
evt[0] = CreateEvent(NULL, TRUE, FALSE, evt_name);
|
||||||
sprintf_s(evt_name, MAX_PATH, "mosq%d_reload", pid);
|
sprintf_s(evt_name, MAX_PATH, "mosq%d_reload", pid);
|
||||||
|
@ -253,7 +253,7 @@ static int sub__add_shared(struct mosquitto *context, uint8_t qos, uint32_t iden
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(shared_ref){
|
if(shared_ref){
|
||||||
shared_subs = mosquitto__realloc(context->shared_subs, sizeof(struct mosquitto__subhier_ref *)*(size_t)(context->shared_sub_count + 1));
|
shared_subs = mosquitto__realloc(context->shared_subs, sizeof(struct mosquitto__subshared_ref *)*(size_t)(context->shared_sub_count + 1));
|
||||||
if(!shared_subs){
|
if(!shared_subs){
|
||||||
mosquitto__free(shared_ref);
|
mosquitto__free(shared_ref);
|
||||||
context->shared_subs[context->shared_sub_count-1] = NULL;
|
context->shared_subs[context->shared_sub_count-1] = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user