Przeglądaj źródła

Client signing of monkeysphere server keys

Bob Mottram 9 lat temu
rodzic
commit
32ed82bd67
Brak konta powiązanego z e-mailem autora
2 zmienionych plików z 795 dodań i 749 usunięć
  1. 758
    746
      src/freedombone-controlpanel-user
  2. 37
    3
      src/freedombone-sec

+ 758
- 746
src/freedombone-controlpanel-user
Plik diff jest za duży
Wyświetl plik


+ 37
- 3
src/freedombone-sec Wyświetl plik

@@ -64,9 +64,6 @@ DH_KEYLENGTH=2048
64 64
 LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
65 65
 
66 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 68
 function get_protocols_from_website {
72 69
   if [ ! -f $WEBSITES_DIRECTORY/$1 ]; then
@@ -614,6 +611,10 @@ function enable_monkeysphere {
614 611
 	esac
615 612
 
616 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 618
 		if [ ! -f /home/$MY_USERNAME/.monkeysphere/authorized_user_ids ]; then
618 619
 			dialog --title $"GPG based authentication" \
619 620
 				   --msgbox $"$MY_USERNAME does not currently have any ids within ~/.monkeysphere/authorized_user_ids" 6 40
@@ -927,6 +928,33 @@ function refresh_gpg_keys {
927 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 958
 function show_help {
931 959
   echo ''
932 960
   echo "${PROJECT_NAME}-sec"
@@ -938,6 +966,7 @@ function show_help {
938 966
   echo $'  -e --export              Export security settings to a file'
939 967
   echo $'  -i --import              Import security settings from a file'
940 968
   echo $'  -r --refresh             Refresh GPG keys for all users'
969
+  echo $'  -s --sign                Sign monkeysphere server keys'
941 970
   echo $'     --register [domain]   Register a https domain with monkeysphere'
942 971
   echo ''
943 972
   exit 0
@@ -973,6 +1002,11 @@ case $key in
973 1002
 	shift
974 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 1011
 	# unknown option
978 1012
 	;;