X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fstatd%2Fsimu.c;h=25e8badad160246f2efb600a51659deed8fb4d9e;hb=9b13713fa592b02da0dc79c5505fdf7002155d13;hp=fa4e3a63da246608bd11fd934639c9d2c55aa3cc;hpb=8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9;p=nfs-utils.git diff --git a/utils/statd/simu.c b/utils/statd/simu.c index fa4e3a6..25e8bad 100644 --- a/utils/statd/simu.c +++ b/utils/statd/simu.c @@ -4,7 +4,11 @@ * NSM for Linux. */ -#include "config.h" +#ifdef HAVE_CONFIG_H +#include +#endif +#include + #include "statd.h" #include "notlist.h" @@ -18,12 +22,26 @@ void * sm_simu_crash_1_svc (void *argp, struct svc_req *rqstp) { static char *result = NULL; + struct in_addr caller; + + caller = svc_getcaller(rqstp->rq_xprt)->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) { + note(N_WARNING, "Call to statd-simu-crash from unprivileged port"); + goto failure; + } - log (L_WARNING, "*** SIMULATING CRASH! ***"); + note (N_WARNING, "*** SIMULATING CRASH! ***"); my_svc_exit (); if (rtnl) nlist_kill (&rtnl); + failure: return ((void *)&result); }