Make error messages for missing config file clearer.

pull/1229/head
Roger A. Light 7 years ago
parent 70a22f290f
commit 463de0a2c1

@ -5,6 +5,7 @@ Broker:
- Fix clients being disconnected when ACLs are in use. This only affects the - Fix clients being disconnected when ACLs are in use. This only affects the
case where a client connects using a username, and the anonymous ACL list is case where a client connects using a username, and the anonymous ACL list is
defined but specific user ACLs are not defined. Closes #1162. defined but specific user ACLs are not defined. Closes #1162.
- Make error messages for missing config file clearer.
Library: Library:
- Use higher resolution timer for random initialisation of client id - Use higher resolution timer for random initialisation of client id

@ -392,7 +392,6 @@ int config__parse_args(struct mosquitto_db *db, struct mosquitto__config *config
db->config_file = argv[i+1]; db->config_file = argv[i+1];
if(config__read(db, config, false)){ if(config__read(db, config, false)){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open configuration file.");
return MOSQ_ERR_INVAL; return MOSQ_ERR_INVAL;
} }
}else{ }else{
@ -618,7 +617,9 @@ int config__read(struct mosquitto_db *db, struct mosquitto__config *config, bool
rc = config__read_file(config, reload, db->config_file, &cr, 0, &lineno); rc = config__read_file(config, reload, db->config_file, &cr, 0, &lineno);
} }
if(rc){ if(rc){
log__printf(NULL, MOSQ_LOG_ERR, "Error found at %s:%d.", db->config_file, lineno); if(lineno > 0){
log__printf(NULL, MOSQ_LOG_ERR, "Error found at %s:%d.", db->config_file, lineno);
}
return rc; return rc;
} }
@ -695,11 +696,11 @@ int config__read(struct mosquitto_db *db, struct mosquitto__config *config, bool
} }
#ifdef FINAL_WITH_TLS_PSK #ifdef FINAL_WITH_TLS_PSK
if(config->bridges[i].tls_psk && !config->bridges[i].tls_psk_identity){ if(config->bridges[i].tls_psk && !config->bridges[i].tls_psk_identity){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration: missing bridge_identity.\n"); log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration: missing bridge_identity.");
return MOSQ_ERR_INVAL; return MOSQ_ERR_INVAL;
} }
if(config->bridges[i].tls_psk_identity && !config->bridges[i].tls_psk){ if(config->bridges[i].tls_psk_identity && !config->bridges[i].tls_psk){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration: missing bridge_psk.\n"); log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration: missing bridge_psk.");
return MOSQ_ERR_INVAL; return MOSQ_ERR_INVAL;
} }
#endif #endif
@ -1221,7 +1222,9 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
rc = config__read_file(config, reload, files[i], cr, level+1, &lineno_ext); rc = config__read_file(config, reload, files[i], cr, level+1, &lineno_ext);
if(rc){ if(rc){
log__printf(NULL, MOSQ_LOG_ERR, "Error found at %s:%d.", files[i], lineno_ext); if(lineno_ext > 0){
log__printf(NULL, MOSQ_LOG_ERR, "Error found at %s:%d.", files[i], lineno_ext);
}
/* Free happens below */ /* Free happens below */
break; break;
} }
@ -2017,7 +2020,7 @@ int config__read_file(struct mosquitto__config *config, bool reload, const char
fptr = mosquitto__fopen(file, "rt", false); fptr = mosquitto__fopen(file, "rt", false);
if(!fptr){ if(!fptr){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open config file %s\n", file); log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open config file %s.", file);
return 1; return 1;
} }

Loading…
Cancel
Save