]> gitweb.fluxo.info Git - firma.git/commitdiff
mais modificacoes pra usar sendmail
authorrhatto <rhatto>
Sat, 6 Aug 2005 16:03:03 +0000 (16:03 +0000)
committerrhatto <rhatto>
Sat, 6 Aug 2005 16:03:03 +0000 (16:03 +0000)
firma

diff --git a/firma b/firma
index 2688eeabd0e25ff6d3c8de64682fff64b0d0c021..e86a5e24cf39f771157dfa263da2dc7f577c6b58 100755 (executable)
--- 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