[quagga-dev 10246] Re: bug in perl script, extract.pl

Joakim Tjernlund joakim.tjernlund at transmode.se
Sun Feb 10 10:48:08 GMT 2013


<equinox at diac24.net> wrote on 2013/02/10 04:00:35:
> 
> On Sat, Feb 09, 2013 at 06:21:25PM +0100, Joakim Tjernlund wrote:
> > line ~91 in extract.pl has this code:
> >  # $protocol is VTYSH_PROTO format for redirection of user input
> >         if ($file =~ /lib/) {
> >            if ($file =~ /keychain.c/) {
> >               $protocol = "VTYSH_RIPD";
> >            }
> > 
> > the ($file =~ /lib/) is to match quaggas lib dir only but this fails
> > when you have lib in your path like so:
> 
> Ouch, yeah.  Really bad way to do things... goes well with the vty
> system really.
> 
> > 
/var/lib/jenkins/workspace/trunk-targetcu3/BUILD/cuappl03a/powerpc-linux/
> ext/quagga/lib/
> 
> Oh, cool, Jenkins.  I've set up a private instance for Quagga to see how
> it works, pretty neat all in all.  Any specific advice/recommendations?
> (Though I assume you run it as part of a whole-system build...)

We do and just got started with this. I am not the lead on this particular 
project
so I cannot go into details but I know the guys working on it likes it so 
far.

> 
> > I don't speak perl so I hope there someone on the list that does and 
can 
> > fix it for me :)
> 
> I'll fix it, unless someone else is faster ;)

well, I had to do a stab at it and this is what I came up with:

>From 7f3317bb45c5037693b73d1786a2179b76507556 Mon Sep 17 00:00:00 2001
From: jocke <jocke at d7fa22be-1ae6-442c-820b-78db8785036d>
Date: Sat, 9 Feb 2013 19:23:19 +0000
Subject: [PATCH] vtysh: fix false lib path matching in extract.pl.in

The if ($file =~ /lib/) path matching logic is supposed to
match Quagga's lib directory only but will match all path
having lib in it such as /var/lib/jenkins/quagga/...

Fix by matching both lib and file: lib/keychain.c etc.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
---
 vtysh/extract.pl.in | 70 
++++++++++++++++++++++++++---------------------------
 1 file changed, 34 insertions(+), 36 deletions(-)

diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in
index e58eeeb..ea99179 100755
--- a/vtysh/extract.pl.in
+++ b/vtysh/extract.pl.in
@@ -89,43 +89,41 @@ foreach (@ARGV) {
        $cmd =~ s/\s+$//g;
 
         # $protocol is VTYSH_PROTO format for redirection of user input
-       if ($file =~ /lib/) {
-           if ($file =~ /keychain.c/) {
-              $protocol = "VTYSH_RIPD";
-           }
-           if ($file =~ /routemap.c/) {
-              $protocol = 
"VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA";
-           }
-           if ($file =~ /filter.c/) {
-              $protocol = "VTYSH_ALL";
-           }
-           if ($file =~ /plist.c/) {
-             if ($defun_array[1] =~ m/ipv6/) {
-                 $protocol = 
"VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA";
-              } else {
-                 $protocol = 
"VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA";
-              }
-           }
-           if ($file =~ /distribute.c/) {
-              if ($defun_array[1] =~ m/ipv6/) {
-                 $protocol = "VTYSH_RIPNGD";
-              } else {
-                 $protocol = "VTYSH_RIPD";
-              }
-           }
-           if ($file =~ /if_rmap.c/) {
-              if ($defun_array[1] =~ m/ipv6/) {
-                 $protocol = "VTYSH_RIPNGD";
-              } else {
-                 $protocol = "VTYSH_RIPD";
-              }
-           }
-          if ($file =~ /vty.c/) {
-             $protocol = "VTYSH_ALL";
-          }
+       if ($file =~ /lib\/keychain.c/) {
+           $protocol = "VTYSH_RIPD";
+       }
+       elsif ($file =~ /lib\/routemap.c/) {
+           $protocol = 
"VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA";
+       }
+       elsif ($file =~ /lib\/filter.c/) {
+           $protocol = "VTYSH_ALL";
+       }
+       elsif ($file =~ /lib\/plist.c/) {
+           if ($defun_array[1] =~ m/ipv6/) {
+               $protocol = 
"VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA";
+           } else {
+               $protocol = 
"VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA";
+           }
+       }
+       elsif ($file =~ /lib\/distribute.c/) {
+           if ($defun_array[1] =~ m/ipv6/) {
+               $protocol = "VTYSH_RIPNGD";
+           } else {
+               $protocol = "VTYSH_RIPD";
+           }
+       }
+       elsif ($file =~ /lib\/if_rmap.c/) {
+           if ($defun_array[1] =~ m/ipv6/) {
+               $protocol = "VTYSH_RIPNGD";
+           } else {
+               $protocol = "VTYSH_RIPD";
+           }
+       }
+       elsif ($file =~ /lib\/vty.c/) {
+           $protocol = "VTYSH_ALL";
         } else {
-           ($protocol) = ($file =~ 
/^.*\/([a-z0-9]+)\/[a-zA-Z0-9_\-]+\.c$/);
-           $protocol = "VTYSH_" . uc $protocol;
+           ($protocol) = ($file =~ 
/^.*\/([a-z0-9]+)\/[a-zA-Z0-9_\-]+\.c$/);
+           $protocol = "VTYSH_" . uc $protocol;
         }
 
        # Append _vtysh to structure then build DEFUN again
-- 
1.8.0.2





More information about the Quagga-dev mailing list