Skip to content

Commit 52bde2a

Browse files
authored
Betreiber-Mails fremder Installationen nicht mehr an vutuv.de [cold-deploy] (#2387)
Eine Installation ohne OPERATOR_EMAIL erbte die Betreiberadresse von vutuv.de und schickte ihren Tagesbericht samt Mitgliedernamen dorthin; dieselbe Adresse stand in ihrer security.txt, NodeInfo und auf den Fehlerseiten. Abseits von vutuv.de greift jetzt postmaster@ der eigenen Absenderdomain, mit einer Warnung beim Boot. Diesen Text hat ein KI-Agent in meinem Namen geschrieben. Ich weiß, dass das problematisch ist.
1 parent cda42ed commit 52bde2a

4 files changed

Lines changed: 105 additions & 6 deletions

File tree

‎config/config.exs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,8 @@ config :vutuv, :appeal_reply_to, "[email protected]"
10531053
# mailto:) because they cannot say what went wrong. Use an address a human
10541054
# reads. It is the *person*, distinct from :operator_name below, which is the
10551055
# organization credited in the footer. (OPERATOR_NAME / OPERATOR_EMAIL)
1056+
# This default and :appeal_reply_to above apply on vutuv.de only; another
1057+
# host without OPERATOR_EMAIL gets postmaster@ its own domain (runtime.exs).
10561058
config :vutuv, :operator_recipient, {"Stefan Wintermeyer", "[email protected]"}
10571059

10581060
# The operator credit in the site and email footers ("a service provided

‎config/runtime.exs‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,38 @@ if config_env() == :prod do
170170
config :vutuv, :bounce_address, bounce_address
171171
end
172172

173-
if appeal_reply_to = System.get_env("APPEAL_REPLY_TO") do
174-
config :vutuv, :appeal_reply_to, appeal_reply_to
175-
end
173+
# The config.exs defaults name vutuv.de's own operator, so they hold only on
174+
# vutuv.de. Anywhere else an unset OPERATOR_EMAIL used to send that
175+
# installation's daily report, member names included, to vutuv.de and print
176+
# vutuv.de's contact in its security.txt and error pages. There it falls
177+
# back to postmaster@ of the domain the installation sends mail from, the
178+
# one mailbox every mail domain must have (RFC 5321).
179+
vutuv_de? = String.replace_prefix(host, "www.", "") == "vutuv.de"
180+
181+
operator_email =
182+
System.get_env("OPERATOR_EMAIL") ||
183+
unless vutuv_de? do
184+
mail_domain =
185+
case String.split(System.get_env("MAILER_FROM_ADDRESS") || "", "@") do
186+
[_local, domain] when domain != "" -> domain
187+
_ -> host
188+
end
189+
190+
fallback = "postmaster@" <> mail_domain
191+
IO.warn("OPERATOR_EMAIL is not set; operator notices go to #{fallback}", [])
192+
fallback
193+
end
176194

177-
if operator_email = System.get_env("OPERATOR_EMAIL") do
195+
if operator_email do
178196
config :vutuv,
179197
:operator_recipient,
180198
{System.get_env("OPERATOR_NAME") || operator_email, operator_email}
181199
end
182200

201+
if appeal_reply_to = System.get_env("APPEAL_REPLY_TO") || (!vutuv_de? && operator_email) do
202+
config :vutuv, :appeal_reply_to, appeal_reply_to
203+
end
204+
183205
if operator_name = System.get_env("OPERATOR_NAME") do
184206
config :vutuv, :operator_name, operator_name
185207
end

‎docs/ADMINS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ Everything else has a default (the vutuv.de production value):
157157
| `MAILER_FROM_ADDRESS` | `[email protected]` | **Set this.** From address on every email |
158158
| `BOUNCE_ADDRESS` | `[email protected]` | **Set this**, to a mailbox on your own domain that really accepts mail — bounces (DSNs) are addressed to it. It is the SMTP envelope sender only and never appears as a header, so it needs no display name and no human reading it; an alias or an automated handler is enough. Do not use a person's address: it is not shown to recipients, but it is what a remote postmaster replies to |
159159
| `OPERATOR_NAME` | `Wintermeyer Consulting` | **Set this.** Your name: site/email footer credit and operator-notice recipient name |
160-
| `OPERATOR_EMAIL` | `sw@wintermeyer-consulting.de` | **Set this.** Receives the daily report, the weekly report of trapped sign-ups, ad bookings and cancellations, and account-deletion records; also the `security.txt` contact. **This pair is shown to visitors**, by name and as a `mailto:`, on the two pages that cannot say what went wrong: the 500 error page and the offline page the service worker keeps. Both ask the reader to come back later and to write to you if it persists, quoting the status code and the UTC minute, so use an address a human reads |
160+
| `OPERATOR_EMAIL` | `postmaster@` your mail domain (vutuv.de's operator only on vutuv.de) | **Set this.** Unset, the release warns at boot and falls back to `postmaster@` the domain of `MAILER_FROM_ADDRESS` (or `PHX_HOST`). Receives the daily report, the weekly report of trapped sign-ups, ad bookings and cancellations, and account-deletion records; also the `security.txt` contact. **This pair is shown to visitors**, by name and as a `mailto:`, on the two pages that cannot say what went wrong: the 500 error page and the offline page the service worker keeps. Both ask the reader to come back later and to write to you if it persists, quoting the status code and the UTC minute, so use an address a human reads |
161161
| `OPERATOR_URL` | `https://wintermeyer-consulting.de` | **Set this.** Linked from the site/email footer |
162162
| `OPERATOR_ADDRESS` | (vutuv.de's) | **Set this.** One-line postal address in every email footer |
163163
| `SOURCE_URL` | `https://github.com/wintermeyer/vutuv` | Where the source of the software you run can be read — the footer's "Source" link and the commit link beside it, the bug-report links on the 400 error page and in the developer docs, and the `source_url` / `repository` fields both API discovery documents publish. **Change this if you run a modified vutuv:** the link claims to be the source of what your users are running, so once you have patched anything, ours is no longer an honest answer. vutuv is MIT, so this is about accuracy rather than a licence obligation |
164164
| `SERVER_STATUS` | `true` | Whether the public page `/system/status` exists, with its link in every page's footer. It shows each server's processor, memory, disks added up, uptime and graphics cards, refreshed every ten seconds, and names servers only by number ("Server 1"). Out of the box it reads the machine vutuv runs on straight from `/proc` and calls nowhere. `false` removes the page (404), the footer link and the background sampler |
165165
| `SERVER_STATUS_HOSTS` | `local` | The servers on that page, comma-separated, in the order they are numbered. `local` is the machine vutuv runs on; anything else is a host running Prometheus' [node_exporter](https://github.com/prometheus/node_exporter) on port 9100 (`10.0.0.3`), a `host:port`, or the full URL of its metrics page. `10.0.0.1,local,10.0.0.3` makes this machine "Server 2". Point it at an internal address and keep the exporter port closed to the internet: the page shows the numbers, never the host |
166166
| `SERVER_STATUS_GPU_HOSTS` | – | The hosts in that list that also run an [nvidia_gpu_exporter](https://github.com/utkuozdemir/nvidia_gpu_exporter) (port 9835 unless given), so their card shows each graphics card's load, memory, temperature and power. `localhost` means the machine vutuv runs on |
167167
| `OPERATOR_HANDLE` | `wintermeyer` | The @handle of the person your media kit (`/system/media-kit`) names as the press contact, and the one an investor writes to on `/system/investors`. The media kit links their profile for the remaining contact details; the investor page names the operator's address (`OPERATOR_EMAIL`) and offers a message on your own installation beside it. Both appear only when the handle really belongs to a member of *your* installation, so leaving the default set costs you nothing but a missing link. `""` renders neither |
168-
| `APPEAL_REPLY_TO` | (vutuv.de's) | Reply-To on the account-deactivation (strike 3) email |
168+
| `APPEAL_REPLY_TO` | `OPERATOR_EMAIL` | Reply-To on the account-deactivation (strike 3) email |
169169
| `BOUNCE_WEBHOOK_TOKEN` | – | Bearer token for `POST /webhooks/bounces`; unset = the endpoint 404s and webhook bounce handling is off. **Prefer the log watcher (`MAIL_LOG_PATH`) to this webhook:** the webhook acts on the DSN it receives without verifying the installation ever mailed the address, so feeding it a raw local bounce mailbox lets a forged bounce freeze a member ([#1063](https://github.com/wintermeyer/vutuv/issues/1063)). On a watcher-only setup leave this unset |
170170
| `MAIL_LOG_PATH` | `/var/log/mail.log` | Postfix log the bounce watcher tails; `""` = watcher off |
171171
| `DEPLOY_MINUTES` | `10` | How long installing a new version takes on your setup. The 500 page tells the visitor this number, because a deploy in flight is the commonest reason they are looking at it, and "come back later" is only useful with a figure on it. Ours is a blue/green deploy that builds, migrates and health-gates before the switch; set yours if your pipeline is slower |

‎test/vutuv/operator_env_test.exs‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
defmodule Vutuv.OperatorEnvTest do
2+
@moduledoc """
3+
Who receives the operator notices when an installation never set
4+
`OPERATOR_EMAIL`.
5+
6+
The shipped default is vutuv.de's own operator, so another installation that
7+
skipped the variable mailed its nightly report (with its members' names) to
8+
vutuv.de and named vutuv.de's operator in its `security.txt`, its NodeInfo
9+
and its error pages. Off vutuv.de the fallback is now `postmaster@` of the
10+
installation's own mail domain.
11+
12+
It evaluates the real `config/runtime.exs` for `:prod`, which is the only
13+
place that branch runs before production. `async: false` because it writes
14+
real environment variables (`PHX_HOST`, `MAILER_FROM_ADDRESS`,
15+
`OPERATOR_EMAIL`, `APPEAL_REPLY_TO`, `DB_PASS`, `SECRET_KEY_BASE`) that the
16+
sandbox does not roll back; the running app reads none of them after boot.
17+
"""
18+
use ExUnit.Case, async: false
19+
20+
@runtime Path.join([__DIR__, "..", "..", "config", "runtime.exs"])
21+
@vars ~w(PHX_HOST MAILER_FROM_ADDRESS OPERATOR_EMAIL OPERATOR_NAME APPEAL_REPLY_TO DB_PASS SECRET_KEY_BASE)
22+
23+
setup do
24+
saved = Map.new(@vars, &{&1, System.get_env(&1)})
25+
Enum.each(@vars, &System.delete_env/1)
26+
System.put_env("DB_PASS", "test")
27+
System.put_env("SECRET_KEY_BASE", String.duplicate("a", 64))
28+
29+
on_exit(fn ->
30+
Enum.each(saved, fn
31+
{var, nil} -> System.delete_env(var)
32+
{var, value} -> System.put_env(var, value)
33+
end)
34+
end)
35+
end
36+
37+
defp prod_config(env) do
38+
Enum.each(env, fn {var, value} -> System.put_env(var, value) end)
39+
Config.Reader.read!(@runtime, env: :prod, target: :host)[:vutuv]
40+
end
41+
42+
test "vutuv.de keeps the defaults from config.exs" do
43+
for host <- ["vutuv.de", "www.vutuv.de"] do
44+
config = prod_config(%{"PHX_HOST" => host})
45+
refute Keyword.has_key?(config, :operator_recipient)
46+
refute Keyword.has_key?(config, :appeal_reply_to)
47+
end
48+
end
49+
50+
test "another installation without OPERATOR_EMAIL writes to its own postmaster" do
51+
config =
52+
prod_config(%{
53+
"PHX_HOST" => "social.example.org",
54+
"MAILER_FROM_ADDRESS" => "[email protected]"
55+
})
56+
57+
assert config[:operator_recipient] == {"[email protected]", "[email protected]"}
58+
assert config[:appeal_reply_to] == "[email protected]"
59+
end
60+
61+
test "without a From address it falls back to the host" do
62+
config = prod_config(%{"PHX_HOST" => "social.example.org"})
63+
64+
assert config[:operator_recipient] ==
65+
66+
end
67+
68+
test "an explicit OPERATOR_EMAIL wins and also answers appeals" do
69+
config =
70+
prod_config(%{"PHX_HOST" => "social.example.org", "OPERATOR_EMAIL" => "[email protected]"})
71+
72+
assert config[:operator_recipient] == {"[email protected]", "[email protected]"}
73+
assert config[:appeal_reply_to] == "[email protected]"
74+
end
75+
end

0 commit comments

Comments
 (0)