Skip to content

Commit 6e4513d

Browse files
committed
Better handling of desired_mechs
If no explicit allowed mechanism is set in configuration just ask GSSAPI for a list of known mechanisms and use that. Do not try to artificially acquire credentials as ultimatily all that does is just call gss_inidicate_mechs() internally. Do not store the result of gss_inidicate_mechs() on cfg->allowed_mechs as that would lead to a leak given that cfg->allowed_mechs is allocated on a memory pool, while gss_inidate_mechs()s results are not. Closes #44 Signed-off-by: Simo Sorce <simo@redhat.com>
1 parent d0732a6 commit 6e4513d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/mod_auth_gssapi.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ static int mag_auth(request_rec *req)
514514
char *clientname;
515515
gss_OID mech_type = GSS_C_NO_OID;
516516
gss_OID_set desired_mechs = GSS_C_NO_OID_SET;
517+
gss_OID_set indicated_mechs = GSS_C_NO_OID_SET;
517518
gss_buffer_desc lname = GSS_C_EMPTY_BUFFER;
518519
struct mag_conn *mc = NULL;
519520
time_t expiration;
@@ -526,16 +527,19 @@ static int mag_auth(request_rec *req)
526527

527528
cfg = ap_get_module_config(req->per_dir_config, &auth_gssapi_module);
528529

529-
if (!cfg->allowed_mechs) {
530+
if (cfg->allowed_mechs) {
531+
desired_mechs = cfg->allowed_mechs;
532+
} else {
530533
/* Try to fetch the default set if not explicitly configured */
531-
gss_cred_id_t server_cred = GSS_C_NO_CREDENTIAL;
532-
(void)mag_acquire_creds(req, cfg, GSS_C_NO_OID_SET, GSS_C_ACCEPT,
533-
&server_cred, &cfg->allowed_mechs);
534-
(void)gss_release_cred(&min, &server_cred);
534+
maj = gss_indicate_mechs(&min, &indicated_mechs);
535+
if (maj != GSS_S_COMPLETE) {
536+
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, req, "%s",
537+
mag_error(req, "gss_indicate_mechs() failed",
538+
maj, min));
539+
}
540+
desired_mechs = indicated_mechs;
535541
}
536542

537-
desired_mechs = cfg->allowed_mechs;
538-
539543
/* implicit auth for subrequests if main auth already happened */
540544
if (!ap_is_initial_req(req) && req->main != NULL) {
541545
type = ap_auth_type(req->main);
@@ -827,6 +831,7 @@ static int mag_auth(request_rec *req)
827831
ap_auth_name(req)));
828832
}
829833
}
834+
gss_release_oid_set(&min, &indicated_mechs);
830835
if (ctx != GSS_C_NO_CONTEXT)
831836
gss_delete_sec_context(&min, &ctx, GSS_C_NO_BUFFER);
832837
gss_release_cred(&min, &acquired_cred);

0 commit comments

Comments
 (0)