/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-2015 Teddy Hogeborn
6
 
# Copyright © 2008-2015 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
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
 
285
285
    esac
286
286
    
287
287
    if [ $SSH -eq 1 ]; then
288
 
        for ssh_keytype in ed25519 rsa; do
289
 
            set +e
290
 
            ssh_fingerprint="`ssh-keyscan -t $ssh_keytype localhost 2>/dev/null`"
291
 
            set -e
292
 
            if [ $? -ne 0 ]; then
293
 
                ssh_fingerprint=""
294
 
                continue
295
 
            fi
296
 
            if [ -n "$ssh_fingerprint" ]; then
297
 
                ssh_fingerprint="${ssh_fingerprint#localhost }"
298
 
                break
299
 
            fi
300
 
        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 }"
301
295
    fi
302
296
    
303
297
    # Import key into temporary key rings
310
304
    
311
305
    # Get fingerprint of key
312
306
    FINGERPRINT="`gpg --quiet --batch --no-tty --no-options \
313
 
        --enable-dsa2 --homedir "$RINGDIR" --trust-model always \
 
307
        --enable-dsa2 --homedir \"$RINGDIR\" --trust-model always \
314
308
        --fingerprint --with-colons \
315
309
        | sed --quiet \
316
310
        --expression='/^fpr:/{s/^fpr:.*:\\([0-9A-Z]*\\):\$/\\1/p;q}'`"
369
363
            }
370
364
        }' < "$SECFILE"
371
365
    if [ -n "$ssh_fingerprint" ]; then
372
 
        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"'
373
367
        echo "ssh_fingerprint = ${ssh_fingerprint}"
374
368
    fi
375
369
fi