From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4053DA073E for ; Tue, 13 Jun 2023 17:03:14 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1862F31B82 for ; Tue, 13 Jun 2023 17:02:44 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 13 Jun 2023 17:02:43 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1315F450E6 for ; Tue, 13 Jun 2023 17:02:43 +0200 (CEST) Date: Tue, 13 Jun 2023 17:02:41 +0200 From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Message-ID: <20230613170241.1f67455c@rosa.proxmox.com> In-Reply-To: <20230609173627.3252569-1-s.ivanov@proxmox.com> References: <20230609173627.3252569-1-s.ivanov@proxmox.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.24; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.051 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [185.83.214.222] Subject: Re: [pve-devel] [PATCH container] setup: template_fixup: remove bogus LXC_NAME line from /etc/hosts X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2023 15:03:14 -0000 I just realized that this has been reported in our bugzilla: https://bugzilla.proxmox.com/show_bug.cgi?id=4515 can gladly resent with the fitting prefix, (and will add it in case this needs more work and a v2) - but if it gets applied as is adding a reference to the bug would be appreciated! On Fri, 9 Jun 2023 19:36:27 +0200 Stoiko Ivanov wrote: > Templates not built directly by us, but redistributed from > images.linuxcontainer.org contain the following line in /etc/hosts: > `127.0.1.1 LXC_NAME` > > While it is mostly cosmetic - LXC_NAME, contains an underscore and is > not a valid DNS name. > > Simply drop it for newly created containers in template_fixup. > > We ship Debian, Devuan ourselves, without this line - so no need for > modification there. > > Currently the nixos container-template (see [0]) also does not seem to > contain the line. > > Noticed the issue with a fresh fedora container, where systemd-resolved > logs a warning upon boot. > > [0] https://nixos.wiki/wiki/Proxmox_Linux_Container > > Signed-off-by: Stoiko Ivanov > --- > src/PVE/LXC/Setup/Alpine.pm | 2 ++ > src/PVE/LXC/Setup/ArchLinux.pm | 2 ++ > src/PVE/LXC/Setup/Base.pm | 11 +++++++++++ > src/PVE/LXC/Setup/CentOS.pm | 2 ++ > src/PVE/LXC/Setup/Fedora.pm | 2 ++ > src/PVE/LXC/Setup/Gentoo.pm | 2 ++ > src/PVE/LXC/Setup/SUSE.pm | 2 ++ > 7 files changed, 23 insertions(+) > > diff --git a/src/PVE/LXC/Setup/Alpine.pm b/src/PVE/LXC/Setup/Alpine.pm > index 87d72be..8672f3c 100644 > --- a/src/PVE/LXC/Setup/Alpine.pm > +++ b/src/PVE/LXC/Setup/Alpine.pm > @@ -40,6 +40,8 @@ sub template_fixup { > $self->ct_symlink('/etc/init.d/savecache', '/etc/runlevels/shutdown/savecache'); > > $self->setup_securetty($conf); > + > + $self->remove_lxc_name_from_etc_hosts(); > } > > sub setup_init { > diff --git a/src/PVE/LXC/Setup/ArchLinux.pm b/src/PVE/LXC/Setup/ArchLinux.pm > index 60118ef..e379ea1 100644 > --- a/src/PVE/LXC/Setup/ArchLinux.pm > +++ b/src/PVE/LXC/Setup/ArchLinux.pm > @@ -40,6 +40,8 @@ sub template_fixup { > > # edit /etc/securetty (enable login on console) > $self->setup_securetty($conf); > + > + $self->remove_lxc_name_from_etc_hosts(); > } > > sub setup_init { > diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm > index 5534397..2d14599 100644 > --- a/src/PVE/LXC/Setup/Base.pm > +++ b/src/PVE/LXC/Setup/Base.pm > @@ -841,4 +841,15 @@ sub remove_pve_sections { > return $data =~ s/^\h*\Q$head\E.*^\h*\Q$tail\E.*?$//rgms; > } > > +# templates from images.linuxcontainers.org have a bogus LXC_NAME line in /etc/hosts > +sub remove_lxc_name_from_etc_hosts { > + my ($self) = @_; > + my $hosts = $self->ct_file_get_contents('/etc/hosts'); > + my @lines = grep { !/^127.0.1.1\s+LXC_NAME$/ } split(/\n/, $hosts); > + > + $hosts = join("\n", @lines). "\n"; > + > + $self->ct_file_set_contents('/etc/hosts', $hosts); > +} > + > 1; > diff --git a/src/PVE/LXC/Setup/CentOS.pm b/src/PVE/LXC/Setup/CentOS.pm > index 1d31cee..e603d6c 100644 > --- a/src/PVE/LXC/Setup/CentOS.pm > +++ b/src/PVE/LXC/Setup/CentOS.pm > @@ -119,6 +119,8 @@ sub template_fixup { > > # always call so root can login, if /etc/securetty doesn't exists it's a no-op > $self->setup_securetty($conf); > + > + $self->remove_lxc_name_from_etc_hosts(); > } > > sub setup_init { > diff --git a/src/PVE/LXC/Setup/Fedora.pm b/src/PVE/LXC/Setup/Fedora.pm > index 17ae7da..6e54a9e 100644 > --- a/src/PVE/LXC/Setup/Fedora.pm > +++ b/src/PVE/LXC/Setup/Fedora.pm > @@ -24,6 +24,8 @@ sub template_fixup { > my ($self, $conf) = @_; > $self->setup_securetty($conf); > $self->ct_unlink('/etc/systemd/system/getty@.service'); > + > + $self->remove_lxc_name_from_etc_hosts(); > } > > sub setup_init { > diff --git a/src/PVE/LXC/Setup/Gentoo.pm b/src/PVE/LXC/Setup/Gentoo.pm > index 6dc8e9f..501db54 100644 > --- a/src/PVE/LXC/Setup/Gentoo.pm > +++ b/src/PVE/LXC/Setup/Gentoo.pm > @@ -35,6 +35,8 @@ sub devttydir { > sub template_fixup { > my ($self, $conf) = @_; > $self->setup_securetty($conf); > + > + $self->remove_lxc_name_from_etc_hosts(); > } > > sub setup_init { > diff --git a/src/PVE/LXC/Setup/SUSE.pm b/src/PVE/LXC/Setup/SUSE.pm > index 7863b50..3c5fc68 100644 > --- a/src/PVE/LXC/Setup/SUSE.pm > +++ b/src/PVE/LXC/Setup/SUSE.pm > @@ -52,6 +52,8 @@ sub template_fixup { > # temporary fix for systemd-firstboot > $self->ct_file_set_contents('/etc/locale.conf', "LANG=C.utf8") if !$self->ct_file_exists('/etc/locale.conf'); > $self->ct_symlink('/usr/share/zoneinfo/UTC', '/etc/localtime') if !$self->ct_file_exists('/etc/localtime'); > + > + $self->remove_lxc_name_from_etc_hosts(); > } > > sub setup_init {