/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: 2014-01-06 15:56:54 UTC
  • Revision ID: teddy@recompile.se-20140106155654-urx23ytuvy0nxzwp
Update init script to modern standards.

* init.d-mandos (status): Moved to standard location.  Re-added use of
                          -p switch compared to skeleton file.
  (*): Update message to include "status".

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-2013 Teddy Hogeborn
 
6
# Copyright © 2008-2013 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.9"
 
24
VERSION="1.6.2"
25
25
 
26
26
KEYDIR="/etc/keys/mandos"
27
27
KEYTYPE=RSA
33
33
KEYCOMMENT=""
34
34
KEYEXPIRE=0
35
35
FORCE=no
36
 
SSH=yes
37
36
KEYCOMMENT_ORIG="$KEYCOMMENT"
38
37
mode=keygen
39
38
 
42
41
fi
43
42
 
44
43
# Parse options
45
 
TEMP=`getopt --options vhpF:d:t:l:s:L:n:e:c:x:fS \
46
 
    --longoptions version,help,password,passfile:,dir:,type:,length:,subtype:,sublength:,name:,email:,comment:,expire:,force,no-ssh \
 
44
TEMP=`getopt --options vhpF:d:t:l:s:L:n:e:c:x:f \
 
45
    --longoptions version,help,password,passfile:,dir:,type:,length:,subtype:,sublength:,name:,email:,comment:,expire:,force \
47
46
    --name "$0" -- "$@"`
48
47
 
49
48
help(){
86
85
                        Encrypt a password from FILE using the key in
87
86
                        the key directory.  All options other than
88
87
                        --dir and --name are ignored.
89
 
  -S, --no-ssh          Don't get SSH key or set "checker" option.
90
88
EOF
91
89
}
92
90
 
105
103
        -c|--comment) KEYCOMMENT="$2"; shift 2;;
106
104
        -x|--expire) KEYEXPIRE="$2"; shift 2;;
107
105
        -f|--force) FORCE=yes; shift;;
108
 
        -S|--no-ssh) SSH=no; shift;;
109
106
        -v|--version) echo "$0 $VERSION"; exit;;
110
107
        -h|--help) help; exit;;
111
108
        --) shift; break;;
191
188
trap "
192
189
set +e; \
193
190
test -n \"$SECFILE\" && shred --remove \"$SECFILE\"; \
194
 
shred --remove \"$RINGDIR\"/sec* 2>/dev/null;
 
191
shred --remove \"$RINGDIR\"/sec*;
195
192
test -n \"$BATCHFILE\" && rm --force \"$BATCHFILE\"; \
196
193
rm --recursive --force \"$RINGDIR\";
197
194
tty --quiet && stty echo; \
231
228
        date
232
229
    fi
233
230
    
234
 
    # Make sure trustdb.gpg exists;
235
 
    # this is a workaround for Debian bug #737128
236
 
    gpg --quiet --batch --no-tty --no-options --enable-dsa2 \
237
 
        --homedir "$RINGDIR" \
238
 
        --import-ownertrust < /dev/null
239
231
    # Generate a new key in the key rings
240
232
    gpg --quiet --batch --no-tty --no-options --enable-dsa2 \
241
233
        --homedir "$RINGDIR" --trust-model always \
277
269
fi
278
270
 
279
271
if [ "$mode" = password ]; then
280
 
    
281
 
    # Make SSH be 0 or 1
282
 
    case "$SSH" in
283
 
        [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]) SSH=1;;
284
 
        [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|*) SSH=0;;
285
 
    esac
286
 
    
287
 
    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 }"
295
 
    fi
296
 
    
297
272
    # Import key into temporary key rings
298
273
    gpg --quiet --batch --no-tty --no-options --enable-dsa2 \
299
274
        --homedir "$RINGDIR" --trust-model always --armor \
362
337
                /^[^-]/s/^/    /p
363
338
            }
364
339
        }' < "$SECFILE"
365
 
    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"'
367
 
        echo "ssh_fingerprint = ${ssh_fingerprint}"
368
 
    fi
369
340
fi
370
341
 
371
342
trap - EXIT
376
347
    shred --remove "$SECFILE"
377
348
fi
378
349
# Remove the key rings
379
 
shred --remove "$RINGDIR"/sec* 2>/dev/null
 
350
shred --remove "$RINGDIR"/sec*
380
351
rm --recursive --force "$RINGDIR"