]> git.ipfire.org Git - pakfire.git/commitdiff
daemon: Remove any previous credentials
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 26 Mar 2025 16:49:01 +0000 (16:49 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 26 Mar 2025 16:49:01 +0000 (16:49 +0000)
Otherwise krb5 will append all credentials, but Heimdal only seems to
read the first (eventually) expired ticket.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/daemon.c

index 3e76ad1f0125e1b5e809cc1b692a3db552ba80cb..4d10005caf6a909266b939b92c8cafd810ac6f68 100644 (file)
@@ -1009,6 +1009,15 @@ static int pakfire_daemon_auth(sd_event_source* s, uint64_t usec, void* data) {
        DEBUG(daemon->ctx, "Successfully fetched credentials\n");
        DEBUG(daemon->ctx, "  Expires: %s\n", time);
 
+       // Remove any previous credentials
+       r = krb5_cc_remove_cred(daemon->krb5.ctx, daemon->krb5.ccache, 0, &creds);
+       if (r) {
+               error = krb5_get_error_message(daemon->krb5.ctx, r);
+
+               ERROR(daemon->ctx, "Failed to remove credentials: %s\n", error);
+               goto ERROR;
+       }
+
        // Store the credentials in the cache
        r = krb5_cc_store_cred(daemon->krb5.ctx, daemon->krb5.ccache, &creds);
        if (r) {