/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-22 02:19:30 UTC
  • Revision ID: teddy@recompile.se-20140622021930-icl7h4cm97blhjml
mandos-keygen: Generate "checker" option to use SSH fingerprints.

To turn this off, use a new "--no-ssh" option to mandos-keygen.

* INSTALL (Mandos Server, Mandos Client): Document new suggested
                                          installation of SSH.
* Makefile (confdir/clients.conf): Use new "--no-ssh" option to
                                   "mandos-keygen".
* debian/control (mandos/Depends): Changed to "fping | ssh-client".
  (mandos-client/Recommends): New; set to "ssh".
* intro.xml (FREQUENTLY ASKED QUESTIONS): Rename and rewrite section
                                          called "Faking ping
                                          replies?" to address new
                                          default behavior.
* mandos-clients.conf.xml (OPTIONS/checker): Briefly discuss new
                                             behavior of
                                             mandos-keygen.
* mandos-keygen: Bug fix: Suppress failure output of "shred" to remove
                 "sec*", since no such files may exist.
 (password mode): Scan for SSH key fingerprints and output as new
                  "checker" and "ssh_fingerprint" options, unless new
                  "--no-ssh" option is given.
* mandos-keygen.xml (SYNOPSIS/--force): Bug fix: Document short form.
  (OPTIONS/--no-ssh): New.
  (SEE ALSO): Add reference "ssh-keyscan(1)".
* plugins.d/mandos-client.xml (SECURITY): Briefly mention the
                                          possibility of using SSH key
                                          fingerprints for checking.

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
115
    if [ -n `basename \"$conf\" | grep '^[[:alnum:]][[:alnum:]\._-]*$' \
146
116
        | grep -v '\.dpkg-.*$'` ]; then
147
 
        [ -f "${conf}" ] && . "${conf}"
 
117
        [ -f ${conf} ] && . ${conf}
148
118
    fi
149
119
done
150
120
export DEVICE
159
129
    if [ -x "$hook" ]; then
160
130
        # Copy any files needed by the network hook
161
131
        MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=files \
162
 
            VERBOSITY=0 "$hook" files | while read -r file target; do
 
132
            VERBOSITY=0 "$hook" files | while read file target; do
163
133
            if [ ! -e "${file}" ]; then
164
134
                echo "WARNING: file ${file} not found, requested by Mandos network hook '${hook##*/}'" >&2
165
135
            fi
171
141
        done
172
142
        # Copy and load any modules needed by the network hook
173
143
        MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=modules \
174
 
            VERBOSITY=0 "$hook" modules | while read -r module; do
175
 
            force_load "$module"
 
144
            VERBOSITY=0 "$hook" modules | while read module; do
 
145
            if [ -z "${target}" ]; then
 
146
                force_load "$module"
 
147
            fi
176
148
        done
177
149
    fi
178
150
done
179
151
 
180
152
# GPGME needs GnuPG
181
 
gpg=/usr/bin/gpg
182
153
libgpgme11_version="`dpkg-query --showformat='${Version}' --show libgpgme11`"
183
 
if dpkg --compare-versions "$libgpgme11_version" ge 1.5.0-0.1; then
184
 
    if [ -e /usr/bin/gpgconf ]; then
185
 
        if [ ! -e "${DESTDIR}/usr/bin/gpgconf" ]; then
186
 
            copy_exec /usr/bin/gpgconf
187
 
        fi
188
 
        gpg="`/usr/bin/gpgconf|sed --quiet --expression='s/^gpg:[^:]*://p'`"
189
 
        gpgagent="`/usr/bin/gpgconf|sed --quiet --expression='s/^gpg-agent:[^:]*://p'`"
190
 
        # Newer versions of GnuPG 2 requires the gpg-agent binary
191
 
        if [ -e "$gpgagent" ] && [ ! -e "${DESTDIR}$gpgagent" ]; then
192
 
            copy_exec "$gpgagent"
193
 
        fi
194
 
    fi
195
 
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
196
155
    gpg=/usr/bin/gpg2
 
156
else
 
157
    gpg=/usr/bin/gpg
197
158
fi
198
159
if [ ! -e "${DESTDIR}$gpg" ]; then
199
160
    copy_exec "$gpg"
224
185
    if [ -d "$file" ]; then
225
186
        continue
226
187
    fi
227
 
    case "$file" in
228
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
229
 
            : ;;
230
 
        "*") : ;;
231
 
        *)
232
 
            cp --archive --sparse=always "$file" \
233
 
               "${DESTDIR}${CONFDIR}"
234
 
            chown ${mandos_user}:${mandos_group} \
235
 
                  "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
236
 
            ;;
237
 
    esac
 
188
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
189
    chown ${mandos_user}:${mandos_group} \
 
190
        "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
238
191
done
239
 
# Use Diffie-Hellman parameters file if available
240
 
if [ -e "${DESTDIR}${CONFDIR}"/dhparams.pem ]; then
241
 
    sed --in-place \
242
 
        --expression="1i--options-for=mandos-client:--dh-params=${CONFDIR}/dhparams.pem" \
243
 
        "${DESTDIR}/${CONFDIR}/plugin-runner.conf"
244
 
fi
245
192
 
246
193
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
247
194
# its plugin directory and its config file.  However, since almost all
252
199
# initrd; it is intended to affect the initrd.img file itself, since
253
200
# it now contains secret key files.  There is, however, no other way
254
201
# to set the permission of the initrd.img file without a race
255
 
# condition.  This umask is set by "initramfs-tools-conf", installed
256
 
# 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".)
257
204
258
205
for full in "${MANDOSDIR}" "${CONFDIR}"; do
259
206
    while [ "$full" != "/" ]; do
271
218
done
272
219
for dir in "${DESTDIR}"/lib* "${DESTDIR}"/usr/lib*; do
273
220
    if [ -d "$dir" ]; then
274
 
        find "$dir" \! -perm -u+rw,g+r -prune -or \! -type l -print0 \
275
 
            | 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
276
223
    fi
277
224
done