Build: avoid compiling code for unused transports, routers, authenticators
[exim.git] / src / src / routers / redirect.c
index 65d9862a4dc96a8a31e5406481f84fd73bcfcccd..37b5f5e2440929f7147b70c011d8a0cb03911f8e 100644 (file)
@@ -2,12 +2,15 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
+/* Copyright (c) The Exim Maintainers 2020 - 2022 */
 /* Copyright (c) University of Cambridge 1995 - 2018 */
-/* Copyright (c) The Exim Maintainers 2020 - 2021 */
 /* See the file NOTICE for conditions of use and distribution. */
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 
 
 #include "../exim.h"
+
+#ifdef ROUTER_REDIRECT /* Remainder of file */
 #include "rf_functions.h"
 #include "redirect.h"
 
@@ -305,9 +308,8 @@ redirect_router_options_block *ob =
 
 while (generated)
   {
-  address_item *parent;
-  address_item *next = generated;
-  uschar *errors_address = next->prop.errors_address;
+  address_item * next = generated, * parent;
+  const uschar * errors_address = next->prop.errors_address;
 
   generated = next->next;
   next->parent = addr;
@@ -370,12 +372,11 @@ while (generated)
     in \N...\N to avoid expansion later. In Cygwin, home directories can
     contain $ characters. */
 
-    if (rblock->home_directory != NULL)
+    if (rblock->home_directory)
       next->home_dir = rblock->home_directory;
     else if (rblock->check_local_user)
       next->home_dir = string_sprintf("\\N%s\\N", pw->pw_dir);
-    else if (rblock->router_home_directory != NULL &&
-             testflag(addr, af_home_expanded))
+    else if (rblock->router_home_directory && testflag(addr, af_home_expanded))
       {
       next->home_dir = deliver_home;
       setflag(next, af_home_expanded);
@@ -395,14 +396,16 @@ while (generated)
     if (next->address[0] == '|')
       {
       address_pipe = next->address;
-      if (rf_get_transport(ob->pipe_transport_name, &(ob->pipe_transport),
+      GET_OPTION("pipe_transport");
+      if (rf_get_transport(ob->pipe_transport_name, &ob->pipe_transport,
           next, rblock->name, US"pipe_transport"))
         next->transport = ob->pipe_transport;
       address_pipe = NULL;
       }
     else if (next->address[0] == '>')
       {
-      if (rf_get_transport(ob->reply_transport_name, &(ob->reply_transport),
+      GET_OPTION("reply_transport");
+      if (rf_get_transport(ob->reply_transport_name, &ob->reply_transport,
           next, rblock->name, US"reply_transport"))
         next->transport = ob->reply_transport;
       }
@@ -412,17 +415,20 @@ while (generated)
       address_file = next->address;
       if (next->address[len-1] == '/')
         {
+       GET_OPTION("directory_transport");
         if (rf_get_transport(ob->directory_transport_name,
             &(ob->directory_transport), next, rblock->name,
             US"directory_transport"))
           next->transport = ob->directory_transport;
         }
       else
-        {
-        if (rf_get_transport(ob->file_transport_name, &(ob->file_transport),
+       {
+       GET_OPTION("file_transport");
+        if (rf_get_transport(ob->file_transport_name, &ob->file_transport,
             next, rblock->name, US"file_transport"))
           next->transport = ob->file_transport;
-        }
+       }
+
       address_file = NULL;
       }
     }
@@ -567,11 +573,15 @@ address. Otherwise, if a local qualify_domain is provided, set that up. */
 
 if (ob->qualify_preserve_domain)
   qualify_domain_recipient = addr->domain;
-else if (ob->qualify_domain)
+else
   {
-  uschar *new_qdr = rf_expand_data(addr, ob->qualify_domain, &xrc);
-  if (!new_qdr) return xrc;
-  qualify_domain_recipient = new_qdr;
+  GET_OPTION("qualify_domain");
+  if (ob->qualify_domain)
+    {
+    uschar *new_qdr = rf_expand_data(addr, ob->qualify_domain, &xrc);
+    if (!new_qdr) return xrc;
+    qualify_domain_recipient = new_qdr;
+    }
   }
 
 redirect.owners = ob->owners;
@@ -587,7 +597,7 @@ redirect.string = (redirect.isfile = (ob->file != NULL))
 frc = rda_interpret(&redirect, options, ob->include_directory,
   ob->sieve_vacation_directory, ob->sieve_enotify_mailto_owner,
   ob->sieve_useraddress, ob->sieve_subaddress, &ugid, &generated,
-  &(addr->message), ob->skip_syntax_errors? &eblock : NULL, &filtertype,
+  &addr->message, ob->skip_syntax_errors? &eblock : NULL, &filtertype,
   string_sprintf("%s router (recipient is %s)", rblock->name, addr->address));
 
 qualify_domain_recipient = save_qualify_domain_recipient;
@@ -676,7 +686,7 @@ switch (frc)
 
     if (filtertype != FILTER_FORWARD && ob->skip_syntax_errors)
       {
-      eblock = store_get(sizeof(error_block), FALSE);
+      eblock = store_get(sizeof(error_block), GET_UNTAINTED);
       eblock->next = NULL;
       eblock->text1 = addr->message;
       eblock->text2 = NULL;
@@ -799,4 +809,5 @@ return yield;
 }
 
 #endif   /*!MACRO_PREDEF*/
+#endif /*ROUTER_REDIRECT*/
 /* End of routers/redirect.c */