Skip to content

Commit

Permalink
Merge pull request Ettercap#992 from koeppea/openbsd-build-fixes
Browse files Browse the repository at this point in the history
OpenBSD build fixes
  • Loading branch information
LocutusOfBorg authored Nov 29, 2022
2 parents b1686d4 + c426337 commit 4ce2d46
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 19 deletions.
14 changes: 14 additions & 0 deletions bundled_deps/libnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ set(LIBNET_LIB_DIR ${LIBNET_PREFIX}/lib)
set(LIBNET_INCLUDE_DIR ${LIBNET_PREFIX}/include)
set(LIBNET_LIBRARY ${LIBNET_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}net${CMAKE_STATIC_LIBRARY_SUFFIX})

if(OS_BSD_OPEN)
# On OpenBSD, timeb.h has been dropped since quite some time
# Actually the libnet code doesn't really depend on it
# so the patch just removes the unnecessary #include <sys/timeb.h>
set(LIBNET_TIMEB_PATCH ${CMAKE_CURRENT_SOURCE_DIR}/libnet-timeb.patch)
endif()

if(OS_BSD_FREE)
# On FreeBSD, arpa/inet.h does not include netinet/in.h even though
# it's available and contains the required symbols. So the patch
# includes this header file explicitely on FreeBSD.
set(LIBNET_IN_H_PATCH ${CMAKE_CURRENT_SOURCE_DIR}/libnet-in.h.patch)
endif()

# Configure the Makefile wrapper. The purpose of this wrapper is to set up
# the environment for building libnet. ExternalProject_Add doesn't
# support setting up any sort of environment, nor does it handle arguments to
Expand Down
10 changes: 10 additions & 0 deletions bundled_deps/libnet/libnet-in.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/include/libnet.h 2012-03-06 01:45:46.000000000 +0100
+++ b/include/libnet.h 2020-01-11 10:01:52.877539205 +0100
@@ -100,6 +100,7 @@

#if !defined(__WIN32__)
# include <arpa/inet.h>
+# include <netinet/in.h>
# include <sys/time.h>
# include <netdb.h>
#endif /* __WIN32__ */
10 changes: 10 additions & 0 deletions bundled_deps/libnet/libnet-timeb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/src/libnet_link_bpf.c 2012-03-19 17:59:50.000000000 +0100
+++ b/src/libnet_link_bpf.c 2020-01-05 23:28:18.034699834 +0100
@@ -28,7 +28,6 @@
*/

#include <sys/param.h> /* optionally get BSD define */
-#include <sys/timeb.h>
#include <sys/file.h>
#include <sys/ioctl.h>

8 changes: 8 additions & 0 deletions bundled_deps/libnet/libnet_build_wrapper.sh.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
#!/bin/sh
if [ -n "@LIBNET_TIMEB_PATCH@" ]; then
patch -fsp1 < "@LIBNET_TIMEB_PATCH@"
fi

if [ -n "@LIBNET_IN_H_PATCH@" ]; then
patch -fsp1 < "@LIBNET_IN_H_PATCH@"
fi

make PREFIX="@EXPORT_PREFIX@" CFLAGS="@EXPORT_C_FLAGS@" CC="@EXPORT_CC@"
7 changes: 5 additions & 2 deletions cmake/Modules/EttercapHeadersCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ check_include_file(getopt.h HAVE_GETOPT_H)
check_include_file(ctype.h HAVE_CTYPE_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)

check_include_file(arpa/nameser.h HAVE_ARPA_NAMESER_H)
# The nameser.h on OpenBSD is not usable, falling back to missing nameser.h
if(NOT OS_BSD_OPEN)
check_include_file(arpa/nameser.h HAVE_ARPA_NAMESER_H)
endif()

check_include_file(ltdl.h HAVE_LTDL_H)
check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(libgen.h HAVE_LIBGEN_H)
check_include_file(libgen.h HAVE_LIBGEN_H)
8 changes: 6 additions & 2 deletions cmake/Modules/FindLIBNET.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
#

# Look for the header file
find_path(LIBNET_INCLUDE_DIR NAMES libnet.h PATH_SUFFIXES libnet11)
find_path(LIBNET_INCLUDE_DIR
NAMES libnet.h
PATH_SUFFIXES libnet11 libnet-1.1)
mark_as_advanced(LIBNET_INCLUDE_DIR)

#Look for the library
find_library(LIBNET_LIBRARY NAMES net libnet PATH_SUFFIXES libnet11)
find_library(LIBNET_LIBRARY
NAMES net libnet
PATH_SUFFIXES libnet11 libnet-1.1)
mark_as_advanced(LIBNET_LIBRARY)

# Make sure we've got an include dir.
Expand Down
3 changes: 2 additions & 1 deletion include/ec_resolv.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
#ifndef OS_BSD_OPEN
#include <arpa/nameser_compat.h>
#endif
#include <resolv.h>
#else
#include <missing/nameser.h>
#endif

#include <resolv.h>

/*
* glibc 2.1.x does not have new NG_GET* macros...
* implement the hack here.
Expand Down
9 changes: 8 additions & 1 deletion include/missing/nameser.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ typedef enum __ns_cert_types {
(cp) += NS_INT32SZ; \
} while (0)

#ifndef __THROW
#define __THROW
#endif
__BEGIN_DECLS
int ns_msg_getflag (ns_msg, int) __THROW;
u_int ns_get16 (const u_char *) __THROW;
Expand Down Expand Up @@ -528,7 +531,11 @@ int ns_samename (const char *, const char *) __THROW;
__END_DECLS

#ifdef BIND_4_COMPAT
#include <arpa/nameser_compat.h>
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser_compat.h>
#else
#include <missing/nameser_compat.h>
#endif
#endif

#endif /* !_ARPA_NAMESER_H_ */
Expand Down
13 changes: 1 addition & 12 deletions src/ec_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,7 @@
#include <ifaddrs.h>
#endif

#if defined(OS_BSD_OPEN)
/* OPENBSD needs 0 */
#define PCAP_TIMEOUT 0
#elif defined(OS_SOLARIS)
/* SOLARIS needs > 1 */
#define PCAP_TIMEOUT 10
#else
/* LINUX needs > 0 */
/* FREEBSD needs 1 */
/* MACOSX needs 1 */
#define PCAP_TIMEOUT 1
#endif
#define PCAP_TIMEOUT 1

struct source_entry {
struct iface_env iface;
Expand Down
2 changes: 1 addition & 1 deletion src/ec_sslwrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#define HAVE_OPENSSL_1_1_0
#endif

#if (OPENSSL_VERSION_NUMBER >= 0x10101000L) && !defined(LIBRESSL_VERSION_NUMBER)
#if (OPENSSL_VERSION_NUMBER >= 0x10101000L) && !defined(LIBRESSL_VERSION_NUMBER) && !defined OS_BSD_OPEN
#define HAVE_OPENSSL_1_1_1
#endif

Expand Down

0 comments on commit 4ce2d46

Please sign in to comment.