postfix alias config error / local_recipient_maps syntax issue

I'm having "postfix Traumatic Stress" trying to get email running on a new server. I installed the /usr/local/etc/postfix/main.cf and master.cf that worked on the production server on the new server.
Problem 1: when I run "newaliases", I get this output:

Code:
# newaliases
aliases line 13: syntax error
newaliases: could not parse aliases file `/etc/aliases': No error: 0

It was unhappy with the line:
Code:
mail_to_program: "| /usr/local/www/data/program_that_takes_the_email"
(there should be a law against "syntax error" when a piece of software was no doubt looking at a very specific aspect of the input)
If I remove that line, there are no errors.
This was from a very compact aliases file:

Code:
root:           myname
# Basic system aliases -- these MUST be present
MAILER-DAEMON:  postmaster
postmaster:     root
freebsd-daily-report: myname
admin: myname
administrator: myname

Code:
# trap decode to catch security attacks
decode:         root
devnull:        /dev/null

mail_to_program: "| /usr/local/www/data/program_that_takes_the_email"

# postconf -n shows:

Code:
alias_database = hash:/usr/local/etc/postfix/aliases
alias_maps = hash:/usr/local/etc/postfix/aliases
allow_mail_to_commands = alias
command_directory = /usr/local/sbin

compatibility_level = 3.9
daemon_directory = /usr/local/libexec/postfix
data_directory = /var/db/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
default_privs = mailnull
disable_vrfy_command = yes
html_directory = /usr/local/share/doc/postfix
inet_interfaces = all
inet_protocols = ipv4
local_recipient_maps = unix:passwd.byname $alias_maps
mail_owner = postfix
mail_spool_directory = /var/mail
mailbox_size_limit = 0
mailq_path = /usr/local/bin/mailq
manpage_directory = /usr/local/man
meta_directory = /usr/local/libexec/postfix
mydomain = foobar.net
myhostname = foobar.net
mynetworks = 127.0.0.0/8, 192.168.0.0/16
mynetworks_style = host
myorigin = foobar.net
newaliases_path = /usr/local/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = /usr/local/share/doc/postfix
sample_directory = /usr/local/etc/postfix
sendmail_path = /usr/local/sbin/sendmail
setgid_group = maildrop
shlib_directory = /usr/local/lib/postfix
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, permit
smtpd_tls_ask_ccert = yes
smtpd_tls_cert_file = /usr/local/etc/apache24/ssl/pemforeverything.pem
smtpd_tls_key_file = $smtpd_tls_cert_file
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_timeout = 3600s
unknown_local_recipient_reject_code = 550

Problem 2:
While I have these two lines in my main.cf that should say where the alias file is:
Code:
alias_database = hash:/usr/local/etc/postfix/aliases
alias_maps = hash:/usr/local/etc/postfix/aliases
and they verify if I do a postalias /usr/local/etc/postfix/aliases
The same file, if moved to /etc/aliases gets the above "syntax error" errors.
However the errors in the maillog file when email comes in to mail_to_program@foobar.net look like:

Code:
Nov 23 13:51:53 foobar dma[dma][65730]: aliases line 13: syntax error
Nov 23 13:51:53 foobar dma[dma][65730]: could not parse aliases file `/etc/aliases': No error: 0

I don't know why the /etc/aliases is being used instead of the file specified in the alias_maps parameter.
At day 3 working on this, it was time to ask for help.
postconf mail_version shows mail_version = 3.9
freebsd-version shows 14.1-STABLE
 
Last edited by a moderator:
Not sure, if this helps... I'm using postmap to generate the hashfile/db instead of newaliases. You could attempt to truss the newaliases run to see where it gets the idea with /etc/aliases from?

The man page for newaliases says it should actually read /etc/mail/aliases...
 
I think you are right about newaliases being hard-wired to /etc/aliases. Running postalias had no errors, but newaliases had errors. And it looks like DMA is also hardwired to /etc/aliases.
This still leaves the problem of figuring out what the syntax error is. And the mystery of why what worked on the old server, running V13.3 and the various piece that were compatable with did not work. The same config files, but now there are errors.
truss had a _lot_ of output, will take time to digest it.
But there was this in /etc/dma/dma.conf
# Path to your alias file. Just stay with the default.
#ALIASES /etc/aliases
 
I change my configuration so that /etc/aliases was where the alias files lived. That way it matches the defauilt in dma. So newaliases build up the database where dma expects to find it.

I'm still getting the syntax error, but, it apparently isn't fatal. Emails are being piped into receiver programs as it was.

Thanks to cmoerz for mentioning truss I did not think of that and it helped.

This is also why I hate any piece of software (config, interpreters, compilers) that just say "syntax error" when it could easily have been more specific, and if the error cause processing to stop, advise the the error was Fatal.
 
remove the double quotes and space after the pipe line. The space after the pipeline gives the error, even if it's quoted. You can make a PR for this bug. Most likely it's introduced after the migration from sendmail to dma.

mail_to_program: |/usr/local/www/data/program_that_takes_the_email

aliases(5)

the default example of msgs also doesn't work because it have "space"
msgs: "| /usr/bin/msgs -s"

 
What does /etc/mail/mailer.conf look like?
Looks like this:
Code:
#
# mailer.conf for use with dma(8)
#
# If sendmail is configured, an example of mailer.conf that uses sendmail
# instead can be found in /usr/share/examples/sendmail.

sendmail        /usr/libexec/dma
mailq           /usr/libexec/dma
newaliases      /usr/libexec/dma
 
remove the double quotes and space after the pipe line. The space after the pipeline gives the error, even if it's quoted. You can make a PR for this bug. Most likely it's introduced after the migration from sendmail to dma.



aliases(5)

the default example of msgs also doesn't work because it have "space"



That did the trick. The line number for the error moved down the 1st line that was in quotes.
So this gets rid of the error.

Thanks so much both of you ! this has been a rough upgrade. There were a few other things that I figured out and fixed, seems like every major piece had some changes. The "database in an RamDisk" is preforming well. The server sits there for minutes at a time with no external/SSD disk activity.
 
/usr/local/share/postfix/mailer.conf.postfix
Looks like:
Code:
#
# Execute the Postfix sendmail program, named /usr/local/sbin/sendmail
#
sendmail        /usr/local/sbin/sendmail
send-mail       /usr/local/sbin/sendmail
mailq           /usr/local/sbin/sendmail
newaliases      /usr/local/sbin/sendmail
 
Back
Top