/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: 2009-04-16 01:00:35 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090416010035-y7ta6ra2da4gf6mp
Minor code cleanup; one minor bug fix.

* initramfs-tools-hook: Bug fix: Use the primary group of the first
                        suitable user found, do not look for a
                        group separately.
* mandos: Unconditionally import "struct" and "fcntl".  Use unicode
          strings everywhere possible.
  (Client._datetime_to_milliseconds): New static method.
  (Client.timeout_milliseconds, Client.interval_milliseconds): Use
                                                               above
                                                               method.
  (ClientDBus.CheckedOK,
  ClientDBus.Enable, ClientDBus.StopChecker): Define normally.
  (if_nametoindex): Document non-acceptance of unicode strings.  All
                    callers adjusted.  Do not import "struct" or
                    "fcntl".  Log warning message if if_nametoindex
                    cannot be found using ctypes modules.
  (main): Bug fix: Do not look for user named "nogroup".

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
CONFDIR="/conf/conf.d/mandos"
69
69
MANDOSDIR="/lib/mandos"
70
70
PLUGINDIR="${MANDOSDIR}/plugins.d"
71
 
HOOKDIR="${MANDOSDIR}/network-hooks.d"
72
71
 
73
72
# Make directories
74
73
install --directory --mode=u=rwx,go=rx "${DESTDIR}${CONFDIR}" \
75
 
        "${DESTDIR}${MANDOSDIR}" "${DESTDIR}${HOOKDIR}"
 
74
        "${DESTDIR}${MANDOSDIR}"
76
75
install --owner=${mandos_user} --group=${mandos_group} --directory \
77
76
    --mode=u=rwx "${DESTDIR}${PLUGINDIR}"
78
77
 
91
90
    case "$base" in
92
91
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
93
92
            : ;;
94
 
        "*") echo "W: Mandos client plugin directory is empty." >&2 ;;
 
93
        */"*")
 
94
            echo "W: Mandos client plugin directory is empty." >&2 ;;
95
95
        *) copy_exec "$file" "${PLUGINDIR}" ;;
96
96
    esac
97
97
done
102
102
    case "$base" in
103
103
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
104
104
            : ;;
105
 
        "*") : ;;
 
105
        */"*") : ;;
106
106
        *) copy_exec "$file" "${PLUGINDIR}" ;;
107
107
    esac
108
108
done
109
109
 
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}
116
 
    fi
117
 
done
118
 
export DEVICE
119
 
 
120
 
# Copy network hooks
121
 
for hook in /etc/mandos/network-hooks.d/*; do
122
 
    case "`basename \"$hook\"`" in
123
 
        "*") continue ;;
124
 
        *[!A-Za-z0-9_.-]*) continue ;;
125
 
        *) test -d "$hook" || copy_exec "$hook" "${HOOKDIR}" ;;
126
 
    esac
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
133
 
            fi
134
 
            if [ -z "${target}" ]; then
135
 
                copy_exec "$file"
136
 
            else
137
 
                copy_exec "$file" "$target"
138
 
            fi
139
 
        done
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
144
 
                force_load "$module"
145
 
            fi
146
 
        done
147
 
    fi
148
 
done
149
 
 
150
110
# GPGME needs /usr/bin/gpg
151
111
if [ ! -e "${DESTDIR}/usr/bin/gpg" \
152
112
    -a -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* \
155
115
fi
156
116
 
157
117
# Config files
158
 
for file in /etc/mandos/plugin-runner.conf; do
 
118
for file in /etc/mandos/*; do
159
119
    if [ -d "$file" ]; then
160
120
        continue
161
121
    fi
163
123
done
164
124
 
165
125
if [ ${mandos_user} != 65534 ]; then
166
 
    sed --in-place --expression="1i--userid=${mandos_user}" \
167
 
        "${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
126
    PLUGINRUNNERCONF="${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
127
    cat <<-EOF >> "$PLUGINRUNNERCONF"
 
128
        
 
129
        --userid=${mandos_user}
 
130
EOF
168
131
fi
169
132
 
170
133
if [ ${mandos_group} != 65534 ]; then
171
 
    sed --in-place --expression="1i--groupid=${mandos_group}" \
172
 
        "${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
134
    PLUGINRUNNERCONF="${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
135
    cat <<-EOF >> "$PLUGINRUNNERCONF"
 
136
        
 
137
        --groupid=${mandos_group}
 
138
EOF
173
139
fi
174
140
 
175
 
# Key files
 
141
# Key files 
176
142
for file in "$keydir"/*; do
177
143
    if [ -d "$file" ]; then
178
144
        continue