1 Description: Store the initial working directory, expand $initial_cwd.
2 Bug 1805 https://bugs.exim.org/show_bug.cgi?id=1805
7 @@ -759,6 +759,7 @@ BOOL ignore_fromline_local = FALSE;
8 uschar *ignore_fromline_hosts = NULL;
9 BOOL inetd_wait_mode = FALSE;
10 int inetd_wait_timeout = -1;
11 +uschar *initial_cwd = NULL;
12 uschar *interface_address = NULL;
13 int interface_port = -1;
14 BOOL is_inetd = FALSE;
17 @@ -3689,6 +3689,13 @@ NOTE: immediatly after opening the confi
18 directory to "/"! Later we change to $spool_directory. We do it there, because
19 during readconf_main() some expansion takes place already. */
21 +/* Store the initial cwd before we change directories */
22 +if ((initial_cwd = getcwd(NULL, 0)) == NULL)
24 + perror("exim: can't get the current working directory");
30 /* Now in directory "/" */
31 @@ -3967,9 +3974,10 @@ if (((debug_selector & D_any) != 0 || (l
34 uschar *p = big_buffer;
36 Ustrcpy(p, "cwd= (failed)");
37 - dummy = /* quieten compiler */ getcwd(CS p+4, big_buffer_size - 4);
39 + Ustrncpy(p + 4, initial_cwd, big_buffer_size-5);
42 (void)string_format(p, big_buffer_size - (p - big_buffer), " %d args:", argc);
46 @@ -486,6 +486,7 @@ extern BOOL ignore_fromline_local; /
47 extern uschar *ignore_fromline_hosts; /* Hosts permitted to send "From " */
48 extern BOOL inetd_wait_mode; /* Whether running in inetd wait mode */
49 extern int inetd_wait_timeout; /* Timeout for inetd wait mode */
50 +extern uschar *initial_cwd; /* The directory we where in at startup */
51 extern BOOL is_inetd; /* True for inetd calls */
52 extern uschar *iterate_item; /* Item from iterate list */
56 @@ -501,6 +501,7 @@ static var_entry var_table[] = {
57 { "host_data", vtype_stringptr, &host_data },
58 { "host_lookup_deferred",vtype_int, &host_lookup_deferred },
59 { "host_lookup_failed", vtype_int, &host_lookup_failed },
60 + { "initial_cwd", vtype_stringptr, &initial_cwd },
61 { "inode", vtype_ino, &deliver_inode },
62 { "interface_address", vtype_stringptr, &interface_address },
63 { "interface_port", vtype_int, &interface_port },
66 @@ -10426,6 +10426,13 @@ $host_lookup_failed
68 See $host_lookup_deferred.
72 + This variable contains the full path name of the initial working
73 + directory of the current Exim process. This may differ from the current
74 + working directory, as Exim changes this to "/" during early startup, and
75 + to $spool_directory later.
79 The only time this variable is set is while expanding the directory_file