/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos-keygen

  • Committer: Teddy Hogeborn
  • Date: 2017-02-22 21:45:35 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 358.
  • Revision ID: teddy@recompile.se-20170222214535-milf6w0b1krwpaex
Server bug fix: Use the mandos.conf "zeroconf" and "restore" options

Allow the "zeroconf" and "restore" options to actually work from the
mandos.conf file, in addition to command line options.

Closes: 855589
Reported-by: Pablo Abelenda <pabelenda@igalia.com>
Suggested-by: Pablo Abelenda <pabelenda@igalia.com>

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-2014 Teddy Hogeborn
6
 
# Copyright © 2008-2014 Björn Påhlsson
 
5
# Copyright © 2008-2016 Teddy Hogeborn
 
6
# Copyright © 2008-2016 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@recompile.se>.
22
22
23
23
 
24
 
VERSION="1.6.8"
 
24
VERSION="1.7.14"
25
25
 
26
26
KEYDIR="/etc/keys/mandos"
27
27
KEYTYPE=RSA
47
47
    --name "$0" -- "$@"`
48
48
 
49
49
help(){
50
 
basename="`basename $0`"
 
50
basename="`basename "$0"`"
51
51
cat <<EOF
52
52
Usage: $basename [ -v | --version ]
53
53
       $basename [ -h | --help ]
113
113
    esac
114
114
done
115
115
if [ "$#" -gt 0 ]; then
116
 
    echo "Unknown arguments: '$@'" >&2
 
116
    echo "Unknown arguments: '$*'" >&2
117
117
    exit 1
118
118
fi
119
119
 
218
218
        #Handle: <no-spaces>
219
219
        #%pubring pubring.gpg
220
220
        #%secring secring.gpg
 
221
        %no-protection
221
222
        %commit
222
223
        EOF
223
224
    
285
286
    esac
286
287
    
287
288
    if [ $SSH -eq 1 ]; then
288
 
        set +e
289
 
        ssh_fingerprint="`ssh-keyscan localhost 2>/dev/null`"
290
 
        if [ $? -ne 0 ]; then
291
 
            ssh_fingerprint=""
292
 
        fi
293
 
        set -e
294
 
        ssh_fingerprint="${ssh_fingerprint#localhost }"
 
289
        for ssh_keytype in ecdsa-sha2-nistp256 ed25519 rsa; do
 
290
            set +e
 
291
            ssh_fingerprint="`ssh-keyscan -t $ssh_keytype localhost 2>/dev/null`"
 
292
            set -e
 
293
            if [ $? -ne 0 ]; then
 
294
                ssh_fingerprint=""
 
295
                continue
 
296
            fi
 
297
            if [ -n "$ssh_fingerprint" ]; then
 
298
                ssh_fingerprint="${ssh_fingerprint#localhost }"
 
299
                break
 
300
            fi
 
301
        done
295
302
    fi
296
303
    
297
304
    # Import key into temporary key rings
304
311
    
305
312
    # Get fingerprint of key
306
313
    FINGERPRINT="`gpg --quiet --batch --no-tty --no-options \
307
 
        --enable-dsa2 --homedir \"$RINGDIR\" --trust-model always \
 
314
        --enable-dsa2 --homedir "$RINGDIR" --trust-model always \
308
315
        --fingerprint --with-colons \
309
316
        | sed --quiet \
310
317
        --expression='/^fpr:/{s/^fpr:.*:\\([0-9A-Z]*\\):\$/\\1/p;q}'`"
318
325
            cat "$PASSFILE"
319
326
        else
320
327
            tty --quiet && stty -echo
321
 
            echo -n "Enter passphrase: " >&2
322
 
            read first
 
328
            echo -n "Enter passphrase: " >/dev/tty
 
329
            read -r first
323
330
            tty --quiet && echo >&2
324
 
            echo -n "Repeat passphrase: " >&2
325
 
            read second
 
331
            echo -n "Repeat passphrase: " >/dev/tty
 
332
            read -r second
326
333
            if tty --quiet; then
327
334
                echo >&2
328
335
                stty echo
363
370
            }
364
371
        }' < "$SECFILE"
365
372
    if [ -n "$ssh_fingerprint" ]; then
366
 
        echo 'checker = ssh-keyscan %%(host)s 2>/dev/null | grep --fixed-strings --line-regexp --quiet --regexp=%%(host)s" %(ssh_fingerprint)s"'
 
373
        echo 'checker = ssh-keyscan -t '"$ssh_keytype"' %%(host)s 2>/dev/null | grep --fixed-strings --line-regexp --quiet --regexp=%%(host)s" %(ssh_fingerprint)s"'
367
374
        echo "ssh_fingerprint = ${ssh_fingerprint}"
368
375
    fi
369
376
fi