Skip to content

Commit 867c294

Browse files
simo5frozencemetery
authored andcommitted
Properly renew expired credentials
When a caller imports expired credentials, we aim to actually renew them if we can. However due to incorrect checks and not clearing of the ret_maj variable after checks we end up returning an error instead. Also fix mechglue to also save and properly report the first call errors when both remote and local fail. Resolves: #170 Signed-off-by: Simo Sorce <[email protected]> Reviewed-by: Robbie Harwood <[email protected]>
1 parent b737477 commit 867c294

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/gp_creds.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,12 @@ uint32_t gp_add_krb5_creds(uint32_t *min,
629629
ret_maj = gp_check_cred(&ret_min, in_cred, desired_name, cred_usage);
630630
if (ret_maj == GSS_S_COMPLETE) {
631631
return GSS_S_COMPLETE;
632-
} else if (ret_maj != GSS_S_CREDENTIALS_EXPIRED &&
633-
ret_maj != GSS_S_NO_CRED) {
632+
} else if (ret_maj == GSS_S_CREDENTIALS_EXPIRED ||
633+
ret_maj == GSS_S_NO_CRED) {
634+
/* continue and try to obtain new creds */
635+
ret_maj = 0;
636+
ret_min = 0;
637+
} else {
634638
*min = ret_min;
635639
return GSS_S_CRED_UNAVAIL;
636640
}
@@ -639,14 +643,14 @@ uint32_t gp_add_krb5_creds(uint32_t *min,
639643
if (acquire_type == ACQ_NORMAL) {
640644
ret_min = gp_get_cred_environment(gpcall, desired_name, &req_name,
641645
&cred_usage, &cred_store);
646+
if (ret_min) {
647+
ret_maj = GSS_S_CRED_UNAVAIL;
648+
}
642649
} else if (desired_name) {
643650
ret_maj = gp_conv_gssx_to_name(&ret_min, desired_name, &req_name);
644651
}
645652
if (ret_maj) {
646653
goto done;
647-
} else if (ret_min) {
648-
ret_maj = GSS_S_CRED_UNAVAIL;
649-
goto done;
650654
}
651655

652656
if (!try_impersonate(gpcall->service, cred_usage, acquire_type)) {

src/mechglue/gpp_acquire_cred.c

+5
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ OM_uint32 gssi_acquire_cred_from(OM_uint32 *minor_status,
186186
}
187187

188188
if (behavior == GPP_REMOTE_FIRST) {
189+
if (maj != GSS_S_COMPLETE) {
190+
/* save errors */
191+
tmaj = maj;
192+
tmin = min;
193+
}
189194
/* So remote failed, but we can fallback to local, try that */
190195
maj = acquire_local(&min, NULL, name,
191196
time_req, desired_mechs, cred_usage, cred_store,

0 commit comments

Comments
 (0)