Bob Mottram 7 лет назад
Родитель
Сommit
b2f92bbcc5
1 измененных файлов: 37 добавлений и 69 удалений
  1. 37
    69
      src/freedombone-sec

+ 37
- 69
src/freedombone-sec Просмотреть файл

924
 }
924
 }
925
 
925
 
926
 function menu_tor_bridges {
926
 function menu_tor_bridges {
927
-    data=$(mktemp 2>/dev/null)
928
-    dialog --backtitle $"Freedombone Control Panel" \
929
-           --title $"Tor Bridges" \
930
-           --radiolist $"Choose an operation:" 14 50 6 \
931
-           1 $"Show bridges" off \
932
-           2 $"Add a bridge" off \
933
-           3 $"Remove a bridge" off \
934
-           4 $"Make this system into a bridge" off \
935
-           5 $"Stop being a bridge" off \
936
-           6 $"Go Back/Exit" on 2> "$data"
937
-    sel=$?
938
-    case $sel in
939
-        1) rm -f "$data"
940
-           exit 1;;
941
-        255) rm -f "$data"
942
-             exit 1;;
943
-    esac
927
+    W=(1 $"Show bridges"
928
+       2 $"Add a bridge"
929
+       3 $"Remove a bridge"
930
+       4 $"Make this system into a bridge"
931
+       5 $"Stop being a bridge")
944
 
932
 
945
-    case $(cat "$data") in
933
+    # shellcheck disable=SC2068
934
+    selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Security Settings" --menu $"Choose an operation, or ESC to go back:" 14 50 6 "${W[@]}" 3>&2 2>&1 1>&3)
935
+
936
+    if [ ! "$selection" ]; then
937
+        exit 0
938
+    fi
939
+
940
+    case $selection in
946
         1)
941
         1)
947
             show_tor_bridges
942
             show_tor_bridges
948
-            rm -f "$data"
949
             exit 0
943
             exit 0
950
             ;;
944
             ;;
951
         2)
945
         2)
952
             add_tor_bridge
946
             add_tor_bridge
953
-            rm -f "$data"
954
             exit 0
947
             exit 0
955
             ;;
948
             ;;
956
         3)
949
         3)
957
             remove_tor_bridge
950
             remove_tor_bridge
958
-            rm -f "$data"
959
             exit 0
951
             exit 0
960
             ;;
952
             ;;
961
         4)
953
         4)
962
             add_tor_bridge_relay
954
             add_tor_bridge_relay
963
-            rm -f "$data"
964
             exit 0
955
             exit 0
965
             ;;
956
             ;;
966
         5)
957
         5)
967
             remove_tor_bridge_relay
958
             remove_tor_bridge_relay
968
-            rm -f "$data"
969
-            exit 0
970
-            ;;
971
-        6)
972
-            rm -f "$data"
973
             exit 0
959
             exit 0
974
             ;;
960
             ;;
975
     esac
961
     esac
976
-    rm -f "$data"
977
 }
962
 }
978
 
963
 
979
 function menu_security_settings {
964
 function menu_security_settings {
980
-    data=$(mktemp 2>/dev/null)
981
-    dialog --backtitle $"Freedombone Control Panel" \
982
-           --title $"Security Settings" \
983
-           --radiolist $"Choose an operation:" 23 76 23 \
984
-           1 $"Run STIG tests" off \
985
-           2 $"Fix STIG test failures" off \
986
-           3 $"Show ssh host public key" off \
987
-           4 $"Tor bridges" off \
988
-           5 $"Password storage" off \
989
-           6 $"Export passwords" off \
990
-           7 $"Regenerate ssh host keys" off \
991
-           8 $"Regenerate Diffie-Hellman keys" off \
992
-           9 $"Update cipersuite" off \
993
-           10 $"Create a new Let's Encrypt certificate" off \
994
-           11 $"Renew Let's Encrypt certificate" off \
995
-           12 $"Delete a Let's Encrypt certificate" off \
996
-           13 $"Enable GPG based authentication (monkeysphere)" off \
997
-           14 $"Register a website with monkeysphere" off \
998
-           15 $"Allow ssh login with passwords" off \
999
-           16 $"Go Back/Exit" on 2> "$data"
1000
-    sel=$?
1001
-    case $sel in
1002
-        1) rm -f "$data"
1003
-           exit 1;;
1004
-        255) rm -f "$data"
1005
-             exit 1;;
1006
-    esac
965
+    W=(1 $"Run STIG tests"
966
+       2 $"Fix STIG test failures"
967
+       3 $"Show ssh host public key"
968
+       4 $"Tor bridges"
969
+       5 $"Password storage"
970
+       6 $"Export passwords"
971
+       7 $"Regenerate ssh host keys"
972
+       8 $"Regenerate Diffie-Hellman keys"
973
+       9 $"Update cipersuite"
974
+       10 $"Create a new Let's Encrypt certificate"
975
+       11 $"Renew Let's Encrypt certificate"
976
+       12 $"Delete a Let's Encrypt certificate"
977
+       13 $"Enable GPG based authentication (monkeysphere)"
978
+       14 $"Register a website with monkeysphere"
979
+       15 $"Allow ssh login with passwords")
980
+
981
+    # shellcheck disable=SC2068
982
+    selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Security Settings" --menu $"Choose an operation, or ESC to exit:" 23 76 23 "${W[@]}" 3>&2 2>&1 1>&3)
983
+
984
+    if [ ! "$selection" ]; then
985
+        exit 0
986
+    fi
1007
 
987
 
1008
     clear
988
     clear
1009
 
989
 
1019
     import_settings
999
     import_settings
1020
     export_settings
1000
     export_settings
1021
 
1001
 
1022
-    case $(cat "$data") in
1002
+    case $selection in
1023
         1)
1003
         1)
1024
             clear
1004
             clear
1025
             echo $'Running STIG tests...'
1005
             echo $'Running STIG tests...'
1026
             echo ''
1006
             echo ''
1027
             ${PROJECT_NAME}-tests --stig showall
1007
             ${PROJECT_NAME}-tests --stig showall
1028
-            rm -f "$data"
1029
             exit 0
1008
             exit 0
1030
             ;;
1009
             ;;
1031
         2)
1010
         2)
1034
             echo ''
1013
             echo ''
1035
             ${PROJECT_NAME}-tests --stig fix
1014
             ${PROJECT_NAME}-tests --stig fix
1036
             echo $'Fixes applied. You will need to run the STIG tests again to be sure that they were all fixed.'
1015
             echo $'Fixes applied. You will need to run the STIG tests again to be sure that they were all fixed.'
1037
-            rm -f "$data"
1038
             exit 0
1016
             exit 0
1039
             ;;
1017
             ;;
1040
         3)
1018
         3)
1041
             dialog --title $"SSH host public keys" \
1019
             dialog --title $"SSH host public keys" \
1042
-                   --msgbox "\n$(get_ssh_server_key)" 12 60
1043
-            rm -f "$data"
1020
+                   --msgbox "\\n$(get_ssh_server_key)" 12 60
1044
             exit 0
1021
             exit 0
1045
             ;;
1022
             ;;
1046
         4)
1023
         4)
1047
             menu_tor_bridges
1024
             menu_tor_bridges
1048
-            rm -f "$data"
1049
             exit 0
1025
             exit 0
1050
             ;;
1026
             ;;
1051
         5)
1027
         5)
1052
             store_passwords
1028
             store_passwords
1053
-            rm -f "$data"
1054
             exit 0
1029
             exit 0
1055
             ;;
1030
             ;;
1056
         6)
1031
         6)
1057
             export_passwords
1032
             export_passwords
1058
-            rm -f "$data"
1059
             exit 0
1033
             exit 0
1060
             ;;
1034
             ;;
1061
         7)
1035
         7)
1086
         15)
1060
         15)
1087
             allow_ssh_passwords
1061
             allow_ssh_passwords
1088
             change_ssh_settings
1062
             change_ssh_settings
1089
-            rm -f "$data"
1090
-            exit 0
1091
-            ;;
1092
-        16)
1093
-            rm -f "$data"
1094
             exit 0
1063
             exit 0
1095
             ;;
1064
             ;;
1096
     esac
1065
     esac
1097
-    rm -f "$data"
1098
 
1066
 
1099
     change_website_settings
1067
     change_website_settings
1100
     change_imap_settings
1068
     change_imap_settings