rp

simple email tools
git clone https://git.parazyd.org/rp
Log | Files | Refs | README | LICENSE

commit 64932cef15feaccdbaf92bb1fb612c82ac5440cc
parent 2d68552c6365774e182814a27209ecbf3d1b3bdc
Author: parazyd <parazyd@dyne.org>
Date:   Thu,  1 Mar 2018 14:57:34 +0100

gpg is working now.

Diffstat:
Mbin/rpcomp | 2+-
Abin/rpgenc | 45+++++++++++++++++++++++++++++++++++++++++++++
Dbin/rpgpgenc | 44--------------------------------------------
Dbin/rpgpgsign | 41-----------------------------------------
Abin/rpgsign | 44++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 90 insertions(+), 86 deletions(-)

diff --git a/bin/rpcomp b/bin/rpcomp @@ -16,7 +16,7 @@ Content-Type: text/plain; charset=\"utf-8\"\n" \ "$(rpcfg -v defaultfrom)" \ "$to" -printf "\nText\n\n" +printf "\n\nText\n\n" [ -e "$HOME/.signature" ] && { printf -- "-- \n" diff --git a/bin/rpgenc b/bin/rpgenc @@ -0,0 +1,45 @@ +#!/bin/sh + +boundary="FuNkAdEliC" +encboundary="enc$boundary" + +email="$(cat)" + +if [ $# -gt 0 ]; then + to="-r $1" +else + to="-r $(echo "$email" | rpheaders To)" +fi + +headers="$(printf "$email" | \ + sed '/^$/q' | \ + sed '/^\r/q' | \ + sed "/Content-Type: /d" | \ + sed "/^ /d" | \ + head -n-1)" + +emabody="$(printf "$email" | sed '1,/^$/d' )" +[ -n "$emabody" ] || \ +emabody="$(printf "$email" | sed '1,/^\r/d' )" + + +encr="$(echo "$emabody" | sed 's/$/\r/' | gpg -eaq --batch $to)" + +cat <<EOF +$headers +Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; + boundary="$encboundary" + + +--$encboundary +Content-Type: application/pgp-encrypted + +Version: 1 + +--$encboundary +Content-Type: application/octet-stream + +$encr + +--$encboundary-- +EOF diff --git a/bin/rpgpgenc b/bin/rpgpgenc @@ -1,44 +0,0 @@ -#!/bin/sh - -boundary="FuNkAdEliC" -_cd="Content-Disposition: inline" - -email="$(cat)" - -if [ $# -gt 0 ]; then - to="-r $1" -else - to="$(echo "$email" | rpheaders To)" - to="-r $to" -fi - -headers="$(printf "$email" | sed '/^$/q' | sed "s/Content-Type.*/$_cd/")" -emabody="$(printf "$email" | sed '1,/^$/d' )" # | sed 's/ $/=20/')" - -encr="$(cat <<EOM | sed 's/$/\r/' | gpg -eaq $to)" - -$emabody -EOM - - -cat <<EOF | sed 's/$/\r/' -$headers -Content-Type: multipart/encrypted; boundary="$boundary"; - protocol="application/pgp-encrypted" -Content-Disposition: inline - - ---$boundary -Content-Type: application/pgp-encrypted -Content-Disposition: attachment - -Version: 1 - ---$boundary -Content-Type: application/octet-stream -Content-Disposition: attachment; filename="msg.asc" - -$encr - ---$boundary -EOF diff --git a/bin/rpgpgsign b/bin/rpgpgsign @@ -1,41 +0,0 @@ -#!/bin/sh - -boundary="FuNkAdEliC" -_cd="Content-Disposition: inline" - -email="$(cat)" - -headers="$(printf "$email" | sed '/^$/q' | sed "s/Content-Type.*/$_cd/")" -emabody="$(printf "$email" | sed '1,/^$/d' | sed 's/ $/=20/')" - -signature="$(cat <<EOM | sed 's/$/\r/' | gpg -baq --batch)" -Content-Type: text/plain; charset=utf-8 -$_cd -Content-Transfer-Encoding: quoted-printable - -$emabody -EOM - - -cat <<EOF | sed 's/$/\r/' -$headers -Content-Type: multipart/signed; micalg=pgp-sha512; - protocol="application/pgp-signature"; boundary="$boundary" -Content-Disposition: inline - - ---$boundary -Content-Type: text/plain; charset=utf-8 -$_cd -Content-Transfer-Encoding: quoted-printable - -$emabody - ---$boundary -Content-Type: application/pgp-signature; name="signature.asc" -Content-Description: Digital signature - -$signature - ---$boundary -EOF diff --git a/bin/rpgsign b/bin/rpgsign @@ -0,0 +1,44 @@ +#!/bin/sh + +boundary="FuNkAdEliC" + +email="$(cat)" + +case "$1" in + -e) + # prepare for encryption + enc=1 + ;; +esac + +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