aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhatto <rhatto>2006-10-09 19:58:45 +0000
committerrhatto <rhatto>2006-10-09 19:58:45 +0000
commiteb84e4ffd04a2b8a239f3873499696788d43a38f (patch)
tree215fd522da36b029bb9da539e6fe61e9d2e5624b
parent6fd7d8e5e70665240c6c3b0a0a58e93734885843 (diff)
downloadfirma-eb84e4ffd04a2b8a239f3873499696788d43a38f.tar.gz
firma-eb84e4ffd04a2b8a239f3873499696788d43a38f.tar.bz2
sendkey pgp/mime fixes; new function RandomString
-rwxr-xr-xfirma70
1 files changed, 61 insertions, 9 deletions
diff --git a/firma b/firma
index 30be641..b42ca5e 100755
--- a/firma
+++ b/firma
@@ -1258,7 +1258,7 @@ function UnsubscribeUser {
done
fi
- chown -R $FIRMA_USER.$FIRMA_GROUP $LIST_PATH
+ FixListOwnership
return $return_code
}
@@ -1346,8 +1346,8 @@ function SubscribeUsers {
echo >&2 "subscribe: wrong option: type subscribe help"
return_code=1
fi
-
- chown -R $FIRMA_USER.$FIRMA_GROUP $LIST_PATH
+
+ FixListOwnerShip
return $return_code
}
@@ -1394,32 +1394,36 @@ function SendListPubkey {
fi
recipients="$key"
- random="$RANDOM"
+ boundary="`RandomString 15`"
# 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"
+To: $recipients
+MIME-Version: 1.0
+Content-Type: multipart/encrypted;
+ protocol=\"application/pgp-encrypted\";
+ boundary=\"${boundary}\"
+Content-Disposition: inline"
# this is the body of the message to be sent, so no indentation here
MESSAGE_BODY="`$GPG --armor --export $LIST_ADDRESS`"
MESSAGE_BODY="
-Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; boundary="$random"
---$random
+--$boundary
Content-Type: application/pgp-encrypted
Content-Disposition: attachment
Version: 1
---$random
+--$boundary
Content-Type: application/octet-stream
Content-Disposition: inline; filename="msg.asc"
$(echo -e "${PASSPHRASE}\n${MESSAGE_BODY}" | $GPG_ENCRYPT --recipient $recipients)
---$random--"
+--$boundary--"
AssembleMessage
@@ -1465,6 +1469,54 @@ function GetSubscribersInfo {
return $?
}
+
+function FixListOwnershipt {
+ #-------------------------------------------------------------
+ # fix list ownership
+ #
+ # parameter(s): none
+ # depends on function(s): none
+ # returns: 0 on success
+ # 1 on failure
+ #-------------------------------------------------------------
+
+ chown -R $FIRMA_USER.$FIRMA_GROUP $LIST_PATH
+ return $?
+}
+
+
+function RandomString {
+ #-------------------------------------------------------------
+ # print a random string
+ # +got it from http://funcoeszz.net/
+ #
+ # parameter(s): string size (max 62)
+ # depends on function(s): none
+ # returns: 0
+ # 1 if string size is greater than 62
+ #-------------------------------------------------------------
+
+ local n alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+
+ if [ -z "$1" ]; then
+ n=6
+ else
+ n=`echo "$1" | sed 's/[^0-9]//g'`
+ fi
+
+ if [ $n -gt 62 ]; then
+ return 1
+ fi
+
+ while [ $n -ne 0 ]; do n=$((n-1)) ; pos=$((RANDOM%${#alpha}+1))
+ echo -n "$alpha" | sed "s/\(.\)\{$pos\}.*/\1/"
+ alpha=`echo $alpha | sed "s/.//$pos"`
+ done | tr -d '\012' ; echo
+
+ return 0
+
+}
+
#-------------------------------------------------------------
# main()
#-------------------------------------------------------------