[Xorp-users] 'echo "any text" | xorpsh' cause abend

Dan Lukes dan@obluda.cz
Thu, 16 Jun 2005 20:09:46 +0200


Issuing command:
echo "show igmp interface" | xorpsh

cause abend. The output:

  ===============
[ 2005/06/16 19:31:57 INFO xorpsh CLI ] CLI enabled
[ 2005/06/16 19:31:57  ERROR xorpsh:79599 CLI +319 cli_node_net.cc 
start_connection ]
    start_connection(): tcgetattr() error: Inappropriate ioctl for device
Segmentation fault (core dumped)

Core was generated by xorpsh'.
Program terminated with signal 11, Segmentation fault.
  ================

Coretump backtrace:
#0  CliClient::set_current_cli_prompt (this=0x0, cli_prompt=@0xbfbf89dc)
     at /usr/include/g++/std/bastring.h:147
#1  0x806a3a9 in RouterCLI::set_prompt (this=0x8379d00, line1=@0xbfbf89cc,
     line2=@0xbfbf89dc) at cli.cc:923
#2  0x80591ad in RouterCLI::operational_mode (this=0x8379d00) at cli.cc:457
#3  0x80586ef in RouterCLI::RouterCLI (this=0x8379d2c, xorpsh=@0xbfbfdb24,
     cli_node=@0xbfbfdd6c, verbose=false) at cli.cc:400
#4  0x80e0f9e in XorpShell::run (this=0xbfbfdb24) at xorpsh_main.cc:245
#5  0x80e4085 in main (argc=1, argv=0xbfbffbe0) at xorpsh_main.cc:612


	IMHO, the responsible code is:

rtrmgr/cli.cc:

RouterCLI::RouterCLI(XorpShell& xorpsh, CliNode& cli_node, bool verbose)
     : _xorpsh(xorpsh),
       _cli_node(cli_node),
       _cli_client(*(_cli_node.add_stdio_client())),
       _verbose(verbose),
       _mode(CLI_MODE_NONE),
       _changes_made(false),
       _op_mode_cmd(0)
{
...


	The problem is - when stdio isn't terminal then tcgetattr failed. It 
cause to several XORP_ERROR returns. At the end, the 
_cli_node.add_stdio_client() return NULL

	If I understant the C++ syntax correctly the 
_cli_client(*(_cli_node.add_stdio_client())) mean this NULL is dereferenced.

	Unfortunatelly my insufficient C++ skills disallow me to send a patch.

	The far idea is to use the isatty function within cli/cli_node_net.cc 
to skip tcgetattr/tcsetattr configuration when we are not on interactive 
terminal.

	This abend may or may not be the reason why 
mehdi.bensaid@rd.francetelecom.com can't obtain the output from xorp by 
python.

						Dan