Project

General

Profile

Bug #3404

lookip in --listen-{up,down} mode not streaming to pipe

Added by Tim Stamp 7 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Category:
libcharon
Target version:
Start date:
Due date:
Estimated time:
Affected version:
5.8.4
Resolution:
Fixed

Description

Firstly, thanks for the fantastic project. Love it.

I've encountered an interesting issue while trying to read output from lookip out to a pipe or file, whereby the output of the command when in "--listen-up" or "--listen-down" mode is not visible anywhere.
Even more strangely, the --dump output is also missing from all outputs when piping the result when used with the --listen-* options.

This works

$ ipsec lookip --dump
lookup: 10.0.0.1 12.34.56.78 default-conn[23] myusername

This works

$ ipsec lookip --dump > foo && cat foo
lookup: 10.0.0.1 12.34.56.78 default-conn[23] myusername

This works

$ ipsec lookip --listen-up --listen-down --dump
lookup: 10.0.0.1 12.34.56.78 default-conn[23] myusername

This does not work as expected.

$ ipsec lookip --listen-up --listen-down --dump > foo
(foo is always empty, STDOUT is always empty)

Using 5.8.4, compiled from source on Ubuntu

./configure --prefix=/usr --sysconfdir=/etc \
        --enable-farp --enable-openssl --enable-eap-mschapv2 --enable-eap-identity --enable-eap-tls
        --enable-ext-auth --enable-lookip --with-routing-table

Any suggestions on workarounds or fixes much appreciated!

Associated revisions

Revision 3d92cff7 (diff)
Added by Tobias Brunner 6 months ago

lookip: Use line buffering for stdout

Otherwise, the output is buffered when e.g. piping the output to another
command (or file). And it avoids having to call fflush() in the
interactive mode.

Fixes #3404.

History

#1 Updated by Tim Stamp 7 months ago

I've engineered a fix, seems to work.

diff lookip.c lookip_orig.c
187d186
<                 fflush(stdout);

#2 Updated by Tobias Brunner 7 months ago

  • Description updated (diff)
  • Status changed from New to Feedback

First, the lookip utility is just an example on how the socket created by the lookip plugin can be used. Depending on what you want to do, writing your own client application might work better.

I've engineered a fix, seems to work.

Yeah, but I think it's easier to just switch stdout to line buffering. I pushed a commit that does so to the 3404-lookip-linebuf branch.

#3 Updated by Tobias Brunner 6 months ago

  • Tracker changed from Issue to Bug
  • Category changed from charon to libcharon
  • Status changed from Feedback to Closed
  • Assignee set to Tobias Brunner
  • Target version set to 5.9.0
  • Resolution set to Fixed

Also available in: Atom PDF