[Exim] small patch that expands 'smtp' options in smtp trans…

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Milan.Kocian
Fecha:  
A: exim-users
Asunto: [Exim] small patch that expands 'smtp' options in smtp transport
Hi,

can you review my patch, please? Don't crucify me. It is my first exim
patch and I don't now what some functions doing :-)). But it seems
working.
Can be this patch inserted in standart distribution? Naturally when
patch looks good.
Patch was tested witch exim 3.12 but I think that with 3.15 will be
work too.

I post patch here because I didn't find any development mailing-list
on exim website. Sorry.

Thank you

Milan Kocian

diff -u -r exim-3.15/src/transports/smtp.c exim-3.15.new/src/transports/smtp.c
--- exim-3.15/src/transports/smtp.c    Wed Jun 14 09:57:45 2000
+++ exim-3.15.new/src/transports/smtp.c    Fri Jun 16 01:21:01 2000
@@ -1326,6 +1326,7 @@
 BOOL continuing = continue_hostname != NULL;
 char *continue_host_address = NULL;
 char *expanded_hosts = NULL;
+char *expanded_service = NULL;
 smtp_transport_options_block *ob =
   (smtp_transport_options_block *)(tblock->options_block);
 host_item *hostlist = addrlist->host_list;
@@ -1417,18 +1418,34 @@
 to use htons() if the configuration specified a port by number instead of
 by name. */


-if (isdigit((uschar)(*ob->service)))
+if (strchr(ob->service, '$') != NULL)
+  {
+  expanded_service = expand_string(ob->service);
+  if (expanded_service == NULL)
+    {
+    addrlist->message = string_sprintf("failed to expand port(service) %s in %s "
+      "transport: %s", ob->service, tblock->name, expand_string_message);
+    addrlist->transport_return = search_find_defer? DEFER : PANIC;
+    return;
+    }
+  DEBUG(9) debug_printf("Expanded port(service) %s to %s\n", ob->service, expanded_service);
+  }
+else
+  {
+  expanded_service = ob->service;
+  }
+if (isdigit((uschar)*expanded_service))
   {
   char *end;
-  port = (int)htons((unsigned short)strtol(ob->service, &end, 0));
-  if (end != ob->service + (int)strlen(ob->service))
-    log_write(0, LOG_PANIC_DIE, "Invalid SMTP service: %s", ob->service);
+  port = (int)htons((unsigned short)strtol(expanded_service, &end, 0));
+  if (end != expanded_service + (int)strlen(expanded_service))
+    log_write(0, LOG_PANIC_DIE, "Invalid SMTP service: %s", expanded_service);
   }
 else
   {
-  struct servent *smtp_service = getservbyname(ob->service, "tcp");
+  struct servent *smtp_service = getservbyname(expanded_service, "tcp");
   if (smtp_service == NULL)
-    log_write(0, LOG_PANIC_DIE, "TCP service \"%s\" not found", ob->service);
+    log_write(0, LOG_PANIC_DIE, "TCP service \"%s\" not found", expanded_service);
   port = smtp_service->s_port;
   }