Friday March 21, 2008 7pm-midnight
Trabant Coffee & Chai
Security Computer Fuzzing Root Vuln Hands-on Hacking

See ya there!
Ian Gallagher

1 #!/bin/bash
2 #
3 # This defines two bash functions to mount and unmount a FUSE EncFS.
4 # You must have setup encfs with $HOME/.encfs/ as the encrypted store,
5 # and $HOME/encfs/ as the mount point prior to this being useful.
6 # Add mount_encfs to a login script, like .bash_login, and umount_encfs
7 # to your .bash_logout script.
8 # The umount_encfs function does some very loose checking to see if it
9 # should unmount the encfs or not. Be sure to manually call umount_encfs
10 # if you can't risk this check failing.
11 # This shall be released AS-IS, author crash@neg9.org
12
13 ENC_STORE="${HOME}/.encfs"
14 ENC_MOUNT="${HOME}/encfs"
15 ENC_STATUS="${HOME}/.encfsmounted"
16
17 function mount_encfs ()
18 {
19 if [ ! -e $ENC_STATUS ]; then
20 echo "nothing mounted" > $ENC_STATUS;
21 fi
22
23 # Check to see if the encfs is already mounted, bail if so
24 ENCFSMOUNTED=$(cat $ENC_STATUS)
25 if [ "${ENCFSMOUNTED}" = "${ENC_MOUNT}" ]; then
26 return;
27 fi;
28
29 # Otherwise, on we go
30 MOUNT="n";
31
32 read -p "Mount encrypted filesystem? [y/N] " MOUNT;
33 if [ "$MOUNT" = "y" -o "$MOUNT" = "Y" ]; then
34 echo "Mounting encrypted filesystem [${ENC_STORE}] on [${ENC_MOUNT}] now..."
35 /usr/bin/encfs $ENC_STORE $ENC_MOUNT;
36 if [ $? -eq 0 ]; then
37 echo "$ENC_MOUNT" > $ENC_STATUS
38 echo "Mounted encrypted filesystem successfully on [${ENC_MOUNT}]";
39 else
40 echo "nothing mounted" > $ENC_STATUS;
41 fi;
42 fi
43
44 return
45 }
46
47 function umount_encfs ()
48 {
49 NINTERACTIVE=$(ls -l /dev/pts/ | grep "^.......... . ${USER}" | wc -l);
50 ENCFSMOUNTED=$(cat $ENC_STATUS)
51 if [ $NINTERACTIVE -le 1 -a "${ENCFSMOUNTED}" = "${ENC_MOUNT}" ]; then
52 /usr/bin/fusermount -u $ENC_MOUNT > /dev/null 2>&1;
53 if [ $? -eq 0 ]; then
54 echo "Unmounted encrypted filesystem [${ENC_STORE}]"
55 echo "nothing mounted" > $ENC_STATUS;
56 else
57 echo "Failed to unmount encrypted filesystem [${ENC_STORE}]";
58 fi;
59 fi
60
61 return
62 }
63
64 function umount_encfs_force ()
65 {
66 /usr/bin/fusermount -u $ENC_MOUNT > /dev/null 2>&1;
67 if [ $? -eq 0 ]; then
68 echo "Unmounted encrypted filesystem [${ENC_STORE}]"
69 echo "nothing mounted" > $ENC_STATUS;
70 else
71 echo "Failed to unmount encrypted filesystem [${ENC_STORE}]";
72 fi;
73
74 return
75 }