Bugzilla – Attachment 90100 Details for
Bug 22943
The in_ipset C4::Auth function name can be confusing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22943: Renames the in_ipset function to in_iprange in C4::Auth
Bug-22943-Renames-the-inipset-function-to-iniprang.patch (text/plain), 7.31 KB, created by
Hayley Pelham
on 2019-05-27 02:03:10 UTC
(
hide
)
Description:
Bug 22943: Renames the in_ipset function to in_iprange in C4::Auth
Filename:
MIME Type:
Creator:
Hayley Pelham
Created:
2019-05-27 02:03:10 UTC
Size:
7.31 KB
patch
obsolete
>From 1ee5fd87c4674e271cd1398bd3ca9ad46cac703b Mon Sep 17 00:00:00 2001 >From: Hayley Mapley <hayleymapley@catalyst.net.nz> >Date: Mon, 27 May 2019 13:57:05 +1200 >Subject: [PATCH] Bug 22943: Renames the in_ipset function to in_iprange in > C4::Auth > >Bug 14407 introduced a new system preference to allow limiting the >online self checkout system to an IP or IP Range. The function that >handles this is called in_ipset, which is the name of a linux tool. To >stop confusion, this patch renames the function to 'in_iprange', and the >variable 'ipset' within it to 'iprange'. > >To test, follow the test plans outlined in Bug 14407 and confirm that >everything works as expected. > >Sponsored-by: Catalyst IT >--- > C4/Auth.pm | 16 ++++++++-------- > opac/sco/printslip.pl | 2 +- > opac/sco/sco-main.pl | 4 ++-- > opac/sco/sco-patron-image.pl | 4 ++-- > t/Auth.t | 28 ++++++++++++++-------------- > 5 files changed, 27 insertions(+), 27 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index d79ce466e0e..26677509fd4 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -61,7 +61,7 @@ BEGIN { > @ISA = qw(Exporter); > @EXPORT = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions); > @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash >- &get_all_subpermissions &get_user_subpermissions track_login_daily &in_ipset >+ &get_all_subpermissions &get_user_subpermissions track_login_daily &in_iprange > ); > %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] ); > $ldap = C4::Context->config('useldapserver') || 0; >@@ -2108,20 +2108,20 @@ sub haspermission { > #FIXME - This fcn should return the failed permission so a suitable error msg can be delivered. > } > >-=head2 in_ipset >+=head2 in_iprange > >- $flags = ($ipset); >+ $flags = ($iprange); > >-C<$ipset> A space separated string describing an IP set. Can include single IPs or ranges >+C<$iprange> A space separated string describing an IP range. Can include single IPs or ranges > >-Returns 1 if the remote address is in the provided ipset, or 0 otherwise. >+Returns 1 if the remote address is in the provided iprange, or 0 otherwise. > > =cut > >-sub in_ipset { >- my ($ipset) = @_; >+sub in_iprange { >+ my ($iprange) = @_; > my $result = 1; >- my @allowedipranges = $ipset ? split(' ', $ipset) : (); >+ my @allowedipranges = $iprange ? split(' ', $iprange) : (); > if (scalar @allowedipranges > 0) { > my @rangelist; > eval { @rangelist = Net::CIDR::range2cidr(@allowedipranges); }; return 0 if $@; >diff --git a/opac/sco/printslip.pl b/opac/sco/printslip.pl >index 8234e891a58..d914c288cc2 100755 >--- a/opac/sco/printslip.pl >+++ b/opac/sco/printslip.pl >@@ -35,7 +35,7 @@ use C4::Members; > use C4::Koha; > > my $input = new CGI; >-unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) { >+unless ( in_iprange(C4::Context->preference('SelfCheckAllowByIPRanges')) ) { > print $input->header(status => '403 Forbidden - functionality not available from your location'); > exit; > } >diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl >index a41971d8022..efc0f90af25 100755 >--- a/opac/sco/sco-main.pl >+++ b/opac/sco/sco-main.pl >@@ -35,7 +35,7 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > >-use C4::Auth qw(get_template_and_user checkpw in_ipset); >+use C4::Auth qw(get_template_and_user checkpw in_iprange); > use C4::Koha; > use C4::Circulation; > use C4::Reserves; >@@ -59,7 +59,7 @@ unless (C4::Context->preference('WebBasedSelfCheck')) { > exit; > } > >-unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) { >+unless ( in_iprange(C4::Context->preference('SelfCheckAllowByIPRanges')) ) { > # redirect to OPAC home if self-checkout not permitted from current IP > print $query->redirect("/cgi-bin/koha/opac-main.pl"); > exit; >diff --git a/opac/sco/sco-patron-image.pl b/opac/sco/sco-patron-image.pl >index b61130eda18..e997ab984bf 100755 >--- a/opac/sco/sco-patron-image.pl >+++ b/opac/sco/sco-patron-image.pl >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use C4::Auth qw(in_ipset); >+use C4::Auth qw(in_iprange); > use C4::Service; > use C4::Members; > use Koha::Patron::Images; >@@ -36,7 +36,7 @@ unless (C4::Context->preference('ShowPatronImageInWebBasedSelfCheck')) { > exit; > } > >-unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) { >+unless ( in_iprange(C4::Context->preference('SelfCheckAllowByIPRanges')) ) { > print $query->header(status => '403 Forbidden - functionality not available from your location'); > exit; > } >diff --git a/t/Auth.t b/t/Auth.t >index d9045947c18..4ab2e8997a2 100644 >--- a/t/Auth.t >+++ b/t/Auth.t >@@ -19,24 +19,24 @@ use Modern::Perl; > use Test::More tests => 13; > use Test::Warn; > >-use C4::Auth qw / in_ipset /; >+use C4::Auth qw / in_iprange /; > > $ENV{REMOTE_ADDR} = '192.168.1.30'; > my $ipset1 = "192.168.1.30"; > >-ok(in_ipset("192.168.1.30"), 'simple single ip matching remote ip'); >-ok(!in_ipset("192.168.1.31"), 'simple single ip not match remote ip'); >-ok(in_ipset("192.168.1.1/24"), 'simple ip range/24 with remote ip in it'); >-ok(!in_ipset("192.168.2.1/24"), 'simple ip range/24 with remote ip not in it'); >-ok(in_ipset("192.168.2.1/16"), 'simple ip range/16 with remote ip in it'); >-ok(!in_ipset("192.168.1.10-30"), 'invalidly represented IP range with remote ip in it'); >-ok(in_ipset("192.168.1.10-192.168.1.30"), 'validly represented ip range with remote ip in it'); >-ok(in_ipset("127.0.0.1 192.168.1.30 192.168.2.10-192.168.2.25"), 'multiple ips and ranges, including the remote ip'); >-ok(!in_ipset("127.0.0.1 8.8.8.8 192.168.2.1/24 192.168.3.1/24 192.168.1.1-192.168.1.29"), "multiple ip and ip ranges, with the remote ip in none of them"); >-ok(in_ipset(""), "blank list given, no preference set - implies everything goes through."); >-ok(in_ipset(), "no list given, no preference set - implies everything goes through."); >-ok(in_ipset("192.168.1.1/36"), 'simple invalid ip range/36 with remote ip in it'); >+ok(in_iprange("192.168.1.30"), 'simple single ip matching remote ip'); >+ok(!in_iprange("192.168.1.31"), 'simple single ip not match remote ip'); >+ok(in_iprange("192.168.1.1/24"), 'simple ip range/24 with remote ip in it'); >+ok(!in_iprange("192.168.2.1/24"), 'simple ip range/24 with remote ip not in it'); >+ok(in_iprange("192.168.2.1/16"), 'simple ip range/16 with remote ip in it'); >+ok(!in_iprange("192.168.1.10-30"), 'invalidly represented IP range with remote ip in it'); >+ok(in_iprange("192.168.1.10-192.168.1.30"), 'validly represented ip range with remote ip in it'); >+ok(in_iprange("127.0.0.1 192.168.1.30 192.168.2.10-192.168.2.25"), 'multiple ips and ranges, including the remote ip'); >+ok(!in_iprange("127.0.0.1 8.8.8.8 192.168.2.1/24 192.168.3.1/24 192.168.1.1-192.168.1.29"), "multiple ip and ip ranges, with the remote ip in none of them"); >+ok(in_iprange(""), "blank list given, no preference set - implies everything goes through."); >+ok(in_iprange(), "no list given, no preference set - implies everything goes through."); >+ok(in_iprange("192.168.1.1/36"), 'simple invalid ip range/36 with remote ip in it'); > $ENV{DEBUG} = 1; >-warning_like { in_ipset("192.168.1.1/36") } >+warning_like { in_iprange("192.168.1.1/36") } > qr/cidrlookup failed for/, > 'noisy simple invalid ip range/36 with remote ip in it'; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22943
:
90100
|
100323
|
100324
|
100702
|
100703
|
100704