(cherry picked from commit 14c50e510b8607b646039e7aad3e403d9d67b87e)
This commit is contained in:
quanhongfei 2021-12-03 15:46:02 +08:00 committed by openeuler-sync-bot
parent f92068d5ef
commit 41b377e254
4 changed files with 10 additions and 100 deletions

View File

@ -1,96 +0,0 @@
From 8e0eb02df52d15dd4317abeddec427cdbac4da3c Mon Sep 17 00:00:00 2001
From: huyan <hu.huyan@huawei.com>
Date: Mon, 8 Jul 2019 02:10:44 +0000
Subject: [PATCH] backport bugfix rpcbind GETADDR return client ip
---
src/util.c | 45 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 39 insertions(+), 6 deletions(-)
diff --git a/src/util.c b/src/util.c
index 74b0284..d722d4f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -103,7 +103,7 @@ char *
addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr,
char *netid)
{
- struct ifaddrs *ifap, *ifp = NULL, *bestif;
+ struct ifaddrs *ifap, *ifp = NULL, *bestif, *exactif;
struct netbuf *serv_nbp = NULL, *hint_nbp = NULL, tbuf;
struct sockaddr *caller_sa, *hint_sa, *ifsa, *ifmasksa, *serv_sa;
struct sockaddr_storage ss;
@@ -157,7 +157,12 @@ addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr,
* network portion of its address is equal to that of the client.
* If so, we have found the interface that we want to use.
*/
- bestif = NULL;
+ bestif = NULL; /* first interface UP with same network & family */
+ exactif = NULL; /* the interface requested by the client */
+ u_int8_t maskAllBits[16] = { /* 16 bytes for IPv6 */
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) {
ifsa = ifap->ifa_addr;
ifmasksa = ifap->ifa_netmask;
@@ -175,8 +180,21 @@ addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr,
if (!bitmaskcmp(&SA2SINADDR(ifsa),
&SA2SINADDR(hint_sa), &SA2SINADDR(ifmasksa),
sizeof(struct in_addr))) {
- bestif = ifap;
- goto found;
+ if (getenv("RPCBIND_GETADDR_RETURN_CLIENT_IP") == NULL) {
+ bestif = ifap;
+ goto found;
+ }
+
+ if(!bestif) /* for compatibility with previous code */
+ bestif = ifap;
+ /* Is this an exact match? */
+ if (!bitmaskcmp(&SA2SINADDR(ifsa),
+ &SA2SINADDR(hint_sa), maskAllBits,
+ sizeof(struct in_addr))) {
+ exactif = ifap;
+ goto found;
+ }
+ /* else go-on looking for an exact match */
}
break;
#ifdef INET6
@@ -197,8 +215,21 @@ addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr,
} else if (!bitmaskcmp(&SA2SIN6ADDR(ifsa),
&SA2SIN6ADDR(hint_sa), &SA2SIN6ADDR(ifmasksa),
sizeof(struct in6_addr))) {
- bestif = ifap;
- goto found;
+ if (getenv("RPCBIND_GETADDR_RETURN_CLIENT_IP") == NULL) {
+ bestif = ifap;
+ goto found;
+ }
+
+ if(!bestif) /* for compatibility with previous code */
+ bestif = ifap;
+ /* Is this an exact match? */
+ if (!bitmaskcmp(&SA2SIN6ADDR(ifsa),
+ &SA2SIN6ADDR(hint_sa), maskAllBits,
+ sizeof(struct in6_addr))) {
+ exactif = ifap;
+ goto found;
+ }
+ /* else go-on looking for an exact match */
}
break;
#endif
@@ -219,6 +250,8 @@ addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr,
goto freeit;
found:
+ if(exactif)
+ bestif = exactif;
/*
* Construct the new address using the the address from
* `bestif', and the port number from `serv_uaddr'.
--
1.7.12.4

Binary file not shown.

BIN
rpcbind-1.2.6.tar.bz2 Normal file

Binary file not shown.

View File

@ -2,8 +2,8 @@
%global rpcbind_state_dir %{_rundir}/rpcbind %global rpcbind_state_dir %{_rundir}/rpcbind
Name: rpcbind Name: rpcbind
Version: 1.2.5 Version: 1.2.6
Release: 2 Release: 1
Summary: Universal addresses to RPC program number mapper Summary: Universal addresses to RPC program number mapper
License: BSD License: BSD
@ -25,7 +25,6 @@ Patch101: %{name}-0.2.3-systemd-tmpfiles.patch
Patch102: %{name}-0.2.4-runstatdir.patch Patch102: %{name}-0.2.4-runstatdir.patch
Patch103: %{name}-0.2.4-systemd-service.patch Patch103: %{name}-0.2.4-systemd-service.patch
Patch104: %{name}-0.2.4-systemd-rundir.patch Patch104: %{name}-0.2.4-systemd-rundir.patch
Patch6000: bugfix-%{name}-GETADDR-return-client-ip.patch
Patch6001: CVE-2017-8779.patch Patch6001: CVE-2017-8779.patch
Patch9000: bugfix-listen-tcp-port-111.patch Patch9000: bugfix-listen-tcp-port-111.patch
@ -46,7 +45,7 @@ host to be able to make RPC calls on a server on that machine.
autoreconf -fisv autoreconf -fisv
%configure --enable-warmstarts --with-statedir="%rpcbind_state_dir" \ %configure --enable-warmstarts --with-statedir="%rpcbind_state_dir" \
--with-rpcuser="%rpcbind_user_group" --with-nss-modules="files altfiles" \ --with-rpcuser="%rpcbind_user_group" --with-nss-modules="files altfiles" \
--sbindir=%{_bindir} --enable-debug --sbindir=%{_bindir} --enable-debug --enable-rmtcalls
make all make all
@ -57,6 +56,7 @@ install -m 0755 -d %{buildroot}%{_tmpfilesdir}
install -m 0755 -d %{buildroot}%{_mandir}/man8 install -m 0755 -d %{buildroot}%{_mandir}/man8
install -m 0755 -d %{buildroot}%{rpcbind_state_dir} install -m 0755 -d %{buildroot}%{rpcbind_state_dir}
%make_install %make_install
make DESTDIR=$RPM_BUILD_ROOT install
install -m 644 %{SOURCE1} %{buildroot}/etc/sysconfig/%{name} install -m 644 %{SOURCE1} %{buildroot}/etc/sysconfig/%{name}
@ -115,6 +115,12 @@ fi
%{_mandir}/man8/*.8.gz %{_mandir}/man8/*.8.gz
%changelog %changelog
* Fri Dec 03 2021 quanhongfei <quanhongfei@huawei.com> - 1.2.6-1
- Type:requirements
- Id:NA
- SUG:NA
- DESC:update rpcbind to 1.2.6
* Thu Oct 10 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.2.5-2 * Thu Oct 10 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.2.5-2
- Type:bugfix - Type:bugfix
- Id:NA - Id:NA