From 4896e9c36e6834039a2eb98e6799ca8a75b1048b Mon Sep 17 00:00:00 2001
From: Andy Walsh <andy.walsh44+github@gmail.com>
Date: Tue, 7 Aug 2018 20:34:45 +0200
Subject: [PATCH] libtirpc: enable host build

* include /etc/netconfig
* cleanup old patches
* update via patch to 1.0.4-rc2

Signed-off-by: Andy Walsh <andy.walsh44+github@gmail.com>
---
 libs/libtirpc/Makefile                        |  19 +-
 libs/libtirpc/patches/001-musl.patch          |  18 ++
 .../patches/002-libtirpc-1.0.4-rc2.patch      | 274 ++++++++++++++++++
 ...parts-of-TIRPC-requiring-NIS-support.patch |  48 ---
 ...t-and-musl-does-not-install-rpcent.h.patch |  35 ---
 ...Disable-DES-authentification-support.patch | 142 ---------
 .../patches/04-musl-rpc-fix-types.h.patch     |  11 -
 7 files changed, 302 insertions(+), 245 deletions(-)
 create mode 100644 libs/libtirpc/patches/001-musl.patch
 create mode 100644 libs/libtirpc/patches/002-libtirpc-1.0.4-rc2.patch
 delete mode 100644 libs/libtirpc/patches/01-Disable-parts-of-TIRPC-requiring-NIS-support.patch
 delete mode 100644 libs/libtirpc/patches/02-uClibc-without-RPC-support-and-musl-does-not-install-rpcent.h.patch
 delete mode 100644 libs/libtirpc/patches/03-Disable-DES-authentification-support.patch
 delete mode 100644 libs/libtirpc/patches/04-musl-rpc-fix-types.h.patch

diff --git a/libs/libtirpc/Makefile b/libs/libtirpc/Makefile
index 1e42b14f6..9e50f0b4f 100644
--- a/libs/libtirpc/Makefile
+++ b/libs/libtirpc/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libtirpc
 PKG_VERSION:=1.0.3
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_URL:=@SF/libtirpc
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
@@ -19,9 +19,11 @@ PKG_MAINTAINER:=Andy Walsh <andy.walsh44+github@gmail.com>
 PKG_LICENSE:=BSD-3-Clause
 
 PKG_FIXUP:=autoreconf
+PKG_REMOVE_FILES:=autogen.sh aclocal.m4
 PKG_INSTALL:=1
 
 include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
 
 define Package/libtirpc
   SECTION:=libs
@@ -32,18 +34,16 @@ define Package/libtirpc
 endef
 
 CONFIGURE_ARGS += --disable-gssapi
-# Info from Buildroot Makefile
-# getrpcby{number,name} are only provided if 'GQ' is defined
-TARGET_CFLAGS += -DGQ
-#CONFIGURE_VARS += \
-#	GSSGLUE_LIBS="-lkrb5 -lk5crypto -l:libcom_err.so.3 -lkeyutils -lresolv -gssapi_krb5" \
-#	GSSGLUE_CFLAGS=-I$(STAGING_DIR)/usr/include/krb5/
+HOST_CONFIGURE_ARGS += --disable-gssapi
 
-#EXTRA_LDFLAGS := -lgssapi_krb5
+TARGET_CFLAGS += -DGQ
+HOST_CFLAGS += -DGQ
 
 define Package/libtirpc/install
 	$(INSTALL_DIR) $(1)/usr/lib
-	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libtirpc.so* $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libtirpc.so* $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/etc
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/netconfig $(1)/etc/
 endef
 
 define Build/InstallDev
@@ -56,4 +56,5 @@ define Build/InstallDev
 	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libtirpc.pc $(1)/usr/lib/pkgconfig/libtirpc.pc
 endef
 
+$(eval $(call HostBuild))
 $(eval $(call BuildPackage,libtirpc))
diff --git a/libs/libtirpc/patches/001-musl.patch b/libs/libtirpc/patches/001-musl.patch
new file mode 100644
index 000000000..0c3ce603e
--- /dev/null
+++ b/libs/libtirpc/patches/001-musl.patch
@@ -0,0 +1,18 @@
+Consider musl provided built-in defines
+
+Helps compile libtirpc with musl
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+--- ./tirpc/rpc/types.h.orig	2018-03-17 10:23:10.022055255 +0100
++++ ./tirpc/rpc/types.h	2018-03-17 10:23:30.877751656 +0100
+@@ -66,7 +66,7 @@
+ #define mem_free(ptr, bsize)	free(ptr)
+ 
+ 
+-#if defined __APPLE_CC__ || defined __FreeBSD__
++#if defined __APPLE_CC__ || defined __FreeBSD__ || !defined(__GLIBC__)
+ # define __u_char_defined
+ # define __daddr_t_defined
+ #endif
diff --git a/libs/libtirpc/patches/002-libtirpc-1.0.4-rc2.patch b/libs/libtirpc/patches/002-libtirpc-1.0.4-rc2.patch
new file mode 100644
index 000000000..35b38cffd
--- /dev/null
+++ b/libs/libtirpc/patches/002-libtirpc-1.0.4-rc2.patch
@@ -0,0 +1,274 @@
+diff --git a/src/clnt_dg.c b/src/clnt_dg.c
+index 04a2aba..eb5467f 100644
+--- a/src/clnt_dg.c
++++ b/src/clnt_dg.c
+@@ -160,15 +160,22 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz)
+ 	thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
+ 	mutex_lock(&clnt_fd_lock);
+ 	if (dg_fd_locks == (int *) NULL) {
+-		int cv_allocsz;
+-		size_t fd_allocsz;
+-		int dtbsize = __rpc_dtbsize();
++		size_t cv_allocsz, fd_allocsz;
++		unsigned int dtbsize = __rpc_dtbsize();
++
++		if ( (size_t) dtbsize > SIZE_MAX/sizeof(cond_t)) {
++			mutex_unlock(&clnt_fd_lock);
++			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
++			errno = EOVERFLOW;
++			goto err1;
++		}
+ 
+ 		fd_allocsz = dtbsize * sizeof (int);
+ 		dg_fd_locks = (int *) mem_alloc(fd_allocsz);
+ 		if (dg_fd_locks == (int *) NULL) {
+ 			mutex_unlock(&clnt_fd_lock);
+ 			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
++			errno = ENOMEM;
+ 			goto err1;
+ 		} else
+ 			memset(dg_fd_locks, '\0', fd_allocsz);
+@@ -180,6 +187,7 @@ clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz)
+ 			dg_fd_locks = (int *) NULL;
+ 			mutex_unlock(&clnt_fd_lock);
+ 			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
++			errno = ENOMEM;
+ 			goto err1;
+ 		} else {
+ 			int i;
+diff --git a/src/clnt_generic.c b/src/clnt_generic.c
+index e5a314f..3f3dabf 100644
+--- a/src/clnt_generic.c
++++ b/src/clnt_generic.c
+@@ -47,7 +47,6 @@
+ 
+ extern bool_t __rpc_is_local_host(const char *);
+ int __rpc_raise_fd(int);
+-extern int __binddynport(int fd);
+ 
+ #ifndef NETIDLEN
+ #define	NETIDLEN 32
+@@ -341,8 +340,7 @@ clnt_tli_create(int fd, const struct netconfig *nconf,
+ 		servtype = nconf->nc_semantics;
+ 		if (!__rpc_fd2sockinfo(fd, &si))
+ 			goto err;
+-		if (__binddynport(fd) == -1)
+-			goto err;
++		bindresvport(fd, NULL);
+ 	} else {
+ 		if (!__rpc_fd2sockinfo(fd, &si))
+ 			goto err;
+diff --git a/src/clnt_vc.c b/src/clnt_vc.c
+index 6098c3a..3d775c7 100644
+--- a/src/clnt_vc.c
++++ b/src/clnt_vc.c
+@@ -63,6 +63,7 @@
+ #include <string.h>
+ #include <unistd.h>
+ #include <signal.h>
++#include <stdint.h>
+ 
+ #include <rpc/rpc.h>
+ #include "rpc_com.h"
+@@ -201,14 +202,25 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz)
+ 	thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
+ 	mutex_lock(&clnt_fd_lock);
+ 	if (vc_fd_locks == (int *) NULL) {
+-		int cv_allocsz, fd_allocsz;
+-		int dtbsize = __rpc_dtbsize();
++		size_t cv_allocsz, fd_allocsz;
++		unsigned int dtbsize = __rpc_dtbsize();
++		struct rpc_createerr *ce = &get_rpc_createerr();
++
++		if ( (size_t) dtbsize > SIZE_MAX/sizeof(cond_t)) {
++			mutex_unlock(&clnt_fd_lock);
++			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
++			ce->cf_stat = RPC_SYSTEMERROR;
++			ce->cf_error.re_errno = EOVERFLOW;
++			goto err;
++		}
+ 
+ 		fd_allocsz = dtbsize * sizeof (int);
+ 		vc_fd_locks = (int *) mem_alloc(fd_allocsz);
+ 		if (vc_fd_locks == (int *) NULL) {
+ 			mutex_unlock(&clnt_fd_lock);
+ 			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
++			ce->cf_stat = RPC_SYSTEMERROR;
++			ce->cf_error.re_errno = ENOMEM;
+ 			goto err;
+ 		} else
+ 			memset(vc_fd_locks, '\0', fd_allocsz);
+@@ -221,6 +233,8 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz)
+ 			vc_fd_locks = (int *) NULL;
+ 			mutex_unlock(&clnt_fd_lock);
+ 			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
++			ce->cf_stat = RPC_SYSTEMERROR;
++			ce->cf_error.re_errno = ENOMEM;
+ 			goto err;
+ 		} else {
+ 			int i;
+diff --git a/src/rpc_soc.c b/src/rpc_soc.c
+index af6c482..5a6eeb7 100644
+--- a/src/rpc_soc.c
++++ b/src/rpc_soc.c
+@@ -67,8 +67,6 @@
+ 
+ extern mutex_t	rpcsoc_lock;
+ 
+-extern int __binddynport(int fd);
+-
+ static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t,
+     int *, u_int, u_int, char *, int);
+ static SVCXPRT *svc_com_create(int, u_int, u_int, char *);
+@@ -147,8 +145,7 @@ clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp, flags)
+ 	bindaddr.maxlen = bindaddr.len =  sizeof (struct sockaddr_in);
+ 	bindaddr.buf = raddr;
+ 
+-	if (__binddynport(fd) == -1)
+-		goto err;
++	bindresvport(fd, NULL);
+ 	cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers,
+ 				sendsz, recvsz);
+ 	if (cl) {
+diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c
+index a94fc73..e45736a 100644
+--- a/src/rpcb_clnt.c
++++ b/src/rpcb_clnt.c
+@@ -752,7 +752,7 @@ __try_protocol_version_2(program, version, nconf, host, tp)
+ 
+ 	client = getpmaphandle(nconf, host, &parms.r_addr);
+ 	if (client == NULL)
+-		return (NULL);
++		goto error;
+ 
+ 	/*
+ 	 * Set retry timeout.
+@@ -771,11 +771,11 @@ __try_protocol_version_2(program, version, nconf, host, tp)
+ 	if (clnt_st != RPC_SUCCESS) {
+ 		rpc_createerr.cf_stat = RPC_PMAPFAILURE;
+ 		clnt_geterr(client, &rpc_createerr.cf_error);
+-		return (NULL);
++		goto error;
+ 	} else if (port == 0) {
+ 		pmapaddress = NULL;
+ 		rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
+-		return (NULL);
++		goto error;
+ 	}
+ 	port = htons(port);
+ 	CLNT_CONTROL(client, CLGET_SVC_ADDR, (char *)&remote);
+@@ -789,14 +789,24 @@ __try_protocol_version_2(program, version, nconf, host, tp)
+ 			free(pmapaddress);
+ 			pmapaddress = NULL;
+ 		}
+-		return (NULL);
++		goto error;
+ 	}
+ 	memcpy(pmapaddress->buf, remote.buf, remote.len);
+ 	memcpy(&((char *)pmapaddress->buf)[sizeof (short)],
+ 			(char *)(void *)&port, sizeof (short));
+ 	pmapaddress->len = pmapaddress->maxlen = remote.len;
+ 
++	CLNT_DESTROY(client);
+ 	return pmapaddress;
++
++error:
++	if (client) {
++		CLNT_DESTROY(client);
++		client = NULL;
++
++	}
++	return (NULL);
++
+ }
+ #endif
+ 
+@@ -836,6 +846,7 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp)
+ 	struct netbuf *address = NULL;
+ 	rpcvers_t start_vers = RPCBVERS4;
+ 	struct netbuf servaddr;
++	struct rpc_err rpcerr;
+ 
+ 	/* parameter checking */
+ 	if (nconf == NULL) {
+@@ -892,7 +903,8 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp)
+ 		clnt_st = CLNT_CALL(client, (rpcproc_t)RPCBPROC_GETADDR,
+ 		    (xdrproc_t) xdr_rpcb, (char *)(void *)&parms,
+ 		    (xdrproc_t) xdr_wrapstring, (char *)(void *) &ua, *tp);
+-		if (clnt_st == RPC_SUCCESS) {
++		switch (clnt_st) {
++		case RPC_SUCCESS:
+ 			if ((ua == NULL) || (ua[0] == 0)) {
+ 				/* address unknown */
+ 				rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
+@@ -914,12 +926,15 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp)
+ 			    (char *)(void *)&servaddr);
+ 			__rpc_fixup_addr(address, &servaddr);
+ 			goto done;
+-		} else if (clnt_st == RPC_PROGVERSMISMATCH) {
+-			struct rpc_err rpcerr;
++		case RPC_PROGVERSMISMATCH:
+ 			clnt_geterr(client, &rpcerr);
+ 			if (rpcerr.re_vers.low > RPCBVERS4)
+ 				goto error;  /* a new version, can't handle */
+-		} else if (clnt_st != RPC_PROGUNAVAIL) {
++			/* Try the next lower version */
++		case RPC_PROGUNAVAIL:
++		case RPC_CANTDECODEARGS:
++			break;
++		default:
+ 			/* Cant handle this error */
+ 			rpc_createerr.cf_stat = clnt_st;
+ 			clnt_geterr(client, &rpc_createerr.cf_error);
+@@ -929,7 +944,7 @@ __rpcb_findaddr_timed(program, version, nconf, host, clpp, tp)
+ 
+ #ifdef PORTMAP 	/* Try version 2 for TCP or UDP */
+ 	if (strcmp(nconf->nc_protofmly, NC_INET) == 0) {
+-		address = __try_protocol_version_2(program, 2, nconf, host, tp);
++		address = __try_protocol_version_2(program, version, nconf, host, tp);
+ 		if (address == NULL)
+ 			goto error;
+ 	}
+diff --git a/src/xdr_stdio.c b/src/xdr_stdio.c
+index 4410262..846c7bf 100644
+--- a/src/xdr_stdio.c
++++ b/src/xdr_stdio.c
+@@ -38,6 +38,7 @@
+  */
+ 
+ #include <stdio.h>
++#include <stdint.h>
+ 
+ #include <arpa/inet.h>
+ #include <rpc/types.h>
+@@ -103,10 +104,12 @@ xdrstdio_getlong(xdrs, lp)
+ 	XDR *xdrs;
+ 	long *lp;
+ {
++	int32_t mycopy;
+ 
+-	if (fread(lp, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
++	if (fread(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
+ 		return (FALSE);
+-	*lp = (long)ntohl((u_int32_t)*lp);
++
++	*lp = (long)ntohl(mycopy);
+ 	return (TRUE);
+ }
+ 
+@@ -115,8 +118,14 @@ xdrstdio_putlong(xdrs, lp)
+ 	XDR *xdrs;
+ 	const long *lp;
+ {
+-	long mycopy = (long)htonl((u_int32_t)*lp);
++	int32_t mycopy;
++
++#if defined(_LP64)
++	if ((*lp > UINT32_MAX) || (*lp < INT32_MIN))
++		return (FALSE);
++#endif
+ 
++	mycopy = (int32_t)htonl((int32_t)*lp);
+ 	if (fwrite(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
+ 		return (FALSE);
+ 	return (TRUE);
diff --git a/libs/libtirpc/patches/01-Disable-parts-of-TIRPC-requiring-NIS-support.patch b/libs/libtirpc/patches/01-Disable-parts-of-TIRPC-requiring-NIS-support.patch
deleted file mode 100644
index eb1bef3dc..000000000
--- a/libs/libtirpc/patches/01-Disable-parts-of-TIRPC-requiring-NIS-support.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From 15adb318818f5d0ac609ef2b87643dd760487cb6 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
-Date: Mon, 20 Jul 2015 20:30:11 +0200
-Subject: [PATCH 1/1] Disable parts of TIRPC requiring NIS support
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-[yann.morin.1998@free.fr: update for 0.3.1]
-Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
-[joerg.krause@embedded.rocks: update for 0.3.2]
-Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
-[peda@axentia.se: update for 1.0.1]
-Signed-off-by: Peter Rosin <peda@axentia.se>
-[bernd.kuhls@t-online.de: update for 1.0.2]
-Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
----
- src/Makefile.am | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 6cc567a..9834f9a 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -24,7 +24,7 @@ libtirpc_la_SOURCES = auth_none.c auth_unix.c authunix_prot.c bindresvport.c cln
-         rpcb_st_xdr.c svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_auth_none.c \
- 	svc_auth_des.c \
-         svc_generic.c svc_raw.c svc_run.c svc_simple.c svc_vc.c getpeereid.c \
--        auth_time.c auth_des.c authdes_prot.c debug.c des_crypt.c des_impl.c
-+        auth_des.c authdes_prot.c debug.c des_crypt.c des_impl.c
- 
- ## XDR
- libtirpc_la_SOURCES += xdr.c xdr_rec.c xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr_stdio.c xdr_sizeof.c
-@@ -41,8 +41,8 @@ if GSS
-     libtirpc_la_CFLAGS = -DHAVE_RPCSEC_GSS $(GSSAPI_CFLAGS)
- endif
- 
--libtirpc_la_SOURCES += key_call.c key_prot_xdr.c getpublickey.c
--libtirpc_la_SOURCES += netname.c netnamer.c rpcdname.c rtime.c
-+#libtirpc_la_SOURCES += key_call.c key_prot_xdr.c getpublickey.c
-+#libtirpc_la_SOURCES += netname.c netnamer.c rpcdname.c rtime.c
- 
- CLEANFILES	       = cscope.* *~
- DISTCLEANFILES	       = Makefile.in
--- 
-2.4.6
-
diff --git a/libs/libtirpc/patches/02-uClibc-without-RPC-support-and-musl-does-not-install-rpcent.h.patch b/libs/libtirpc/patches/02-uClibc-without-RPC-support-and-musl-does-not-install-rpcent.h.patch
deleted file mode 100644
index 51229a024..000000000
--- a/libs/libtirpc/patches/02-uClibc-without-RPC-support-and-musl-does-not-install-rpcent.h.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 7aa1fe6a0f9280571117c30c03c2cc521cd86ec3 Mon Sep 17 00:00:00 2001
-From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-Date: Sat, 23 Jun 2012 21:58:07 +0200
-Subject: [PATCH] uClibc without RPC support and musl does not install rpcent.h
-
-Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-[yann.morin.1998@free.fr: update for 0.3.1]
-Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
-[joerg.krause@embedded.rocks: musl fix]
-Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
-[bernd.kuhls@t-online.de: update for 1.0.2]
-Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
----
- tirpc/rpc/rpcent.h | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/tirpc/rpc/rpcent.h b/tirpc/rpc/rpcent.h
-index 147f909..4a58180 100644
---- a/tirpc/rpc/rpcent.h
-+++ b/tirpc/rpc/rpcent.h
-@@ -48,8 +48,9 @@
- extern "C" {
- #endif
- 
--/* These are defined in /usr/include/rpc/netdb.h */
--#if !defined(__GLIBC__) || defined(__UCLIBC__)
-+/* These are defined in /usr/include/rpc/netdb.h, unless we are using
-+   the C library without RPC support. */
-+#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_RPC__) || !defined(__GLIBC__)
- struct rpcent {
- 	char	*r_name;	/* name of server for this rpc program */
- 	char	**r_aliases;	/* alias list */
--- 
-1.9.1
-
diff --git a/libs/libtirpc/patches/03-Disable-DES-authentification-support.patch b/libs/libtirpc/patches/03-Disable-DES-authentification-support.patch
deleted file mode 100644
index 0c6547240..000000000
--- a/libs/libtirpc/patches/03-Disable-DES-authentification-support.patch
+++ /dev/null
@@ -1,142 +0,0 @@
-From 79975eb4104667be85abd06874c258438826b674 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
-Date: Fri, 24 Jul 2015 14:45:52 +0200
-Subject: [PATCH] Disable DES authentification support
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-uClibc and musl does not provide DES authentication.
-
-Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
-[peda@axentia.se: update for 1.0.1]
-Signed-off-by: Peter Rosin <peda@axentia.se>
-[bernd.kuhls@t-online.de: update for 1.0.2]
-Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
----
- src/Makefile.am |  2 +-
- src/rpc_soc.c   | 32 --------------------------------
- 2 files changed, 1 insertion(+), 33 deletions(-)
-
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 960a522..3a88e31 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -22,9 +22,8 @@ libtirpc_la_SOURCES = auth_none.c auth_unix.c authunix_prot.c bindresvport.c cln
-         pmap_prot.c pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c \
-         rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \
-         rpcb_st_xdr.c svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_auth_none.c \
--	svc_auth_des.c \
-         svc_generic.c svc_raw.c svc_run.c svc_simple.c svc_vc.c getpeereid.c \
--        auth_des.c authdes_prot.c debug.c des_crypt.c des_impl.c
-+        debug.c
- 
- ## XDR
- libtirpc_la_SOURCES += xdr.c xdr_rec.c xdr_array.c xdr_float.c xdr_mem.c xdr_reference.c xdr_stdio.c xdr_sizeof.c
-diff --git a/src/svc_auth.c b/src/svc_auth.c
---- a/src/svc_auth.c
-+++ b/src/svc_auth.c
-@@ -114,9 +114,6 @@ _gss_authenticate(rqst, msg, no_dispatch)
- 	case AUTH_SHORT:
- 		dummy = _svcauth_short(rqst, msg);
- 		return (dummy);
--	case AUTH_DES:
--		dummy = _svcauth_des(rqst, msg);
--		return (dummy);
- #ifdef HAVE_RPCSEC_GSS
- 	case RPCSEC_GSS:
- 		dummy = _svcauth_gss(rqst, msg, no_dispatch);
-diff --git a/src/rpc_soc.c b/src/rpc_soc.c
-index e146ed4..161a1ec 100644
---- a/src/rpc_soc.c
-+++ b/src/rpc_soc.c
-@@ -522,86 +521,6 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
- }
- 
- /*
-- * Create the client des authentication object. Obsoleted by
-- * authdes_seccreate().
-- */
--AUTH *
--authdes_create(servername, window, syncaddr, ckey)
--	char *servername;		/* network name of server */
--	u_int window;			/* time to live */
--	struct sockaddr *syncaddr;	/* optional hostaddr to sync with */
--	des_block *ckey;		/* optional conversation key to use */
--{
--	AUTH *nauth;
--	char hostname[NI_MAXHOST];
--
--	if (syncaddr) {
--		/*
--		 * Change addr to hostname, because that is the way
--		 * new interface takes it.
--		 */
--	        switch (syncaddr->sa_family) {
--		case AF_INET:
--		  if (getnameinfo(syncaddr, sizeof(struct sockaddr_in), hostname,
--				  sizeof hostname, NULL, 0, 0) != 0)
--		    goto fallback;
--		  break;
--		case AF_INET6:
--		  if (getnameinfo(syncaddr, sizeof(struct sockaddr_in6), hostname,
--				  sizeof hostname, NULL, 0, 0) != 0)
--		    goto fallback;
--		  break;
--		default:
--		  goto fallback;
--		}
--		nauth = authdes_seccreate(servername, window, hostname, ckey);
--		return (nauth);
--	}
--fallback:
--	return authdes_seccreate(servername, window, NULL, ckey);
--}
--
--/*
-- * Create the client des authentication object. Obsoleted by
-- * authdes_pk_seccreate().
-- */
--extern AUTH *authdes_pk_seccreate(const char *, netobj *, u_int, const char *,
--        const des_block *, nis_server *);
--
--AUTH *
--authdes_pk_create(servername, pkey, window, syncaddr, ckey)
--	char *servername;		/* network name of server */
--	netobj *pkey;			/* public key */
--	u_int window;			/* time to live */
--	struct sockaddr *syncaddr;	/* optional hostaddr to sync with */
--	des_block *ckey;		/* optional conversation key to use */
--{
--	AUTH *nauth;
--	char hostname[NI_MAXHOST];
--
--	if (syncaddr) {
--		/*
--		 * Change addr to hostname, because that is the way
--		 * new interface takes it.
--		 */
--	        switch (syncaddr->sa_family) {
--		case AF_INET:
--		  if (getnameinfo(syncaddr, sizeof(struct sockaddr_in), hostname,
--				  sizeof hostname, NULL, 0, 0) != 0)
--		    goto fallback;
--		  break;
--		default:
--		  goto fallback;
--		}
--		nauth = authdes_pk_seccreate(servername, pkey, window, hostname, ckey, NULL);
--		return (nauth);
--	}
--fallback:
--	return authdes_pk_seccreate(servername, pkey, window, NULL, ckey, NULL);
--}
--
--
--/*
-  * Create a client handle for a unix connection. Obsoleted by clnt_vc_create()
-  */
- CLIENT *
--- 
-2.4.6
-
diff --git a/libs/libtirpc/patches/04-musl-rpc-fix-types.h.patch b/libs/libtirpc/patches/04-musl-rpc-fix-types.h.patch
deleted file mode 100644
index b0616ead3..000000000
--- a/libs/libtirpc/patches/04-musl-rpc-fix-types.h.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/tirpc/rpc/types.h	2018-03-27
-+++ b/tirpc/rpc/types.h	2018-03-27
-@@ -66,7 +66,7 @@ typedef   int32_t rpc_inline_t;
- #define mem_free(ptr, bsize)	free(ptr)
- 
- 
--#if defined __APPLE_CC__ || defined __FreeBSD__
-+#if defined __APPLE_CC__ || defined __FreeBSD__ || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
- # define __u_char_defined
- # define __daddr_t_defined
- #endif