From 6121f4f22dd6f2ac63b567ffc9e449e2eeb649c4 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 23 Feb 2009 13:18:17 -0500 Subject: [PATCH] deliver -p: Expand relative paths before chdir()ing. --HG-- branch : HEAD --- src/deliver/deliver.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/deliver/deliver.c b/src/deliver/deliver.c index 042c3ac31a..24393c36b7 100644 --- a/src/deliver/deliver.c +++ b/src/deliver/deliver.c @@ -828,6 +828,7 @@ int main(int argc, char *argv[]) struct mailbox_transaction_context *t; struct mailbox_header_lookup_ctx *headers_ctx; struct mail *mail; + char cwd[PATH_MAX]; uid_t process_euid; bool stderr_rejection = FALSE; bool keep_environment = FALSE; @@ -893,6 +894,12 @@ int main(int argc, char *argv[]) if (i == argc) i_fatal_status(EX_USAGE, "Missing -p argument"); path = argv[i]; + 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); + } } else if (strcmp(argv[i], "-e") == 0) { stderr_rejection = TRUE; } else if (strcmp(argv[i], "-c") == 0) { -- 2.47.3