/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: 2008-09-05 18:19:52 UTC
  • mfrom: (24.1.91 mandos)
  • Revision ID: teddy@fukt.bsnet.se-20080905181952-qfuwtyvefanh9v3v
* mandos: Open the PID file before daemonizing, but write to it
          afterwards.

* plugin-runner.xml (SECURITY): Improved grammar.

Also merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
KEYCOMMENT_ORIG="$KEYCOMMENT"
36
36
mode=keygen
37
37
 
38
 
if [ ! -d "$KEYDIR" ]; then
39
 
    KEYDIR="/etc/mandos/keys"
40
 
fi
41
 
 
42
38
# Parse options
43
39
TEMP=`getopt --options vhd:t:l:n:e:c:x:f \
44
40
    --longoptions version,help,password,dir:,type:,length:,subtype:,sublength:,name:,email:,comment:,expire:,force \
152
148
        [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|*) FORCE=0;;
153
149
    esac
154
150
    
155
 
    if [ \( -e "$SECKEYFILE" -o -e "$PUBKEYFILE" \) \
156
 
        -a "$FORCE" -eq 0 ]; then
 
151
    if { [ -e "$SECKEYFILE" ] || [ -e "$PUBKEYFILE" ]; } \
 
152
        && [ "$FORCE" -eq 0 ]; then
157
153
        echo "Refusing to overwrite old key files; use --force" >&2
158
154
        exit 1
159
155
    fi
188
184
stty echo; \
189
185
" EXIT
190
186
 
191
 
umask 077
 
187
umask 027
192
188
 
193
189
if [ "$mode" = keygen ]; then
194
190
    # Create batch file for GnuPG
258
254
    FINGERPRINT="`gpg --quiet --batch --no-tty --no-options \
259
255
        --enable-dsa2 --homedir \"$RINGDIR\" --trust-model always \
260
256
        --fingerprint --with-colons \
261
 
        | sed --quiet \
262
 
        --expression='/^fpr:/{s/^fpr:.*:\\([0-9A-Z]*\\):\$/\\1/p;q}'`"
 
257
        | sed -n -e '/^fpr:/{s/^fpr:.*:\\([0-9A-Z]*\\):\$/\\1/p;q}'`"
263
258
    
264
259
    test -n "$FINGERPRINT"
265
260
    
267
262
    
268
263
    stty -echo
269
264
    echo -n "Enter passphrase: " >&2
270
 
    head --lines=1 | tr --delete '\n' \
 
265
    sed -e '1q' \
271
266
        | gpg --quiet --batch --no-tty --no-options --enable-dsa2 \
272
267
        --homedir "$RINGDIR" --trust-model always --armor --encrypt \
273
268
        --recipient "$FINGERPRINT" --comment "$FILECOMMENT" \
281
276
        fingerprint = $FINGERPRINT
282
277
        secret =
283
278
EOF
284
 
    sed --quiet --expression='
 
279
    sed -n -e '
285
280
        /^-----BEGIN PGP MESSAGE-----$/,/^-----END PGP MESSAGE-----$/{
286
281
            /^$/,${
287
282
                # Remove 24-bit Radix-64 checksum