From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 5C30E1FF0FC for ; Tue, 27 Oct 2026 10:31:32 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 683B62168A; Tue, 27 Oct 2026 10:31:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=straightec.de; s=dkim; t=1793008737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Stlouhq2aOtDgz+S7kEmiePkhNt9WkCiL3zz7+dQ8I=; b=xjfHXkbRd73Ds9/r1/HX0ZYD0U6+aVjW+BeITth+Hx9u3dt3knarUKXkur3CmsbNZod3jK GWqO2TBrtabkawim/+8nrnK2e/zLnrVssOXAV+pQ0TkxMmhVN+c1z0SCQu6Cjxs8NI8O6A r+xxboy0rIRltONqkXXe2niOxP3AisG58DHEnemIqUdN6bGqOP+bdE6obT7tEgM8tsw5lJ GbqumVydVJdY8kOdheC/L4T8EcFom+ZNCY9bHO6FN67p0QXYtW5mREODEvRpk6cHKJKfI6 FI9Z93efuYJ/6aECax8+RSPqdssnX9WsYcEf5t8D2QVvYM7wZ0jfYnFfYAxsHA== From: Carsten Haerle To: pmg-devel@lists.proxmox.com Subject: [PATCH pmg-api 1/6] fix #8231: config: add option to not trust the local network automatically Date: Mon, 26 Oct 2026 10:58:46 +0100 Message-ID: <20261026095852.3243241-2-carsten.haerle@straightec.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261026095852.3243241-1-carsten.haerle@straightec.de> References: <20261026095852.3243241-1-carsten.haerle@straightec.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record X-MailFrom: carsten.haerle@straightec.de X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation Message-ID-Hash: GRPNGQ77J5RAM6Q4K4AC3NTGQZQAOFKU X-Message-ID-Hash: GRPNGQ77J5RAM6Q4K4AC3NTGQZQAOFKU X-Mailman-Approved-At: Tue, 27 Oct 2026 10:31:21 +0100 CC: Carsten Haerle X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The network of the node's IP address is always added to postfix' mynetworks, so every host in it may relay mail through the internal port to any destination. This is not visible in the GUI and can only be changed by overriding the main.cf template, which then has to be kept in sync with every update. Add the 'trust_local_network' option to the mail section. It defaults to 1, keeping the current behaviour. If disabled, only loopback, the default relay, transport hosts and the configured networks are trusted. Signed-off-by: Carsten Haerle --- src/PMG/Config.pm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/PMG/Config.pm b/src/PMG/Config.pm index 070a34f..655a433 100644 --- a/src/PMG/Config.pm +++ b/src/PMG/Config.pm @@ -695,6 +695,14 @@ sub properties { type =3D> 'boolean', default =3D> 0, }, + trust_local_network =3D> { + description =3D> "Trust the network of the node's IP address, = that is, allow all" + . " hosts in it to relay mail through the internal port. I= f disabled, only" + . " the default relay, transport hosts and the configured = networks are" + . " trusted.", + type =3D> 'boolean', + default =3D> 1, + }, maxsize =3D> { description =3D> "Maximum email size. Larger mails are rejected. (postfix o= ption `message_size_limit`)", @@ -876,6 +884,7 @@ sub options { max_filters =3D> { optional =3D> 1 }, max_policy =3D> { optional =3D> 1 }, hide_received =3D> { optional =3D> 1 }, + trust_local_network =3D> { optional =3D> 1 }, rejectunknown =3D> { optional =3D> 1 }, rejectunknownsender =3D> { optional =3D> 1 }, conn_count_limit =3D> { optional =3D> 1 }, @@ -1578,7 +1587,8 @@ sub get_template_vars { =20 $vars->{postfix}->{transportnets} =3D join(' ', sort keys %$transportn= ets); =20 - if (defined($int_ip)) { # we cannot really do anything and the loopbac= k nets are already added + # without an IP we cannot really do anything and the loopback nets are= already added + if (defined($int_ip) && $self->get('mail', 'trust_local_network')) { if (my $int_net_cidr =3D PMG::Utils::find_local_network_for_ip($in= t_ip, 1)) { if ($int_net_cidr =3D~ m/^($IPV6RE)\/(\d+)$/) { $mynetworks->{"[$1]/$2"} =3D 1; --=20 2.53.0