Unverified Commit 30bae689 authored by Ph. Gesang's avatar Ph. Gesang 💾
Browse files

lib/audit_logging: s3: net: make use of json_loadfd depend on jansson version



Jansson added json_loadfd() with version 2.10. Replaying the
machine account credentials using ``net ads dumpcreds --undump``
depends on this API for processing stdin. Make all uses of it
conditional to avoid breaking the build on systems with older
versions of jansson.
Signed-off-by: Ph. Gesang's avatarPhilipp Gesang <philipp.gesang@intra2net.com>
parent 5a928465
......@@ -1271,6 +1271,7 @@ struct json_object json_get_object(struct json_object *object, const char *name)
return o;
}
#ifdef HAVE_RECENT_JANSSON
/*
* @brief Decode data reading from file descriptor.
*
......@@ -1326,6 +1327,7 @@ int json_from_fd(struct json_object *dst, int jsfd)
return 0;
}
#endif /* [HAVE_RECENT_JANSSON] */
/*
* @brief Get a SID from a JSON object.
......
......@@ -110,7 +110,9 @@ _WARN_UNUSED_RESULT_ struct json_object json_get_object(
_WARN_UNUSED_RESULT_ char *json_to_string(TALLOC_CTX *mem_ctx,
const struct json_object *object);
#ifdef HAVE_RECENT_JANSSON
_WARN_UNUSED_RESULT_ int json_from_fd(struct json_object *dst, int jsfd);
#endif /* [HAVE_RECENT_JANSSON] */
_WARN_UNUSED_RESULT_ int json_from_string (struct json_object *dst,
const char *jsdata);
#endif
......
......@@ -814,6 +814,7 @@ static void test_json_from_string(void **state)
json_free(&object);
}
#ifdef HAVE_RECENT_JANSSON
/*
* Note on below test: we use posix shm here because of its availability
* on older kernels; memfd_create(2) would be even simpler to use but it
......@@ -850,6 +851,7 @@ static void test_json_from_fd(void **state)
json_free(&object);
}
#endif /* [HAVE_RECENT_JANSSON] */
static void test_json_get_array(void **state)
{
......@@ -1068,7 +1070,9 @@ int main(int argc, const char **argv)
cmocka_unit_test(test_json_get_base64),
cmocka_unit_test(test_json_to_string),
cmocka_unit_test(test_json_from_string),
#ifdef HAVE_RECENT_JANSSON
cmocka_unit_test(test_json_from_fd),
#endif /* [HAVE_RECENT_JANSSON] */
cmocka_unit_test(test_json_get_array),
cmocka_unit_test(test_json_get_object),
#ifdef HAVE_ADS
......
......@@ -1470,6 +1470,7 @@ int net_ads_testjoin(struct net_context *c, int argc, const char **argv)
return 0;
}
#ifdef HAVE_RECENT_JANSSON
static int net_ads_dumpcreds_un(struct net_context *c,
TALLOC_CTX *ctx,
ADS_STRUCT *ads)
......@@ -1562,6 +1563,17 @@ failure:
json_free (&jsobj);
return ret;
}
#else /* [HAVE_RECENT_JANSSON] */
static int net_ads_dumpcreds_un(struct net_context *_c,
TALLOC_CTX *_ctx,
ADS_STRUCT *_ads)
{
d_fprintf (stderr,
_("--undump not available due to outdated libjansson\n"));
return -1;
}
#endif /* [HAVE_RECENT_JANSSON] */
static int net_ads_dumpcreds_json (TALLOC_CTX *ctx,
const char *samname,
......
......@@ -282,6 +282,10 @@ def configure(conf):
if conf.CHECK_CFG(package='jansson', args='--cflags --libs',
msg='Checking for jansson'):
conf.CHECK_FUNCS_IN('json_object', 'jansson')
# jansson 2.10 added json_loadfd()
if tuple (map (int, conf.check_cfg(modversion='jansson').split ("."))) \
>= (2, 10):
conf.define('HAVE_RECENT_JANSSON', '1')
if not conf.CONFIG_GET('HAVE_JSON_OBJECT'):
if Options.options.with_json != False:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment