X-Git-Url: http://www.project-moonshot.org/gitweb/?p=mod_auth_gssapi.git;a=blobdiff_plain;f=src%2Fmod_auth_gssapi.c;h=b1b16e54c859cf9d5db100a36601c2bd14921c47;hp=d4e268219d8273d2215be0da80617d84efc0aeb3;hb=7aed3f2080561c603bc2dc6e44dcce3f6f09a09e;hpb=f476cb32f8103bdf1435d33ea6e81cba9805f576 diff --git a/src/mod_auth_gssapi.c b/src/mod_auth_gssapi.c index d4e2682..b1b16e5 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"; @@ -649,6 +658,19 @@ struct mag_req_cfg *mag_init_cfg(request_rec *req) return req_cfg; } +static bool use_s4u2proxy(struct mag_req_cfg *req_cfg) { + if (req_cfg->cfg->use_s4u2proxy) { + if (req_cfg->cfg->deleg_ccache_dir != NULL) { + return true; + } else { + ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, req_cfg->req, + "S4U2 Proxy requested but GssapiDelegCcacheDir " + "is not set. Constrained delegation disabled!"); + } + } + return false; +} + static int mag_auth(request_rec *req) { const char *type; @@ -743,7 +765,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 +824,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); @@ -841,7 +863,7 @@ static int mag_auth(request_rec *req) req->ap_auth_type = apr_pstrdup(req->pool, auth_types[auth_type]); #ifdef HAVE_CRED_STORE - if (cfg->use_s4u2proxy) { + if (use_s4u2proxy(req_cfg)) { cred_usage = GSS_C_BOTH; } #endif @@ -947,10 +969,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); } } @@ -1049,9 +1071,6 @@ static const char *mag_use_s4u2p(cmd_parms *parms, void *mconfig, int on) struct mag_config *cfg = (struct mag_config *)mconfig; cfg->use_s4u2proxy = on ? true : false; - if (cfg->deleg_ccache_dir == NULL) { - cfg->deleg_ccache_dir = apr_pstrdup(parms->pool, "/tmp"); - } return NULL; } #endif @@ -1265,6 +1284,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 +1298,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; }