commit 2991db784849bf0d8cb3eea6580368e9f40654dd parent ff87e0f95666f2fc496459a183ebd22969e229f8 Author: parazyd <parazyd@dyne.org> Date: Sat, 28 Mar 2020 21:53:54 +0100 Rework rpsign. It now signs inline. Note that it will not sign attachments, just the initial text, and should always be ran with pipe input from rpcomp. Diffstat:
M | bin/rpsign | | | 63 | ++++----------------------------------------------------------- |
1 file changed, 4 insertions(+), 59 deletions(-)
diff --git a/bin/rpsign b/bin/rpsign @@ -1,63 +1,8 @@ #!/bin/sh -# -# Copy me if you can -# by parazyd -# - -usage() { - cat <<EOF -* Usage: $(basename $0) [-e] < email - -e: Prepare email for encryption -EOF - exit 1 -} - -while getopts "eh" opt; do - case "$opt" in - e) - # Prepare for encryption - enc=1 - ;; - *) - usage - ;; - esac -done - - -boundary="$(rputil -e genmimeb)" email="$(cat)" +email_headers="$(printf "%s" "$email" | sed '/^$/q')" +email_body="$(printf "%s" "$email" | sed '1,/^$/d')" -headers="$(echo "$email" | sed '/^$/q' | sed '/Content-Type: /d')" -emabody="$(echo "$email" | sed '1,/^$/d')" - -tosign="$(cat <<EOM -Content-Type: text/plain; charset=utf-8 -Content-Transfer-Encoding: quoted-printable - -$emabody -EOM -)" - -signature="$(echo "$tosign" | sed 's/$/\r/' | gpg -baq --batch)" - -# We need a newline to conform with rfc3156 -# TODO; remove -e flag and make detection automagic. -[ -n "$enc" ] && headers="$headers\\n" - -cat <<EOM -$headers -Content-Type: multipart/signed; micalg=pgp-sha512; - protocol="application/pgp-signature"; boundary="$boundary" - ---$boundary -$tosign - ---$boundary -Content-Type: application/pgp-signature - -$signature - ---$boundary-- -EOM +printf "%s\n\n" "$email_headers" +printf "%s\n" "$email_body" | gpg -q --batch --clearsign