New variable $config_dir, $config_file. Bug 1553
authorHeiko Schlittermann <hs+exim@schlittermann.de>
Sat, 29 Nov 2014 19:39:58 +0000 (19:39 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Mon, 12 Jan 2015 18:58:34 +0000 (18:58 +0000)
doc/doc-docbook/spec.xfpt
doc/doc-txt/NewStuff
src/src/expand.c
src/src/globals.c
src/src/globals.h
src/src/readconf.c
test/scripts/0000-Basic/0002
test/stdout/0002

index b786621885cf0490e7d383becf5c21a0b55f7646..8ef56d1e3bbb7d717f9e38ff696b65ee59eedc61 100644 (file)
@@ -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.
 
 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
 .vitem &$demime_errorlevel$&
 .vindex "&$demime_errorlevel$&"
 This variable is available when Exim is compiled with
index 76947300eaffeb05d5e11a5dcfe644b50767a7b6..f40fbedfd9a95f0a10995ad588ff4747bfe94ca1 100644 (file)
@@ -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.
 
     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
 ------------
 
 Version 4.84
 ------------
index d2f215dfd0a150bec644ffc6d8445dbd85b3e0c4..0e9dff27fe5edc5b7c01f6b6413b825523ce0b83 100644 (file)
@@ -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 },
   { "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 },
   { "csa_status",          vtype_stringptr,   &csa_status },
 #ifdef EXPERIMENTAL_DCC
   { "dcc_header",          vtype_stringptr,   &dcc_header },
index 1b09008a141034d61e763ecacc9a7cf0fe60c295..5cd738bbb9ea7a6c670a9b4c9597d10d742dbbba 100644 (file)
@@ -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_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;
 
 #ifdef CONFIGURE_OWNER
 uid_t   config_uid             = CONFIGURE_OWNER;
index f4baa0bb0d24e46360ec5da05c04a645c81a873e..5746167dd9d6bba54a0128f44aa4ef67451b2da4 100644 (file)
@@ -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 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
 #ifdef CONFIGURE_OWNER
 extern uid_t   config_uid;             /* Additional owner */
 #endif
index f0d08d0e1d851d77da9b884ffe16211d43f3abbc..df4cbb2fd5a1a2daab8ba0e3f58026894c76257f 100644 (file)
@@ -3008,7 +3008,12 @@ file is a serious disaster. */
 
 if (config_file != NULL)
   {
 
 if (config_file != NULL)
   {
+  uschar *p;
   config_filename = config_main_filename = string_copy(filename);
   config_filename = config_main_filename = string_copy(filename);
+
+  p = strrchr(filename, '/');
+  config_main_directory = p ? string_copyn(filename, p - filename) 
+                            : string_copy(".");
   }
 else
   {
   }
 else
   {
index bcfacdea4ca9be4b14626bb47049502fe9577418..11fa1cd138948efee5265efc0cf4e353e6d9a64b 100644 (file)
@@ -15,6 +15,8 @@ exim -be
 # Some fixed variables
 
 exim_path: $exim_path
 # 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
 primary_hostname: $primary_hostname
 primary_hostname: ${primary_hostname}
 qualify_domain: $qualify_domain
index a3706ee5ae844aebb4a9c1fc6ea45e86e19cb7a6..00ac02a2e76cf95ee5ea4c1ce09caa6c9e48fcd5 100644 (file)
@@ -6,6 +6,8 @@
 > # Some fixed variables
 > 
 > exim_path: TESTSUITE/eximdir/exim
 > # 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
 > primary_hostname: myhost.test.ex
 > primary_hostname: myhost.test.ex
 > qualify_domain: myhost.test.ex