summaryrefslogtreecommitdiffstats
path: root/src/client.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/client.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/client.c')
-rw-r--r--src/client.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/client.c b/src/client.c
index 46baab8..3affaed 100644
--- a/src/client.c
+++ b/src/client.c
@@ -171,7 +171,7 @@ static int og_resp_probe(struct og_client *cli, json_t *data)
static int og_resp_shell_run(struct og_client *cli, json_t *data)
{
- const char *output = NULL;
+ const char *cmd = NULL, *output = NULL;
uint32_t retcode;
const char *key;
json_t *value;
@@ -181,7 +181,11 @@ static int og_resp_shell_run(struct og_client *cli, json_t *data)
return -1;
json_object_foreach(data, key, value) {
- if (!strcmp(key, "out")) {
+ if (!strcmp(key, "cmd")) {
+ err = og_json_parse_string(value, &cmd);
+ if (err < 0)
+ return err;
+ } else if (!strcmp(key, "out")) {
err = og_json_parse_string(value, &output);
if (err < 0)
return err;
@@ -199,7 +203,9 @@ static int og_resp_shell_run(struct og_client *cli, json_t *data)
return -1;
}
+ free((void *)cli->shell.cmd);
free((void *)cli->shell.output);
+ cli->shell.cmd = strdup(cmd);
cli->shell.output = strdup(output);
cli->shell.retcode = retcode;