|
@@ -119,33 +119,6 @@ function email_create_template {
|
119
|
119
|
fi
|
120
|
120
|
}
|
121
|
121
|
|
122
|
|
-function email_install_tls {
|
123
|
|
- # make a tls certificate for email
|
124
|
|
- if [ ! -f /etc/ssl/certs/exim.dhparam ]; then
|
125
|
|
- ${PROJECT_NAME}-addcert -h exim --dhkey $DH_KEYLENGTH
|
126
|
|
- check_certificates exim
|
127
|
|
- fi
|
128
|
|
- cp /etc/ssl/private/exim.key /etc/exim4
|
129
|
|
- cp /etc/ssl/certs/exim.crt /etc/exim4
|
130
|
|
- cp /etc/ssl/certs/exim.dhparam /etc/exim4
|
131
|
|
- chown root:Debian-exim /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
|
132
|
|
- chmod 640 /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
|
133
|
|
-
|
134
|
|
- sed -i '/login_saslauthd_server/,/.endif/ s/# *//' /etc/exim4/exim4.conf.template
|
135
|
|
- if ! grep -q "MAIN_TLS_ENABLE = true" /etc/exim4/exim4.conf.template; then
|
136
|
|
- sed -i "/.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME/i\MAIN_HARDCODE_PRIMARY_HOSTNAME =\nMAIN_TLS_ENABLE = true" /etc/exim4/exim4.conf.template
|
137
|
|
- else
|
138
|
|
- sed -i "s|MAIN_HARDCODE_PRIMARY_HOSTNAME =.*|MAIN_HARDCODE_PRIMARY_HOSTNAME =|g" /etc/exim4/exim4.conf.template
|
139
|
|
- fi
|
140
|
|
- sed -i "s|SMTPLISTENEROPTIONS=''|SMTPLISTENEROPTIONS='-oX 465:25:587 -oP /var/run/exim4/exim.pid'|g" /etc/default/exim4
|
141
|
|
- if ! grep -q "tls_on_connect_ports=465" /etc/exim4/exim4.conf.template; then
|
142
|
|
- sed -i '/SSL configuration for exim/i\tls_on_connect_ports=465' /etc/exim4/exim4.conf.template
|
143
|
|
- fi
|
144
|
|
- if ! grep -q "# don't send system passwords" /etc/exim4/exim4.conf.template; then
|
145
|
|
- sed -i "s|don't send system passwords.*|# don't send system passwords unencrypted|g" /etc/exim4/exim4.conf.template
|
146
|
|
- fi
|
147
|
|
-}
|
148
|
|
-
|
149
|
122
|
function configure_email_onion {
|
150
|
123
|
if [[ $(is_completed $FUNCNAME) == "1" ]]; then
|
151
|
124
|
return
|
|
@@ -832,179 +805,6 @@ function remove_email {
|
832
|
805
|
echo ''
|
833
|
806
|
}
|
834
|
807
|
|
835
|
|
-function install_email_with_tor {
|
836
|
|
- apt-get -yq remove postfix
|
837
|
|
- apt-get -yq install exim4 sasl2-bin swaks libnet-ssleay-perl procmail xinetd
|
838
|
|
-
|
839
|
|
- if [ ! -d /etc/exim4 ]; then
|
840
|
|
- echo $"ERROR: Exim does not appear to have installed. $CHECK_MESSAGE"
|
841
|
|
- exit 48
|
842
|
|
- fi
|
843
|
|
-
|
844
|
|
- onion_service_name='email'
|
845
|
|
- if [ ! -d /var/lib/tor ]; then
|
846
|
|
- echo $"No Tor installation found. ${onion_service_name} onion site cannot be configured."
|
847
|
|
- exit 877367
|
848
|
|
- fi
|
849
|
|
- if ! grep -q "hidden_service_${onion_service_name}" /etc/tor/torrc; then
|
850
|
|
- echo "HiddenServiceDir /var/lib/tor/hidden_service_${onion_service_name}/" >> /etc/tor/torrc
|
851
|
|
- echo 'HiddenServicePort 25 127.0.0.1:25' >> /etc/tor/torrc
|
852
|
|
- echo 'HiddenServicePort 587 127.0.0.1:587' >> /etc/tor/torrc
|
853
|
|
- echo 'HiddenServicePort 465 127.0.0.1:465' >> /etc/tor/torrc
|
854
|
|
- echo 'HiddenServicePort 993 127.0.0.1:993' >> /etc/tor/torrc
|
855
|
|
- echo $"Added onion site for ${onion_service_name}"
|
856
|
|
- fi
|
857
|
|
-
|
858
|
|
- onion_update
|
859
|
|
- function_check wait_for_onion_service
|
860
|
|
- wait_for_onion_service ${onion_service_name}
|
861
|
|
-
|
862
|
|
- if [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
|
863
|
|
- echo $"${onion_service_name} onion site hostname not found"
|
864
|
|
- exit 76362
|
865
|
|
- fi
|
866
|
|
- EMAIL_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
|
867
|
|
-
|
868
|
|
- if [[ $ONION_ONLY != "no" ]]; then
|
869
|
|
- function_check set_hostname
|
870
|
|
- set_hostname ${EMAIL_ONION_HOSTNAME}
|
871
|
|
- MY_EMAIL_ADDRESS=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}
|
872
|
|
- fi
|
873
|
|
- set_completion_param "email onion domain" "${EMAIL_ONION_HOSTNAME}"
|
874
|
|
-
|
875
|
|
- # see https://github.com/petterreinholdtsen/exim4-smtorp
|
876
|
|
- echo '# tor stuff first' > /etc/exim4/conf.d/router/100_exim4-smtorp
|
877
|
|
- echo '#' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
878
|
|
- echo '# if were submitting mail *from* a .tor/.onion address,' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
879
|
|
- echo '# make sure any header lines that may give us away is' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
880
|
|
- echo '# stripped out, and add a new, cryptic Message-ID.' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
881
|
|
- echo '# In address_data we store the name we should HELO as.' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
882
|
|
- echo 'tor_to_any:' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
883
|
|
- echo ' debug_print = "R: manualroute from .onion to $local_part@$domain"' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
884
|
|
- echo ' driver = manualroute' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
885
|
|
- echo ' domains = ! +local_domains' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
886
|
|
- echo ' condition = ${if match {$sender_address_domain}{\N.*\.(onion|tor)$\N}}' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
887
|
|
- echo ' address_data = $sender_address_domain' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
888
|
|
- echo ' transport = remote_smtp_onion' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
889
|
|
- echo ' self = send' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
890
|
|
- echo ' route_list = * localhost' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
891
|
|
- echo ' headers_remove = Received:Message-ID:X-Mailer:User-Agent' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
892
|
|
- echo ' headers_add = Message-ID: <${lc:${sha1:$message_id}}@$sender_address_domain>' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
893
|
|
- echo '' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
894
|
|
- echo '# this catches the case where were submitting mail' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
895
|
|
- echo '# from a regular email address where we dont need to' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
896
|
|
- echo '# rewrite any headers' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
897
|
|
- echo 'any_to_tor:' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
898
|
|
- echo ' debug_print = "R: manualroute for $local_part@$domain"' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
899
|
|
- echo ' driver = manualroute' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
900
|
|
- echo ' domains = ! +local_domains' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
901
|
|
- echo ' transport = remote_smtp_onion' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
902
|
|
- echo ' self = send' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
903
|
|
- echo ' route_list = *.onion localhost ; *.tor localhost' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
904
|
|
- echo ' address_data = $smtp_active_hostname' >> /etc/exim4/conf.d/router/100_exim4-smtorp
|
905
|
|
-
|
906
|
|
- echo 'remote_smtp_onion:' > /etc/exim4/conf.d/transport/100_exim4-smtorp
|
907
|
|
- echo ' debug_print = "T: remote_smtp_onion for $local_part@$original_domain"' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
908
|
|
- echo ' driver = smtp' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
909
|
|
- echo '' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
910
|
|
- echo ' # set helo_data to where we want to connect to,' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
911
|
|
- echo ' # for the proxy program tor-smtp' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
912
|
|
- echo ' helo_data = "$address_data $original_domain"' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
913
|
|
- echo '' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
914
|
|
- echo ' # wherever we configured our script at' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
915
|
|
- echo ' port = 12668' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
916
|
|
- echo '' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
917
|
|
- echo ' # cannot use TLS otherwise it will EHLO again!!' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
918
|
|
- echo ' hosts_avoid_tls = *' >> /etc/exim4/conf.d/transport/100_exim4-smtorp
|
919
|
|
-
|
920
|
|
- if [ ! -d $INSTALL_DIR ]; then
|
921
|
|
- mkdir -p $INSTALL_DIR
|
922
|
|
- fi
|
923
|
|
- cd $INSTALL_DIR
|
924
|
|
- function_check git_clone
|
925
|
|
- git_clone $EXIM_ONION_REPO $INSTALL_DIR/exim4-smtorp
|
926
|
|
- cd $INSTALL_DIR/exim4-smtorp/tor-smtp
|
927
|
|
- make
|
928
|
|
- if [ ! -f $INSTALL_DIR/exim4-smtorp/tor-smtp/tor-smtp ]; then
|
929
|
|
- echo $'Unable to make tor smtp transport'
|
930
|
|
- exit 52629
|
931
|
|
- fi
|
932
|
|
- if [ ! -d /usr/lib/exim4-smtorp ]; then
|
933
|
|
- mkdir /usr/lib/exim4-smtorp
|
934
|
|
- fi
|
935
|
|
- cp $INSTALL_DIR/exim4-smtorp/tor-smtp/tor-smtp /usr/lib/exim4-smtorp/tor-smtp
|
936
|
|
- if [ ! -f /usr/lib/exim4-smtorp/tor-smtp ]; then
|
937
|
|
- echo $'Unable to copy tor-smtp'
|
938
|
|
- exit 83503
|
939
|
|
- fi
|
940
|
|
- cp $INSTALL_DIR/exim4-smtorp/xinetd /etc/xinetd.d/tor-smtp
|
941
|
|
- if [ ! -f /etc/xinetd.d/tor-smtp ]; then
|
942
|
|
- echo $'Unable to copy to xinetd.d'
|
943
|
|
- exit 835954
|
944
|
|
- fi
|
945
|
|
- systemctl restart xinetd
|
946
|
|
-
|
947
|
|
- # configure for Maildir format
|
948
|
|
- sed -i 's/MAIL_DIR/#MAIL_DIR/g' /etc/login.defs
|
949
|
|
- sed -i 's|#MAIL_FILE.*|MAIL_FILE Maildir/|g' /etc/login.defs
|
950
|
|
-
|
951
|
|
- if ! grep -q "export MAIL" /etc/profile; then
|
952
|
|
- echo 'export MAIL=~/Maildir' >> /etc/profile
|
953
|
|
- fi
|
954
|
|
-
|
955
|
|
- sed -i 's|pam_mail.so standard|pam_mail.so dir=~/Maildir standard|g' /etc/pam.d/login
|
956
|
|
- sed -i 's|pam_mail.so standard noenv|pam_mail.so dir=~/Maildir standard|g' /etc/pam.d/sshd
|
957
|
|
- sed -i 's|pam_mail.so nopen|pam_mail.so dir=~/Maildir nopen|g' /etc/pam.d/su
|
958
|
|
-
|
959
|
|
- echo "dc_eximconfig_configtype='internet'" > /etc/exim4/update-exim4.conf.conf
|
960
|
|
- if [[ $ONION_ONLY == "no" ]]; then
|
961
|
|
- # both ICANN and onion domains
|
962
|
|
- echo "dc_other_hostnames='${DEFAULT_DOMAIN_NAME};mail.${DEFAULT_DOMAIN_NAME};${EMAIL_ONION_HOSTNAME}'" >> /etc/exim4/update-exim4.conf.conf
|
963
|
|
- else
|
964
|
|
- echo "dc_other_hostnames='${EMAIL_ONION_HOSTNAME}'" >> /etc/exim4/update-exim4.conf.conf
|
965
|
|
- fi
|
966
|
|
- echo "dc_local_interfaces=''" >> /etc/exim4/update-exim4.conf.conf
|
967
|
|
- echo "dc_readhost=''" >> /etc/exim4/update-exim4.conf.conf
|
968
|
|
- echo "dc_relay_domains=''" >> /etc/exim4/update-exim4.conf.conf
|
969
|
|
- echo "dc_minimaldns='false'" >> /etc/exim4/update-exim4.conf.conf
|
970
|
|
- IPv4_address=$(get_ipv4_address)
|
971
|
|
- IPv4_address_base=$(echo "$IPv4_address" | awk -F '.' '{print $1"."$2"."$3}')
|
972
|
|
- RELAY_NETS="${IPv4_address_base}.0/24"
|
973
|
|
- if [ $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
|
974
|
|
- RELAY_NETS=$(echo $LOCAL_NETWORK_STATIC_IP_ADDRESS | awk -F '.' '{print $1 "." $2 "." $3 ".0/24"}')
|
975
|
|
- fi
|
976
|
|
- echo "dc_relay_nets='$RELAY_NETS'" >> /etc/exim4/update-exim4.conf.conf
|
977
|
|
- echo "dc_smarthost=''" >> /etc/exim4/update-exim4.conf.conf
|
978
|
|
- echo "CFILEMODE='644'" >> /etc/exim4/update-exim4.conf.conf
|
979
|
|
- echo "dc_use_split_config='false'" >> /etc/exim4/update-exim4.conf.conf
|
980
|
|
- echo "dc_hide_mailname=''" >> /etc/exim4/update-exim4.conf.conf
|
981
|
|
- echo "dc_mailname_in_oh='true'" >> /etc/exim4/update-exim4.conf.conf
|
982
|
|
- echo "dc_localdelivery='maildir_home'" >> /etc/exim4/update-exim4.conf.conf
|
983
|
|
- echo "dc_main_log_selector=-all" >> /etc/exim4/update-exim4.conf.conf
|
984
|
|
- update-exim4.conf
|
985
|
|
- sed -i "s/START=no/START=yes/g" /etc/default/saslauthd
|
986
|
|
- systemctl start saslauthd
|
987
|
|
-
|
988
|
|
- email_install_tls
|
989
|
|
-
|
990
|
|
- adduser $MY_USERNAME sasl
|
991
|
|
- addgroup Debian-exim sasl
|
992
|
|
- systemctl restart exim4
|
993
|
|
-
|
994
|
|
- email_create_template
|
995
|
|
-
|
996
|
|
- if [ -f /usr/sbin/exim ]; then
|
997
|
|
- chmod u+s /usr/sbin/exim
|
998
|
|
- fi
|
999
|
|
- if [ -f /usr/sbin/exim4 ]; then
|
1000
|
|
- chmod u+s /usr/sbin/exim4
|
1001
|
|
- fi
|
1002
|
|
-
|
1003
|
|
- function_check configure_firewall_for_email
|
1004
|
|
- configure_firewall_for_email
|
1005
|
|
- dpkg-reconfigure --frontend noninteractive exim4-config
|
1006
|
|
-}
|
1007
|
|
-
|
1008
|
808
|
function install_email_basic {
|
1009
|
809
|
apt-get -yq remove postfix
|
1010
|
810
|
apt-get -yq install exim4 sasl2-bin swaks libnet-ssleay-perl procmail
|
|
@@ -1710,7 +1510,6 @@ function install_email {
|
1710
|
1510
|
check_email_address_exists
|
1711
|
1511
|
install_email_basic
|
1712
|
1512
|
configure_email_onion
|
1713
|
|
- #install_email_with_tor
|
1714
|
1513
|
|
1715
|
1514
|
mark_completed $FUNCNAME
|
1716
|
1515
|
}
|