/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:37:28 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080905183728-l0m8v3vqa302uwrw
* mandos (main): Use EAFP with pidfile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
        [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|*) FORCE=0;;
149
149
    esac
150
150
    
151
 
    if [ \( -e "$SECKEYFILE" -o -e "$PUBKEYFILE" \) \
152
 
        -a "$FORCE" -eq 0 ]; then
 
151
    if { [ -e "$SECKEYFILE" ] || [ -e "$PUBKEYFILE" ]; } \
 
152
        && [ "$FORCE" -eq 0 ]; then
153
153
        echo "Refusing to overwrite old key files; use --force" >&2
154
154
        exit 1
155
155
    fi
184
184
stty echo; \
185
185
" EXIT
186
186
 
187
 
umask 077
 
187
umask 027
188
188
 
189
189
if [ "$mode" = keygen ]; then
190
190
    # Create batch file for GnuPG
254
254
    FINGERPRINT="`gpg --quiet --batch --no-tty --no-options \
255
255
        --enable-dsa2 --homedir \"$RINGDIR\" --trust-model always \
256
256
        --fingerprint --with-colons \
257
 
        | sed --quiet \
258
 
        --expression='/^fpr:/{s/^fpr:.*:\\([0-9A-Z]*\\):\$/\\1/p;q}'`"
 
257
        | sed -n -e '/^fpr:/{s/^fpr:.*:\\([0-9A-Z]*\\):\$/\\1/p;q}'`"
259
258
    
260
259
    test -n "$FINGERPRINT"
261
260
    
263
262
    
264
263
    stty -echo
265
264
    echo -n "Enter passphrase: " >&2
266
 
    head --lines=1 | tr --delete '\n' \
 
265
    sed -e '1q' \
267
266
        | gpg --quiet --batch --no-tty --no-options --enable-dsa2 \
268
267
        --homedir "$RINGDIR" --trust-model always --armor --encrypt \
269
268
        --recipient "$FINGERPRINT" --comment "$FILECOMMENT" \
277
276
        fingerprint = $FINGERPRINT
278
277
        secret =
279
278
EOF
280
 
    sed --quiet --expression='
 
279
    sed -n -e '
281
280
        /^-----BEGIN PGP MESSAGE-----$/,/^-----END PGP MESSAGE-----$/{
282
281
            /^$/,${
283
282
                # Remove 24-bit Radix-64 checksum