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>
43 #include <rx/rx_globals.h>
44 #include <rx/rxstat.h>
45 #include <afs/cellconfig.h>
48 #include <afs/audit.h>
49 #include <afs/com_err.h>
52 #include <afs/afsutil.h>
54 #include "vlserver_internal.h"
57 const char *vl_dbaseName;
58 struct afsconf_dir *vldb_confdir = 0; /* vldb configuration dir */
61 struct vldstats dynamic_statistics;
62 struct ubik_dbase *VL_dbase;
63 afs_uint32 rd_HostAddress[MAXSERVERID + 1];
64 afs_uint32 wr_HostAddress[MAXSERVERID + 1];
66 static void *CheckSignal(void*);
69 int rxJumbograms = 0; /* default is to not send and receive jumbo grams */
72 int rxkadDisableDotCheck = 0;
75 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
76 afs_uint32 SHostAddrs[ADDRSPERSITE];
79 CheckSignal_Signal(int unused)
81 #if defined(AFS_PTHREAD_ENV)
84 IOMGR_SoftSig(CheckSignal, 0);
89 CheckSignal(void *unused)
95 Init_VLdbase(&ctx, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE)))
96 return (void *)(intptr_t)errorcode;
97 VLog(0, ("Dump name hash table out\n"));
98 for (i = 0; i < HASHSIZE; i++) {
101 VLog(0, ("Dump id hash table out\n"));
102 for (i = 0; i < HASHSIZE; i++) {
105 return ((void *)(intptr_t)ubik_EndTrans(ctx.trans));
109 /* Initialize the stats for the opcodes */
111 initialize_dstats(void)
115 dynamic_statistics.start_time = (afs_uint32) time(0);
116 for (i = 0; i < MAX_NUMBER_OPCODES; i++) {
117 dynamic_statistics.requests[i] = 0;
118 dynamic_statistics.aborts[i] = 0;
122 /* check whether caller is authorized to manage RX statistics */
124 vldb_rxstat_userok(struct rx_call *call)
126 return afsconf_SuperUser(vldb_confdir, call, NULL);
129 /* Main server module */
131 #include "AFS_component_version_number.c"
134 main(int argc, char **argv)
138 struct rx_service *tservice;
139 struct rx_securityClass **securityClasses;
140 afs_int32 numClasses;
141 struct afsconf_dir *tdir;
142 struct ktc_encryptionKey tkey;
143 struct afsconf_cell info;
145 char hostname[VL_MAXNAMELEN];
146 int noAuth = 0, index;
147 char clones[MAXHOSTSPERCELL];
148 char *auditFileName = NULL;
149 afs_uint32 host = ntohl(INADDR_ANY);
153 * The following signal action for AIX is necessary so that in case of a
154 * crash (i.e. core is generated) we can include the user's data section
155 * in the core dump. Unfortunately, by default, only a partial core is
156 * generated which, in many cases, isn't too useful.
158 struct sigaction nsa;
160 rx_extraPackets = 100; /* should be a switch, I guess... */
161 sigemptyset(&nsa.sa_mask);
162 nsa.sa_handler = SIG_DFL;
163 nsa.sa_flags = SA_FULLDUMP;
164 sigaction(SIGABRT, &nsa, NULL);
165 sigaction(SIGSEGV, &nsa, NULL);
169 /* Parse command line */
170 for (index = 1; index < argc; index++) {
171 if (strcmp(argv[index], "-noauth") == 0) {
173 } else if (strcmp(argv[index], "-p") == 0) {
174 lwps = atoi(argv[++index]);
176 printf("Warning: '-p %d' is too big; using %d instead\n",
180 } else if (strcmp(argv[index], "-d") == 0) {
181 if ((index + 1) >= argc) {
182 fprintf(stderr, "missing argument for -d\n");
185 debuglevel = atoi(argv[++index]);
186 LogLevel = debuglevel;
187 } else if (strcmp(argv[index], "-nojumbo") == 0) {
189 } else if (strcmp(argv[index], "-jumbo") == 0) {
191 } else if (strcmp(argv[index], "-rxbind") == 0) {
193 } else if (strcmp(argv[index], "-allow-dotted-principals") == 0) {
194 rxkadDisableDotCheck = 1;
195 } else if (!strcmp(argv[index], "-rxmaxmtu")) {
196 if ((index + 1) >= argc) {
197 fprintf(stderr, "missing argument for -rxmaxmtu\n");
200 rxMaxMTU = atoi(argv[++index]);
201 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
202 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
203 printf("rxMaxMTU %d invalid; must be between %d-%" AFS_SIZET_FMT "\n",
204 rxMaxMTU, RX_MIN_PACKET_SIZE,
205 RX_MAX_PACKET_DATA_SIZE);
209 } else if (strcmp(argv[index], "-smallmem") == 0) {
212 } else if (strcmp(argv[index], "-trace") == 0) {
213 extern char rxi_tracename[80];
214 strcpy(rxi_tracename, argv[++index]);
216 } else if (strcmp(argv[index], "-auditlog") == 0) {
217 auditFileName = argv[++index];
219 } else if (strcmp(argv[index], "-audit-interface") == 0) {
220 char *interface = argv[++index];
222 if (osi_audit_interface(interface)) {
223 printf("Invalid audit interface '%s'\n", interface);
227 } else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
228 rx_enablePeerRPCStats();
229 } else if (strcmp(argv[index], "-enable_process_stats") == 0) {
230 rx_enableProcessRPCStats();
232 } else if (strcmp(argv[index], "-syslog") == 0) {
233 /* set syslog logging flag */
235 } else if (strncmp(argv[index], "-syslog=", 8) == 0) {
237 serverLogSyslogFacility = atoi(argv[index] + 8);
240 /* support help flag */
242 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
243 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
244 "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
245 "[-syslog[=FACILITY]] "
246 "[-enable_peer_stats] [-enable_process_stats] "
249 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
250 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
251 "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
252 "[-enable_peer_stats] [-enable_process_stats] "
261 osi_audit_file(auditFileName);
264 /* Initialize dirpaths */
265 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
267 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
269 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
273 vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH;
276 serverLogSyslogTag = "vlserver";
278 OpenLog(AFSDIR_SERVER_VLOG_FILEPATH); /* set up logging */
281 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
284 ("vlserver: can't open configuration files in dir %s, giving up.\n",
285 AFSDIR_SERVER_ETC_DIRPATH);
289 /* initialize winsock */
290 if (afs_winsockInit() < 0) {
291 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
292 fprintf(stderr, "vlserver: couldn't initialize winsock. \n");
297 gethostname(hostname, sizeof(hostname));
298 th = gethostbyname(hostname);
300 printf("vlserver: couldn't get address of this host (%s).\n",
304 memcpy(&myHost, th->h_addr, sizeof(afs_uint32));
306 #if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV)
307 signal(SIGXCPU, CheckSignal_Signal);
309 /* get list of servers */
311 afsconf_GetExtendedCellInfo(tdir, NULL, AFSCONF_VLDBSERVICE, &info,
314 printf("vlserver: Couldn't get cell server list for 'afsvldb'.\n");
318 vldb_confdir = tdir; /* Preserve our configuration dir */
319 /* rxvab no longer supported */
320 memset(&tkey, 0, sizeof(tkey));
323 afsconf_SetNoAuthFlag(tdir, 1);
328 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
329 AFSDIR_SERVER_NETINFO_FILEPATH) {
331 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
332 ADDRSPERSITE, reason,
333 AFSDIR_SERVER_NETINFO_FILEPATH,
334 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
338 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
341 host = SHostAddrs[0];
342 rx_InitHost(host, htons(AFSCONF_VLDBPORT));
347 ubik_CRXSecurityProc = afsconf_ClientAuth;
348 ubik_CRXSecurityRock = (char *)tdir;
349 ubik_SRXSecurityProc = afsconf_ServerAuth;
350 ubik_SRXSecurityRock = (char *)tdir;
351 ubik_CheckRXSecurityProc = afsconf_CheckAuth;
352 ubik_CheckRXSecurityRock = (char *)tdir;
353 ubik_SyncWriterCacheProc = vlsynccache;
355 ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, clones,
356 vl_dbaseName, &VL_dbase);
358 printf("vlserver: Ubik init failed: %s\n", afs_error_message(code));
364 if (rxMaxMTU != -1) {
365 rx_SetMaxMTU(rxMaxMTU);
367 rx_SetRxDeadTime(50);
369 memset(rd_HostAddress, 0, sizeof(rd_HostAddress));
370 memset(wr_HostAddress, 0, sizeof(wr_HostAddress));
373 afsconf_BuildServerSecurityObjects(tdir, 0, &securityClasses, &numClasses);
376 rx_NewServiceHost(host, 0, USER_SERVICE_ID, "Vldb server",
377 securityClasses, numClasses,
379 if (tservice == (struct rx_service *)0) {
380 printf("vlserver: Could not create VLDB_SERVICE rx service\n");
383 rx_SetMinProcs(tservice, 2);
386 rx_SetMaxProcs(tservice, lwps);
388 if (rxkadDisableDotCheck) {
389 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
390 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
394 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats",
395 securityClasses, numClasses,
396 RXSTATS_ExecuteRequest);
397 if (tservice == (struct rx_service *)0) {
398 printf("vlserver: Could not create rpc stats rx service\n");
401 rx_SetMinProcs(tservice, 2);
402 rx_SetMaxProcs(tservice, 4);
404 LogCommandLine(argc, argv, "vlserver", VldbVersion, "Starting AFS", FSLog);
405 printf("%s\n", cml_version_number); /* Goes to the log */
407 /* allow super users to manage RX statistics */
408 rx_SetRxStatUserOk(vldb_rxstat_userok);
410 rx_StartServer(1); /* Why waste this idle process?? */
412 return 0; /* not reachable */