Description: adjust for apache2
Origin: vendor
Forwarded: no
Author: AGOSTINI Yves <agostini@univ-metz.fr>
Reviewed-by: gregor herrmann <gregoa@debian.org>
Last-Update: 2013-08-20

--- a/AuthzNetLDAP.pm
+++ b/AuthzNetLDAP.pm
@@ -9,7 +9,13 @@ require DynaLoader;
 require AutoLoader;
 
 use Net::LDAP;
-use mod_perl;
+BEGIN {
+  eval {
+          require mod_perl;
+          import mod_perl ;
+      };
+  if ($@) { require mod_perl2; import mod_perl2; };
+};
 
 @ISA = qw(Exporter DynaLoader);
 # Items to export into callers namespace by default. Note: do not export
@@ -28,15 +34,15 @@ use constant MP2 => ($mod_perl::VERSION 
 # test for the version of mod_perl, and use the appropriate libraries
 BEGIN {
 	if (MP2) {
-		require Apache::Const;
-		require Apache::Access;
-		require Apache::Connection;
-		require Apache::Log;
-		require Apache::RequestRec;
-		require Apache::RequestUtil;
+		require Apache2::Const;
+		require Apache2::Access;
+		require Apache2::Connection;
+		require Apache2::Log;
+		require Apache2::RequestRec;
+		require Apache2::RequestUtil;
 		require URI;
 		require URI::ldap;
-		Apache::Const->import(-compile => 'HTTP_UNAUTHORIZED','OK', 'DECLINED');
+		Apache2::Const->import(-compile => 'HTTP_UNAUTHORIZED','OK', 'DECLINED');
 	} else {
 		require Apache::Constants;
 		require URI;
@@ -63,7 +69,7 @@ sub handler
 
    my $requires = $r->requires;
 
-   return MP2 ? Apache::DECLINED : Apache::Constants::DECLINED unless $requires;
+   return MP2 ? Apache2::Const::DECLINED : Apache::Constants::DECLINED unless $requires;
 
 
    my $username = MP2 ? $r->user : $r->connection->user;
@@ -88,7 +94,7 @@ sub handler
    {
         $r->note_basic_auth_failure;
         MP2 ? $r->log_error("user $username: LDAP Connection Failed: $error",$r->uri) : $r->log_reason("user $username: LDAP Connection Failed: $error",$r->uri);
-        return MP2 ? Apache::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
+        return MP2 ? Apache2::Const::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
    }
 
    #first let's get the user's DN 
@@ -105,7 +111,7 @@ sub handler
    {
         $r->note_basic_auth_failure;
         MP2 ? $r->log_error("user $username: LDAP Connection Failed: $error",$r->uri) : $r->log_reason("user $username: LDAP Connection Failed: $error",$r->uri);
-        return MP2 ? Apache::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
+        return MP2 ? Apache2::Const::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
    }
    my $entry = $mesg->shift_entry(); 
  
@@ -120,7 +126,7 @@ sub handler
        my ($requirement,@rest) = split(/\s+/, $req->{requirement});
      if (lc $requirement eq 'user')
      {
-        foreach (@rest) {return MP2 ? Apache::OK : Apache::Constants::OK if $username eq $_;}
+        foreach (@rest) {return MP2 ? Apache2::Const::OK : Apache::Constants::OK if $username eq $_;}
      }
      elsif (lc $requirement eq 'group')
     {
@@ -129,23 +135,23 @@ sub handler
         my ($foo,$group) = split(/"/,$req->{requirement}); 
          my $isMember = Apache::AuthzNetLDAP::_getIsMember($ldap,$r,$group,$entry->dn());
          MP2 ? $r->log_error("user $username: group($group) DEBUG - isMember: $isMember",$r->uri) : $r->log_reason("user $username: group($group) DEBUG - isMember: $isMember",$r->uri);
-         return MP2 ? Apache::OK : Apache::Constants::OK if $isMember;
+         return MP2 ? Apache2::Const::OK : Apache::Constants::OK if $isMember;
      }
 	  elsif (lc $requirement eq 'ldap-url')
 	 {
 	     my ($foo,$url) = split (/ldap-url/,$req->{requirement});
         my $isMember = Apache::AuthzNetLDAP::_checkURL($r,$ldap,$entry->dn(),$url);
 		MP2 ? $r->log_error("user $username: group($url) DEBUG - isMember: $isMember",$r->uri) : $r->log_reason("user $username: group($url) DEBUG - isMember: $isMember",$r->uri);
-		return MP2 ? Apache::OK : Apache::Constants::OK if $isMember;
+		return MP2 ? Apache2::Const::OK : Apache::Constants::OK if $isMember;
       }	     
      elsif (lc $requirement eq 'valid-user') {
-         return MP2 ? Apache::OK : Apache::Constants::OK;
+         return MP2 ? Apache2::Const::OK : Apache::Constants::OK;
               }
    }       
 
         $r->note_basic_auth_failure;
         MP2 ? $r->log_error("user $username: group (test) LDAP membership check failed with ismember: DEBUG REMOVE COMMENT",$r->uri) : $r->log_reason("user $username: group (test) LDAP membership check failed with ismember: DEBUG REMOVE COMMENT",$r->uri);
-        return MP2 ? Apache::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
+        return MP2 ? Apache2::Const::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
    
  
   
@@ -206,7 +212,7 @@ sub _getIsMember
    {
         $r->note_basic_auth_failure;
         MP2 ? $r->log_error("user $userDN: group ($groupDN) LDAP search Failed: $error",$r->uri) : $r->log_reason("user $userDN: group ($groupDN) LDAP search Failed: $error",$r->uri);
-        return MP2 ? Apache::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
+        return MP2 ? Apache2::Const::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
    }
       my $entry = $mesg->pop_entry();
 
@@ -236,7 +242,7 @@ sub _getIsMember
         {
           $r->note_basic_auth_failure;
           MP2 ? $r->log_error("user $userDN: group ($groupDN) LDAP search Failed: $error",$r->uri) : $r->log_reason("user $userDN: group ($groupDN) LDAP search Failed: $error",$r->uri);
-          return MP2 ? Apache::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
+          return MP2 ? Apache2::Const::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
         }
 
         #if we find an entry it returns true
@@ -280,7 +286,7 @@ sub _getIsMember
    {
         $r->note_basic_auth_failure;
         MP2 ? $r->log_error("user $userDN: group ($groupDN) LDAP search Failed: $error",$r->uri) : $r->log_reason("user $userDN: group ($groupDN) LDAP search Failed: $error",$r->uri);
-        return MP2 ? Apache::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
+        return MP2 ? Apache2::Const::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
    }
 
      #if make it this far then you must be a member
@@ -312,7 +318,7 @@ sub _checkURL
         {
           $r->note_basic_auth_failure;
           MP2 ? $r->log_error("user $userDN: group ($urlval) LDAP search Failed: $error",$r->uri) : $r->log_reason("user $userDN: group ($urlval) LDAP search Failed: $error",$r->uri);
-          return MP2 ? Apache::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
+          return MP2 ? Apache2::Const::HTTP_UNAUTHORIZED : Apache::Constants::HTTP_UNAUTHORIZED;
         }
 
         #if we find an entry it returns true
