--- a/src/conf-yaml-loader.c +++ b/src/conf-yaml-loader.c @@ -118,6 +118,7 @@ ConfYamlHandleInclude(ConfNode *parent, const char *filename) yaml_parser_t parser; char include_filename[PATH_MAX]; FILE *file; + int rc; if (yaml_parser_initialize(&parser) != 1) { SCLogError(SC_ERR_CONF_YAML_ERROR, "Failed to initialize YAML parser"); @@ -132,26 +133,31 @@ ConfYamlHandleInclude(ConfNode *parent, const char *filename) conf_dirname, filename); } + rc = -1; + file = fopen(include_filename, "r"); if (file == NULL) { SCLogError(SC_ERR_FOPEN, "Failed to open configuration include file %s: %s", include_filename, strerror(errno)); - return -1; + goto out; } yaml_parser_set_input_file(&parser, file); - if (ConfYamlParse(&parser, parent, 0) != 0) { + if (ConfYamlParse(&parser, parent, 0) == 0) { + rc = 0; + } + else { SCLogError(SC_ERR_CONF_YAML_ERROR, "Failed to include configuration file %s", filename); - return -1; } - yaml_parser_delete(&parser); fclose(file); +out: + yaml_parser_delete(&parser); - return 0; + return rc; } /**