浏览代码

Client signing of monkeysphere server keys

Bob Mottram 9 年前
父节点
当前提交
32ed82bd67
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 795 次插入749 次删除
  1. 758
    746
      src/freedombone-controlpanel-user
  2. 37
    3
      src/freedombone-sec

+ 758
- 746
src/freedombone-controlpanel-user
文件差异内容过多而无法显示
查看文件


+ 37
- 3
src/freedombone-sec 查看文件

64
 LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
64
 LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
65
 
65
 
66
 MY_USERNAME=
66
 MY_USERNAME=
67
-if grep -q "MY_USERNAME" $CONFIGURATION_FILE; then
68
-	MY_USERNAME=$(grep "MY_USERNAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
69
-fi
70
 
67
 
71
 function get_protocols_from_website {
68
 function get_protocols_from_website {
72
   if [ ! -f $WEBSITES_DIRECTORY/$1 ]; then
69
   if [ ! -f $WEBSITES_DIRECTORY/$1 ]; then
614
 	esac
611
 	esac
615
 
612
 
616
 	if [ $monkey ]; then
613
 	if [ $monkey ]; then
614
+		if grep -q "MY_USERNAME" $CONFIGURATION_FILE; then
615
+			MY_USERNAME=$(grep "MY_USERNAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
616
+		fi
617
+
617
 		if [ ! -f /home/$MY_USERNAME/.monkeysphere/authorized_user_ids ]; then
618
 		if [ ! -f /home/$MY_USERNAME/.monkeysphere/authorized_user_ids ]; then
618
 			dialog --title $"GPG based authentication" \
619
 			dialog --title $"GPG based authentication" \
619
 				   --msgbox $"$MY_USERNAME does not currently have any ids within ~/.monkeysphere/authorized_user_ids" 6 40
620
 				   --msgbox $"$MY_USERNAME does not currently have any ids within ~/.monkeysphere/authorized_user_ids" 6 40
927
 	exit 0
928
 	exit 0
928
 }
929
 }
929
 
930
 
931
+function monkeysphere_sign_server_keys {
932
+	server_keys_file=/home/$USER/.monkeysphere/server_keys
933
+	if [ ! -f $server_keys_file ]; then
934
+		exit 0
935
+	fi
936
+
937
+	keys_signed=
938
+	while read line; do
939
+		echo $line
940
+		if [ ${#line} -gt 2 ]; then
941
+			fpr=$(gpg --with-colons --fingerprint "$line" | grep fpr | head -n 1 | awk -F ':' '{print $10}')
942
+			if [ ${#fpr} -gt 2 ]; then
943
+				gpg --sign-key $fpr
944
+				if [ "$?" = "0" ]; then
945
+					gpg --update-trustdb
946
+					keys_signed=1
947
+				fi
948
+			fi
949
+		fi
950
+	done <$server_keys_file
951
+
952
+	if [ $keys_signed ]; then
953
+		rm $server_keys_file
954
+	fi
955
+	exit 0
956
+}
957
+
930
 function show_help {
958
 function show_help {
931
   echo ''
959
   echo ''
932
   echo "${PROJECT_NAME}-sec"
960
   echo "${PROJECT_NAME}-sec"
938
   echo $'  -e --export              Export security settings to a file'
966
   echo $'  -e --export              Export security settings to a file'
939
   echo $'  -i --import              Import security settings from a file'
967
   echo $'  -i --import              Import security settings from a file'
940
   echo $'  -r --refresh             Refresh GPG keys for all users'
968
   echo $'  -r --refresh             Refresh GPG keys for all users'
969
+  echo $'  -s --sign                Sign monkeysphere server keys'
941
   echo $'     --register [domain]   Register a https domain with monkeysphere'
970
   echo $'     --register [domain]   Register a https domain with monkeysphere'
942
   echo ''
971
   echo ''
943
   exit 0
972
   exit 0
973
 	shift
1002
 	shift
974
 	register_website "$1"
1003
 	register_website "$1"
975
 	;;
1004
 	;;
1005
+	# user signs monkeysphere server keys
1006
+	-s|--sign)
1007
+	shift
1008
+	monkeysphere_sign_server_keys
1009
+	;;
976
 	*)
1010
 	*)
977
 	# unknown option
1011
 	# unknown option
978
 	;;
1012
 	;;