Why do I have to manually copy /etc/services and /etc/resolv.conf into /var/spool/postfix/etc?

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?


Solution 1:

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?

Solution 2:

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.