mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
New AMI Command Output Format
This change modifies how the the output from a CLI command is sent to a client over AMI. Output from the CLI command is now sent as a series of zero-or-more Output: headers. Additionally, commands that fail to execute (eg: no such command, invalid syntax etc.) now cause an Error response instead of Success. If the command executed successfully, but the manager unable to provide the output the reason will be included in the Message: header. Otherwise it will contain 'Command output follows'. Depends on a new version of starpy (> 1.0.2) that supports the new output format. See pull-request https://github.com/asterisk/starpy/pull/34 ASTERISK-24730 Change-Id: I6718d95490f0a6b3f171c1a5cdad9207f9a44888
This commit is contained in:
committed by
George Joseph
parent
f89481e39c
commit
2f418c052e
14
main/cli.c
14
main/cli.c
@@ -2681,12 +2681,12 @@ int ast_cli_command_full(int uid, int gid, int fd, const char *s)
|
||||
int x;
|
||||
char *duplicate = parse_args(s, &x, args + 1, AST_MAX_ARGS, NULL);
|
||||
char tmp[AST_MAX_ARGS + 1];
|
||||
char *retval = NULL;
|
||||
char *retval = CLI_FAILURE;
|
||||
struct ast_cli_args a = {
|
||||
.fd = fd, .argc = x, .argv = args+1 };
|
||||
|
||||
if (duplicate == NULL)
|
||||
return -1;
|
||||
return RESULT_FAILURE;
|
||||
|
||||
if (x < 1) /* We need at least one entry, otherwise ignore */
|
||||
goto done;
|
||||
@@ -2705,8 +2705,7 @@ int ast_cli_command_full(int uid, int gid, int fd, const char *s)
|
||||
/* Check if the user has rights to run this command. */
|
||||
if (!cli_has_permissions(uid, gid, tmp)) {
|
||||
ast_cli(fd, "You don't have permissions to run '%s' command\n", tmp);
|
||||
ast_free(duplicate);
|
||||
return 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2719,14 +2718,13 @@ int ast_cli_command_full(int uid, int gid, int fd, const char *s)
|
||||
|
||||
if (retval == CLI_SHOWUSAGE) {
|
||||
ast_cli(fd, "%s", S_OR(e->usage, "Invalid usage, but no usage information available.\n"));
|
||||
} else {
|
||||
if (retval == CLI_FAILURE)
|
||||
ast_cli(fd, "Command '%s' failed.\n", s);
|
||||
} else if (retval == CLI_FAILURE) {
|
||||
ast_cli(fd, "Command '%s' failed.\n", s);
|
||||
}
|
||||
ast_atomic_fetchadd_int(&e->inuse, -1);
|
||||
done:
|
||||
ast_free(duplicate);
|
||||
return 0;
|
||||
return retval == CLI_SUCCESS ? RESULT_SUCCESS : RESULT_FAILURE;
|
||||
}
|
||||
|
||||
int ast_cli_command_multiple_full(int uid, int gid, int fd, size_t size, const char *s)
|
||||
|
Reference in New Issue
Block a user