]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/statd/simu.c
Make --enable-secure-statd the default.
[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
26 #ifdef RESTRICTED_STATD
27         struct in_addr  caller;
28
29         /* 1.   Reject anyone not calling from 127.0.0.1.
30          *      Ignore the my_name specified by the caller, and
31          *      use "127.0.0.1" instead.
32          */
33         caller = svc_getcaller(rqstp->rq_xprt)->sin_addr;
34         if (caller.s_addr != htonl(INADDR_LOOPBACK)) {
35                 note(N_WARNING,
36                         "Call to statd from non-local host %s",
37                         inet_ntoa(caller));
38                 goto failure;
39         }
40         if (ntohs(svc_getcaller(rqstp->rq_xprt)->sin_port) >= 1024) {
41                 note(N_WARNING,
42                      "Call to statd-simu-crash from unprivileged port\n");
43                 goto failure;
44         }
45 #endif
46   note (N_WARNING, "*** SIMULATING CRASH! ***");
47   my_svc_exit ();
48
49   if (rtnl)
50     nlist_kill (&rtnl);
51
52 #ifdef RESTRICTED_STATD
53  failure:
54 #endif
55   return ((void *)&result);
56 }