How to make Postfix ignore leading whitespace in virtual alias table format?
The virtual alias table format of Postfix gives special meaning to leading whitespace under certain conditions:
multi-line text
A logical line starts with non-whitespace text. A line that
starts with whitespace continues a logical line.
I have lots of entries in those files following this example. Especially the prefix a
is of different lengths for multiple different lines.
# Some comment...
[email protected] recipient
[email protected] recipient
[email protected] recipient
[email protected] recipient
[email protected] recipient
[email protected] recipient
To make things better readable, I would like to have the following layout of the same entries instead:
# Some comment...
[email protected] recipient
[email protected] recipient
[email protected] recipient
[email protected] recipient
[email protected] recipient
[email protected] recipient
Or sometimes the same approach with a different order. Though, the former example would be more common in theory.
# Some comment...
[email protected] recipient
[email protected] recipient
[email protected] recipient
[email protected] recipient
[email protected] recipient
[email protected] recipient
So, the difference really only is to add leading whitespace to make things more readable. At least in the second example, according to the docs that leading whitespace would be recognized as continuation of the former lines, which would simply be wrong in my case.
But how is the first example treated? There's never a starting logical line in theory, but lines as well are not empty or whitespace or comments only.
In general, is there any way to configure/... Postfix that leading whitespace is simply always ignored and never used for continuation?
If it's simply not possible at all with the current implementation of Postfix, I will accept that. Just want to make sure I'm not missing something.
Thanks!
Solution 1:
Postfix comes with a postmap
tool for pre-compiling tables.
postmap hash:/tmp/virtual && postmap -s hash:/tmp/virtual
postmap hash:/tmp/virtual && postmap -q "[email protected]" hash:/tmp/virtual
But how is the first example treated? There's never a starting logical line in theory, but lines as well are not empty or whitespace or comments only.
Postfix warns you that a "logical line must not start with whitespace" and ignores the following continuation lines, resulting in a table with just one entry (for "a.b.c.d").
(This seems to be different from the configuration file parser, where a comments-only line still counts as a logical line and the comment simply carries over to all continuation lines.)
In general, is there any way to configure/... Postfix that leading whitespace is simply always ignored and never used for continuation?
No. The usage of Postfix's readllines() "logical line read" function is not configurable.