Change in libosmocore[master]: logging/vty: fix vty_read_file(): do not write warnings to stdin

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Wed Nov 20 19:30:24 UTC 2019


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/16143 )


Change subject: logging/vty: fix vty_read_file(): do not write warnings to stdin
......................................................................

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
---
M src/vty/vty.c
M tests/testsuite.at
2 files changed, 6 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/43/16143/1

diff --git a/src/vty/vty.c b/src/vty/vty.c
index babe0ef..3357d5a 100644
--- a/src/vty/vty.c
+++ b/src/vty/vty.c
@@ -1468,11 +1468,15 @@
 	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 5865140..c231b96 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -199,10 +199,7 @@
 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])

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/16143
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Icdeaea67a06da3a2f07b252e455629559ecc1829
Gerrit-Change-Number: 16143
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191120/f6e71de5/attachment.htm>


More information about the gerrit-log mailing list