/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: 2014-07-25 22:44:20 UTC
  • mto: This revision was merged to the branch mainline in revision 724.
  • Revision ID: teddy@recompile.se-20140725224420-4a5ct2ptt0hsc92z
Require Python 2.7.

This is in preparation for the eventual move to Python 3, which will
happen as soon as all Python modules required by Mandos are available.
The mandos-ctl and mandos-monitor programs are already portable
between Python 2.6 and Python 3 without changes; this change will
bring the requirement up to Python 2.7.

* INSTALL (Prerequisites/Libraries/Mandos Server): Document
                                                   requirement of
                                                   Python 2.7; remove
                                                   Python-argparse
                                                   which is in the
                                                   Python 2.7 standard
                                                   library.
* debian/control (Source: mandos/Build-Depends-Indep): Depend on
                                                       exactly the
                                                       python2.7
                                                       package and all
                                                       the Python 2.7
                                                       versions of the
                                                       python modules.
  (Package: mandos/Depends): - '' - but still depend on python (<=2.7)
                            and the generic versions of the Python
                            modules; this is for mandos-ctl and
                            mandos-monitor, both of which are
                            compatible with Python 3, and use
                            #!/usr/bin/python.
* mandos: Use #!/usr/bin/python2.7 instead of #!/usr/bin/python.

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