Skip to content

Commit d6d8a6b

Browse files
iboukrissimo5
authored andcommitted
Fail server startup on bad mechanisms
This helps to detect mis-configurations early. Configuration errors are considered fatal in apache anyway. Reviewed-by: Simo Sorce <[email protected]>
1 parent 7963859 commit d6d8a6b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/mod_auth_gssapi.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ static apr_status_t mag_oid_set_destroy(void *ptr)
11521152
return APR_SUCCESS;
11531153
}
11541154

1155-
static void mag_list_of_mechs(cmd_parms *parms, gss_OID_set *oidset,
1155+
static bool mag_list_of_mechs(cmd_parms *parms, gss_OID_set *oidset,
11561156
bool add_spnego, const char *w)
11571157
{
11581158
gss_buffer_desc buf = { 0 };
@@ -1167,7 +1167,7 @@ static void mag_list_of_mechs(cmd_parms *parms, gss_OID_set *oidset,
11671167
ap_log_error(APLOG_MARK, APLOG_ERR, 0, parms->server,
11681168
"gss_create_empty_oid_set() failed.");
11691169
*oidset = GSS_C_NO_OID_SET;
1170-
return;
1170+
return false;
11711171
}
11721172
if (add_spnego) {
11731173
oid = discard_const(&gss_mech_spnego);
@@ -1177,7 +1177,7 @@ static void mag_list_of_mechs(cmd_parms *parms, gss_OID_set *oidset,
11771177
"gss_add_oid_set_member() failed.");
11781178
(void)gss_release_oid_set(&min, &set);
11791179
*oidset = GSS_C_NO_OID_SET;
1180-
return;
1180+
return false;
11811181
}
11821182
}
11831183
/* register in the pool so it can be released once the server
@@ -1203,7 +1203,7 @@ static void mag_list_of_mechs(cmd_parms *parms, gss_OID_set *oidset,
12031203
if (maj != GSS_S_COMPLETE) {
12041204
ap_log_error(APLOG_MARK, APLOG_ERR, 0, parms->server,
12051205
"Unrecognized GSSAPI Mechanism: [%s]", w);
1206-
return;
1206+
return false;
12071207
}
12081208
release_oid = true;
12091209
}
@@ -1215,14 +1215,17 @@ static void mag_list_of_mechs(cmd_parms *parms, gss_OID_set *oidset,
12151215
if (release_oid) {
12161216
(void)gss_release_oid(&min, &oid);
12171217
}
1218+
1219+
return true;
12181220
}
12191221

12201222
static const char *mag_allow_mech(cmd_parms *parms, void *mconfig,
12211223
const char *w)
12221224
{
12231225
struct mag_config *cfg = (struct mag_config *)mconfig;
12241226

1225-
mag_list_of_mechs(parms, &cfg->allowed_mechs, true, w);
1227+
if (!mag_list_of_mechs(parms, &cfg->allowed_mechs, true, w))
1228+
return "Failed to apply GssapiAllowedMech directive";
12261229

12271230
return NULL;
12281231
}
@@ -1233,7 +1236,8 @@ static const char *mag_basic_auth_mechs(cmd_parms *parms, void *mconfig,
12331236
{
12341237
struct mag_config *cfg = (struct mag_config *)mconfig;
12351238

1236-
mag_list_of_mechs(parms, &cfg->basic_mechs, false, w);
1239+
if (!mag_list_of_mechs(parms, &cfg->basic_mechs, false, w))
1240+
return "Failed to apply GssapiBasicAuthMech directive";
12371241

12381242
return NULL;
12391243
}

0 commit comments

Comments
 (0)