Mercurial > dovecot > core-2.2
changeset 10501:28a14e2fe5d6 HEAD
Use t_abspath() instead of duplicating code.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 16 Dec 2009 13:42:45 -0500 |
parents | 28ff2944d4e9 |
children | 13be6ac759ee |
files | src/lda/main.c src/master/main.c |
diffstat | 2 files changed, 4 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lda/main.c Wed Dec 16 13:31:12 2009 -0500 +++ b/src/lda/main.c Wed Dec 16 13:42:45 2009 -0500 @@ -7,6 +7,7 @@ #include "close-keep-errno.h" #include "istream.h" #include "istream-seekable.h" +#include "abspath.h" #include "safe-mkstemp.h" #include "eacces-error.h" #include "mkdir-parents.h" @@ -256,7 +257,6 @@ struct istream *input; struct mailbox_transaction_context *t; struct mailbox_header_lookup_ctx *headers_ctx; - char cwd[PATH_MAX]; void **sets; uid_t process_euid; bool stderr_rejection = FALSE; @@ -328,13 +328,7 @@ break; case 'p': /* input path */ - path = optarg; - if (*path != '/') { - /* expand relative paths before we chdir */ - if (getcwd(cwd, sizeof(cwd)) == NULL) - i_fatal("getcwd() failed: %m"); - path = t_strconcat(cwd, "/", path, NULL); - } + path = t_abspath(optarg); break; default: print_help();
--- a/src/master/main.c Wed Dec 16 13:31:12 2009 -0500 +++ b/src/master/main.c Wed Dec 16 13:42:45 2009 -0500 @@ -8,6 +8,7 @@ #include "write-full.h" #include "env-util.h" #include "hostpid.h" +#include "abspath.h" #include "restrict-process-size.h" #include "master-service.h" #include "master-service-settings.h" @@ -420,15 +421,12 @@ static const char *get_full_config_path(struct service_list *list) { const char *path; - char cwd[PATH_MAX]; path = master_service_get_config_path(master_service); if (*path == '/') return path; - if (getcwd(cwd, sizeof(cwd)) == NULL) - i_fatal("getcwd() failed: %m"); - return p_strconcat(list->pool, cwd, "/", path, NULL); + return p_strdup(list->pool, t_abspath(path)); } static void master_time_moved(time_t old_time, time_t new_time)