nmap: add option to build/install ncat
PATCH v4 1/1 nmap: add option to build/install ncat
Ncat is a much-improved reimplementation of the venerable Netcat and is compatible with uClibc and musl. It provides features not available in the ancient GNU netcat and its Busybox double like IPv6, proxies, and Unix sockets.
Tha nmap package now installs ncat if the BR2_PACKAGE_NMAP_NCAT option is selected. The other programs (nmap, ndiff, etc.) are chosen via the BR2_PACKAGE_NMAP_NMAP option.
We symlink 'nc' to ncat if neiter netcat nor netcat-openbsd is selected, even though ncat does not have the same interface as netcat-openbsd. However, since Fedora/RHEL install nmap-ncat as 'nc', it can be assumed that packages that depend on 'nc' know how to deal with this diversity. For example, the virt-manager package does that. Also user-supplied scripts can be assumed to do the right thing, since the user also selects whether nmap-ncat, netcat or netcat-openbsd is installed.
---
Changes v1->v2:
- Add dependens on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS, like netcat does
- Remove forced dependence on busybox, since its installation script does not override existing programs.
Changes v2->v3:
- Use a better logic to select either ncat tools, nmap or both, as suggested by Arnout Vandecappelle and Thomas Petazzoni.
- Add a prominent comment about the symlink to 'nc', as suggested by Arnout.
Changes v3->v4:
- Restore forced dependence on busybox, since it may be necessary if packages become built in parallel, leading to a race condition on the creation of the "nc" link.
--- package/nmap/Config.in | 27 ++++++++++++++++++++++++++- package/nmap/nmap.mk | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 3 deletions(-)
package/nmap/Config.in +26 -1
@@ -4,6 +4,12 @@ config BR2_PACKAGE_NMAP depends on BR2_USE_MMU # fork() depends on BR2_TOOLCHAIN_HAS_THREADS select BR2_PACKAGE_LIBPCAP + select BR2_PACKAGE_NMAP_NMAP if !BR2_PACKAGE_NMAP_NCAT + +if BR2_PACKAGE_NMAP + +config BR2_PACKAGE_NMAP_NMAP + bool "install nmap tools" select BR2_PACKAGE_PCRE help Nmap ("Network Mapper") is a free and open source (license)
@@ -11,6 +17,25 @@ config BR2_PACKAGE_NMAP http://nmap.org -comment "nmap needs a toolchain w/ C++, threads" +config BR2_PACKAGE_NMAP_NCAT + bool "install ncat" + depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS + help + Ncat is a feature-packed networking utility which reads and + writes data across networks from the command line. Ncat was + written for the Nmap Project as a much-improved + reimplementation of the venerable Netcat. + + If symlink to "nc" is installed if neither netcat or + netcat-openbsd is selected. + +comment "a symlink from ncat to 'nc' will be installed" + depends on BR2_PACKAGE_NMAP_NCAT + depends on !BR2_PACKAGE_NETCAT + depends on !BR2_PACKAGE_NETCAT_OPENBSD + +endif + +comment "nmap-nmap needs a toolchain w/ C++, threads" depends on BR2_USE_MMU depends on !(BR2_INSTALL_LIBSTDCPP && BR2_TOOLCHAIN_HAS_THREADS)
package/nmap/nmap.mk +36 -2
@@ -7,13 +7,19 @@ NMAP_VERSION = 7.60 NMAP_SITE = https://nmap.org/dist NMAP_SOURCE = nmap-$(NMAP_VERSION).tar.bz2 -NMAP_DEPENDENCIES = libpcap pcre +NMAP_DEPENDENCIES = libpcap NMAP_CONF_OPTS = --without-liblua --without-zenmap \ --with-libdnet=included --with-liblinear=included \ - --with-libpcre="$(STAGING_DIR)/usr" --without-ncat + --with-libpcre="$(STAGING_DIR)/usr" NMAP_LICENSE = GPL-2.0 NMAP_LICENSE_FILES = COPYING +# Ensure Busybox gets built/installed before, so that this package +# overrides Busybox nc. +ifeq ($(BR2_PACKAGE_BUSYBOX)$(BR2_PACKAGE_NMAP_NCAT),yy) +NMAP_DEPENDENCIES += busybox +endif + # needed by libpcap NMAP_LIBS_FOR_STATIC_LINK += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
@@ -43,6 +49,10 @@ else NMAP_CONF_OPTS += --without-openssl endif +ifeq ($(BR2_PACKAGE_NMAP_NMAP),y) + +NMAP_DEPENDENCIES += pcre + # ndiff only works with python2.x ifeq ($(BR2_PACKAGE_PYTHON),y) NMAP_DEPENDENCIES += python
@@ -50,4 +60,28 @@ else NMAP_CONF_OPTS += --without-ndiff endif +ifeq ($(BR2_PACKAGE_NMAP_NCAT),) +NMAP_CONF_OPTS += --without-ncat +endif + +else # only ncat + +NMAP_CONF_OPTS += --without-ndiff --without-zenmap --without-nping --without-nmap-update +define NMAP_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) build-ncat +endef +define NMAP_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install-ncat +endef + +endif + +# Add a symlink to "nc" if none of the competing netcats is selected +ifeq ($(BR2_PACKAGE_NMAP_NCAT):$(BR2_PACKAGE_NETCAT)$(BR2_PACKAGE_NETCAT_OPENBSD),y:) +define NMAP_INSTALL_NCAT_SYMLINK + ln -fs ncat $(TARGET_DIR)/usr/bin/nc +endef +NMAP_POST_INSTALL_TARGET_HOOKS += NMAP_INSTALL_NCAT_SYMLINK +endif + $(eval $(autotools-package))
Signature · 1 line
2.13.6
PATCH 1/1 netcat: add forced dependence on BusyBox
It may be necessary if packages become built in parallel, leading to a race condition on the creation of the "nc" link. Moreover, netcat is as shy as BusyBox and would not override an existing file/link, so we must remove $(TARGET_DIR)/usr/bin/nc in advance.
Of course this still leaves a race conditon if other netcat competitors but we must assume thet the user is a grown-up person who knows what is doing.
--- package/netcat/netcat.mk | 11 +++++++++++ 1 file changed, 11 insertions(+)
package/netcat/netcat.mk +11 -0
@@ -9,4 +9,15 @@ NETCAT_SITE = http://downloads.sourceforge.net/project/netcat/netcat/$(NETCAT_VE NETCAT_LICENSE = GPL-2.0+ NETCAT_LICENSE_FILES = COPYING +# Ensure Busybox gets built/installed before, so that this package +# overrides Busybox nc. We must remove an existing file/link because +# netcat is as shy as Busybox and would not override existing files. +ifeq ($(BR2_PACKAGE_BUSYBOX),y) +NETCAT_DEPENDENCIES += busybox +define NETCAT_RMOVE_NC_LINK + rm -f $(TARGET_DIR)/usr/bin/nc +endef +NETCAT_PRE_INSTALL_TARGET_HOOKS += NETCAT_RMOVE_NC_LINK +endif + $(eval $(autotools-package))
Signature · 1 line
2.13.6
PATCH 1/1 netcat: add forced dependence on BusyBox
Hi Carlos,
Le 12/10/2017 ? 17:14, Carlos Santos a ?crit?:
Quoted 8 lines
It may be necessary if packages become built in parallel, leading to a race condition on the creation of the "nc" link. Moreover, netcat is as shy as BusyBox and would not override an existing file/link, so we must remove $(TARGET_DIR)/usr/bin/nc in advance.
Of course this still leaves a race conditon if other netcat competitors but we must assume thet the user is a grown-up person who knows what is doing.
It seems you are using a custom busybox config file because the netcat applet is disabled by default.
I'm agree, the dependency on busybox is missing but the TARGET_HOOKS doesn't seems necessary. I removed it and netcat package is able to override the busybox symlink.
/usr/bin/install -c netcat output/target/usr/bin/netcat
Maybe we should check if other packages depending on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS have a dependency on busybox.
Best regards,
Romain
Quoted 27 lines
Signed-off-by Carlos Santos <[email protected]>--- package/netcat/netcat.mk | 11 +++++++++++ 1 file changed, 11 insertions(+)package/netcat/netcat.mk +11
-0@@ -9,4 +9,15 @@ NETCAT_SITE = http://downloads.sourceforge.net/project/netcat/netcat/$(NETCAT_VE NETCAT_LICENSE = GPL-2.0+ NETCAT_LICENSE_FILES = COPYING +# Ensure Busybox gets built/installed before, so that this package +# overrides Busybox nc. We must remove an existing file/link because +# netcat is as shy as Busybox and would not override existing files. +ifeq ($(BR2_PACKAGE_BUSYBOX),y) +NETCAT_DEPENDENCIES += busybox +define NETCAT_RMOVE_NC_LINK + rm -f $(TARGET_DIR)/usr/bin/nc +endef +NETCAT_PRE_INSTALL_TARGET_HOOKS += NETCAT_RMOVE_NC_LINK +endif + $(eval $(autotools-package))
PATCH 1/1 netcat: add forced dependence on BusyBox
Quoted 12 lines · Romain Naour
Hi Carlos,
Le 12/10/2017 ? 17:14, Carlos Santos a ?crit?:
Quoted 8 lines
It may be necessary if packages become built in parallel, leading to a race condition on the creation of the "nc" link. Moreover, netcat is as shy as BusyBox and would not override an existing file/link, so we must remove $(TARGET_DIR)/usr/bin/nc in advance.
Of course this still leaves a race conditon if other netcat competitors but we must assume thet the user is a grown-up person who knows what is doing.
Quoted 8 lines
It seems you are using a custom busybox config file because the netcat applet is disabled by default.
I'm agree, the dependency on busybox is missing but the
TARGET_HOOKSdoesn't seems necessary. I removed it and netcat package is able to override the busybox symlink.
/usr/bin/install-c netcat output/target/usr/bin/netcat
And anyway, in the context of PPS we will eventually have to reverse the
busybox dependencies, i.e. busybox will depend on netcat.
Quoted 2 lines
Maybe we should check if other packages depending on
BR2_PACKAGE_BUSYBOX_SHOW_OTHERShave a dependency on busybox.
check-uniq-files should cover this.
Regards,
Arnout
Quoted 37 lines
Best regards,
RomainQuoted 17 lines
Signed-off-by Carlos Santos <[email protected]>--- package/netcat/netcat.mk | 11 +++++++++++ 1 file changed, 11 insertions(+)package/netcat/netcat.mk +2
-0@@ -9,4 +9,15 @@ NETCAT_SITE = http://downloads.sourceforge.net/project/netcat/netcat/$(NETCAT_VE NETCAT_LICENSE = GPL-2.0+ NETCAT_LICENSE_FILES = COPYING +# Ensure Busybox gets built/installed before, so that this package +# overrides Busybox nc. We must remove an existing file/link becausepackage/netcat/netcat.mk NETCAT_SITE = http://downloads.sourceforge.net/project/netcat/netcat/$(NETCAT_VE · line 23
Quoted 10 lines
package/netcat/netcat.mk +9
-0+# netcat is as shy as Busybox and would not override existing files. +ifeq ($(BR2_PACKAGE_BUSYBOX),y) +NETCAT_DEPENDENCIES += busybox +define NETCAT_RMOVE_NC_LINK + rm -f $(TARGET_DIR)/usr/bin/nc +endef +NETCAT_PRE_INSTALL_TARGET_HOOKS += NETCAT_RMOVE_NC_LINK +endif + $(eval $(autotools-package))_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 netcat: add forced dependence on BusyBox
Arnout, All,
On 2018-03-31 15:03 +0200, Arnout Vandecappelle spake thusly:
Quoted 16 lines · Romain Naour
Quoted 15 lines
Hi Carlos,
Le 12/10/2017 ? 17:14, Carlos Santos a ?crit?:
Quoted 8 lines
It may be necessary if packages become built in parallel, leading to a race condition on the creation of the "nc" link. Moreover, netcat is as shy as BusyBox and would not override an existing file/link, so we must remove $(TARGET_DIR)/usr/bin/nc in advance.
Of course this still leaves a race conditon if other netcat competitors but we must assume thet the user is a grown-up person who knows what is doing.
It seems you are using a custom busybox config file because the netcat applet is disabled by default.
Quoted 8 lines
Quoted 5 lines
I'm agree, the dependency on busybox is missing but the
TARGET_HOOKSdoesn't seems necessary. I removed it and netcat package is able to override the busybox symlink.
/usr/bin/install-c netcat output/target/usr/bin/netcatAnd anyway, in the context of PPS we will eventually have to reverse the
busybox dependencies, i.e. busybox will depend on netcat.
Actually, we can do that even before PPS...
Regards,
Yann E. MORIN.
Quoted 57 lines
Quoted 2 lines
Maybe we should check if other packages depending on
BR2_PACKAGE_BUSYBOX_SHOW_OTHERShave a dependency on busybox.check-uniq-files should cover this.
Regards,
ArnoutQuoted 37 lines
Best regards,
RomainQuoted 17 lines
Signed-off-by Carlos Santos <[email protected]>--- package/netcat/netcat.mk | 11 +++++++++++ 1 file changed, 11 insertions(+)package/netcat/netcat.mk +2
-0@@ -9,4 +9,15 @@ NETCAT_SITE = http://downloads.sourceforge.net/project/netcat/netcat/$(NETCAT_VE NETCAT_LICENSE = GPL-2.0+ NETCAT_LICENSE_FILES = COPYING +# Ensure Busybox gets built/installed before, so that this package +# overrides Busybox nc. We must remove an existing file/link becausepackage/netcat/netcat.mk NETCAT_SITE = http://downloads.sourceforge.net/project/netcat/netcat/$(NETCAT_VE · line 23
Quoted 10 lines
package/netcat/netcat.mk +9
-0+# netcat is as shy as Busybox and would not override existing files. +ifeq ($(BR2_PACKAGE_BUSYBOX),y) +NETCAT_DEPENDENCIES += busybox +define NETCAT_RMOVE_NC_LINK + rm -f $(TARGET_DIR)/usr/bin/nc +endef +NETCAT_PRE_INSTALL_TARGET_HOOKS += NETCAT_RMOVE_NC_LINK +endif + $(eval $(autotools-package))_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildrootSignature · 10 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 netcat: add forced dependence on BusyBox
In reply to Romain NaourQuoted 12 lines · Romain Naour
Hi Carlos,
Le 12/10/2017 ? 17:14, Carlos Santos a ?crit?:
Quoted 8 lines
It may be necessary if packages become built in parallel, leading to a race condition on the creation of the "nc" link. Moreover, netcat is as shy as BusyBox and would not override an existing file/link, so we must remove $(TARGET_DIR)/usr/bin/nc in advance.
Of course this still leaves a race conditon if other netcat competitors but we must assume thet the user is a grown-up person who knows what is doing.
Quoted 8 lines
It seems you are using a custom busybox config file because the netcat applet is disabled by default.
I'm agree, the dependency on busybox is missing but the
TARGET_HOOKSdoesn't seems necessary. I removed it and netcat package is able to override the busybox symlink.
/usr/bin/install-c netcat output/target/usr/bin/netcat
I've applied, after removing the unneeded removal of nc.
If it turns out to be needed after all, please submit a follow-up patch.
Regards,
Arnout
Quoted 3 lines
Maybe we should check if other packages depending on
BR2_PACKAGE_BUSYBOX_SHOW_OTHERShave a dependency on busybox.
[snip]
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 netcat: add forced dependence on BusyBox
Quoted 22 lines · Arnout Vandecappelle
Quoted 19 lines · Romain Naour
Hi Carlos,
Le 12/10/2017 ? 17:14, Carlos Santos a ?crit?:
Quoted 8 lines
It may be necessary if packages become built in parallel, leading to a race condition on the creation of the "nc" link. Moreover, netcat is as shy as BusyBox and would not override an existing file/link, so we must remove $(TARGET_DIR)/usr/bin/nc in advance.
Of course this still leaves a race conditon if other netcat competitors but we must assume thet the user is a grown-up person who knows what is doing.
It seems you are using a custom busybox config file because the netcat applet is disabled by default.
I'm agree, the dependency on busybox is missing but the
TARGET_HOOKSdoesn't seems necessary. I removed it and netcat package is able to override the busybox symlink.
Quoted 5 lines
Quoted 1 line
/usr/bin/install-c netcat output/target/usr/bin/netcatI've applied, after removing the unneeded removal of nc.
If it turns out to be needed after all, please submit a follow-up patch.
OK, so it *was* needed, so I pushed a follow-up commit that does the removal.
I've done that unconditionally, though, the 'nc' could come from somewhere else
as well.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH v4 1/1 nmap: add option to build/install ncat
In reply to Carlos SantosHello,
Quoted 17 lines · Carlos Santos
Ncat is a much-improved reimplementation of the venerable Netcat and is compatible with uClibc and musl. It provides features not available in the ancient GNU netcat and its Busybox double like IPv6, proxies, and Unix sockets.
Tha nmap package now installs ncat if the
BR2_PACKAGE_NMAP_NCAToption is selected. The other programs (nmap, ndiff, etc.) are chosen via theBR2_PACKAGE_NMAP_NMAPoption.We symlink 'nc' to ncat if neiter netcat nor netcat-openbsd is selected, even though ncat does not have the same interface as netcat-openbsd. However, since Fedora/RHEL install nmap-ncat as 'nc', it can be assumed that packages that depend on 'nc' know how to deal with this diversity. For example, the virt-manager package does that. Also user-supplied scripts can be assumed to do the right thing, since the user also selects whether nmap-ncat, netcat or netcat-openbsd is installed.
Quoted 1 line
Signed-off-by Carlos Santos <[email protected]>
We looked at this in further details with Arnout, and we still didn't like the special casing for the ncat-only case. In addition, it is weird to have suboptions for nmap and ncat, while the package also installs nping and ndiff.
So instead, I've added sub-options for nmap, ncat, ndiff and nping, and then I've played with make targets to only build/install what's needed. The nmap Makefile.in conveniently offers the following make targets:
nmap, build-ncat, build-nping, build-ndiff
to build the respective programs, and:
install-nmap, install-ncat, install-nping, install-ndiff
to install the respective programs.
I've used this solution, which makes the package a lot cleaner and easier to read I believe. See the final commit at
https://git.buildroot.org/buildroot/commit/?id=55ec9b4e40b08a11cb9c1662c427c8d58351924a.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com