File: new-apache2.patch

package info (click to toggle)
libapache-authznetldap-perl 0.07-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 124 kB
  • sloc: perl: 433; makefile: 2
file content (147 lines) | stat: -rw-r--r-- 6,756 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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