diff --git a/src/freedombone-controlpanel b/src/freedombone-controlpanel index 501d4de1..97ed03b4 100755 --- a/src/freedombone-controlpanel +++ b/src/freedombone-controlpanel @@ -13,7 +13,7 @@ # License # ======= # -# Copyright (C) 2015-2017 Bob Mottram +# Copyright (C) 2015-2018 Bob Mottram # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -166,6 +166,7 @@ function any_key_verify { fi ;; esac + rm $data } function get_app_icann_address { @@ -304,7 +305,7 @@ function view_or_change_passwords { fi ;; esac - + rm $data } function check_for_updates { @@ -330,19 +331,23 @@ function add_user { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac new_user_username=$(cat $data | sed -n 1p) new_user_ssh_public_key=$(cat $data | sed -n 2p) if [ ${#new_user_username} -lt 2 ]; then dialog --title $"New username" \ --msgbox $"No username was given" 6 40 + rm $data return fi if [[ "$new_user_username" == *" "* ]]; then dialog --title $"Invalid username" \ --msgbox $"The username should not contain any spaces" 6 40 + rm $data return fi if [ ${#new_user_ssh_public_key} -lt 20 ]; then @@ -359,6 +364,7 @@ function add_user { --msgbox $"This does not look like an ssh public key" 6 40 fi fi + rm $data } function pad_string { @@ -742,6 +748,7 @@ function change_ssh_public_key { fi ;; esac + rm $data } function remove_user_from_mailing_list { @@ -848,8 +855,10 @@ function add_to_mailing_list { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac LIST_NAME=$(cat $data | sed -n 1p) LIST_SUBJECT=$(cat $data | sed -n 2p) @@ -867,12 +876,14 @@ function add_to_mailing_list { if [ ${#LIST_NAME} -lt 2 ]; then dialog --title $"Add mailing list" \ --msgbox $"No mailing list name was given" 6 40 + rm $data return fi if [ ${#LIST_SUBJECT} -lt 2 ]; then if [ ${#LIST_EMAIL} -lt 2 ]; then dialog --title $"Add mailing list" \ --msgbox $"No mailing list subject or address was given" 6 40 + rm $data return fi fi @@ -883,6 +894,7 @@ function add_to_mailing_list { if [[ "$LIST_EMAIL" != *"@"* || "$LIST_EMAIL" != *"."* ]]; then dialog --title $"Add mailing list" \ --msgbox $"Unrecognised email address" 6 40 + rm $data return else ${PROJECT_NAME}-addlist -u $SELECTED_USERNAME -l "$LIST_NAME" \ @@ -892,6 +904,7 @@ function add_to_mailing_list { dialog --title $"Add mailing list" \ --msgbox $"$LIST_NAME list was added" 6 40 + rm $data } function email_rule { @@ -910,8 +923,10 @@ function email_rule { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac RULE_EMAIL=$(cat $data | sed -n 1p) RULE_FOLDER=$(cat $data | sed -n 2p) @@ -928,16 +943,19 @@ function email_rule { if [ ${#RULE_EMAIL} -lt 2 ]; then dialog --title $"Add email rule" \ --msgbox $"No email address was given" 6 40 + rm $data return fi if [ ${#RULE_FOLDER} -lt 2 ]; then dialog --title $"Add email rule" \ --msgbox $"No folder name was given" 6 40 + rm $data return fi if [[ "$RULE_EMAIL" != *"@"* || "$RULE_EMAIL" != *"."* ]]; then dialog --title $"Add email rule" \ --msgbox $"Unrecognised email address" 6 40 + rm $data return fi @@ -945,6 +963,7 @@ function email_rule { -g "$RULE_FOLDER" --public $RULE_PUBLIC dialog --title $"Add email rule" \ --msgbox $"Email rule for $RULE_EMAIL was added" 6 40 + rm $data } function block_unblock_email { @@ -963,19 +982,23 @@ function block_unblock_email { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac BLOCK_EMAIL=$(cat $data | sed -n 1p) BLOCK=$(cat $data | sed -n 2p) if [ ${#BLOCK_EMAIL} -lt 2 ]; then dialog --title $"Block/Unblock an email" \ --msgbox $"No email address was given" 6 40 + rm $data return fi if [[ "$BLOCK_EMAIL" != *"@"* || "$BLOCK_EMAIL" != *"."* ]]; then dialog --title $"Block/Unblock an email" \ --msgbox $"Unrecognised email address" 6 40 + rm $data return fi if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then @@ -987,6 +1010,7 @@ function block_unblock_email { dialog --title $"Unblock an email" \ --msgbox "Email from $BLOCK_EMAIL to $SELECTED_USERNAME unblocked" 6 75 fi + rm $data } function block_unblock_subject { @@ -1005,14 +1029,17 @@ function block_unblock_subject { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac BLOCK_SUBJECT=$(cat $data | sed -n 1p) BLOCK=$(cat $data | sed -n 2p) if [ ${#BLOCK_SUBJECT} -lt 2 ]; then dialog --title $"Block/Unblock an email" \ --msgbox $"No subject was given" 6 40 + rm $data return fi if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then @@ -1024,6 +1051,7 @@ function block_unblock_subject { dialog --title $"Unblock an email" \ --msgbox "Email with subject $BLOCK_SUBJECT to $SELECTED_USERNAME unblocked" 6 40 fi + rm $data } function create_keydrive_master { @@ -1226,18 +1254,21 @@ function restore_data_remote { friend_server_domain_name=$(<$data) if [ ${#friend_server_domain_name} -lt 2 ]; then + rm $data return fi if [[ $friend_server_domain_name != *"."* ]]; then dialog --title $"Remote server domain name" \ --msgbox $"Invalid domain name" 6 40 + rm $data return fi restore_data_from_storage $friend_server_domain_name ;; esac + rm $data } function ping_enable_disable { @@ -1387,8 +1418,10 @@ function format_drive { --yesno $"\nPlease confirm that you wish to format drive\n\n ${USB_DRIVE}\n\nAll current data on the drive will be lost, and you will be prompted to give a password used to encrypt the drive.\n\nDANGER: If you screw up here and format the wrong drive it's your own fault!" 16 60 sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac clear @@ -1397,6 +1430,7 @@ function format_drive { echo '' ${PROJECT_NAME}-format $USB_DRIVE any_key + rm $data } function remove_backups { @@ -1409,13 +1443,16 @@ function remove_backups { --yesno $"\nPlease confirm that you wish to remove backups from this drive\n\n ${drive}\n\nYou will not be able to recover them afterwards." 12 60 sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac clear ${PROJECT_NAME}-backup-local $USB_DRIVE remove any_key + rm $data } function shut_down_system { @@ -1465,6 +1502,7 @@ function change_system_name { fi ;; esac + rm $data } function set_dynamic_IP { @@ -1515,11 +1553,14 @@ Enter a static local IP address for this system.\n\nIt will typically be ${IPv4_ 0) NEW_STATIC_IP=$(<$data) if [[ "$NEW_STATIC_IP" != *"."* ]]; then set_dynamic_IP + rm $data return fi ;; - 1) return;; + 1) rm $data + return;; esac + rm $data # get the gateway data=$(tempfile 2>/dev/null) @@ -1531,10 +1572,12 @@ Enter a static local IP address for this system.\n\nIt will typically be ${IPv4_ case $sel in 0) NEW_STATIC_GATEWAY=$(<$data) if [[ "$NEW_STATIC_GATEWAY" != *"."* ]]; then + rm $data return fi ;; - 1) return;; + 1) rm $data + return;; esac if [[ "$NEW_STATIC_GATEWAY" == *"."* && "$NEW_STATIC_IP" == *"."* ]]; then @@ -1604,6 +1647,7 @@ Enter a static local IP address for this system.\n\nIt will typically be ${IPv4_ esac fi fi + rm $data } function wifi_settings { @@ -1662,8 +1706,10 @@ function hotspot_settings { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac TEMP_WIFI_HOTSPOT=$(cat $data | sed -n 1p) TEMP_WIFI_SSID=$(cat $data | sed -n 2p) @@ -1671,9 +1717,11 @@ function hotspot_settings { TEMP_WIFI_PASSPHRASE=$(cat $data | sed -n 4p) if [ ${#TEMP_WIFI_SSID} -lt 2 ]; then + rm $data return fi if [ ${#TEMP_WIFI_TYPE} -lt 2 ]; then + rm $data return fi @@ -1691,11 +1739,13 @@ function hotspot_settings { if [ ! $TEMP_WIFI_PASSPHRASE ]; then dialog --title $"Wifi Settings" \ --msgbox $"No wifi hotspot passphrase was given" 6 40 + rm $data return fi if [ ${#TEMP_WIFI_PASSPHRASE} -lt 2 ]; then dialog --title $"Wifi Settings" \ --msgbox $"Wifi hotspot passphrase was too short" 6 40 + rm $data return fi @@ -1726,6 +1776,7 @@ function hotspot_settings { dialog --title $"Wifi Settings" \ --msgbox $"Hotspot settings were changed" 6 40 + rm $data } function reinstall_mariadb { @@ -1792,6 +1843,7 @@ function email_extra_domains { fi ;; esac + rm $data } function email_smtp_proxy { @@ -1823,6 +1875,7 @@ function email_smtp_proxy { SMTP_PROXY_PORT=$(cat $data | sed -n 4p) SMTP_PROXY_USERNAME=$(cat $data | sed -n 5p) SMTP_PROXY_PASSWORD=$(cat $data | sed -n 6p) + rm $data # change muttrc if [ $SMTP_PROXY_ENABLE != $'no' ]; then @@ -1868,8 +1921,10 @@ function menu_backup_restore { 11 $"Back to main menu" on 2> $data sel=$? case $sel in - 1) break;; - 255) break;; + 1) rm $data + break;; + 255) rm $data + break;; esac case $(cat $data) in 1) backup_data;; @@ -1884,6 +1939,7 @@ function menu_backup_restore { 10) remove_backups;; 11) break;; esac + rm $data done } @@ -1905,8 +1961,10 @@ function menu_email { 8 $"Back to main menu" on 2> $data sel=$? case $sel in - 1) break;; - 255) break;; + 1) rm $data + break;; + 255) rm $data + break;; esac case $(cat $data) in 1) add_to_mailing_list;; @@ -1918,6 +1976,7 @@ function menu_email { 7) email_extra_domains;; 8) break;; esac + rm $data done } @@ -1945,6 +2004,7 @@ function domain_blocking_add { fi ;; esac + rm $data } function ip_blocking_add { @@ -1968,6 +2028,7 @@ function ip_blocking_add { fi ;; esac + rm $data } function domain_blocking_remove { @@ -1994,6 +2055,7 @@ function domain_blocking_remove { fi ;; esac + rm $data } function ip_blocking_remove { @@ -2017,6 +2079,7 @@ function ip_blocking_remove { fi ;; esac + rm $data } function domain_blocking_show { @@ -2049,8 +2112,10 @@ function domain_blocking { 6 $"Back to main menu" on 2> $data sel=$? case $sel in - 1) break;; - 255) break;; + 1) rm $data + break;; + 255) rm $data + break;; esac case $(cat $data) in 1) domain_blocking_add;; @@ -2058,8 +2123,10 @@ function domain_blocking { 3) ip_blocking_add;; 4) ip_blocking_remove;; 5) domain_blocking_show;; - 6) break;; + 6) rm $data + break;; esac + rm $data done } @@ -2079,8 +2146,10 @@ function menu_users { 6 $"Back to main menu" on 2> $data sel=$? case $sel in - 1) break;; - 255) break;; + 1) rm $data + break;; + 255) rm $data + break;; esac case $(cat $data) in 1) add_user;; @@ -2088,8 +2157,10 @@ function menu_users { 3) change_password;; 4) change_ssh_public_key;; 5) reset_password_tries;; - 6) break;; + 6) rm $data + break;; esac + rm $data done } @@ -2172,16 +2243,20 @@ function menu_wifi { 5 $"Exit" on 2> $data sel=$? case $sel in - 1) break;; - 255) break;; + 1) rm $data + break;; + 255) rm $data + break;; esac case $(cat $data) in 1) wifi_enable;; 2) wifi_settings;; 3) wifi_edit_networks;; 4) hotspot_settings;; - 5) break;; + 5) rm $data + break;; esac + rm $data done } @@ -2256,8 +2331,10 @@ function menu_top_level { 22 $"Exit" on 2> $data sel=$? case $sel in - 1) exit 1;; - 255) exit 1;; + 1) rm $data + exit 1;; + 255) rm $data + exit 1;; esac please_wait case $(cat $data) in @@ -2287,8 +2364,10 @@ function menu_top_level { 19) check_for_updates;; 20) shut_down_system;; 21) restart_system;; - 22) break;; + 22) rm $data + break;; esac + rm $data done } diff --git a/src/freedombone-controlpanel-user b/src/freedombone-controlpanel-user index ea588d1c..894435aa 100755 --- a/src/freedombone-controlpanel-user +++ b/src/freedombone-controlpanel-user @@ -13,7 +13,7 @@ # License # ======= # -# Copyright (C) 2016 Bob Mottram +# Copyright (C) 2018 Bob Mottram # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -169,8 +169,10 @@ function add_to_mailing_list { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac LIST_NAME=$(cat $data | sed -n 1p) LIST_SUBJECT=$(cat $data | sed -n 2p) @@ -188,12 +190,14 @@ function add_to_mailing_list { if [ ${#LIST_NAME} -lt 2 ]; then dialog --title $"Add mailing list" \ --msgbox $"No mailing list name was given" 6 40 + rm $data return fi if [ ${#LIST_SUBJECT} -lt 2 ]; then if [ ${#LIST_EMAIL} -lt 2 ]; then dialog --title $"Add mailing list" \ --msgbox $"No mailing list subject or address was given" 6 40 + rm $data return fi fi @@ -204,6 +208,7 @@ function add_to_mailing_list { if [[ "$LIST_EMAIL" != *"@"* || "$LIST_EMAIL" != *"."* ]]; then dialog --title $"Add mailing list" \ --msgbox $"Unrecognised email address" 6 40 + rm $data return else ${PROJECT_NAME}-addlist -u $USER -l "$LIST_NAME" \ @@ -213,6 +218,7 @@ function add_to_mailing_list { dialog --title $"Add mailing list" \ --msgbox $"$LIST_NAME list was added" 6 40 + rm $data } function email_rule_address { @@ -227,8 +233,10 @@ function email_rule_address { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac RULE_EMAIL=$(cat $data | sed -n 1p) RULE_FOLDER=$(cat $data | sed -n 2p) @@ -245,16 +253,19 @@ function email_rule_address { if [ ${#RULE_EMAIL} -lt 2 ]; then dialog --title $"Create an email rule" \ --msgbox $"No email address was given" 6 40 + rm $data return fi if [ ${#RULE_FOLDER} -lt 2 ]; then dialog --title $"Create an email rule" \ --msgbox $"No folder name was given" 6 40 + rm $data return fi if [[ "$RULE_EMAIL" != *"@"* || "$RULE_EMAIL" != *"."* ]]; then dialog --title $"Create an email rule" \ --msgbox $"Unrecognised email address" 6 40 + rm $data return fi @@ -262,6 +273,7 @@ function email_rule_address { -g "$RULE_FOLDER" --public $RULE_PUBLIC dialog --title $"Create an email rule" \ --msgbox $"Email rule for $RULE_EMAIL was added" 6 40 + rm $data } function gpg_set_trust { @@ -281,8 +293,10 @@ function gpg_set_trust { 5 $"I trust ultimately" off 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac TRUST_LEVEL=$(cat $data) if [ ${TRUST_LEVEL} -ge 1 ] ; then @@ -296,6 +310,7 @@ function gpg_set_trust { fi fi fi + rm $data fi } @@ -311,8 +326,10 @@ function email_rule_subject { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac RULE_SUBJECT=$(cat $data | sed -n 1p) RULE_FOLDER=$(cat $data | sed -n 2p) @@ -329,11 +346,13 @@ function email_rule_subject { if [ ${#RULE_SUBJECT} -lt 2 ]; then dialog --title $"Create an email rule" \ --msgbox $"No subject text was given" 6 40 + rm $data return fi if [ ${#RULE_FOLDER} -lt 2 ]; then dialog --title $"Create an email rule" \ --msgbox $"No folder name was given" 6 40 + rm $data return fi @@ -341,6 +360,7 @@ function email_rule_subject { -g "$RULE_FOLDER" --public $RULE_PUBLIC dialog --title $"Create an email rule" \ --msgbox $"Email rule for subject '$RULE_SUBJECT' was added" 6 40 + rm $data } function block_unblock_email { @@ -355,8 +375,10 @@ function block_unblock_email { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac BLOCK_EMAIL=$(cat $data | sed -n 1p) BLOCK=$(cat $data | sed -n 2p) @@ -368,6 +390,7 @@ function block_unblock_email { if [[ "$BLOCK_EMAIL" != *"@"* || "$BLOCK_EMAIL" != *"."* ]]; then dialog --title "$blockstr" \ --msgbox $"Unrecognised email address" 6 40 + rm $data return fi if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then @@ -379,6 +402,7 @@ function block_unblock_email { dialog --title $"Unblock an email" \ --msgbox "Email from $BLOCK_EMAIL is now unblocked" 6 75 fi + rm $data } function block_unblock_subject { @@ -393,14 +417,17 @@ function block_unblock_subject { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac BLOCK_SUBJECT=$(cat $data | sed -n 1p) BLOCK=$(cat $data | sed -n 2p) if [ ${#BLOCK_SUBJECT} -lt 2 ]; then dialog --title "$blockstr" \ --msgbox $"No subject was given" 6 40 + rm $data return fi if [[ $BLOCK == "y"* || $BLOCK == "Y"* ]]; then @@ -412,6 +439,7 @@ function block_unblock_subject { dialog --title $"Unblock an email" \ --msgbox $"Email with subject $BLOCK_SUBJECT is now unblocked" 6 40 fi + rm $data } function show_gpg_key { @@ -530,6 +558,7 @@ function remove_gpg_key { fi ;; esac + rm $data } function add_ssh_key { @@ -568,6 +597,7 @@ function add_ssh_key { fi ;; esac + rm $data } function remove_ssh_key { @@ -590,6 +620,7 @@ function remove_ssh_key { fi ;; esac + rm $data } function smtp_proxy { @@ -631,8 +662,10 @@ function smtp_proxy { 2> $data sel=$? case $sel in - 1) return;; - 255) return;; + 1) rm $data + return;; + 255) rm $data + return;; esac SMTP_PROXY_ENABLE=$(cat $data | sed -n 1p) SMTP_PROXY_PROTOCOL=$(cat $data | sed -n 2p) @@ -654,6 +687,7 @@ function smtp_proxy { sed -i 's|set smtp_url|#set smtp_url|g' $MUTTRC_FILE fi fi + rm $data } function sign_gpg_key { @@ -682,6 +716,7 @@ function sign_gpg_key { fi ;; esac + rm $data } @@ -702,6 +737,7 @@ function gpg_key_trust { fi ;; esac + rm $data } function menu_encryption_keys { @@ -725,8 +761,10 @@ function menu_encryption_keys { 11 $"Back to main menu" on 2> $data sel=$? case $sel in - 1) break;; - 255) break;; + 1) rm $data + break;; + 255) rm $data + break;; esac case $(cat $data) in 1) show_gpg_key;; @@ -739,8 +777,10 @@ function menu_encryption_keys { 8) add_ssh_key;; 9) remove_ssh_key;; 10) gpg_key_trust;; - 11) break;; + 11) rm $data + break;; esac + rm $data done } @@ -761,8 +801,10 @@ function menu_email { 7 $"Back to main menu" on 2> $data sel=$? case $sel in - 1) break;; - 255) break;; + 1) rm $data + break;; + 255) rm $data + break;; esac case $(cat $data) in 1) add_to_mailing_list;; @@ -771,8 +813,10 @@ function menu_email { 4) email_rule_subject;; 5) block_unblock_email;; 6) block_unblock_subject;; - 7) break;; + 7) rm $data + break;; esac + rm $data done } @@ -857,8 +901,10 @@ function menu_top_level { 9 $"Log out" on 2> $data sel=$? case $sel in - 1) exit 1;; - 255) exit 1;; + 1) rm $data + exit 1;; + 255) rm $data + exit 1;; esac case $(cat $data) in 1) mutt;; @@ -868,9 +914,11 @@ function menu_top_level { 5) menu_encryption_keys;; 6) smtp_proxy;; 7) menu_admin;; - 8) break;; + 8) rm $data + break;; 9) kill -HUP `pgrep -s 0 -o`;; esac + rm $data done }