assorted-warning-cleanup-20071126
[openafs.git] / src / sys / rmtsysd.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* Daemon that implements remote procedure call service for non-vendor system
11  * calls (currently setpag and pioctl). The AFS cache manager daemon, afsd,
12  * currently fires up this module, when the "-rmtsys" flag is given.
13  * This is the main routine for rmtsysd, which can be used separately from
14  * afsd.
15  */
16 #include <afsconfig.h>
17 #include <afs/param.h>
18
19 RCSID
20     ("$Header$");
21
22 #ifdef  AFS_AIX32_ENV
23 #include <signal.h>
24 #endif
25 #include <sys/types.h>
26 #include <sys/ioctl.h>
27 #include <afs/vice.h>
28 #include <netdb.h>
29 #include <netinet/in.h>
30 #include <sys/stat.h>
31 #include <sys/file.h>
32 #include <errno.h>
33 #include <stdio.h>
34 #include <rx/xdr.h>
35 #include "rmtsys.h"
36
37
38 extern RMTSYS_ExecuteRequest();
39
40 #define N_SECURITY_OBJECTS 1    /* No real security yet */
41
42 #include "AFS_component_version_number.c"
43
44 int
45 main(int argc, char *argv[])
46 {
47     struct rx_securityClass *(securityObjects[N_SECURITY_OBJECTS]);
48     struct rx_service *service;
49
50 #ifdef  AFS_AIX32_ENV
51     /*
52      * The following signal action for AIX is necessary so that in case of a 
53      * crash (i.e. core is generated) we can include the user's data section 
54      * in the core dump. Unfortunately, by default, only a partial core is
55      * generated which, in many cases, isn't too useful.
56      */
57     struct sigaction nsa;
58
59     sigemptyset(&nsa.sa_mask);
60     nsa.sa_handler = SIG_DFL;
61     nsa.sa_flags = SA_FULLDUMP;
62     sigaction(SIGABRT, &nsa, NULL);
63     sigaction(SIGSEGV, &nsa, NULL);
64 #endif
65     /* Initialize the rx-based RMTSYS server */
66     if (rx_Init(htons(AFSCONF_RMTSYSPORT)) < 0)
67         rmt_Quit("rx_init");
68     securityObjects[0] = rxnull_NewServerSecurityObject();
69     if (securityObjects[0] == (struct rx_securityClass *)0)
70         rmt_Quit("rxnull_NewServerSecurityObject");
71     service =
72         rx_NewService(0, RMTSYS_SERVICEID, AFSCONF_RMTSYSSERVICE,
73                       securityObjects, N_SECURITY_OBJECTS,
74                       RMTSYS_ExecuteRequest);
75     if (service == (struct rx_service *)0)
76         rmt_Quit("rx_NewService");
77     /* One may wish to tune some default RX params for better performance
78      * at some point... */
79     rx_SetMaxProcs(service, 2);
80     rx_StartServer(1);          /* Donate this process to the server process pool */
81     return 0;
82 }