inspeqtor icon indicating copy to clipboard operation
inspeqtor copied to clipboard

inspeqtorctl fails with nc: invalid option -- 'U' (workaround possible)

Open tibra opened this issue 4 years ago • 3 comments

Dear Mike 👋,

calling the inspeqtorctl command fails:

inspeqtorctl
> nc: invalid option -- 'U'

Environment

Debian 10 Buster
Inspeqtor 2.0.0
netcat v1.10-41.1

Other projects seem to have similar problems.

It seems to be related to line 13 here:

if [ ! -x /bin/nc ] && [ ! -x /usr/bin/nc ]; then
  # Some OS's ship with nc in the base, others don't.
  # What a crock.
  echo Could not find a working netcat in /bin/nc or /usr/bin/nc.
  echo Please install your operating system\'s \'netcat\' or \'nc\' package
else
  echo "$@" | nc -U ${INSPEQTOR_SOCK:-/var/run/inspeqtor.sock}
fi

🔧 Workaround I can confirm, as suggested here, that the netcat-openbsd package on debian works, which supports the old cli and inspeqtorctl works as intended.

I can live with the workaround, but others may be wondering what goes on. Maybe you have an idea how to fix it without having another conditional.

Thank you kindly!

tibra avatar May 18 '20 12:05 tibra

If I remove -U, will nc start failing on other platforms that do support -U?

mperham avatar May 18 '20 18:05 mperham

Yes, it will then fail without providing a conditional or another solution to read the socket because the CLI changed (an since nowadays container images change their base images too, it might create regressions):

Options, that nc.traditional does not know are: -4 / -6, -U, -k Options, that nc6 does not know are: -U, -k but it knows --continuous

  • Creating a conditional on inspeqtor's side is not straight forward and probably error prone because checking the version number requires parsing the man pages m(
  • Requiring netcat-openbsd as a dependency would be an option, albeit contrary to the philosophy of a standalone library.
  • Apart from that, socat seems to be an actively maintained and modern alternative.

Would it make sense to bundle this into the inspeqtor package if the OS cli env is not reliable enough?

tibra avatar May 19 '20 04:05 tibra

Yeah we can change the packages and binary to install and use socat.

mperham avatar May 19 '20 05:05 mperham