diff options
author | Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de> | 2016-03-09 11:13:42 +0100 |
---|---|---|
committer | Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de> | 2016-03-09 11:46:21 +0100 |
commit | 3615fa9a06356891367c66ed284cef9db5cefca3 (patch) | |
tree | 53e0d0886fc58378deb435454c0061d884f90a2c /src | |
parent | d8b70640f81ea7af8d04c94c0cb5bcceb8163c39 (diff) |
Store the initial working directory, expand $initial_cwd. Bug 1805
Diffstat (limited to 'src')
-rw-r--r-- | src/src/exim.c | 8 | ||||
-rw-r--r-- | src/src/expand.c | 1 | ||||
-rw-r--r-- | src/src/globals.c | 1 | ||||
-rw-r--r-- | src/src/globals.h | 1 |
4 files changed, 9 insertions, 2 deletions
diff --git a/src/src/exim.c b/src/src/exim.c index 02fda6756..574e7804b 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -3747,6 +3747,9 @@ NOTE: immediatly after opening the configuration file we change the working directory to "/"! Later we change to $spool_directory. We do it there, because during readconf_main() some expansion takes place already. */ +/* Store the initial cwd before we change directories */ +initial_cwd = getcwd(NULL, 0); + readconf_main(); /* Now in directory "/" */ @@ -4042,9 +4045,10 @@ if (((debug_selector & D_any) != 0 || LOGGING(arguments)) { int i; uschar *p = big_buffer; - char * dummy; Ustrcpy(p, "cwd= (failed)"); - dummy = /* quieten compiler */ getcwd(CS p+4, big_buffer_size - 4); + + Ustrncpy(p + 4, initial_cwd, big_buffer_size-5); + while (*p) p++; (void)string_format(p, big_buffer_size - (p - big_buffer), " %d args:", argc); while (*p) p++; diff --git a/src/src/expand.c b/src/src/expand.c index cc22e65fb..99d2ffc00 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -543,6 +543,7 @@ static var_entry var_table[] = { { "host_lookup_deferred",vtype_int, &host_lookup_deferred }, { "host_lookup_failed", vtype_int, &host_lookup_failed }, { "host_port", vtype_int, &deliver_host_port }, + { "initial_cwd", vtype_stringptr, &initial_cwd }, { "inode", vtype_ino, &deliver_inode }, { "interface_address", vtype_stringptr, &interface_address }, { "interface_port", vtype_int, &interface_port }, diff --git a/src/src/globals.c b/src/src/globals.c index e5bbb8340..da6e4b31d 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -797,6 +797,7 @@ BOOL ignore_fromline_local = FALSE; uschar *ignore_fromline_hosts = NULL; BOOL inetd_wait_mode = FALSE; int inetd_wait_timeout = -1; +uschar *initial_cwd = NULL; uschar *interface_address = NULL; int interface_port = -1; BOOL is_inetd = FALSE; diff --git a/src/src/globals.h b/src/src/globals.h index 1919d8c1f..b7f9c3489 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -512,6 +512,7 @@ extern BOOL ignore_fromline_local; /* Local SMTP ignore fromline */ extern uschar *ignore_fromline_hosts; /* Hosts permitted to send "From " */ extern BOOL inetd_wait_mode; /* Whether running in inetd wait mode */ extern int inetd_wait_timeout; /* Timeout for inetd wait mode */ +extern uschar *initial_cwd; /* The directory we where in at startup */ extern BOOL is_inetd; /* True for inetd calls */ extern uschar *iterate_item; /* Item from iterate list */ |