/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

  • Committer: Teddy Hogeborn
  • Date: 2015-06-28 16:35:27 UTC
  • mto: This revision was merged to the branch mainline in revision 759.
  • Revision ID: teddy@recompile.se-20150628163527-cky0ec59zew7teua
Add a plugin helper directory, available to all plugins.

* Makefile (PLUGIN_HELPERS): New; list of plugin helpers.
  (CPROGS): Appended "$(PLUGIN_HELPERS)".
* initramfs-tools-hook: Create new plugin helper directory, and copy
                        plugin helpers provided by the system and/or
                        by the local administrator.
  (PLUGINHELPERDIR): New.
* plugin-runner.c: Take new --plugin-helper-dir option and provide
                   environment variable to all plugins.
  (PHDIR): New; set to "/lib/mandos/plugin-helpers".
  (main/pluginhelperdir): New.
  (main/options): New option "--plugin-helper-dir".
  (main/parse_opt, main/parse_opt_config_file): Accept new option.
  (main): Use new option to set MANDOSPLUGINHELPERDIR environment
          variable as if using --global-env MANDOSPLUGINHELPERDIR=...
* plugin-runner.xml: Document new --plugin-helper-dir option.
  (SYNOPSIS, OPTIONS): Add "--plugin-helper-dir" option.
  (PLUGINS/WRITING PLUGINS): Document new environment variable
                             available to plugins.
  (ENVIRONMENT): Document new environment variable
                 "MANDOSPLUGINHELPERDIR" affected by the new
                 --plugin-helper-dir option.

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-2017 Teddy Hogeborn
6
 
# Copyright © 2008-2017 Björn Påhlsson
 
5
# Copyright © 2008-2014 Teddy Hogeborn
 
6
# Copyright © 2008-2014 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.7.15"
 
24
VERSION="1.6.9"
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
222
221
        %commit
223
222
        EOF
224
223
    
286
285
    esac
287
286
    
288
287
    if [ $SSH -eq 1 ]; then
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
 
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 }"
302
295
    fi
303
296
    
304
297
    # Import key into temporary key rings
311
304
    
312
305
    # Get fingerprint of key
313
306
    FINGERPRINT="`gpg --quiet --batch --no-tty --no-options \
314
 
        --enable-dsa2 --homedir "$RINGDIR" --trust-model always \
 
307
        --enable-dsa2 --homedir \"$RINGDIR\" --trust-model always \
315
308
        --fingerprint --with-colons \
316
309
        | sed --quiet \
317
310
        --expression='/^fpr:/{s/^fpr:.*:\\([0-9A-Z]*\\):\$/\\1/p;q}'`"
325
318
            cat "$PASSFILE"
326
319
        else
327
320
            tty --quiet && stty -echo
328
 
            echo -n "Enter passphrase: " >/dev/tty
329
 
            read -r first
 
321
            echo -n "Enter passphrase: " >&2
 
322
            read first
330
323
            tty --quiet && echo >&2
331
 
            echo -n "Repeat passphrase: " >/dev/tty
332
 
            read -r second
 
324
            echo -n "Repeat passphrase: " >&2
 
325
            read second
333
326
            if tty --quiet; then
334
327
                echo >&2
335
328
                stty echo
370
363
            }
371
364
        }' < "$SECFILE"
372
365
    if [ -n "$ssh_fingerprint" ]; then
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"'
 
366
        echo 'checker = ssh-keyscan %%(host)s 2>/dev/null | grep --fixed-strings --line-regexp --quiet --regexp=%%(host)s" %(ssh_fingerprint)s"'
374
367
        echo "ssh_fingerprint = ${ssh_fingerprint}"
375
368
    fi
376
369
fi