X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fstatd%2Fsimu.c;h=a7ecb85c275509e687c4351955c4c5b4d1e3c03d;hb=2dd083c5bdb5b38729b46dc65c886c77aa5a82b9;hp=82d794e1c2667a20198f0cb24a89bcf5e95f75ca;hpb=dad50c0e589b5651242de50e81200b036d995b73;p=nfs-utils.git diff --git a/utils/statd/simu.c b/utils/statd/simu.c index 82d794e..a7ecb85 100644 --- a/utils/statd/simu.c +++ b/utils/statd/simu.c @@ -7,8 +7,10 @@ #ifdef HAVE_CONFIG_H #include #endif + #include +#include "rpcmisc.h" #include "statd.h" #include "notlist.h" @@ -21,36 +23,33 @@ 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; + + 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(sin->sin_port) >= 1024) { + note(N_WARNING, "Call to statd-simu-crash from unprivileged port"); + goto failure; + } -#ifdef RESTRICTED_STATD - struct in_addr caller; - - /* 1. Reject anyone not calling from 127.0.0.1. - * Ignore the my_name specified by the caller, and - * use "127.0.0.1" instead. - */ - 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\n"); - goto failure; - } -#endif note (N_WARNING, "*** SIMULATING CRASH! ***"); my_svc_exit (); if (rtnl) nlist_kill (&rtnl); -#ifdef RESTRICTED_STATD failure: -#endif return ((void *)&result); }