From: markus schnalke Date: Fri, 22 Apr 2016 10:46:33 +0000 (+0200) Subject: mhsign: Fix key lookup of aliases when encrypting X-Git-Tag: mmh-0.3~40 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=bd02210b2be64956a952f925a2dcd35fb42f6136;p=mmh mhsign: Fix key lookup of aliases when encrypting Now mhsign can handle addresses that contain whitespace (e.g. ``markus schnalke '') in aliases. The helper tool ap(1) is used to extract the actual addresses. --- diff --git a/test/tests/mhsign/test-mhsign b/test/tests/mhsign/test-mhsign new file mode 100755 index 0000000..7654e5f --- /dev/null +++ b/test/tests/mhsign/test-mhsign @@ -0,0 +1,77 @@ +#!/bin/sh +###################################################### +# +# Test mhsign (correct alias expansion with -enc) +# +###################################################### + +. "$MH_TEST_COMMON" + + +# setup some aliases + +cat >"$MH_TEST_DIR/.mmh/aliases" < +a4: Unknown Person +a5: "Unknown Person" +a6: (Unknown) (Person) +a7: Unknown , unknownperson@example.org +! +cat >>"$MH_TEST_DIR/.mmh/profile" <"$MH_TEST_DIR/bin/gpg" +chmod +x "$MH_TEST_DIR/bin/gpg" +export MMHPGPKEY=0x12345678 + + +# now test it + +draft=`mhpath +drafts b` +cat >"$draft" < +Unknown Person +"Unknown Person" +(Unknown) (Person) +Unknown +unknownperson@example.org +! + +runandcheck "mhsign -enc $draft" < +Could not find key for +Could not find key for +Could not find key for +Could not find key for +Could not find key for +Could not find key for +Could not find key for +! diff --git a/uip/Makefile.in b/uip/Makefile.in index be02b67..6b7a570 100644 --- a/uip/Makefile.in +++ b/uip/Makefile.in @@ -130,7 +130,7 @@ mmhwrap: mmhwrap.sh chmod +x mmhwrap mhsign: mhsign.sh - cp $(srcdir)/mhsign.sh mhsign + sed "s,%libdir%,"$(libdir)"," $(srcdir)/mhsign.sh >mhsign chmod +x mhsign mhpgp: mhpgp.sh diff --git a/uip/mhsign.sh b/uip/mhsign.sh index 038052b..17b7489 100755 --- a/uip/mhsign.sh +++ b/uip/mhsign.sh @@ -108,14 +108,17 @@ lookupkeys() { echo "Encryption is not supported for BCCs" >&2 return 1 fi - - for i in `whom -ali -tocc -nobcc "$1"` ; do + + whom -ali -tocc -nobcc "$1" | while read i ; do case "$i" in '|'*) echo "Ignoring pipe address" >&2 continue ;; *@*) ;; - *) i="$i@`hostname -f`" ;; + *) a="$i@`hostname -f`" ;; esac + # extract the actual address + format='%<{error}%{error}: %{text}%|%(addr{text})%>' + i=`%libdir%/ap -form "=$format" "$i"` if k=`lookupkeyfile "$i"` ; then KL="$KL $k" elif k=`lookupkeyring "$i"` ; then