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
10
# The environment contains at least:
12
# DESTDIR -- The staging directory where the image is being built.
14
# No initramfs pre-requirements
30
. /usr/share/initramfs-tools/hook-functions
32
if [ -d /usr/lib/mandos ]; then
34
elif [ -d /usr/local/lib/mandos ]; then
41
# The Mandos network client uses the network
43
# The Mandos network client uses IPv6
46
# These are directories inside the initrd
47
CONFDIR="/conf/conf.d/mandos"
48
MANDOSDIR="/lib/mandos"
49
PLUGINDIR="${MANDOSDIR}/plugins.d"
52
mkdir --parents "${DESTDIR}${CONFDIR}"
53
mkdir --parents "${DESTDIR}${PLUGINDIR}"
55
# Copy the Mandos plugin runner
56
copy_exec "$prefix"/lib/mandos/plugin-runner "${DESTDIR}${MANDOSDIR}"
60
# Copy the packaged plugins
61
for file in "$prefix"/lib/mandos/plugins.d/*; do
62
base="`basename \"$file\"`"
63
# Is this plugin overridden?
64
if [ -e "/etc/mandos/plugins.d/$base" ]; then
68
*~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
69
*) copy_exec "$file" "${PLUGINDIR}";;
73
# Copy any user-supplied plugins
74
for file in /etc/mandos/plugins.d/*; do
75
base="`basename \"$file\"`"
77
*~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
78
*) copy_exec "$file" "${PLUGINDIR}";;
82
# GPGME needs /usr/bin/gpg
83
if ! [ -e "${DESTDIR}/usr/bin/gpg" ] \
84
&& [ -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* 2>/dev/null`" ]; then
85
copy_exec /usr/bin/gpg
88
# Key files and config files
89
for file in /etc/mandos/*; do
90
if [ -d "$file" ]; then
93
cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
96
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
97
# its plugin directory and its config file. However, since almost all
98
# files in initrd have been created with umask 027, this opening of
99
# permissions is needed.
101
# (The umask is not really intended to affect the files inside the
102
# initrd; it is intended to affect the initrd.img file itself, since
103
# it now contains secret key files. There is, however, no other way
104
# to set the permission of the initrd.img file without a race
105
# condition. This umask is set by "initramfs-tools-hook-conf",
106
# installed as "/usr/share/initramfs-tools/conf-hooks.d/mandos".)
108
for full in "${PLUGINDIR}" "${CONFDIR}"; do
109
while [ "$full" != "/" ]; do
110
chmod a+rX "${DESTDIR}$full"
111
full="`dirname \"$full\"`"
115
# Reset some other things to sane permissions which we have
116
# inadvertently affected with our umask setting.
117
for dir in / /bin /etc /keyscripts /sbin /scripts /usr /usr/bin; do
118
chmod a+rX "${DESTDIR}$dir"
120
for dir in /lib /usr/lib; do
121
find "${DESTDIR}$dir" \! -perm /u+rw,g+r -prune -o -print0 \
122
| xargs --null chmod a+rX