[pve-devel] [PATCH container] fix #1844: check /etc/.pve-ignore.hosts early

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Jul 20 08:49:21 CEST 2018


Our checks for .pve-ignore.* files happen at write time so
we mostly don't have to think about them within the
functions dealing with them. /etc/hosts is one of the files
we need nowhere except when updating it, and there are some
tools managing it and producing files too large for our
default file_get_contents() size limit, so here we want to
skip early to avoid an error at read time.

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 src/PVE/LXC/Setup/Base.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 0d6a796..2f346e9 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -54,6 +54,9 @@ sub lookup_dns_conf {
 sub update_etc_hosts {
     my ($self, $hostip, $oldname, $newname, $searchdomains) = @_;
 
+    my $hosts_fn = '/etc/hosts';
+    return if $self->ct_is_file_ignored($hosts_fn);
+
     my $namepart = ($newname =~ s/\..*$//r);
 
     my $all_names = '';
@@ -70,7 +73,6 @@ sub update_etc_hosts {
 
     # Prepare section:
     my $section = '';
-    my $hosts_fn = '/etc/hosts';
 
     my $lo4 = "127.0.0.1 localhost.localnet localhost\n";
     my $lo6 = "::1 localhost.localnet localhost\n";
-- 
2.11.0





More information about the pve-devel mailing list