summaryrefslogtreecommitdiffstats
path: root/src/mod_auth_gssapi.c
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2015-08-30 14:31:44 -0400
committerSimo Sorce <simo@redhat.com>2015-08-30 14:31:44 -0400
commit86661d07812b010b8cf664c2dab596be15ff1e31 (patch)
tree639a690c71d6513a1a5b3ef20c0b6e93ebc88be4 /src/mod_auth_gssapi.c
parent3e4f466d5224af50c6789894cca459aa4504ef47 (diff)
downloadmod_auth_gssapi-86661d07812b010b8cf664c2dab596be15ff1e31.tar.gz
mod_auth_gssapi-86661d07812b010b8cf664c2dab596be15ff1e31.tar.xz
mod_auth_gssapi-86661d07812b010b8cf664c2dab596be15ff1e31.zip
Allocate new keys at server startup.
This avoids a potential race condition if the first 2 request come in at the same time. It also avoids issues with forked apapche processes which may end up with different keys per fork. Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'src/mod_auth_gssapi.c')
-rw-r--r--src/mod_auth_gssapi.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/mod_auth_gssapi.c b/src/mod_auth_gssapi.c
index d4e2682..6f185f9 100644
--- a/src/mod_auth_gssapi.c
+++ b/src/mod_auth_gssapi.c
@@ -621,21 +621,30 @@ done:
struct mag_req_cfg *mag_init_cfg(request_rec *req)
{
+ struct mag_server_config *scfg;
struct mag_req_cfg *req_cfg = apr_pcalloc(req->pool,
sizeof(struct mag_req_cfg));
+ req_cfg->req = req;
req_cfg->cfg = ap_get_module_config(req->per_dir_config,
&auth_gssapi_module);
+ scfg = ap_get_module_config(req->server->module_config,
+ &auth_gssapi_module);
+
if (req_cfg->cfg->allowed_mechs) {
req_cfg->desired_mechs = req_cfg->cfg->allowed_mechs;
} else {
- struct mag_server_config *scfg;
- /* Try to fetch the default set if not explicitly configured */
- scfg = ap_get_module_config(req->server->module_config,
- &auth_gssapi_module);
+ /* Use the default set if not explicitly configured */
req_cfg->desired_mechs = scfg->default_mechs;
}
+ if (!req_cfg->cfg->mag_skey) {
+ req_cfg->mag_skey = req_cfg->cfg->mag_skey;
+ } else {
+ /* Use server random key if not explicitly configured */
+ req_cfg->mag_skey = scfg->mag_skey;
+ }
+
if (req->proxyreq == PROXYREQ_PROXY) {
req_cfg->req_proto = "Proxy-Authorization";
req_cfg->rep_proto = "Proxy-Authenticate";
@@ -743,7 +752,7 @@ static int mag_auth(request_rec *req)
/* if available, session always supersedes connection bound data */
if (req_cfg->use_sessions) {
- mag_check_session(req, cfg, &mc);
+ mag_check_session(req_cfg, &mc);
}
auth_header = apr_table_get(req->headers_in, req_cfg->req_proto);
@@ -802,7 +811,7 @@ static int mag_auth(request_rec *req)
ba_pwd.length = strlen(ba_pwd.value);
if (mc && mc->established &&
- mag_basic_check(cfg, mc, ba_user, ba_pwd)) {
+ mag_basic_check(req_cfg, mc, ba_user, ba_pwd)) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, req,
"Already established BASIC AUTH context found!");
mag_set_req_data(req, cfg, mc);
@@ -947,10 +956,10 @@ complete:
mc->expiration = expiration;
mc->auth_type = auth_type;
if (auth_type == AUTH_TYPE_BASIC) {
- mag_basic_cache(cfg, mc, ba_user, ba_pwd);
+ mag_basic_cache(req_cfg, mc, ba_user, ba_pwd);
}
if (req_cfg->use_sessions) {
- mag_attempt_session(req, cfg, mc);
+ mag_attempt_session(req_cfg, mc);
}
}
@@ -1265,6 +1274,7 @@ static void *mag_create_server_config(apr_pool_t *p, server_rec *s)
{
struct mag_server_config *scfg;
uint32_t maj, min;
+ apr_status_t rc;
scfg = apr_pcalloc(p, sizeof(struct mag_server_config));
@@ -1278,6 +1288,12 @@ static void *mag_create_server_config(apr_pool_t *p, server_rec *s)
mag_oid_set_destroy, apr_pool_cleanup_null);
}
+ rc = SEAL_KEY_CREATE(p, &scfg->mag_skey, NULL);
+ if (rc != OK) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
+ "Failed to generate random sealing key!");
+ }
+
return scfg;
}