From b639b4d4f7f3d51c50dd687a38690c57ba20dced Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Thu, 21 Nov 2019 02:20:11 +0700 Subject: logging/vty: fix vty_read_file(): do not write warnings to stdin Setting vty->fd to 0 is a bad idea, which may cause the process to write() warnings to its own _stdin_ (yes, it's possible). For example, when a configuration file contains deprecated logging commands. Let's use stderr by default. Change-Id: Icdeaea67a06da3a2f07b252e455629559ecc1829 --- src/vty/vty.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/vty/vty.c b/src/vty/vty.c index babe0ef6..3357d5a7 100644 --- a/src/vty/vty.c +++ b/src/vty/vty.c @@ -1468,11 +1468,15 @@ vty_read_file(FILE *confp, void *priv) struct vty *vty; vty = vty_new(); - vty->fd = 0; vty->type = VTY_FILE; vty->node = CONFIG_NODE; vty->priv = priv; + /* By default, write to stderr. Otherwise, during parsing of the logging + * configuration, all invocations to vty_out() would make the process + * write() to its own stdin (fd=0)! */ + vty->fd = fileno(stderr); + ret = config_from_file(vty, confp); if (ret != CMD_SUCCESS) { -- cgit v1.2.3