/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

merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    exit 1
41
41
fi
42
42
 
43
 
for d in /etc/keys/mandos /usr/local/lib/mandos/keys; do
 
43
for d in /etc/keys/mandos /etc/mandos/keys; do
44
44
    if [ -d "$d" ]; then
45
45
        keydir="$d"
46
46
        break
51
51
    exit 1
52
52
fi
53
53
 
 
54
mandos_user="`{ getent passwd mandos \
 
55
                || getent passwd nobody \
 
56
                || echo ::65534::::; } \
 
57
        | awk --field-separator=: '{ print $3 }'`" 
 
58
mandos_group="`{ getent group mandos \
 
59
                || getent group nogroup \
 
60
                || echo ::65534:; } \
 
61
        | awk --field-separator=: '{ print $3 }'`"
 
62
 
54
63
# The Mandos network client uses the network
55
64
auto_add_modules net
56
65
# The Mandos network client uses IPv6
62
71
PLUGINDIR="${MANDOSDIR}/plugins.d"
63
72
 
64
73
# Make directories
65
 
mkdir --parents "${DESTDIR}${CONFDIR}"
66
 
mkdir --parents "${DESTDIR}${PLUGINDIR}"
 
74
install --directory --mode=u=rwx,go=rx "${DESTDIR}${CONFDIR}" \
 
75
        "${DESTDIR}${MANDOSDIR}"
 
76
install --owner=${mandos_user} --group=${mandos_group} --directory \
 
77
    --mode=u=rwx "${DESTDIR}${PLUGINDIR}"
67
78
 
68
79
# Copy the Mandos plugin runner
69
80
copy_exec "$prefix"/lib/mandos/plugin-runner "${MANDOSDIR}"
95
106
done
96
107
 
97
108
# GPGME needs /usr/bin/gpg
98
 
if ! [ -e "${DESTDIR}/usr/bin/gpg" ] \
99
 
    && [ -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* 2>/dev/null`" ]; then
 
109
if [ ! -e "${DESTDIR}/usr/bin/gpg" \
 
110
    -a -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* \
 
111
                2>/dev/null`" ]; then
100
112
    copy_exec /usr/bin/gpg
101
113
fi
102
114
 
103
 
# Config files and key files 
104
 
for file in /etc/mandos/* "$keydir"/*; do
105
 
    if [ -d "$file" ]; then
106
 
        continue
107
 
    fi
108
 
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
115
# Config files
 
116
for file in /etc/mandos/*; do
 
117
    if [ -d "$file" ]; then
 
118
        continue
 
119
    fi
 
120
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
121
done
 
122
 
 
123
# Key files 
 
124
for file in  "$keydir"/*; do
 
125
    if [ -d "$file" ]; then
 
126
        continue
 
127
    fi
 
128
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
129
    chown ${mandos_user}:${mandos_group} \
 
130
        "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
109
131
done
110
132
 
111
133
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
120
142
# condition.  This umask is set by "initramfs-tools-hook-conf",
121
143
# installed as "/usr/share/initramfs-tools/conf-hooks.d/mandos".)
122
144
123
 
for full in "${PLUGINDIR}" "${CONFDIR}"; do
 
145
for full in "${MANDOSDIR}" "${CONFDIR}"; do
124
146
    while [ "$full" != "/" ]; do
125
147
        chmod a+rX "${DESTDIR}$full"
126
148
        full="`dirname \"$full\"`"
135
157
    fi
136
158
done
137
159
for dir in /lib /usr/lib; do
138
 
    find "${DESTDIR}$dir" \! -perm /u+rw,g+r -prune -o -print0 \
 
160
    find "${DESTDIR}$dir" \! -perm -u+rw,g+r -prune -or -print0 \
139
161
        | xargs --null --no-run-if-empty chmod a+rX
140
162
done