/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
new approve/deny functionallity in mandos-monitor

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,2009 Teddy Hogeborn
 
6
# Copyright © 2008,2009 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.0.14"
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
217
217
        %commit
218
218
        EOF
219
219
    
 
220
    if tty --quiet; then
 
221
        cat <<-EOF
 
222
        Note: Due to entropy requirements, key generation could take
 
223
        anything from a few minutes to SEVERAL HOURS.  Please be
 
224
        patient and/or supply the system with more entropy if needed.
 
225
        EOF
 
226
        echo -n "Started: "
 
227
        date
 
228
    fi
 
229
    
220
230
    # Generate a new key in the key rings
221
231
    gpg --quiet --batch --no-tty --no-options --enable-dsa2 \
222
232
        --homedir "$RINGDIR" --trust-model always \
223
233
        --gen-key "$BATCHFILE"
224
234
    rm --force "$BATCHFILE"
225
235
    
 
236
    if tty --quiet; then
 
237
        echo -n "Finished: "
 
238
        date
 
239
    fi
 
240
    
226
241
    # Backup any old key files
227
242
    if cp --backup=numbered --force "$SECKEYFILE" "$SECKEYFILE" \
228
243
        2>/dev/null; then
284
299
        stty echo
285
300
        if [ "$first" != "$second" ]; then
286
301
            echo -e "Passphrase mismatch" >&2
287
 
            false
 
302
            touch "$RINGDIR"/mismatch
288
303
        else
289
304
            echo -n "$first"
290
305
        fi
292
307
        --homedir "$RINGDIR" --trust-model always --armor --encrypt \
293
308
        --sign --recipient "$FINGERPRINT" --comment "$FILECOMMENT" \
294
309
        > "$SECFILE"
295
 
    status="${PIPESTATUS[0]}"
296
 
    if [ "$status" -ne 0 ]; then
297
 
        exit "$status"
 
310
    if [ -e "$RINGDIR"/mismatch ]; then
 
311
        rm --force "$RINGDIR"/mismatch
 
312
        exit 1
298
313
    fi
299
314
    
300
315
    cat <<-EOF