Changeset e961598


Ignore:
Timestamp:
07/10/13 08:20:22 (16 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
87d35b7
Parents:
22f36fc
Message:

Now it encrypts all files properly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-sh/xtrafiles/local/bin/enable_user_pefs

    r22f36fc re961598  
    55 
    66PEFSDBDIR="/var/db/pefs" 
     7 
     8# Check if we can safely enable PEFS on this system 
     9if [ ! -e "/boot/kernel/pefs.ko" ] ; then 
     10   echo "Error: Requires PEFS in base system!" 
     11   exit 1 
     12fi 
    713 
    814USER="$1" 
     
    2026fi 
    2127 
     28if [ "${USERHOMEDIR}" = "/" ] ; then 
     29   echo "Invalid HOMEDIR = / " 
     30   exit 1 
     31fi 
     32 
    2233if [ "$USERHOMEDIR" != "`realpath ${USERHOMEDIR}`" ] ; then 
    23   echo "Warning: PEFS will not work with sym-linked home dirs.." 
     34  NEWDIR=`realpath $USERHOMEDIR` 
     35  echo "Updating sym-linked home dir ${USERHOMEDIR} -> ${NEWDIR}" 
     36  OLDLINE=`cat /etc/master.passwd | grep "^${USER}:" | cut -d ':' -f 4-` 
     37  NEWLINE=`echo $OLDLINE | sed "s|:${USERHOMEDIR}:|:${NEWDIR}:|g"` 
     38  sed -i '.bak' "s|${OLDLINE}|${NEWLINE}|g" /etc/master.passwd 
     39  pwd_mkdb -p /etc/master.passwd 
    2440  USERHOMEDIR=`realpath $USERHOMEDIR` 
    2541fi 
    2642 
    27 if [ "$USERHOMEDIR" = '/' ] ; then 
    28   echo "Bad USERHOMEDIR = /" 
    29   exit 1 
    30 fi 
     43echo "Encrypting ${USERHOMEDIR}" 
    3144 
    32 echo "Encrypting ${USERHOMEDIR}" 
    33 #umount ${USERHOMEDIR} 2>/dev/null 
    34  
    35 tar cvf /usr/home/.USER.$$ -C ${USERHOMEDIR} . 2>/dev/null 
    36 rm -rf ${USERHOMEDIR}/* 
     45mkdir ${USERHOMEDIR}.$$ 
     46tar cvf - -C "${USERHOMEDIR}" . 2>/dev/null | tar xvpf - -C "${USERHOMEDIR}.$$" 2>/dev/null 
     47rm -rf ${USERHOMEDIR}/* 2>/dev/null 
     48rm -rf ${USERHOMEDIR}/.* 2>/dev/null 
    3749chown ${USER}:${USER} ${USERHOMEDIR} 
    3850 
     
    4254 
    4355mv ${USERHOMEDIR}/.pefs.db /tmp/.pefs.db.$$ 
    44 tar xvf /usr/home/.USER.$$ -C ${USERHOMEDIR} 2>/dev/null 
    45 sync 
    46 chown -R ${USER}:${USER} ${USERHOMEDIR} 
     56tar cvf - -C "${USERHOMEDIR}.$$" . 2>/dev/null | tar xvpf - -C "${USERHOMEDIR}" 2>/dev/null 
    4757 
    4858umount ${USERHOMEDIR} 
     
    5262 
    5363pefs mount ${USERHOMEDIR} ${USERHOMEDIR} 
    54 rm /usr/home/.USER.$$  
     64rm -rf "${USERHOMEDIR}.$$" 
     65 
    5566 
    5667# Make sure the DBDIR exists 
     
    6576fi 
    6677 
     78# Copy /etc/pam.d/ template files 
     79cp /usr/local/share/pcbsd/pefs/other /etc/pam.d/other 
     80cp /usr/local/share/pcbsd/pefs/system /etc/pam.d/system 
Note: See TracChangeset for help on using the changeset viewer.