aboutsummaryrefslogtreecommitdiff
path: root/misc/poc/firma-0.1.5
diff options
context:
space:
mode:
Diffstat (limited to 'misc/poc/firma-0.1.5')
-rwxr-xr-xmisc/poc/firma-0.1.557
1 files changed, 57 insertions, 0 deletions
diff --git a/misc/poc/firma-0.1.5 b/misc/poc/firma-0.1.5
new file mode 100755
index 0000000..029a09d
--- /dev/null
+++ b/misc/poc/firma-0.1.5
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# firma v0.2: simple encrypted mailing list aliases
+# feedback: rhatto@riseup.net | GPL
+#
+# list configuration is passed through a config file,
+# where you put PARAMETER=value (whithout spaces)
+#
+# MAIL= path for mail program
+# GPG= path for gnupg binary
+# TMP= where you want the temp files
+# LISTNAME= list email
+# GPGDIR= gpg dir for the lists' keyring
+# PASSWD= passwd for the lists' keyring
+# FOOTER= message footer
+
+# eval the config file
+source $1
+
+GPGCOMMAND="$GPG -q --homedir $GPGDIR"
+GPGLIST="$GPGCOMMAND --list-keys"
+GPGDECRYPT="$GPGCOMMAND --decrypt"
+GPGENCRYPT="$GPGCOMMAND --always-trust -e -s -a -r"
+
+rm $TMP $TMP.gpg
+touch $TMP; chmod 600 $TMP;
+touch $TMP.gpg; chmod 600 $TMP.gpg;
+
+# todo: use an array
+while read STDIN; do
+ echo $STDIN >> $TMP
+done
+
+# get the headers
+FROM=$(grep -m 1 ^From: $TMP | cut -f 2 -d :)
+DATE=$(grep -m 1 ^Date: $TMP)
+SUBJECT=$(grep -m 1 ^Subject: $TMP)
+
+# detect the encrypted message
+sed -n '/-----BEGIN PGP MESSAGE-----/,/-----END PGP MESSAGE-----/p' $TMP >> $TMP.gpg
+
+# encrypting and sending for each recipient on the list
+for EMAIL in $($GPGLIST | grep pub | cut -d "<" -f 2 | sed -e 's/>//' | grep @ | grep -v $LISTNAME); do
+
+ echo "$PASSWD
+ Message from: $FROM
+ $SUBJECT
+ $DATE
+
+ $(echo "$PASSWD" | $GPGDECRYPT $TMP.gpg)
+
+ ---
+ $FOOTER " | sed -e 's/=20$//' | $GPGENCRYPT $EMAIL | $MAIL -r $LISTNAME $EMAIL
+
+done
+
+rm $TMP $TMP.gpg