Fix DKIM information leakage
[exim.git] / src / src / readconf.c
index 5c0c22f53ea9c39f82ba7f48ab4b7c8520df0e71..b2a3c7370ba836350c7a6157b0ada5c6ebc6ae99 100644 (file)
@@ -445,6 +445,7 @@ static optionlist optionlist_config[] = {
   { "strip_trailing_dot",       opt_bool,        &strip_trailing_dot },
   { "syslog_duplication",       opt_bool,        &syslog_duplication },
   { "syslog_facility",          opt_stringptr,   &syslog_facility_str },
+  { "syslog_pid",               opt_bool,        &syslog_pid },
   { "syslog_processname",       opt_stringptr,   &syslog_processname },
   { "syslog_timestamp",         opt_bool,        &syslog_timestamp },
   { "system_filter",            opt_stringptr,   &system_filter },
@@ -567,6 +568,7 @@ macro_create(const uschar * name, const uschar * val,
 unsigned namelen = Ustrlen(name);
 macro_item * m = store_get(sizeof(macro_item) + namelen);
 
+/* fprintf(stderr, "%s: '%s' '%s'\n", __FUNCTION__, name, val) */
 if (!macros)
   {
   macros = m;
@@ -762,6 +764,9 @@ due to conflicts with other common macros. */
 #ifdef SUPPORT_SOCKS
   macro_create(US"_HAVE_SOCKS", US"y", FALSE, TRUE);
 #endif
+#ifdef TCP_FASTOPEN
+  macro_create(US"_HAVE_TCP_FASTOPEN", US"y", FALSE, TRUE);
+#endif
 #ifdef EXPERIMENTAL_LMDB
   macro_create(US"_HAVE_LMDB", US"y", FALSE, TRUE);
 #endif
@@ -788,90 +793,99 @@ due to conflicts with other common macros. */
 #endif
 
 #ifdef LOOKUP_LSEARCH
-  macro_create(US"_HAVE_LKUP_LSEARCH", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_LSEARCH", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_CDB
-  macro_create(US"_HAVE_LKUP_CDB", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_CDB", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_DBM
-  macro_create(US"_HAVE_LKUP_DBM", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_DBM", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_DNSDB
-  macro_create(US"_HAVE_LKUP_DNSDB", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_DNSDB", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_DSEARCH
-  macro_create(US"_HAVE_LKUP_DSEARCH", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_DSEARCH", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_IBASE
-  macro_create(US"_HAVE_LKUP_IBASE", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_IBASE", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_LDAP
-  macro_create(US"_HAVE_LKUP_LDAP", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_LDAP", US"y", FALSE, TRUE);
 #endif
 #ifdef EXPERIMENTAL_LMDB
-  macro_create(US"_HAVE_LKUP_LMDB", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_LMDB", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_MYSQL
-  macro_create(US"_HAVE_LKUP_MYSQL", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_MYSQL", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_NIS
-  macro_create(US"_HAVE_LKUP_NIS", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_NIS", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_NISPLUS
-  macro_create(US"_HAVE_LKUP_NISPLUS", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_NISPLUS", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_ORACLE
-  macro_create(US"_HAVE_LKUP_ORACLE", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_ORACLE", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_PASSWD
-  macro_create(US"_HAVE_LKUP_PASSWD", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_PASSWD", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_PGSQL
-  macro_create(US"_HAVE_LKUP_PGSQL", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_PGSQL", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_REDIS
-  macro_create(US"_HAVE_LKUP_REDIS", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_REDIS", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_SQLITE
-  macro_create(US"_HAVE_LKUP_SQLITE", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_SQLITE", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_TESTDB
-  macro_create(US"_HAVE_LKUP_TESTDB", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_TESTDB", US"y", FALSE, TRUE);
 #endif
 #ifdef LOOKUP_WHOSON
-  macro_create(US"_HAVE_LKUP_WHOSON", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_LOOKUP_WHOSON", US"y", FALSE, TRUE);
 #endif
 
 #ifdef TRANSPORT_APPENDFILE
 # ifdef SUPPORT_MAILDIR
-  macro_create(US"_HAVE_TPT_APPEND_MAILDR", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_TRANSPORT_APPEND_MAILDR", US"y", FALSE, TRUE);
 # endif
 # ifdef SUPPORT_MAILSTORE
-  macro_create(US"_HAVE_TPT_APPEND_MAILSTORE", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_TRANSPORT_APPEND_MAILSTORE", US"y", FALSE, TRUE);
 # endif
 # ifdef SUPPORT_MBX
-  macro_create(US"_HAVE_TPT_APPEND_MBX", US"y", FALSE, TRUE);
+  macro_create(US"_HAVE_TRANSPORT_APPEND_MBX", US"y", FALSE, TRUE);
 # endif
 #endif
 }
 
 
 void
-readconf_options_from_list(optionlist * opts, unsigned nopt, uschar * group)
+readconf_options_from_list(optionlist * opts, unsigned nopt, const uschar * section, uschar * group)
 {
 int i;
 const uschar * s;
 
-/* Walk the array backwards to get substring-conflict names */
-for (i = nopt-1; i >= 0; i--) if (*(s = opts[i].name) && *s != '*')
-  macro_create(string_sprintf("_OPT_%T_%T", group, s), US"y", FALSE, TRUE);
+/* The 'previously-defined-substring' rule for macros in config file
+lines is done so for these builtin macros: we know that the table
+we source from is in strict alpha order, hence the builtins portion
+of the macros list is in reverse-alpha (we prepend them) - so longer
+macros that have substrings are always discovered first during
+expansion. */
+
+for (i = 0; i < nopt; i++)  if (*(s = opts[i].name) && *s != '*')
+  if (group)
+    macro_create(string_sprintf("_OPT_%T_%T_%T", section, group, s), US"y", FALSE, TRUE);
+  else
+    macro_create(string_sprintf("_OPT_%T_%T", section, s), US"y", FALSE, TRUE);
 }
 
 
 static void
 readconf_options(void)
 {
-readconf_options_from_list(optionlist_config, nelem(optionlist_config), US"MAIN");
+readconf_options_from_list(optionlist_config, nelem(optionlist_config), US"MAIN", NULL);
 readconf_options_routers();
 readconf_options_transports();
 readconf_options_auths();
@@ -1006,6 +1020,7 @@ for (;;)
     for (t = s; (p = CUstrchr(t, '_')); t = p+1)
       if (c = p[1], c == 'O' || c == 'D' || c == 'H')
        {
+/* fprintf(stderr, "%s: builtins create triggered by '%s'\n", __FUNCTION__, s); */
        macros_create_builtin();
        break;
        }
@@ -1025,6 +1040,7 @@ for (;;)
       int moveby;
       int replen = Ustrlen(m->replacement);
 
+/* fprintf(stderr, "%s: matched '%s' in '%s'\n", __FUNCTION__, m->name, t) */
       /* Expand the buffer if necessary */
 
       while (newlen - m->namelen + replen + 1 > big_buffer_size)
@@ -2334,6 +2350,11 @@ switch (type)
   if (value < 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
     "integer \"%s\" is too large (overflow)", s);
 
+  /* We get a coverity error here for using count, as it derived
+  from the tainted buffer pointed to by s, as parsed by sscanf().
+  By the definition of sscanf we must be aceessing between start
+  and end of s (assuming it is nul-terminated...) so ignore the error.  */
+  /* coverity[tainted_data] */
   if (s[count] == '.')
     {
     int d = 100;
@@ -4286,12 +4307,12 @@ readconf_options_auths(void)
 {
 struct auth_info * ai;
 
-readconf_options_from_list(optionlist_auths, optionlist_auths_size, US"AU");
+readconf_options_from_list(optionlist_auths, optionlist_auths_size, US"AUTHENTICATORS", NULL);
 
 for (ai = auths_available; ai->driver_name[0]; ai++)
   {
-  macro_create(string_sprintf("_DRVR_AUTH_%T", ai->driver_name), US"y", FALSE, TRUE);
-  readconf_options_from_list(ai->options, (unsigned)*ai->options_count, ai->driver_name);
+  macro_create(string_sprintf("_DRIVER_AUTHENTICATOR_%T", ai->driver_name), US"y", FALSE, TRUE);
+  readconf_options_from_list(ai->options, (unsigned)*ai->options_count, US"AUTHENTICATOR", ai->driver_name);
   }
 }