From 40be5dd2df4e57237a44fee596e8c2df232686d2 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 23 Apr 2018 13:47:32 -0500 Subject: tcp-wrappers: patch up crufty code, fix w/musl --- pkgs/os-specific/linux/tcp-wrappers/cdecls.patch | 31 +++ pkgs/os-specific/linux/tcp-wrappers/default.nix | 8 + .../tcp-wrappers/tcp-wrappers-7.6-headers.patch | 295 +++++++++++++++++++++ 3 files changed, 334 insertions(+) create mode 100644 pkgs/os-specific/linux/tcp-wrappers/cdecls.patch create mode 100644 pkgs/os-specific/linux/tcp-wrappers/tcp-wrappers-7.6-headers.patch (limited to 'pkgs/os-specific/linux/tcp-wrappers') diff --git a/pkgs/os-specific/linux/tcp-wrappers/cdecls.patch b/pkgs/os-specific/linux/tcp-wrappers/cdecls.patch new file mode 100644 index 00000000000..eee640e8a82 --- /dev/null +++ b/pkgs/os-specific/linux/tcp-wrappers/cdecls.patch @@ -0,0 +1,31 @@ +__BEGIN_DECLS/__END_DECLS are BSD specific and not defined in musl +glibc and uclibc had sys/cdefs.h doing it. + +Upstream-Status: Pending +Signed-off-by: Khem Raj + +Index: tcp_wrappers_7.6/tcpd.h +=================================================================== +--- tcp_wrappers_7.6.orig/tcpd.h ++++ tcp_wrappers_7.6/tcpd.h +@@ -11,7 +11,9 @@ + #include + #include + +-__BEGIN_DECLS ++#ifdef __cplusplus ++extern "C" { ++#endif + + /* Structure to describe one communications endpoint. */ + +@@ -252,6 +254,8 @@ extern char *fix_strtok(); + extern char *my_strtok(); + #endif + +-__END_DECLS ++#ifdef __cplusplus ++} ++#endif + + #endif diff --git a/pkgs/os-specific/linux/tcp-wrappers/default.nix b/pkgs/os-specific/linux/tcp-wrappers/default.nix index 667189009cc..e3aae30babc 100644 --- a/pkgs/os-specific/linux/tcp-wrappers/default.nix +++ b/pkgs/os-specific/linux/tcp-wrappers/default.nix @@ -25,6 +25,14 @@ in stdenv.mkDerivation rec { substituteInPlace debian/patches/13_shlib_weaksym --replace STRINGS STRINGDEFS ''; + # Fix __BEGIN_DECLS usage (even if it wasn't non-standard, this doesn't include sys/cdefs.h) + patches = [ ./cdecls.patch ]; + + postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + substituteInPlace Makefile \ + --replace '-DNETGROUP' '-DUSE_GETDOMAIN' + ''; + buildInputs = [ libnsl ]; makeFlags = [ "REAL_DAEMON_DIR=$(out)/bin" "linux" ]; diff --git a/pkgs/os-specific/linux/tcp-wrappers/tcp-wrappers-7.6-headers.patch b/pkgs/os-specific/linux/tcp-wrappers/tcp-wrappers-7.6-headers.patch new file mode 100644 index 00000000000..328a4a10261 --- /dev/null +++ b/pkgs/os-specific/linux/tcp-wrappers/tcp-wrappers-7.6-headers.patch @@ -0,0 +1,295 @@ +--- a/options.c ++++ b/options.c +@@ -34,6 +34,8 @@ + + /* System libraries. */ + ++#include ++#include + #include + #include + #include +--- a/safe_finger.c ++++ b/safe_finger.c +@@ -20,6 +20,11 @@ + + /* System libraries */ + ++#include ++#include ++#include ++#include ++#include + #include + #include + #include +@@ -27,7 +31,7 @@ + #include + #include + +-extern void exit(); ++int pipe_stdin(char **argv); + + /* Local stuff */ + +--- a/scaffold.c ++++ b/scaffold.c +@@ -10,6 +10,7 @@ + + /* System libraries. */ + ++#include + #include + #include + #include +@@ -27,7 +27,4 @@ + #endif + +-#ifndef INET6 +-extern char *malloc(); +-#endif + + /* Application-specific. */ +--- a/shell_cmd.c ++++ b/shell_cmd.c +@@ -14,6 +14,10 @@ + + /* System libraries. */ + ++#include ++#include ++#include ++#include + #include + #include + #include +@@ -25,8 +25,6 @@ + #include + #include + +-extern void exit(); +- + /* Local stuff. */ + + #include "tcpd.h" +--- a/tcpdchk.c ++++ b/tcpdchk.c +@@ -20,6 +20,8 @@ + + /* System libraries. */ + ++#include ++#include + #include + #include + #ifdef INET6 +@@ -35,10 +36,7 @@ + #include + #include + +-extern int errno; +-extern void exit(); +-extern int optind; +-extern char *optarg; ++int cidr_mask_addr(char *str); + + #ifndef INADDR_NONE + #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ +--- a/clean_exit.c ++++ b/clean_exit.c +@@ -13,8 +13,8 @@ + #endif + + #include +- +-extern void exit(); ++#include ++#include + + #include "tcpd.h" + +--- a/hosts_access.c ++++ b/hosts_access.c +@@ -23,6 +23,7 @@ + + /* System libraries. */ + ++#include + #include + #ifdef INT32_T + typedef uint32_t u_int32_t; +@@ -43,8 +44,8 @@ + #include + #endif + +-extern char *fgets(); +-extern int errno; ++static int match_pattern_ylo(const char *s, const char *pattern); ++int cidr_mask_addr(char *str); + + #ifndef INADDR_NONE + #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ +--- a/inetcf.c ++++ b/inetcf.c +@@ -9,15 +9,14 @@ + static char sccsid[] = "@(#) inetcf.c 1.7 97/02/12 02:13:23"; + #endif + ++#include + #include + #include + #include + #include + #include + +-extern int errno; +-extern void exit(); +- ++#include "scaffold.h" + #include "tcpd.h" + #include "inetcf.h" + +--- a/percent_x.c ++++ b/percent_x.c +@@ -16,12 +16,12 @@ + + /* System libraries. */ + ++#include ++#include + #include + #include + #include + +-extern void exit(); +- + /* Local stuff. */ + + #include "tcpd.h" +--- a/rfc931.c ++++ b/rfc931.c +@@ -15,6 +15,7 @@ + + /* System libraries. */ + ++#include + #include + #include + #include +--- a/tcpd.c ++++ b/tcpd.c +@@ -16,6 +16,7 @@ + + /* System libraries. */ + ++#include + #include + #include + #include +@@ -39,6 +39,8 @@ + #include "patchlevel.h" + #include "tcpd.h" + ++void fix_options(struct request_info *request); ++ + int allow_severity = SEVERITY; /* run-time adjustable */ + int deny_severity = LOG_WARNING; /* ditto */ + +--- a/tcpdmatch.c ++++ b/tcpdmatch.c +@@ -19,6 +19,8 @@ + + /* System libraries. */ + ++#include ++#include + #include + #include + #include +@@ -30,9 +32,6 @@ + #include + #include + +-extern void exit(); +-extern int optind; +-extern char *optarg; + + #ifndef INADDR_NONE + #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ +--- a/update.c ++++ b/update.c +@@ -19,6 +19,7 @@ + + /* System libraries */ + ++#include + #include + #include + #include +--- a/misc.c ++++ b/misc.c +@@ -14,11 +14,10 @@ + #include + #include + #include ++#include + + #include "tcpd.h" + +-extern char *fgets(); +- + #ifndef INADDR_NONE + #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ + #endif +--- a/fix_options.c ++++ b/fix_options.c +@@ -32,6 +32,7 @@ + + /* fix_options - get rid of IP-level socket options */ + ++void + fix_options(request) + struct request_info *request; + { +@@ -38,11 +38,8 @@ + #ifdef IP_OPTIONS + unsigned char optbuf[BUFFER_SIZE / 3], *cp; + char lbuf[BUFFER_SIZE], *lp; +-#ifdef __GLIBC__ +- size_t optsize = sizeof(optbuf), ipproto; +-#else +- int optsize = sizeof(optbuf), ipproto; +-#endif ++ socklen_t optsize = sizeof(optbuf); ++ int ipproto; + struct protoent *ip; + int fd = request->fd; + unsigned int opt; +--- a/socket.c ++++ b/socket.c +@@ -95,11 +95,7 @@ + static struct sockaddr_in client; + static struct sockaddr_in server; + #endif +-#ifdef __GLIBC__ +- size_t len; +-#else +- int len; +-#endif ++ socklen_t len; + char buf[BUFSIZ]; + int fd = request->fd; + +@@ -430,11 +426,7 @@ + #else + struct sockaddr_in sin; + #endif +-#ifdef __GLIBC__ +- size_t size = sizeof(sin); +-#else +- int size = sizeof(sin); +-#endif ++ socklen_t size; + + /* + * Eat up the not-yet received datagram. Some systems insist on a -- cgit 1.4.1