X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mail-setup;h=8f2a5c5f973fbecee46c5a113b34fbba73ae9d55;hb=9a0f77b0495e6f2643d5646c54b4c99cf3118c67;hp=499bbac09f61bbb854e2d06c642db74bc036a69a;hpb=3f6c5b1f2c72614ee8cb4d0e4325e7beddda9c04;p=distro-setup diff --git a/mail-setup b/mail-setup index 499bbac..8f2a5c5 100755 --- a/mail-setup +++ b/mail-setup @@ -183,10 +183,10 @@ if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi shopt -s nullglob -if [[ -s /usr/local/lib/err ]]; then - source /usr/local/lib/err -elif [[ -s /a/bin/errhandle/err ]]; then - source /a/bin/errhandle/err +if [[ -s /usr/local/lib/bash-bear ]]; then + source /usr/local/lib/bash-bear +elif [[ -s /a/bin/bash-bear-trap/bash-bear ]]; then + source /a/bin/bash-bear-trap/bash-bear else echo "no err tracing script found" exit 1 @@ -1366,6 +1366,10 @@ smtp_reserve_hosts = +iank_trusted LOCAL_DENY_EXCEPTIONS_LOCAL_ACL_FILE = /etc/exim4/conf.d/local_deny_exceptions_acl acl_not_smtp = acl_check_not_smtp + + +DEBBUGS_DOMAIN = b.b8.nz + EOF if dpkg --compare-versions "$(dpkg-query -f='${Version}\n' --show exim4)" ge 4.94; then @@ -1860,8 +1864,8 @@ if mailhost; then # plus debug does not help. # sudo -u radicale radicale -D - # created password file with: - # htpasswd -c /p/c/machine_specific/li/filesystem/etc/caldav-htpasswd + # created radicale password file with: + # htpasswd -c /p/c/machine_specific/li/filesystem/etc/caldav-htpasswd ian # chmod 640 /p/c/machine_specific/li/filesystem/etc/caldav-htpasswd # # setup chgrp www-data in ./conflink @@ -2033,7 +2037,7 @@ EOF ssl = required # this is the same as the certbot list, i check changes in /a/bin/ds/filesystem/usr/local/bin/check-lets-encrypt-ssl-settings ssl_cipher_list = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384 -ssl_protocols = TLSv1.2 +ssl_min_protocol = TLSv1.2 ssl_prefer_server_ciphers = no protocol lmtp { @@ -2744,7 +2748,7 @@ EOF u /usr/local/bin/ncup <<'EOFOUTER' #!/bin/bash -source /usr/local/lib/err +source /usr/local/lib/bash-bear m() { printf "%s\n" "$*"; "$@"; } err-cleanup() { @@ -2796,6 +2800,67 @@ EOF fi +# * debbugs + +pi debbugs +# missing dependency. apache error log: +# Can't locate List/AllUtils.pm in @INC (you may need to install the List::AllUtils module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.34.0 /usr/local/share/perl/5.34.0 /usr/lib/x86_64-linux-gnu/perl5/5.34 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.34 /usr/share/perl/5.34 /usr/local/lib/site_perl) at /var/lib/debbugs/www/cgi/pkgreport.cgi line 23. +pi liblist-allutils-perl lynx +# workarounds for broken debbugsconfig which is +# itself deprecated. this is temporary before I +# figure out how to install from git +if [[ -e /usr/share/doc/debbugs/examples/text.gz ]]; then + gunzip /usr/share/doc/debbugs/examples/text.gz +fi +mkdir -p /etc/debbugs/indices +debbugsconfig + + +# ld for local debbugs +/a/exe/web-conf -t -a 127.0.1.1 -p 80 -r /var/lib/debbugs/www - apache2 ld <<'EOF' +# copied from debbugs upstream example + + Options Indexes SymLinksIfOwnerMatch MultiViews + DirectoryIndex index.html + Require all granted + + +ScriptAlias /cgi/ /var/lib/debbugs/www/cgi/ + + AllowOverride None + Options ExecCGI SymLinksIfOwnerMatch + Require all granted + + +RewriteEngine on +RewriteCond %{HTTP_USER_AGENT} .*apt-listbugs.* +RewriteRule .* /apt-listbugs.html [R,L] + +# RewriteLog /org/bugs.debian.org/apache-rewrite.log +# RewriteLogLevel 0 + +#RewriteRule ^/$ http://www.debian.org/Bugs/ +RewriteRule ^/(robots\.txt|release-critical|apt-listbugs\.html)$ - [L] +# The following two redirect to up-to-date pages +RewriteRule ^/[[:space:]]*#?([[:digit:]][[:digit:]][[:digit:]]+)([;&].+)?$ /cgi-bin/bugreport.cgi?bug=$1$2 [L,R,NE] +RewriteRule ^/([^/+]*)([+])([^/]*)$ "/$1%%{%}2B$3" [N] +RewriteRule ^/[Ff][Rr][Oo][Mm]:([^/]+\@.+)$ /cgi-bin/pkgreport.cgi?submitter=$1 [PT,NE] +# Commented out, 'cuz aj says it will crash master. (old master) +# RewriteRule ^/[Ss][Ee][Vv][Ee][Rr][Ii][Tt][Yy]:([^/]+\@.+)$ /cgi-bin/pkgreport.cgi?severity=$1 [L,R] +RewriteRule ^/([^/]+\@.+)$ /cgi-bin/pkgreport.cgi?maint=$1 [PT,NE] +RewriteRule ^/mbox:([[:digit:]][[:digit:]][[:digit:]]+)([;&].+)?$ /cgi-bin/bugreport.cgi?mbox=yes&bug=$1$2 [PT,NE] +RewriteRule ^/src:([^/]+)$ /cgi-bin/pkgreport.cgi?src=$1 [PT,NE] +RewriteRule ^/severity:([^/]+)$ /cgi-bin/pkgreport.cgi?severity=$1 [PT,NE] +RewriteRule ^/tag:([^/]+)$ /cgi-bin/pkgreport.cgi?tag=$1 [PT,NE] +# RewriteMap fix-chars int:noescape +RewriteCond %{REQUEST_URI} ^/(Access\.html|Developer\.html|Reporting\.html|server-request\.html|server-control\.html|server-refcard\.html).* [NC] +RewriteRule .* - [L] +# PT|passthrough to bugreport.cgi and pkgreport.cgi +RewriteRule ^/([0-9]+)$ /cgi-bin/bugreport.cgi?bug=$1 [PT,NE] +RewriteRule ^/([^/]+)$ /cgi-bin/pkgreport.cgi?pkg=$1 [PT,NE] +EOF + + # * exim host conditional config # ** exim certs @@ -3035,6 +3100,36 @@ EOF if [[ ! -e /etc/exim4/no-delay-eximids ]]; then install -o iank -g iank <(echo) /etc/exim4/no-delay-eximids fi + + u /etc/exim4/conf.d/transport/30_debbugs <<'EOF' +debbugs_pipe: + debug_print = "T: debbugs_pipe for $local_part@$domain" + driver = pipe + command = /usr/lib/debbugs/receive + return_output +EOF + + + # We dont want delays or backups for mail being stored locally. + # We could put domain exclusion on other routes, but going for + # higher priority instead. + u /etc/exim4/conf.d/router/153_debbugs <<'EOF' +debbugs: + debug_print = "R: debbugs for $local_part@$domain" + driver = accept + transport = debbugs_pipe + local_parts = submit : bugs : maintonly : quiet : forwarded : \ + done : close : request : submitter : control : ^\\d+ + domains = DEBBUGS_DOMAIN + +bounce_debbugs: + debug_print = "R: bounce_debbugs for $local_part@$domain" + driver = redirect + allow_fail + data = :fail: Unknown user + domains = DEBBUGS_DOMAIN +EOF + u /etc/exim4/conf.d/router/155_delay <<'EOF' # By default, delay sending email by 30-40 minutes in case I # change my mind. @@ -3134,16 +3229,27 @@ MAILDIR_HOME_MAILDIR_LOCATION = /m/md/Sent EOF + # ian: save a copy of sent mail. i thought of other ways to do this, + # for example, to only save sent mail that is not sent from my mail + # client which saves a copy by default, but in the end, it seems + # simplest to turn that off. We want to save external mail sent by + # smarthosts. However, there is one complication: encrypted + # mail. Saving it here just gets us an encrypted copy that we can't + # read. Soo, we could bcc ourselves: then we still have the + # annoyance that it is encrypted so we can't grep it. Or, we could + # hack emacs so that it sends us an unencrypted copy. Turns out that + # the emacs function which saves sent email can also send us a + # copy. But, then we have 3 copies: the encrypted copy exim saves, + # the unencrypted copy exim saves, and the copy emacs saves. Soo, + # we can emacs send a copy directly to the sent alias but only when + # it is not mail_host, and have the exim condition for redirecting a + # copy to the sent alias avoid doing it if it has an emacs user + # agent header. u /etc/exim4/conf.d/router/186_sentarchive_nn <<'EOF' -# ian: save a copy of sent mail. i thought of other ways to -# do this, for example, to only save sent mail that is not sent -# from my mail client which saves a copy by default, but in the -# end, it seems simplest to turn that off. We want to save -# external mail sent by smarthosts. sentarchive_nn: driver = redirect domains = ! +local_domains - condition = ${if !bool{${lookup{$local_part@$domain}lsearch{/etc/exim4/ignore-sent}{true}}}} + condition = ${if and {{!bool{${lookup{$local_part@$domain}lsearch{/etc/exim4/ignore-sent}{true}}}} {!match {$h_user-agent:}{emacs}}}} data = vojdedIdNejyebni@b8.nz unseen EOF @@ -3318,6 +3424,8 @@ EOF ;; # ** not MAIL_HOST|bk|je *) + echo|u /etc/exim4/conf.d/transport/30_debbugs + echo|u /etc/exim4/conf.d/router/153_debbugs echo|u /etc/exim4/conf.d/router/155_delay # this one should be removed for all non mail_hosts. note # bk and je never become mail_host @@ -3508,25 +3616,25 @@ sentarchive: driver = redirect domains = ! +local_domains senders = <; *@fsf.org ; *@posteo.net - condition = ${if !bool{${lookup{$local_part@$domain}lsearch{/etc/exim4/ignore-sent}{true}}}} + condition = ${if and {{!bool{${lookup{$local_part@$domain}lsearch{/etc/exim4/ignore-sent}{true}}}} {!match {$h_user-agent:}{emacs}}}} data = vojdedIdNejyebni@b8.nz unseen EOF u /etc/myexim4/conf.d/router/160_backup_redir <<'EOF' backup_redir: -driver = redirect -# i dont email myself from my own machine much, so lets ignore that. -domains = ! +local_domains -senders = <; *@fsf.org ; *@posteo.net -condition = ${if !bool{${lookup{$local_part@$domain}lsearch{/etc/exim4/ignore-sent}{true}}}} -# b is just an arbirary short string -data = b@eximbackup.b8.nz -# note, to test this, i could temporarily allow testignore. -# alerts avoids potential mail loop. -local_parts = ! root : ! testignore : ! alerts : ! daylert -unseen = true -errors_to = alerts@iankelling.org + driver = redirect + # i dont email myself from my own machine much, so lets ignore that. + domains = ! +local_domains + senders = <; *@fsf.org ; *@posteo.net + condition = ${if and {{!bool{${lookup{$local_part@$domain}lsearch{/etc/exim4/ignore-sent}{true}}}} {!match {$h_user-agent:}{emacs}}}} + # b is just an arbirary short string + data = b@eximbackup.b8.nz + # note, to test this, i could temporarily allow testignore. + # alerts avoids potential mail loop. + local_parts = ! root : ! testignore : ! alerts : ! daylert + unseen = true + errors_to = alerts@iankelling.org EOF # for bk, we have a exim4in.service that will do this for us. @@ -3598,6 +3706,25 @@ elif [[ $uid != 608 ]]; then m find / /nocow -xdev -path ./var/tmp -prune -o -gid $gid -execdir chgrp -h 608 {} + fi + +# note: example config has a debbugs user, +# but my exim runs setuid as Debian-exim so it can't switch +# to another user. Anyways, I'm not exposing this to the +# internet at this time. If I do, the thing to do would +# be to use a sudo config (or sudo alternative). This +# would be how to setup + +# IFS=:; read -r _ _ uid _ < <(getent passwd debbugs||:) ||:; unset IFS +# if [[ ! $uid ]]; then +# # /a/opt/debbugs/debian/README.mail +# adduser --uid 610 --system --group --home /o/debbugs \ +# --no-create-home --disabled-login --force-badname debbugs +# m find /o/debbugs -xdev -path ./var/tmp -prune -o -uid $uid -execdir chown -h 610 {} + +# m find /o/debbugs -xdev -path ./var/tmp -prune -o -gid $gid -execdir chgrp -h 610 {} + +# elif [[ $uid != 610 ]]; then +# err debbugs exist but is not uid 610: investigate +# fi + # * start / stop services reifactive dnsmasq nscd