X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=src%2FPVE%2FINotify.pm;h=134305f636d7b2e6a621c07dca74d1af4d892d6b;hp=fbedc506918a4ab7f528951426a62cce5aaec800;hb=0541ec90f205b99d5715be05c0b17d08e9fa1450;hpb=b51b16e6f58de4cb385bd461d97866b3d94c93ec diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm index fbedc50..134305f 100644 --- a/src/PVE/INotify.pm +++ b/src/PVE/INotify.pm @@ -764,39 +764,43 @@ sub read_etc_network_interfaces { # we try to keep order inside the file my $priority = 2; # 1 is reserved for lo - my $gateway = 0; - - while (defined ($line = <$fh>)) { + SECTION: while (defined ($line = <$fh>)) { chomp ($line); - next if $line =~ m/^#/; + next if $line =~ m/^\s*#/; - if ($line =~ m/^auto\s+(.*)$/) { + if ($line =~ m/^\s*auto\s+(.*)$/) { my @aa = split (/\s+/, $1); foreach my $a (@aa) { $ifaces->{$a}->{autostart} = 1; } - } elsif ($line =~ m/^iface\s+(\S+)\s+inet\s+(\S+)\s*$/) { + } elsif ($line =~ m/^\s*iface\s+(\S+)\s+inet\s+(\S+)\s*$/) { my $i = $1; $ifaces->{$i}->{method} = $2; $ifaces->{$i}->{priority} = $priority++; my $d = $ifaces->{$i}; while (defined ($line = <$fh>)) { - if ($line =~ m/^\s*#(.*)\s*$/) { + chomp $line; + if ($line =~ m/^\s*#(.*?)\s*$/) { # NOTE: we use 'comments' instead of 'comment' to # avoid automatic utf8 conversion $d->{comments} = '' if !$d->{comments}; $d->{comments} .= "$1\n"; - } elsif ($line =~ m/^\s+((\S+)\s+(.+))$/) { + } elsif ($line =~ m/^\s*(?:iface\s + |mapping\s + |auto\s + |allow- + |source\s + |source-directory\s + )/x) { + last; + } elsif ($line =~ m/^\s*((\S+)\s+(.+))$/) { my $option = $1; my ($id, $value) = ($2, $3); - if (($id eq 'address') || ($id eq 'netmask') || ($id eq 'broadcast')) { - $d->{$id} = $value; - } elsif ($id eq 'gateway') { + if (($id eq 'address') || ($id eq 'netmask') || ($id eq 'broadcast') || ($id eq 'gateway')) { $d->{$id} = $value; - $gateway = 1; } elsif ($id eq 'ovs_type' || $id eq 'ovs_options'|| $id eq 'ovs_bridge' || $id eq 'ovs_bonds' || $id eq 'ovs_ports') { $d->{$id} = $value; @@ -837,6 +841,8 @@ sub read_etc_network_interfaces { last; } } + last SECTION if !defined($line); + redo SECTION; } }