<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/16143">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">logging/vty: fix vty_read_file(): do not write warnings to stdin<br><br>Setting vty->fd to 0 is a bad idea, which may cause the process<br>to write() warnings to its own _stdin_ (yes, it's possible).<br>For example, when a configuration file contains deprecated<br>logging commands. Let's use stderr by default.<br><br>Change-Id: Icdeaea67a06da3a2f07b252e455629559ecc1829<br>---<br>M src/vty/vty.c<br>M tests/testsuite.at<br>2 files changed, 6 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/43/16143/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/vty/vty.c b/src/vty/vty.c</span><br><span>index babe0ef..3357d5a 100644</span><br><span>--- a/src/vty/vty.c</span><br><span>+++ b/src/vty/vty.c</span><br><span>@@ -1468,11 +1468,15 @@</span><br><span>   struct vty *vty;</span><br><span> </span><br><span>         vty = vty_new();</span><br><span style="color: hsl(0, 100%, 40%);">-        vty->fd = 0;</span><br><span>      vty->type = VTY_FILE;</span><br><span>     vty->node = CONFIG_NODE;</span><br><span>  vty->priv = priv;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+      /* By default, write to stderr. Otherwise, during parsing of the logging</span><br><span style="color: hsl(120, 100%, 40%);">+       * configuration, all invocations to vty_out() would make the process</span><br><span style="color: hsl(120, 100%, 40%);">+  * write() to its own stdin (fd=0)! */</span><br><span style="color: hsl(120, 100%, 40%);">+        vty->fd = fileno(stderr);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>       ret = config_from_file(vty, confp);</span><br><span> </span><br><span>      if (ret != CMD_SUCCESS) {</span><br><span>diff --git a/tests/testsuite.at b/tests/testsuite.at</span><br><span>index 5865140..c231b96 100644</span><br><span>--- a/tests/testsuite.at</span><br><span>+++ b/tests/testsuite.at</span><br><span>@@ -199,10 +199,7 @@</span><br><span> AT_KEYWORDS([vty])</span><br><span> cat $abs_srcdir/vty/vty_test.ok > expout</span><br><span> cp $abs_srcdir/vty/*.cfg .</span><br><span style="color: hsl(0, 100%, 40%);">-# FIXME: calling vty_out() during initialization of the VTY interface would cause</span><br><span style="color: hsl(0, 100%, 40%);">-# the process write to its own *stdin*! This breaks the output of 'make check'.</span><br><span style="color: hsl(0, 100%, 40%);">-# Let's work this around untill the bug in libosmovty is fixed.</span><br><span style="color: hsl(0, 100%, 40%);">-AT_CHECK([$abs_top_builddir/tests/vty/vty_test 0>/dev/null], [0], [expout], [ignore])</span><br><span style="color: hsl(120, 100%, 40%);">+AT_CHECK([$abs_top_builddir/tests/vty/vty_test], [0], [expout], [ignore])</span><br><span> AT_CLEANUP</span><br><span> </span><br><span> AT_SETUP([gprs-bssgp])</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/16143">change 16143</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/16143"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Icdeaea67a06da3a2f07b252e455629559ecc1829 </div>
<div style="display:none"> Gerrit-Change-Number: 16143 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>