Bug 196065 - [PATCH] security/nmap Compilation test omits native-xtools environment (poudriere + native-xtools)
Summary: [PATCH] security/nmap Compilation test omits native-xtools environment (poudr...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Many People
Assignee: Olli Hauer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-17 16:13 UTC by Mikael Urankar
Modified: 2015-09-27 10:58 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (ohauer)


Attachments
Patch to add test for nxb-bin (527 bytes, patch)
2014-12-17 16:13 UTC, Mikael Urankar
no flags Details | Diff
use CHOSEN_COMPILER_TYPE (836 bytes, patch)
2014-12-19 15:13 UTC, Mikael Urankar
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikael Urankar freebsd_committer 2014-12-17 16:13:12 UTC
Created attachment 150683 [details]
Patch to add test for nxb-bin

Fix similar to 193478, this time for native-xtools cross compile tools used by poudriere to build package for arm or mips, CC is defined as /nxb-bin/usr/bin/cc

build log on armv6:
http://mikael.urankar.free.fr/FreeBSD/arm/build_logs/nmap-6.47.log
Comment 1 Bugzilla Automation freebsd_committer 2014-12-17 16:13:12 UTC
Auto-assigned to maintainer ohauer@FreeBSD.org
Comment 2 Sean Bruno freebsd_committer 2014-12-18 20:39:08 UTC
This will only work on architectures where /nxb-bin/usr/bin/cc is really clang.

I'll have to modify this to not break the cross build for mips.

Probably something along the lines of an arch check.
Comment 3 Olli Hauer freebsd_committer 2014-12-18 20:53:09 UTC
(In reply to Sean Bruno from comment #2)
> This will only work on architectures where /nxb-bin/usr/bin/cc is really
> clang.
> 
> I'll have to modify this to not break the cross build for mips.
> 
> Probably something along the lines of an arch check.

Hi Sean,

feel free to to adjust the nmap port directly (you have my approval ;).
If possible add a comment about the addition directly to port so it is clear which platform needs the adjustment.
Comment 4 Mikael Urankar freebsd_committer 2014-12-19 15:13:27 UTC
Created attachment 150772 [details]
use CHOSEN_COMPILER_TYPE

Maybe we can use the CHOSEN_COMPILER_TYPE feature we have in the ports infrastructure (see attached patch)?
Comment 5 Olli Hauer freebsd_committer 2014-12-19 18:14:43 UTC
(In reply to mikael.urankar from comment #4)
> Created attachment 150772 [details]
> use CHOSEN_COMPILER_TYPE
> 
> Maybe we can use the CHOSEN_COMPILER_TYPE feature we have in the ports
> infrastructure (see attached patch)?

Hm, looks promising but I suspect 8.x will run into the wrong .if statement.
I'm not sure about 9.x which has gcc and clang in the base OS.
Comment 7 commit-hook freebsd_committer 2014-12-25 13:30:03 UTC
A commit references this bug:

Author: ohauer
Date: Thu Dec 25 13:29:30 UTC 2014
New revision: 375549
URL: https://svnweb.freebsd.org/changeset/ports/375549

Log:
  - fix build on arm/mips

  PR:			196065
  Submitted by:	mikael.urankar

Changes:
  head/security/nmap/Makefile
Comment 8 Olli Hauer freebsd_committer 2014-12-25 13:36:42 UTC
Patch was committed,

Thanks to Mikael for testing and providing the patch!
Comment 9 Olli Hauer freebsd_committer 2015-01-20 23:02:40 UTC
Hi Mikael and Sean,

could you do a functional test with nmap?

It seems something on the FreeBSD stack has changed on current.

There is the following constrict in nmap/libnetutil/netutil.cc that seems to be no longer valid for current and generates corrupt IP checksums.

snippet from nmap/libnetutil/netutil.cc:

#if FREEBSD || BSDI || NETBSD || DEC || MACOSX
  ip->ip_len = ntohs(ip->ip_len);
  ip->ip_off = ntohs(ip->ip_off);
#endif

res = Sendto("send_ip_packet_sd", sd, packet, packetlen, 0,
...
#if FREEBSD || BSDI || NETBSD || DEC || MACOSX
  ip->ip_len = htons(ip->ip_len);
  ip->ip_off = htons(ip->ip_off);
#endif

Simple patch to disable 
http://people.freebsd.org/~ohauer/diffs/patch-libnetutil_netutil.cc
Comment 10 Mikael Urankar freebsd_committer 2015-01-21 10:35:58 UTC
I confirm the issue on head (r277215):
sendto in send_ip_packet_sd: sendto(5, packet, 44, 0, 192.168.0.254, 16) => Invalid argument
Offending packet: TCP 192.168.0.22:49911 > 192.168.0.254:21 S ttl=58 id=18569 iplen=11264  seq=2240940697 win=1024 <mss 1460>

It goes away with your patch.
Comment 11 Sean Bruno freebsd_committer 2015-05-07 15:47:50 UTC
(In reply to Olli Hauer from comment #9)

I think this should be good to commit no?  Or is this being upstreamed?
Comment 12 Olli Hauer freebsd_committer 2015-09-27 10:18:15 UTC
It is send to upstream, and a fix is included in BETA5 (but I think with the wrong __FreeBSD_version)

I will commit BETA5 with the proper fix [1], also remove the gcc/clang workarounds [2]

1) PR 202139
2) PR 200558
Comment 13 commit-hook freebsd_committer 2015-09-27 10:33:25 UTC
A commit references this bug:

Author: ohauer
Date: Sun Sep 27 10:32:33 UTC 2015
New revision: 398033
URL: https://svnweb.freebsd.org/changeset/ports/398033

Log:
  - update to 6.49BETA5
  - use DOCS instead PORTDOCS
  - remove gcc workaround [1]
  - (hopefully) use the correct __FreeBSD_version for SOCK_RAW

  Changelog:
  https://nmap.org/changelog.html

  PR:		196065 [1]
  PR:		200558 [2]
  PR:		202139 [3]

  Submitted by:	sbruno@ , mikael.urankar@gmail.com [1]
  Submitted by:	truckman@ [2]
  Submitted by:	trasz@ [3]

Changes:
  head/security/nmap/Makefile
  head/security/nmap/distinfo
  head/security/nmap/files/patch-Makefile.in
  head/security/nmap/files/patch-configure
  head/security/nmap/files/patch-libdnet-stripped__configure
  head/security/nmap/files/patch-libdnet-stripped__src__eth-bsd.c
  head/security/nmap/files/patch-liblua-lua523
  head/security/nmap/files/patch-liblua__Makefile
  head/security/nmap/files/patch-liblua__liolib.c
  head/security/nmap/files/patch-libnetutil_netutil.cc
  head/security/nmap/files/patch-nmap.cc
  head/security/nmap/files/patch-output.cc
  head/security/nmap/files/patch-tcpip.cc
  head/security/nmap/pkg-plist
Comment 14 Olli Hauer freebsd_committer 2015-09-27 10:58:20 UTC
Both issues should be solved with the last commit.

Hopefully the fix from PR 200558 (removing all the compiler stuff) was the right thing.