[pve-devel] [PATCH] copy_bridge_config : parse values

Dietmar Maurer dietmar at proxmox.com
Wed Feb 26 07:30:49 CET 2014


> I wonder if this would solve also the problem? Please can you test?

I would prefer to fix it this way (avoid to run external program using system()).
Any objections?

> diff --git a/data/PVE/Network.pm b/data/PVE/Network.pm index
> 9ad34f1..458a2da 100644
> --- a/data/PVE/Network.pm
> +++ b/data/PVE/Network.pm
> @@ -114,8 +114,7 @@ sub copy_bridge_config {
>             my $v0 =
> PVE::Tools::file_read_firstline("/sys/class/net/$br0/bridge/$sysname");
>             my $v1 =
> PVE::Tools::file_read_firstline("/sys/class/net/$br1/bridge/$sysname");
>             if ($v0 ne $v1) {
> -               system("echo \"$v0\" > /sys/class/net/$br1/bridge/$sysname") == 0
> ||
> -                   warn "unable to set bridge config '$sysname'\n";
> +               write_proc_entry("/sys/class/net/$br1/bridge/$sysname",
> + $v0);
>             }
>         };
>         warn $@ if $@;
> diff --git a/data/PVE/ProcFSTools.pm b/data/PVE/ProcFSTools.pm index
> 79d8cfd..e0a8828 100644
> --- a/data/PVE/ProcFSTools.pm
> +++ b/data/PVE/ProcFSTools.pm
> @@ -246,4 +246,14 @@ sub read_proc_net_dev {
>      return $res;
>  }
> 
> +sub write_proc_entry {
> +    my ($filename, $data) = @_;#
> +
> +    my $fh = IO::File->new($filename,  O_WRONLY);
> +    die "unable to open file '$filename' - $!\n" if !$fh;
> +    die "unable to write '$filename' - $!\n" unless print $fh $data;
> +    die "closing file '$filename' failed - $!\n" unless close $fh;
> +    $fh->close();
> +}
> +
>  1;
> 
> 
> > -----Original Message-----
> > From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> > bounces at pve.proxmox.com] On Behalf Of Alexandre Derumier
> > Sent: Dienstag, 25. Februar 2014 06:15
> > To: pve-devel at pve.proxmox.com
> > Subject: [pve-devel] [PATCH] copy_bridge_config : parse values
> >
> > fix bug
> >
> > WARNING: Insecure dependency in system while running with -T switch at
> > /usr/share/perl5/PVE/Network.pm line 175.
> >
> > Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> > ---
> >  data/PVE/Network.pm |    9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/data/PVE/Network.pm b/data/PVE/Network.pm index
> > 98ef18e..99350cb 100644
> > --- a/data/PVE/Network.pm
> > +++ b/data/PVE/Network.pm
> > @@ -168,6 +168,15 @@ sub copy_bridge_config {
> >  	eval {
> >  	    my $v0 =
> > PVE::Tools::file_read_firstline("/sys/class/net/$br0/bridge/$sysname");
> >  	    my $v1 =
> > PVE::Tools::file_read_firstline("/sys/class/net/$br1/bridge/$sysname")
> > ;
> > +
> > +	    if($v0 =~ m/^(\S+)/){
> > +		$v0 = $1;
> > +	    }
> > +
> > +	    if($v1 =~ m/^(\S+)/){
> > +		$v1 = $1;
> > +	    }
> > +
> >  	    if ($v0 ne $v1) {
> >  		system("echo \"$v0\" >
> > /sys/class/net/$br1/bridge/$sysname") == 0 ||
> >  		    warn "unable to set bridge config '$sysname'\n";
> > --
> > 1.7.10.4
> >
> > _______________________________________________
> > pve-devel mailing list
> > pve-devel at pve.proxmox.com
> > http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel





More information about the pve-devel mailing list