Fix check for commandline macro definition
authorJeremy Harris <jgh146exb@wizmail.org>
Mon, 10 Oct 2016 13:20:30 +0000 (14:20 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Mon, 10 Oct 2016 13:29:28 +0000 (14:29 +0100)
Without this, mailq (done by unpriv user) and daemon SIGHUP handling fail

Broken-by: c0b9d3e87264
src/src/exim.c
src/src/readconf.c

index f05ba78a8b17a1d6ef99f81d4be668cdb3ef4678..95f8cef3bab9ce6aa4cee99d30c3036e6cc49ea9 100644 (file)
@@ -1347,12 +1347,12 @@ exit(EXIT_FAILURE);
 /* Typically, Exim will drop privileges if macros are supplied.  In some
 cases, we want to not do so.
 
 /* Typically, Exim will drop privileges if macros are supplied.  In some
 cases, we want to not do so.
 
-Arguments:    none (macros is a global)
+Arguments:    opt_D_used - true if the commandline had a "-D" option
 Returns:      true if trusted, false otherwise
 */
 
 static BOOL
 Returns:      true if trusted, false otherwise
 */
 
 static BOOL
-macros_trusted(void)
+macros_trusted(BOOL opt_D_used)
 {
 #ifdef WHITELIST_D_MACROS
 macro_item *m;
 {
 #ifdef WHITELIST_D_MACROS
 macro_item *m;
@@ -1362,7 +1362,7 @@ size_t len;
 BOOL prev_char_item, found;
 #endif
 
 BOOL prev_char_item, found;
 #endif
 
-if (macros == NULL)
+if (!opt_D_used)
   return TRUE;
 #ifndef WHITELIST_D_MACROS
 return FALSE;
   return TRUE;
 #ifndef WHITELIST_D_MACROS
 return FALSE;
@@ -3679,7 +3679,7 @@ configuration file changes and macro definitions haven't happened. */
 
 if ((                                            /* EITHER */
     (!trusted_config ||                          /* Config changed, or */
 
 if ((                                            /* EITHER */
     (!trusted_config ||                          /* Config changed, or */
-     !macros_trusted()) &&                       /*  impermissible macros and */
+     !macros_trusted(opt_D_used)) &&            /*  impermissible macros and */
     real_uid != root_uid &&                      /* Not root, and */
     !running_in_test_harness                     /* Not fudged */
     ) ||                                         /*   OR   */
     real_uid != root_uid &&                      /* Not root, and */
     !running_in_test_harness                     /* Not fudged */
     ) ||                                         /*   OR   */
index 8425c0b379aac6e74b48f805d9b07ff6ccaf1de2..edc09aa4eda5f793d9eac6dd13ae117c61a7a1d8 100644 (file)
@@ -784,7 +784,7 @@ for (;;)
   replacing all occurrences of the macro. */
 
   macro_found = FALSE;
   replacing all occurrences of the macro. */
 
   macro_found = FALSE;
-  for (m = macros; m != NULL; m = m->next)
+  for (m = macros; m; m = m->next)
     {
     uschar *p, *pp;
     uschar *t = s;
     {
     uschar *p, *pp;
     uschar *t = s;