From dae6d8df799c9c66d18e6548bc16eb164854582b Mon Sep 17 00:00:00 2001 From: rhatto Date: Wed, 11 Oct 2006 18:28:37 +0000 Subject: admin via email almost completed --- firma | 72 ++++++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 27 deletions(-) (limited to 'firma') diff --git a/firma b/firma index cf9eb57..f8805f2 100755 --- a/firma +++ b/firma @@ -797,7 +797,7 @@ function ProcessMessage { return_code=1 fi elif [ "$MODE" == "admin-non-interactive" ]; then - EmailAdminTask + EmailListAdministration fi # else, if the message was correctly encrypted but its signature is invalid, @@ -1510,32 +1510,40 @@ function SubscribeUsers { # 1 on failure #------------------------------------------------------------- - # TODO: add support to admin via email - local -i return_code=0 local keyserver local method if [ "$1" == "help" ]; then - echo " + AdminLog " help show this help stdin waits for key material from stdin file import pubkeys from file keyserver [server-address] import from " elif [ "$1" == "stdin" ]; then - echo "Please enter the key material here, finninshing with Ctrl-D sequence..." - $GPG_NOBATCH --import + if [ "$MODE" == "admin-interactive" ]; then + echo "Please enter the key material here, finninshing with Ctrl-D sequence..." + $GPG_NOBATCH --import + else + AdminLog "subscribe: stdin option only valid in the interactive (command-line) mode" + return_code=1 + fi elif [ "$1" == "file" ]; then - if [ ! -z "$2" ]; then - if [ -f "$2" ]; then - $GPG --import < $2 + if [ "$MODE" == "admin-interactive" ]; then + if [ ! -z "$2" ]; then + if [ -f "$2" ]; then + $GPG --import < $2 + else + echo >&2 "subscribe: cant add subscribers from $1: no such file or directory" + return_code=1 + fi else - echo >&2 "subscribe: cant add subscribers from $1: no such file or directory" + echo >&2 "subscribe: missing parameters: subscribe file requires a file name" return_code=1 fi else - echo >&2 "subscribe: missing parameters: subscribe file requires a file name" + AdminLog "subscribe: file option only valid in the interactive (command-line) mode" return_code=1 fi elif [ "$1" == "keyserver" ]; then @@ -1551,19 +1559,26 @@ function SubscribeUsers { fi fi if CheckValidEmail $2; then - method="--search-keys" + if [ "$MODE" == "admin-interactive" ]; then + method="--search-keys" + else + AdminLog "subscribe: please use a keyid instead of an email when in the non-interactive admin mode" + return_code=1 + fi else method="--recv-keys" fi - shift - $GPG_NOBATCH --keyserver $keyserver $method $* - return_code=$? + if [ "$return_code" == "0" ]; then + shift + $GPG_NOBATCH --keyserver $keyserver $method $* + return_code=$? + fi else - echo >&2 "subscribe: missing parameters: type subscribe help" + AdminLog "subscribe: missing parameters: type subscribe help" return_code=1 fi else - echo >&2 "subscribe: wrong option: type subscribe help" + AdminLog "subscribe: wrong option: type subscribe help" return_code=1 fi @@ -1691,8 +1706,8 @@ function GetSubscribersInfo { local output if [ "$1" == "help" ]; then - AdminLog "usage: info [all|email|help]" - AdminLog "supported arguments: all (for all subscribers) or a space-separated subscriber emails." + AdminLog "usage: info [all|emails|help]" + AdminLog "supported arguments: all (for all subscribers) or a space-separated subscribers' emails." return 0 elif [ "$1" == "all" ]; then GetSubscribersList @@ -1780,7 +1795,7 @@ function AdminLog { } -function EmailAdminTask { +function EmailListAdministration { #------------------------------------------------------------- # parse and execute admin tasks via email # @@ -1792,7 +1807,7 @@ function EmailAdminTask { local -i return_code=0 local sender found - local command_list + local command found=0 for sender in $LIST_ADMIN; do @@ -1804,10 +1819,13 @@ function EmailAdminTask { if [ "$found" == "1" ]; then # message was sent by an admin #+then, parse and process admin tasks - # TODO: - parse commands - # TODO: - call admin functions - # TODO: - email result back to sender - command_list="`echo $DECRYPTED_MESSAGE`" + echo $DECRYPTED_MESSAGE | while read command; do + AdminLog "Command> $command" + ListAdministration $command + done + # TODO: send encrypted + MESSAGE_BODY="$ADMIN_MESSAGE" + ComposeAndSendBounceMessage else # message was sent by a normal subscriber # this is the body of the message to be sent, so no indentation here @@ -1931,7 +1949,7 @@ FUNCTIONS=" FixOwnership RandomString AdminLog - EmailAdminTask" + EmailListAdministration" for VAR in $GLOBAL_VARS; do declare $VAR @@ -2044,7 +2062,7 @@ case $# in ;; -e|--email-admin-task) MODE="admin-non-interactive" - EmailAdminTask + EmailListAdministration EXIT_CODE=$? ;; # end case #3 -- cgit v1.2.3