aboutsummaryrefslogtreecommitdiffstats
path: root/main/manager.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-02 20:55:00 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-02 20:55:00 +0000
commit9c27f7b3dd797724623159b19c1d64d07482b47d (patch)
tree35dc5141f41323b7636ee235d54135ba2920c800 /main/manager.c
parent441041aca6684d1e2da9503017012866d263cd77 (diff)
Backport the change that only went in to trunk that fixes the command manager
action over http. (reported internally by pari and bkruse) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@62739 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/manager.c')
-rw-r--r--main/manager.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/main/manager.c b/main/manager.c
index 07458a506..32a8133a6 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -1612,11 +1612,24 @@ static int action_command(struct mansession *s, const struct message *m)
{
const char *cmd = astman_get_header(m, "Command");
const char *id = astman_get_header(m, "ActionID");
+ char *buf;
+ char template[] = "/tmp/ast-ami-XXXXXX"; /* template for temporary file */
+ int fd = mkstemp(template);
+ off_t l;
+
astman_append(s, "Response: Follows\r\nPrivilege: Command\r\n");
if (!ast_strlen_zero(id))
astman_append(s, "ActionID: %s\r\n", id);
/* FIXME: Wedge a ActionID response in here, waiting for later changes */
- ast_cli_command(s->fd, cmd);
+ ast_cli_command(fd, cmd); /* XXX need to change this to use a FILE * */
+ l = lseek(fd, 0, SEEK_END); /* how many chars available */
+ buf = alloca(l+1);
+ lseek(fd, 0, SEEK_SET);
+ read(fd, buf, l);
+ buf[l] = '\0';
+ close(fd);
+ unlink(template);
+ astman_append(s, buf);
astman_append(s, "--END COMMAND--\r\n\r\n");
return 0;
}