]> gitweb.fluxo.info Git - firma.git/commitdiff
started to code EmailAdminTask
authorrhatto <rhatto>
Tue, 10 Oct 2006 20:42:14 +0000 (20:42 +0000)
committerrhatto <rhatto>
Tue, 10 Oct 2006 20:42:14 +0000 (20:42 +0000)
firma

diff --git a/firma b/firma
index 18264fe7df8bd63cac60fcccdfa5a777737dafb7..90bf9d4a35501f3c5f4dc49e3731ac11db3fed46 100755 (executable)
--- a/firma
+++ b/firma
@@ -780,7 +780,7 @@ function ProcessMessage {
 
         GetSenderAddress
 
-        if [[ -n $(echo $LIST_ADMINS) || -n "$SENDER_ADDRESS" ]]; then
+        if [[ -n $(echo $LIST_ADMIN) || -n "$SENDER_ADDRESS" ]]; then
           ComposeAndSendWarningMessage
         fi
 
@@ -1750,7 +1750,8 @@ function EmailAdminTask {
   # parse and execute admin tasks via email
   #
   # parameter(s): none
-  # depends on function(s): none
+  # depends on function(s): GetMessage, GetGpgMessage, GetSubscribersList,
+  #                         GetSenderAddress
   # returns: 0 on success  :)
   #          1 on failure  :/
   #-------------------------------------------------------------
@@ -1762,8 +1763,43 @@ function EmailAdminTask {
   #       - call admin functions
 
   local -i return_code=0
+  local sender found
+
   ADMIN_MODE="non-interactive"
 
+  #TODO: else cases
+  # try to read message from STDIN
+  if GetMessage; then
+
+    # check if the message was encrypted
+    if GetGpgMessage; then
+
+      # if it was, parse gpg decrypt STDERR to decide what to do next
+      ParseGpgDecryptStderr
+
+      # if the message was encrypted with the list's public key and
+      #+if the message signature is valid
+      if [[ $ENCRYPTED_TO_LIST == 1 && $GOOD_SIGNATURE == 1 ]]; then
+        GetSenderAddress
+        found=0
+        for sender in $LIST_ADMIN; do
+          if [ "$sender" == "$SENDER_ADDRESS" ]; then
+            found=1
+            break
+          fi
+        done
+        # TODO: check if the signature was made with the sender address pubkey
+        if [ "$found" == "1" ]; then
+          # message was sent by an admin
+          true
+        else
+          # message was sent by a normal subscriber
+          false
+        fi
+      fi
+    fi
+  fi
+
   return $return_code
 }