projects
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Supress TLS/Env warnings in checking and listing mode
[exim.git]
/
src
/
src
/
readconf.c
diff --git
a/src/src/readconf.c
b/src/src/readconf.c
index 92160c8f28dc41cbf71d6de33b55cb9218a4d507..c547c78b7ca34446eed22f797364e10a87bba576 100644
(file)
--- a/
src/src/readconf.c
+++ b/
src/src/readconf.c
@@
-11,16
+11,12
@@
implementation of the conditional .ifdef etc. */
#include "exim.h"
#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 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
+static void print_config(BOOL admin, BOOL terse);
#define CSTATE_STACK_SIZE 10
#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. */
/* 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:
{
case opt_Kint:
{
@@
-2652,7
+2649,7
@@
if (type == NULL)
if (Ustrcmp(name, "config") == 0)
{
if (Ustrcmp(name, "config") == 0)
{
- print_config(admin_user);
+ print_config(admin_user
, no_labels
);
return;
}
return;
}
@@
-2711,16
+2708,15
@@
if (type == NULL)
{
if (environ)
{
{
if (environ)
{
- uschar **p;
- size_t n;
+ uschar ** p;
for (p = USS environ; *p; p++) ;
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++)
{
for (p = USS environ; *p; p++)
{
- if (no_labels) *(Ustrchr(*p, '=')) = '\0';
- puts(*p);
+ uschar * q;
+ if (no_labels && (q = Ustrchr(*p, '='))) *q = '\0';
+ puts(CS *p);
}
}
return;
}
}
return;
@@
-2951,7
+2947,7
@@
Returns: bool for "okay"; false will cause caller to immediately exit.
#ifdef SUPPORT_TLS
static BOOL
#ifdef SUPPORT_TLS
static BOOL
-tls_dropprivs_validate_require_cipher(
void
)
+tls_dropprivs_validate_require_cipher(
BOOL nowarn
)
{
const uschar *errmsg;
pid_t pid;
{
const uschar *errmsg;
pid_t pid;
@@
-2965,7
+2961,7
@@
if ( !tls_advertise_hosts
|| Ustrcmp(tls_advertise_hosts, ":") == 0
)
return TRUE;
|| Ustrcmp(tls_advertise_hosts, ":") == 0
)
return TRUE;
-else if (!tls_certificate)
+else if (!
nowarn && !
tls_certificate)
log_write(0, LOG_MAIN|LOG_PANIC,
"Warning: No server certificate defined; TLS connections will fail.\n"
" Suggested action: either install a certificate or change tls_advertise_hosts option");
log_write(0, LOG_MAIN|LOG_PANIC,
"Warning: No server certificate defined; TLS connections will fail.\n"
" Suggested action: either install a certificate or change tls_advertise_hosts option");
@@
-3039,7
+3035,7
@@
systems. Therefore they are available only when requested by compile-time
options. */
void
options. */
void
-readconf_main(
void
)
+readconf_main(
BOOL nowarn
)
{
int sep = 0;
struct stat statbuf;
{
int sep = 0;
struct stat statbuf;
@@
-3052,14
+3048,6
@@
while((filename = string_nextinlist(&list, &sep, big_buffer, big_buffer_size))
!= NULL)
{
!= 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)
/* Cut out all the fancy processing unless specifically wanted */
#if defined(CONFIGURE_FILE_USE_NODE) || defined(CONFIGURE_FILE_USE_EUID)
@@
-3113,6
+3101,15
@@
while((filename = string_nextinlist(&list, &sep, big_buffer, big_buffer_size))
if (config_file != NULL || errno != ENOENT) break;
}
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
/* 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
@@
-3476,7
+3473,7
@@
if ((tls_verify_hosts != NULL || tls_try_verify_hosts != NULL) &&
/* This also checks that the library linkage is working and we can call
routines in it, so call even if tls_require_ciphers is unset */
/* This also checks that the library linkage is working and we can call
routines in it, so call even if tls_require_ciphers is unset */
-if (!tls_dropprivs_validate_require_cipher())
+if (!tls_dropprivs_validate_require_cipher(
nowarn
))
exit(1);
/* Magic number: at time of writing, 1024 has been the long-standing value
exit(1);
/* Magic number: at time of writing, 1024 has been the long-standing value
@@
-3500,16
+3497,16
@@
if (openssl_options != NULL)
# endif
}
# endif
}
-if (
gnutls_require_kx || gnutls_require_mac || gnutls_require_proto
)
+if (
!nowarn && (gnutls_require_kx || gnutls_require_mac || gnutls_require_proto)
)
log_write(0, LOG_MAIN, "WARNING: main options"
" gnutls_require_kx, gnutls_require_mac and gnutls_require_protocols"
" are obsolete\n");
#endif /*SUPPORT_TLS*/
log_write(0, LOG_MAIN, "WARNING: main options"
" gnutls_require_kx, gnutls_require_mac and gnutls_require_protocols"
" are obsolete\n");
#endif /*SUPPORT_TLS*/
-if (
(!add_environment || *add_environment == '\0') && !keep_environment
)
+if (
!nowarn && !keep_environment && environ && *environ
)
log_write(0, LOG_MAIN,
log_write(0, LOG_MAIN,
- "W
ARNING
: purging the environment.\n"
- " Suggested action: use keep_environment
and add_environment.\n
");
+ "W
arning
: purging the environment.\n"
+ " Suggested action: use keep_environment
.
");
}
}
@@
-3622,9
+3619,9
@@
while ((buffer = get_config_line()) != NULL)
if (isupper(*name) && *s == '=')
{
if (isupper(*name) && *s == '=')
{
- if (d
!= NULL
)
+ if (d)
{
{
- if (
d->driver_name == NULL
)
+ if (
!d->driver_name
)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"no driver defined for %s \"%s\"", class, d->name);
(d->info->init)(d);
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"no driver defined for %s \"%s\"", class, d->name);
(d->info->init)(d);
@@
-3644,9
+3641,9
@@
while ((buffer = get_config_line()) != NULL)
/* Finish off initializing the previous driver. */
/* Finish off initializing the previous driver. */
- if (d
!= NULL
)
+ if (d)
{
{
- if (
d->driver_name == NULL
)
+ if (
!d->driver_name
)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"no driver defined for %s \"%s\"", class, d->name);
(d->info->init)(d);
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"no driver defined for %s \"%s\"", class, d->name);
(d->info->init)(d);
@@
-3654,7
+3651,7
@@
while ((buffer = get_config_line()) != NULL)
/* Check that we haven't already got a driver of this name */
/* Check that we haven't already got a driver of this name */
- for (d = *anchor; d
!= NULL
; d = d->next)
+ for (d = *anchor; d; d = d->next)
if (Ustrcmp(name, d->name) == 0)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"there are two %ss called \"%s\"", class, name);
if (Ustrcmp(name, d->name) == 0)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"there are two %ss called \"%s\"", class, name);
@@
-3665,7
+3662,7
@@
while ((buffer = get_config_line()) != NULL)
d = store_get(instance_size);
memcpy(d, instance_default, instance_size);
*p = d;
d = store_get(instance_size);
memcpy(d, instance_default, instance_size);
*p = d;
- p = &
(d->next)
;
+ p = &
d->next
;
d->name = string_copy(name);
/* Clear out the "set" bits in the generic options */
d->name = string_copy(name);
/* Clear out the "set" bits in the generic options */
@@
-3683,8
+3680,8
@@
while ((buffer = get_config_line()) != NULL)
/* Not the start of a new driver. Give an error if we have not set up a
current driver yet. */
/* Not the start of a new driver. Give an error if we have not set up a
current driver yet. */
- if (
d == NULL) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
- "%s name missing", class);
+ if (
!d)
+
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
"%s name missing", class);
/* First look to see if this is a generic option; if it is "driver",
initialize the driver. If is it not a generic option, we can look for a
/* First look to see if this is a generic option; if it is "driver",
initialize the driver. If is it not a generic option, we can look for a
@@
-3693,7
+3690,7
@@
while ((buffer = get_config_line()) != NULL)
if (readconf_handle_option(buffer, driver_optionlist,
driver_optionlist_count, d, NULL))
{
if (readconf_handle_option(buffer, driver_optionlist,
driver_optionlist_count, d, NULL))
{
- if (
d->info == NULL && d->driver_name != NULL
)
+ if (
!d->info && d->driver_name
)
init_driver(d, drivers_available, size_of_info, class);
}
init_driver(d, drivers_available, size_of_info, class);
}
@@
-3701,11
+3698,9
@@
while ((buffer = get_config_line()) != NULL)
live therein. A flag with each option indicates if it is in the public
block. */
live therein. A flag with each option indicates if it is in the public
block. */
- else if (d->info != NULL)
- {
+ else if (d->info)
readconf_handle_option(buffer, d->info->options,
*(d->info->options_count), d, US"option \"%s\" unknown");
readconf_handle_option(buffer, d->info->options,
*(d->info->options_count), d, US"option \"%s\" unknown");
- }
/* The option is not generic and the driver name has not yet been given. */
/* The option is not generic and the driver name has not yet been given. */
@@
-3715,9
+3710,9
@@
while ((buffer = get_config_line()) != NULL)
/* Run the initialization function for the final driver. */
/* Run the initialization function for the final driver. */
-if (d
!= NULL
)
+if (d)
{
{
- if (
d->driver_name == NULL
)
+ if (
!d->driver_name
)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"no driver defined for %s \"%s\"", class, d->name);
(d->info->init)(d);
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"no driver defined for %s \"%s\"", class, d->name);
(d->info->init)(d);
@@
-4076,22
+4071,19
@@
readconf_driver_init(US"authenticator",
optionlist_auths, /* generic options */
optionlist_auths_size);
optionlist_auths, /* generic options */
optionlist_auths_size);
-for (au = auths; au
!= NULL
; au = au->next)
+for (au = auths; au; au = au->next)
{
{
- if (
au->public_name == NULL
)
+ if (
!au->public_name
)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG, "no public name specified for "
"the %s authenticator", au->name);
log_write(0, LOG_PANIC_DIE|LOG_CONFIG, "no public name specified for "
"the %s authenticator", au->name);
- for (bu = au->next; bu != NULL; bu = bu->next)
- {
+
+ for (bu = au->next; bu; bu = bu->next)
if (strcmpic(au->public_name, bu->public_name) == 0)
if (strcmpic(au->public_name, bu->public_name) == 0)
- {
if ((au->client && bu->client) || (au->server && bu->server))
log_write(0, LOG_PANIC_DIE|LOG_CONFIG, "two %s authenticators "
"(%s and %s) have the same public name (%s)",
if ((au->client && bu->client) || (au->server && bu->server))
log_write(0, LOG_PANIC_DIE|LOG_CONFIG, "two %s authenticators "
"(%s and %s) have the same public name (%s)",
-
(au->client)
? US"client" : US"server", au->name, bu->name,
+
au->client
? US"client" : US"server", au->name, bu->name,
au->public_name);
au->public_name);
- }
- }
}
}
}
}
@@
-4311,10
+4303,10
@@
current = next;
/* List the parsed config lines, care about nice formatting and
hide the <hide> values unless we're the admin user */
void
/* List the parsed config lines, care about nice formatting and
hide the <hide> values unless we're the admin user */
void
-print_config(BOOL admin)
+print_config(BOOL admin
, BOOL terse
)
{
config_line_item *i;
{
config_line_item *i;
-const int TS = 2;
+const int TS =
terse ? 0 :
2;
int indent = 0;
for (i = config_lines; i; i = i->next)
int indent = 0;
for (i = config_lines; i; i = i->next)
@@
-4354,7
+4346,7
@@
for (i = config_lines; i; i = i->next)
/* begin lines are left aligned */
else if (Ustrncmp(current, "begin", 5) == 0 && isspace(current[5]))
{
/* begin lines are left aligned */
else if (Ustrncmp(current, "begin", 5) == 0 && isspace(current[5]))
{
- puts("");
+
if (!terse)
puts("");
puts(CCS current);
indent = TS;
}
puts(CCS current);
indent = TS;
}
@@
-4362,7
+4354,8
@@
for (i = config_lines; i; i = i->next)
/* router/acl/transport block names */
else if (current[Ustrlen(current)-1] == ':' && !Ustrchr(current, '='))
{
/* router/acl/transport block names */
else if (current[Ustrlen(current)-1] == ':' && !Ustrchr(current, '='))
{
- printf("\n%*s%s\n", TS, "", current);
+ if (!terse) puts("");
+ printf("%*s%s\n", TS, "", current);
indent = 2 * TS;
}
indent = 2 * TS;
}