Pipe transport: expand the path option
authorJeremy Harris <jgh146exb@wizmail.org>
Sun, 4 Dec 2016 11:21:55 +0000 (11:21 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Sun, 4 Dec 2016 11:21:55 +0000 (11:21 +0000)
doc/doc-docbook/spec.xfpt
doc/doc-txt/ChangeLog
src/src/transports/pipe.c
test/confs/0173

index f9a80558e01a14722b49af09c3f228b1c36535c7..8c7d17b717091e5a64ae4919bdef8a5791db1e6f 100644 (file)
@@ -23290,12 +23290,12 @@ message_suffix =
 &`\n`& to &`\r\n`& in &%message_suffix%&.
 
 
 &`\n`& to &`\r\n`& in &%message_suffix%&.
 
 
-.option path pipe string "see below"
-This option specifies the string that is set up in the PATH environment
-variable of the subprocess. The default is:
-.code
-/bin:/usr/bin
-.endd
+.option path pipe string&!! "bin:/usr/bin"
+.new
+This option is expanded and
+.wen
+specifies the string that is set up in the PATH environment
+variable of the subprocess.
 If the &%command%& option does not yield an absolute path name, the command is
 sought in the PATH directories, in the usual way. &*Warning*&: This does not
 apply to a command specified as a transport filter.
 If the &%command%& option does not yield an absolute path name, the command is
 sought in the PATH directories, in the usual way. &*Warning*&: This does not
 apply to a command specified as a transport filter.
index b783303a1aeef16f5b3c935e65d2ce67a2103bc7..0127dd65a42509360ff155b9ed5624712709aec1 100644 (file)
@@ -6,6 +6,8 @@ Exim version 4.next
 JH/01 Bug 1922: Support IDNA2008.  This has slightly different conversion rules
       than -2003 did; needs libidn2 in addition to linidn.
 
 JH/01 Bug 1922: Support IDNA2008.  This has slightly different conversion rules
       than -2003 did; needs libidn2 in addition to linidn.
 
+JH/02 The path option on a pipe transport is now expanded before use
+
 
 Exim version 4.88
 -----------------
 
 Exim version 4.88
 -----------------
index d3841e05021332fcb26a75b2b8d19136bc992dc7..0535b674332103bf573922aabb8ecbb5ad4bc13b 100644 (file)
@@ -332,16 +332,14 @@ set_up_direct_command(const uschar ***argvptr, uschar *cmd,
 {
 BOOL permitted = FALSE;
 const uschar **argv;
 {
 BOOL permitted = FALSE;
 const uschar **argv;
-uschar buffer[64];
 
 /* Set up "transport <name>" to be put in any error messages, and then
 call the common function for creating an argument list and expanding
 the items if necessary. If it fails, this function fails (error information
 is in the addresses). */
 
 
 /* Set up "transport <name>" to be put in any error messages, and then
 call the common function for creating an argument list and expanding
 the items if necessary. If it fails, this function fails (error information
 is in the addresses). */
 
-sprintf(CS buffer, "%.50s transport", tname);
 if (!transport_set_up_command(argvptr, cmd, expand_arguments, expand_fail,
 if (!transport_set_up_command(argvptr, cmd, expand_arguments, expand_fail,
-      addr, buffer, NULL))
+      addr, string_sprintf("%.50s transport", tname), NULL))
   return FALSE;
 
 /* Point to the set-up arguments. */
   return FALSE;
 
 /* Point to the set-up arguments. */
@@ -350,12 +348,11 @@ argv = *argvptr;
 
 /* If allow_commands is set, see if the command is in the permitted list. */
 
 
 /* If allow_commands is set, see if the command is in the permitted list. */
 
-if (ob->allow_commands != NULL)
+if (ob->allow_commands)
   {
   int sep = 0;
   const uschar *s;
   uschar *p;
   {
   int sep = 0;
   const uschar *s;
   uschar *p;
-  uschar buffer[256];
 
   if (!(s = expand_string(ob->allow_commands)))
     {
 
   if (!(s = expand_string(ob->allow_commands)))
     {
@@ -365,7 +362,7 @@ if (ob->allow_commands != NULL)
     return FALSE;
     }
 
     return FALSE;
     }
 
-  while ((p = string_nextinlist(&s, &sep, buffer, sizeof(buffer))))
+  while ((p = string_nextinlist(&s, &sep, NULL, 0)))
     if (Ustrcmp(p, argv[0]) == 0) { permitted = TRUE; break; }
   }
 
     if (Ustrcmp(p, argv[0]) == 0) { permitted = TRUE; break; }
   }
 
@@ -389,7 +386,7 @@ if (!permitted)
       }
     }
 
       }
     }
 
-  else if (ob->allow_commands != NULL)
+  else if (ob->allow_commands)
     {
     addr->transport_return = FAIL;
     addr->message = string_sprintf("\"%s\" command not permitted by %s "
     {
     addr->transport_return = FAIL;
     addr->message = string_sprintf("\"%s\" command not permitted by %s "
@@ -405,10 +402,9 @@ if (argv[0][0] != '/')
   {
   int sep = 0;
   uschar *p;
   {
   int sep = 0;
   uschar *p;
-  const uschar *listptr = ob->path;
-  uschar buffer[1024];
+  const uschar *listptr = expand_string(ob->path);
 
 
-  while ((p = string_nextinlist(&listptr, &sep, buffer, sizeof(buffer))) != NULL)
+  while ((p = string_nextinlist(&listptr, &sep, NULL, 0)))
     {
     struct stat statbuf;
     sprintf(CS big_buffer, "%.256s/%.256s", p, argv[0]);
     {
     struct stat statbuf;
     sprintf(CS big_buffer, "%.256s/%.256s", p, argv[0]);
@@ -418,7 +414,7 @@ if (argv[0][0] != '/')
       break;
       }
     }
       break;
       }
     }
-  if (p == NULL)
+  if (!p)
     {
     addr->transport_return = FAIL;
     addr->message = string_sprintf("\"%s\" command not found for %s transport",
     {
     addr->transport_return = FAIL;
     addr->message = string_sprintf("\"%s\" command not found for %s transport",
@@ -618,7 +614,7 @@ if (cmd == NULL || *cmd == '\0')
 and numerical the variables in existence. These are passed in
 addr->pipe_expandn for use here. */
 
 and numerical the variables in existence. These are passed in
 addr->pipe_expandn for use here. */
 
-if (expand_arguments && addr->pipe_expandn != NULL)
+if (expand_arguments && addr->pipe_expandn)
   {
   uschar **ss = addr->pipe_expandn;
   expand_nmax = -1;
   {
   uschar **ss = addr->pipe_expandn;
   expand_nmax = -1;
@@ -658,7 +654,7 @@ envp[envcount++] = string_sprintf("LOCAL_PART_SUFFIX=%#s",
 envp[envcount++] = string_sprintf("DOMAIN=%s", deliver_domain);
 envp[envcount++] = string_sprintf("HOME=%#s", deliver_home);
 envp[envcount++] = string_sprintf("MESSAGE_ID=%s", message_id);
 envp[envcount++] = string_sprintf("DOMAIN=%s", deliver_domain);
 envp[envcount++] = string_sprintf("HOME=%#s", deliver_home);
 envp[envcount++] = string_sprintf("MESSAGE_ID=%s", message_id);
-envp[envcount++] = string_sprintf("PATH=%s", ob->path);
+envp[envcount++] = string_sprintf("PATH=%s", expand_string(ob->path));
 envp[envcount++] = string_sprintf("RECIPIENT=%#s%#s%#s@%#s",
   deliver_localpart_prefix, deliver_localpart, deliver_localpart_suffix,
   deliver_domain);
 envp[envcount++] = string_sprintf("RECIPIENT=%#s%#s%#s@%#s",
   deliver_localpart_prefix, deliver_localpart, deliver_localpart_suffix,
   deliver_domain);
@@ -866,10 +862,10 @@ if (!transport_write_message(fd_in, &tctx, 0))
 
 /* Now any configured suffix */
 
 
 /* Now any configured suffix */
 
-if (ob->message_suffix != NULL)
+if (ob->message_suffix)
   {
   uschar *suffix = expand_string(ob->message_suffix);
   {
   uschar *suffix = expand_string(ob->message_suffix);
-  if (suffix == NULL)
+  if (!suffix)
     {
     addr->transport_return = search_find_defer? DEFER : PANIC;
     addr->message = string_sprintf("Expansion of \"%s\" (suffix for %s "
     {
     addr->transport_return = search_find_defer? DEFER : PANIC;
     addr->message = string_sprintf("Expansion of \"%s\" (suffix for %s "
@@ -1077,11 +1073,10 @@ if ((rc = child_close(pid, timeout)) != 0)
         {
         const uschar *s = ob->temp_errors;
         uschar *p;
         {
         const uschar *s = ob->temp_errors;
         uschar *p;
-        uschar buffer[64];
         int sep = 0;
 
         addr->transport_return = FAIL;
         int sep = 0;
 
         addr->transport_return = FAIL;
-        while ((p = string_nextinlist(&s,&sep,buffer,sizeof(buffer))))
+        while ((p = string_nextinlist(&s,&sep,NULL,0)))
           if (rc == Uatoi(p)) { addr->transport_return = DEFER; break; }
         }
 
           if (rc == Uatoi(p)) { addr->transport_return = DEFER; break; }
         }
 
index 1b423e152b57ebe1c637178abcc14e1ec8e4e477..bfddc71e867158ef3218778b9e0f958d836ae354 100644 (file)
@@ -36,6 +36,7 @@ pipe:
   driver = pipe
   return_output
   user = CALLER
   driver = pipe
   return_output
   user = CALLER
+  path = ${env{PATH}}
 
 
 # ----- Retry -----
 
 
 # ----- Retry -----