]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/statd/simu.c
nfs-utils: Fix source code character encoding
[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 <netdb.h>
12 #include <arpa/inet.h>
13
14 #include "sockaddr.h"
15 #include "rpcmisc.h"
16 #include "statd.h"
17 #include "notlist.h"
18
19 extern void my_svc_exit (void);
20
21
22 /*
23  * Services SM_SIMU_CRASH requests.
24  *
25  * Although the kernel contacts the statd service via only IPv4
26  * transports, the statd service can receive other requests, such
27  * as SM_NOTIFY, from remote peers via IPv6.
28  */
29 void *
30 sm_simu_crash_1_svc (__attribute__ ((unused)) void *argp, struct svc_req *rqstp)
31 {
32   struct sockaddr *sap = nfs_getrpccaller(rqstp->rq_xprt);
33   char buf[INET6_ADDRSTRLEN];
34   static char *result = NULL;
35
36   xlog(D_CALL, "Received SM_SIMU_CRASH");
37
38   if (!nfs_is_v4_loopback(sap))
39     goto out_nonlocal;
40
41   if ((int)nfs_get_port(sap) >= IPPORT_RESERVED) {
42     xlog_warn("SM_SIMU_CRASH call from unprivileged port");
43     goto failure;
44   }
45
46   my_svc_exit ();
47
48   if (rtnl)
49     nlist_kill (&rtnl);
50
51  failure:
52   return ((void *)&result);
53
54  out_nonlocal:
55   if (!statd_present_address(sap, buf, sizeof(buf)))
56     buf[0] = '\0';
57   xlog_warn("SM_SIMU_CRASH call from non-local host %s", buf);
58   goto failure;
59 }