/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

* network-hooks.d/bridge: Bug fix - really find brctl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    exit 1
41
41
fi
42
42
 
43
 
for d in /etc/keys/mandos /usr/local/lib/mandos/keys; do
 
43
for d in /etc/keys/mandos /etc/mandos/keys; do
44
44
    if [ -d "$d" ]; then
45
45
        keydir="$d"
46
46
        break
51
51
    exit 1
52
52
fi
53
53
 
 
54
set `{ getent passwd _mandos \
 
55
    || getent passwd nobody \
 
56
    || echo ::65534:65534:::; } \
 
57
    | cut --delimiter=: --fields=3,4 --only-delimited \
 
58
    --output-delimiter=" "`
 
59
mandos_user="$1"
 
60
mandos_group="$2"
 
61
 
54
62
# The Mandos network client uses the network
55
63
auto_add_modules net
56
64
# The Mandos network client uses IPv6
60
68
CONFDIR="/conf/conf.d/mandos"
61
69
MANDOSDIR="/lib/mandos"
62
70
PLUGINDIR="${MANDOSDIR}/plugins.d"
 
71
HOOKDIR="${MANDOSDIR}/network-hooks.d"
63
72
 
64
73
# Make directories
65
 
mkdir --parents "${DESTDIR}${CONFDIR}"
66
 
mkdir --parents "${DESTDIR}${PLUGINDIR}"
 
74
install --directory --mode=u=rwx,go=rx "${DESTDIR}${CONFDIR}" \
 
75
        "${DESTDIR}${MANDOSDIR}" "${DESTDIR}${HOOKDIR}"
 
76
install --owner=${mandos_user} --group=${mandos_group} --directory \
 
77
    --mode=u=rwx "${DESTDIR}${PLUGINDIR}"
67
78
 
68
79
# Copy the Mandos plugin runner
69
80
copy_exec "$prefix"/lib/mandos/plugin-runner "${MANDOSDIR}"
78
89
        continue
79
90
    fi
80
91
    case "$base" in
81
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
82
 
        "*") :;;
83
 
        *) copy_exec "$file" "${PLUGINDIR}";;
 
92
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
 
93
            : ;;
 
94
        "*") echo "W: Mandos client plugin directory is empty." >&2 ;;
 
95
        *) copy_exec "$file" "${PLUGINDIR}" ;;
84
96
    esac
85
97
done
86
98
 
88
100
for file in /etc/mandos/plugins.d/*; do
89
101
    base="`basename \"$file\"`"
90
102
    case "$base" in
91
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
92
 
        "*") :;;
93
 
        *) copy_exec "$file" "${PLUGINDIR}";;
94
 
    esac
 
103
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
 
104
            : ;;
 
105
        "*") : ;;
 
106
        *) copy_exec "$file" "${PLUGINDIR}" ;;
 
107
    esac
 
108
done
 
109
 
 
110
# Copy network hooks
 
111
for hook in /etc/mandos/network-hooks.d/*; do
 
112
    case "`basename \"$hook\"`" in
 
113
        "*") continue ;;
 
114
        *[!A-Za-z0-9_.-]*) continue ;;
 
115
        *) test -d "$hook" || copy_exec "$hook" "${HOOKDIR}" ;;
 
116
    esac
 
117
    if [ -x "$hook" ]; then
 
118
        # Copy any files needed by the network hook
 
119
        MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=files \
 
120
            VERBOSITY=0 "$hook" files | while read file target; do
 
121
            if [ ! -e "${file}" ]; then
 
122
                echo "WARNING: file ${file} not found, requested by Mandos network hook '${hook##*/}'" >&2
 
123
            fi
 
124
            if [ -z "${target}" ]; then
 
125
                copy_exec "$file"
 
126
            else
 
127
                copy_exec "$file" "$target"
 
128
            fi
 
129
        done
 
130
        # Copy and load any modules needed by the network hook
 
131
        MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=modules \
 
132
            VERBOSITY=0 "$hook" modules | while read module; do
 
133
            if [ -z "${target}" ]; then
 
134
                force_load "$module"
 
135
            fi
 
136
        done
 
137
    fi
95
138
done
96
139
 
97
140
# GPGME needs /usr/bin/gpg
98
 
if ! [ -e "${DESTDIR}/usr/bin/gpg" ] \
99
 
    && [ -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* 2>/dev/null`" ]; then
 
141
if [ ! -e "${DESTDIR}/usr/bin/gpg" \
 
142
    -a -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* \
 
143
                2>/dev/null`" ]; then
100
144
    copy_exec /usr/bin/gpg
101
145
fi
102
146
 
103
 
# Config files and key files 
104
 
for file in /etc/mandos/* "$keydir"/*; do
105
 
    if [ -d "$file" ]; then
106
 
        continue
107
 
    fi
108
 
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
147
# Config files
 
148
for file in /etc/mandos/plugin-runner.conf; do
 
149
    if [ -d "$file" ]; then
 
150
        continue
 
151
    fi
 
152
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
153
done
 
154
 
 
155
if [ ${mandos_user} != 65534 ]; then
 
156
    sed --in-place --expression="1i--userid=${mandos_user}" \
 
157
        "${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
158
fi
 
159
 
 
160
if [ ${mandos_group} != 65534 ]; then
 
161
    sed --in-place --expression="1i--groupid=${mandos_group}" \
 
162
        "${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
163
fi
 
164
 
 
165
# Key files
 
166
for file in "$keydir"/*; do
 
167
    if [ -d "$file" ]; then
 
168
        continue
 
169
    fi
 
170
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
171
    chown ${mandos_user}:${mandos_group} \
 
172
        "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
109
173
done
110
174
 
111
175
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
120
184
# condition.  This umask is set by "initramfs-tools-hook-conf",
121
185
# installed as "/usr/share/initramfs-tools/conf-hooks.d/mandos".)
122
186
123
 
for full in "${PLUGINDIR}" "${CONFDIR}"; do
 
187
for full in "${MANDOSDIR}" "${CONFDIR}"; do
124
188
    while [ "$full" != "/" ]; do
125
189
        chmod a+rX "${DESTDIR}$full"
126
190
        full="`dirname \"$full\"`"
134
198
        chmod a+rX "${DESTDIR}$dir"
135
199
    fi
136
200
done
137
 
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
 
201
for dir in "${DESTDIR}"/lib* "${DESTDIR}"/usr/lib*; do
 
202
    if [ -d "$dir" ]; then
 
203
        find "$dir" \! -perm -u+rw,g+r -prune -or -print0 \
 
204
            | xargs --null --no-run-if-empty chmod a+rX
 
205
    fi
140
206
done