summaryrefslogtreecommitdiffstats
path: root/src/vty
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-06-03 12:41:24 +0200
committerHarald Welte <laforge@gnumonks.org>2012-06-03 12:44:38 +0200
commit8b0d5b3726da5f35751d14a6c2238af2851e3a19 (patch)
tree4dd407cf589ffd7f6c078ead2a9d1b0bb5ef4120 /src/vty
parent98d77bd4dcef86cb0a56bc0a5162bc407fb566d3 (diff)
VTY: safe version of printing VTY welcome message
The old method used raw writes to the telnet FD, which is bad for several reasons: a) we don't know if we can actually write that many bytes to the socket at the given time b) the socket is still in blocking mode, so we could stall the entire process c) there may be weird interaction with the buffered writes of the vty_out Now, the print_welcome() functionality has moved to vty_hello() instead, where we can use normal vty_out() in buffered mode. This commit is expected to fix the garbled welcome message on arm-eglibc targets. It might still be a good idea to migrate the entire telnet interface to libtelnet - but at some later time ;)
Diffstat (limited to 'src/vty')
-rw-r--r--src/vty/telnet_interface.c19
-rw-r--r--src/vty/vty.c11
2 files changed, 11 insertions, 19 deletions
diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c
index 77120417..1abf141d 100644
--- a/src/vty/telnet_interface.c
+++ b/src/vty/telnet_interface.c
@@ -90,23 +90,6 @@ int telnet_init_dynif(void *tall_ctx, void *priv, const char *ip, int port)
extern struct host host;
-static void print_welcome(int fd)
-{
- static const char *msg1 = "Welcome to the ";
- static const char *msg2 = " control interface\r\n";
- const char *app_name = "<unnamed>";
-
- if (host.app_info->name)
- app_name = host.app_info->name;
-
- write(fd, msg1, strlen(msg1));
- write(fd, app_name, strlen(app_name));
- write(fd, msg2, strlen(msg2));
-
- if (host.app_info->copyright)
- write(fd, host.app_info->copyright, strlen(host.app_info->copyright));
-}
-
/*! \brief close a telnet connection */
int telnet_close_client(struct osmo_fd *fd)
{
@@ -169,8 +152,6 @@ static int telnet_new_connection(struct osmo_fd *fd, unsigned int what)
osmo_fd_register(&connection->fd);
llist_add_tail(&connection->entry, &active_connections);
- print_welcome(new_connection);
-
connection->vty = vty_create(new_connection, connection);
if (!connection->vty) {
LOGP(0, LOGL_ERROR, "couldn't create VTY\n");
diff --git a/src/vty/vty.c b/src/vty/vty.c
index 04df2be0..86131ecc 100644
--- a/src/vty/vty.c
+++ b/src/vty/vty.c
@@ -339,6 +339,17 @@ int vty_config_unlock(struct vty *vty)
/* Say hello to vty interface. */
void vty_hello(struct vty *vty)
{
+ const char *app_name = "<unnamed>";
+
+ if (host.app_info->name)
+ app_name = host.app_info->name;
+
+ vty_out(vty, "Welcome to the %s control interface%s",
+ app_name, VTY_NEWLINE);
+
+ if (host.app_info->copyright)
+ vty_out(vty, host.app_info->copyright);
+
if (host.motdfile) {
FILE *f;
char buf[4096];