]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/INotify.pm
removed write-only $gateway variable
[pve-common.git] / src / PVE / INotify.pm
index fbedc506918a4ab7f528951426a62cce5aaec800..134305f636d7b2e6a621c07dca74d1af4d892d6b 100644 (file)
@@ -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;
        }
     }