Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kcm: replace old credentials when storing a new one #5775

Closed
pbrezina opened this issue Sep 7, 2021 · 2 comments
Closed

kcm: replace old credentials when storing a new one #5775

pbrezina opened this issue Sep 7, 2021 · 2 comments
Assignees
Labels
Closed: Fixed Issue was closed as fixed. KCM

Comments

@pbrezina
Copy link
Member

pbrezina commented Sep 7, 2021

Currently, when KCM stores a new credential it just blindly appends it to the existing credential cache. This make the ccache grow overtime when it stores a credential that already is in the ccache - such as refresh_time control credential which is stored when GSSAPI tries to refresh a particular ticket.

Instead of appending, we should replace the old credential. Even though we have improved KCM performance dramatically, this will help further as the ccache will stay as small as needed.

@pbrezina pbrezina added the KCM label Sep 7, 2021
@pbrezina pbrezina self-assigned this Sep 7, 2021
pbrezina added a commit to pbrezina/sssd that referenced this issue Sep 7, 2021
Currently, we just append input credential to the ccache. This however
make the ccache grow over time as credentials expires and more control
credentials are stored.

Now we remove or credentials that are the same and overwrite them with
the input credential.

Resolves:
SSSD#5775
@pbrezina
Copy link
Member Author

pbrezina commented Sep 7, 2021

You can use this code to test. Each call will add a new test control credential.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <krb5.h>

int main(int argc, const char **argv)
{
    krb5_data data = {0, strlen("hello"), strdup("hello")};
    krb5_context context;
    krb5_error_code ret;
    krb5_ccache cc;

    ret = krb5_init_context(&context);
    if (ret != 0) {
        printf("krb5_init_context Error %d\n", ret);
        return 1;
    }

    ret = krb5_cc_default(context, &cc);
    if (ret != 0) {
        printf("krb5_cc_default Error %d\n", ret);
        return 1;
    }

    ret = krb5_cc_set_config(context, cc, NULL, "test", &data);
    if (ret != 0) {
        printf("krb5_cc_set_config Error %d\n", ret);
        return 1;
    }

    return 0;
}
$ gcc -ggdb3 -o main src/main.c -lkrb5

pbrezina added a commit to pbrezina/sssd that referenced this issue Sep 7, 2021
Currently, we just append input credential to the ccache. This however
make the ccache grow over time as credentials expires and more control
credentials are stored.

Now we remove or credentials that are the same and overwrite them with
the input credential.

Resolves: SSSD#5775

:fixes: KCM now replace the old credential with new one when storing
  an update credential that is however already present in the ccache
  to avoid unnecessary grow of the ccache.
pbrezina added a commit to pbrezina/sssd that referenced this issue Sep 7, 2021
Currently, we just append input credential to the ccache. This however
make the ccache grow over time as credentials expires and more control
credentials are stored.

Now we remove or credentials that are the same and overwrite them with
the input credential.

Resolves: SSSD#5775

:fixes: KCM now replace the old credential with new one when storing
  an update credential that is however already present in the ccache
  to avoid unnecessary growth of the ccache.
pbrezina added a commit to pbrezina/sssd that referenced this issue Sep 7, 2021
Currently, we just append input credential to the ccache. This however
make the ccache grow over time as credentials expires and more control
credentials are stored.

Now we remove or credentials that are the same and overwrite them with
the input credential.

Resolves: SSSD#5775

:fixes: KCM now replace the old credential with new one when storing
  an update credential that is however already present in the ccache
  to avoid unnecessary growth of the ccache.
pbrezina added a commit to pbrezina/sssd that referenced this issue Sep 13, 2021
Currently, we just append input credential to the ccache. This however
make the ccache grow over time as credentials expires and more control
credentials are stored.

Now we remove or credentials that are the same and overwrite them with
the input credential.

Resolves: SSSD#5775

:fixes: KCM now replace the old credential with new one when storing
  an update credential that is however already present in the ccache
  to avoid unnecessary growth of the ccache.
@pbrezina
Copy link
Member Author

pbrezina commented Oct 5, 2021

Pushed PR: #5776

  • master
    • 55c5de2 - kcm: replace existing credentials to avoid unnecessary ccache growth
    • aca2e08 - krb5: remove unused mem_ctx from get_krb5_data_from_cred()

@pbrezina pbrezina added the Closed: Fixed Issue was closed as fixed. label Oct 5, 2021
shridhargadekar pushed a commit to shridhargadekar/sssd that referenced this issue Apr 1, 2022
Currently, we just append input credential to the ccache. This however
make the ccache grow over time as credentials expires and more control
credentials are stored.

Now we remove or credentials that are the same and overwrite them with
the input credential.

Resolves: SSSD#5775

:fixes: KCM now replace the old credential with new one when storing
  an update credential that is however already present in the ccache
  to avoid unnecessary growth of the ccache.

Reviewed-by: Justin Stephenson <jstephen@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed: Fixed Issue was closed as fixed. KCM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant