X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fstatd%2Fsimu.c;h=f1d0bf886f3dfb5caf87ebdeb38406a75db4b329;hp=78a6ee2e9d6cc059d233b11c4efa8ef9631ff2af;hb=a8dcaa282122b5db8f4ffb7e5d99b2c4b62cbb78;hpb=430052cab3c8044ef6d1be7b5a5ded13c45d0c40 diff --git a/utils/statd/simu.c b/utils/statd/simu.c index 78a6ee2..f1d0bf8 100644 --- a/utils/statd/simu.c +++ b/utils/statd/simu.c @@ -4,7 +4,15 @@ * NSM for Linux. */ -#include "config.h" +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "sockaddr.h" +#include "rpcmisc.h" #include "statd.h" #include "notlist.h" @@ -13,17 +21,39 @@ 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 *sap = nfs_getrpccaller(rqstp->rq_xprt); + char buf[INET6_ADDRSTRLEN]; static char *result = NULL; - note (N_WARNING, "*** SIMULATING CRASH! ***"); + xlog(D_CALL, "Received SM_SIMU_CRASH"); + + if (!nfs_is_v4_loopback(sap)) + goto out_nonlocal; + + if ((int)nfs_get_port(sap) >= IPPORT_RESERVED) { + xlog_warn("SM_SIMU_CRASH call from unprivileged port"); + goto failure; + } + my_svc_exit (); if (rtnl) nlist_kill (&rtnl); + 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; }