X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fstatd%2Fsimu.c;h=7df04d9080abaf406c393a79f6dee7128e6c4b1a;hp=fa4e3a63da246608bd11fd934639c9d2c55aa3cc;hb=9ccfe0fa5a43dfc4453b09e328565a6c8f999fe4;hpb=8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9 diff --git a/utils/statd/simu.c b/utils/statd/simu.c index fa4e3a6..7df04d9 100644 --- a/utils/statd/simu.c +++ b/utils/statd/simu.c @@ -4,7 +4,13 @@ * NSM for Linux. */ -#include "config.h" +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "rpcmisc.h" #include "statd.h" #include "notlist.h" @@ -17,13 +23,35 @@ 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; + + xlog(D_CALL, "Received SM_SIMU_CRASH"); + + if (sin->sin_family != AF_INET) { + xlog_warn("Call to statd from non-AF_INET address"); + goto failure; + } + + caller = sin->sin_addr; + if (caller.s_addr != htonl(INADDR_LOOPBACK)) { + xlog_warn("Call to statd from non-local host %s", + inet_ntoa(caller)); + goto failure; + } + + if (ntohs(sin->sin_port) >= 1024) { + xlog_warn("Call to statd-simu-crash from unprivileged port"); + goto failure; + } - log (L_WARNING, "*** SIMULATING CRASH! ***"); + xlog_warn("*** SIMULATING CRASH! ***"); my_svc_exit (); if (rtnl) nlist_kill (&rtnl); + failure: return ((void *)&result); }