summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2012-10-24 12:06:01 -0400
committerGreg Hudson <ghudson@mit.edu>2012-10-24 12:06:01 -0400
commitec6dc0e991b3653e16a637bfaa0daf783f82af31 (patch)
treea7bc34a971b2c57cca2f69084487f1270b807e74 /src
parent8444f28163fcfe47ccb9808458f951af10417277 (diff)
downloadkrb5-ec6dc0e991b3653e16a637bfaa0daf783f82af31.tar.gz
krb5-ec6dc0e991b3653e16a637bfaa0daf783f82af31.tar.xz
krb5-ec6dc0e991b3653e16a637bfaa0daf783f82af31.zip
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. ticket: 7427 (new) target_version: 1.11 tags: pullup
Diffstat (limited to 'src')
-rw-r--r--src/include/k5-json.h2
-rw-r--r--src/lib/krb5/krb/get_in_tkt.c3
-rw-r--r--src/util/support/json.c6
-rw-r--r--src/util/support/libkrb5support-fixed.exports1
4 files changed, 11 insertions, 1 deletions
diff --git a/src/include/k5-json.h b/src/include/k5-json.h
index fb9a3afe6c..42dcfa3d38 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 c2cd9e8837..c20d4b73b5 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 e6d7eea269..f02fe263df 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 13b1b575e9..0579611fda 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