bzr branch
http://bzr.recompile.se/loggerhead/mandos/trunk
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
1 |
#!/bin/sh
|
2 |
||
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
3 |
# This script will be run by 'mkinitramfs' when it creates the image.
|
4 |
# Its job is to decide which files to install, then install them into
|
|
5 |
# the staging area, where the initramfs is being created. This
|
|
6 |
# happens when a new 'linux-image' package is installed, or when the
|
|
7 |
# administrator runs 'update-initramfs' by hand to update an initramfs
|
|
8 |
# image.
|
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
9 |
|
10 |
# The environment contains at least:
|
|
11 |
#
|
|
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
12 |
# DESTDIR -- The staging directory where the image is being built.
|
13 |
||
14 |
# No initramfs pre-requirements
|
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
15 |
PREREQ="cryptroot" |
16 |
||
17 |
prereqs()
|
|
18 |
{
|
|
19 |
echo "$PREREQ" |
|
20 |
}
|
|
21 |
||
22 |
case $1 in |
|
23 |
# get pre-requisites
|
|
24 |
prereqs)
|
|
25 |
prereqs
|
|
26 |
exit 0 |
|
27 |
;; |
|
28 |
esac
|
|
29 |
||
30 |
. /usr/share/initramfs-tools/hook-functions
|
|
31 |
||
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
32 |
if [ -d /usr/lib/mandos ]; then |
33 |
prefix=/usr |
|
34 |
elif [ -d /usr/local/lib/mandos ]; then |
|
35 |
prefix=/usr/local |
|
36 |
else
|
|
37 |
# Mandos not found |
|
38 |
exit 1 |
|
39 |
fi
|
|
40 |
||
41 |
# The Mandos network client uses the network
|
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
42 |
auto_add_modules net
|
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
43 |
# The Mandos network client uses IPv6
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
44 |
force_load ipv6
|
45 |
||
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
46 |
# These are directories inside the initrd
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
47 |
CONFDIR="/conf/conf.d/mandos" |
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
48 |
MANDOSDIR="/lib/mandos" |
49 |
PLUGINDIR="${MANDOSDIR}/plugins.d" |
|
50 |
||
51 |
# Make directories
|
|
52 |
mkdir --parents "${DESTDIR}${CONFDIR}" |
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
53 |
mkdir --parents "${DESTDIR}${PLUGINDIR}" |
54 |
||
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
55 |
# Copy the Mandos plugin runner
|
56 |
copy_exec "$prefix"/lib/mandos/plugin-runner "${DESTDIR}${MANDOSDIR}" |
|
57 |
||
58 |
# Copy the plugins
|
|
59 |
||
60 |
# Copy the packaged plugins
|
|
61 |
for file in "$prefix"/lib/mandos/plugins.d/*; do |
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
62 |
base="`basename \"$file\"`" |
63 |
# Is this plugin overridden? |
|
64 |
if [ -e "/etc/mandos/plugins.d/$base" ]; then |
|
65 |
continue |
|
66 |
fi |
|
67 |
case "$base" in |
|
68 |
*~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;; |
|
69 |
*) copy_exec "$file" "${PLUGINDIR}";; |
|
70 |
esac |
|
71 |
done
|
|
72 |
||
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
73 |
# Copy any user-supplied plugins
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
74 |
for file in /etc/mandos/plugins.d/*; do |
75 |
base="`basename \"$file\"`" |
|
76 |
case "$base" in |
|
77 |
*~|.*|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;; |
|
78 |
*) copy_exec "$file" "${PLUGINDIR}";; |
|
79 |
esac |
|
80 |
done
|
|
81 |
||
82 |
# GPGME needs /usr/bin/gpg
|
|
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
83 |
if ! [ -e "${DESTDIR}/usr/bin/gpg" ] \ |
84 |
&& [ -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* 2>/dev/null`" ]; then |
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
85 |
copy_exec /usr/bin/gpg |
86 |
fi
|
|
87 |
||
88 |
# Key files
|
|
89 |
for file in /etc/mandos/*; do |
|
90 |
if [ -d "$file" ]; then |
|
91 |
continue |
|
92 |
fi |
|
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
93 |
cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}" |
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
94 |
done
|
95 |
# Create key ring files
|
|
101
by Teddy Hogeborn
* initramfs-tools-hook: Added "--enable-dsa2" and "--trust-model |
96 |
gpg --no-random-seed-file --quiet --batch --no-tty --armor \ |
97 |
--no-default-keyring --no-options --enable-dsa2 \ |
|
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
98 |
--homedir "${DESTDIR}${CONFDIR}" --no-permission-warning \ |
101
by Teddy Hogeborn
* initramfs-tools-hook: Added "--enable-dsa2" and "--trust-model |
99 |
--trust-model always --import-options import-minimal \ |
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
100 |
--import "${DESTDIR}${CONFDIR}/seckey.txt" |
101 |
chown nobody "${DESTDIR}${CONFDIR}/secring.gpg" |
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
102 |
|
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
103 |
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
|
104 |
# its plugin directory and its config file. However, since almost all
|
|
105 |
# files in initrd have been created with umask 027, this opening of
|
|
106 |
# permissions is needed.
|
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
107 |
#
|
108 |
# (The umask is not really intended to affect the files inside the
|
|
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
109 |
# initrd; it is intended to affect the initrd.img file itself, since
|
110 |
# it now contains secret key files. There is, however, no other way
|
|
111 |
# to set the permission of the initrd.img file without a race
|
|
112 |
# condition. This umask is set by "initramfs-tools-hook-conf",
|
|
113 |
# installed as "/usr/share/initramfs-tools/conf-hooks.d/mandos".)
|
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
114 |
#
|
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
115 |
for full in "${PLUGINDIR}" "${CONFDIR}"; do |
116 |
while [ "$full" != "/" ]; do |
|
117 |
chmod a+rX "${DESTDIR}$full" |
|
118 |
full="`dirname \"$full\"`" |
|
119 |
done |
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
120 |
done
|
74
by Teddy Hogeborn
* Makefile (PREFIX, CONFDIR): New. |
121 |
|
122 |
# Reset some other things to sane permissions which we have
|
|
123 |
# inadvertently affected with our umask setting.
|
|
68
by Teddy Hogeborn
* initramfs-tools-hook: New. |
124 |
for dir in / /bin /etc /keyscripts /sbin /scripts /usr /usr/bin; do |
125 |
chmod a+rX "${DESTDIR}$dir" |
|
126 |
done
|
|
127 |
for dir in /lib /usr/lib; do |
|
128 |
chmod --recursive a+rX "${DESTDIR}$dir" |
|
129 |
done
|