Use json functions from libsudo_util in cvtsudoers.
This commit is contained in:
@@ -68,3 +68,6 @@ __dso_public bool sudo_json_close_array_v1(struct json_container *json);
|
||||
|
||||
__dso_public bool sudo_json_add_value_v1(struct json_container *json, const char *name, struct json_value *value);
|
||||
#define sudo_json_add_value(_a, _b, _c) sudo_json_add_value_v1((_a), (_b), (_c))
|
||||
|
||||
__dso_public bool sudo_json_add_value_as_object_v1(struct json_container *json, const char *name, struct json_value *value);
|
||||
#define sudo_json_add_value_as_object(_a, _b, _c) sudo_json_add_value_as_object_v1((_a), (_b), (_c))
|
||||
|
@@ -125,9 +125,11 @@ sudo_json_open_object_v1(struct json_container *json, const char *name)
|
||||
|
||||
print_indent(json->fp, json->indent_level);
|
||||
|
||||
if (name != NULL) {
|
||||
json_print_string(json, name);
|
||||
putc(':', json->fp);
|
||||
putc(' ', json->fp);
|
||||
}
|
||||
putc('{', json->fp);
|
||||
|
||||
json->indent_level += json->indent_increment;
|
||||
@@ -186,8 +188,8 @@ sudo_json_close_array_v1(struct json_container *json)
|
||||
}
|
||||
|
||||
bool
|
||||
sudo_json_add_value_v1(struct json_container *json, const char *name,
|
||||
struct json_value *value)
|
||||
sudo_json_add_value_int(struct json_container *json, const char *name,
|
||||
struct json_value *value, bool as_object)
|
||||
{
|
||||
unsigned int i;
|
||||
debug_decl(sudo_json_add_value, SUDO_DEBUG_UTIL);
|
||||
@@ -200,10 +202,17 @@ sudo_json_add_value_v1(struct json_container *json, const char *name,
|
||||
|
||||
print_indent(json->fp, json->indent_level);
|
||||
|
||||
if (as_object) {
|
||||
putc('{', json->fp);
|
||||
putc(' ', json->fp);
|
||||
}
|
||||
|
||||
/* name */
|
||||
if (name != NULL) {
|
||||
json_print_string(json, name);
|
||||
putc(':', json->fp);
|
||||
putc(' ', json->fp);
|
||||
}
|
||||
|
||||
/* value */
|
||||
switch (value->type) {
|
||||
@@ -254,5 +263,24 @@ sudo_json_add_value_v1(struct json_container *json, const char *name,
|
||||
break;
|
||||
}
|
||||
|
||||
if (as_object) {
|
||||
putc(' ', json->fp);
|
||||
putc('}', json->fp);
|
||||
}
|
||||
|
||||
debug_return_bool(true);
|
||||
}
|
||||
|
||||
bool
|
||||
sudo_json_add_value_v1(struct json_container *json, const char *name,
|
||||
struct json_value *value)
|
||||
{
|
||||
return sudo_json_add_value_int(json, name, value, false);
|
||||
}
|
||||
|
||||
bool
|
||||
sudo_json_add_value_as_object_v1(struct json_container *json, const char *name,
|
||||
struct json_value *value)
|
||||
{
|
||||
return sudo_json_add_value_int(json, name, value, true);
|
||||
}
|
||||
|
@@ -3,8 +3,8 @@ sudo_conf_askpass_path_v1
|
||||
sudo_conf_clear_paths_v1
|
||||
sudo_conf_debug_files_v1
|
||||
sudo_conf_debugging_v1
|
||||
sudo_conf_devsearch_path_v1
|
||||
sudo_conf_developer_mode_v1
|
||||
sudo_conf_devsearch_path_v1
|
||||
sudo_conf_disable_coredump_v1
|
||||
sudo_conf_group_source_v1
|
||||
sudo_conf_max_groups_v1
|
||||
@@ -32,12 +32,12 @@ sudo_debug_fork_v1
|
||||
sudo_debug_get_active_instance_v1
|
||||
sudo_debug_get_fds_v1
|
||||
sudo_debug_get_instance_v1
|
||||
sudo_debug_needed_v1
|
||||
sudo_debug_printf2_v1
|
||||
sudo_debug_register_v1
|
||||
sudo_debug_set_active_instance_v1
|
||||
sudo_debug_update_fd_v1
|
||||
sudo_debug_vprintf2_v1
|
||||
sudo_debug_needed_v1
|
||||
sudo_debug_write2_v1
|
||||
sudo_digest_alloc_v1
|
||||
sudo_digest_final_v1
|
||||
@@ -63,10 +63,10 @@ sudo_ev_get_timeleft_v1
|
||||
sudo_ev_get_timeleft_v2
|
||||
sudo_ev_got_break_v1
|
||||
sudo_ev_got_exit_v1
|
||||
sudo_ev_loop_v1
|
||||
sudo_ev_loopbreak_v1
|
||||
sudo_ev_loopcontinue_v1
|
||||
sudo_ev_loopexit_v1
|
||||
sudo_ev_loop_v1
|
||||
sudo_ev_pending_v1
|
||||
sudo_ev_set_v1
|
||||
sudo_fatal_callback_deregister_v1
|
||||
@@ -77,12 +77,13 @@ sudo_gai_fatal_nodebug_v1
|
||||
sudo_gai_vfatal_nodebug_v1
|
||||
sudo_gai_vwarn_nodebug_v1
|
||||
sudo_gai_warn_nodebug_v1
|
||||
sudo_get_ttysize_v1
|
||||
sudo_getgrouplist2_v1
|
||||
sudo_gethostname_v1
|
||||
sudo_gettime_awake_v1
|
||||
sudo_gettime_mono_v1
|
||||
sudo_gettime_real_v1
|
||||
sudo_get_ttysize_v1
|
||||
sudo_json_add_value_as_object_v1
|
||||
sudo_json_add_value_v1
|
||||
sudo_json_close_array_v1
|
||||
sudo_json_close_object_v1
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user