[pve-devel] [PATCH container] setup: template_fixup: remove bogus LXC_NAME line from /etc/hosts

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jun 13 18:46:15 CEST 2023


Am 09/06/2023 um 19:36 schrieb Stoiko Ivanov:
> 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');

This failed the build...

prepare test-alpine-001                                                                                                                                        
can't open '/etc/hosts' - No such file or directory                                                                                                            
error in setup task PVE::LXC::Setup::post_create_hook                                                                                                          
make[3]: *** [Makefile:8: test_setup] Error 1


Please add an actual test for this.

> +    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;







More information about the pve-devel mailing list