17386a403a
The content of this branch was automatically imported from Fedora ELN with the following as its source: https://src.fedoraproject.org/rpms/rpcbind#43178e7a5b2cfc5aac26bb243d70c1d95a57859d
250 lines
7.6 KiB
Diff
250 lines
7.6 KiB
Diff
diff -up rpcbind-1.2.5/src/pmap_svc.c.orig rpcbind-1.2.5/src/pmap_svc.c
|
|
--- rpcbind-1.2.5/src/pmap_svc.c.orig 2018-08-15 10:51:19.000000000 -0400
|
|
+++ rpcbind-1.2.5/src/pmap_svc.c 2019-11-11 09:50:09.051438608 -0500
|
|
@@ -50,6 +50,7 @@ static char sccsid[] = "@(#)pmap_svc.c 1
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <stdio.h>
|
|
+#include <string.h>
|
|
#include <rpc/rpc.h>
|
|
#include <rpc/pmap_prot.h>
|
|
#include <rpc/rpcb_prot.h>
|
|
diff -up rpcbind-1.2.5/src/rpcbind.c.orig rpcbind-1.2.5/src/rpcbind.c
|
|
--- rpcbind-1.2.5/src/rpcbind.c.orig 2018-08-15 10:51:19.000000000 -0400
|
|
+++ rpcbind-1.2.5/src/rpcbind.c 2019-11-11 09:50:09.050438602 -0500
|
|
@@ -42,11 +42,10 @@
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
-#include <sys/errno.h>
|
|
#include <sys/resource.h>
|
|
#include <sys/wait.h>
|
|
#include <sys/time.h>
|
|
-#include <sys/signal.h>
|
|
+#include <signal.h>
|
|
#include <sys/file.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/un.h>
|
|
@@ -340,7 +339,7 @@ init_transport(struct netconfig *nconf)
|
|
{
|
|
int fd = -1;
|
|
struct t_bind taddr;
|
|
- struct addrinfo hints, *res;
|
|
+ struct addrinfo hints, *res = NULL;
|
|
struct __rpc_sockinfo si;
|
|
SVCXPRT *my_xprt = NULL;
|
|
int status; /* bound checking ? */
|
|
@@ -817,8 +816,12 @@ got_socket:
|
|
}
|
|
#endif
|
|
|
|
+ if (res != NULL)
|
|
+ freeaddrinfo(res);
|
|
return (0);
|
|
error:
|
|
+ if (res != NULL)
|
|
+ freeaddrinfo(res);
|
|
close(fd);
|
|
return (1);
|
|
}
|
|
diff -up rpcbind-1.2.5/src/rpcb_stat.c.orig rpcbind-1.2.5/src/rpcb_stat.c
|
|
--- rpcbind-1.2.5/src/rpcb_stat.c.orig 2018-08-15 10:51:19.000000000 -0400
|
|
+++ rpcbind-1.2.5/src/rpcb_stat.c 2019-11-11 09:50:09.051438608 -0500
|
|
@@ -151,7 +151,7 @@ rpcbs_rmtcall(rpcvers_t rtype, rpcproc_t
|
|
rpcbs_rmtcalllist *rl;
|
|
struct netconfig *nconf;
|
|
|
|
- if (rtype > RPCBVERS_STAT)
|
|
+ if (rtype >= RPCBVERS_STAT)
|
|
return;
|
|
for (rl = inf[rtype].rmtinfo; rl; rl = rl->next) {
|
|
|
|
diff -up rpcbind-1.2.5/src/rpcb_svc_com.c.orig rpcbind-1.2.5/src/rpcb_svc_com.c
|
|
--- rpcbind-1.2.5/src/rpcb_svc_com.c.orig 2018-08-15 10:51:19.000000000 -0400
|
|
+++ rpcbind-1.2.5/src/rpcb_svc_com.c 2019-11-11 09:50:09.050438602 -0500
|
|
@@ -42,7 +42,7 @@
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/param.h>
|
|
-#include <sys/poll.h>
|
|
+#include <poll.h>
|
|
#include <bits/poll.h>
|
|
#include <sys/socket.h>
|
|
#include <rpc/rpc.h>
|
|
diff -up rpcbind-1.2.5/src/rpcinfo.c.orig rpcbind-1.2.5/src/rpcinfo.c
|
|
--- rpcbind-1.2.5/src/rpcinfo.c.orig 2018-08-15 10:51:19.000000000 -0400
|
|
+++ rpcbind-1.2.5/src/rpcinfo.c 2019-11-11 09:50:09.052438613 -0500
|
|
@@ -693,11 +693,11 @@ reply_proc (res, who, nconf)
|
|
}
|
|
if (!(uaddr = taddr2uaddr (nconf, who)))
|
|
{
|
|
- uaddr = UNKNOWN;
|
|
+ printf ("%s\t%s\n", UNKNOWN, hostname);
|
|
+ } else {
|
|
+ printf ("%s\t%s\n", uaddr, hostname);
|
|
+ free ((char *) uaddr);
|
|
}
|
|
- printf ("%s\t%s\n", uaddr, hostname);
|
|
- if (strcmp (uaddr, UNKNOWN))
|
|
- free ((char *) uaddr);
|
|
return (FALSE);
|
|
}
|
|
|
|
@@ -973,6 +973,7 @@ rpcbdump (dumptype, netid, argc, argv)
|
|
(" program version(s) netid(s) service owner\n");
|
|
for (rs = rs_head; rs; rs = rs->next)
|
|
{
|
|
+ size_t netidmax = sizeof(buf) - 1;
|
|
char *p = buf;
|
|
|
|
printf ("%10ld ", rs->prog);
|
|
@@ -985,12 +986,22 @@ rpcbdump (dumptype, netid, argc, argv)
|
|
}
|
|
printf ("%-10s", buf);
|
|
buf[0] = '\0';
|
|
- for (nl = rs->nlist; nl; nl = nl->next)
|
|
- {
|
|
- strcat (buf, nl->netid);
|
|
- if (nl->next)
|
|
- strcat (buf, ",");
|
|
- }
|
|
+
|
|
+ for (nl = rs->nlist; nl; nl = nl->next)
|
|
+ {
|
|
+ strncat (buf, nl->netid, netidmax);
|
|
+ if (strlen (nl->netid) < netidmax)
|
|
+ netidmax -= strlen(nl->netid);
|
|
+ else
|
|
+ break;
|
|
+
|
|
+ if (nl->next && netidmax > 1)
|
|
+ {
|
|
+ strncat (buf, ",", netidmax);
|
|
+ netidmax --;
|
|
+ }
|
|
+ }
|
|
+
|
|
printf ("%-32s", buf);
|
|
rpc = getrpcbynumber (rs->prog);
|
|
if (rpc)
|
|
diff -up rpcbind-1.2.5/src/util.c.orig rpcbind-1.2.5/src/util.c
|
|
--- rpcbind-1.2.5/src/util.c.orig 2018-08-15 10:51:19.000000000 -0400
|
|
+++ rpcbind-1.2.5/src/util.c 2019-11-11 09:50:09.051438608 -0500
|
|
@@ -45,7 +45,7 @@
|
|
#include <net/if.h>
|
|
#include <netinet/in.h>
|
|
#include <ifaddrs.h>
|
|
-#include <sys/poll.h>
|
|
+#include <poll.h>
|
|
#include <rpc/rpc.h>
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
@@ -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,10 @@ addrmerge(struct netbuf *caller, char *s
|
|
* 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 maskAllAddrBits[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; /* 16 bytes for IPv6 */
|
|
for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) {
|
|
ifsa = ifap->ifa_addr;
|
|
ifmasksa = ifap->ifa_netmask;
|
|
@@ -175,8 +178,16 @@ addrmerge(struct netbuf *caller, char *s
|
|
if (!bitmaskcmp(&SA2SINADDR(ifsa),
|
|
&SA2SINADDR(hint_sa), &SA2SINADDR(ifmasksa),
|
|
sizeof(struct in_addr))) {
|
|
- 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), maskAllAddrBits,
|
|
+ sizeof(struct in_addr))) {
|
|
+ exactif = ifap;
|
|
+ goto found;
|
|
+ }
|
|
+ /* else go-on looking for an exact match */
|
|
}
|
|
break;
|
|
#ifdef INET6
|
|
@@ -197,8 +208,16 @@ addrmerge(struct netbuf *caller, char *s
|
|
} else if (!bitmaskcmp(&SA2SIN6ADDR(ifsa),
|
|
&SA2SIN6ADDR(hint_sa), &SA2SIN6ADDR(ifmasksa),
|
|
sizeof(struct in6_addr))) {
|
|
- 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), maskAllAddrBits,
|
|
+ sizeof(struct in6_addr))) {
|
|
+ exactif = ifap;
|
|
+ goto found;
|
|
+ }
|
|
+ /* else go-on looking for an exact match */
|
|
}
|
|
break;
|
|
#endif
|
|
@@ -215,10 +234,13 @@ addrmerge(struct netbuf *caller, char *s
|
|
(bestif->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))))
|
|
bestif = ifap;
|
|
}
|
|
+
|
|
if (bestif == NULL)
|
|
goto freeit;
|
|
|
|
found:
|
|
+ if(exactif)
|
|
+ bestif = exactif;
|
|
/*
|
|
* Construct the new address using the the address from
|
|
* `bestif', and the port number from `serv_uaddr'.
|
|
@@ -322,9 +344,10 @@ network_init()
|
|
/*
|
|
* Now join the RPC ipv6 multicast group on all interfaces.
|
|
*/
|
|
- if (getifaddrs(&ifp) < 0)
|
|
+ if (getifaddrs(&ifp) < 0) {
|
|
+ freeaddrinfo (res);
|
|
return;
|
|
-
|
|
+ }
|
|
mreq6.ipv6mr_interface = 0;
|
|
inet_pton(AF_INET6, RPCB_MULTICAST_ADDR, &mreq6.ipv6mr_multiaddr);
|
|
|
|
@@ -352,8 +375,8 @@ network_init()
|
|
perror("setsockopt v6 multicast");
|
|
}
|
|
#endif
|
|
-
|
|
- /* close(s); */
|
|
+ freeaddrinfo (res);
|
|
+ close(s);
|
|
}
|
|
|
|
struct sockaddr *
|
|
diff -up rpcbind-1.2.5/src/warmstart.c.orig rpcbind-1.2.5/src/warmstart.c
|
|
--- rpcbind-1.2.5/src/warmstart.c.orig 2018-08-15 10:51:19.000000000 -0400
|
|
+++ rpcbind-1.2.5/src/warmstart.c 2019-11-11 09:50:09.051438608 -0500
|
|
@@ -35,6 +35,7 @@
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <stdio.h>
|
|
+#include <string.h>
|
|
#include <rpc/rpc.h>
|
|
#include <rpc/rpcb_prot.h>
|
|
#include <rpc/xdr.h>
|