*** make_chroot_jail.sh	2016-01-21 08:30:32.216010166 -0500
--- make_chroot_jail_new.sh	2016-01-21 09:59:09.453163442 -0500
***************
*** 35,40 ****
--- 35,45 ----
  # - move existing accounts to chroot
  #####################################################################
  
+ #
+ # 1/21/2016 - Jon M, Fixed to work with i386 32-bit Debian Jessie. It 
+ #             might work with amd64.
+ #####################################################################
+ 
  # path to sshd's config file: needed for automatic detection of the locaten of
  # the sftp-server binary
  SSHD_CONFIG="/etc/ssh/sshd_config"
***************
*** 403,410 ****
  # the old method with $HOME/ldlist[2] (so I don't have to check the existence
  # of the mktemp package / binary at the beginning
  #
! TMPFILE1=`mktemp` &> /dev/null ||  TMPFILE1="${HOME}/ldlist"; if [ -x ${TMPFILE1} ]; then mv ${TMPFILE1} ${TMPFILE1}.bak;fi
! TMPFILE2=`mktemp` &> /dev/null ||  TMPFILE2="${HOME}/ldlist2"; if [ -x ${TMPFILE2} ]; then mv ${TMPFILE2} ${TMPFILE2}.bak;fi
  
  for app in $APPS;  do
      # First of all, check that this application exists
--- 408,421 ----
  # the old method with $HOME/ldlist[2] (so I don't have to check the existence
  # of the mktemp package / binary at the beginning
  #
! TMPFILE1=`mktemp` ||  TMPFILE1="${HOME}/ldlist"
! if [ -x ${TMPFILE1} ]; then 
!   mv ${TMPFILE1} ${TMPFILE1}.bak
! fi
! TMPFILE2=`mktemp` || TMPFILE2="${HOME}/ldlist2"
! if [ -x ${TMPFILE2} ]; then 
!   mv ${TMPFILE2} ${TMPFILE2}.bak
! fi
  
  for app in $APPS;  do
      # First of all, check that this application exists
***************
*** 435,441 ****
     fi
  done
  for lib in `cat ${TMPFILE2}`; do
!     mkdir -p .`dirname $lib` > /dev/null 2>&1
  
  	# If the files in the chroot are on the same file system as the original
  	# files you should be able to use hard links instead of copying the files,
--- 446,453 ----
     fi
  done
  for lib in `cat ${TMPFILE2}`; do
!     libpath=`dirname $lib` 
!     mkdir -p .$libpath
  
  	# If the files in the chroot are on the same file system as the original
  	# files you should be able to use hard links instead of copying the files,
***************
*** 469,476 ****
    # needed for scp on RHEL
    echo "export LD_LIBRARY_PATH=/usr/kerberos/lib" >> ${JAILPATH}/etc/profile
  elif [ "$DISTRO" = DEBIAN ]; then
!   cp /lib/libnss_compat.so.2 /lib/libnsl.so.1 /lib/libnss_files.so.2 /lib/libcap.so.1 /lib/libnss_dns.so.2 ${JAILPATH}/lib/
! else
    cp /lib/libnss_compat.so.2 /lib/libnsl.so.1 /lib/libnss_files.so.2 /lib/libcap.so.1 /lib/libnss_dns.so.2 ${JAILPATH}/lib/
  fi
  
--- 481,501 ----
    # needed for scp on RHEL
    echo "export LD_LIBRARY_PATH=/usr/kerberos/lib" >> ${JAILPATH}/etc/profile
  elif [ "$DISTRO" = DEBIAN ]; then
!   OTHERLIBPATH=""
!   if [ -d /lib/x86_64-linux-gnu ]; then
!     OTHERLIBPATH="lib/x86_64-linux-gnu"
!   fi
!   if [ -d /lib/i386-linux-gnu ]; then
!     OTHERLIBPATH="lib/i386-linux-gnu"
!   fi
!   if [ "$OTHERLIBPATH" != "" ]; then
!     if ! [ -d ${JAILPATH}/${OTHERLIBPATH} ]; then
!       mkdir -p ${JAILPATH}/${OTHERLIBPATH}
!     fi
!     cp /${OTHERLIBPATH}/libnss_compat.so.2 /${OTHERLIBPATH}/libnsl.so.1 /${OTHERLIBPATH}/libnss_files.so.2 \
!       /${OTHERLIBPATH}/libcap.so.2 /${OTHERLIBPATH}/libnss_dns.so.2 ${JAILPATH}/${OTHERLIBPATH}
!   fi
!   else
    cp /lib/libnss_compat.so.2 /lib/libnsl.so.1 /lib/libnss_files.so.2 /lib/libcap.so.1 /lib/libnss_dns.so.2 ${JAILPATH}/lib/
  fi
  
***************
*** 487,493 ****
  
  # ...and of course the PAM-modules...
  echo "Copying PAM-Modules to jail"
! cp -r /lib/security ${JAILPATH}/lib/
  
  # ...and something else useful for PAM
  cp -r /etc/security ${JAILPATH}/etc/
--- 512,531 ----
  
  # ...and of course the PAM-modules...
  echo "Copying PAM-Modules to jail"
! if [ "$DISTRO" = DEBIAN ]; then
!   OTHERLIBPATH=""
!   if [ -d /lib/x86_64-linux-gnu/security ]; then
!     OTHERLIBPATH="lib/x86_64-linux-gnu"
!   fi
!   if [ -d /lib/i386-linux-gnu/security ]; then
!     OTHERLIBPATH="lib/i386-linux-gnu"
!   fi
!   if [ "$OTHERLIBPATH" != "" ]; then
!     cp -r /${OTHERLIBPATH}/security ${JAILPATH}/${OTHERLIBPATH}
!   fi
!   else
!   cp -r /lib/security ${JAILPATH}/lib/
! fi
  
  # ...and something else useful for PAM
  cp -r /etc/security ${JAILPATH}/etc/
