/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to initramfs-tools-hook

  • Committer: Teddy Hogeborn
  • Date: 2008-09-04 07:44:49 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080904074449-pk6vtwo9fp3lq62i
* README: Improved spelling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
. /usr/share/initramfs-tools/hook-functions
31
31
 
32
 
for d in /usr /usr/local; do
33
 
    if [ -d "$d"/lib/mandos ]; then
34
 
        prefix="$d"
35
 
        break
36
 
    fi
37
 
done
38
 
if [ -z "$prefix" ]; then
 
32
if [ -d /usr/lib/mandos ]; then
 
33
    prefix=/usr
 
34
elif [ -d /usr/local/lib/mandos ]; then
 
35
    prefix=/usr/local
 
36
else
39
37
    # Mandos not found
40
38
    exit 1
41
39
fi
42
40
 
43
 
for d in /etc/keys/mandos /usr/local/lib/mandos/keys; do
44
 
    if [ -d "$d" ]; then
45
 
        keydir="$d"
46
 
        break
47
 
    fi
48
 
done
49
 
if [ -z "$keydir" ]; then
50
 
    # Mandos key directory not found
51
 
    exit 1
52
 
fi
53
 
 
54
41
# The Mandos network client uses the network
55
42
auto_add_modules net
56
43
# The Mandos network client uses IPv6
66
53
mkdir --parents "${DESTDIR}${PLUGINDIR}"
67
54
 
68
55
# Copy the Mandos plugin runner
69
 
copy_exec "$prefix"/lib/mandos/plugin-runner "${MANDOSDIR}"
 
56
copy_exec "$prefix"/lib/mandos/plugin-runner "${DESTDIR}${MANDOSDIR}"
70
57
 
71
58
# Copy the plugins
72
59
 
79
66
    fi
80
67
    case "$base" in
81
68
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
82
 
        "*") :;;
83
69
        *) copy_exec "$file" "${PLUGINDIR}";;
84
70
    esac
85
71
done
88
74
for file in /etc/mandos/plugins.d/*; do
89
75
    base="`basename \"$file\"`"
90
76
    case "$base" in
91
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
92
 
        "*") :;;
 
77
        *~|.*|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
93
78
        *) copy_exec "$file" "${PLUGINDIR}";;
94
79
    esac
95
80
done
100
85
    copy_exec /usr/bin/gpg
101
86
fi
102
87
 
103
 
# Config files and key files 
104
 
for file in /etc/mandos/* "$keydir"/*; do
 
88
# Key files
 
89
for file in /etc/mandos/*; do
105
90
    if [ -d "$file" ]; then
106
91
        continue
107
92
    fi
108
93
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
109
94
done
 
95
# Create key ring files
 
96
gpg --no-random-seed-file --quiet --batch --no-tty --armor \
 
97
    --no-default-keyring --no-options --enable-dsa2 \
 
98
    --homedir "${DESTDIR}${CONFDIR}" --no-permission-warning \
 
99
    --trust-model always --import-options import-minimal \
 
100
    --import "${DESTDIR}${CONFDIR}/seckey.txt"
 
101
chown nobody "${DESTDIR}${CONFDIR}/secring.gpg"
110
102
 
111
103
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
112
104
# its plugin directory and its config file.  However, since almost all
130
122
# Reset some other things to sane permissions which we have
131
123
# inadvertently affected with our umask setting.
132
124
for dir in / /bin /etc /keyscripts /sbin /scripts /usr /usr/bin; do
133
 
    if [ -d "${DESTDIR}$dir" ]; then
134
 
        chmod a+rX "${DESTDIR}$dir"
135
 
    fi
 
125
    chmod a+rX "${DESTDIR}$dir"
136
126
done
137
127
for dir in /lib /usr/lib; do
138
 
    find "${DESTDIR}$dir" \! -perm /u+rw,g+r -prune -o -print0 \
139
 
        | xargs --null --no-run-if-empty chmod a+rX
 
128
    chmod --recursive a+rX "${DESTDIR}$dir"
140
129
done