/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: 2017-08-20 16:20:54 UTC
  • Revision ID: teddy@recompile.se-20170820162054-jwig602syxx2k4l0
Alter copyright notices slightly.  Actual license is unchanged!

This alters all copyright notices to use the Free Software
Foundation's recommendations for license notices; from
<https://www.gnu.org/licenses/gpl-howto.html>:

  For programs that are more than one file, it is better to replace
  “this program” with the name of the program, and begin the statement
  with a line saying “This file is part of NAME”.

* DBUS-API: Use program name "Mandos" explicitly in license notice.
* debian/copyright: - '' -
* initramfs-unpack: - '' -
* legalnotice.xml: - '' -
* mandos: - '' -
* mandos-ctl: - '' -
* mandos-keygen: - '' -
* mandos-monitor: - '' -
* plugin-helpers/mandos-client-iprouteadddel.c: - '' -
* plugin-runner.c: - '' -
* plugins.d/askpass-fifo.c: - '' -
* plugins.d/mandos-client.c: - '' -
* plugins.d/password-prompt.c: - '' -
* plugins.d/plymouth.c: - '' -
* plugins.d/splashy.c: - '' -
* plugins.d/usplash.c: - '' -

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"
73
74
HOOKDIR="${MANDOSDIR}/network-hooks.d"
74
75
 
75
76
# Make directories
76
77
install --directory --mode=u=rwx,go=rx "${DESTDIR}${CONFDIR}" \
77
78
        "${DESTDIR}${MANDOSDIR}" "${DESTDIR}${HOOKDIR}"
78
79
install --owner=${mandos_user} --group=${mandos_group} --directory \
79
 
    --mode=u=rwx "${DESTDIR}${PLUGINDIR}"
 
80
        --mode=u=rwx "${DESTDIR}${PLUGINDIR}" \
 
81
        "${DESTDIR}${PLUGINHELPERDIR}"
80
82
 
81
83
# Copy the Mandos plugin runner
82
84
copy_exec "$libdir"/mandos/plugin-runner "${MANDOSDIR}"
98
100
    esac
99
101
done
100
102
 
 
103
# Copy the packaged plugin helpers
 
104
for file in "$libdir"/mandos/plugin-helpers/*; do
 
105
    base="`basename \"$file\"`"
 
106
    # Is this plugin overridden?
 
107
    if [ -e "/etc/mandos/plugin-helpers/$base" ]; then
 
108
        continue
 
109
    fi
 
110
    case "$base" in
 
111
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
 
112
            : ;;
 
113
        "*") : ;;
 
114
        *) copy_exec "$file" "${PLUGINHELPERDIR}" ;;
 
115
    esac
 
116
done
 
117
 
101
118
# Copy any user-supplied plugins
102
119
for file in /etc/mandos/plugins.d/*; do
103
120
    base="`basename \"$file\"`"
109
126
    esac
110
127
done
111
128
 
 
129
# Copy any user-supplied plugin helpers
 
130
for file in /etc/mandos/plugin-helpers/*; do
 
131
    base="`basename \"$file\"`"
 
132
    case "$base" in
 
133
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
 
134
            : ;;
 
135
        "*") : ;;
 
136
        *) copy_exec "$file" "${PLUGINHELPERDIR}" ;;
 
137
    esac
 
138
done
 
139
 
112
140
# Get DEVICE from initramfs.conf and other files
113
141
. /etc/initramfs-tools/initramfs.conf
114
142
for conf in /etc/initramfs-tools/conf.d/*; do
115
143
    if [ -n `basename \"$conf\" | grep '^[[:alnum:]][[:alnum:]\._-]*$' \
116
144
        | grep -v '\.dpkg-.*$'` ]; then
117
 
        [ -f ${conf} ] && . ${conf}
 
145
        [ -f "${conf}" ] && . "${conf}"
118
146
    fi
119
147
done
120
148
export DEVICE
129
157
    if [ -x "$hook" ]; then
130
158
        # Copy any files needed by the network hook
131
159
        MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=files \
132
 
            VERBOSITY=0 "$hook" files | while read file target; do
 
160
            VERBOSITY=0 "$hook" files | while read -r file target; do
133
161
            if [ ! -e "${file}" ]; then
134
162
                echo "WARNING: file ${file} not found, requested by Mandos network hook '${hook##*/}'" >&2
135
163
            fi
141
169
        done
142
170
        # Copy and load any modules needed by the network hook
143
171
        MANDOSNETHOOKDIR=/etc/mandos/network-hooks.d MODE=modules \
144
 
            VERBOSITY=0 "$hook" modules | while read module; do
145
 
            if [ -z "${target}" ]; then
146
 
                force_load "$module"
147
 
            fi
 
172
            VERBOSITY=0 "$hook" modules | while read -r module; do
 
173
            force_load "$module"
148
174
        done
149
175
    fi
150
176
done
158
184
            copy_exec /usr/bin/gpgconf
159
185
        fi
160
186
        gpg="`/usr/bin/gpgconf|sed --quiet --expression='s/^gpg:[^:]*://p'`"
 
187
        gpgagent="`/usr/bin/gpgconf|sed --quiet --expression='s/^gpg-agent:[^:]*://p'`"
 
188
        # Newer versions of GnuPG 2 requires the gpg-agent binary
 
189
        if [ -e "$gpgagent" ] && [ ! -e "${DESTDIR}$gpgagent" ]; then
 
190
            copy_exec "$gpgagent"
 
191
        fi
161
192
    fi
162
193
elif dpkg --compare-versions "$libgpgme11_version" ge 1.4.1-0.1; then
163
194
    gpg=/usr/bin/gpg2
191
222
    if [ -d "$file" ]; then
192
223
        continue
193
224
    fi
194
 
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
195
 
    chown ${mandos_user}:${mandos_group} \
196
 
        "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
 
225
    case "$file" in
 
226
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
 
227
            : ;;
 
228
        "*") : ;;
 
229
        *)
 
230
            cp --archive --sparse=always "$file" \
 
231
               "${DESTDIR}${CONFDIR}"
 
232
            chown ${mandos_user}:${mandos_group} \
 
233
                  "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
 
234
            ;;
 
235
    esac
197
236
done
 
237
# Use Diffie-Hellman parameters file if available
 
238
if [ -e "${DESTDIR}${CONFDIR}"/dhparams.pem ]; then
 
239
    sed --in-place \
 
240
        --expression="1i--options-for=mandos-client:--dh-params=${CONFDIR}/dhparams.pem" \
 
241
        "${DESTDIR}/${CONFDIR}/plugin-runner.conf"
 
242
fi
198
243
 
199
244
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
200
245
# its plugin directory and its config file.  However, since almost all
224
269
done
225
270
for dir in "${DESTDIR}"/lib* "${DESTDIR}"/usr/lib*; do
226
271
    if [ -d "$dir" ]; then
227
 
        find "$dir" \! -perm -u+rw,g+r -prune -or -print0 \
228
 
            | xargs --null --no-run-if-empty chmod a+rX
 
272
        find "$dir" \! -perm -u+rw,g+r -prune -or \! -type l -print0 \
 
273
            | xargs --null --no-run-if-empty chmod a+rX --
229
274
    fi
230
275
done