Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 373283 - net-analyzer/netcat-110-r8: -c does execve() instead of system()
Summary: net-analyzer/netcat-110-r8: -c does execve() instead of system()
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Netmon Herd
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2011-06-28 05:13 UTC by Xuefer
Modified: 2018-01-11 21:22 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to have -c option of good functional (25_all_sh_c_2.patch,637 bytes, patch)
2016-05-08 08:26 UTC, zzwaker
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xuefer 2011-06-28 05:13:45 UTC
this issue is in net-analyzer/netcat-110-r8 too
netcat -c does not use /bin/sh -c but works like -e

Reproducible: Always

Steps to Reproduce:
1. A $ ssh -o ProxyCommand='nc -l 127.0.0.1 -p 1024' a@a
2. B $ nc localhost 1024 -c '/usr/bin/nc localhost 22'

Actual Results:  
A: output: exec /usr/bin/nc localhost 2222 failed : No such file or directory
B: no output

Expected Results:  
A: output: SSH-2.0-OpenSSH_5.8p1-hpn13v10
B: no output

the follow is tail part of strace -f nc localhost 1024 -c '/usr/bin/nc localhost 2222'

rt_sigaction(SIGALRM, {SIG_IGN, [ALRM], SA_RESTORER|SA_RESTART, 0x38ee231d70}, {SIG_IGN, [ALRM], SA_RESTORER|SA_RESTART, 0x38ee231d70}, 8) = 0
alarm(0)                                = 0
dup2(3, 0)                              = 0
close(3)                                = 0
dup2(0, 1)                              = 1
dup2(0, 2)                              = 2
execve("/usr/bin/nc localhost 2222", ["nc localhost 2222"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
write(2, "exec /usr/bin/nc localhost 2222 "..., 38) = 38
write(2, " : No such file or directory\n", 29) = 29
close(3)                                = -1 EBADF (Bad file descriptor)
exit_group(1)                           = ?
Comment 1 zzwaker 2016-05-08 08:26:23 UTC
Created attachment 433580 [details, diff]
patch to have -c option of good functional

I also encountered the same situation by the follower steps:

1. server to listen on port 4000
     #  nc -v -l -p 4000
2. client try to connected with -c option
     #  nc -v -c date localhost 4000

the output will be the "... no such file or directory"

And the attached patch can solve this. Tks!
Comment 2 SpanKY gentoo-dev 2018-01-11 21:22:49 UTC
this was fixed in netcat-110-r9