aboutsummaryrefslogtreecommitdiff
path: root/firma
diff options
context:
space:
mode:
authorrhatto <rhatto>2006-10-09 12:45:06 +0000
committerrhatto <rhatto>2006-10-09 12:45:06 +0000
commitf43eb2af062c46cce0ae9787ccb58599734db0b4 (patch)
treebb1fb6c96f2540a09e62eb88c92011ec9abd8951 /firma
parenta48b214826879150ea874b69dd8739a842e38694 (diff)
downloadfirma-f43eb2af062c46cce0ae9787ccb58599734db0b4.tar.gz
firma-f43eb2af062c46cce0ae9787ccb58599734db0b4.tar.bz2
added function UnsubscribeUser
Diffstat (limited to 'firma')
-rwxr-xr-xfirma46
1 files changed, 42 insertions, 4 deletions
diff --git a/firma b/firma
index 1f75e8a..d676bd6 100755
--- a/firma
+++ b/firma
@@ -934,7 +934,8 @@ function ListAdministration {
quit quit this prompt
help show this help
use EMAIL-ADDRESS use the given address for message delivery instead
- of the primary address on key
+ of the primary address on key
+ unsub EMAIL-ADDRESS unsubscribe an email from the list
"
;;
quit)
@@ -1151,9 +1152,46 @@ function CheckValidEmail {
function UnsubscribeUser {
- # TODO: usubscribe if $1 is subscriber
- # always fix list folder permissions
- true
+ #-------------------------------------------------------------
+ # unsubscribe a user and remove its pubkey from
+ #+the list keyring
+ #
+ # parameter(s): chosen email address
+ # depends on function(s): DeclareGpgVars
+ # returns: 0 on success,
+ # 1 if task can't be executed (public key not found, etc.)
+ #-------------------------------------------------------------
+
+ local key
+ local -i return_code=0
+ local keyid="$($GPG_LIST_KEYS --with-fingerprint $1 2> /dev/null | grep ^fpr | cut -d : -f 10)"
+ local uid_count="$($GPG_LIST_KEYS --fixed-list-mode $keyid 2> /dev/null | grep ^uid | wc -l)"
+ local chosen_uid_number="$($GPG_LIST_KEYS --fixed-list-mode $keyid 2> /dev/null | grep ^uid | grep -ni "$1" | cut -d : -f 1)"
+
+ if [ "$1" == "$LIST_ADDRESS" ]; then
+ # check if user is trying to unsubscribe the list key
+ return_code=1
+ echo >&2 "can't delete the list pubkey."
+ 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 "use: \"$1\" is not associated with any public key on this keyring."
+ return_code=1
+ else
+ for key in $keyid; do
+ $GPG --batch --delete-key --yes $key
+ if [ "$?" == "0" ]; then
+ echo >&2 "deleted key id $key for $1"
+ # now just update the trust db
+ $GPG_LIST_KEYS &> /dev/null
+ else
+ echo >&2 "error deleting key id $key for $1"
+ return_code=1
+ fi
+ done
+ fi
+
+ chown -R $USER.$GROUP $LIST_PATH
+ return $return_code
}