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>
51 #include <afs/afsutil.h>
53 #include "vlserver_internal.h"
56 const char *vl_dbaseName;
57 struct afsconf_dir *vldb_confdir = 0; /* vldb configuration dir */
60 struct vldstats dynamic_statistics;
61 struct ubik_dbase *VL_dbase;
62 afs_uint32 HostAddress[MAXSERVERID + 1];
64 static void *CheckSignal(void*);
67 int rxJumbograms = 0; /* default is to not send and receive jumbo grams */
70 int rxkadDisableDotCheck = 0;
73 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
74 afs_uint32 SHostAddrs[ADDRSPERSITE];
77 CheckSignal_Signal(int unused)
79 #if defined(AFS_PTHREAD_ENV)
82 IOMGR_SoftSig(CheckSignal, 0);
87 CheckSignal(void *unused)
90 struct ubik_trans *trans;
93 Init_VLdbase(&trans, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE)))
94 return (void *)(intptr_t)errorcode;
95 VLog(0, ("Dump name hash table out\n"));
96 for (i = 0; i < HASHSIZE; i++) {
99 VLog(0, ("Dump id hash table out\n"));
100 for (i = 0; i < HASHSIZE; i++) {
101 HashIdDump(trans, i);
103 return ((void *)(intptr_t)ubik_EndTrans(trans));
107 /* Initialize the stats for the opcodes */
109 initialize_dstats(void)
113 dynamic_statistics.start_time = (afs_uint32) time(0);
114 for (i = 0; i < MAX_NUMBER_OPCODES; i++) {
115 dynamic_statistics.requests[i] = 0;
116 dynamic_statistics.aborts[i] = 0;
120 /* check whether caller is authorized to manage RX statistics */
122 vldb_rxstat_userok(struct rx_call *call)
124 return afsconf_SuperUser(vldb_confdir, call, NULL);
127 /* Main server module */
129 #include "AFS_component_version_number.c"
132 main(int argc, char **argv)
136 struct rx_service *tservice;
137 struct rx_securityClass **securityClasses;
138 afs_int32 numClasses;
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;
145 char clones[MAXHOSTSPERCELL];
146 char *auditFileName = NULL;
147 afs_uint32 host = ntohl(INADDR_ANY);
151 * The following signal action for AIX is necessary so that in case of a
152 * crash (i.e. core is generated) we can include the user's data section
153 * in the core dump. Unfortunately, by default, only a partial core is
154 * generated which, in many cases, isn't too useful.
156 struct sigaction nsa;
158 rx_extraPackets = 100; /* should be a switch, I guess... */
159 sigemptyset(&nsa.sa_mask);
160 nsa.sa_handler = SIG_DFL;
161 nsa.sa_flags = SA_FULLDUMP;
162 sigaction(SIGABRT, &nsa, NULL);
163 sigaction(SIGSEGV, &nsa, NULL);
167 /* Parse command line */
168 for (index = 1; index < argc; index++) {
169 if (strcmp(argv[index], "-noauth") == 0) {
171 } else if (strcmp(argv[index], "-p") == 0) {
172 lwps = atoi(argv[++index]);
174 printf("Warning: '-p %d' is too big; using %d instead\n",
178 } else if (strcmp(argv[index], "-d") == 0) {
179 if ((index + 1) >= argc) {
180 fprintf(stderr, "missing argument for -d\n");
183 debuglevel = atoi(argv[++index]);
184 LogLevel = debuglevel;
185 } else if (strcmp(argv[index], "-nojumbo") == 0) {
187 } else if (strcmp(argv[index], "-jumbo") == 0) {
189 } else if (strcmp(argv[index], "-rxbind") == 0) {
191 } else if (strcmp(argv[index], "-allow-dotted-principals") == 0) {
192 rxkadDisableDotCheck = 1;
193 } else if (!strcmp(argv[index], "-rxmaxmtu")) {
194 if ((index + 1) >= argc) {
195 fprintf(stderr, "missing argument for -rxmaxmtu\n");
198 rxMaxMTU = atoi(argv[++index]);
199 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
200 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
201 printf("rxMaxMTU %d invalid; must be between %d-%" AFS_SIZET_FMT "\n",
202 rxMaxMTU, RX_MIN_PACKET_SIZE,
203 RX_MAX_PACKET_DATA_SIZE);
207 } else if (strcmp(argv[index], "-smallmem") == 0) {
210 } else if (strcmp(argv[index], "-trace") == 0) {
211 extern char rxi_tracename[80];
212 strcpy(rxi_tracename, argv[++index]);
214 } else if (strcmp(argv[index], "-auditlog") == 0) {
215 auditFileName = argv[++index];
217 } else if (strcmp(argv[index], "-audit-interface") == 0) {
218 char *interface = argv[++index];
220 if (osi_audit_interface(interface)) {
221 printf("Invalid audit interface '%s'\n", interface);
225 } else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
226 rx_enablePeerRPCStats();
227 } else if (strcmp(argv[index], "-enable_process_stats") == 0) {
228 rx_enableProcessRPCStats();
230 } else if (strcmp(argv[index], "-syslog") == 0) {
231 /* set syslog logging flag */
233 } else if (strncmp(argv[index], "-syslog=", 8) == 0) {
235 serverLogSyslogFacility = atoi(argv[index] + 8);
238 /* support help flag */
240 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
241 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
242 "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
243 "[-syslog[=FACILITY]] "
244 "[-enable_peer_stats] [-enable_process_stats] "
247 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
248 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
249 "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
250 "[-enable_peer_stats] [-enable_process_stats] "
259 osi_audit_file(auditFileName);
262 /* Initialize dirpaths */
263 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
265 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
267 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
271 vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH;
274 serverLogSyslogTag = "vlserver";
276 OpenLog(AFSDIR_SERVER_VLOG_FILEPATH); /* set up logging */
279 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
282 ("vlserver: can't open configuration files in dir %s, giving up.\n",
283 AFSDIR_SERVER_ETC_DIRPATH);
287 /* initialize winsock */
288 if (afs_winsockInit() < 0) {
289 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
290 fprintf(stderr, "vlserver: couldn't initialize winsock. \n");
295 gethostname(hostname, sizeof(hostname));
296 th = gethostbyname(hostname);
298 printf("vlserver: couldn't get address of this host (%s).\n",
302 memcpy(&myHost, th->h_addr, sizeof(afs_uint32));
304 #if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV)
305 signal(SIGXCPU, CheckSignal_Signal);
307 /* get list of servers */
309 afsconf_GetExtendedCellInfo(tdir, NULL, AFSCONF_VLDBSERVICE, &info,
312 printf("vlserver: Couldn't get cell server list for 'afsvldb'.\n");
316 vldb_confdir = tdir; /* Preserve our configuration dir */
317 /* rxvab no longer supported */
318 memset(&tkey, 0, sizeof(tkey));
321 afsconf_SetNoAuthFlag(tdir, 1);
326 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
327 AFSDIR_SERVER_NETINFO_FILEPATH) {
329 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
330 ADDRSPERSITE, reason,
331 AFSDIR_SERVER_NETINFO_FILEPATH,
332 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
336 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
339 host = SHostAddrs[0];
340 rx_InitHost(host, htons(AFSCONF_VLDBPORT));
345 ubik_CRXSecurityProc = afsconf_ClientAuth;
346 ubik_CRXSecurityRock = (char *)tdir;
347 ubik_SRXSecurityProc = afsconf_ServerAuth;
348 ubik_SRXSecurityRock = (char *)tdir;
349 ubik_CheckRXSecurityProc = afsconf_CheckAuth;
350 ubik_CheckRXSecurityRock = (char *)tdir;
352 ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, clones,
353 vl_dbaseName, &VL_dbase);
355 printf("vlserver: Ubik init failed with code %d\n", code);
361 if (rxMaxMTU != -1) {
362 rx_SetMaxMTU(rxMaxMTU);
364 rx_SetRxDeadTime(50);
366 memset(HostAddress, 0, sizeof(HostAddress));
369 afsconf_BuildServerSecurityObjects(tdir, 0, &securityClasses, &numClasses);
372 rx_NewServiceHost(host, 0, USER_SERVICE_ID, "Vldb server",
373 securityClasses, numClasses,
375 if (tservice == (struct rx_service *)0) {
376 printf("vlserver: Could not create VLDB_SERVICE rx service\n");
379 rx_SetMinProcs(tservice, 2);
382 rx_SetMaxProcs(tservice, lwps);
384 if (rxkadDisableDotCheck) {
385 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
386 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
390 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats",
391 securityClasses, numClasses,
392 RXSTATS_ExecuteRequest);
393 if (tservice == (struct rx_service *)0) {
394 printf("vlserver: Could not create rpc stats rx service\n");
397 rx_SetMinProcs(tservice, 2);
398 rx_SetMaxProcs(tservice, 4);
400 LogCommandLine(argc, argv, "vlserver", VldbVersion, "Starting AFS", FSLog);
401 printf("%s\n", cml_version_number); /* Goes to the log */
403 /* allow super users to manage RX statistics */
404 rx_SetRxStatUserOk(vldb_rxstat_userok);
406 rx_StartServer(1); /* Why waste this idle process?? */
408 return 0; /* not reachable */