3
3
# This script will be run by 'mkinitramfs' when it creates the image.
4
4
# Its job is to decide which files to install, then install them into
5
5
# the staging area, where the initramfs is being created. This
6
# happens when a new 'linux-image' package is installed, or when the
6
# happens when a new 'linux-image' package is installed, or when an
7
7
# administrator runs 'update-initramfs' by hand to update an initramfs
60
68
CONFDIR="/conf/conf.d/mandos"
61
69
MANDOSDIR="/lib/mandos"
62
70
PLUGINDIR="${MANDOSDIR}/plugins.d"
71
HOOKDIR="${MANDOSDIR}/network-hooks.d"
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}"
68
79
# Copy the Mandos plugin runner
69
80
copy_exec "$prefix"/lib/mandos/plugin-runner "${MANDOSDIR}"
88
100
for file in /etc/mandos/plugins.d/*; do
89
101
base="`basename \"$file\"`"
91
*~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
93
*) copy_exec "$file" "${PLUGINDIR}";;
97
# GPGME needs /usr/bin/gpg
98
if ! [ -e "${DESTDIR}/usr/bin/gpg" ] \
99
&& [ -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* 2>/dev/null`" ]; then
100
copy_exec /usr/bin/gpg
103
# Config files and key files
104
for file in /etc/mandos/* "$keydir"/*; do
105
if [ -d "$file" ]; then
108
cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
103
*~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
106
*) copy_exec "$file" "${PLUGINDIR}" ;;
110
# Get DEVICE from initramfs.conf and other files
111
. /etc/initramfs-tools/initramfs.conf
112
for conf in /etc/initramfs-tools/conf.d/*; do
113
if [ -n `basename \"$conf\" | grep '^[[:alnum:]][[:alnum:]\._-]*$' \
114
| grep -v '\.dpkg-.*$'` ]; then
115
[ -f ${conf} ] && . ${conf}
121
for hook in /etc/mandos/network-hooks.d/*; do
122
case "`basename \"$hook\"`" in
124
*[!A-Za-z0-9_.-]*) continue ;;
125
*) test -d "$hook" || copy_exec "$hook" "${HOOKDIR}" ;;
127
if [ -x "$hook" ]; then
128
# Copy any files needed by the network hook
129
MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=files \
130
VERBOSITY=0 "$hook" files | while read file target; do
131
if [ ! -e "${file}" ]; then
132
echo "WARNING: file ${file} not found, requested by Mandos network hook '${hook##*/}'" >&2
134
if [ -z "${target}" ]; then
137
copy_exec "$file" "$target"
140
# Copy and load any modules needed by the network hook
141
MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=modules \
142
VERBOSITY=0 "$hook" modules | while read module; do
143
if [ -z "${target}" ]; then
151
libgpgme11_version="`dpkg-query --showformat='${Version}' --show libgpgme11`"
152
if dpkg --compare-versions "$libgpgme11_version" ge 1.4.1-0.1; then
157
if [ ! -e "${DESTDIR}$gpg" ]; then
161
unset libgpgme11_version
164
for file in /etc/mandos/plugin-runner.conf; do
165
if [ -d "$file" ]; then
168
cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
171
if [ ${mandos_user} != 65534 ]; then
172
sed --in-place --expression="1i--userid=${mandos_user}" \
173
"${DESTDIR}${CONFDIR}/plugin-runner.conf"
176
if [ ${mandos_group} != 65534 ]; then
177
sed --in-place --expression="1i--groupid=${mandos_group}" \
178
"${DESTDIR}${CONFDIR}/plugin-runner.conf"
182
for file in "$keydir"/*; do
183
if [ -d "$file" ]; then
186
cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
187
chown ${mandos_user}:${mandos_group} \
188
"${DESTDIR}${CONFDIR}/`basename \"$file\"`"
111
191
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
120
200
# condition. This umask is set by "initramfs-tools-hook-conf",
121
201
# installed as "/usr/share/initramfs-tools/conf-hooks.d/mandos".)
123
for full in "${PLUGINDIR}" "${CONFDIR}"; do
203
for full in "${MANDOSDIR}" "${CONFDIR}"; do
124
204
while [ "$full" != "/" ]; do
125
205
chmod a+rX "${DESTDIR}$full"
126
206
full="`dirname \"$full\"`"
134
214
chmod a+rX "${DESTDIR}$dir"
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
217
for dir in "${DESTDIR}"/lib* "${DESTDIR}"/usr/lib*; do
218
if [ -d "$dir" ]; then
219
find "$dir" \! -perm -u+rw,g+r -prune -or -print0 \
220
| xargs --null --no-run-if-empty chmod a+rX