What’s touching that config file?!

Recently I started wondering what the heck was putting “root: bolt” at the end of /etc/aliases “every time” I did an upgrade of something.

I asked #debian on irc.freenode.net, who told me to run this:

grep /etc/aliases /var/lib/dpkg/info/*postinst

What it does is basically to look though all files which names end in “postinst” in the /var/lib/dpkg/info/ directory, showing all lines which contain “/etc/aliases“, and where they’re at.

The result was this:

$ grep /etc/aliases /var/lib/dpkg/info/*postinst
/var/lib/dpkg/info/exim4-config.postinst:    echo "root: ${poma}" >> /etc/aliases
/var/lib/dpkg/info/exim4-config.postinst:#initialize /etc/aliases
/var/lib/dpkg/info/exim4-config.postinst:echo '# /etc/aliases' > /etc/aliases.tmp
/var/lib/dpkg/info/exim4-config.postinst:echo 'mailer-daemon: postmaster' >> /etc/aliases.tmp
/var/lib/dpkg/info/exim4-config.postinst:done >> /etc/aliases.tmp
/var/lib/dpkg/info/exim4-config.postinst:mv /etc/aliases.tmp /etc/aliases
/var/lib/dpkg/info/exim4-config.postinst:    if [ ! -e /etc/aliases ] ; then
/var/lib/dpkg/info/exim4-config.postinst:    if ! grep -q '^root:[[:space:]]*[[:alnum:]]' /etc/aliases && \

This tells you a lot of things. Firstly, exim4 is likely the culprit here. Upgrading it will likely cause “root: bolt” (or whoever is set as your postmaster in exim4) to be added to the end of the file again. Also, if you notice the last line there, it’s actually grepping for a line starting with “root:”, followed by a space and something alpha-numeric.

This means that if I, instead of removing or commenting the “root: bolt” line, replace it with “root: root”, directing all of root’s mail… to root, there will be a line matching the aforementioned description, and exim4’s postinst script will leave /etc/aliases alone.


Leave a Reply

Your email address will not be published. Required fields are marked *