#!/bin/sh

if [ -z "$1" ]; then
	echo Usage: cfssh directory
	exit
fi
export PS1="crypto:`basename $1`$ "
set -- $1 `dd if=/dev/urandom bs=8 count=1 2>/dev/null | od -D`
D=.$3.$4
cfs_attach $1 $D || exit 1
echo "Directory is /crypt/$D"
cd /crypt/$D
D="                    "
CWD=`/bin/pwd`
D=`basename $CWD`
PWD=$CWD
export RANDOM=0
exec /bin/sh -c "$SHELL ; cfs_detach $D"
