X-Git-Url: https://git.sesse.net/?p=itkacl;a=blobdiff_plain;f=libapache2-mod-authz-itkacl-0.7%2Fmod_authz_itkacl.c;fp=libapache2-mod-authz-itkacl-0.6%2Fmod_authz_itkacl.c;h=97017ef0693f06d6973af1a3c9138073192a8469;hp=51ec224c00438326eceb4f6c9e1f062abad6f252;hb=HEAD;hpb=5ea73ea3a1ffa23ca598fac117830664b66a2ebf diff --git a/libapache2-mod-authz-itkacl-0.6/mod_authz_itkacl.c b/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 51ec224..97017ef 100644 --- a/libapache2-mod-authz-itkacl-0.6/mod_authz_itkacl.c +++ b/libapache2-mod-authz-itkacl-0.7/mod_authz_itkacl.c @@ -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" @@ -14,18 +14,17 @@ #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; }