Browse Source

Merge branch 'stretch' of https://github.com/bashrc/freedombone

Bob Mottram 7 years ago
parent
commit
47feb45691
3 changed files with 217 additions and 320 deletions
  1. 109
    150
      src/freedombone-controlpanel
  2. 71
    101
      src/freedombone-controlpanel-user
  3. 37
    69
      src/freedombone-sec

+ 109
- 150
src/freedombone-controlpanel View File

1780
     echo $"Firewall Settings"
1780
     echo $"Firewall Settings"
1781
     echo ''
1781
     echo ''
1782
     while read -r line; do
1782
     while read -r line; do
1783
-        firewall_name=$(awk "$line" -F '=' '{print $1}')
1784
-        firewall_port=$(awk "$line" -F '=' '{print $2}')
1783
+        firewall_name=$(echo "$line" | awk -F '=' '{print $1}')
1784
+        firewall_port=$(echo "$line" | awk -F '=' '{print $2}')
1785
         echo -n -e "$(pad_string "${firewall_name}")"
1785
         echo -n -e "$(pad_string "${firewall_name}")"
1786
         echo "${firewall_port}"
1786
         echo "${firewall_port}"
1787
     done < "$FIREWALL_CONFIG"
1787
     done < "$FIREWALL_CONFIG"
1881
 function menu_backup_restore {
1881
 function menu_backup_restore {
1882
     while true
1882
     while true
1883
     do
1883
     do
1884
-        data=$(mktemp 2>/dev/null)
1885
-        dialog --backtitle $"Freedombone Control Panel" \
1886
-               --title $"Backup and Restore" \
1887
-               --radiolist $"Choose an operation:" 19 70 12 \
1888
-               1 $"Backup data to USB drive" off \
1889
-               2 $"Restore GPG key from USB keydrive" off \
1890
-               3 $"Restore data from USB drive" off \
1891
-               4 $"Reinstall mariadb" off \
1892
-               5 $"Configure remote backups" off \
1893
-               6 $"Restore from remote backup" off \
1894
-               7 $"Backup GPG key to USB (master keydrive)" off \
1895
-               8 $"Backup GPG key to USB (fragment keydrive)" off \
1896
-               9 $"Format a USB drive (LUKS encrypted)" off \
1897
-               10 $"Remove backups from a USB drive" off \
1898
-               11 $"Back to main menu" on 2> "$data"
1899
-        sel=$?
1900
-        case $sel in
1901
-            1) rm -f "$data"
1902
-               break;;
1903
-            255) rm -f "$data"
1904
-                 break;;
1905
-        esac
1906
-        case $(cat "$data") in
1884
+        W=(1 $"Backup data to USB drive"
1885
+           2 $"Restore GPG key from USB keydrive"
1886
+           3 $"Restore data from USB drive"
1887
+           4 $"Reinstall mariadb"
1888
+           5 $"Configure remote backups"
1889
+           6 $"Restore from remote backup"
1890
+           7 $"Backup GPG key to USB (master keydrive)"
1891
+           8 $"Backup GPG key to USB (fragment keydrive)"
1892
+           9 $"Format a USB drive (LUKS encrypted)"
1893
+           10 $"Remove backups from a USB drive")
1894
+
1895
+        # shellcheck disable=SC2068
1896
+        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Backup and Restore" --menu $"Choose an operation, or ESC for main menu:" 19 70 12 "${W[@]}" 3>&2 2>&1 1>&3)
1897
+
1898
+        if [ ! "$selection" ]; then
1899
+           break
1900
+        fi
1901
+
1902
+        case $selection in
1907
             1) backup_data;;
1903
             1) backup_data;;
1908
             2) restore_gpg_key;;
1904
             2) restore_gpg_key;;
1909
             3) restore_data;;
1905
             3) restore_data;;
1914
             8) create_keydrive_fragment;;
1910
             8) create_keydrive_fragment;;
1915
             9) format_drive;;
1911
             9) format_drive;;
1916
             10) remove_backups;;
1912
             10) remove_backups;;
1917
-            11) rm -f "$data"
1918
-                break;;
1919
         esac
1913
         esac
1920
-        rm -f "$data"
1921
     done
1914
     done
1922
 }
1915
 }
1923
 
1916
 
1924
 function menu_email {
1917
 function menu_email {
1925
     while true
1918
     while true
1926
     do
1919
     do
1927
-        data=$(mktemp 2>/dev/null)
1928
-        dialog --backtitle $"Freedombone Control Panel" \
1929
-               --title $"Email Menu" \
1930
-               --radiolist $"Choose an operation:" 15 70 8 \
1931
-               1 $"Add a user to a mailing list" off \
1932
-               2 $"Remove a user from a mailing list" off \
1933
-               3 $"Add an email rule" off \
1934
-               4 $"Block/Unblock an email address" off \
1935
-               5 $"Block/Unblock email with subject text" off \
1936
-               6 $"Outgoing Email Proxy" off \
1937
-               7 $"Extra email domains" off \
1938
-               8 $"Back to main menu" on 2> "$data"
1939
-        sel=$?
1940
-        case $sel in
1941
-            1) rm -f "$data"
1942
-               break;;
1943
-            255) rm -f "$data"
1944
-                 break;;
1945
-        esac
1946
-        case $(cat "$data") in
1920
+        W=(1 $"Add a user to a mailing list"
1921
+           2 $"Remove a user from a mailing list"
1922
+           3 $"Add an email rule"
1923
+           4 $"Block/Unblock an email address"
1924
+           5 $"Block/Unblock email with subject text"
1925
+           6 $"Outgoing Email Proxy"
1926
+           7 $"Extra email domains")
1927
+
1928
+        # shellcheck disable=SC2068
1929
+        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Email Menu" --menu $"Choose an operation, or ESC for main menu:" 15 70 8 "${W[@]}" 3>&2 2>&1 1>&3)
1930
+
1931
+        if [ ! "$selection" ]; then
1932
+           break
1933
+        fi
1934
+
1935
+        case $selection in
1947
             1) add_to_mailing_list;;
1936
             1) add_to_mailing_list;;
1948
             2) remove_user_from_mailing_list;;
1937
             2) remove_user_from_mailing_list;;
1949
             3) email_rule;;
1938
             3) email_rule;;
1951
             5) block_unblock_subject;;
1940
             5) block_unblock_subject;;
1952
             6) email_smtp_proxy;;
1941
             6) email_smtp_proxy;;
1953
             7) email_extra_domains;;
1942
             7) email_extra_domains;;
1954
-            8) rm -f "$data"
1955
-               break;;
1956
         esac
1943
         esac
1957
-        rm -f "$data"
1958
     done
1944
     done
1959
 }
1945
 }
1960
 
1946
 
2073
 function domain_blocking {
2059
 function domain_blocking {
2074
     while true
2060
     while true
2075
     do
2061
     do
2076
-        data=$(mktemp 2>/dev/null)
2077
-        dialog --backtitle $"Freedombone Control Panel" \
2078
-               --title $"Domain or User Blocking" \
2079
-               --radiolist $"Choose an operation:" 14 60 6 \
2080
-               1 $"Block a domain or user" off \
2081
-               2 $"Unblock a domain or user" off \
2082
-               3 $"Block an IP address" off \
2083
-               4 $"Unblock an IP address" off \
2084
-               5 $"Show blocked domains and users" off \
2085
-               6 $"Back to main menu" on 2> "$data"
2086
-        sel=$?
2087
-        case $sel in
2088
-            1) rm -f "$data"
2089
-               break;;
2090
-            255) rm -f "$data"
2091
-                 break;;
2092
-        esac
2093
-        case $(cat "$data") in
2062
+        W=(1 $"Block a domain or user"
2063
+           2 $"Unblock a domain or user"
2064
+           3 $"Block an IP address"
2065
+           4 $"Unblock an IP address"
2066
+           5 $"Show blocked domains and users")
2067
+
2068
+        # shellcheck disable=SC2068
2069
+        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Domain or User Blocking" --menu $"Choose an operation, or ESC for main menu:" 13 70 6 "${W[@]}" 3>&2 2>&1 1>&3)
2070
+
2071
+        if [ ! "$selection" ]; then
2072
+           break
2073
+        fi
2074
+
2075
+        case $selection in
2094
             1) domain_blocking_add;;
2076
             1) domain_blocking_add;;
2095
             2) domain_blocking_remove;;
2077
             2) domain_blocking_remove;;
2096
             3) ip_blocking_add;;
2078
             3) ip_blocking_add;;
2097
             4) ip_blocking_remove;;
2079
             4) ip_blocking_remove;;
2098
             5) domain_blocking_show;;
2080
             5) domain_blocking_show;;
2099
-            6) rm -f "$data"
2100
-               break;;
2101
         esac
2081
         esac
2102
-        rm -f "$data"
2103
     done
2082
     done
2104
 }
2083
 }
2105
 
2084
 
2106
 function menu_users {
2085
 function menu_users {
2107
     while true
2086
     while true
2108
     do
2087
     do
2109
-        data=$(mktemp 2>/dev/null)
2110
-        dialog --backtitle $"Freedombone Control Panel" \
2111
-               --title $"Manage Users" \
2112
-               --radiolist $"Choose an operation:" 13 70 6 \
2113
-               1 $"Add a user" off \
2114
-               2 $"Delete a user" off \
2115
-               3 $"Change user password" off \
2116
-               4 $"Change user ssh public key" off \
2117
-               5 $"Reset password tries" off \
2118
-               6 $"Back to main menu" on 2> "$data"
2119
-        sel=$?
2120
-        case $sel in
2121
-            1) rm -f "$data"
2122
-               break;;
2123
-            255) rm -f "$data"
2124
-                 break;;
2125
-        esac
2126
-        case $(cat "$data") in
2088
+        W=(1 $"Add a user"
2089
+           2 $"Delete a user"
2090
+           3 $"Change user password"
2091
+           4 $"Change user ssh public key"
2092
+           5 $"Reset password tries")
2093
+
2094
+        # shellcheck disable=SC2068
2095
+        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Manage Users" --menu $"Choose an operation, or ESC for main menu:" 13 70 6 "${W[@]}" 3>&2 2>&1 1>&3)
2096
+
2097
+        if [ ! "$selection" ]; then
2098
+            break
2099
+        fi
2100
+
2101
+        case $selection in
2127
             1) add_user;;
2102
             1) add_user;;
2128
             2) delete_user;;
2103
             2) delete_user;;
2129
             3) change_password;;
2104
             3) change_password;;
2130
             4) change_ssh_public_key;;
2105
             4) change_ssh_public_key;;
2131
             5) reset_password_tries;;
2106
             5) reset_password_tries;;
2132
-            6) rm -f "$data"
2133
-               break;;
2134
         esac
2107
         esac
2135
-        rm -f "$data"
2136
     done
2108
     done
2137
 }
2109
 }
2138
 
2110
 
2202
             fi
2174
             fi
2203
         fi
2175
         fi
2204
 
2176
 
2205
-        data=$(mktemp 2>/dev/null)
2206
-        dialog --backtitle $"Freedombone Control Panel" \
2207
-               --title $"Wifi Menu" \
2208
-               --radiolist $"${status_str}\\n\\nChoose an operation:" 14 70 6 \
2209
-               1 $"Enable or disable Wifi" off \
2210
-               2 $"Configure wifi networks" off \
2211
-               3 $"Manually edit wifi networks file" off \
2212
-               4 $"Hotspot settings" off \
2213
-               5 $"Exit" on 2> "$data"
2214
-        sel=$?
2215
-        case $sel in
2216
-            1) rm -f "$data"
2217
-               break;;
2218
-            255) rm -f "$data"
2219
-                 break;;
2220
-        esac
2221
-        case $(cat "$data") in
2177
+        W=(1 $"Enable or disable Wifi"
2178
+           2 $"Configure wifi networks"
2179
+           3 $"Manually edit wifi networks file"
2180
+           4 $"Hotspot settings")
2181
+
2182
+        # shellcheck disable=SC2068
2183
+        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Wifi Menu" --menu $"${status_str}\\n\\nChoose an operation, or ESC for main menu:" 14 70 6 "${W[@]}" 3>&2 2>&1 1>&3)
2184
+
2185
+        if [ ! "$selection" ]; then
2186
+            break
2187
+        fi
2188
+
2189
+        case $selection in
2222
             1) wifi_enable;;
2190
             1) wifi_enable;;
2223
             2) wifi_settings;;
2191
             2) wifi_settings;;
2224
             3) wifi_edit_networks;;
2192
             3) wifi_edit_networks;;
2225
             4) hotspot_settings;;
2193
             4) hotspot_settings;;
2226
-            5) rm -f "$data"
2227
-               break;;
2228
         esac
2194
         esac
2229
-        rm -f "$data"
2230
     done
2195
     done
2231
 }
2196
 }
2232
 
2197
 
2275
 function menu_top_level {
2240
 function menu_top_level {
2276
     while true
2241
     while true
2277
     do
2242
     do
2278
-        data=$(mktemp 2>/dev/null)
2279
-        dialog --backtitle $"Freedombone Control Panel" \
2280
-               --title $"Control Panel" \
2281
-               --radiolist $"Choose an operation:" 30 70 22 \
2282
-               1 $"About this system" off \
2283
-               2 $"Passwords" off \
2284
-               3 $"Backup and Restore" off \
2285
-               4 $"Show Firewall" off \
2286
-               5 $"Verify Tripwire Code" off \
2287
-               6 $"Reset Tripwire" off \
2288
-               7 $"App Settings" off \
2289
-               8 $"Add/Remove Apps" off \
2290
-               9 $"Logging on/off" off \
2291
-               10 $"Ping enable/disable" off \
2292
-               11 $"Manage Users" off \
2293
-               12 $"Email Menu" off \
2294
-               13 $"Domain or User Blocking" off \
2295
-               14 $"Security Settings" off \
2296
-               15 $"Change the name of this system" off \
2297
-               16 $"Set a static local IP address" off \
2298
-               17 $"Wifi menu" off \
2299
-               18 $"Add Clacks" off \
2300
-               19 $"Check for updates" off \
2301
-               20 $"Power off the system" off \
2302
-               21 $"Restart the system" off \
2303
-               22 $"Exit" on 2> "$data"
2304
-        sel=$?
2305
-        case $sel in
2306
-            1) rm -f "$data"
2307
-               exit 1;;
2308
-            255) rm -f "$data"
2309
-                 exit 1;;
2310
-        esac
2243
+        W=(1 $"About this system"
2244
+           2 $"Passwords"
2245
+           3 $"Backup and Restore"
2246
+           4 $"Show Firewall"
2247
+           5 $"Verify Tripwire Code"
2248
+           6 $"Reset Tripwire"
2249
+           7 $"App Settings"
2250
+           8 $"Add/Remove Apps"
2251
+           9 $"Logging on/off"
2252
+           10 $"Ping enable/disable"
2253
+           11 $"Manage Users"
2254
+           12 $"Email Menu"
2255
+           13 $"Domain or User Blocking"
2256
+           14 $"Security Settings"
2257
+           15 $"Change the name of this system"
2258
+           16 $"Set a static local IP address"
2259
+           17 $"Wifi menu"
2260
+           18 $"Add Clacks"
2261
+           19 $"Check for updates"
2262
+           20 $"Power off the system"
2263
+           21 $"Restart the system")
2264
+
2265
+        # shellcheck disable=SC2068
2266
+        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Administrator Control Panel" --menu $"Choose an operation, or ESC to exit:" 28 60 28 "${W[@]}" 3>&2 2>&1 1>&3)
2267
+
2268
+        if [ ! "$selection" ]; then
2269
+            break
2270
+        fi
2271
+
2311
         please_wait
2272
         please_wait
2312
-        case $(cat "$data") in
2273
+
2274
+        case $selection in
2313
             1) show_about;;
2275
             1) show_about;;
2314
             2) view_or_change_passwords;;
2276
             2) view_or_change_passwords;;
2315
             3) menu_backup_restore;;
2277
             3) menu_backup_restore;;
2335
             19) check_for_updates;;
2297
             19) check_for_updates;;
2336
             20) shut_down_system;;
2298
             20) shut_down_system;;
2337
             21) restart_system;;
2299
             21) restart_system;;
2338
-            22) rm -f "$data"
2339
-                break;;
2340
         esac
2300
         esac
2341
-        rm -f "$data"
2342
     done
2301
     done
2343
 }
2302
 }
2344
 
2303
 

+ 71
- 101
src/freedombone-controlpanel-user View File

283
     fpr=$(gpg --with-colons --fingerprint "$TRUST_ADDRESS" | grep fpr | head -n 1 | awk -F ':' '{print $10}')
283
     fpr=$(gpg --with-colons --fingerprint "$TRUST_ADDRESS" | grep fpr | head -n 1 | awk -F ':' '{print $10}')
284
     if [ ${#fpr} -gt 2 ]; then
284
     if [ ${#fpr} -gt 2 ]; then
285
 
285
 
286
-        data=$(mktemp 2>/dev/null)
287
-        dialog --backtitle $"Freedombone User Control Panel" \
288
-               --title $"Trust a PGP/GPG key or website domain" \
289
-               --radiolist $"Set the trust level for $TRUST_ADDRESS:" 18 70 10 \
290
-               1 $"I don't know or won't say" off \
291
-               2 $"I do NOT trust" off \
292
-               3 $"I trust marginally" on \
293
-               4 $"I trust fully" off \
294
-               5 $"I trust ultimately" off 2> "$data"
295
-        sel=$?
296
-        case $sel in
297
-            1) rm -f "$data"
298
-               return;;
299
-            255) rm -f "$data"
300
-                 return;;
301
-        esac
302
-        TRUST_LEVEL=$(cat "$data")
303
-        if [ "${TRUST_LEVEL}" -ge 1 ] ; then
304
-            if [ "${TRUST_LEVEL}" -le 5 ] ; then
305
-                if echo -e "trust\\n${TRUST_LEVEL}\\ny\\nsave\\n" | gpg --command-fd 0 --edit-key "$fpr"; then
306
-                    gpg --update-trustdb
307
-                    dialog --title $"Trust a PGP/GPG key or website domain" \
308
-                           --backtitle $"Freedombone User Control Panel" \
309
-                           --msgbox $"$TRUST_ADDRESS was set to trust level ${TRUST_LEVEL}" 6 50
310
-                fi
311
-            fi
286
+        W=(1 $"I don't know or won't say"
287
+           2 $"I do NOT trust"
288
+           3 $"I trust marginally"
289
+           4 $"I trust fully"
290
+           5 $"I trust ultimately")
291
+
292
+        # shellcheck disable=SC2068
293
+        TRUST_LEVEL=$(dialog --backtitle $"Freedombone User Control Panel" --title $"Trust a PGP/GPG key or website domain" --menu $"Set the trust level for $TRUST_ADDRESS:" 18 70 10 "${W[@]}" 3>&2 2>&1 1>&3)
294
+
295
+        if [ ! "$TRUST_LEVEL" ]; then
296
+            return;
297
+        fi
298
+
299
+        if echo -e "trust\\n${TRUST_LEVEL}\\ny\\nsave\\n" | gpg --command-fd 0 --edit-key "$fpr"; then
300
+            gpg --update-trustdb
301
+            dialog --title $"Trust a PGP/GPG key or website domain" \
302
+                   --backtitle $"Freedombone User Control Panel" \
303
+                   --msgbox $"$TRUST_ADDRESS was set to trust level ${TRUST_LEVEL}" 6 50
312
         fi
304
         fi
313
-        rm -f "$data"
314
     fi
305
     fi
315
 }
306
 }
316
 
307
 
732
 function menu_encryption_keys {
723
 function menu_encryption_keys {
733
     while true
724
     while true
734
     do
725
     do
735
-        data=$(mktemp 2>/dev/null)
736
-        dialog --backtitle $"Freedombone User Control Panel" \
737
-               --title $"My Encryption Keys" \
738
-               --radiolist $"Choose an operation:" 19 70 11 \
739
-               1 $"Show your PGP/GPG key" off \
740
-               2 $"Show your full PGP/GPG key, including private key" off \
741
-               3 $"Publish your PGP/GPG key so that others can find it" off \
742
-               4 $"Add someone's PGP/GPG key" off \
743
-               5 $"Remove someone's PGP/GPG key" off \
744
-               6 $"Sign a PGP/GPG key or website domain" off \
745
-               7 $"Refresh your PGP/GPG keys" off \
746
-               8 $"Add an ssh key for logging in" off \
747
-               9 $"Remove an ssh key for logging in" off \
748
-               10 $"Set the trust level for a PGP/GPG key" off \
749
-               11 $"Back to main menu" on 2> "$data"
750
-        sel=$?
751
-        case $sel in
752
-            1) rm -f "$data"
753
-               break;;
754
-            255) rm -f "$data"
755
-                 break;;
756
-        esac
757
-        case $(cat "$data") in
726
+        W=(1 $"Show your PGP/GPG key"
727
+           2 $"Show your full PGP/GPG key, including private key"
728
+           3 $"Publish your PGP/GPG key so that others can find it"
729
+           4 $"Add someone's PGP/GPG key"
730
+           5 $"Remove someone's PGP/GPG key"
731
+           6 $"Sign a PGP/GPG key or website domain"
732
+           7 $"Refresh your PGP/GPG keys"
733
+           8 $"Add an ssh key for logging in"
734
+           9 $"Remove an ssh key for logging in"
735
+           10 $"Set the trust level for a PGP/GPG key")
736
+
737
+        # shellcheck disable=SC2068
738
+        selection=$(dialog --backtitle $"Freedombone User Control Panel" --title $"My Encryption Keys" --menu $"Choose an operation, or ESC for main menu:" 19 70 11 "${W[@]}" 3>&2 2>&1 1>&3)
739
+
740
+        if [ ! "$selection" ]; then
741
+            break
742
+        fi
743
+
744
+        case $selection in
758
             1) show_gpg_key;;
745
             1) show_gpg_key;;
759
             2) show_full_gpg_key;;
746
             2) show_full_gpg_key;;
760
             3) publish_gpg_key;;
747
             3) publish_gpg_key;;
765
             8) add_ssh_key;;
752
             8) add_ssh_key;;
766
             9) remove_ssh_key;;
753
             9) remove_ssh_key;;
767
             10) gpg_key_trust;;
754
             10) gpg_key_trust;;
768
-            11) rm -f "$data"
769
-                break;;
770
         esac
755
         esac
771
-        rm -f "$data"
772
     done
756
     done
773
 }
757
 }
774
 
758
 
775
 function menu_email {
759
 function menu_email {
776
     while true
760
     while true
777
     do
761
     do
778
-        data=$(mktemp 2>/dev/null)
779
-        dialog --backtitle $"Freedombone User Control Panel" \
780
-               --title $"Change Email Filtering Rules" \
781
-               --radiolist $"Choose an operation:" 14 70 7 \
782
-               1 $"Add yourself to a mailing list" off \
783
-               2 $"Remove yourself from a mailing list" off \
784
-               3 $"Add an email rule for an address" off \
785
-               4 $"Add an email rule for a subject" off \
786
-               5 $"Block or unblock an email address" off \
787
-               6 $"Block or unblock email with subject text" off \
788
-               7 $"Back to main menu" on 2> "$data"
789
-        sel=$?
790
-        case $sel in
791
-            1) rm -f "$data"
792
-               break;;
793
-            255) rm -f "$data"
794
-                 break;;
795
-        esac
796
-        case $(cat "$data") in
762
+        W=(1 $"Add yourself to a mailing list"
763
+           2 $"Remove yourself from a mailing list"
764
+           3 $"Add an email rule for an address"
765
+           4 $"Add an email rule for a subject"
766
+           5 $"Block or unblock an email address"
767
+           6 $"Block or unblock email with subject text")
768
+
769
+        # shellcheck disable=SC2068
770
+        selection=$(dialog --backtitle $"Freedombone User Control Panel" --title $"Change Email Filtering Rules" --menu $"Choose an operation, or ESC for main menu:" 14 70 7 "${W[@]}" 3>&2 2>&1 1>&3)
771
+
772
+        if [ ! "$selection" ]; then
773
+            break
774
+        fi
775
+
776
+        case $selection in
797
             1) add_to_mailing_list;;
777
             1) add_to_mailing_list;;
798
             2) remove_user_from_mailing_list;;
778
             2) remove_user_from_mailing_list;;
799
             3) email_rule_address;;
779
             3) email_rule_address;;
800
             4) email_rule_subject;;
780
             4) email_rule_subject;;
801
             5) block_unblock_email;;
781
             5) block_unblock_email;;
802
             6) block_unblock_subject;;
782
             6) block_unblock_subject;;
803
-            7) rm -f "$data"
804
-               break;;
805
         esac
783
         esac
806
-        rm -f "$data"
807
     done
784
     done
808
 }
785
 }
809
 
786
 
899
 function menu_top_level {
876
 function menu_top_level {
900
     while true
877
     while true
901
     do
878
     do
902
-        data=$(mktemp 2>/dev/null)
903
-        dialog --backtitle $"Freedombone User Control Panel" \
904
-               --title $"User Control Panel" \
905
-               --radiolist $"Choose an operation:" 20 60 13 \
906
-               1 $"Use Email" off \
907
-               2 $"Show your Email Address" off \
908
-               3 $"Change Email Filtering/Blocking Rules" off \
909
-               4 $"Run an App" off \
910
-               5 $"Browse the Web" off \
911
-               6 $"My Encryption Keys" off \
912
-               7 $"Set an outgoing email proxy" off \
913
-               8 $"Administrator controls" off \
914
-               9 $"Exit to the command line" off \
915
-               10 $"Log out" on 2> "$data"
916
-        sel=$?
917
-        case $sel in
918
-            1) rm -f "$data"
919
-               exit 1;;
920
-            255) rm -f "$data"
921
-                 exit 1;;
922
-        esac
923
-        case $(cat "$data") in
879
+        W=(1 $"Use Email"
880
+           2 $"Show your Email Address"
881
+           3 $"Change Email Filtering/Blocking Rules"
882
+           4 $"Run an App"
883
+           5 $"Browse the Web"
884
+           6 $"My Encryption Keys"
885
+           7 $"Set an outgoing email proxy"
886
+           8 $"Administrator controls"
887
+           9 $"Exit to the command line")
888
+
889
+        # shellcheck disable=SC2068
890
+        selection=$(dialog --backtitle $"Freedombone User Control Panel" --title $"User Control Panel" --menu $"Choose an operation, or ESC to log out:" 20 60 13 "${W[@]}" 3>&2 2>&1 1>&3)
891
+        if [ ! "$selection" ]; then
892
+            kill -HUP "$(pgrep -s 0 -o)"
893
+            break
894
+        fi
895
+
896
+        case $selection in
924
             1) mutt;;
897
             1) mutt;;
925
             2) show_your_email_address;;
898
             2) show_your_email_address;;
926
             3) menu_email;;
899
             3) menu_email;;
929
             6) menu_encryption_keys;;
902
             6) menu_encryption_keys;;
930
             7) smtp_proxy;;
903
             7) smtp_proxy;;
931
             8) menu_admin;;
904
             8) menu_admin;;
932
-            9) rm -f "$data"
933
-               break;;
934
-            10) kill -HUP "$(pgrep -s 0 -o)";;
905
+            9) break;;
935
         esac
906
         esac
936
-        rm -f "$data"
937
     done
907
     done
938
 }
908
 }
939
 
909
 

+ 37
- 69
src/freedombone-sec View File

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