]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Don't save empty cc_config_out in ccache
authorGreg Hudson <ghudson@mit.edu>
Wed, 24 Oct 2012 16:06:01 +0000 (12:06 -0400)
committerTom Yu <tlyu@mit.edu>
Tue, 30 Oct 2012 17:23:17 +0000 (13:23 -0400)
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
src/lib/krb5/krb/get_in_tkt.c
src/util/support/json.c
src/util/support/libkrb5support-fixed.exports

index fb9a3afe6c0b6bec6ef84a605accadd28b1228e4..42dcfa3d38565388d579f618a9b7cc614ddc843a 100644 (file)
@@ -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);
index c2cd9e883726eb2c534d2b49088be8cac3c52b5e..c20d4b73b560a85efefb79e4e27b58e7a22c8b76 100644 (file)
@@ -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)
index e6d7eea2699b2fc803c46db479c9dbcffaad6ef9..f02fe263df6c1cdbc59b507e60aef8528a765b3b 100644 (file)
@@ -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)
index 13b1b575e9eb8ac004a4ff5a3ab1318fa1a6545e..0579611fdab88a6b428db12192292b9d6c424c30 100644 (file)
@@ -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