aboutsummaryrefslogtreecommitdiffstats
path: root/manager.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-29 12:56:46 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-06-29 12:56:46 +0000
commited56b47de7f4a39c426fef692f424d82e565714a (patch)
treed715877541188789ffca02a85def77a7a01cbea9 /manager.c
parenteb2476308635e0c068a4ab2f27e9adbbf935c2ef (diff)
Create reentrant ast_inet_ntoa and replace all inet_ntoa's with ast_inet_ntoa's (but #1944)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3345 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'manager.c')
-rwxr-xr-xmanager.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/manager.c b/manager.c
index fc42e7ab9..f990c073d 100755
--- a/manager.c
+++ b/manager.c
@@ -163,12 +163,13 @@ static int handle_showmancmds(int fd, int argc, char *argv[])
static int handle_showmanconn(int fd, int argc, char *argv[])
{
struct mansession *s;
+ char iabuf[80];
char *format = " %-15.15s %-15.15s\n";
ast_mutex_lock(&sessionlock);
s = sessions;
ast_cli(fd, format, "Username", "IP Address");
while (s) {
- ast_cli(fd, format,s->username, inet_ntoa(s->sin.sin_addr));
+ ast_cli(fd, format,s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
s = s->next;
}
@@ -311,6 +312,7 @@ static int set_eventmask(struct mansession *s, char *eventmask)
static int authenticate(struct mansession *s, struct message *m)
{
struct ast_config *cfg;
+ char iabuf[80];
char *cat;
char *user = astman_get_header(m, "Username");
char *pass = astman_get_header(m, "Secret");
@@ -340,7 +342,7 @@ static int authenticate(struct mansession *s, struct message *m)
v = v->next;
}
if (ha && !ast_apply_ha(ha, &(s->sin))) {
- ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", inet_ntoa(s->sin.sin_addr), user);
+ ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
ast_free_ha(ha);
ast_destroy(cfg);
return -1;
@@ -369,7 +371,7 @@ static int authenticate(struct mansession *s, struct message *m)
} else if (password && !strcasecmp(password, pass)) {
break;
} else {
- ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", inet_ntoa(s->sin.sin_addr), user);
+ ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
ast_destroy(cfg);
return -1;
}
@@ -386,7 +388,7 @@ static int authenticate(struct mansession *s, struct message *m)
set_eventmask(s, events);
return 0;
}
- ast_log(LOG_NOTICE, "%s tried to authenticate with non-existant user '%s'\n", inet_ntoa(s->sin.sin_addr), user);
+ ast_log(LOG_NOTICE, "%s tried to authenticate with non-existant user '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
ast_destroy(cfg);
return -1;
}
@@ -938,6 +940,7 @@ static int process_message(struct mansession *s, struct message *m)
struct manager_action *tmp = first_action;
char *id = astman_get_header(m,"ActionID");
char idText[256] = "";
+ char iabuf[80];
strncpy(action, astman_get_header(m, "Action"), sizeof(action));
ast_log( LOG_DEBUG, "Manager received command '%s'\n", action );
@@ -976,8 +979,8 @@ static int process_message(struct mansession *s, struct message *m)
} else {
s->authenticated = 1;
if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged on from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
- ast_log(LOG_EVENT, "Manager '%s' logged on from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged on from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
+ ast_log(LOG_EVENT, "Manager '%s' logged on from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
astman_send_ack(s, m, "Authentication accepted");
}
} else if (!strcasecmp(action, "Logoff")) {
@@ -1009,6 +1012,7 @@ static int get_input(struct mansession *s, char *output)
int res;
int x;
struct pollfd fds[1];
+ char iabuf[80];
for (x=1;x<s->inlen;x++) {
if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r')) {
/* Copy output data up to and including \r\n */
@@ -1022,7 +1026,7 @@ static int get_input(struct mansession *s, char *output)
}
}
if (s->inlen >= sizeof(s->inbuf) - 1) {
- ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", inet_ntoa(s->sin.sin_addr), s->inbuf);
+ ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), s->inbuf);
s->inlen = 0;
}
fds[0].fd = s->fd;
@@ -1046,6 +1050,7 @@ static void *session_do(void *data)
{
struct mansession *s = data;
struct message m;
+ char iabuf[80];
int res;
ast_mutex_lock(&s->lock);
@@ -1070,12 +1075,12 @@ static void *session_do(void *data)
}
if (s->authenticated) {
if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
- ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
+ ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
} else {
if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", inet_ntoa(s->sin.sin_addr));
- ast_log(LOG_EVENT, "Failed attempt from %s\n", inet_ntoa(s->sin.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
+ ast_log(LOG_EVENT, "Failed attempt from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
}
destroy_session(s);
return NULL;