X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fstatd%2Fsimu.c;h=f1d0bf886f3dfb5caf87ebdeb38406a75db4b329;hb=9a5293a10551c03b4fb976503dd24da569fcadb3;hp=a7ecb85c275509e687c4351955c4c5b4d1e3c03d;hpb=27a49079b03316eebcbc74197b73988b01b58ecc;p=nfs-utils.git diff --git a/utils/statd/simu.c b/utils/statd/simu.c index a7ecb85..f1d0bf8 100644 --- a/utils/statd/simu.c +++ b/utils/statd/simu.c @@ -8,8 +8,10 @@ #include #endif +#include #include +#include "sockaddr.h" #include "rpcmisc.h" #include "statd.h" #include "notlist.h" @@ -19,32 +21,28 @@ extern void my_svc_exit (void); /* * Services SM_SIMU_CRASH requests. + * + * Although the kernel contacts the statd service via only IPv4 + * transports, the statd service can receive other requests, such + * as SM_NOTIFY, from remote peers via IPv6. */ void * -sm_simu_crash_1_svc (void *argp, struct svc_req *rqstp) +sm_simu_crash_1_svc (__attribute__ ((unused)) void *argp, struct svc_req *rqstp) { - struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); + struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt); + char buf[INET6_ADDRSTRLEN]; static char *result = NULL; - struct in_addr caller; - if (sin->sin_family != AF_INET) { - note(N_WARNING, "Call to statd from non-AF_INET address"); - goto failure; - } + xlog(D_CALL, "Received SM_SIMU_CRASH"); - 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 (!nfs_is_v4_loopback(sap)) + goto out_nonlocal; - if (ntohs(sin->sin_port) >= 1024) { - note(N_WARNING, "Call to statd-simu-crash from unprivileged port"); + if ((int)nfs_get_port(sap) >= IPPORT_RESERVED) { + xlog_warn("SM_SIMU_CRASH call from unprivileged port"); goto failure; } - note (N_WARNING, "*** SIMULATING CRASH! ***"); my_svc_exit (); if (rtnl) @@ -52,4 +50,10 @@ sm_simu_crash_1_svc (void *argp, struct svc_req *rqstp) failure: return ((void *)&result); + + out_nonlocal: + if (!statd_present_address(sap, buf, sizeof(buf))) + buf[0] = '\0'; + xlog_warn("SM_SIMU_CRASH call from non-local host %s", buf); + goto failure; }