X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/2478dbdfba7cf729ddee43a5a77bde8c25ccdede..f2cb6292ba93101c1e8eff8933df6157cfe05fd8:/src/src/readconf.c diff --git a/src/src/readconf.c b/src/src/readconf.c index 92160c8f2..7396c8bd9 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -11,16 +11,12 @@ implementation of the conditional .ifdef etc. */ #include "exim.h" +extern char **environ; + static void fn_smtp_receive_timeout(const uschar * name, const uschar * str); static void save_config_line(const uschar* line); static void save_config_position(const uschar *file, int line); static void print_config(BOOL admin); -/* glibc seems to define environ as a macro, we can use this to check -it's existence. And, if we declare environ a 2nd time, it shouldn't -harm */ -#ifndef environ -extern char **environ; -#endif #define CSTATE_STACK_SIZE 10 @@ -2043,6 +2039,7 @@ switch (type) /* Integer held in K: again, allow octal and hex formats, and suffixes K and M. */ + /*XXX consider moving to int_eximarith_t (but mind the overflow test 0415) */ case opt_Kint: { @@ -2712,15 +2709,13 @@ if (type == NULL) if (environ) { uschar **p; - size_t n; for (p = USS environ; *p; p++) ; - n = p - USS environ; - qsort(environ, p - USS environ, sizeof(*p), (__compar_fn_t) string_compare_by_pointer); + qsort(environ, p - USS environ, sizeof(*p), string_compare_by_pointer); for (p = USS environ; *p; p++) { if (no_labels) *(Ustrchr(*p, '=')) = '\0'; - puts(*p); + puts(CS *p); } } return; @@ -3052,14 +3047,6 @@ while((filename = string_nextinlist(&list, &sep, big_buffer, big_buffer_size)) != NULL) { - /* To avoid confusion: Exim changes to / at the very beginning and - * and to $spool_directory later. */ - if (filename[0] != '/') - { - fprintf(stderr, "-C %s: only absolute names are allowed\n", filename); - exit(EXIT_FAILURE); - } - /* Cut out all the fancy processing unless specifically wanted */ #if defined(CONFIGURE_FILE_USE_NODE) || defined(CONFIGURE_FILE_USE_EUID) @@ -3113,6 +3100,15 @@ while((filename = string_nextinlist(&list, &sep, big_buffer, big_buffer_size)) if (config_file != NULL || errno != ENOENT) break; } +/* Now, once we found and opened our configuration file, we change the directory +to a safe place. Later we change to $spool_directory. */ + +if (Uchdir("/") < 0) + { + perror("exim: chdir `/': "); + exit(EXIT_FAILURE); + } + /* On success, save the name for verification; config_filename is used when logging configuration errors (it changes for .included files) whereas config_main_filename is the name shown by -bP. Failure to open a configuration