From: Timo Sirainen Date: Tue, 11 Mar 2025 07:39:09 +0000 (+0200) Subject: lib-settings, global: settings_parse_read_file() - Return file's struct stat X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b345fa99e079d2761f6742f9d522c63d6e588844;p=thirdparty%2Fdovecot%2Fcore.git lib-settings, global: settings_parse_read_file() - Return file's struct stat --- diff --git a/src/config/config-parser.c b/src/config/config-parser.c index b2883538ae..ba6cb0bea5 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -686,7 +686,8 @@ static int config_apply_file(struct config_parser_context *ctx, /* preserve original relative path in doveconf output */ if (full_path != path && ctx->expand_values) path = full_path; - if (settings_parse_read_file(full_path, path, ctx->pool, output_r, &error) < 0) { + if (settings_parse_read_file(full_path, path, ctx->pool, NULL, + output_r, &error) < 0) { ctx->error = p_strdup(ctx->pool, error); if (config_apply_error(ctx, line->key) < 0) return -1; diff --git a/src/lib-http/test-http-client.c b/src/lib-http/test-http-client.c index ea543c395c..0187d109c6 100644 --- a/src/lib-http/test-http-client.c +++ b/src/lib-http/test-http-client.c @@ -390,7 +390,7 @@ int main(int argc, char *argv[]) const char *ca_value; if (settings_parse_read_file("/etc/pki/tls/cert.pem", "/etc/pki/tls/cert.pem", - unsafe_data_stack_pool, + unsafe_data_stack_pool, NULL, &ca_value, &error) < 0) i_fatal("%s", error); settings_file_get(ca_value, unsafe_data_stack_pool, diff --git a/src/lib-settings/settings-parser.c b/src/lib-settings/settings-parser.c index c02a44649b..05a9381922 100644 --- a/src/lib-settings/settings-parser.c +++ b/src/lib-settings/settings-parser.c @@ -276,7 +276,7 @@ get_file(struct setting_parser_context *ctx, bool dup_value, const char **value) } const char *error; - if (settings_parse_read_file(*value, *value, ctx->set_pool, + if (settings_parse_read_file(*value, *value, ctx->set_pool, NULL, value, &error) < 0) { settings_parser_set_error(ctx, error); return -1; @@ -297,7 +297,7 @@ get_in_port_zero(struct setting_parser_context *ctx, const char *value, } int settings_parse_read_file(const char *path, const char *value_path, - pool_t pool, + pool_t pool, struct stat *st_r, const char **output_r, const char **error_r) { struct stat st; @@ -335,6 +335,8 @@ int settings_parse_read_file(const char *path, const char *value_path, return -1; } + if (st_r != NULL) + *st_r = st; *output_r = buf; return 0; } diff --git a/src/lib-settings/settings-parser.h b/src/lib-settings/settings-parser.h index 38bf623413..f2bbd4b95c 100644 --- a/src/lib-settings/settings-parser.h +++ b/src/lib-settings/settings-parser.h @@ -3,6 +3,7 @@ #include "str-parse.h" +struct stat; struct var_expand_table; struct var_expand_provider; @@ -272,7 +273,7 @@ bool settings_check(struct event *event, const struct setting_parser_info *info, /* Read a SET_FILE from the given path and write "value_path\ncontents" to output_r. Returns 0 on success, -1 on error. */ int settings_parse_read_file(const char *path, const char *value_path, - pool_t pool, + pool_t pool, struct stat *st_r, const char **output_r, const char **error_r); int settings_parse_boollist_string(const char *value, pool_t pool, ARRAY_TYPE(const_string) *dest,