> I've named it .include_if_exists, and it's a very dirty patch, use it at
> your own risk. Maybe it blows up your whole server, maybe it opens root
> for everyone, you've been warned so don't blame me later. :)
Ok, blame me for being so stupid in thinking that a small change doesn't
need testing. Appended is a corrected version
Nico
---------------------------- Diff again --------------------------------
diff -uNr exim-4.24/src/readconf.c exim-4.24-include-if-exists/src/readconf.c
--- exim-4.24/src/readconf.c 2003-09-22 10:29:58.000000000 +0200
+++ exim-4.24-include-if-exists/src/readconf.c 2003-10-04 01:54:54.000000000 +0200
@@ -630,18 +630,14 @@
/* Handle .include lines - these are also physical lines. */
- if (Ustrncmp(ss, ".include ", 9) == 0)
+ if (Ustrncmp(ss, ".include ", 9) == 0 || Ustrncmp(ss, ".include_if_exists ", 19) == 0)
{
uschar *t;
- config_file_item *save = store_get(sizeof(config_file_item));
+ config_file_item *save;
+ struct stat statbuf;
+ BOOL include_if_exists = (ss[8] == '_' ? TRUE : FALSE);
- save->next = config_file_stack;
- config_file_stack = save;
- save->file = config_file;
- save->filename = config_filename;
- save->lineno = config_lineno;
-
- ss += 9;
+ ss += (include_if_exists ? 19 : 9);
while (isspace(*ss)) ss++;
t = ss + Ustrlen(ss);
while (t > ss && isspace(t[-1])) t--;
@@ -651,6 +647,17 @@
t--;
}
*t = 0;
+
+ if (include_if_exists && (Ustat(ss, &statbuf) != 0))
+ continue;
+
+ save = store_get(sizeof(config_file_item));
+ save->next = config_file_stack;
+ config_file_stack = save;
+ save->file = config_file;
+ save->filename = config_filename;
+ save->lineno = config_lineno;
+
config_file = Ufopen(ss, "rb");
if (config_file == NULL)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "failed to open included "