Skip to content

Commit b4b43c2

Browse files
simo5frozencemetery
authored andcommitted
Add warnings if s4u2proxy options are inconsistent
In most cases, people configuring GssapiUseS4U2Proxy should really set all three cred store options for keytab, client_keytab, and ccache to isolate httpd from default system ccaches and keytabs. Not doing so unintentionally easily leads to very hard to debug issues when trying to use the proxying feature. Not enforcing as a hard misconfiguration both for compatibility reasons and also because there are corner cases where the configuration is intentional. Signed-off-by: Simo Sorce <simo@redhat.com> [rharwood@redhat.com: typo fix and commit message cleanup] Reviewed-by: Robbie Harwood <rharwood@redhat.com>
1 parent 8ef0dc8 commit b4b43c2

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/mod_auth_gssapi.c

+49
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,54 @@ static int mag_auth_basic(struct mag_req_cfg *req_cfg, struct mag_conn *mc,
659659
return ret;
660660
}
661661

662+
#define OPTION_WARNING "Warning: %s is set but %s = %s is missing!"
663+
664+
void mag_verify_config(request_rec *req, struct mag_config *cfg)
665+
{
666+
/* we check only once */
667+
if (cfg->verified) return;
668+
669+
/* Check if cred store config is consistent with use_s4u2proxy.
670+
* Although not strictly required it is generally adivsable to
671+
* set keytab, client_keytab, and ccache in the cred_store when
672+
* use_s4u2proxy is set, this is to avoid easy mistakes that are
673+
* very difficult to diagnose */
674+
if (cfg->use_s4u2proxy) {
675+
bool has_keytab = false;
676+
bool has_client_keytab = false;
677+
bool has_ccache = false;
678+
679+
for (int i = 0; i < cfg->cred_store->count; i++) {
680+
const char *key = cfg->cred_store->elements[i].key;
681+
if (strcmp(key, "keytab") == 0) {
682+
has_keytab = true;
683+
} else if (strcmp(key, "client_keytab") == 0) {
684+
has_client_keytab = true;
685+
} else if (strcmp(key, "ccache") == 0) {
686+
has_ccache = true;
687+
}
688+
}
689+
690+
if (!has_keytab) {
691+
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, req,
692+
OPTION_WARNING, "GssapiUseS4U2Proxy",
693+
"GssapiCredStore", "keytab");
694+
}
695+
if (!has_client_keytab) {
696+
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, req,
697+
OPTION_WARNING, "GssapiUseS4U2Proxy",
698+
"GssapiCredStore", "client_keytab");
699+
}
700+
if (!has_ccache) {
701+
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, req,
702+
OPTION_WARNING, "GssapiUseS4U2Proxy",
703+
"GssapiCredStore", "ccache");
704+
}
705+
}
706+
707+
cfg->verified = true;
708+
}
709+
662710
struct mag_req_cfg *mag_init_cfg(request_rec *req)
663711
{
664712
struct mag_server_config *scfg;
@@ -667,6 +715,7 @@ struct mag_req_cfg *mag_init_cfg(request_rec *req)
667715
req_cfg->req = req;
668716
req_cfg->cfg = ap_get_module_config(req->per_dir_config,
669717
&auth_gssapi_module);
718+
mag_verify_config(req, req_cfg->cfg);
670719

671720
scfg = ap_get_module_config(req->server->module_config,
672721
&auth_gssapi_module);

src/mod_auth_gssapi.h

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ struct mag_config {
9999
gss_name_t acceptor_name;
100100
bool acceptor_name_from_req;
101101
uint32_t basic_timeout;
102+
103+
bool verified;
102104
};
103105

104106
struct mag_server_config {

0 commit comments

Comments
 (0)