summaryrefslogtreecommitdiffstats
path: root/src/rest.c
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-06-21 15:04:47 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-06-21 15:05:26 +0200
commit6cbe69e89e716f81a71f7541e2e0f036b297a2fc (patch)
treee6564b12103c1a19c07bfb702aee70c65ad3629d /src/rest.c
parent12d5caf6a6af5cb4870d375e185341909fc61b7e (diff)
rest: add cmd to shell/output
Add "cmd" field to json that provides the original command string, so it is provided with the output and the return code.
Diffstat (limited to 'src/rest.c')
-rw-r--r--src/rest.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/rest.c b/src/rest.c
index e61add0..4dc7515 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -777,7 +777,7 @@ static int og_cmd_run_get(json_t *element, struct og_msg_params *params,
return -1;
for (i = 0; i < params->ips_array_len; i++) {
- json_t *object, *output, *addr;
+ json_t *object, *output, *addr, *cmd;
struct og_client *cli;
cli = og_client_find(params->ips_array[i]);
@@ -797,6 +797,14 @@ static int og_cmd_run_get(json_t *element, struct og_msg_params *params,
}
json_object_set_new(object, "addr", addr);
+ cmd = json_string(cli->shell.cmd);
+ if (!cmd) {
+ json_decref(object);
+ json_decref(array);
+ return -1;
+ }
+ json_object_set_new(object, "cmd", cmd);
+
output = json_string(cli->shell.output);
if (!output) {
json_decref(object);