From 00d54325d3d8a325ebcab40df549b4146204f6e0 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Tue, 26 Nov 2024 11:18:36 +0100 Subject: rest: update POST /shell/run for cmd execution Remove legacy "echo" parameter. Add boolean "inline" parameter to determine if the execution is an inline command or a predefined script in /opt/opengnsys/shell/ --- src/json.h | 1 - src/rest.c | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/json.h b/src/json.h index 1d711dd..6536d88 100644 --- a/src/json.h +++ b/src/json.h @@ -75,7 +75,6 @@ struct og_msg_params { const char *cache; const char *cache_size; const char *comment; - bool echo; struct og_partition partition_setup[OG_PARTITION_MAX]; struct og_image image; uint64_t flags; diff --git a/src/rest.c b/src/rest.c index db6f829..cf50f64 100644 --- a/src/rest.c +++ b/src/rest.c @@ -65,7 +65,7 @@ struct ev_loop *og_loop; #define OG_REST_PARAM_SYNC_DIFF_NAME (1UL << 27) #define OG_REST_PARAM_SYNC_PATH (1UL << 28) #define OG_REST_PARAM_SYNC_METHOD (1UL << 29) -#define OG_REST_PARAM_ECHO (1UL << 30) +#define OG_REST_PARAM_INLINE (1UL << 30) #define OG_REST_PARAM_TASK (1UL << 31) #define OG_REST_PARAM_TIME_YEARS (1UL << 32) #define OG_REST_PARAM_TIME_MONTHS (1UL << 33) @@ -667,6 +667,7 @@ static int og_cmd_run_post(json_t *element, struct og_msg_params *params) { json_t *value, *clients; const char *key; + bool inline_cmd; int err = 0; if (json_typeof(element) != JSON_OBJECT) @@ -677,9 +678,9 @@ static int og_cmd_run_post(json_t *element, struct og_msg_params *params) err = og_json_parse_clients(value, params); else if (!strcmp(key, "run")) err = og_json_parse_run(value, params); - else if (!strcmp(key, "echo")) { - err = og_json_parse_bool(value, ¶ms->echo); - params->flags |= OG_REST_PARAM_ECHO; + else if (!strcmp(key, "inline")) { + err = og_json_parse_bool(value, &inline_cmd); + params->flags |= OG_REST_PARAM_INLINE; } if (err < 0) @@ -688,7 +689,7 @@ static int og_cmd_run_post(json_t *element, struct og_msg_params *params) if (!og_msg_params_validate(params, OG_REST_PARAM_ADDR | OG_REST_PARAM_RUN_CMD | - OG_REST_PARAM_ECHO)) + OG_REST_PARAM_INLINE)) return -1; clients = json_copy(element); -- cgit v1.2.3-18-g5258