if (full_path != path && ctx->expand_values)
path = full_path;
if (settings_parse_read_file(full_path, path, ctx->pool, &st,
- output_r, &error) < 0) {
+ "", output_r, &error) < 0) {
ctx->error = p_strdup(ctx->pool, error);
if (config_apply_error(ctx, line->key) < 0)
return -1;
if (settings_parse_read_file("/etc/pki/tls/cert.pem",
"/etc/pki/tls/cert.pem",
unsafe_data_stack_pool, NULL,
- &ca_value, &error) < 0)
+ "", &ca_value, &error) < 0)
i_fatal("%s", error);
settings_file_get(ca_value, unsafe_data_stack_pool,
&ssl_set.ca);
const char *error;
if (settings_parse_read_file(*value, *value, ctx->set_pool, NULL,
- value, &error) < 0) {
+ "", value, &error) < 0) {
settings_parser_set_error(ctx, error);
return -1;
}
int settings_parse_read_file(const char *path, const char *value_path,
pool_t pool, struct stat *st_r,
- const char **output_r, const char **error_r)
+ const char *prefix, const char **output_r,
+ const char **error_r)
{
struct stat st;
int fd;
i_close_fd(&fd);
return -1;
}
+ size_t prefix_len = strlen(prefix);
size_t value_path_len = strlen(value_path);
- char *buf = p_malloc(pool, value_path_len + 1 + st.st_size + 1);
- memcpy(buf, value_path, value_path_len);
- buf[value_path_len] = '\n';
-
- int ret = read_full(fd, buf + value_path_len + 1, st.st_size);
+ char *buf = p_malloc(pool, prefix_len + value_path_len + 1 +
+ st.st_size + 1);
+ memcpy(buf, prefix, prefix_len);
+ memcpy(buf + prefix_len, value_path, value_path_len);
+ buf[prefix_len + value_path_len] = '\n';
+
+ int ret = read_full(fd, buf + prefix_len + value_path_len + 1,
+ st.st_size);
i_close_fd(&fd);
if (ret < 0) {
*error_r = t_strdup_printf("read(%s) failed: %m", path);
"read(%s) failed: Unexpected EOF", path);
return -1;
}
- if (memchr(buf + value_path_len + 1, '\0', st.st_size) != NULL) {
+ if (memchr(buf + prefix_len + value_path_len + 1, '\0', st.st_size) != NULL) {
*error_r = t_strdup_printf(
"%s contains NUL characters - This is not supported",
path);
bool settings_check(struct event *event, const struct setting_parser_info *info,
pool_t pool, void *set, const char **error_r);
-/* Read a SET_FILE from the given path and write "value_path\ncontents" to
- output_r. Returns 0 on success, -1 on error. */
+/* Read a SET_FILE from the given path and write
+ "<prefix><value_path>\n<contents>" 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, struct stat *st_r,
- const char **output_r, const char **error_r);
+ const char *prefix, const char **output_r,
+ const char **error_r);
int settings_parse_boollist_string(const char *value, pool_t pool,
ARRAY_TYPE(const_string) *dest,
const char **error_r);
file.path = str_c(ctx->str);
if (settings_parse_read_file(file.path, file.path,
&ctx->mpool->pool, NULL,
- value, error_r) < 0)
+ "", value, error_r) < 0)
return -1;
} else {
*value = p_strdup(&ctx->mpool->pool, str_c(ctx->str));