]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/statd/simu.c
25e8badad160246f2efb600a51659deed8fb4d9e
[nfs-utils.git] / utils / statd / simu.c
1 /*
2  * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff
3  *
4  * NSM for Linux.
5  */
6
7 #ifdef HAVE_CONFIG_H
8 #include <config.h>
9 #endif
10 #include <arpa/inet.h>
11
12 #include "statd.h"
13 #include "notlist.h"
14
15 extern void my_svc_exit (void);
16
17
18 /*
19  * Services SM_SIMU_CRASH requests.
20  */
21 void *
22 sm_simu_crash_1_svc (void *argp, struct svc_req *rqstp)
23 {
24   static char *result = NULL;
25   struct in_addr caller;
26
27   caller = svc_getcaller(rqstp->rq_xprt)->sin_addr;
28   if (caller.s_addr != htonl(INADDR_LOOPBACK)) {
29     note(N_WARNING, "Call to statd from non-local host %s",
30       inet_ntoa(caller));
31     goto failure;
32   }
33
34   if (ntohs(svc_getcaller(rqstp->rq_xprt)->sin_port) >= 1024) {
35     note(N_WARNING, "Call to statd-simu-crash from unprivileged port");
36     goto failure;
37   }
38
39   note (N_WARNING, "*** SIMULATING CRASH! ***");
40   my_svc_exit ();
41
42   if (rtnl)
43     nlist_kill (&rtnl);
44
45  failure:
46   return ((void *)&result);
47 }