/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: 2010-09-12 03:00:40 UTC
  • Revision ID: teddy@fukt.bsnet.se-20100912030040-b0uopyennste9fdh
Documentation changes:

* DBUS-API: New file documenting the server D-Bus interface.

* clients.conf: Add examples of new approval settings.

* debian/mandos.docs: Added "DBUS-API".

* mandos-clients.conf.xml (OPTIONS): Added "approved_by_default",
                                     "approval_delay", and
                                     "approval_duration".
* mandos.xml (D-BUS INTERFACE): Refer to the "DBUS-API" file.
  (BUGS): Remove mention of lack of a remote query interface.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    exit 1
41
41
fi
42
42
 
43
 
for d in /etc/keys/mandos /usr/local/lib/mandos/keys; do
 
43
for d in /etc/keys/mandos /etc/mandos/keys; do
44
44
    if [ -d "$d" ]; then
45
45
        keydir="$d"
46
46
        break
51
51
    exit 1
52
52
fi
53
53
 
 
54
set `{ getent passwd _mandos \
 
55
    || getent passwd nobody \
 
56
    || echo ::65534:65534:::; } \
 
57
    | cut --delimiter=: --fields=3,4 --only-delimited \
 
58
    --output-delimiter=" "`
 
59
mandos_user="$1"
 
60
mandos_group="$2"
 
61
 
54
62
# The Mandos network client uses the network
55
63
auto_add_modules net
56
64
# The Mandos network client uses IPv6
62
70
PLUGINDIR="${MANDOSDIR}/plugins.d"
63
71
 
64
72
# Make directories
65
 
mkdir --parents "${DESTDIR}${CONFDIR}"
66
 
mkdir --parents "${DESTDIR}${PLUGINDIR}"
 
73
install --directory --mode=u=rwx,go=rx "${DESTDIR}${CONFDIR}" \
 
74
        "${DESTDIR}${MANDOSDIR}"
 
75
install --owner=${mandos_user} --group=${mandos_group} --directory \
 
76
    --mode=u=rwx "${DESTDIR}${PLUGINDIR}"
67
77
 
68
78
# Copy the Mandos plugin runner
69
79
copy_exec "$prefix"/lib/mandos/plugin-runner "${MANDOSDIR}"
78
88
        continue
79
89
    fi
80
90
    case "$base" in
81
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
82
 
        "*") :;;
83
 
        *) copy_exec "$file" "${PLUGINDIR}";;
 
91
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
 
92
            : ;;
 
93
        "*") echo "W: Mandos client plugin directory is empty." >&2 ;;
 
94
        *) copy_exec "$file" "${PLUGINDIR}" ;;
84
95
    esac
85
96
done
86
97
 
88
99
for file in /etc/mandos/plugins.d/*; do
89
100
    base="`basename \"$file\"`"
90
101
    case "$base" in
91
 
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-new|*.dpkg-divert) : ;;
92
 
        "*") :;;
93
 
        *) copy_exec "$file" "${PLUGINDIR}";;
 
102
        *~|.*|\#*\#|*.dpkg-old|*.dpkg-bak|*.dpkg-new|*.dpkg-divert)
 
103
            : ;;
 
104
        "*") : ;;
 
105
        *) copy_exec "$file" "${PLUGINDIR}" ;;
94
106
    esac
95
107
done
96
108
 
97
109
# GPGME needs /usr/bin/gpg
98
 
if ! [ -e "${DESTDIR}/usr/bin/gpg" ] \
99
 
    && [ -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* 2>/dev/null`" ]; then
 
110
if [ ! -e "${DESTDIR}/usr/bin/gpg" \
 
111
    -a -n "`ls \"${DESTDIR}\"/usr/lib/libgpgme.so* \
 
112
                2>/dev/null`" ]; then
100
113
    copy_exec /usr/bin/gpg
101
114
fi
102
115
 
103
 
# Config files and key files 
104
 
for file in /etc/mandos/* "$keydir"/*; do
105
 
    if [ -d "$file" ]; then
106
 
        continue
107
 
    fi
108
 
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
116
# Config files
 
117
for file in /etc/mandos/plugin-runner.conf; do
 
118
    if [ -d "$file" ]; then
 
119
        continue
 
120
    fi
 
121
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
122
done
 
123
 
 
124
if [ ${mandos_user} != 65534 ]; then
 
125
    sed --in-place --expression="1i--userid=${mandos_user}" \
 
126
        "${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
127
fi
 
128
 
 
129
if [ ${mandos_group} != 65534 ]; then
 
130
    sed --in-place --expression="1i--groupid=${mandos_group}" \
 
131
        "${DESTDIR}${CONFDIR}/plugin-runner.conf"
 
132
fi
 
133
 
 
134
# Key files 
 
135
for file in "$keydir"/*; do
 
136
    if [ -d "$file" ]; then
 
137
        continue
 
138
    fi
 
139
    cp --archive --sparse=always "$file" "${DESTDIR}${CONFDIR}"
 
140
    chown ${mandos_user}:${mandos_group} \
 
141
        "${DESTDIR}${CONFDIR}/`basename \"$file\"`"
109
142
done
110
143
 
111
144
# /lib/mandos/plugin-runner will drop priviliges, but needs access to
120
153
# condition.  This umask is set by "initramfs-tools-hook-conf",
121
154
# installed as "/usr/share/initramfs-tools/conf-hooks.d/mandos".)
122
155
123
 
for full in "${PLUGINDIR}" "${CONFDIR}"; do
 
156
for full in "${MANDOSDIR}" "${CONFDIR}"; do
124
157
    while [ "$full" != "/" ]; do
125
158
        chmod a+rX "${DESTDIR}$full"
126
159
        full="`dirname \"$full\"`"
134
167
        chmod a+rX "${DESTDIR}$dir"
135
168
    fi
136
169
done
137
 
for dir in /lib /usr/lib; do
138
 
    find "${DESTDIR}$dir" \! -perm /u+rw,g+r -prune -o -print0 \
139
 
        | xargs --null --no-run-if-empty chmod a+rX
 
170
for dir in "${DESTDIR}"/lib* "${DESTDIR}"/usr/lib*; do
 
171
    if [ -d "$dir" ]; then
 
172
        find "$dir" \! -perm -u+rw,g+r -prune -or -print0 \
 
173
            | xargs --null --no-run-if-empty chmod a+rX
 
174
    fi
140
175
done