krb5 commit [krb5-1.11]: Don't save empty cc_config_out in ccache
Tom Yu
tlyu at MIT.EDU
Tue Oct 30 14:02:19 EDT 2012
https://github.com/krb5/krb5/commit/38cfcb9d83112b0212e8a920bacc19a628fa4ce3
commit 38cfcb9d83112b0212e8a920bacc19a628fa4ce3
Author: Greg Hudson <ghudson at mit.edu>
Date: Wed Oct 24 12:06:01 2012 -0400
Don't save empty cc_config_out in ccache
Add an internal json function to make it easier to detect if an object
is empty, and use it to avoid creating a ccache config entry for
preauth module config data if there isn't any to save.
(cherry picked from commit ec6dc0e991b3653e16a637bfaa0daf783f82af31)
ticket: 7427
version_fixed: 1.11
status: resolved
src/include/k5-json.h | 2 ++
src/lib/krb5/krb/get_in_tkt.c | 3 ++-
src/util/support/json.c | 6 ++++++
src/util/support/libkrb5support-fixed.exports | 1 +
4 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/src/include/k5-json.h b/src/include/k5-json.h
index fb9a3af..42dcfa3 100644
--- a/src/include/k5-json.h
+++ b/src/include/k5-json.h
@@ -148,6 +148,8 @@ k5_json_object k5_json_object_create(void);
void k5_json_object_iterate(k5_json_object obj,
k5_json_object_iterator_fn func, void *arg);
+/* Return the number of mappings in an object. */
+size_t k5_json_object_count(k5_json_object obj);
/* Store val into object at key, incrementing val's reference count. */
int k5_json_object_set(k5_json_object obj, const char *key, k5_json_value val);
diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c
index c2cd9e8..c20d4b7 100644
--- a/src/lib/krb5/krb/get_in_tkt.c
+++ b/src/lib/krb5/krb/get_in_tkt.c
@@ -1198,7 +1198,8 @@ save_cc_config_out_data(krb5_context context, krb5_ccache ccache,
char *encoded;
krb5_error_code code;
- if (ctx->cc_config_out == NULL)
+ if (ctx->cc_config_out == NULL ||
+ k5_json_object_count(ctx->cc_config_out) == 0)
return 0;
encoded = k5_json_encode(ctx->cc_config_out);
if (encoded == NULL)
diff --git a/src/util/support/json.c b/src/util/support/json.c
index e6d7eea..f02fe26 100644
--- a/src/util/support/json.c
+++ b/src/util/support/json.c
@@ -295,6 +295,12 @@ k5_json_object_create(void)
return alloc_value(&object_type, sizeof(struct k5_json_object_st));
}
+size_t
+k5_json_object_count(k5_json_object obj)
+{
+ return obj->len;
+}
+
/* Return the entry for key within obj, or NULL if none exists. */
static struct entry *
object_search(k5_json_object obj, const char *key)
diff --git a/src/util/support/libkrb5support-fixed.exports b/src/util/support/libkrb5support-fixed.exports
index 13b1b57..0579611 100644
--- a/src/util/support/libkrb5support-fixed.exports
+++ b/src/util/support/libkrb5support-fixed.exports
@@ -11,6 +11,7 @@ k5_json_get_tid
k5_json_null_create
k5_json_number_create
k5_json_number_value
+k5_json_object_count
k5_json_object_create
k5_json_object_get
k5_json_object_iterate
More information about the cvs-krb5
mailing list