]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings, global: settings_parse_read_file() - Return file's struct stat
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 11 Mar 2025 07:39:09 +0000 (09:39 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 14 Mar 2025 10:29:43 +0000 (10:29 +0000)
src/config/config-parser.c
src/lib-http/test-http-client.c
src/lib-settings/settings-parser.c
src/lib-settings/settings-parser.h

index b2883538aedcd500b2cd31b11f22f5968318f7e6..ba6cb0bea55ecf18ddfaf9fdd3861f5fcecffa75 100644 (file)
@@ -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;
index ea543c395cb7552206d723c6ae18985506831f43..0187d109c630b94b0f40abb53e37e714d8b79a70 100644 (file)
@@ -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,
index c02a44649bf823fc30855a074934ddd110acf730..05a93819228f78c239061cfd2e1f028260c7bd04 100644 (file)
@@ -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;
 }
index 38bf623413a228e0469bc03407f89d4cb77488c2..f2bbd4b95cc81fa5e03833871dc89f51a7330c35 100644 (file)
@@ -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,