]> git.sesse.net Git - itkacl/blobdiff - libapache2-mod-authz-itkacl-0.7/mod_authz_itkacl.c
Release a new version of the Apache module, with the context support.
[itkacl] / libapache2-mod-authz-itkacl-0.7 / mod_authz_itkacl.c
similarity index 86%
rename from libapache2-mod-authz-itkacl-0.6/mod_authz_itkacl.c
rename to libapache2-mod-authz-itkacl-0.7/mod_authz_itkacl.c
index 51ec224c00438326eceb4f6c9e1f062abad6f252..97017ef0693f06d6973af1a3c9138073192a8469 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * ITKACL module, (C) 2004-2015 Steinar H. Gunderson
+ * ITKACL module, (C) 2004-2022 Steinar H. Gunderson
  */
 
-#define MODAUTHITKACL_VERSION "0.6"
+#define MODAUTHITKACL_VERSION "0.7"
 
 #include "apr_strings.h"
 
 #include "http_protocol.h"
 #include "http_request.h"
 #include "mod_auth.h"
+#include "itkacl.h"
 
 module AP_MODULE_DECLARE_DATA authz_itkacl_module;
-
-extern int itkacl_check(const char * const realm, const char * const user,
-                       char *errmsg, size_t errmsg_size);
+static struct itkacl_ctx *ctx = NULL;
 
 static int handle_require(request_rec *r, const char *username, const char *acl_path)
 {
        char errmsg[1024];
        int ret;
 
-       ret = itkacl_check(acl_path, username, errmsg, 1024);
+       ret = itkacl_check_with_ctx(ctx, acl_path, username, errmsg, 1024);
        if (ret == 0) {
                return AUTHZ_GRANTED;
        }
@@ -107,6 +106,17 @@ static authz_status authz_itkacl_authorize_user(request_rec *r, const char *requ
 static int authz_itkacl_init_handler(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 {
        ap_add_version_component(p, "mod_auth_itkacl/" MODAUTHITKACL_VERSION);
+       if (ctx != NULL) {
+               itkacl_free_ctx(ctx);
+       }
+       {
+               char errmsg[1024];
+               ctx = itkacl_create_ctx(errmsg, sizeof(errmsg));
+               if (ctx == NULL) {
+                       ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, "Error while initializing libitkacl: %s", errmsg);
+                       return HTTP_INTERNAL_SERVER_ERROR;
+               }
+       }
        return OK;
 }