Re: question on Apache2_4::AuthCookie
André Warnier (tomcat) <[email protected]>
| Newsgroups | gmane.comp.apache.mod-perl |
|---|---|
| Message-ID | <[email protected]> |
On 07.04.2016 21:12, Lathan Bidwell wrote: >> >> Hi. >> I have (a long time ago) created an AAA module based originally on >> Apache2::AuthCookie (a copy and rewrite, not a sub-class). Now I need to >> adapt this to Apache 2.4. >> I have read all the docs at >> https://metacpan.org/source/MSCHOUT/Apache-AuthCookie-3.24/lib/Apache2_4/AuthCookie.pm, >> and followed the related correspondence on this list. >> My problem is that I would like to keep a single perl source, for both >> Apache 2.2 and Apache 2.4. >> As far as I can tell so far, this should not be a big problem, except for >> the following difference : >> >> In the Apache 2.2 version, I have this statement : >> >> use Apache2::Const -compile => qw(:common :http :methods :override :proxy); >> >> and in the Apache 2.4 version, I must have this statement or it will not >> compile : >> >> use Apache2::Const -compile => qw(:common :http :methods :override :proxy >> AUTHZ_GRANTED AUTHZ_DENIED AUTHZ_DENIED_NO_USER); >> >> > I'm not very familiar with require vs use, but could you use a begin > block, Apache2::ServerUtil::get_server_version() > and then if/else based on the version number? > I was kind of thinking in that direction also, but as I recall BEGIN blocks can be kind of iffy in an Apache/mod_perl module context. I'm not an expert either, so I guess I'll have to go review some docs about this. Thanks for the reference to Apache2::ServerUtil::get_server_version(), saves me some digging. > > > >> (That is because these new AUTHZ_* constants must be used in the new >> "AuthzProvider" subs). >> >> I could of course hack the values of these constants under 2.4, and use >> their values directly in my module, but that is rather "inelegant". >> >> My question is thus : would there be a way to make the import of these >> constants conditional on the Apache version the module is running under ? >> (In other words e.g. define them with value 0 initially (for Apache 2.2, >> since they are never used there), and override them if under Apache 2.4 ? >> >> Or, to put this another way : imagining that there are already some >> servers, currently running Apache 2.2 with, say, mod_perl 2.0.7, and on >> which the current (2.2-only) version of my Auth module is running. >> If I ever update these servers with the latest (2.4-compatible) version of >> my module, including the above extra imported constants, that updated >> module will not compile anymore on those systems (because these constants >> are not defined there). >> Is there a way to avoid this incompatibility ? >> >> I tried to phrase the above as clearly as possible, but if it is still >> confusing, I can try again.. >> >> Thanks >> >> >