diff options
| author | Stig Thormodsrud <stig@io.vyatta.com> | 2009-02-06 12:09:26 -0800 |
|---|---|---|
| committer | Stig Thormodsrud <stig@io.vyatta.com> | 2009-02-06 12:09:26 -0800 |
| commit | f9cf46359e923ffab788663a8d644b06bfe0e9b5 (patch) | |
| tree | e4fc972391230d9e14103fe80750a264d79abfeb /lib | |
| parent | c1f4b2919df3815785faf45c35f729b06662aeaf (diff) | |
| download | vyatta-cfg-firewall-f9cf46359e923ffab788663a8d644b06bfe0e9b5.tar.gz vyatta-cfg-firewall-f9cf46359e923ffab788663a8d644b06bfe0e9b5.zip | |
Add validation of group type.
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/Vyatta/IpTables/IpSet.pm | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/Vyatta/IpTables/IpSet.pm b/lib/Vyatta/IpTables/IpSet.pm index 3410c03..e28c5e4 100755 --- a/lib/Vyatta/IpTables/IpSet.pm +++ b/lib/Vyatta/IpTables/IpSet.pm @@ -73,6 +73,24 @@ sub exists { return $rc ? 0 : 1; } +sub get_type { + my ($self) = @_; + + return if ! $self->exists(); + my @lines = `sudo ipset -L $self->{_name}`; + foreach my $line (@lines) { + if ($line =~ /^Type:\s+(\w+)$/) { + $self->{_type} = $1; + last; + } + } + return if ! defined $self->{_type}; + $self->{_type} = 'address' if $self->{_type} eq 'iphash'; + $self->{_type} = 'network' if $self->{_type} eq 'nethash'; + $self->{_type} = 'port' if $self->{_type} eq 'portmap'; + return $self->{_type}; +} + sub create { my ($self) = @_; @@ -209,8 +227,9 @@ sub rule { my ($self, $direction) = @_; if (! $self->exists()) { - my $rc = $self->create(); - return (undef, $rc) if $rc; + my $name = $self->{_name}; + $name = 'undefined' if ! defined $name; + return (undef, "Undefined group [$name]"); } my $srcdst; |
