diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2009-03-05 06:20:40 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2009-03-05 06:20:40 -0500 |
commit | 27a49079b03316eebcbc74197b73988b01b58ecc (patch) | |
tree | f24ddd9ce2c3d2cb9cc508c9ce27ae966c79dc91 /utils/statd/simu.c | |
parent | 5529fdbb4acb2507b79acf07e08c2a88c1df9e38 (diff) | |
download | nfs-utils-27a49079b03316eebcbc74197b73988b01b58ecc.tar.gz nfs-utils-27a49079b03316eebcbc74197b73988b01b58ecc.tar.xz nfs-utils-27a49079b03316eebcbc74197b73988b01b58ecc.zip |
nfs-utils: Provide type-checked version of svc_getcaller()
TI-RPC's version of the svc_getcaller() macro points to a sockaddr_in6,
not a sockaddr_in, though for AF_INET callers, an AF_INET address
resides there. To squelch compiler warnings when the TI-RPC version of
the svc_req structure is used, add inline helpers with appropriate
type casting.
Note that tcp_wrappers support only AF_INET addresses for now.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils/statd/simu.c')
-rw-r--r-- | utils/statd/simu.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/utils/statd/simu.c b/utils/statd/simu.c index 25e8bad..a7ecb85 100644 --- a/utils/statd/simu.c +++ b/utils/statd/simu.c @@ -7,8 +7,10 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif + #include <arpa/inet.h> +#include "rpcmisc.h" #include "statd.h" #include "notlist.h" @@ -21,17 +23,23 @@ extern void my_svc_exit (void); void * sm_simu_crash_1_svc (void *argp, struct svc_req *rqstp) { + struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); static char *result = NULL; struct in_addr caller; - caller = svc_getcaller(rqstp->rq_xprt)->sin_addr; + if (sin->sin_family != AF_INET) { + note(N_WARNING, "Call to statd from non-AF_INET address"); + goto failure; + } + + caller = sin->sin_addr; if (caller.s_addr != htonl(INADDR_LOOPBACK)) { note(N_WARNING, "Call to statd from non-local host %s", inet_ntoa(caller)); goto failure; } - if (ntohs(svc_getcaller(rqstp->rq_xprt)->sin_port) >= 1024) { + if (ntohs(sin->sin_port) >= 1024) { note(N_WARNING, "Call to statd-simu-crash from unprivileged port"); goto failure; } |