浏览代码

Remove xinetd when fixing stig tests, since it causes a violation

Bob Mottram 7 年前
父节点
当前提交
ca5428ca33
共有 3 个文件被更改,包括 5 次插入174 次删除
  1. 0
    174
      src/freedombone-base-email
  2. 4
    0
      src/freedombone-tests
  3. 1
    0
      src/freedombone-utils-web

+ 0
- 174
src/freedombone-base-email 查看文件

@@ -805,179 +805,6 @@ function remove_email {
805 805
     echo ''
806 806
 }
807 807
 
808
-function install_email_with_tor {
809
-    apt-get -yq remove postfix
810
-    apt-get -yq install exim4 sasl2-bin swaks libnet-ssleay-perl procmail xinetd
811
-
812
-    if [ ! -d /etc/exim4 ]; then
813
-        echo $"ERROR: Exim does not appear to have installed. $CHECK_MESSAGE"
814
-        exit 48
815
-    fi
816
-
817
-    onion_service_name='email'
818
-    if [ ! -d /var/lib/tor ]; then
819
-        echo $"No Tor installation found. ${onion_service_name} onion site cannot be configured."
820
-        exit 877367
821
-    fi
822
-    if ! grep -q "hidden_service_${onion_service_name}" /etc/tor/torrc; then
823
-        echo "HiddenServiceDir /var/lib/tor/hidden_service_${onion_service_name}/" >> /etc/tor/torrc
824
-        echo 'HiddenServicePort 25 127.0.0.1:25' >> /etc/tor/torrc
825
-        echo 'HiddenServicePort 587 127.0.0.1:587' >> /etc/tor/torrc
826
-        echo 'HiddenServicePort 465 127.0.0.1:465' >> /etc/tor/torrc
827
-        echo 'HiddenServicePort 993 127.0.0.1:993' >> /etc/tor/torrc
828
-        echo $"Added onion site for ${onion_service_name}"
829
-    fi
830
-
831
-    onion_update
832
-    function_check wait_for_onion_service
833
-    wait_for_onion_service ${onion_service_name}
834
-
835
-    if [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
836
-        echo $"${onion_service_name} onion site hostname not found"
837
-        exit 76362
838
-    fi
839
-    EMAIL_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
840
-
841
-    if [[ $ONION_ONLY != "no" ]]; then
842
-        function_check set_hostname
843
-        set_hostname ${EMAIL_ONION_HOSTNAME}
844
-        MY_EMAIL_ADDRESS=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}
845
-    fi
846
-    set_completion_param "email onion domain" "${EMAIL_ONION_HOSTNAME}"
847
-
848
-    # see https://github.com/petterreinholdtsen/exim4-smtorp
849
-    echo '# tor stuff first' > /etc/exim4/conf.d/router/100_exim4-smtorp
850
-    echo '#' >> /etc/exim4/conf.d/router/100_exim4-smtorp
851
-    echo '# if were submitting mail *from* a .tor/.onion address,' >> /etc/exim4/conf.d/router/100_exim4-smtorp
852
-    echo '# make sure any header lines that may give us away is' >> /etc/exim4/conf.d/router/100_exim4-smtorp
853
-    echo '# stripped out, and add a new, cryptic Message-ID.' >> /etc/exim4/conf.d/router/100_exim4-smtorp
854
-    echo '# In address_data we store the name we should HELO as.' >> /etc/exim4/conf.d/router/100_exim4-smtorp
855
-    echo 'tor_to_any:' >> /etc/exim4/conf.d/router/100_exim4-smtorp
856
-    echo '        debug_print     = "R: manualroute from .onion to $local_part@$domain"' >> /etc/exim4/conf.d/router/100_exim4-smtorp
857
-    echo '        driver          = manualroute' >> /etc/exim4/conf.d/router/100_exim4-smtorp
858
-    echo '        domains         = ! +local_domains' >> /etc/exim4/conf.d/router/100_exim4-smtorp
859
-    echo '        condition       = ${if match {$sender_address_domain}{\N.*\.(onion|tor)$\N}}' >> /etc/exim4/conf.d/router/100_exim4-smtorp
860
-    echo '        address_data    = $sender_address_domain' >> /etc/exim4/conf.d/router/100_exim4-smtorp
861
-    echo '        transport       = remote_smtp_onion' >> /etc/exim4/conf.d/router/100_exim4-smtorp
862
-    echo '        self            = send' >> /etc/exim4/conf.d/router/100_exim4-smtorp
863
-    echo '        route_list      = * localhost' >> /etc/exim4/conf.d/router/100_exim4-smtorp
864
-    echo '        headers_remove  = Received:Message-ID:X-Mailer:User-Agent' >> /etc/exim4/conf.d/router/100_exim4-smtorp
865
-    echo '        headers_add     = Message-ID: <${lc:${sha1:$message_id}}@$sender_address_domain>' >> /etc/exim4/conf.d/router/100_exim4-smtorp
866
-    echo '' >> /etc/exim4/conf.d/router/100_exim4-smtorp
867
-    echo '# this catches the case where were submitting mail' >> /etc/exim4/conf.d/router/100_exim4-smtorp
868
-    echo '# from a regular email address where we dont need to' >> /etc/exim4/conf.d/router/100_exim4-smtorp
869
-    echo '# rewrite any headers' >> /etc/exim4/conf.d/router/100_exim4-smtorp
870
-    echo 'any_to_tor:' >> /etc/exim4/conf.d/router/100_exim4-smtorp
871
-    echo '        debug_print     = "R: manualroute for $local_part@$domain"' >> /etc/exim4/conf.d/router/100_exim4-smtorp
872
-    echo '        driver          = manualroute' >> /etc/exim4/conf.d/router/100_exim4-smtorp
873
-    echo '        domains         = ! +local_domains' >> /etc/exim4/conf.d/router/100_exim4-smtorp
874
-    echo '        transport       = remote_smtp_onion' >> /etc/exim4/conf.d/router/100_exim4-smtorp
875
-    echo '        self            = send' >> /etc/exim4/conf.d/router/100_exim4-smtorp
876
-    echo '        route_list      = *.onion localhost ; *.tor localhost' >> /etc/exim4/conf.d/router/100_exim4-smtorp
877
-    echo '        address_data    = $smtp_active_hostname' >> /etc/exim4/conf.d/router/100_exim4-smtorp
878
-
879
-    echo 'remote_smtp_onion:' > /etc/exim4/conf.d/transport/100_exim4-smtorp
880
-    echo '        debug_print = "T: remote_smtp_onion for $local_part@$original_domain"' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
881
-    echo '        driver = smtp' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
882
-    echo '' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
883
-    echo '        # set helo_data to where we want to connect to,' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
884
-    echo '        # for the proxy program tor-smtp' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
885
-    echo '        helo_data = "$address_data $original_domain"' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
886
-    echo '' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
887
-    echo '        # wherever we configured our script at' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
888
-    echo '        port = 12668' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
889
-    echo '' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
890
-    echo '        # cannot use TLS otherwise it will EHLO again!!' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
891
-    echo '        hosts_avoid_tls = *' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
892
-
893
-    if [ ! -d $INSTALL_DIR ]; then
894
-        mkdir -p $INSTALL_DIR
895
-    fi
896
-    cd $INSTALL_DIR
897
-    function_check git_clone
898
-    git_clone $EXIM_ONION_REPO $INSTALL_DIR/exim4-smtorp
899
-    cd $INSTALL_DIR/exim4-smtorp/tor-smtp
900
-    make
901
-    if [ ! -f $INSTALL_DIR/exim4-smtorp/tor-smtp/tor-smtp ]; then
902
-        echo $'Unable to make tor smtp transport'
903
-        exit 52629
904
-    fi
905
-    if [ ! -d /usr/lib/exim4-smtorp ]; then
906
-        mkdir /usr/lib/exim4-smtorp
907
-    fi
908
-    cp $INSTALL_DIR/exim4-smtorp/tor-smtp/tor-smtp /usr/lib/exim4-smtorp/tor-smtp
909
-    if [ ! -f /usr/lib/exim4-smtorp/tor-smtp ]; then
910
-        echo $'Unable to copy tor-smtp'
911
-        exit 83503
912
-    fi
913
-    cp $INSTALL_DIR/exim4-smtorp/xinetd /etc/xinetd.d/tor-smtp
914
-    if [ ! -f /etc/xinetd.d/tor-smtp ]; then
915
-        echo $'Unable to copy to xinetd.d'
916
-        exit 835954
917
-    fi
918
-    systemctl restart xinetd
919
-
920
-    # configure for Maildir format
921
-    sed -i 's/MAIL_DIR/#MAIL_DIR/g' /etc/login.defs
922
-    sed -i 's|#MAIL_FILE.*|MAIL_FILE Maildir/|g' /etc/login.defs
923
-
924
-    if ! grep -q "export MAIL" /etc/profile; then
925
-        echo 'export MAIL=~/Maildir' >> /etc/profile
926
-    fi
927
-
928
-    sed -i 's|pam_mail.so standard|pam_mail.so dir=~/Maildir standard|g' /etc/pam.d/login
929
-    sed -i 's|pam_mail.so standard noenv|pam_mail.so dir=~/Maildir standard|g' /etc/pam.d/sshd
930
-    sed -i 's|pam_mail.so nopen|pam_mail.so dir=~/Maildir nopen|g' /etc/pam.d/su
931
-
932
-    echo "dc_eximconfig_configtype='internet'" > /etc/exim4/update-exim4.conf.conf
933
-    if [[ $ONION_ONLY == "no" ]]; then
934
-        # both ICANN and onion domains
935
-        echo "dc_other_hostnames='${DEFAULT_DOMAIN_NAME};mail.${DEFAULT_DOMAIN_NAME};${EMAIL_ONION_HOSTNAME}'" >> /etc/exim4/update-exim4.conf.conf
936
-    else
937
-        echo "dc_other_hostnames='${EMAIL_ONION_HOSTNAME}'" >> /etc/exim4/update-exim4.conf.conf
938
-    fi
939
-    echo "dc_local_interfaces=''" >> /etc/exim4/update-exim4.conf.conf
940
-    echo "dc_readhost=''" >> /etc/exim4/update-exim4.conf.conf
941
-    echo "dc_relay_domains=''" >> /etc/exim4/update-exim4.conf.conf
942
-    echo "dc_minimaldns='false'" >> /etc/exim4/update-exim4.conf.conf
943
-    IPv4_address=$(get_ipv4_address)
944
-    IPv4_address_base=$(echo "$IPv4_address" | awk -F '.' '{print $1"."$2"."$3}')
945
-    RELAY_NETS="${IPv4_address_base}.0/24"
946
-    if [ $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
947
-        RELAY_NETS=$(echo $LOCAL_NETWORK_STATIC_IP_ADDRESS | awk -F '.' '{print $1 "." $2 "." $3 ".0/24"}')
948
-    fi
949
-    echo "dc_relay_nets='$RELAY_NETS'" >> /etc/exim4/update-exim4.conf.conf
950
-    echo "dc_smarthost=''" >> /etc/exim4/update-exim4.conf.conf
951
-    echo "CFILEMODE='644'" >> /etc/exim4/update-exim4.conf.conf
952
-    echo "dc_use_split_config='false'" >> /etc/exim4/update-exim4.conf.conf
953
-    echo "dc_hide_mailname=''" >> /etc/exim4/update-exim4.conf.conf
954
-    echo "dc_mailname_in_oh='true'" >> /etc/exim4/update-exim4.conf.conf
955
-    echo "dc_localdelivery='maildir_home'" >> /etc/exim4/update-exim4.conf.conf
956
-    echo "dc_main_log_selector=-all" >> /etc/exim4/update-exim4.conf.conf
957
-    update-exim4.conf
958
-    sed -i "s/START=no/START=yes/g" /etc/default/saslauthd
959
-    systemctl start saslauthd
960
-
961
-    email_install_tls
962
-
963
-    adduser $MY_USERNAME sasl
964
-    addgroup Debian-exim sasl
965
-    systemctl restart exim4
966
-
967
-    email_create_template
968
-
969
-    if [ -f /usr/sbin/exim ]; then
970
-        chmod u+s /usr/sbin/exim
971
-    fi
972
-    if [ -f /usr/sbin/exim4 ]; then
973
-        chmod u+s /usr/sbin/exim4
974
-    fi
975
-
976
-    function_check configure_firewall_for_email
977
-    configure_firewall_for_email
978
-    dpkg-reconfigure --frontend noninteractive exim4-config
979
-}
980
-
981 808
 function install_email_basic {
982 809
     apt-get -yq remove postfix
983 810
     apt-get -yq install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
@@ -1683,7 +1510,6 @@ function install_email {
1683 1510
     check_email_address_exists
1684 1511
     install_email_basic
1685 1512
     configure_email_onion
1686
-    #install_email_with_tor
1687 1513
 
1688 1514
     mark_completed $FUNCNAME
1689 1515
 }

+ 4
- 0
src/freedombone-tests 查看文件

@@ -135,6 +135,10 @@ function fix_stig {
135 135
     if [[ $RUN_STIG != 'fix' ]]; then
136 136
         return
137 137
     fi
138
+    if service --status-all | grep "+.*xinetd";then
139
+        apt-get -yq remove --purge xinetd
140
+        apt -yq autoremove
141
+    fi
138 142
     lockdown_permissions
139 143
 }
140 144
 

+ 1
- 0
src/freedombone-utils-web 查看文件

@@ -1014,6 +1014,7 @@ function email_install_tls {
1014 1014
         email_config_changed=1
1015 1015
     fi
1016 1016
     if [ $email_config_changed ]; then
1017
+        systemctl restart saslauthd
1017 1018
         systemctl restart exim4
1018 1019
     fi
1019 1020
 }