]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/statd/simu.c
NFS man page: update nfs(5) with details about IPv6 support
[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
11 #include <arpa/inet.h>
12
13 #include "rpcmisc.h"
14 #include "statd.h"
15 #include "notlist.h"
16
17 extern void my_svc_exit (void);
18
19
20 /*
21  * Services SM_SIMU_CRASH requests.
22  */
23 void *
24 sm_simu_crash_1_svc (void *argp, struct svc_req *rqstp)
25 {
26   struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt);
27   static char *result = NULL;
28   struct in_addr caller;
29
30   xlog(D_CALL, "Received SM_SIMU_CRASH");
31
32   if (sin->sin_family != AF_INET) {
33     xlog_warn("Call to statd from non-AF_INET address");
34     goto failure;
35   }
36
37   caller = sin->sin_addr;
38   if (caller.s_addr != htonl(INADDR_LOOPBACK)) {
39     xlog_warn("Call to statd from non-local host %s",
40       inet_ntoa(caller));
41     goto failure;
42   }
43
44   if (ntohs(sin->sin_port) >= 1024) {
45     xlog_warn("Call to statd-simu-crash from unprivileged port");
46     goto failure;
47   }
48
49   xlog_warn("*** SIMULATING CRASH! ***");
50   my_svc_exit ();
51
52   if (rtnl)
53     nlist_kill (&rtnl);
54
55  failure:
56   return ((void *)&result);
57 }