/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: 2016-06-27 20:21:50 UTC
  • Revision ID: teddy@recompile.se-20160627202150-ml201ilxwjf1g29w
mandos-ctl: Implement --dump-json option

* mandos-ctl (main): Implement --dump-json option
* mandos-ctl.xml (NAME, DESCRIPTION): Change description to the more
                                      accurate "control or query".
  (SYNOPSIS): Add required group around action options and add new
              "--dump-json" option.
  (OPTIONS): Document new "--dump-json" option.

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
150
178
done
151
179
 
152
180
# GPGME needs GnuPG
 
181
gpg=/usr/bin/gpg
153
182
libgpgme11_version="`dpkg-query --showformat='${Version}' --show libgpgme11`"
154
 
if dpkg --compare-versions "$libgpgme11_version" ge 1.4.1-0.1; then
 
183
if dpkg --compare-versions "$libgpgme11_version" ge 1.5.0-0.1; then
 
184
    if [ -e /usr/bin/gpgconf ]; then
 
185
        if [ ! -e "${DESTDIR}/usr/bin/gpgconf" ]; then
 
186
            copy_exec /usr/bin/gpgconf
 
187
        fi
 
188
        gpg="`/usr/bin/gpgconf|sed --quiet --expression='s/^gpg:[^:]*://p'`"
 
189
        gpgagent="`/usr/bin/gpgconf|sed --quiet --expression='s/^gpg-agent:[^:]*://p'`"
 
190
        # Newer versions of GnuPG 2 requires the gpg-agent binary
 
191
        if [ -e "$gpgagent" ] && [ ! -e "${DESTDIR}$gpgagent" ]; then
 
192
            copy_exec "$gpgagent"
 
193
        fi
 
194
    fi
 
195
elif dpkg --compare-versions "$libgpgme11_version" ge 1.4.1-0.1; then
155
196
    gpg=/usr/bin/gpg2
156
 
else
157
 
    gpg=/usr/bin/gpg
158
197
fi
159
198
if [ ! -e "${DESTDIR}$gpg" ]; then
160
199
    copy_exec "$gpg"
185
224
    if [ -d "$file" ]; then
186
225
        continue
187
226
    fi
188
 
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
189
 
    chown ${mandos_user}:${mandos_group} \
190
 
        "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
 
227
    case "$file" in
 
228
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
 
229
            : ;;
 
230
        "*") : ;;
 
231
        *)
 
232
            cp --archive --sparse=always "$file" \
 
233
               "${DESTDIR}${CONFDIR}"
 
234
            chown ${mandos_user}:${mandos_group} \
 
235
                  "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
 
236
            ;;
 
237
    esac
191
238
done
 
239
# Use Diffie-Hellman parameters file if available
 
240
if [ -e "${DESTDIR}${CONFDIR}"/dhparams.pem ]; then
 
241
    sed --in-place \
 
242
        --expression="1i--options-for=mandos-client:--dh-params=${CONFDIR}/dhparams.pem" \
 
243
        "${DESTDIR}/${CONFDIR}/plugin-runner.conf"
 
244
fi
192
245
 
193
246
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
194
247
# its plugin directory and its config file.  However, since almost all
218
271
done
219
272
for dir in "${DESTDIR}"/lib* "${DESTDIR}"/usr/lib*; do
220
273
    if [ -d "$dir" ]; then
221
 
        find "$dir" \! -perm -u+rw,g+r -prune -or -print0 \
222
 
            | xargs --null --no-run-if-empty chmod a+rX
 
274
        find "$dir" \! -perm -u+rw,g+r -prune -or \! -type l -print0 \
 
275
            | xargs --null --no-run-if-empty chmod a+rX --
223
276
    fi
224
277
done