Explorar el Código

Security menu style

Bob Mottram hace 7 años
padre
commit
b2f92bbcc5
Se han modificado 1 ficheros con 37 adiciones y 69 borrados
  1. 37
    69
      src/freedombone-sec

+ 37
- 69
src/freedombone-sec Ver fichero

@@ -924,86 +924,66 @@ function remove_tor_bridge_relay {
924 924
 }
925 925
 
926 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 941
         1)
947 942
             show_tor_bridges
948
-            rm -f "$data"
949 943
             exit 0
950 944
             ;;
951 945
         2)
952 946
             add_tor_bridge
953
-            rm -f "$data"
954 947
             exit 0
955 948
             ;;
956 949
         3)
957 950
             remove_tor_bridge
958
-            rm -f "$data"
959 951
             exit 0
960 952
             ;;
961 953
         4)
962 954
             add_tor_bridge_relay
963
-            rm -f "$data"
964 955
             exit 0
965 956
             ;;
966 957
         5)
967 958
             remove_tor_bridge_relay
968
-            rm -f "$data"
969
-            exit 0
970
-            ;;
971
-        6)
972
-            rm -f "$data"
973 959
             exit 0
974 960
             ;;
975 961
     esac
976
-    rm -f "$data"
977 962
 }
978 963
 
979 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 988
     clear
1009 989
 
@@ -1019,13 +999,12 @@ function menu_security_settings {
1019 999
     import_settings
1020 1000
     export_settings
1021 1001
 
1022
-    case $(cat "$data") in
1002
+    case $selection in
1023 1003
         1)
1024 1004
             clear
1025 1005
             echo $'Running STIG tests...'
1026 1006
             echo ''
1027 1007
             ${PROJECT_NAME}-tests --stig showall
1028
-            rm -f "$data"
1029 1008
             exit 0
1030 1009
             ;;
1031 1010
         2)
@@ -1034,28 +1013,23 @@ function menu_security_settings {
1034 1013
             echo ''
1035 1014
             ${PROJECT_NAME}-tests --stig fix
1036 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 1016
             exit 0
1039 1017
             ;;
1040 1018
         3)
1041 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 1021
             exit 0
1045 1022
             ;;
1046 1023
         4)
1047 1024
             menu_tor_bridges
1048
-            rm -f "$data"
1049 1025
             exit 0
1050 1026
             ;;
1051 1027
         5)
1052 1028
             store_passwords
1053
-            rm -f "$data"
1054 1029
             exit 0
1055 1030
             ;;
1056 1031
         6)
1057 1032
             export_passwords
1058
-            rm -f "$data"
1059 1033
             exit 0
1060 1034
             ;;
1061 1035
         7)
@@ -1086,15 +1060,9 @@ function menu_security_settings {
1086 1060
         15)
1087 1061
             allow_ssh_passwords
1088 1062
             change_ssh_settings
1089
-            rm -f "$data"
1090
-            exit 0
1091
-            ;;
1092
-        16)
1093
-            rm -f "$data"
1094 1063
             exit 0
1095 1064
             ;;
1096 1065
     esac
1097
-    rm -f "$data"
1098 1066
 
1099 1067
     change_website_settings
1100 1068
     change_imap_settings