-2

Can send but not receive from a Gmail. Postfix is on 3.6.2, OS is Ubuntu 18.04.

I am trying to get chroot setup on my Postfix server. I have used the LINUX2 script from examples\chroot-setup. This article mentions my exact problem, but the adjustments to the script don't do anything: https://titanwolf.org/Network/Articles/Article?AID=34a1b4ec-6d41-44f7-a914-e822d6b61351#gsc.tab=0 (It appears it's translated and it's quite poor.)

After running the LINUX2 script, lib and lib64 (/var/spool/postfix) are empty. The libraries I need are on my system but some are in /lib/x86_64-linux-gnu/ and others in /usr/lib/x86_64-linux-gnu. The filenames also seem to vary. Even if I copy both folders to lib64 and restart Postfix, I still cannot receive. Of course, if I remove chroot from smtp it works fine.

Tyler Montney
  • 1,402
  • 1
  • 17
  • 25

1 Answers1

0

I realized I was copying from the right directories to the wrong ones in chroot. Here's the full working script, my changes are notated by three #'s on boths sides:

#! /bin/sh

CP="cp -p"

cond_copy() {
  # find files as per pattern in $1
  # if any, copy to directory $2
  dir=`dirname "$1"`
  pat=`basename "$1"`
  ### Added a slash to $dir ###
  lr=`find "$dir/" -maxdepth 1 -name "$pat"`
  if test ! -d "$2" ; then exit 1 ; fi
  if test "x$lr" != "x" ; then $CP $1 "$2" ; fi
} 

set -e
umask 022

POSTFIX_DIR=${POSTFIX_DIR-/var/spool/postfix}
cd ${POSTFIX_DIR}

mkdir -p etc lib usr/lib/zoneinfo lib/x86_64-linux-gnu usr/lib/x86_64-linux-gnu
test -d /lib64 && mkdir -p lib64

# find localtime (SuSE 5.3 does not have /etc/localtime)
lt=/etc/localtime
if test ! -f $lt ; then lt=/usr/lib/zoneinfo/localtime ; fi
if test ! -f $lt ; then lt=/usr/share/zoneinfo/localtime ; fi
if test ! -f $lt ; then echo "cannot find localtime" ; exit 1 ; fi
rm -f etc/localtime

# copy localtime and some other system files into the chroot's etc
$CP -f $lt /etc/services /etc/resolv.conf /etc/nsswitch.conf etc
$CP -f /etc/host.conf /etc/hosts /etc/passwd etc
ln -s -f /etc/localtime usr/lib/zoneinfo

### My "fix" for Ubuntu. ###
if test -d /lib/x86_64-linux-gnu; then
  cond_copy '/lib/x86_64-linux-gnu/libnss_*.so*' lib/x86_64-linux-gnu
  cond_copy '/lib/x86_64-linux-gnu/libresolv.so*' lib/x86_64-linux-gnu
  cond_copy '/lib/x86_64-linux-gnu/libdb.so*' lib/x86_64-linux-gnu
fi
if test -d /usr/lib/x86_64-linux-gnu; then
  cond_copy '/usr/lib/x86_64-linux-gnu/libnss_*.so*' usr/lib/x86_64-linux-gnu
  cond_copy '/usr/lib/x86_64-linux-gnu/libresolv.so*' usr/lib/x86_64-linux-gnu
  cond_copy '/usr/lib/x86_64-linux-gnu/libdb.so*' usr/lib/x86_64-linux-gnu
fi
### End fix ###

postfix reload
Tyler Montney
  • 1,402
  • 1
  • 17
  • 25