Skip to content

Add warnings if s4u2proxy options are inconsistent #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/mod_auth_gssapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,54 @@ static int mag_auth_basic(struct mag_req_cfg *req_cfg, struct mag_conn *mc,
return ret;
}

#define OPTION_WARNING "Warning: %s is set but %s = %s is missing!"

void mag_verify_config(request_rec *req, struct mag_config *cfg)
{
/* we check only once */
if (cfg->verified) return;

/* Check if cred store config is consistent with use_s4u2proxy.
* Although not strictly required it is generally adivsable to
* set keytab, client_keytab, and ccache in the cred_store when
* use_s4u2proxy is set, this is to avoid easy mistakes that are
* very difficult to diagnose */
if (cfg->use_s4u2proxy) {
bool has_keytab = false;
bool has_client_keytab = false;
bool has_ccache = false;

for (int i = 0; i < cfg->cred_store->count; i++) {
const char *key = cfg->cred_store->elements[i].key;
if (strcmp(key, "keytab") == 0) {
has_keytab = true;
} else if (strcmp(key, "client_keytab") == 0) {
has_client_keytab = true;
} else if (strcmp(key, "ccache") == 0) {
has_ccache = true;
}
}

if (!has_keytab) {
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, req,
OPTION_WARNING, "GssapiUseS4U2Proxy",
"GssapiCredStore", "keytab");
}
if (!has_client_keytab) {
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, req,
OPTION_WARNING, "GssapiUseS4U2Proxy",
"GssapiCredStore", "client_keytab");
}
if (!has_ccache) {
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, req,
OPTION_WARNING, "GssapiUseS4U2Proxy",
"GssapiCredStore", "ccache");
}
}

cfg->verified = true;
}

struct mag_req_cfg *mag_init_cfg(request_rec *req)
{
struct mag_server_config *scfg;
Expand All @@ -667,6 +715,7 @@ struct mag_req_cfg *mag_init_cfg(request_rec *req)
req_cfg->req = req;
req_cfg->cfg = ap_get_module_config(req->per_dir_config,
&auth_gssapi_module);
mag_verify_config(req, req_cfg->cfg);

scfg = ap_get_module_config(req->server->module_config,
&auth_gssapi_module);
Expand Down
2 changes: 2 additions & 0 deletions src/mod_auth_gssapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ struct mag_config {
gss_name_t acceptor_name;
bool acceptor_name_from_req;
uint32_t basic_timeout;

bool verified;
};

struct mag_server_config {
Expand Down