aboutsummaryrefslogtreecommitdiff
path: root/firma
diff options
context:
space:
mode:
authorrhatto <rhatto>2006-10-09 17:25:28 +0000
committerrhatto <rhatto>2006-10-09 17:25:28 +0000
commit40a70afaf7a64548ffd363e7a50461fd0b309ea9 (patch)
tree724f895d96d1a8eb6ea773ce35f1fdc77364c5b5 /firma
parent5b1cf4665213bb52d3cff3bd8ad32d1346228110 (diff)
downloadfirma-40a70afaf7a64548ffd363e7a50461fd0b309ea9.tar.gz
firma-40a70afaf7a64548ffd363e7a50461fd0b309ea9.tar.bz2
added admin info command
Diffstat (limited to 'firma')
-rwxr-xr-xfirma137
1 files changed, 101 insertions, 36 deletions
diff --git a/firma b/firma
index 4be8c03..5fc1f01 100755
--- a/firma
+++ b/firma
@@ -955,7 +955,8 @@ function ListAdministration {
quit quit this prompt
help show this help
list show list subscribers
- sendkey <subscriber> send list pubkey to subscriber
+ info EMAIL-ADDRESS show info of a given subscriber
+ sendkey SUBSCRIBER send list pubkey to subscriber
subscribe [..] subscribe users ('subscribe help' for options)
use EMAIL-ADDRESS use the given address for message delivery instead
of the primary address on key
@@ -974,15 +975,19 @@ function ListAdministration {
return_code=1
;;
list)
- # use GetSubscribersList instead or leave a more verbose listing?
- $GPG_LIST_KEYS
+ GetSubscribersList
+ echo $SUBSCRIBERS_LIST
;;
subscribe)
echo >&2 "$1: missing arguments (try \"subscribe help\")"
return_code=1
;;
sendkey)
- echo >&2 "$1: missing argument: subsciber email address."
+ echo >&2 "$1: missing arguments (try \"sendkey help\")."
+ return_code=1
+ ;;
+ info)
+ echo >&2 "$1: missing arguments (try \"info help\")."
return_code=1
;;
*)
@@ -1003,13 +1008,8 @@ function ListAdministration {
fi
;;
unsub)
- # check if argument is an email address
- if CheckValidEmail $2; then
- UnsubscribeUser $2
- else
- echo >&2 "$1: invalid argument -- $2 (try \"help\")"
- return_code=1
- fi
+ UnsubscribeUser $2
+ return_code=$?
;;
subscribe)
shift
@@ -1017,7 +1017,13 @@ function ListAdministration {
return_code=$?
;;
sendkey)
- SendListPubkey $2
+ shift
+ SendListPubkey $*
+ return_code=$?
+ ;;
+ info)
+ shift
+ GetSubscribersInfo $*
return_code=$?
;;
help|quit)
@@ -1211,8 +1217,12 @@ function UnsubscribeUser {
local -i return_code=0
local keyid="$($GPG_LIST_KEYS --with-fingerprint $1 2> /dev/null | grep ^fpr | cut -d : -f 10)"
+ # check if its a valid email
+ if ! ValidEmail $1; then
+ echo >&2 "unsub: \"$1\" is not an email address."
+ return_code=1
# check if user is trying to unsubscribe the list key
- if [ "$1" == "$LIST_ADDRESS" ]; then
+ elif [ "$1" == "$LIST_ADDRESS" ]; then
echo >&2 "unsub: can't delete the list pubkey."
return_code=1
# check if supplied address is associated with a public key
@@ -1322,45 +1332,98 @@ function SubscribeUsers {
function SendListPubkey {
#-------------------------------------------------------------
- # send list pubkey to a given subscriber
+ # send list pubkey to a given subscriber list
#
- # parameter(s): subscriber email
+ # parameter(s): subscribers' emails
# depends on function(s): GetMessage, GetSenderAddress, AssembleMessage
# returns: 0 on success
# 1 on failure
#-------------------------------------------------------------
- local keyid="$($GPG_LIST_KEYS --with-fingerprint $1 2> /dev/null | grep ^fpr | cut -d : -f 10)"
+ local key
+ local keys
+ local keyid
- if [ -z "$1" ]; then
- echo >&2 "sendkey: missing argument: subscriber email address."
- return 1
- elif ! CheckValidEmail $1; then
- echo >&2 "sendkey: \"$1\" is not an email address."
- return 1
- elif [[ -z "$($GPG_LIST_KEYS --fixed-list-mode "<$1>" 2> /dev/null | grep -v '^tru:')" ]]; then
- # check if supplied address is associated with a public key
- echo >&2 "sendkey: \"$1\" is not associated with any public key on this keyring."
- return 1
+ if [ "$1" == "help" ]; then
+ echo "usage: sendkey [all|email|help]"
+ echo "supported arguments: all (for all subscribers) or a space-separated subscriber emails."
+ return 0
+ elif [ "$1" == "all" ]; then
+ GetSubscribersList
+ keys="$SUBSCRIBERS_LIST"
+ else
+ keys="$*"
fi
- recipients="$1"
+ for key in $keys; do
+ keyid="$($GPG_LIST_KEYS --with-fingerprint $1 2> /dev/null | grep ^fpr | cut -d : -f 10)"
+
+ if [ -z "$key" ]; then
+ echo >&2 "sendkey: missing argument: subscriber email address."
+ return 1
+ elif ! CheckValidEmail $key; then
+ echo >&2 "sendkey: \"$key\" is not an email address."
+ return 1
+ elif [[ -z "$($GPG_LIST_KEYS --fixed-list-mode "<$key>" 2> /dev/null | grep -v '^tru:')" ]]; then
+ # check if supplied address is associated with a public key
+ echo >&2 "sendkey: \"$key\" is not associated with any public key on this keyring."
+ return 1
+ fi
- # these are the headers of the message to be sent, so no indentation here
- MESSAGE_HEADERS="\
+ recipients="$key"
+
+ # these are the headers of the message to be sent, so no indentation here
+ MESSAGE_HEADERS="\
From: $LIST_ADDRESS
Subject: List public key for $LIST_ADDRESS
To: $recipients"
- # this is the body of the message to be sent
- MESSAGE_BODY="`$GPG --armor --export $LIST_ADDRESS`"
+ # this is the body of the message to be sent
+ MESSAGE_BODY="`$GPG --armor --export $LIST_ADDRESS`"
- AssembleMessage
+ MESSAGE_BODY="$(
+ echo -e "${PASSPHRASE}\n${MESSAGE_BODY}" | \
+ $GPG_ENCRYPT --recipient $subscriber
+ )"
+
+ AssembleMessage
+
+ # send message
+ echo "$MESSAGE" | $MAIL_AGENT $MAIL_AGENT_ARGS $recipients
+ done
+
+}
- # send message
- echo "$MESSAGE" | $MAIL_AGENT $MAIL_AGENT_ARGS $recipients
- return $?
+function GetSubscribersInfo {
+ #-------------------------------------------------------------
+ # get info on a subscriber pubkey
+ #
+ # parameter(s): subscribers' emails
+ # depends on function(s): none
+ # returns: 0 on success
+ # 1 on failure
+ #-------------------------------------------------------------
+
+ local key
+ local keys
+
+ if [ "$1" == "help" ]; then
+ echo "usage: info [all|email|help]"
+ echo "supported arguments: all (for all subscribers) or a space-separated subscriber emails."
+ return 0
+ elif [ "$1" == "all" ]; then
+ GetSubscribersList
+ keys="$SUBSCRIBERS_LIST"
+ else
+ keys="$*"
+ fi
+
+ for key in keys; do
+ $GPG --list-keys $key
+ done
+
+ return $?
}
#-------------------------------------------------------------
@@ -1429,7 +1492,9 @@ FUNCTIONS="
CheckListPermissions
UnsubscribeUser
LogMessage
- SubscribeUsers"
+ SubscribeUsers
+ SendListPubkey
+ GetSubscriberInfo"
for VAR in $GLOBAL_VARS; do
declare $VAR