aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-24 15:27:23 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-24 15:27:23 +0000
commit4d82d06a4e5afea9a14b8db191d0affe6067d4d6 (patch)
tree61eaf83b71d7c43b03d2ccf2026ff94cff7799ef
parentef88503110c3b84763ba29ebe7ca63f10d757e77 (diff)
Add the ability to blacklist certain commands from being executed using the Command AMI action. (issue #9240 reported by junky)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@65902 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/manager.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/main/manager.c b/main/manager.c
index b3933df32..2b6fbf796 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -129,6 +129,11 @@ static struct permalias {
{ 0, "none" },
};
+static const char *command_blacklist[] = {
+ "module load",
+ "module unload",
+};
+
struct mansession {
/*! Execution thread */
pthread_t t;
@@ -1620,9 +1625,16 @@ static int action_command(struct mansession *s, const struct message *m)
const char *id = astman_get_header(m, "ActionID");
char *buf, *final_buf;
char template[] = "/tmp/ast-ami-XXXXXX"; /* template for temporary file */
- int fd = mkstemp(template);
+ int fd = mkstemp(template), i = 0;
off_t l;
+ for (i = 0; i < sizeof(command_blacklist) / sizeof(command_blacklist[0]); i++) {
+ if (!strncmp(cmd, command_blacklist[i], strlen(command_blacklist[i]))) {
+ astman_send_error(s, m, "Command blacklisted");
+ return 0;
+ }
+ }
+
astman_append(s, "Response: Follows\r\nPrivilege: Command\r\n");
if (!ast_strlen_zero(id))
astman_append(s, "ActionID: %s\r\n", id);