/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-01-08 03:54:06 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090108035406-01uqkv9xqgxlnw7c
Change the default value of the "checker" option command to make the
checker command be run-time dependent on the "host" client attribute
instead of reading it only once on startup:

* clients.conf (checker): Changed default commented-out value to
                          "fping -q -- %%(host)s".
* mandos (main): Changed default value for the "checker" config option
                 to "fping -q -- %%(host)s".
* mandos-clients.conf.xml (OPTIONS): Document changed default value.
  (EXAMPLE): Changed value of "checker".

* plugins.d/password-prompt.c: Whitespace changes only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
. /usr/share/initramfs-tools/hook-functions
31
31
 
32
 
if [ -d /usr/lib/mandos ]; then
33
 
    prefix=/usr
34
 
elif [ -d /usr/local/lib/mandos ]; then
35
 
    prefix=/usr/local
36
 
else
 
32
for d in /usr /usr/local; do
 
33
    if [ -d "$d"/lib/mandos ]; then
 
34
        prefix="$d"
 
35
        break
 
36
    fi
 
37
done
 
38
if [ -z "$prefix" ]; then
37
39
    # Mandos not found
38
40
    exit 1
39
41
fi
40
42
 
 
43
for d in /etc/keys/mandos /etc/mandos/keys; do
 
44
    if [ -d "$d" ]; then
 
45
        keydir="$d"
 
46
        break
 
47
    fi
 
48
done
 
49
if [ -z "$keydir" ]; then
 
50
    # Mandos key directory not found
 
51
    exit 1
 
52
fi
 
53
 
 
54
mandos_user="`{ getent passwd _mandos \
 
55
                || getent passwd mandos \
 
56
                || getent passwd nobody \
 
57
                || echo ::65534::::; } \
 
58
        | awk --field-separator=: '{ print $3 }'`" 
 
59
mandos_group="`{ getent group _mandos \
 
60
                || getent group mandos \
 
61
                || getent group nogroup \
 
62
                || echo ::65534:; } \
 
63
        | awk --field-separator=: '{ print $3 }'`"
 
64
 
41
65
# The Mandos network client uses the network
42
66
auto_add_modules net
43
67
# The Mandos network client uses IPv6
49
73
PLUGINDIR="${MANDOSDIR}/plugins.d"
50
74
 
51
75
# Make directories
52
 
mkdir --parents "${DESTDIR}${CONFDIR}"
53
 
mkdir --parents "${DESTDIR}${PLUGINDIR}"
 
76
install --directory --mode=u=rwx,go=rx "${DESTDIR}${CONFDIR}" \
 
77
        "${DESTDIR}${MANDOSDIR}"
 
78
install --owner=${mandos_user} --group=${mandos_group} --directory \
 
79
    --mode=u=rwx "${DESTDIR}${PLUGINDIR}"
54
80
 
55
81
# Copy the Mandos plugin runner
56
 
copy_exec "$prefix"/lib/mandos/plugin-runner "${DESTDIR}${MANDOSDIR}"
 
82
copy_exec "$prefix"/lib/mandos/plugin-runner "${MANDOSDIR}"
57
83
 
58
84
# Copy the plugins
59
85
 
65
91
        continue
66
92
    fi
67
93
    case "$base" in
68
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
 
94
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert) : ;;
 
95
        "*") :;;
69
96
        *) copy_exec "$file" "${PLUGINDIR}";;
70
97
    esac
71
98
done
74
101
for file in /etc/mandos/plugins.d/*; do
75
102
    base="`basename \"$file\"`"
76
103
    case "$base" in
77
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
 
104
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert) : ;;
 
105
        "*") :;;
78
106
        *) copy_exec "$file" "${PLUGINDIR}";;
79
107
    esac
80
108
done
81
109
 
82
110
# GPGME needs /usr/bin/gpg
83
 
if ! [ -e "${DESTDIR}/usr/bin/gpg" ] \
84
 
    && [ -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* 2>/dev/null`" ]; then
 
111
if [ ! -e "${DESTDIR}/usr/bin/gpg" \
 
112
    -a -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* \
 
113
                2>/dev/null`" ]; then
85
114
    copy_exec /usr/bin/gpg
86
115
fi
87
116
 
88
 
# Key files and config files
 
117
# Config files
89
118
for file in /etc/mandos/*; do
90
119
    if [ -d "$file" ]; then
91
120
        continue
93
122
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
94
123
done
95
124
 
 
125
if [ ${mandos_user} != 65534 ]; then
 
126
    PLUGINRUNNERCONF="${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
127
    echo "--userid=${mandos_user}" >> "$PLUGINRUNNERCONF"
 
128
fi
 
129
 
 
130
if [ ${mandos_group} != 65534 ]; then
 
131
    PLUGINRUNNERCONF="${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
132
    echo "--groupid=${mandos_group}" >> "$PLUGINRUNNERCONF"
 
133
fi
 
134
 
 
135
# Key files 
 
136
for file in  "$keydir"/*; do
 
137
    if [ -d "$file" ]; then
 
138
        continue
 
139
    fi
 
140
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
141
    chown ${mandos_user}:${mandos_group} \
 
142
        "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
 
143
done
 
144
 
96
145
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
97
146
# its plugin directory and its config file.  However, since almost all
98
147
# files in initrd have been created with umask 027, this opening of
105
154
# condition.  This umask is set by "initramfs-tools-hook-conf",
106
155
# installed as "/usr/share/initramfs-tools/conf-hooks.d/mandos".)
107
156
108
 
for full in "${PLUGINDIR}" "${CONFDIR}"; do
 
157
for full in "${MANDOSDIR}" "${CONFDIR}"; do
109
158
    while [ "$full" != "/" ]; do
110
159
        chmod a+rX "${DESTDIR}$full"
111
160
        full="`dirname \"$full\"`"
115
164
# Reset some other things to sane permissions which we have
116
165
# inadvertently affected with our umask setting.
117
166
for dir in / /bin /etc /keyscripts /sbin /scripts /usr /usr/bin; do
118
 
    chmod a+rX "${DESTDIR}$dir"
 
167
    if [ -d "${DESTDIR}$dir" ]; then
 
168
        chmod a+rX "${DESTDIR}$dir"
 
169
    fi
119
170
done
120
171
for dir in /lib /usr/lib; do
121
 
    find "${DESTDIR}$dir" \! -perm /u+rw,g+r -prune -o -print0 \
122
 
        | xargs --null chmod a+rX
 
172
    find "${DESTDIR}$dir" \! -perm -u+rw,g+r -prune -or -print0 \
 
173
        | xargs --null --no-run-if-empty chmod a+rX
123
174
done