/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 mandos-keygen

Merge from trunk.  Just a minor release to make it lintian clean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
3
3
# Mandos key generator - create a new OpenPGP key for a Mandos client
4
4
5
 
# Copyright © 2008 Teddy Hogeborn
6
 
# Copyright © 2008 Björn Påhlsson
 
5
# Copyright © 2008-2010 Teddy Hogeborn
 
6
# Copyright © 2008-2010 Björn Påhlsson
7
7
8
8
# This program is free software: you can redistribute it and/or modify
9
9
# it under the terms of the GNU General Public License as published by
21
21
# Contact the authors at <mandos@fukt.bsnet.se>.
22
22
23
23
 
24
 
VERSION="1.0.2"
 
24
VERSION="1.2"
25
25
 
26
26
KEYDIR="/etc/keys/mandos"
27
27
KEYTYPE=DSA
147
147
        echo "Invalid key length" >&2
148
148
        exit 1
149
149
    fi
150
 
 
 
150
    
151
151
    if [ -z "$KEYEXPIRE" ]; then
152
152
        echo "Empty key expiration" >&2
153
153
        exit 1
172
172
    if [ -n "$KEYEMAIL" ]; then
173
173
        KEYEMAILLINE="Name-Email: $KEYEMAIL"
174
174
    fi
175
 
 
 
175
    
176
176
    # Create temporary gpg batch file
177
177
    BATCHFILE="`mktemp -t mandos-keygen-batch.XXXXXXXXXX`"
178
178
fi
195
195
stty echo; \
196
196
" EXIT
197
197
 
 
198
set -e
 
199
 
198
200
umask 077
199
201
 
200
202
if [ "$mode" = keygen ]; then
217
219
        %commit
218
220
        EOF
219
221
    
 
222
    if tty --quiet; then
 
223
        cat <<-EOF
 
224
        Note: Due to entropy requirements, key generation could take
 
225
        anything from a few minutes to SEVERAL HOURS.  Please be
 
226
        patient and/or supply the system with more entropy if needed.
 
227
        EOF
 
228
        echo -n "Started: "
 
229
        date
 
230
    fi
 
231
    
220
232
    # Generate a new key in the key rings
221
233
    gpg --quiet --batch --no-tty --no-options --enable-dsa2 \
222
234
        --homedir "$RINGDIR" --trust-model always \
223
235
        --gen-key "$BATCHFILE"
224
236
    rm --force "$BATCHFILE"
225
237
    
 
238
    if tty --quiet; then
 
239
        echo -n "Finished: "
 
240
        date
 
241
    fi
 
242
    
226
243
    # Backup any old key files
227
244
    if cp --backup=numbered --force "$SECKEYFILE" "$SECKEYFILE" \
228
245
        2>/dev/null; then
278
295
        stty -echo
279
296
        echo -n "Enter passphrase: " >&2
280
297
        first="$(head --lines=1 | tr --delete '\n')"
281
 
        echo -n -e "\nRepeat passphrase: " >&2
 
298
        echo >&2
 
299
        echo -n "Repeat passphrase: " >&2
282
300
        second="$(head --lines=1 | tr --delete '\n')"
283
301
        echo >&2
284
302
        stty echo
285
303
        if [ "$first" != "$second" ]; then
286
 
            echo -e "Passphrase mismatch" >&2
287
 
            false
 
304
            echo "Passphrase mismatch" >&2
 
305
            touch "$RINGDIR"/mismatch
288
306
        else
289
307
            echo -n "$first"
290
308
        fi
292
310
        --homedir "$RINGDIR" --trust-model always --armor --encrypt \
293
311
        --sign --recipient "$FINGERPRINT" --comment "$FILECOMMENT" \
294
312
        > "$SECFILE"
295
 
    status="${PIPESTATUS[0]}"
296
 
    if [ "$status" -ne 0 ]; then
297
 
        exit "$status"
 
313
    if [ -e "$RINGDIR"/mismatch ]; then
 
314
        rm --force "$RINGDIR"/mismatch
 
315
        exit 1
298
316
    fi
299
317
    
300
318
    cat <<-EOF