Subject: | check_pwd() is broken |
As reported by Ferenc Wágner in https://bugs.debian.org/930671 the check_pwd() function broke in 0.28, because it passes numeric attribute IDs to add_attributes() that now cause a fatal error.
Please consider the attached patch for fixing this.
Thanks for your work on Authen-Radius,
--
Niko Tyni
ntyni@debian.org
Subject: | 0001-Fix-0.28-regression-with-check_pwd.patch |
From ba0078591c35d1d6a404828aab9d06fb43c4d5fc Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Thu, 20 Jun 2019 16:43:30 +0300
Subject: [PATCH] Fix 0.28 regression with check_pwd()
add_attributes() is documented to accept raw numeric attributes,
and check_pwd() uses those.
Bug-Debian: https://bugs.debian.org/930671
---
Radius.pm | 3 ++-
t/error.t | 13 ++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Radius.pm b/Radius.pm
index fd0a6c9..3497e99 100644
--- a/Radius.pm
+++ b/Radius.pm
@@ -862,7 +862,8 @@ sub add_attributes {
$attr_name = $1;
}
- die 'unknown attr name '.$attr_name if (! exists $dict_name{$attr_name});
+ die 'unknown attr name '.$attr_name
+ if ($attr_name =~ /\D/ and ! exists $dict_name{$attr_name});
$id = $dict_name{$attr_name}{id} // int($attr_name);
$vendor = vendorID($attr);
diff --git a/t/error.t b/t/error.t
index 6a02cb3..e1c8f5f 100644
--- a/t/error.t
+++ b/t/error.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 12;
use Test::NoWarnings;
BEGIN { use_ok('Authen::Radius') };
@@ -17,3 +17,14 @@ ok( $auth->clear_attributes, 'clear attributes');
is($auth->get_error(), 'ENONE', 'error was reset');
is(Authen::Radius->get_error(), 'ENONE', 'global error also reset');
+
+my @attributes = (
+ { Name => 1, Value => 'user', Type => 'string' },
+ { Name => 2, Value => 'pass', Type => 'string' },
+ { Name => 4, Value => '127.0.0.1', Type => 'ipaddr' }
+);
+
+# called by check_pwd()
+ok( $auth->add_attributes(@attributes), 'add attributes');
+is($auth->get_error(), 'ENONE', 'no error with add_attributes');
+is(Authen::Radius->get_error(), 'ENONE', 'no global error either');
--
2.20.1