]> iEval git - apache2-authzcaps.git/blobdiff - lib/Apache2/AuthzCaps.pm
Get rid of smartmatch
[apache2-authzcaps.git] / lib / Apache2 / AuthzCaps.pm
index b0ccffc4da58bab532475e4279cd862be9e7bcf3..8ffaaac79cbc99f995be0d6e8ee596b9aa2877e7 100644 (file)
@@ -1,10 +1,11 @@
-package Apache2::AuthzCaps 0.001;
+package Apache2::AuthzCaps;
 
 use 5.014000;
 use strict;
 use warnings;
 use subs qw/OK DECLINED/;
-no if $] >= 5.017011, warnings => 'experimental::smartmatch';
+
+our $VERSION = '0.001001';
 
 use if $ENV{MOD_PERL}, 'Apache2::Access';
 use if $ENV{MOD_PERL}, 'Apache2::Const' => qw/OK DECLINED/;
@@ -20,45 +21,40 @@ our @EXPORT_OK = qw/setcap hascaps/;
 our $rootdir;
 
 sub setcap{
-  my ($user, $cap, $value) = @_;
-  my $config = eval { LoadFile "$rootdir/$user.yml" } // {};
-  $config->{caps}//={};
-  my $caps=$config->{caps};
-
-  delete $caps->{$cap} unless $value;
-  $caps->{$cap} = 1 if $value;
-  DumpFile "$rootdir/$user.yml", $config
+       my ($user, $cap, $value) = @_;
+       my $config = eval { LoadFile "$rootdir/$user.yml" } // {};
+       $config->{caps}//={};
+       my $caps=$config->{caps};
+
+       delete $caps->{$cap} unless $value;
+       $caps->{$cap} = 1 if $value;
+       DumpFile "$rootdir/$user.yml", $config
 }
 
 sub hascaps{
-  my ($user, @caps) = @_;
-  my $config = LoadFile "$rootdir/$user.yml";
-  my $caps = $config->{caps};
-  for (@caps) {
-       return 0 unless $caps->{$_}
-  }
-  1
+       my ($user, @caps) = @_;
+       my $config = LoadFile "$rootdir/$user.yml";
+       my $caps = $config->{caps};
+       for (@caps) {
+               return 0 unless $caps->{$_}
+       }
+       1
 }
 
 sub handler{
-  my $r=shift;
-  my $user = $r->user;
-  local $rootdir = $r->dir_config('AuthzCapsRootdir');
+       my $r=shift;
+       my $user = $r->user;
+       local $rootdir = $r->dir_config('AuthzCapsRootdir');
 
-  if ($user) {
-  LOOP: for my $requirement (map { $_->{requirement} } @{$r->requires}) {
-         my ($command, @args) = split ' ', $requirement;
+       if ($user) {
+               for my $requirement (map { $_->{requirement} } @{$r->requires}) {
+                       my ($command, @args) = split ' ', $requirement;
 
-         given ($command){
-               when('cap'){
-                 return OK if hascaps $user, @args
+                       return OK if $command eq 'cap' && hascaps $user, @args;
                }
-
-         }
        }
-  }
 
-  DECLINED
+       DECLINED
 }
 
 1;
This page took 0.01932 seconds and 4 git commands to generate.