소스 검색

Can set tls date source from the control panel

Bob Mottram 9 년 전
부모
커밋
a6dee9f998
1개의 변경된 파일37개의 추가작업 그리고 9개의 파일을 삭제
  1. 37
    9
      src/freedombone-controlpanel

+ 37
- 9
src/freedombone-controlpanel 파일 보기

@@ -38,6 +38,7 @@ SELECTED_USERNAME=
38 38
 SIP_CONFIG_FILE=/etc/sipwitch.conf
39 39
 ADMIN_USER=
40 40
 UPGRADE_SCRIPT_NAME="${PROJECT_NAME}-upgrade"
41
+UPDATE_DATE_SCRIPT=/usr/bin/updatedate
41 42
 
42 43
 function any_key {
43 44
     echo ' '
@@ -707,6 +708,31 @@ function change_system_name {
707 708
     esac
708 709
 }
709 710
 
711
+function set_tls_time_source {
712
+    TLS_DATE_SOURCE=$(cat $UPDATE_DATE_SCRIPT | grep 'TIMESOURCE=' | awk -F '=' '{print $2}')
713
+    data=$(tempfile 2>/dev/null)
714
+    trap "rm -f $data" 0 1 2 5 15
715
+    dialog --title $"Set the TLS date/time source" \
716
+           --backtitle $"Freedombone Control Panel" \
717
+           --inputbox $"Enter a domain name to use as a TLS time source.\n\nFactors to consider when choosing a source are whether you wish that site to know that your system is 'alive' and also what might happen if an adversary were to try to mess with the date/time from that domain (i.e. how much blowback would there be)." 14 60 "$TLS_DATE_SOURCE" 2>$data
718
+    sel=$?
719
+    case $sel in
720
+        0) NEW_TLS_DATE_SOURCE=$(<$data)
721
+           if [[ $NEW_TLS_DATE_SOURCE == *"."* && $NEW_TLS_DATE_SOURCE != *'/'* ]]; then
722
+               if [[ $NEW_TLS_DATE_SOURCE != "http"* ]]; then
723
+                   sed -i "s|TIMESOURCE=.*|TIMESOURCE=${NEW_TLS_DATE_SOURCE}|g" $UPDATE_DATE_SCRIPT
724
+               else
725
+                   dialog --title $"Invalid domain name" \
726
+                          --msgbox $"Don't include the 'https'" 6 70
727
+               fi
728
+           else
729
+               dialog --title $"Invalid domain name" \
730
+                      --msgbox $"That doesn't look like a domain name" 6 70
731
+           fi
732
+           ;;
733
+    esac
734
+}
735
+
710 736
 function menu_backup_restore {
711 737
     while true
712 738
     do
@@ -859,7 +885,7 @@ function menu_top_level {
859 885
         trap "rm -f $data" 0 1 2 5 15
860 886
         dialog --backtitle $"Freedombone Control Panel" \
861 887
                --title $"Control Panel" \
862
-               --radiolist $"Choose an operation:" 21 70 14 \
888
+               --radiolist $"Choose an operation:" 22 70 15 \
863 889
                1 $"Backup and Restore" off \
864 890
                2 $"Show SIP Phone Extensions" off \
865 891
                3 $"Reset Tripwire" off \
@@ -870,10 +896,11 @@ function menu_top_level {
870 896
                8 $"Hubzilla" off \
871 897
                9 $"Media menu" off \
872 898
                10 $"Change the name of this system" off \
873
-               11 $"Check for updates" off \
874
-               12 $"Power off the system" off \
875
-               13 $"Restart the system" off \
876
-               14 $"Exit" on 2> $data
899
+               11 $"Set the TLS date/time source" off \
900
+               12 $"Check for updates" off \
901
+               13 $"Power off the system" off \
902
+               14 $"Restart the system" off \
903
+               15 $"Exit" on 2> $data
877 904
         sel=$?
878 905
         case $sel in
879 906
             1) exit 1;;
@@ -890,10 +917,11 @@ function menu_top_level {
890 917
             8) menu_hubzilla;;
891 918
             9) menu_media;;
892 919
             10) change_system_name;;
893
-            11) check_for_updates;;
894
-            12) shut_down_system;;
895
-            13) restart_system;;
896
-            14) break;;
920
+            11) set_tls_time_source;;
921
+            12) check_for_updates;;
922
+            13) shut_down_system;;
923
+            14) restart_system;;
924
+            15) break;;
897 925
         esac
898 926
     done
899 927
 }