blob: eab39e66cb1fb26c567ce365d2468229ccada7d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/bin/bash
#
# firma v0.1: simple encrypted mailing list aliases
# feedback: rhatto@riseup.net | GPL
#
# list configuration is passed thru the 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
# 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)" | sed -e 's/=20$//' | $GPGENCRYPT $EMAIL | $MAIL -r $LISTNAME $EMAIL
done
rm $TMP $TMP.gpg
|