/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-script

  • Committer: Teddy Hogeborn
  • Date: 2011-07-15 01:07:51 UTC
  • Revision ID: teddy@fukt.bsnet.se-20110715010751-bh9rhcm6hv8f174e
* initramfs-tools-script: Bug fix: Add missing "--options" argument to
                          getopt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
# Get DEVICE from /conf/initramfs.conf and other files
58
58
. /conf/initramfs.conf
59
59
for conf in /conf/conf.d/*; do
60
 
    [ -f "${conf}" ] && . "${conf}"
 
60
    [ -f ${conf} ] && . ${conf}
61
61
done
62
62
if [ -e /conf/param.conf ]; then
63
63
    . /conf/param.conf
94
94
# If we are connecting directly, run "configure_networking" (from
95
95
# /scripts/functions); it needs IPOPTS and DEVICE
96
96
if [ "${connect+set}" = set ]; then
97
 
    set +e                      # Required by library functions
98
97
    configure_networking
99
 
    set -e
100
98
    if [ -n "$connect" ]; then
101
99
        cat <<-EOF >>/conf/conf.d/mandos/plugin-runner.conf
102
100
        
110
108
 
111
109
# Our keyscript
112
110
mandos=/lib/mandos/plugin-runner
113
 
test -x "$mandos"
114
111
 
115
112
# parse /conf/conf.d/cryptroot.  Format:
116
 
# target=sda2_crypt,source=/dev/sda2,rootdev,key=none,keyscript=/foo/bar/baz
117
 
# Is the root device specially marked?
118
 
changeall=yes
119
 
while read -r options; do
120
 
    case "$options" in
121
 
        rootdev,*|*,rootdev,*|*,rootdev)
122
 
            # If the root device is specially marked, don't change all
123
 
            # lines in crypttab by default.
124
 
            changeall=no
125
 
            ;;
126
 
    esac
127
 
done < /conf/conf.d/cryptroot
128
 
 
 
113
# target=sda2_crypt,source=/dev/sda2,key=none,keyscript=/foo/bar/baz
129
114
exec 3>/conf/conf.d/cryptroot.mandos
130
 
while read -r options; do
 
115
while read options; do
131
116
    newopts=""
132
 
    keyscript=""
133
 
    changethis="$changeall"
134
117
    # Split option line on commas
135
118
    old_ifs="$IFS"
136
119
    IFS="$IFS,"
142
125
                newopts="$newopts,$opt"
143
126
                ;;
144
127
            "") : ;;
145
 
            # Always use Mandos on the root device, if marked
146
 
            rootdev)
147
 
                changethis=yes
148
 
                newopts="$newopts,$opt"
149
 
                ;;
150
 
            # Don't use Mandos on resume device, if marked
151
 
            resumedev)
152
 
                changethis=no
153
 
                newopts="$newopts,$opt"
154
 
                ;;
155
128
            *)
156
129
                newopts="$newopts,$opt"
157
130
                ;;
160
133
    IFS="$old_ifs"
161
134
    unset old_ifs
162
135
    # If there was no keyscript option, add one.
163
 
    if [ "$changethis" = yes ] && [ -z "$keyscript" ]; then
 
136
    if [ -z "$keyscript" ]; then
164
137
        replace_cryptroot=yes
165
138
        newopts="$newopts,keyscript=$mandos"
166
139
    fi
176
149
else
177
150
    rm /conf/conf.d/cryptroot.mandos
178
151
fi
 
152
 
 
153
## Work around Debian bug #633582: <http://bugs.debian.org/633582>
 
154
# First determine the mandos user and group ID
 
155
mandos_user="65534"
 
156
mandos_group="65534"
 
157
while read line; do
 
158
    line="${line%%#*}"
 
159
    TEMP=`getopt --quiet --longoptions userid:,groupid: --options "" -- $line`
 
160
    eval set -- "$TEMP"
 
161
    while true; do
 
162
        case "$1" in
 
163
            --userid) mandos_user="$2"; shift 2;;
 
164
            --groupid) mandos_group="$2"; shift 2;;
 
165
            --) shift; break;;
 
166
        esac
 
167
    done
 
168
done < /conf/conf.d/mandos/plugin-runner.conf
 
169
chown "${mandos_user}:${mandos_group}" \
 
170
    /lib/mandos/plugins.d \
 
171
    /conf/conf.d/mandos/pubkey.txt \
 
172
    /conf/conf.d/mandos/seckey.txt