#include "mod_session.h"
#include "mod_request.h"
-#define LOG_PREFIX "mod_auth_form: "
#define FORM_LOGIN_HANDLER "form-login-handler"
#define FORM_LOGOUT_HANDLER "form-logout-handler"
#define FORM_REDIRECT_HANDLER "form-redirect-handler"
AUTHN_PROVIDER_VERSION);
if (!provider || !provider->check_password) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"no authn provider configured");
auth_result = AUTH_GENERAL_ERROR;
break;
switch (auth_result) {
case AUTH_DENIED:
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"user '%s': authentication failure for \"%s\": "
"password Mismatch",
sent_user, r->uri);
return_code = HTTP_UNAUTHORIZED;
break;
case AUTH_USER_NOT_FOUND:
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"user '%s' not found: %s", sent_user, r->uri);
return_code = HTTP_UNAUTHORIZED;
break;
*/
if (PROXYREQ_PROXY == r->proxyreq) {
ap_log_rerror(APLOG_MARK, APLOG_ERR,
- 0, r, LOG_PREFIX "form auth cannot be used for proxy "
+ 0, r, "form auth cannot be used for proxy "
"requests due to XSS risk, access denied: %s", r->uri);
return HTTP_INTERNAL_SERVER_ERROR;
}
/* We need an authentication realm. */
if (!ap_auth_name(r)) {
ap_log_rerror(APLOG_MARK, APLOG_ERR,
- 0, r, LOG_PREFIX "need AuthName: %s", r->uri);
+ 0, r, "need AuthName: %s", r->uri);
return HTTP_INTERNAL_SERVER_ERROR;
}
}
if (r->method_number != M_POST) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"the " FORM_LOGIN_HANDLER " only supports the POST method for %s",
r->uri);
return HTTP_METHOD_NOT_ALLOWED;
if (r->kept_body && sent_method && sent_mimetype) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"internal redirect to method '%s' and body mimetype '%s' for the "
"uri: %s", sent_method, sent_mimetype, r->uri);
}
else {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"internal redirect requested but one or all of method, mimetype or "
"body are NULL: %s", r->uri);
return HTTP_INTERNAL_SERVER_ERROR;
#include "http_request.h"
#include "http_protocol.h"
-#define SESSION_PREFIX "mod_session: "
#define SESSION_EXPIRY "expiry"
#define HTTP_SESSION "HTTP_SESSION"
/* should the session be loaded at all? */
if (!session_included(r, dconf)) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, SESSION_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"excluded by configuration for: %s", r->uri);
return APR_SUCCESS;
}
/* load the session from the session hook */
rv = ap_run_session_load(r, &zz);
if (DECLINED == rv) {
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, SESSION_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
"session is enabled but no session modules have been configured, "
"session not loaded: %s", r->uri);
return APR_EGENERAL;
}
else if (OK != rv) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, SESSION_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"error while loading the session, "
"session not loaded: %s", r->uri);
return rv;
else {
rv = ap_run_session_decode(r, zz);
if (OK != rv) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, SESSION_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"error while decoding the session, "
"session not loaded: %s", r->uri);
return rv;
/* sanity checks, should we try save at all? */
if (z->written) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, SESSION_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"attempt made to save the session twice, "
"session not saved: %s", r->uri);
return APR_EGENERAL;
}
if (z->expiry && z->expiry < now) {
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, SESSION_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
"attempt made to save a session when the session had already expired, "
"session not saved: %s", r->uri);
return APR_EGENERAL;
/* encode the session */
rv = ap_run_session_encode(r, z);
if (OK != rv) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, SESSION_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"error while encoding the session, "
"session not saved: %s", r->uri);
return rv;
/* try the save */
rv = ap_run_session_save(r, z);
if (DECLINED == rv) {
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, SESSION_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
"session is enabled but no session modules have been configured, "
"session not saved: %s", r->uri);
return APR_EGENERAL;
}
else if (OK != rv) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, SESSION_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"error while saving the session, "
"session not saved: %s", r->uri);
return rv;
#include "http_log.h"
#include "util_cookies.h"
-#define LOG_PREFIX "mod_session_cookie: "
#define MOD_SESSION_COOKIE "mod_session_cookie"
module AP_MODULE_DECLARE_DATA session_cookie_module;
#include "apr_crypto.h" /* for apr_*_crypt et al */
-#define LOG_PREFIX "mod_session_crypto: "
#define CRYPTO_KEY "session_crypto_context"
module AP_MODULE_DECLARE_DATA session_crypto_module;
res = apr_crypto_get_block_key_types(&ciphers, f);
if (APR_SUCCESS != res) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"no ciphers returned by APR. "
"session encryption not possible");
return res;
}
options[offset] = 0;
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"cipher '%s' not recognised by crypto driver. "
"session encryption not possible, options: %s", dconf->cipher, options);
(unsigned char *) (&salt), sizeof(apr_uuid_t),
*cipher, APR_MODE_CBC, 1, 4096, f, r->pool);
if (APR_STATUS_IS_ENOKEY(res)) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"the passphrase '%s' was empty", passphrase);
}
if (APR_STATUS_IS_EPADDING(res)) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"padding is not supported for cipher");
}
if (APR_STATUS_IS_EKEYTYPE(res)) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"the key type is not known");
}
if (APR_SUCCESS != res) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"encryption could not be configured.");
return res;
}
res = apr_crypto_block_encrypt_init(&block, &iv, key, &blockSize, r->pool);
if (APR_SUCCESS != res) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"apr_crypto_block_encrypt_init failed");
return res;
}
res = apr_crypto_block_encrypt(&encrypt, &encryptlen, (unsigned char *)in,
strlen(in), block);
if (APR_SUCCESS != res) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"apr_crypto_block_encrypt failed");
return res;
}
res = apr_crypto_block_encrypt_finish(encrypt + encryptlen, &tlen, block);
if (APR_SUCCESS != res) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"apr_crypto_block_encrypt_finish failed");
return res;
}
(unsigned char *)decoded, sizeof(apr_uuid_t),
*cipher, APR_MODE_CBC, 1, 4096, f, r->pool);
if (APR_STATUS_IS_ENOKEY(res)) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r,
"the passphrase '%s' was empty", passphrase);
continue;
}
else if (APR_STATUS_IS_EPADDING(res)) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r,
"padding is not supported for cipher");
continue;
}
else if (APR_STATUS_IS_EKEYTYPE(res)) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r,
"the key type is not known");
continue;
}
else if (APR_SUCCESS != res) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r,
"encryption could not be configured.");
continue;
}
/* sanity check - decoded too short? */
if (decodedlen < (sizeof(apr_uuid_t) + ivSize)) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, r,
"too short to decrypt, skipping");
res = APR_ECRYPT;
continue;
res = apr_crypto_block_decrypt_init(&block, &blockSize, (unsigned char *)slider, key,
r->pool);
if (APR_SUCCESS != res) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r,
"apr_crypto_block_decrypt_init failed");
continue;
}
res = apr_crypto_block_decrypt(&decrypted, &decryptedlen,
(unsigned char *)slider, len, block);
if (res) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r,
"apr_crypto_block_decrypt failed");
continue;
}
res = apr_crypto_block_decrypt_finish(decrypted + decryptedlen, &tlen, block);
if (APR_SUCCESS != res) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r,
"apr_crypto_block_decrypt_finish failed");
continue;
}
}
if (APR_SUCCESS != res) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, res, r,
"decryption failed");
}
apr_pool_userdata_get((void **)&f, CRYPTO_KEY, r->server->process->pconf);
res = encrypt_string(r, f, dconf, z->encoded, &encoded);
if (res != OK) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, res, r,
"encrypt session failed");
return res;
}
r->server->process->pconf);
res = decrypt_string(r, f, dconf, z->encoded, &encoded);
if (res != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r,
"decrypt session failed, wrong passphrase?");
return res;
}
rv = apr_crypto_init(p);
if (APR_SUCCESS != rv) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, LOG_PREFIX
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
"APR crypto could not be initialised");
return rv;
}
rv = apr_crypto_get_driver(&driver, conf->library, conf->params, &err, p);
if (APR_EREINIT == rv) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s, LOG_PREFIX
+ ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
"warning: crypto for '%s' was already initialised, "
"using existing configuration", conf->library);
rv = APR_SUCCESS;
}
if (APR_SUCCESS != rv && err) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, LOG_PREFIX
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
"%s", err->msg);
return rv;
}
if (APR_ENOTIMPL == rv) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, LOG_PREFIX
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
"The crypto library '%s' could not be found",
conf->library);
return rv;
}
if (APR_SUCCESS != rv || !driver) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, LOG_PREFIX
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
"The crypto library '%s' could not be loaded",
conf->library);
return rv;
rv = apr_crypto_make(&f, driver, conf->params, p);
if (APR_SUCCESS != rv) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, LOG_PREFIX
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
"The crypto library '%s' could not be initialised",
conf->library);
return rv;
}
- ap_log_error(APLOG_MARK, APLOG_INFO, rv, s, LOG_PREFIX
+ ap_log_error(APLOG_MARK, APLOG_INFO, rv, s,
"The crypto library '%s' was loaded successfully",
conf->library);
#include "mod_dbd.h"
#include "mpm_common.h"
-#define LOG_PREFIX "mod_session_dbd: "
#define MOD_SESSION_DBD "mod_session_dbd"
module AP_MODULE_DECLARE_DATA session_dbd_module;
session_dbd_prepare_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_prepare);
session_dbd_acquire_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_acquire);
if (!session_dbd_prepare_fn || !session_dbd_acquire_fn) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"You must load mod_dbd to enable AuthDBD functions");
return APR_EGENERAL;
}
dbd = session_dbd_acquire_fn(r);
if (!dbd) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"failed to acquire database connection");
return APR_EGENERAL;
}
statement = apr_hash_get(dbd->prepared, query, APR_HASH_KEY_STRING);
if (!statement) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"failed to find the prepared statement called '%s'", query);
return APR_EGENERAL;
}
&session_dbd_module);
if (conf->selectlabel == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"no SessionDBDselectlabel has been specified");
return APR_EGENERAL;
}
rv = apr_dbd_pvbselect(dbd->driver, r->pool, dbd->handle, &res, statement,
0, key, &expiry, NULL);
if (rv) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"query execution error saving session '%s' "
"in database using query '%s': %s", key, conf->selectlabel,
apr_dbd_error(dbd->driver, dbd->handle, rv));
rv != -1;
rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1)) {
if (rv != 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"error retrieving results while saving '%s' "
"in database using query '%s': %s", key, conf->selectlabel,
apr_dbd_error(dbd->driver, dbd->handle, rv));
&session_dbd_module);
if (conf->updatelabel == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"no SessionDBDupdatelabel has been specified");
return APR_EGENERAL;
}
rv = apr_dbd_pvbquery(dbd->driver, r->pool, dbd->handle, &rows, statement,
val, &expiry, key, NULL);
if (rv) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"query execution error updating session '%s' "
"using database query '%s': %s", key, conf->updatelabel,
apr_dbd_error(dbd->driver, dbd->handle, rv));
}
if (conf->insertlabel == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"no SessionDBDinsertlabel has been specified");
return APR_EGENERAL;
}
rv = apr_dbd_pvbquery(dbd->driver, r->pool, dbd->handle, &rows, statement,
val, &expiry, key, NULL);
if (rv) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"query execution error inserting session '%s' "
"in database with '%s': %s", key, conf->insertlabel,
apr_dbd_error(dbd->driver, dbd->handle, rv));
return APR_SUCCESS;
}
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"the session insert query did not cause any rows to be added "
"to the database for session '%s', session not inserted", key);
&session_dbd_module);
ap_dbd_t *dbd = session_dbd_acquire_fn(r);
if (dbd == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"failed to acquire database connection to remove "
"session with key '%s'", key);
return APR_EGENERAL;
}
if (conf->deletelabel == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"no SessionDBDdeletelabel has been specified");
return APR_EGENERAL;
}
statement = apr_hash_get(dbd->prepared, conf->deletelabel,
APR_HASH_KEY_STRING);
if (statement == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"prepared statement could not be found for "
"SessionDBDdeletelabel with the label '%s'",
conf->deletelabel);
rv = apr_dbd_pvbquery(dbd->driver, r->pool, dbd->handle, &rows, statement,
key, NULL);
if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"query execution error removing session '%s' "
"from database", key);
return rv;
return OK;
}
else {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, LOG_PREFIX
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
"peruser sessions can only be saved if a user is logged in, "
"session not saved: %s", r->uri);
}