Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-distro / recipes-security / gssproxy / files / Only-empty-FILE-ccaches-when-storing-remote-creds.patch
1 From 1fa33903be640f8d22757d21da294e70f0812698 Mon Sep 17 00:00:00 2001
2 From: Robbie Harwood <rharwood@redhat.com>
3 Date: Tue, 10 Oct 2017 18:00:45 -0400
4 Subject: [PATCH] Only empty FILE ccaches when storing remote creds
5
6 This mitigates issues when services share a ccache between two
7 processes.  We cannot fix this for FILE ccaches without introducing
8 other issues.
9
10 Signed-off-by: Robbie Harwood <rharwood@redhat.com>
11 Reviewed-by: Simo Sorce <simo@redhat.com>
12 Merges: #216
13 (cherry picked from commit d09e87f47a21dd250bfd7a9c59a5932b5c995057)
14 ---
15  proxy/src/mechglue/gpp_creds.c | 18 +++++++++++++-----
16  1 file changed, 13 insertions(+), 5 deletions(-)
17
18 diff --git a/proxy/src/mechglue/gpp_creds.c b/proxy/src/mechglue/gpp_creds.c
19 index 9fe9bd1..6bdff45 100644
20 --- a/proxy/src/mechglue/gpp_creds.c
21 +++ b/proxy/src/mechglue/gpp_creds.c
22 @@ -147,6 +147,7 @@ uint32_t gpp_store_remote_creds(uint32_t *min, bool default_creds,
23      char cred_name[creds->desired_name.display_name.octet_string_len + 1];
24      XDR xdrctx;
25      bool xdrok;
26 +    const char *cc_type;
27  
28      *min = 0;
29  
30 @@ -193,13 +194,20 @@ uint32_t gpp_store_remote_creds(uint32_t *min, bool default_creds,
31      }
32      cred.ticket.length = xdr_getpos(&xdrctx);
33  
34 -    /* Always initialize and destroy any existing contents to avoid pileup of
35 -     * entries */
36 -    ret = krb5_cc_initialize(ctx, ccache, cred.client);
37 -    if (ret == 0) {
38 -        ret = krb5_cc_store_cred(ctx, ccache, &cred);
39 +    cc_type = krb5_cc_get_type(ctx, ccache);
40 +    if (strcmp(cc_type, "FILE") == 0) {
41 +        /* FILE ccaches don't handle updates properly: if they have the same
42 +         * principal name, they are blackholed.  We either have to change the
43 +         * name (at which point the file grows forever) or flash the cache on
44 +         * every update. */
45 +        ret = krb5_cc_initialize(ctx, ccache, cred.client);
46 +        if (ret != 0) {
47 +            goto done;
48 +        }
49      }
50  
51 +    ret = krb5_cc_store_cred(ctx, ccache, &cred);
52 +
53  done:
54      if (ctx) {
55          krb5_free_cred_contents(ctx, &cred);