#! /bin/sh

printf "Content-Type: text/plain\r\n\r\n"

user=""
key=""

list="$QUERY_STRING"

while [ "$list" != "" ]
do
	item=${list%%&*}
	list=${list#*&}

	if [ "$item" = "$list" ]; then list=""; fi

	case "$item" in
		usr=*) user="${item#*=}" ;;
		key=*) key="${item#*=}"  ;;
	esac
done

if [ "$user" != "" ] && [ "$key" != "" ]
then
	key=$(echo $key | sed 's/%20/ /g')
	/home/www/cgi-bin/add-ssh-key-suid "$user" "$key"
fi
