summaryrefslogtreecommitdiffstats
path: root/scripts/snmp-proxy/net-radius-freeradius-dictionary.diff
blob: f379cf4ee369fc4b75955ade9cc70a6e44d34fff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--- Net-Radius-1.56.orig/Radius/Dictionary.pm	2008-06-20 14:08:57.000000000 +0100
+++ Net-Radius-1.56.1/Radius/Dictionary.pm	2008-06-20 15:54:33.000000000 +0100
@@ -30,14 +30,23 @@
 
 sub readfile {
   my ($self, $filename) = @_;
+  my $dict;
 
-  open DICT, "<$filename";
+  open $dict, "<$filename";
 
-  while (defined(my $l = <DICT>)) {
+  my @in_vendor = ();
+
+  while (defined(my $l = <$dict>)) {
     next if $l =~ /^\#/;
     next unless my @l = split /\s+/, $l;
 
-    if ($l[0] =~ m/^vendor$/i) 
+    if ($l[0] =~ m/^\$include$/i)
+    {
+        my @fn = split /\//, $filename;
+        $fn[$#fn] = $l[1];
+        $self->readfile(join '/', @fn);
+    }
+    elsif ($l[0] =~ m/^vendor$/i) 
     {
 	if (defined $l[1] and defined $l[2] and $l[2] =~ /^[xo0-9]+$/)
 	{
@@ -53,8 +62,42 @@
 	    warn "Garbled VENDOR line $l\n";
 	}
     }
+    elsif ($l[0] =~ m/^begin-vendor$/i)
+    {
+    if ( defined $l[1] )
+    {
+        push @in_vendor, $l[1];
+    }
+    else
+    {
+	    warn "Garbled BEGIN-VENDOR line $l\n";
+    }
+    }
+    elsif ($l[0] =~ m/^end-vendor$/i)
+    {
+    if ( defined $l[1] )
+    {
+        if ( $in_vendor[$#in_vendor] eq $l[1] ) {
+            pop @in_vendor;
+        }else {
+            warn "mismatched END-VENDOR line $l\n";
+        }
+    }
+    else
+    {
+	    warn "Garbled END-VENDOR line $l\n";
+    }
+    }
     elsif ($l[0] =~ m/^attribute$/i) 
     {
+    if (@l == 5) {
+        my @tags = grep { not ( m/^encrypt=\d$/ or m/^has_tag$/ ) } split /,/, pop @l;
+        push @l, join ',', @tags if scalar @tags;
+    }
+    if (@l == 4 and scalar @in_vendor) {
+        push @l, $in_vendor[$#in_vendor];
+    }
+
 	if (@l == 4)
 	{
 	    $self->{attr}->{$l[1]}  = [@l[2,3]];
@@ -166,7 +209,7 @@
       warn "Warning: Weird dictionary line: $l\n";
     }
   }
-  close DICT;
+  close $dict;
 }
 
 # Accessors for standard attributes