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>
17 #include <WINNT/afsevent.h>
20 #ifdef HAVE_SYS_FILE_H
26 #include <rx/rx_globals.h>
27 #include <rx/rxstat.h>
28 #include <afs/cellconfig.h>
31 #include <afs/audit.h>
32 #include <afs/com_err.h>
35 #include <afs/afsutil.h>
38 #include "vlserver_internal.h"
41 const char *vl_dbaseName;
42 struct afsconf_dir *vldb_confdir = 0; /* vldb configuration dir */
45 struct vldstats dynamic_statistics;
46 struct ubik_dbase *VL_dbase;
47 afs_uint32 rd_HostAddress[MAXSERVERID + 1];
48 afs_uint32 wr_HostAddress[MAXSERVERID + 1];
50 static void *CheckSignal(void*);
53 int rxJumbograms = 0; /* default is to not send and receive jumbo grams */
56 int rxkadDisableDotCheck = 0;
59 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
60 afs_uint32 SHostAddrs[ADDRSPERSITE];
63 CheckSignal_Signal(int unused)
65 #if defined(AFS_PTHREAD_ENV)
68 IOMGR_SoftSig(CheckSignal, 0);
73 CheckSignal(void *unused)
79 Init_VLdbase(&ctx, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE)))
80 return (void *)(intptr_t)errorcode;
81 VLog(0, ("Dump name hash table out\n"));
82 for (i = 0; i < HASHSIZE; i++) {
85 VLog(0, ("Dump id hash table out\n"));
86 for (i = 0; i < HASHSIZE; i++) {
89 return ((void *)(intptr_t)ubik_EndTrans(ctx.trans));
93 /* Initialize the stats for the opcodes */
95 initialize_dstats(void)
99 dynamic_statistics.start_time = (afs_uint32) time(0);
100 for (i = 0; i < MAX_NUMBER_OPCODES; i++) {
101 dynamic_statistics.requests[i] = 0;
102 dynamic_statistics.aborts[i] = 0;
106 /* check whether caller is authorized to manage RX statistics */
108 vldb_rxstat_userok(struct rx_call *call)
110 return afsconf_SuperUser(vldb_confdir, call, NULL);
113 /* Main server module */
115 #include "AFS_component_version_number.c"
118 main(int argc, char **argv)
122 struct rx_service *tservice;
123 struct rx_securityClass **securityClasses;
124 afs_int32 numClasses;
125 struct afsconf_dir *tdir;
126 struct ktc_encryptionKey tkey;
127 struct afsconf_cell info;
129 char hostname[VL_MAXNAMELEN];
130 int noAuth = 0, index;
131 char clones[MAXHOSTSPERCELL];
132 char *auditFileName = NULL;
133 afs_uint32 host = ntohl(INADDR_ANY);
137 * The following signal action for AIX is necessary so that in case of a
138 * crash (i.e. core is generated) we can include the user's data section
139 * in the core dump. Unfortunately, by default, only a partial core is
140 * generated which, in many cases, isn't too useful.
142 struct sigaction nsa;
144 rx_extraPackets = 100; /* should be a switch, I guess... */
145 sigemptyset(&nsa.sa_mask);
146 nsa.sa_handler = SIG_DFL;
147 nsa.sa_flags = SA_FULLDUMP;
148 sigaction(SIGABRT, &nsa, NULL);
149 sigaction(SIGSEGV, &nsa, NULL);
153 /* Parse command line */
154 for (index = 1; index < argc; index++) {
155 if (strcmp(argv[index], "-noauth") == 0) {
157 } else if (strcmp(argv[index], "-p") == 0) {
158 lwps = atoi(argv[++index]);
160 printf("Warning: '-p %d' is too big; using %d instead\n",
164 } else if (strcmp(argv[index], "-d") == 0) {
165 if ((index + 1) >= argc) {
166 fprintf(stderr, "missing argument for -d\n");
169 debuglevel = atoi(argv[++index]);
170 LogLevel = debuglevel;
171 } else if (strcmp(argv[index], "-nojumbo") == 0) {
173 } else if (strcmp(argv[index], "-jumbo") == 0) {
175 } else if (strcmp(argv[index], "-rxbind") == 0) {
177 } else if (strcmp(argv[index], "-allow-dotted-principals") == 0) {
178 rxkadDisableDotCheck = 1;
179 } else if (!strcmp(argv[index], "-rxmaxmtu")) {
180 if ((index + 1) >= argc) {
181 fprintf(stderr, "missing argument for -rxmaxmtu\n");
184 rxMaxMTU = atoi(argv[++index]);
185 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
186 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
187 printf("rxMaxMTU %d invalid; must be between %d-%" AFS_SIZET_FMT "\n",
188 rxMaxMTU, RX_MIN_PACKET_SIZE,
189 RX_MAX_PACKET_DATA_SIZE);
193 } else if (strcmp(argv[index], "-smallmem") == 0) {
196 } else if (strcmp(argv[index], "-trace") == 0) {
197 extern char rxi_tracename[80];
198 strcpy(rxi_tracename, argv[++index]);
200 } else if (strcmp(argv[index], "-auditlog") == 0) {
201 auditFileName = argv[++index];
203 } else if (strcmp(argv[index], "-audit-interface") == 0) {
204 char *interface = argv[++index];
206 if (osi_audit_interface(interface)) {
207 printf("Invalid audit interface '%s'\n", interface);
211 } else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
212 rx_enablePeerRPCStats();
213 } else if (strcmp(argv[index], "-enable_process_stats") == 0) {
214 rx_enableProcessRPCStats();
216 } else if (strcmp(argv[index], "-syslog") == 0) {
217 /* set syslog logging flag */
219 } else if (strncmp(argv[index], "-syslog=", 8) == 0) {
221 serverLogSyslogFacility = atoi(argv[index] + 8);
224 /* support help flag */
226 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
227 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
228 "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
229 "[-syslog[=FACILITY]] "
230 "[-enable_peer_stats] [-enable_process_stats] "
233 printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
234 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
235 "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
236 "[-enable_peer_stats] [-enable_process_stats] "
245 osi_audit_file(auditFileName);
248 /* Initialize dirpaths */
249 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
251 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
253 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
257 vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH;
260 serverLogSyslogTag = "vlserver";
262 OpenLog(AFSDIR_SERVER_VLOG_FILEPATH); /* set up logging */
265 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
268 ("vlserver: can't open configuration files in dir %s, giving up.\n",
269 AFSDIR_SERVER_ETC_DIRPATH);
273 /* initialize winsock */
274 if (afs_winsockInit() < 0) {
275 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
276 fprintf(stderr, "vlserver: couldn't initialize winsock. \n");
281 gethostname(hostname, sizeof(hostname));
282 th = gethostbyname(hostname);
284 printf("vlserver: couldn't get address of this host (%s).\n",
288 memcpy(&myHost, th->h_addr, sizeof(afs_uint32));
290 #if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV)
291 signal(SIGXCPU, CheckSignal_Signal);
293 /* get list of servers */
295 afsconf_GetExtendedCellInfo(tdir, NULL, AFSCONF_VLDBSERVICE, &info,
298 printf("vlserver: Couldn't get cell server list for 'afsvldb'.\n");
302 vldb_confdir = tdir; /* Preserve our configuration dir */
303 /* rxvab no longer supported */
304 memset(&tkey, 0, sizeof(tkey));
307 afsconf_SetNoAuthFlag(tdir, 1);
312 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
313 AFSDIR_SERVER_NETINFO_FILEPATH) {
315 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
316 ADDRSPERSITE, reason,
317 AFSDIR_SERVER_NETINFO_FILEPATH,
318 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
322 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
325 host = SHostAddrs[0];
326 rx_InitHost(host, htons(AFSCONF_VLDBPORT));
331 ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate, tdir);
332 ubik_SetServerSecurityProcs(afsconf_BuildServerSecurityObjects,
333 afsconf_CheckAuth, tdir);
335 ubik_SyncWriterCacheProc = vlsynccache;
337 ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, clones,
338 vl_dbaseName, &VL_dbase);
340 printf("vlserver: Ubik init failed: %s\n", afs_error_message(code));
346 if (rxMaxMTU != -1) {
347 rx_SetMaxMTU(rxMaxMTU);
349 rx_SetRxDeadTime(50);
351 memset(rd_HostAddress, 0, sizeof(rd_HostAddress));
352 memset(wr_HostAddress, 0, sizeof(wr_HostAddress));
355 afsconf_BuildServerSecurityObjects(tdir, &securityClasses, &numClasses);
358 rx_NewServiceHost(host, 0, USER_SERVICE_ID, "Vldb server",
359 securityClasses, numClasses,
361 if (tservice == (struct rx_service *)0) {
362 printf("vlserver: Could not create VLDB_SERVICE rx service\n");
365 rx_SetMinProcs(tservice, 2);
368 rx_SetMaxProcs(tservice, lwps);
370 if (rxkadDisableDotCheck) {
371 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
372 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
376 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats",
377 securityClasses, numClasses,
378 RXSTATS_ExecuteRequest);
379 if (tservice == (struct rx_service *)0) {
380 printf("vlserver: Could not create rpc stats rx service\n");
383 rx_SetMinProcs(tservice, 2);
384 rx_SetMaxProcs(tservice, 4);
386 LogCommandLine(argc, argv, "vlserver", VldbVersion, "Starting AFS", FSLog);
387 printf("%s\n", cml_version_number); /* Goes to the log */
389 /* allow super users to manage RX statistics */
390 rx_SetRxStatUserOk(vldb_rxstat_userok);
392 rx_StartServer(1); /* Why waste this idle process?? */
394 return 0; /* not reachable */