Nmap Development mailing list archives

Re: fix to build nmap on some OpenBSD archs


From: David Fifield <david () bamsoftware com>
Date: Mon, 2 Aug 2010 16:02:53 -0700

On Thu, Jul 29, 2010 at 09:02:24AM +0200, Sebastian Reitenbach wrote:
Hi,
On Thursday 29 July 2010 05:38:12 am David Fifield wrote:
On Thu, Jul 08, 2010 at 12:58:57PM +0200, Sebastian Reitenbach wrote:
OpenBSD sparc and some others have gcc-2.95 as default compiler. Appended
patch against nmap 5.21 fixes compilation, so that I can actually use it
on my sparc.

Thanks. I see that this patch is mostly about not mixing code and
declarations in C code (not C++, where it is allowed). I have committed
that.

the patch regarding nsock/src/nsock_pcap.c was already in the OpenBSD
ports tree, only parts of it are responsible to fix the build with gcc2.
The part where I am not responsible and not sure what it fixes is the
following:

@@ -325,11 +323,14 @@ int do_actual_pcap_read(msevent *nse)
 void nse_readpcap(nsock_event nsee,
        const unsigned char **l2_data, size_t *l2_len,
        const unsigned char **l3_data, size_t *l3_len,
-       size_t *packet_len, struct timeval *ts)
+       size_t *packet_len, struct bpf_timeval *ts)
 {
        msevent *nse = (msevent *)nsee;

I guess the timeval is not existing.

I'm not sure about this either. You say it is necessary for you to build
on OpenBSD? What if you use the --with-libpcap=included configure
option? I tried applying this part of the patch on x86_64 GNU/Linux, and
got the error

I rechecked and saw that there are other patches needed to make this work:
http://www.openbsd.org/cgi-bin/cvsweb/ports/net/nmap/patches/patch-
nsock_include_nsock_h
http://www.openbsd.org/cgi-bin/cvsweb/ports/net/nmap/patches/patch-
nsock_src_nsock_pcap_h

Those are also needed to get nmap compiled on OpenBSD, also with newer gcc, I 
tried on i386 with gcc-4.2.

I tried to remove above two patches and removed the patch above from 
nsock_pcap.c, and tried to rebuild nmap, but I got this error:

cc -c -I/usr/local/include -I/usr/include -I../../nbase -DHAVE_CONFIG_H -
DNSOCK_VERSION=\"0.02\" -D_FORTIFY_SOURCE=2 -I../include -I../../libpcap -
DIWASHERECFLAGS -I/usr/local/include -Wall   nsock_pcap.c -o nsock_pcap.o
nsock_pcap.c: In function 'do_actual_pcap_read':
nsock_pcap.c:295: error: incompatible types in assignment
gmake[1]: *** [nsock_pcap.o] Error 1
gmake[1]: Leaving directory `/home/ports/pobj/nmap-5.21/nmap-5.21/nsock/src'
gmake: *** [nsock_build] Error 2
*** Error code 2

Hmm, this looks like the patches weren't undone completely. The incompatible
types are probably bpf_timeval and timeval.

I tried compiling today on OpenBSD, with no patches at all, and did not have a
problem compiling Nsock.

Nmap is compiled with the following configure parameters:
              --with-libpcap=included \
                --with-openssl=/usr \
                --with-libdnet=/usr/local \
                --with-liblua=/usr/local \
                --with-libpcre=/usr/local \
                --with-mandir=/usr/local/man \
                --disable-nls

I exchanged the --with-libpcap=/usr with --with-libpcap=included and tried to 
rebuild it but ran into the following error:

===>  Building for nmap-5.21
Makefile:341: makefile.dep: No such file or directory
c++ -MM -I/usr/include/lua -I/usr/local/include -I/usr/local/include -
I/usr/local/include  -I/usr/local/include -I/usr/include -Ilibpcap -Inbase -
Insock/include main.cc nmap.cc targets.cc tcpip.cc nmap_error.cc utils.cc 
idle_scan.cc osscan.cc osscan2.cc output.cc payload.cc scan_engine.cc 
timing.cc charpool.cc services.cc protocols.cc nmap_rpc.cc portlist.cc 
NmapOps.cc TargetGroup.cc Target.cc FingerPrintResults.cc service_scan.cc 
NmapOutputTable.cc MACLookup.cc nmap_tty.cc nmap_dns.cc traceroute.cc 
portreasons.cc nse_main.cc nse_nsock.cc nse_fs.cc nse_nmaplib.cc nse_debug.cc 
nse_pcrelib.cc nse_binlib.cc nse_bit.cc nse_openssl.cc nse_ssl_cert.cc  > 
makefile.dep
gmake: *** No rule to make target `libpcap/Makefile', needed by `pcap_build'.  
Stop.

For this, please try doing a "gmake distclean" before configuring with
--with-pcap=included.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: