summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/doc-docbook/spec.xfpt11
-rw-r--r--doc/doc-txt/NewStuff3
-rw-r--r--src/src/expand.c2
-rw-r--r--src/src/globals.c1
-rw-r--r--src/src/globals.h1
-rw-r--r--src/src/readconf.c5
-rw-r--r--test/scripts/0000-Basic/00022
-rw-r--r--test/stdout/00022
8 files changed, 27 insertions, 0 deletions
diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index b78662188..8ef56d1e3 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -11254,6 +11254,17 @@ The building process for Exim keeps a count of the number
of times it has been compiled. This serves to distinguish different
compilations of the same version of the program.
+.vitem &$config_dir$&
+.vindex "&$config_dir$&"
+The directory name of the main configuration file. That is, the content of
+&$config_file$& with the last component stripped. The value does not
+contain the trailing slash. If &$config_file$& does not contain a slash,
+&$config_dir$& is ".".
+
+.vitem &$config_file$&
+.vindex "&$config_file$&"
+The name of the main configuration file Exim is using.
+
.vitem &$demime_errorlevel$&
.vindex "&$demime_errorlevel$&"
This variable is available when Exim is compiled with
diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff
index 76947300e..f40fbedfd 100644
--- a/doc/doc-txt/NewStuff
+++ b/doc/doc-txt/NewStuff
@@ -25,6 +25,9 @@ Version 4.85
server certs used for TLS match the result of the MX lookup. It does
not use the same mechanism as DANE.
+ 4. New expansion items $config_file, $config_dir, containing the file
+ and directory name of the main configuration file.
+
Version 4.84
------------
diff --git a/src/src/expand.c b/src/src/expand.c
index d2f215dfd..0e9dff27f 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -446,6 +446,8 @@ static var_entry var_table[] = {
{ "caller_uid", vtype_uid, &real_uid },
{ "compile_date", vtype_stringptr, &version_date },
{ "compile_number", vtype_stringptr, &version_cnumber },
+ { "config_dir", vtype_stringptr, &config_main_directory },
+ { "config_file", vtype_stringptr, &config_main_filename },
{ "csa_status", vtype_stringptr, &csa_status },
#ifdef EXPERIMENTAL_DCC
{ "dcc_header", vtype_stringptr, &dcc_header },
diff --git a/src/src/globals.c b/src/src/globals.c
index 1b09008a1..5cd738bbb 100644
--- a/src/src/globals.c
+++ b/src/src/globals.c
@@ -496,6 +496,7 @@ gid_t config_gid = CONFIGURE_GROUP;
uschar *config_main_filelist = US CONFIGURE_FILE
"\0<-----------Space to patch configure_filename->";
uschar *config_main_filename = NULL;
+uschar *config_main_directory = NULL;
#ifdef CONFIGURE_OWNER
uid_t config_uid = CONFIGURE_OWNER;
diff --git a/src/src/globals.h b/src/src/globals.h
index f4baa0bb0..5746167dd 100644
--- a/src/src/globals.h
+++ b/src/src/globals.h
@@ -282,6 +282,7 @@ extern gid_t config_gid; /* Additional group owner */
extern int config_lineno; /* Line number */
extern uschar *config_main_filelist; /* List of possible config files */
extern uschar *config_main_filename; /* File name actually used */
+extern uschar *config_main_directory; /* Directory where the main config file was found */
#ifdef CONFIGURE_OWNER
extern uid_t config_uid; /* Additional owner */
#endif
diff --git a/src/src/readconf.c b/src/src/readconf.c
index f0d08d0e1..df4cbb2fd 100644
--- a/src/src/readconf.c
+++ b/src/src/readconf.c
@@ -3008,7 +3008,12 @@ file is a serious disaster. */
if (config_file != NULL)
{
+ uschar *p;
config_filename = config_main_filename = string_copy(filename);
+
+ p = strrchr(filename, '/');
+ config_main_directory = p ? string_copyn(filename, p - filename)
+ : string_copy(".");
}
else
{
diff --git a/test/scripts/0000-Basic/0002 b/test/scripts/0000-Basic/0002
index bcfacdea4..11fa1cd13 100644
--- a/test/scripts/0000-Basic/0002
+++ b/test/scripts/0000-Basic/0002
@@ -15,6 +15,8 @@ exim -be
# Some fixed variables
exim_path: $exim_path
+config_dir: $config_dir
+config_file: $config_file
primary_hostname: $primary_hostname
primary_hostname: ${primary_hostname}
qualify_domain: $qualify_domain
diff --git a/test/stdout/0002 b/test/stdout/0002
index a3706ee5a..00ac02a2e 100644
--- a/test/stdout/0002
+++ b/test/stdout/0002
@@ -6,6 +6,8 @@
> # Some fixed variables
>
> exim_path: TESTSUITE/eximdir/exim
+> config_dir: TESTSUITE
+> config_file: TESTSUITE/test-config
> primary_hostname: myhost.test.ex
> primary_hostname: myhost.test.ex
> qualify_domain: myhost.test.ex