Add scripts from mblaze/contrib
Directly from tag v6.0, e0733f187b34b21fa8335b9914c29a28fa2e856d.
This commit is contained in:
parent
69e00b6f58
commit
eb605487e5
5 changed files with 111 additions and 2 deletions
34
mblaze/contrib/mverify
Executable file
34
mblaze/contrib/mverify
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
# mverify MSG - verify a OpenPGP or SMIME message
|
||||
|
||||
# Needs gpg2 (for OpenPGP) and openssl (for SMIME).
|
||||
|
||||
[ "$#" -eq 0 ] && set -- .
|
||||
|
||||
mshow -t "$1" | DOS2UNIX='/
$/!s/$/
/' awk -v "msg=$1" '
|
||||
{ match($0, "^ *"); indent = RLENGTH }
|
||||
$2 == "text/plain" { plain++ }
|
||||
$2 == "multipart/signed" { signed = 0+$1; si = indent; next }
|
||||
signed && !content && indent == si+2 { content = 0+$1; next }
|
||||
signed && content && !signature && indent == si+2 { signature = 0+$1; type = $2 }
|
||||
function q(a) { gsub("\\47", "\47\\\47\47", a); return "\47"a"\47" }
|
||||
END {
|
||||
if (type == "" && plain) { // guess plain text armored signature
|
||||
exit(system("mshow -r " q(msg) " | gpg2 --verify"));
|
||||
} else if (type == "") {
|
||||
print("No signature found.")
|
||||
exit(100)
|
||||
} else if (type == "application/pgp-signature") {
|
||||
exit(system("mshow -r -O " q(msg) " " q(content) \
|
||||
" | sed $DOS2UNIX | " \
|
||||
" { mshow -O " q(msg) " " q(signature) \
|
||||
" | gpg2 --verify - /dev/fd/3; } 3<&0"))
|
||||
} else if (type == "application/pkcs7-signature") {
|
||||
exit(system("mshow -r -O " q(msg) " " q(signed) \
|
||||
" | openssl smime -verify"))
|
||||
} else {
|
||||
print("Cannot verify signatures of type " type ".")
|
||||
exit(2)
|
||||
}
|
||||
}
|
||||
'
|
Loading…
Add table
Add a link
Reference in a new issue