From a545bcd54312b543ddc46a872ec79d0416032b0f Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 25 Mar 2010 17:33:40 +0200 Subject: [PATCH] config: Avoid problems with trailing '/' in base_dir. --HG-- branch : HEAD --- src/config/old-set-parser.c | 7 ++++++- src/master/master-settings.c | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/config/old-set-parser.c b/src/config/old-set-parser.c index fa02a3e909..224703b6a8 100644 --- a/src/config/old-set-parser.c +++ b/src/config/old-set-parser.c @@ -59,9 +59,14 @@ old_settings_handle_root(struct config_parser_context *ctx, const char *key, const char *value) { const char *p; + unsigned int len; - if (strcmp(key, "base_dir") == 0) + if (strcmp(key, "base_dir") == 0) { + len = strlen(value); + if (len > 0 && value[len-1] == '/') + value = t_strndup(value, len-1); ctx->old->base_dir = p_strdup(ctx->pool, value); + } if (strcmp(key, "protocols") == 0) { char **protos, **s; bool have_imap = FALSE, have_imaps = FALSE; diff --git a/src/master/master-settings.c b/src/master/master-settings.c index 9ce63d9648..8e497a0ba8 100644 --- a/src/master/master-settings.c +++ b/src/master/master-settings.c @@ -348,9 +348,15 @@ master_settings_verify(void *_set, pool_t pool, const char **error_r) struct service_settings *const *services; const char *const *strings; ARRAY_TYPE(const_string) all_listeners; - unsigned int i, j, count, process_limit; + unsigned int i, j, count, len, process_limit; unsigned int auth_client_limit, max_auth_client_processes; + len = strlen(set->base_dir); + if (len > 0 && set->base_dir[len-1] == '/') { + /* drop trailing '/' */ + set->base_dir = p_strndup(pool, set->base_dir, len - 1); + } + if (set->last_valid_uid != 0 && set->first_valid_uid > set->last_valid_uid) { *error_r = "first_valid_uid can't be larger than last_valid_uid"; -- 2.47.3