|
|
d738b9 |
From 7c50ae9787c2fbfb479fbc513a2aeb2aff039d43 Mon Sep 17 00:00:00 2001
|
|
|
d738b9 |
From: Greg Hudson <ghudson@mit.edu>
|
|
|
d738b9 |
Date: Wed, 1 Aug 2018 15:53:12 -0400
|
|
|
d738b9 |
Subject: [PATCH] Don't include all MEMORY ccaches in collection
|
|
|
d738b9 |
|
|
|
d738b9 |
In the MEMORY ccache implementation, only yield a cache in the
|
|
|
d738b9 |
per-type cursor if it is the context default cache, matching the
|
|
|
d738b9 |
behavior of FILE after commit 45360c9688ca963f75a2480f2cf818424fc3dc7b
|
|
|
d738b9 |
(ticket 6955).
|
|
|
d738b9 |
|
|
|
d738b9 |
ticket: 8720 (new)
|
|
|
d738b9 |
(cherry picked from commit 49bb627fed70c5258c151c5135ac3d95ed1ee55d)
|
|
|
d738b9 |
---
|
|
|
d738b9 |
src/lib/krb5/ccache/cc_memory.c | 25 ++++++++++---------------
|
|
|
d738b9 |
src/lib/krb5/ccache/t_cccol.py | 7 ++++---
|
|
|
d738b9 |
2 files changed, 14 insertions(+), 18 deletions(-)
|
|
|
d738b9 |
|
|
|
d738b9 |
diff --git a/src/lib/krb5/ccache/cc_memory.c b/src/lib/krb5/ccache/cc_memory.c
|
|
|
d738b9 |
index 8cdaff7fb..cfd5c6389 100644
|
|
|
d738b9 |
--- a/src/lib/krb5/ccache/cc_memory.c
|
|
|
d738b9 |
+++ b/src/lib/krb5/ccache/cc_memory.c
|
|
|
d738b9 |
@@ -132,7 +132,7 @@ struct mcc_cursor {
|
|
|
d738b9 |
|
|
|
d738b9 |
/* Iterator over memory caches. */
|
|
|
d738b9 |
struct krb5_mcc_ptcursor_data {
|
|
|
d738b9 |
- struct krb5_mcc_list_node *cur;
|
|
|
d738b9 |
+ krb5_boolean first;
|
|
|
d738b9 |
};
|
|
|
d738b9 |
|
|
|
d738b9 |
k5_cc_mutex krb5int_mcc_mutex = K5_CC_MUTEX_PARTIAL_INITIALIZER;
|
|
|
d738b9 |
@@ -693,9 +693,7 @@ krb5_mcc_ptcursor_new(
|
|
|
d738b9 |
return ENOMEM;
|
|
|
d738b9 |
}
|
|
|
d738b9 |
n->data = cdata;
|
|
|
d738b9 |
- k5_cc_mutex_lock(context, &krb5int_mcc_mutex);
|
|
|
d738b9 |
- cdata->cur = mcc_head;
|
|
|
d738b9 |
- k5_cc_mutex_unlock(context, &krb5int_mcc_mutex);
|
|
|
d738b9 |
+ cdata->first = TRUE;
|
|
|
d738b9 |
*cursor = n;
|
|
|
d738b9 |
return 0;
|
|
|
d738b9 |
}
|
|
|
d738b9 |
@@ -707,22 +705,19 @@ krb5_mcc_ptcursor_next(
|
|
|
d738b9 |
krb5_ccache *ccache)
|
|
|
d738b9 |
{
|
|
|
d738b9 |
struct krb5_mcc_ptcursor_data *cdata = NULL;
|
|
|
d738b9 |
+ const char *defname;
|
|
|
d738b9 |
|
|
|
d738b9 |
*ccache = NULL;
|
|
|
d738b9 |
cdata = cursor->data;
|
|
|
d738b9 |
- if (cdata->cur == NULL)
|
|
|
d738b9 |
+ if (!cdata->first)
|
|
|
d738b9 |
+ return 0;
|
|
|
d738b9 |
+ cdata->first = FALSE;
|
|
|
d738b9 |
+
|
|
|
d738b9 |
+ defname = krb5_cc_default_name(context);
|
|
|
d738b9 |
+ if (defname == NULL || strncmp(defname, "MEMORY:", 7) != 0)
|
|
|
d738b9 |
return 0;
|
|
|
d738b9 |
|
|
|
d738b9 |
- *ccache = malloc(sizeof(**ccache));
|
|
|
d738b9 |
- if (*ccache == NULL)
|
|
|
d738b9 |
- return ENOMEM;
|
|
|
d738b9 |
-
|
|
|
d738b9 |
- (*ccache)->ops = &krb5_mcc_ops;
|
|
|
d738b9 |
- (*ccache)->data = cdata->cur->cache;
|
|
|
d738b9 |
- k5_cc_mutex_lock(context, &krb5int_mcc_mutex);
|
|
|
d738b9 |
- cdata->cur = cdata->cur->next;
|
|
|
d738b9 |
- k5_cc_mutex_unlock(context, &krb5int_mcc_mutex);
|
|
|
d738b9 |
- return 0;
|
|
|
d738b9 |
+ return krb5_cc_resolve(context, defname, ccache);
|
|
|
d738b9 |
}
|
|
|
d738b9 |
|
|
|
d738b9 |
static krb5_error_code KRB5_CALLCONV
|
|
|
d738b9 |
diff --git a/src/lib/krb5/ccache/t_cccol.py b/src/lib/krb5/ccache/t_cccol.py
|
|
|
d738b9 |
index f7f178564..c6d5f514d 100755
|
|
|
d738b9 |
--- a/src/lib/krb5/ccache/t_cccol.py
|
|
|
d738b9 |
+++ b/src/lib/krb5/ccache/t_cccol.py
|
|
|
d738b9 |
@@ -97,10 +97,11 @@ if test_keyring:
|
|
|
d738b9 |
|
|
|
d738b9 |
mfoo = 'MEMORY:foo'
|
|
|
d738b9 |
mbar = 'MEMORY:bar'
|
|
|
d738b9 |
-cursor_test('filemem', [fccname, mfoo, mbar], [fccname, mfoo, mbar])
|
|
|
d738b9 |
-cursor_test('dirmem', [dccname, mfoo], [duser, dalice, dbob, mfoo])
|
|
|
d738b9 |
+cursor_test('filemem', [fccname, mfoo], [fccname])
|
|
|
d738b9 |
+cursor_test('dirmem', [dccname, mfoo], [duser, dalice, dbob])
|
|
|
d738b9 |
+cursor_test('mem', [mfoo, mbar], [mfoo])
|
|
|
d738b9 |
if test_keyring:
|
|
|
d738b9 |
- cursor_test('keyringmem', [krccname, mfoo], [kruser, kralice, krbob, mfoo])
|
|
|
d738b9 |
+ cursor_test('keyringmem', [krccname, mfoo], [kruser, kralice, krbob])
|
|
|
d738b9 |
|
|
|
d738b9 |
# Test krb5_cccol_have_content.
|
|
|
d738b9 |
realm.run(['./t_cccursor', dccname, 'CONTENT'])
|