aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhatto <rhatto>2005-08-06 16:03:03 +0000
committerrhatto <rhatto>2005-08-06 16:03:03 +0000
commit54fdfb9aff3ffca5cdd92606804957bc93b9c0f2 (patch)
tree86df9cae63ddf6346915875a53bf0852500ec848
parent2dd5990b8d52a37059cc0c10b7155d6f46bd5595 (diff)
downloadfirma-54fdfb9aff3ffca5cdd92606804957bc93b9c0f2.tar.gz
firma-54fdfb9aff3ffca5cdd92606804957bc93b9c0f2.tar.bz2
mais modificacoes pra usar sendmail
-rwxr-xr-xfirma48
1 files changed, 32 insertions, 16 deletions
diff --git a/firma b/firma
index 2688eea..e86a5e2 100755
--- a/firma
+++ b/firma
@@ -97,11 +97,12 @@ function get_message {
MESSAGE[$n]="$STDIN\n"
((++n))
done
+ echo $n
}
function get_gpg_message {
signal=0
- x=0
+ x=0 ; n=$1
for ((count=0;count<=n;count++)); do
if [[ $signal == "0" ]] && [[ "$(echo "${MESSAGE[$count]}" | grep -v -e "-----BEGIN PGP MESSAGE-----")" == "" ]]; then
GPG_MESSAGE[$x]=${MESSAGE[$count]}
@@ -135,11 +136,8 @@ function message_list {
# compose and send a message to the list
# $1: subscriber email
# sorry no identation :P
+n=0
echo "$PASSWD
-From: $LISTNAME
-To: $1
-Subject: none
-
Message from: $FROM
Subject: $SUBJECT
$DATE
@@ -147,17 +145,25 @@ $DATE
$(get_gpg_stderr | grep -F 'gpg: Signature made')
$(get_gpg_stderr | grep -F 'gpg: Good signature from')
-$(echo -e "$PASSWD\n${GPG_MESSAGE[@]}" | $GPGDECRYPT 2> /dev/null)" | sed -e 's/=20$//' | $GPGENCRYPT $1 | $MAIL $MAIL_ARGS
+$(echo -e "$PASSWD\n${GPG_MESSAGE[@]}" | $GPGDECRYPT 2> /dev/null)" | sed -e 's/=20$//' | $GPGENCRYPT $1 | while read STDIN; do
+ LIST_MESSAGE[$n]="$STDIN\n"
+ ((++n))
+done
+
+# send the message to the list
+echo "From: $LISTNAME
+To: $1
+Subject: none
+
+$(echo -e "${LIST_MESSAGE[@]}")" | $MAIL $MAIL_ARGS
+
}
function message_list_error {
# compose and send an error message
# sorry no identation :P
+n=0
echo "$PASSWD
-From: $LISTNAME
-To: $1
-Subject: none
-
Message from: $FROM
Subject: [BAD SIGNATURE] $SUBJECT
$DATE
@@ -165,15 +171,25 @@ $DATE
$(get_gpg_stderr | grep -F 'gpg: Signature made')
$(get_gpg_stderr | grep -F 'gpg: BAD signature from')
-$(echo -e "$PASSWD\n${GPG_MESSAGE[@]}" | $GPGDECRYPT 2> /dev/null)" | sed -e 's/=20$//' | $GPGENCRYPT $1 | $MAIL $MAIL_ARGS
+$(echo -e "$PASSWD\n${GPG_MESSAGE[@]}" | $GPGDECRYPT 2> /dev/null)" | sed -e 's/=20$//' | $GPGENCRYPT $1 | while read STDIN; do
+ LIST_MESSAGE[$n]="$STDIN\n"
+ ((++n))
+done
+
+# send the message to the list
+echo "From: $LISTNAME
+To: $1
+Subject: none
+
+$(echo -e "${LIST_MESSAGE[@]}")" | $MAIL $MAIL_ARGS
+
}
function message_list_return {
# send a bounce message
# $1: sender email (usually $FROMADD)
# sorry no identation :P
-echo "
-From: $LISTNAME
+echo "From: $LISTNAME
To: $1
Subject: none
@@ -187,15 +203,15 @@ $DATE
you have any questions. ]
--
- firma v$VERSION" | $MAIL $MAIL_ARGS
+ firma v$VERSION" | $MAIL $MAIL_ARGS
}
function process_message {
# process a message sent to the list
- get_message
+ lines=$(get_message)
get_message_headers
- get_gpg_message
+ get_gpg_message $lines
# if signature is Good, encrypt and send it for each list subscriber
# todo: declare a function to decrypt, re-encrypt and send the list messages