/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
/* Export a hook for modules that manage clientside sessions * (e.g. mod_auth_cookie) * to deal with those when we successfully login/logout at the server * * XXX: WHY would this be specific to dbd_authz? Why wouldn't we track * this across all authz user providers in a lower level mod, such as * mod_auth_basic/digest?
*/
APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(authz_dbd, AUTHZ_DBD, int, client_login,
(request_rec *r, int code, constchar *action),
(r, code, action), OK, DECLINED)
if (cfg->query == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01642) "No query configured for %s!", action); return HTTP_INTERNAL_SERVER_ERROR;
}
dbd = dbd_handle(r); if (dbd == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02902) "No db handle available for %s! " "Check your database access",
action); return HTTP_INTERNAL_SERVER_ERROR;
}
if (cfg->redirect == 1) {
newuri = apr_table_get(r->headers_in, "Referer");
}
if (!newuri && cfg->redir_query) {
query = apr_hash_get(dbd->prepared, cfg->redir_query,
APR_HASH_KEY_STRING); if (query == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01646) "authz_dbd: no redirect query!"); /* OK, this is non-critical; we can just not-redirect */
} elseif ((rv = apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle,
&res, query, 0, r->user, NULL)) == 0) { for (rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1);
rv != -1;
rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1)) { if (rv != 0) {
message = apr_dbd_error(dbd->driver, dbd->handle, rv);
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01647) "authz_dbd in get_row; action=%s user=%s [%s]",
action, r->user, message?message:noerror);
} elseif (newuri == NULL) {
newuri =
apr_pstrdup(r->pool,
apr_dbd_get_entry(dbd->driver, row, 0));
} /* we can't break out here or row won't get cleaned up */
}
} else {
message = apr_dbd_error(dbd->driver, dbd->handle, rv);
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01648) "authz_dbd/redirect for %s of %s [%s]",
action, r->user, message?message:noerror);
}
} if (newuri != NULL) {
r->status = HTTP_MOVED_TEMPORARILY;
apr_table_set(r->err_headers_out, "Location", newuri);
}
authz_dbd_run_client_login(r, OK, action); return OK;
}
staticint authz_dbd_group_query(request_rec *r, authz_dbd_cfg *cfg,
apr_array_header_t *groups)
{ /* SELECT user_group FROM authz WHERE user = %s */ int rv; constchar *message;
ap_dbd_t *dbd;
apr_dbd_prepared_t *query;
apr_dbd_results_t *res = NULL;
apr_dbd_row_t *row = NULL;
if (cfg->query == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01649) "No query configured for dbd-group!"); return HTTP_INTERNAL_SERVER_ERROR;
}
dbd = dbd_handle(r); if (dbd == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02903) "No db handle available for dbd-query! " "Check your database access"); return HTTP_INTERNAL_SERVER_ERROR;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.