8

I encountered this problem with my Postfix install:

https://www.virtualmin.com/node/23909

i.e. I was getting the error:

postfix/smtp[130]: fatal: unknown service: smtp/tcp

and like at the url above, the solution was to manually copy /etc/services and /etc/resolv.conf into /var/spool/postfix/etc

My impression is this "just started happening" and previously wasn't a problem, however I have only been making minor seemingly unrelated changes to postfix main.cf so I don't understand why.

The Postfix installation tutorials I was following don't mention anything about having to manually copy those files... this feels like something Postfix ought to do by itself and isn't for some reason.

Is there some underlying misconfiguration that would cause this?

5 Answers 5

18

Some Postfix processes are running in a chroot environment by default. Therefore there usually is something to provide them with the necessary files on startup.

On my Debian 7 system, the file /etc/init.d/postfix has the following lines that copy all necessary files inside the chroot:

FILES="etc/localtime etc/services etc/resolv.conf etc/hosts \
        etc/nsswitch.conf etc/nss_mdns.config"
for file in $FILES; do
     [ -d ${file%/*} ] || mkdir -p ${file%/*}
     if [ -f /${file} ]; then rm -f ${file} && cp /${file} ${file}; fi
     if [ -f  ${file} ]; then chmod a+rX ${file}; fi
done

It is strange that your installation does not include this; you shouldn’t have to do anything by yourself here.

How did you install postfix and on which system?

1
  • 6
    ah! I'd switched from starting postfix via service postfix start (i.e. making use of /etc/init.d/postfix) to just doing postfix start... going back to service postfix start solves it, surely for the reason above
    – Anentropic
    Jan 22, 2015 at 18:33
5

It looks like Postfix wants to run chrooted. See here for more info about what that means.

You can change it with the Chroot configuration option in /etc/postfix/master.cf.

0

It can be a timing issue with NetworkManager. Make postfix load later in the boot process by changing the name of the postfix file in /etc/rc{x}.d

For example:

sudo mv /etc/rc5.d/S20postfix /etc/rc5.d/S92postfix

You may have to change this in all your /etc/rc{x}.d directories. Remember to reboot to test it.

2
  • IIRC, NetworkManager rebuilds the /etc/resolv.conf from scratch on startup. It blanks out all the lines except for the first comment line. If the postfix startup script calls for this file on startup in the timeframe that NM is rebuilding /etc/resolv.conf, then your /var/spool/postfix/etc/resolv.conf will have only the first commented line. Making postifx load later in the boot process should help with this.
    – TomBoland
    Sep 2, 2015 at 14:03
  • You can edit your question to put in the extra information, you don't have to comment on your own question. (And you probably shouldn't as comments aren't regarded too well, and might not survive)
    – Reaces
    Sep 2, 2015 at 14:39
0

If the file just contains one line with the text "# Generated by resolvconf" it is most likely a problem with boot order.

First check if "/etc/resolv.conf" contains the nameserver. If this is the case your network is correctly configured and up.

Even on modern distributions with systemd postfix is currently still booted up by init.d scripts that are processed during systemd boot. To understand what is happening during boot just read this article: https://unix.stackexchange.com/questions/233468/how-does-systemd-use-etc-init-d-scripts

Postfix is started by executing "/etc/rc1.d/K01postfix". This script contains the following line to ensure network:

# Required-Start:    $local_fs $remote_fs $syslog $named $network $time

And here is the problem. We have to ensure that the network is not only up but also online. Otherwise the resolv.conf is copied from "/etc/resolv.conf" before it has been completely created.

This can be done by executing:

systemctl enable systemd-networkd-wait-online.service

See also this article for a good description: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

-1

I found that the easiest solution to this problem for me was to add a restart of the postfix restart into /etc/rc.local

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .