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 CC4EB1FF0AE for ; Tue, 15 Sep 2026 11:18:20 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 78377215C2; Tue, 15 Sep 2026 11:18:18 +0200 (CEST) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager v3 1/2] fix #8031: factor out APT proxy write from update_database call Date: Tue, 15 Sep 2026 11:16:57 +0200 Message-ID: <20260915091758.85522-2-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260915091758.85522-1-j.theisen@proxmox.com> References: <20260915091758.85522-1-j.theisen@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1789463875757 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.313 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: G7KVAYOAZ5RWCKH6GABHW3A7WAY364XC X-Message-ID-Hash: G7KVAYOAZ5RWCKH6GABHW3A7WAY364XC X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To allow reuse of the same function for the Cluster set_options call this commit factors the function to write the APT proxy config file out of the update_database call into a sub function. Signed-off-by: Jonas Theisen --- PVE/API2/APT.pm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm index 6dd4c261..87928e58 100644 --- a/PVE/API2/APT.pm +++ b/PVE/API2/APT.pm @@ -290,6 +290,19 @@ __PACKAGE__->register_method({ }, }); +sub update_apt_proxy_config { + my $dcconf = PVE::Cluster::cfs_read_file('datacenter.cfg'); + my $aptconf = "// no proxy configured\n"; + + if (my $http_proxy = $dcconf->{http_proxy}) { + my $http_proxy_uri = URI->new($http_proxy); + $aptconf = "Acquire::http::Proxy \"${http_proxy_uri}\";\n"; + } + my $aptcfn = "/etc/apt/apt.conf.d/76pveproxy"; + + PVE::Tools::file_set_contents($aptcfn, $aptconf); +} + __PACKAGE__->register_method({ name => 'update_database', path => 'update', @@ -334,15 +347,7 @@ __PACKAGE__->register_method({ my $realcmd = sub { my $upid = shift; - # setup proxy for apt - - my $aptconf = "// no proxy configured\n"; - if (my $http_proxy = $dcconf->{http_proxy}) { - my $http_proxy_uri = URI->new($http_proxy); - $aptconf = "Acquire::http::Proxy \"${http_proxy_uri}\";\n"; - } - my $aptcfn = "/etc/apt/apt.conf.d/76pveproxy"; - PVE::Tools::file_set_contents($aptcfn, $aptconf); + update_apt_proxy_config(); my $cmd = ['apt-get', 'update']; -- 2.47.3