aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-11-21 02:20:11 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-11-21 10:48:30 +0700
commitb639b4d4f7f3d51c50dd687a38690c57ba20dced (patch)
tree22d9f9e53206c84fa99c6097d272aef3c0f04969
parent4abda9ea26403e24b2d91b83a1e4c81f5fb4b003 (diff)
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
-rw-r--r--src/vty/vty.c6
-rw-r--r--tests/testsuite.at5
2 files changed, 6 insertions, 5 deletions
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) {
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 58651409..c231b964 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -199,10 +199,7 @@ AT_SETUP([vty])
AT_KEYWORDS([vty])
cat $abs_srcdir/vty/vty_test.ok > expout
cp $abs_srcdir/vty/*.cfg .
-# FIXME: calling vty_out() during initialization of the VTY interface would cause
-# the process write to its own *stdin*! This breaks the output of 'make check'.
-# Let's work this around untill the bug in libosmovty is fixed.
-AT_CHECK([$abs_top_builddir/tests/vty/vty_test 0>/dev/null], [0], [expout], [ignore])
+AT_CHECK([$abs_top_builddir/tests/vty/vty_test], [0], [expout], [ignore])
AT_CLEANUP
AT_SETUP([gprs-bssgp])