aboutsummaryrefslogtreecommitdiff
path: root/firma
diff options
context:
space:
mode:
authorrhatto <rhatto>2006-10-11 18:28:37 +0000
committerrhatto <rhatto>2006-10-11 18:28:37 +0000
commitdae6d8df799c9c66d18e6548bc16eb164854582b (patch)
tree15e88c5c0356202afff368f923b03f4883bc600e /firma
parente0f16f447d2bc35c3e025932d5285a6f3f3880bb (diff)
downloadfirma-dae6d8df799c9c66d18e6548bc16eb164854582b.tar.gz
firma-dae6d8df799c9c66d18e6548bc16eb164854582b.tar.bz2
admin via email almost completed
Diffstat (limited to 'firma')
-rwxr-xr-xfirma72
1 files changed, 45 insertions, 27 deletions
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 <file-name> import pubkeys from file
keyserver [server-address] <key-ids> import <key-ids> from <server-address>
"
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