Re: [exim] Stacking or renaming headers

2023-03-19 Thread Jeremy Harris via Exim-users

On 19/03/2023 17:42, Ian Z via Exim-users wrote:

   X-Original-Foo: the-ur-foo
   Foo: the-no-longer-ur-foo

I am not thinking of a header with addresses here, so Exim's rewrite
mechanism doesn't apply. Is there a "best" or "accepted" way to do
this? In particular, can I do this in an ACL:

   add_header = X-Original-Foo: $h_foo:
   set acl_m_original_foo = $h_foo:
   remove_header = Foo
   add_header = Foo: the-no-longer-$acl_m_original_foo


Yes.  And you don't need the temporary variable.


(I am not sure if the last add_header trum^H^H^H^Hoverrides the
preceding remove_header.)


No.


And if not in ACL, can I do something similar in a router or transport?


Yes, both.
--
Cheers,
  Jeremy


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


Re: [exim] Single quotes and transport_filter

2023-03-19 Thread Jeremy Harris via Exim-users

On 19/03/2023 17:22, Ian Z via Exim-users wrote:

Chapter 24 documents the transport_filter option. An example is given
where the argv vector for the command comes from an expansion:

   transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'

   This runs the command /bin/cmd1 if the host name is a.b.c, and
   /bin/cmd2 otherwise. If double quotes had been used, they would have
   been stripped by Exim when it read the option’s value.  When the
   value is used, if the single quotes were missing, the line would be
   split into two items, /bin/cmd${if and eq{$host}{a.b.c}{1}{2}, and
   an error would occur when Exim tried to expand the first one.

I have two problems grokking this:

- I can  find no other place in the spec where it is specifically
   explained what single quotes do, as opposed to double quotes.


Yup; this could be better.

In the coding I find an explanatory comment:

/* Split the command up into arguments terminated by white space. Lose
trailing space at the start and end. Double-quoted arguments can contain \\ and
\" escapes and so can be handled by the standard function; single-quoted
arguments are verbatim. Copy each argument into a new string. */



- In Section 29.3 on pipe commands (which are supposedly expanded the
   same way), there is this example:

 command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}

 will not work, because the expansion item gets split between
 several arguments.  You have to write

 command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"

   So why are double quotes OK here?


The difference is an artefact of the option-handling described in
Ch.6 Sec.17 :-  if an option value *starts* with a doublequote
then it must end with one (and, implicitly, they get stripped
at that processing phase.  The pipe example does not.

--
Cheers,
  Jeremy


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


[exim] Stacking or renaming headers

2023-03-19 Thread Ian Z via Exim-users
By "Stacking", I mean the common pattern where

  Foo: the-ur-foo

is rewritten into

  X-Original-Foo: the-ur-foo
  Foo: the-no-longer-ur-foo

I am not thinking of a header with addresses here, so Exim's rewrite
mechanism doesn't apply. Is there a "best" or "accepted" way to do
this? In particular, can I do this in an ACL:

  add_header = X-Original-Foo: $h_foo:
  set acl_m_original_foo = $h_foo:
  remove_header = Foo
  add_header = Foo: the-no-longer-$acl_m_original_foo

(I am not sure if the last add_header trum^H^H^H^Hoverrides the
preceding remove_header.)

And if not in ACL, can I do something similar in a router or transport?

-- 
Ian

-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


[exim] Single quotes and transport_filter

2023-03-19 Thread Ian Z via Exim-users
Chapter 24 documents the transport_filter option. An example is given
where the argv vector for the command comes from an expansion:

  transport_filter = '/bin/cmd${if eq{$host}{a.b.c}{1}{2}}'

  This runs the command /bin/cmd1 if the host name is a.b.c, and
  /bin/cmd2 otherwise. If double quotes had been used, they would have
  been stripped by Exim when it read the option’s value.  When the
  value is used, if the single quotes were missing, the line would be
  split into two items, /bin/cmd${if and eq{$host}{a.b.c}{1}{2}, and
  an error would occur when Exim tried to expand the first one.

I have two problems grokking this:

- I can  find no other place in the spec where it is specifically
  explained what single quotes do, as opposed to double quotes.

- In Section 29.3 on pipe commands (which are supposedly expanded the
  same way), there is this example:

command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}

will not work, because the expansion item gets split between
several arguments.  You have to write

command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"

  So why are double quotes OK here?

-- 
Ian

-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


Re: [exim] Tainted search query is not properly quoted

2023-03-19 Thread Jeremy Harris via Exim-users

On 19/03/2023 10:58, Odhiambo Washington via Exim-users wrote:

  warn  condition= ${if eq {$acl_m_greyexpiry}{} {1}}
 set acl_m_dontcare = ${lookup sqlite {INSERT INTO greylist \
   VALUES ( '$acl_m_greyident', \

  '${eval10:$tod_epoch+300}', \

  '${quote_sqlite:$sender_host_address}', \

  '${quote_sqlite:$sender_helo_name}' );}}


It's not obvious to me what I haven't quoted properly.


The only obvious element is your $acl_m_greyindent, since $tod_epoch
shouldn't be derived from wire information.  The debug "expand" channel
would show you for definite.
--
Cheers,
  Jeremy


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


[exim] Tainted search query is not properly quoted

2023-03-19 Thread Odhiambo Washington via Exim-users
I am missing a little something in my config for greylisting.
Exim-4.96 here.

2023-03-19 13:53:21 1pdqf6-000LgR-0z tainted search query is not properly
quoted (ACL warn, /etc/exim/exim-greylist.conf.inc 124): INSERT INTO
greylist VALUES ( 'ecpeUlXRs7cHPrkaiW5j', '1679223501', '74.6.132.40', '
sonic306-1.consmr.mail.bf2.yahoo.com' );

The relevant config causing this:

 warn  condition= ${if eq {$acl_m_greyexpiry}{} {1}}
set acl_m_dontcare = ${lookup sqlite {INSERT INTO greylist \
  VALUES ( '$acl_m_greyident', \

 '${eval10:$tod_epoch+300}', \

 '${quote_sqlite:$sender_host_address}', \

 '${quote_sqlite:$sender_helo_name}' );}}


It's not obvious to me what I haven't quoted properly.


-- 
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254 7 3200 0004/+254 7 2274 3223
"Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)
-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/