1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
From: Michael Olbrich <m.olbrich@pengutronix.de>
Date: Tue, 27 Aug 2019 21:42:24 +0200
Subject: [PATCH] use libtirpc if found
sunrpc was deprecated in glibc a long time ago. Some distributions, for
example Arch Linux, have disabled sunrpc. As a result building fails.
Use libtirpc if it is available. Use sunrpc otherwise.
libtirpc will not listen if the socket is already bound, so do it before
calling svctcp_create().
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
configure.ac | 3 +++
daemon.c | 5 +++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index cf1d9d107c82..668fbda2f0be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,6 +9,9 @@ AC_SYS_LARGEFILE
AC_SEARCH_LIBS(xdr_int, nsl)
AC_SEARCH_LIBS(socket, socket)
AC_SEARCH_LIBS(inet_aton, resolv)
+PKG_CHECK_MODULES([TIRPC], [libtirpc],
+ [CFLAGS="$CFLAGS $TIRPC_CFLAGS"
+ LIBS="$LIBS $TIRPC_LIBS"],[:])
AC_CHECK_HEADERS(mntent.h,,,[#include <stdio.h>])
AC_CHECK_HEADERS(stdint.h,,,[#include <stdio.h>])
AC_CHECK_HEADERS(sys/mnttab.h,,,[#include <stdio.h>])
diff --git a/daemon.c b/daemon.c
index d14af4509b12..fbd901f5e19d 100644
--- a/daemon.c
+++ b/daemon.c
@@ -110,7 +110,7 @@ void logmsg(int prio, const char *fmt, ...)
*/
struct in_addr get_remote(struct svc_req *rqstp)
{
- return (svc_getcaller(rqstp->rq_xprt))->sin_addr;
+ return ((struct sockaddr_in *)svc_getcaller(rqstp->rq_xprt))->sin_addr;
}
/*
@@ -118,7 +118,7 @@ struct in_addr get_remote(struct svc_req *rqstp)
*/
short get_port(struct svc_req *rqstp)
{
- return (svc_getcaller(rqstp->rq_xprt))->sin_port;
+ return ((struct sockaddr_in *)svc_getcaller(rqstp->rq_xprt))->sin_port;
}
/*
@@ -779,6 +779,7 @@ static SVCXPRT *create_tcp_transport(unsigned int port)
fprintf(stderr, "Couldn't bind to tcp port %d\n", port);
exit(1);
}
+ listen(sock, SOMAXCONN);
}
transp = svctcp_create(sock, 0, 0);
|