summaryrefslogtreecommitdiff
blob: 8f6dd386237b219282a404c6264eecf19cecfe42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/sbin/runscript
#
# bestcrypt         Encrypted File Systems.
#
# Version:      1.2
#
# Revision:    $Id$
#
# Author:       Jetico Inc. (support@jetico.com)
#
# Modified by Stefan Tittel (with thanks to steveb) to work around
# the "xargs: environment too large for exec"-error occuring in
# the gentoo 1.4 linux distribution.

# chkconfig: 2345 85 98
# description: BestCrypt init script


# Source function library.
#. /etc/rc.d/init.d/functions

# See how we were called.

KERNEL_VERSION=`uname -r|sed 's/\(.\..\).*/\1/'`

start() {
	ebegin "Initializing BestCrypt"
	declare -i status=0
	rm -rf /dev/bcrypt?* 2>/dev/null
        if [ $KERNEL_VERSION = "2.2" ]; then
         mknod -m 666 /dev/bcrypt0 b 7 128
         mknod -m 666 /dev/bcrypt1 b 7 129
         mknod -m 666 /dev/bcrypt2 b 7 130
         mknod -m 666 /dev/bcrypt3 b 7 131
         mknod -m 666 /dev/bcrypt4 b 7 132
         mknod -m 666 /dev/bcrypt5 b 7 133
         mknod -m 666 /dev/bcrypt6 b 7 134
         mknod -m 666 /dev/bcrypt7 b 7 135
         mknod -m 666 /dev/bcrypt8 b 7 136
         mknod -m 666 /dev/bcrypt9 b 7 137
         mknod -m 666 /dev/bcrypt10 b 7 138
         mknod -m 666 /dev/bcrypt11 b 7 139
         mknod -m 666 /dev/bcrypt12 b 7 140
         mknod -m 666 /dev/bcrypt13 b 7 141
         mknod -m 666 /dev/bcrypt14 b 7 142
         mknod -m 666 /dev/bcrypt15 b 7 143
        else
	  if [ ! -c /dev/.devfsd ] && [ ! -e /dev/.udev ];
	  then
            mknod -m 666 /dev/bcrypt0 b 188 0
            mknod -m 666 /dev/bcrypt1 b 188 1
            mknod -m 666 /dev/bcrypt2 b 188 2
            mknod -m 666 /dev/bcrypt3 b 188 3
            mknod -m 666 /dev/bcrypt4 b 188 4
            mknod -m 666 /dev/bcrypt5 b 188 5
            mknod -m 666 /dev/bcrypt6 b 188 6
            mknod -m 666 /dev/bcrypt7 b 188 7
            mknod -m 666 /dev/bcrypt8 b 188 8
            mknod -m 666 /dev/bcrypt9 b 188 9
            mknod -m 666 /dev/bcrypt10 b 188 10
            mknod -m 666 /dev/bcrypt11 b 188 11
            mknod -m 666 /dev/bcrypt12 b 188 12
            mknod -m 666 /dev/bcrypt13 b 188 13
            mknod -m 666 /dev/bcrypt14 b 188 14
            mknod -m 666 /dev/bcrypt15 b 188 15
          fi
	fi
	modprobe bc || status=1
	modprobe bc_blowfish || status=1
	modprobe bc_des || status=1
	modprobe bc_gost || status=1
	modprobe bc_twofish || status=1
	modprobe bc_bf448 || status=1
	modprobe bc_bf128 || status=1
	modprobe bc_3des || status=1
	modprobe bc_idea || status=1
	modprobe bc_rijn || status=1
	modprobe bc_cast || status=1
	modprobe bc_rc6 || status=1
	modprobe bc_serpent || status=1
	eend ${status}
}

stop() {
	ebegin "Unmounting encrypted filesystems"

# The original line causing the "xargs: environment too large for exec error".	
	# grep BestCrypt /etc/mtab |awk '{print $2}'|xargs -r -n 1 bctool umount

# The line for which it work's fine now.
	for i in $(grep BestCrypt /etc/mtab | awk '{print $2}') ; do bctool umount ${i} ; done

	eend $?
	ebegin "Shutting down BestCrypt modules"
	for i in `lsmod |egrep "^bc_.*" |awk '{print $1}' `; do 
		rmmod $i
	done
	if [ ! -c /dev/.devfsd ] && [ ! -e /dev/.udev ];
	then
		rm -f /dev/bcrypt?* 2>/dev/null
	fi
	rmmod bc
	eend $?
}