Blame SOURCES/httpd-2.4.6-mod_authz_dbd-missing-query.patch

41a6c3
diff --git a/modules/aaa/mod_authz_dbd.c b/modules/aaa/mod_authz_dbd.c
41a6c3
index 1a456fe..6a0f705 100644
41a6c3
--- a/modules/aaa/mod_authz_dbd.c
41a6c3
+++ b/modules/aaa/mod_authz_dbd.c
41a6c3
@@ -116,7 +116,7 @@ static int authz_dbd_login(request_rec *r, authz_dbd_cfg *cfg,
41a6c3
     const char *newuri = NULL;
41a6c3
     int nrows;
41a6c3
     const char *message;
41a6c3
-    ap_dbd_t *dbd = dbd_handle(r);
41a6c3
+    ap_dbd_t *dbd;
41a6c3
     apr_dbd_prepared_t *query;
41a6c3
     apr_dbd_results_t *res = NULL;
41a6c3
     apr_dbd_row_t *row = NULL;
41a6c3
@@ -126,6 +126,16 @@ static int authz_dbd_login(request_rec *r, authz_dbd_cfg *cfg,
41a6c3
                       "No query configured for %s!", action);
41a6c3
         return HTTP_INTERNAL_SERVER_ERROR;
41a6c3
     }
41a6c3
+
41a6c3
+    dbd = dbd_handle(r);
41a6c3
+    if (dbd == NULL) {
41a6c3
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02902)
41a6c3
+                      "No db handle available for %s! "
41a6c3
+                      "Check your database access",
41a6c3
+                      action);
41a6c3
+        return HTTP_INTERNAL_SERVER_ERROR;
41a6c3
+    }
41a6c3
+
41a6c3
     query = apr_hash_get(dbd->prepared, cfg->query, APR_HASH_KEY_STRING);
41a6c3
     if (query == NULL) {
41a6c3
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01643)
41a6c3
@@ -202,7 +212,7 @@ static int authz_dbd_group_query(request_rec *r, authz_dbd_cfg *cfg,
41a6c3
     /* SELECT group FROM authz WHERE user = %s */
41a6c3
     int rv;
41a6c3
     const char *message;
41a6c3
-    ap_dbd_t *dbd = dbd_handle(r);
41a6c3
+    ap_dbd_t *dbd;
41a6c3
     apr_dbd_prepared_t *query;
41a6c3
     apr_dbd_results_t *res = NULL;
41a6c3
     apr_dbd_row_t *row = NULL;
41a6c3
@@ -212,6 +222,15 @@ static int authz_dbd_group_query(request_rec *r, authz_dbd_cfg *cfg,
41a6c3
                       "No query configured for dbd-group!");
41a6c3
         return HTTP_INTERNAL_SERVER_ERROR;
41a6c3
     }
41a6c3
+
41a6c3
+    dbd = dbd_handle(r);
41a6c3
+    if (dbd == NULL) {
41a6c3
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02903)
41a6c3
+                      "No db handle available for dbd-query! "
41a6c3
+                      "Check your database access");
41a6c3
+        return HTTP_INTERNAL_SERVER_ERROR;
41a6c3
+    }
41a6c3
+
41a6c3
     query = apr_hash_get(dbd->prepared, cfg->query, APR_HASH_KEY_STRING);
41a6c3
     if (query == NULL) {
41a6c3
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01650)