4
echo "You must run this script as root. Do not use sudo; either log in"
5
echo "as root or use 'su -'"
7
echo "This script applies to Open Client systems only with the IBM-security-compliance RPM installed"
10
whoami | grep "^root$" &> /dev/null
12
echo "Please run this script as root"
18
echo " # ecryptfs-setup-pam.sh [username] [passphrase] <noninteractive>"
21
if test "x$1" == "x"; then
22
echo "Must provide a username"
27
if test "x$2" == "x"; then
28
echo "Must provide a login passphrase"
33
if test "x$3" == "xnoninteractive"; then
34
echo "Running in non-interactive mode"
37
echo "Running in interactive mode"
42
echo $2 | grep "[;\"\\]"
44
echo "Warning: Using backslashes, quotes, or semicolons in your passphrase"
45
echo "may cause problems."
47
if test $INTERACTIVE == 1; then
48
echo "Hit ENTER to continue, CTRL-C to abort..."
53
echo "Using username [$1]"
54
echo "Using login passphrase [$2]"
56
echo "This script will attempt to set up your system to mount eCryptfs"
57
echo "automatically on login, using your login passphrase."
59
if test $INTERACTIVE == 1; then
60
echo "Hit ENTER to continue, CTRL-C to abort..."
64
echo "This script will now attempt to take the following steps:"
65
echo " * Insert the ecryptfs kernel module"
66
echo " # modprobe ecryptfs"
67
echo " * Create a Confidential directory in the user's home directory"
68
echo " # mkdir /home/$1/Confidential"
69
echo " # chown $1:$1 /home/$1/Confidential"
70
echo " # chmod 700 /home/$1/Confidential"
71
echo " * Perform an eCryptfs mount"
72
echo " # mount -t ecryptfs /home/$1/Confidential /home/$1/Confidential -o key=passphrase:passwd=\"$2\",cipher=aes,ecryptfs_key_bytes=16,passthrough=n,no_sig_cache"
73
echo " * Add an entry to /etc/fstab with the the mount parameters"
74
echo " # grep ecryptfs_sig /etc/mtab | sed 's/ecryptfs_cipher\=aes,ecryptfs_key_bytes\=16/ecryptfs_cipher\=aes,ecryptfs_key_bytes\=16,user,noauto,/' >> /etc/fstab"
75
echo " * Unmount eCryptfs"
76
echo " # umount ecryptfs"
77
echo " * Add pam_ecryptfs to PAM stack"
78
echo " # cat /etc/pam.d/system-auth | sed 's/auth\s*required\s*pam_unix\.so likeauth nullok/auth required pam_unix.so likeauth nullok\nauth required pam_ecryptfs.so/' > /tmp/system-auth"
79
echo " # cp -f /etc/pam.d/system-auth /etc/pam.d/.system-auth-before-pam_ecryptfs"
80
echo " # mv -f /tmp/system-auth /etc/pam.d/system-auth"
81
echo " * Add eCryptfs mount commands to /home/$1/.bash_profile"
82
echo " # cp -f /home/$1/.bash_profile /home/$1/.bash_profile-before-pam_ecryptfs"
83
echo " # echo \"if test -e \$HOME/.ecryptfs/auto-mount; then\" >> /home/$1/.bash_profile"
84
echo " # echo \" mount | grep \\\"\$HOME/Confidential type ecryptfs\\\"\" >> /home/$1/.bash_profile"
85
echo " # echo \" if test \$? != 0; then\" >> /home/$1/.bash_profile"
86
echo " # echo \" mount -i \$HOME/Confidential\" >> /home/$1/.bash_profile"
87
echo " # echo \" fi\" >> /home/$1/.bash_profile"
88
echo " # echo \"fi\" >> /home/$1/.bash_profile"
89
echo " * Turn on automount for the user"
90
echo " # mkdir -p /home/$1/.ecryptfs"
91
echo " # chown $1:$1 /home/$1/.ecryptfs"
92
echo " # touch /home/$1/.ecryptfs/auto-mount"
93
echo " # chown $1:$1 /home/$1/.ecryptfs/auto-mount"
95
echo "If something goes wrong, or if you notice that an operation "
96
echo "listed above will not work on your system, than you will need "
97
echo "to take these steps manually."
99
if test $INTERACTIVE == 1; then
100
echo "Hit ENTER to continue, CTRL-C to abort..."
104
mkdir /home/$1/Confidential
105
chown $1:$1 /home/$1/Confidential
106
chmod 700 /home/$1/Confidential
107
mount -t ecryptfs /home/$1/Confidential /home/$1/Confidential -o key=passphrase:passwd="$2",cipher=aes,ecryptfs_key_bytes=16,passthrough=n,no_sig_cache
108
grep ecryptfs_sig /etc/mtab | sed 's/ecryptfs_cipher\=aes,ecryptfs_key_bytes\=16/ecryptfs_cipher\=aes,ecryptfs_key_bytes\=16,user,noauto,/' >> /etc/fstab
109
umount /home/$1/Confidential
110
cat /etc/pam.d/system-auth | sed 's/auth\s*required\s*pam_unix\.so likeauth nullok/auth required pam_unix.so likeauth nullok\nauth required pam_ecryptfs.so/' > /tmp/system-auth
111
cp -f /etc/pam.d/system-auth /etc/pam.d/.system-auth-before-pam_ecryptfs
112
mv -f /tmp/system-auth /etc/pam.d/system-auth
113
cp -f /home/$1/.bash_profile /home/$1/.bash_profile-before-pam_ecryptfs
114
echo "if test -e \$HOME/.ecryptfs/auto-mount; then" >> /home/$1/.bash_profile
115
echo " mount | grep \"\$HOME/Confidential type ecryptfs\"" >> /home/$1/.bash_profile
116
echo " if test \$? != 0; then" >> /home/$1/.bash_profile
117
echo " mount -i \$HOME/Confidential" >> /home/$1/.bash_profile
118
echo " fi" >> /home/$1/.bash_profile
119
echo "fi" >> /home/$1/.bash_profile
120
mkdir -p /home/$1/.ecryptfs
121
chown $1:$1 /home/$1/.ecryptfs
122
touch /home/$1/.ecryptfs/auto-mount
123
chown $1:$1 /home/$1/.ecryptfs/auto-mount