Mod auth imap for apache2.4 patch
Jump to navigation
Jump to search
The following patch can be applied to the mod_auth_imap module found at http://ben.brillat.net/projects/mod_auth_imap/ to make it work with apache2.4
--- mod_auth_imap.c.orig 2015-09-15 20:51:06.321378328 -0400
+++ mod_auth_imap.c 2015-09-15 20:54:18.553530740 -0400
@@ -20,6 +20,8 @@
#include "apr_dbm.h"
#include "apr_md5.h"
+#include "mod_auth.h"
+
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
@@ -346,56 +348,10 @@
* checks the username against the allowed users in the .htaccess or httpd.conf
* returns "OK", "DECLINED", or "HTTP_UNAUTHORIZED" (see defines)
*******************************************************************************/
-static int imap_check_user_access (request_rec *r) {
- imap_config_rec *sec =
- (imap_config_rec *)ap_get_module_config (r->per_dir_config, &auth_imap_module);
- char *user = r->user;
- int m = r->method_number;
- int method_restricted = 0;
- register int x;
- const char *t, *w;
- const apr_array_header_t *reqs_arr = ap_requires (r);
- require_line *reqs;
-
- if (!reqs_arr)
- return (OK);
- reqs = (require_line *)reqs_arr->elts;
-
- for(x=0; x < reqs_arr->nelts; x++) {
-
- if (! (reqs[x].method_mask & (1 << m))) continue;
-
- method_restricted = 1;
-
- t = reqs[x].requirement;
- w = ap_getword(r->pool, &t, ' ');
- if(!strcmp(w,"valid-user"))
- return OK;
- if(!strcmp(w,"user")) {
- while(t[0]) {
- w = ap_getword_conf (r->pool, &t);
- if(!strcmp(user,w))
- return OK;
- }
- }
- else if(!strcmp(w,"group"))
- return DECLINED;
- }
-
- if (!method_restricted)
- return OK;
-
- if (!(sec->imap_authoritative))
- return DECLINED;
-
- ap_note_basic_auth_failure (r);
- return HTTP_UNAUTHORIZED;
-}
static void imap_register_hooks(apr_pool_t *p) {
- ap_hook_check_user_id(imap_authenticate_basic_user, NULL, NULL,
- APR_HOOK_MIDDLE);
- ap_hook_auth_checker(imap_check_user_access, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_register_auth_provider(p, AUTHN_PROVIDER_GROUP, "IMAP", AUTHN_PROVIDER_VERSION, &auth_imap_module, AP_AUTH_INTERNAL_PER_CONF);
+ ap_register_auth_provider(p, AUTHZ_PROVIDER_GROUP, "valid-user", AUTHZ_PROVIDER_VERSION, &auth_imap_module, AP_AUTH_INTERNAL_PER_CONF);
}
/*******************************************************************************