2 * Copyright 2000, International Business Machines Corporation and others.
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
10 #include <afsconfig.h>
11 #include <afs/param.h>
15 #include <sys/types.h>
24 #include <WINNT/afsevent.h>
26 #ifdef HAVE_SYS_FILE_H
33 #ifdef HAVE_NETINET_IN_H
34 #include <netinet/in.h>
40 #include <rx/rx_globals.h>
41 #include <afs/cellconfig.h>
46 #include <afs/afsutil.h>
51 const char *vl_dbaseName;
52 struct afsconf_dir *vldb_confdir = 0; /* vldb configuration dir */
55 struct vldstats dynamic_statistics;
56 struct ubik_dbase *VL_dbase;
57 afs_uint32 HostAddress[MAXSERVERID + 1];
58 extern int afsconf_CheckAuth();
59 extern int afsconf_ServerAuth();
61 static void *CheckSignal(void*);
64 int rxJumbograms = 0; /* default is to not send and receive jumbo grams */
67 int rxkadDisableDotCheck = 0;
70 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
71 afs_uint32 SHostAddrs[ADDRSPERSITE];
76 #if defined(AFS_PTHREAD_ENV)
79 IOMGR_SoftSig(CheckSignal, 0);
84 CheckSignal(void *unused)
86 register int i, errorcode;
87 struct ubik_trans *trans;
90 Init_VLdbase(&trans, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE))
91 return (void *)errorcode;
92 VLog(0, ("Dump name hash table out\n"));
93 for (i = 0; i < HASHSIZE; i++) {
96 VLog(0, ("Dump id hash table out\n"));
97 for (i = 0; i < HASHSIZE; i++) {
100 return ((void *)ubik_EndTrans(trans));
104 /* Initialize the stats for the opcodes */
110 dynamic_statistics.start_time = (afs_uint32) time(0);
111 for (i = 0; i < MAX_NUMBER_OPCODES; i++) {
112 dynamic_statistics.requests[i] = 0;
113 dynamic_statistics.aborts[i] = 0;
117 /* check whether caller is authorized to manage RX statistics */
119 vldb_rxstat_userok(call)
120 struct rx_call *call;
122 return afsconf_SuperUser(vldb_confdir, call, NULL);
125 /* Main server module */
127 #include "AFS_component_version_number.c"
133 register afs_int32 code;
135 struct rx_service *tservice;
136 struct rx_securityClass *sc[3];
137 extern int VL_ExecuteRequest();
138 extern int RXSTATS_ExecuteRequest();
139 struct afsconf_dir *tdir;
140 struct ktc_encryptionKey tkey;
141 struct afsconf_cell info;
143 char hostname[VL_MAXNAMELEN];
144 int noAuth = 0, index, i;
145 extern int rx_extraPackets;
146 char commandLine[150];
147 char clones[MAXHOSTSPERCELL];
148 afs_uint32 host = ntohl(INADDR_ANY);
152 * The following signal action for AIX is necessary so that in case of a
153 * crash (i.e. core is generated) we can include the user's data section
154 * in the core dump. Unfortunately, by default, only a partial core is
155 * generated which, in many cases, isn't too useful.
157 struct sigaction nsa;
159 rx_extraPackets = 100; /* should be a switch, I guess... */
160 sigemptyset(&nsa.sa_mask);
161 nsa.sa_handler = SIG_DFL;
162 nsa.sa_flags = SA_FULLDUMP;
163 sigaction(SIGABRT, &nsa, NULL);
164 sigaction(SIGSEGV, &nsa, NULL);
168 /* Parse command line */
169 for (index = 1; index < argc; index++) {
170 if (strcmp(argv[index], "-noauth") == 0) {
172 } else if (strcmp(argv[index], "-p") == 0) {
173 lwps = atoi(argv[++index]);
175 printf("Warning: '-p %d' is too big; using %d instead\n",
179 } else if (strcmp(argv[index], "-d") == 0) {
180 if ((index + 1) >= argc) {
181 fprintf(stderr, "missing argument for -d\n");
184 debuglevel = atoi(argv[++index]);
185 LogLevel = debuglevel;
186 } else if (strcmp(argv[index], "-nojumbo") == 0) {
188 } else if (strcmp(argv[index], "-jumbo") == 0) {
190 } else if (strcmp(argv[index], "-rxbind") == 0) {
192 } else if (strcmp(argv[index], "-allow-dotted-principals") == 0) {
193 rxkadDisableDotCheck = 1;
194 } else if (!strcmp(argv[index], "-rxmaxmtu")) {
195 if ((index + 1) >= argc) {
196 fprintf(stderr, "missing argument for -rxmaxmtu\n");
199 rxMaxMTU = atoi(argv[++index]);
200 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
201 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
202 printf("rxMaxMTU %lu invalid; must be between %d-%d\n",
203 rxMaxMTU, RX_MIN_PACKET_SIZE,
204 RX_MAX_PACKET_DATA_SIZE);
208 } else if (strcmp(argv[index], "-smallmem") == 0) {
211 } else if (strcmp(argv[index], "-trace") == 0) {
212 extern char rxi_tracename[80];
213 strcpy(rxi_tracename, argv[++index]);
215 } else if (strcmp(argv[index], "-auditlog") == 0) {
216 char *fileName = argv[++index];
218 osi_audit_file(fileName);
219 } else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
220 rx_enablePeerRPCStats();
221 } else if (strcmp(argv[index], "-enable_process_stats") == 0) {
222 rx_enableProcessRPCStats();
224 } else if (strcmp(argv[index], "-syslog") == 0) {
225 /* set syslog logging flag */
227 } else if (strncmp(argv[index], "-syslog=", 8) == 0) {
229 serverLogSyslogFacility = atoi(argv[index] + 8);
232 /* support help flag */
234 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
235 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
236 "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
237 "[-syslog[=FACILITY]] "
238 "[-enable_peer_stats] [-enable_process_stats] "
241 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
242 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
243 "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
244 "[-enable_peer_stats] [-enable_process_stats] "
252 /* Initialize dirpaths */
253 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
255 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
257 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
261 vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH;
264 serverLogSyslogTag = "vlserver";
266 OpenLog(AFSDIR_SERVER_VLOG_FILEPATH); /* set up logging */
269 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
272 ("vlserver: can't open configuration files in dir %s, giving up.\n",
273 AFSDIR_SERVER_ETC_DIRPATH);
277 /* initialize winsock */
278 if (afs_winsockInit() < 0) {
279 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
280 fprintf(stderr, "vlserver: couldn't initialize winsock. \n");
285 gethostname(hostname, sizeof(hostname));
286 th = gethostbyname(hostname);
288 printf("vlserver: couldn't get address of this host (%s).\n",
292 memcpy(&myHost, th->h_addr, sizeof(afs_int32));
294 #if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV)
295 signal(SIGXCPU, CheckSignal_Signal);
297 /* get list of servers */
299 afsconf_GetExtendedCellInfo(tdir, NULL, AFSCONF_VLDBSERVICE, &info,
302 printf("vlserver: Couldn't get cell server list for 'afsvldb'.\n");
306 vldb_confdir = tdir; /* Preserve our configuration dir */
307 /* rxvab no longer supported */
308 memset(&tkey, 0, sizeof(tkey));
311 afsconf_SetNoAuthFlag(tdir, 1);
316 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
317 AFSDIR_SERVER_NETINFO_FILEPATH) {
319 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
320 ADDRSPERSITE, reason,
321 AFSDIR_SERVER_NETINFO_FILEPATH,
322 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
326 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
329 host = SHostAddrs[0];
330 rx_InitHost(host, htons(AFSCONF_VLDBPORT));
335 ubik_CRXSecurityProc = afsconf_ClientAuth;
336 ubik_CRXSecurityRock = (char *)tdir;
337 ubik_SRXSecurityProc = afsconf_ServerAuth;
338 ubik_SRXSecurityRock = (char *)tdir;
339 ubik_CheckRXSecurityProc = afsconf_CheckAuth;
340 ubik_CheckRXSecurityRock = (char *)tdir;
342 ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, clones,
343 vl_dbaseName, &VL_dbase);
345 printf("vlserver: Ubik init failed with code %d\n", code);
351 if (rxMaxMTU != -1) {
352 rx_SetMaxMTU(rxMaxMTU);
354 rx_SetRxDeadTime(50);
356 memset(HostAddress, 0, sizeof(HostAddress));
359 sc[0] = rxnull_NewServerSecurityObject();
360 sc[1] = (struct rx_securityClass *)0;
361 sc[2] = rxkad_NewServerSecurityObject(0, tdir, afsconf_GetKey, NULL);
364 rx_NewServiceHost(host, 0, USER_SERVICE_ID, "Vldb server", sc, 3,
366 if (tservice == (struct rx_service *)0) {
367 printf("vlserver: Could not create VLDB_SERVICE rx service\n");
370 rx_SetMinProcs(tservice, 2);
373 rx_SetMaxProcs(tservice, lwps);
375 if (rxkadDisableDotCheck) {
376 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
377 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
381 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats", sc, 3,
382 RXSTATS_ExecuteRequest);
383 if (tservice == (struct rx_service *)0) {
384 printf("vlserver: Could not create rpc stats rx service\n");
387 rx_SetMinProcs(tservice, 2);
388 rx_SetMaxProcs(tservice, 4);
390 for (commandLine[0] = '\0', i = 0; i < argc; i++) {
392 strcat(commandLine, " ");
393 strcat(commandLine, argv[i]);
396 ("Starting AFS vlserver %d (%s)\n", VLDBVERSION_4, commandLine));
397 printf("%s\n", cml_version_number); /* Goes to the log */
399 /* allow super users to manage RX statistics */
400 rx_SetRxStatUserOk(vldb_rxstat_userok);
402 rx_StartServer(1); /* Why waste this idle process?? */
404 return 0; /* not reachable */