~mrooney/ecryptfs/nautilus-integration

« back to all changes in this revision

Viewing changes to debian/ecryptfs-utils.prerm

  • Committer: Dustin Kirkland
  • Date: 2009-02-24 13:48:15 UTC
  • Revision ID: kirkland@canonical.com-20090224134815-0hfibouvf7dzt9wl
prevent removal of ecryptfs-utils package, if in use

debian/ecryptfs-utils.prerm: perform some cursory checks, to ensure that
there are no obvious, current users of ecryptfs before allowing package
removal, Bug #331085

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh -e
2
2
 
3
3
if [ "$1" = remove ]; then
 
4
        # We must do some checking to prevent removal of ecryptfs if in use
 
5
        # Check active mounts
 
6
        if out=`mount | grep "\Wtype\Wecryptfs\W"`; then
 
7
                echo "ERROR: Cannot remove ecryptfs-utils, as it appears to be in use:" 1>&2
 
8
                echo "$out" 1>&2
 
9
                exit 1
 
10
        fi
 
11
        if out=`grep "\Wecryptfs\W" /proc/mounts`; then
 
12
                echo "ERROR: Cannot remove ecryptfs-utils, as it appears to be in use:" 1>&2
 
13
                echo "$out" 1>&2
 
14
                exit 1
 
15
        fi
 
16
        # Check fstab
 
17
        if out=`grep "\Wecryptfs\W" /etc/fstab`; then
 
18
                echo "ERROR: Cannot remove ecryptfs-utils, as it appears to be in use:" 1>&2
 
19
                echo "$out" 1>&2
 
20
                exit 1
 
21
        fi
 
22
        # Check home directories
 
23
        for i in `ls /home`; do
 
24
                if [ -d "/home/$i/.ecryptfs" ]; then
 
25
                        # If we find a .ecryptfs directory (or link) in a home,
 
26
                        # directory, then someone is using ecryptfs-utils, and
 
27
                        # we should not allow package removal
 
28
                        echo "ERROR: Cannot remove ecryptfs-utils, as it appears to be in use:" 1>&2
 
29
                        echo "       [/home/$i/.ecryptfs]" 1>&2
 
30
                        exit 1
 
31
                fi
 
32
        done
4
33
        pam-auth-update --package --remove ecryptfs-utils
5
34
fi
6
35