/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: 2014-06-15 02:48:49 UTC
  • Revision ID: teddy@recompile.se-20140615024849-68x3q8g4yzadl33s
mandos: New "--no-zeroconf" option.  Also make "--socket=0" work.

* mandos (main): New "--no-zeroconf" option.  Also do not interpret
                 socket=0 as no socket.
* mandos-options.xml (zeroconf): New.
* mandos.conf (socket, zeroconf): New.
* mandos.xml (SYNOPSIS, OPTIONS): Added "--no-zeroconf".

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
CONFDIR="/conf/conf.d/mandos"
71
71
MANDOSDIR="/lib/mandos"
72
72
PLUGINDIR="${MANDOSDIR}/plugins.d"
73
 
PLUGINHELPERDIR="${MANDOSDIR}/plugin-helpers"
74
73
HOOKDIR="${MANDOSDIR}/network-hooks.d"
75
74
 
76
75
# Make directories
77
76
install --directory --mode=u=rwx,go=rx "${DESTDIR}${CONFDIR}" \
78
77
        "${DESTDIR}${MANDOSDIR}" "${DESTDIR}${HOOKDIR}"
79
78
install --owner=${mandos_user} --group=${mandos_group} --directory \
80
 
        --mode=u=rwx "${DESTDIR}${PLUGINDIR}" \
81
 
        "${DESTDIR}${PLUGINHELPERDIR}"
82
 
 
83
 
copy_exec "$libdir"/mandos/mandos-to-cryptroot-unlock "${MANDOSDIR}"
 
79
    --mode=u=rwx "${DESTDIR}${PLUGINDIR}"
84
80
 
85
81
# Copy the Mandos plugin runner
86
82
copy_exec "$libdir"/mandos/plugin-runner "${MANDOSDIR}"
102
98
    esac
103
99
done
104
100
 
105
 
# Copy the packaged plugin helpers
106
 
for file in "$libdir"/mandos/plugin-helpers/*; do
107
 
    base="`basename \"$file\"`"
108
 
    # Is this plugin overridden?
109
 
    if [ -e "/etc/mandos/plugin-helpers/$base" ]; then
110
 
        continue
111
 
    fi
112
 
    case "$base" in
113
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
114
 
            : ;;
115
 
        "*") : ;;
116
 
        *) copy_exec "$file" "${PLUGINHELPERDIR}" ;;
117
 
    esac
118
 
done
119
 
 
120
101
# Copy any user-supplied plugins
121
102
for file in /etc/mandos/plugins.d/*; do
122
103
    base="`basename \"$file\"`"
128
109
    esac
129
110
done
130
111
 
131
 
# Copy any user-supplied plugin helpers
132
 
for file in /etc/mandos/plugin-helpers/*; do
133
 
    base="`basename \"$file\"`"
134
 
    case "$base" in
135
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
136
 
            : ;;
137
 
        "*") : ;;
138
 
        *) copy_exec "$file" "${PLUGINHELPERDIR}" ;;
139
 
    esac
140
 
done
141
 
 
142
112
# Get DEVICE from initramfs.conf and other files
143
113
. /etc/initramfs-tools/initramfs.conf
144
114
for conf in /etc/initramfs-tools/conf.d/*; do
145
 
    if [ -n "`basename \"$conf\" \
146
 
        | grep '^[[:alnum:]][[:alnum:]\._-]*$' \
147
 
        | grep -v '\.dpkg-.*$'`" ]; then
148
 
        [ -f "${conf}" ] && . "${conf}"
 
115
    if [ -n `basename \"$conf\" | grep '^[[:alnum:]][[:alnum:]\._-]*$' \
 
116
        | grep -v '\.dpkg-.*$'` ]; then
 
117
        [ -f ${conf} ] && . ${conf}
149
118
    fi
150
119
done
151
120
export DEVICE
160
129
    if [ -x "$hook" ]; then
161
130
        # Copy any files needed by the network hook
162
131
        MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=files \
163
 
            VERBOSITY=0 "$hook" files | while read -r file target; do
 
132
            VERBOSITY=0 "$hook" files | while read file target; do
164
133
            if [ ! -e "${file}" ]; then
165
134
                echo "WARNING: file ${file} not found, requested by Mandos network hook '${hook##*/}'" >&2
166
135
            fi
172
141
        done
173
142
        # Copy and load any modules needed by the network hook
174
143
        MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=modules \
175
 
            VERBOSITY=0 "$hook" modules | while read -r module; do
176
 
            force_load "$module"
 
144
            VERBOSITY=0 "$hook" modules | while read module; do
 
145
            if [ -z "${target}" ]; then
 
146
                force_load "$module"
 
147
            fi
177
148
        done
178
149
    fi
179
150
done
180
151
 
181
152
# GPGME needs GnuPG
182
 
gpg=/usr/bin/gpg
183
153
libgpgme11_version="`dpkg-query --showformat='${Version}' --show libgpgme11`"
184
 
if dpkg --compare-versions "$libgpgme11_version" ge 1.5.0-0.1; then
185
 
    if [ -e /usr/bin/gpgconf ]; then
186
 
        if [ ! -e "${DESTDIR}/usr/bin/gpgconf" ]; then
187
 
            copy_exec /usr/bin/gpgconf
188
 
        fi
189
 
        gpg="`/usr/bin/gpgconf|sed --quiet --expression='s/^gpg:[^:]*://p'`"
190
 
        gpgagent="`/usr/bin/gpgconf|sed --quiet --expression='s/^gpg-agent:[^:]*://p'`"
191
 
        # Newer versions of GnuPG 2 requires the gpg-agent binary
192
 
        if [ -e "$gpgagent" ] && [ ! -e "${DESTDIR}$gpgagent" ]; then
193
 
            copy_exec "$gpgagent"
194
 
        fi
195
 
    fi
196
 
elif dpkg --compare-versions "$libgpgme11_version" ge 1.4.1-0.1; then
 
154
if dpkg --compare-versions "$libgpgme11_version" ge 1.4.1-0.1; then
197
155
    gpg=/usr/bin/gpg2
 
156
else
 
157
    gpg=/usr/bin/gpg
198
158
fi
199
159
if [ ! -e "${DESTDIR}$gpg" ]; then
200
160
    copy_exec "$gpg"
225
185
    if [ -d "$file" ]; then
226
186
        continue
227
187
    fi
228
 
    case "$file" in
229
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
230
 
            : ;;
231
 
        "*") : ;;
232
 
        *)
233
 
            cp --archive --sparse=always "$file" \
234
 
               "${DESTDIR}${CONFDIR}"
235
 
            chown ${mandos_user}:${mandos_group} \
236
 
                  "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
237
 
            ;;
238
 
    esac
 
188
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
189
    chown ${mandos_user}:${mandos_group} \
 
190
        "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
239
191
done
240
 
# Use Diffie-Hellman parameters file if available
241
 
if [ -e "${DESTDIR}${CONFDIR}"/dhparams.pem ]; then
242
 
    sed --in-place \
243
 
        --expression="1i--options-for=mandos-client:--dh-params=${CONFDIR}/dhparams.pem" \
244
 
        "${DESTDIR}/${CONFDIR}/plugin-runner.conf"
245
 
fi
246
192
 
247
193
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
248
194
# its plugin directory and its config file.  However, since almost all
253
199
# initrd; it is intended to affect the initrd.img file itself, since
254
200
# it now contains secret key files.  There is, however, no other way
255
201
# to set the permission of the initrd.img file without a race
256
 
# condition.  This umask is set by "initramfs-tools-conf", installed
257
 
# as "/usr/share/initramfs-tools/conf.d/mandos-conf".)
 
202
# condition.  This umask is set by "initramfs-tools-hook-conf",
 
203
# installed as "/usr/share/initramfs-tools/conf-hooks.d/mandos".)
258
204
259
205
for full in "${MANDOSDIR}" "${CONFDIR}"; do
260
206
    while [ "$full" != "/" ]; do
272
218
done
273
219
for dir in "${DESTDIR}"/lib* "${DESTDIR}"/usr/lib*; do
274
220
    if [ -d "$dir" ]; then
275
 
        find "$dir" \! -perm -u+rw,g+r -prune -or \! -type l -print0 \
276
 
            | xargs --null --no-run-if-empty chmod a+rX --
 
221
        find "$dir" \! -perm -u+rw,g+r -prune -or -print0 \
 
222
            | xargs --null --no-run-if-empty chmod a+rX
277
223
    fi
278
224
done