a3fc74390906141a097959fb38aac1a559e101a8
[openafs.git] / src / volser / volmain.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 #include <afsconfig.h>
11 #include <afs/param.h>
12
13 #include <roken.h>
14 #include <afs/opr.h>
15 #ifdef AFS_PTHREAD_ENV
16 # include <opr/lock.h>
17 # include <opr/softsig.h>
18 #endif
19
20 #ifdef AFS_NT40_ENV
21 #include <windows.h>
22 #include <WINNT/afsevent.h>
23 #endif
24
25 #include <rx/rx_queue.h>
26 #include <afs/afsint.h>
27 #include <afs/prs_fs.h>
28 #include <afs/nfs.h>
29 #include <lwp.h>
30 #include <lock.h>
31 #include <afs/afssyscalls.h>
32 #include <afs/ihandle.h>
33 #ifdef AFS_NT40_ENV
34 #include <afs/ntops.h>
35 #endif
36 #include <afs/vnode.h>
37 #include <afs/volume.h>
38 #include <afs/partition.h>
39 #include <rx/rx.h>
40 #include <rx/rxstat.h>
41 #include <rx/rx_globals.h>
42 #include <afs/auth.h>
43 #include <afs/cellconfig.h>
44 #include <afs/keys.h>
45 #include <afs/dir.h>
46 #include <ubik.h>
47 #include <afs/audit.h>
48 #include <afs/afsutil.h>
49 #include <afs/cmd.h>
50 #include <lwp.h>
51
52 #include "volser.h"
53 #include "volint.h"
54 #include "volser_internal.h"
55
56 #define VolserVersion "2.0"
57 #define N_SECURITY_OBJECTS 3
58
59 extern struct Lock localLock;
60 char *GlobalNameHack = NULL;
61 int hackIsIn = 0;
62 afs_int32 GlobalVolCloneId, GlobalVolParentId;
63 int GlobalVolType;
64 int VolumeChanged;              /* XXXX */
65 static char busyFlags[MAXHELPERS];
66 struct volser_trans *QI_GlobalWriteTrans = 0;
67 struct afsconf_dir *tdir;
68 static afs_int32 runningCalls = 0;
69 int DoLogging = 0;
70 int debuglevel = 0;
71 #define MAXLWP 128
72 int lwps = 9;
73 int udpBufSize = 0;             /* UDP buffer size for receive */
74 int restrictedQueryLevel = RESTRICTED_QUERY_ANYUSER;
75
76 int rxBind = 0;
77 int rxkadDisableDotCheck = 0;
78 int DoPreserveVolumeStats = 1;
79 int rxJumbograms = 0;   /* default is to not send and receive jumbograms. */
80 int rxMaxMTU = -1;
81 char *auditFileName = NULL;
82 static struct logOptions logopts;
83 char *configDir = NULL;
84
85 enum vol_s2s_crypt doCrypt = VS2SC_NEVER;
86
87 #define ADDRSPERSITE 16         /* Same global is in rx/rx_user.c */
88 afs_uint32 SHostAddrs[ADDRSPERSITE];
89
90 #define VS_EXIT(code)  {                                          \
91                           osi_audit(VS_ExitEvent, code, AUD_END); \
92                           exit(code);                             \
93                        }
94
95 static void
96 MyBeforeProc(struct rx_call *acall)
97 {
98     VTRANS_LOCK;
99     runningCalls++;
100     VTRANS_UNLOCK;
101     return;
102 }
103
104 static void
105 MyAfterProc(struct rx_call *acall, afs_int32 code)
106 {
107     VTRANS_LOCK;
108     runningCalls--;
109     VTRANS_UNLOCK;
110     return;
111 }
112
113 /* Called every GCWAKEUP seconds to try to unlock all our partitions,
114  * if we're idle and there are no active transactions
115  */
116 static void
117 TryUnlock(void)
118 {
119     /* if there are no running calls, and there are no active transactions, then
120      * it should be safe to release any partition locks we've accumulated */
121     VTRANS_LOCK;
122     if (runningCalls == 0 && TransList() == (struct volser_trans *)0) {
123         VTRANS_UNLOCK;
124         VPFullUnlock();         /* in volprocs.c */
125     } else
126         VTRANS_UNLOCK;
127 }
128
129 /* background daemon for timing out transactions */
130 static void*
131 BKGLoop(void *unused)
132 {
133     struct timeval tv;
134     int loop = 0;
135
136     opr_threadname_set("vol bkg");
137     while (1) {
138         tv.tv_sec = GCWAKEUP;
139         tv.tv_usec = 0;
140 #ifdef AFS_PTHREAD_ENV
141 #ifdef AFS_NT40_ENV
142         Sleep(GCWAKEUP * 1000);
143 #else
144         select(0, 0, 0, 0, &tv);
145 #endif
146 #else
147         (void)IOMGR_Select(0, 0, 0, 0, &tv);
148 #endif
149         GCTrans();
150         TryUnlock();
151         loop++;
152         if (loop == 10) {       /* reopen log every 5 minutes */
153             loop = 0;
154             ReOpenLog();
155         }
156     }
157
158     AFS_UNREACHED(return(NULL));
159 }
160
161 #if defined(AFS_NT40_ENV) || defined(AFS_DARWIN160_ENV)
162 /* no volser_syscall */
163 #elif defined(AFS_SUN511_ENV)
164 int
165 volser_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
166 {
167     int err, code;
168     code = ioctl_sun_afs_syscall(28 /* AFSCALL_CALL */, a3, a4, a5, 0, 0, 0,
169                                  &err);
170     if (code) {
171         err = code;
172     }
173     return err;
174 }
175 #elif !defined(AFS_SYSCALL)
176 int
177 volser_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
178 {
179     errno = ENOSYS;
180     return -1;
181 }
182 #else
183 int
184 volser_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
185 {
186     afs_uint32 rcode;
187 #ifndef AFS_LINUX20_ENV
188     void (*old) (int);
189
190     old = signal(SIGSYS, SIG_IGN);
191 #endif
192     rcode =
193         syscall(AFS_SYSCALL /* AFS_SYSCALL */ , 28 /* AFSCALL_CALL */ , a3,
194                 a4, a5);
195 #ifndef AFS_LINUX20_ENV
196     signal(SIGSYS, old);
197 #endif
198
199     return rcode;
200 }
201 #endif
202
203
204 /* check whether caller is authorized to manage RX statistics */
205 int
206 vol_rxstat_userok(struct rx_call *call)
207 {
208     return afsconf_SuperUser(tdir, call, NULL);
209 }
210
211 /**
212  * Return true if this name is a member of the local realm.
213  */
214 static int
215 vol_IsLocalRealmMatch(void *rock, char *name, char *inst, char *cell)
216 {
217     struct afsconf_dir *dir = (struct afsconf_dir *)rock;
218     afs_int32 islocal = 0;      /* default to no */
219     int code;
220
221     code = afsconf_IsLocalRealmMatch(dir, &islocal, name, inst, cell);
222     if (code) {
223         ViceLog(0,
224                 ("Failed local realm check; code=%d, name=%s, inst=%s, cell=%s\n",
225                  code, name, inst, cell));
226     }
227     return islocal;
228 }
229
230 enum optionsList {
231     OPT_log,
232     OPT_rxbind,
233     OPT_dotted,
234     OPT_debug,
235     OPT_threads,
236     OPT_auditlog,
237     OPT_audit_interface,
238     OPT_nojumbo,
239     OPT_jumbo,
240     OPT_rxmaxmtu,
241     OPT_sleep,
242     OPT_udpsize,
243     OPT_peer,
244     OPT_process,
245     OPT_preserve_vol_stats,
246     OPT_clear_vol_stats,
247     OPT_sync,
248 #ifdef HAVE_SYSLOG
249     OPT_syslog,
250 #endif
251     OPT_logfile,
252     OPT_config,
253     OPT_restricted_query,
254     OPT_transarc_logs,
255     OPT_s2s_crypt
256 };
257
258 static int
259 ParseArgs(int argc, char **argv) {
260     int code;
261     int optval;
262     char *optstring = NULL;
263     struct cmd_syndesc *opts;
264     char *sleepSpec = NULL;
265     char *sync_behavior = NULL;
266     char *restricted_query_parameter = NULL;
267     char *s2s_crypt_behavior = NULL;
268
269     opts = cmd_CreateSyntax(NULL, NULL, NULL, 0, NULL);
270     cmd_AddParmAtOffset(opts, OPT_log, "-log", CMD_FLAG, CMD_OPTIONAL,
271            "log vos users");
272     cmd_AddParmAtOffset(opts, OPT_rxbind, "-rxbind", CMD_FLAG, CMD_OPTIONAL,
273            "bind only to the primary interface");
274     cmd_AddParmAtOffset(opts, OPT_dotted, "-allow-dotted-principals", CMD_FLAG, CMD_OPTIONAL,
275            "permit Kerberos 5 principals with dots");
276     cmd_AddParmAtOffset(opts, OPT_debug, "-d", CMD_SINGLE, CMD_OPTIONAL,
277            "debug level");
278     cmd_AddParmAtOffset(opts, OPT_threads, "-p", CMD_SINGLE, CMD_OPTIONAL,
279            "number of threads");
280     cmd_AddParmAtOffset(opts, OPT_auditlog, "-auditlog", CMD_SINGLE,
281            CMD_OPTIONAL, "location of audit log");
282     cmd_AddParmAtOffset(opts, OPT_audit_interface, "-audit-interface",
283            CMD_SINGLE, CMD_OPTIONAL, "interface to use for audit logging");
284     cmd_AddParmAtOffset(opts, OPT_nojumbo, "-nojumbo", CMD_FLAG, CMD_OPTIONAL,
285             "disable jumbograms");
286     cmd_AddParmAtOffset(opts, OPT_jumbo, "-jumbo", CMD_FLAG, CMD_OPTIONAL,
287             "enable jumbograms");
288     cmd_AddParmAtOffset(opts, OPT_rxmaxmtu, "-rxmaxmtu", CMD_SINGLE,
289             CMD_OPTIONAL, "maximum MTU for RX");
290     cmd_AddParmAtOffset(opts, OPT_udpsize, "-udpsize", CMD_SINGLE,
291             CMD_OPTIONAL, "size of socket buffer in bytes");
292     cmd_AddParmAtOffset(opts, OPT_sleep, "-sleep", CMD_SINGLE,
293             CMD_OPTIONAL, "make background daemon sleep (LWP only)");
294     cmd_AddParmAtOffset(opts, OPT_peer, "-enable_peer_stats", CMD_FLAG,
295             CMD_OPTIONAL, "enable RX transport statistics");
296     cmd_AddParmAtOffset(opts, OPT_process, "-enable_process_stats", CMD_FLAG,
297             CMD_OPTIONAL, "enable RX RPC statistics");
298     /* -preserve-vol-stats on by default now. */
299     cmd_AddParmAtOffset(opts, OPT_preserve_vol_stats, "-preserve-vol-stats", CMD_FLAG,
300             CMD_OPTIONAL|CMD_HIDDEN,
301             "preserve volume statistics when restoring/recloning");
302     cmd_AddParmAtOffset(opts, OPT_clear_vol_stats, "-clear-vol-stats", CMD_FLAG,
303             CMD_OPTIONAL, "clear volume statistics when restoring/recloning");
304 #ifdef HAVE_SYSLOG
305     cmd_AddParmAtOffset(opts, OPT_syslog, "-syslog", CMD_SINGLE_OR_FLAG,
306             CMD_OPTIONAL, "log to syslog");
307 #endif
308     cmd_AddParmAtOffset(opts, OPT_transarc_logs, "-transarc-logs", CMD_FLAG,
309                         CMD_OPTIONAL, "enable Transarc style logging");
310     cmd_AddParmAtOffset(opts, OPT_sync, "-sync",
311             CMD_SINGLE, CMD_OPTIONAL, "always | onclose | never");
312     cmd_AddParmAtOffset(opts, OPT_logfile, "-logfile", CMD_SINGLE,
313            CMD_OPTIONAL, "location of log file");
314     cmd_AddParmAtOffset(opts, OPT_config, "-config", CMD_SINGLE,
315            CMD_OPTIONAL, "configuration location");
316     cmd_AddParmAtOffset(opts, OPT_restricted_query, "-restricted_query",
317             CMD_SINGLE, CMD_OPTIONAL, "anyuser | admin");
318     cmd_AddParmAtOffset(opts, OPT_s2s_crypt, "-s2scrypt",
319             CMD_SINGLE, CMD_OPTIONAL, "always | inherit | never");
320
321     code = cmd_Parse(argc, argv, &opts);
322     if (code == CMD_HELP) {
323         exit(0);
324     }
325     if (code)
326         return 1;
327
328     cmd_OptionAsFlag(opts, OPT_log, &DoLogging);
329     cmd_OptionAsFlag(opts, OPT_rxbind, &rxBind);
330     cmd_OptionAsFlag(opts, OPT_dotted, &rxkadDisableDotCheck);
331     if (cmd_OptionPresent(opts, OPT_clear_vol_stats))
332         DoPreserveVolumeStats = 0;
333     if (cmd_OptionPresent(opts, OPT_peer))
334         rx_enablePeerRPCStats();
335     if (cmd_OptionPresent(opts, OPT_process))
336         rx_enableProcessRPCStats();
337     if (cmd_OptionPresent(opts, OPT_nojumbo))
338         rxJumbograms = 0;
339     if (cmd_OptionPresent(opts, OPT_jumbo))
340         rxJumbograms = 1;
341
342 #ifdef HAVE_SYSLOG
343     if (cmd_OptionPresent(opts, OPT_syslog)) {
344         if (cmd_OptionPresent(opts, OPT_logfile)) {
345             fprintf(stderr, "Invalid options: -syslog and -logfile are exclusive.\n");
346             return -1;
347         }
348         if (cmd_OptionPresent(opts, OPT_transarc_logs)) {
349             fprintf(stderr, "Invalid options: -syslog and -transarc-logs are exclusive.\n");
350             return -1;
351         }
352         logopts.lopt_dest = logDest_syslog;
353         logopts.lopt_facility = LOG_DAEMON;
354         logopts.lopt_tag = "volserver";
355         cmd_OptionAsInt(opts, OPT_syslog, &logopts.lopt_facility);
356     } else
357 #endif
358     {
359         logopts.lopt_dest = logDest_file;
360         if (cmd_OptionPresent(opts, OPT_transarc_logs)) {
361             logopts.lopt_rotateOnOpen = 1;
362             logopts.lopt_rotateStyle = logRotate_old;
363         }
364         if (cmd_OptionPresent(opts, OPT_logfile))
365             cmd_OptionAsString(opts, OPT_logfile, (char**)&logopts.lopt_filename);
366         else
367             logopts.lopt_filename = AFSDIR_SERVER_VOLSERLOG_FILEPATH;
368     }
369     cmd_OptionAsInt(opts, OPT_debug, &logopts.lopt_logLevel);
370
371     cmd_OptionAsInt(opts, OPT_rxmaxmtu, &rxMaxMTU);
372     if (cmd_OptionAsInt(opts, OPT_udpsize, &optval) == 0) {
373         if (optval < rx_GetMinUdpBufSize()) {
374             printf("Warning:udpsize %d is less than minimum %d; ignoring\n",
375                     optval, rx_GetMinUdpBufSize());
376         } else
377             udpBufSize = optval;
378     }
379     cmd_OptionAsString(opts, OPT_auditlog, &auditFileName);
380
381     if (cmd_OptionAsString(opts, OPT_audit_interface, &optstring) == 0) {
382         if (osi_audit_interface(optstring)) {
383             printf("Invalid audit interface '%s'\n", optstring);
384             return -1;
385         }
386         free(optstring);
387         optstring = NULL;
388     }
389     if (cmd_OptionAsInt(opts, OPT_threads, &lwps) == 0) {
390         if (lwps > MAXLWP) {
391             printf("Warning: '-p %d' is too big; using %d instead\n", lwps, MAXLWP);
392             lwps = MAXLWP;
393         }
394     }
395     if (cmd_OptionAsString(opts, OPT_sleep, &sleepSpec) == 0) {
396         printf("Warning: -sleep option ignored; this option is obsolete\n");
397     }
398     if (cmd_OptionAsString(opts, OPT_sync, &sync_behavior) == 0) {
399         if (ih_SetSyncBehavior(sync_behavior)) {
400             printf("Invalid -sync value %s\n", sync_behavior);
401             return -1;
402         }
403     }
404     cmd_OptionAsString(opts, OPT_config, &configDir);
405     if (cmd_OptionAsString(opts, OPT_restricted_query,
406                            &restricted_query_parameter) == 0) {
407         if (strcmp(restricted_query_parameter, "anyuser") == 0)
408             restrictedQueryLevel = RESTRICTED_QUERY_ANYUSER;
409         else if (strcmp(restricted_query_parameter, "admin") == 0)
410             restrictedQueryLevel = RESTRICTED_QUERY_ADMIN;
411         else {
412             printf("invalid argument for -restricted_query: %s\n",
413                    restricted_query_parameter);
414             return -1;
415         }
416         free(restricted_query_parameter);
417     }
418     if (cmd_OptionAsString(opts, OPT_s2s_crypt, &s2s_crypt_behavior) == 0) {
419         if (strcmp(s2s_crypt_behavior, "always") == 0)
420             doCrypt = VS2SC_ALWAYS;
421         else if (strcmp(s2s_crypt_behavior, "never") == 0)
422             doCrypt = VS2SC_NEVER;
423         else if (strcmp(s2s_crypt_behavior, "inherit") == 0)
424             doCrypt = VS2SC_INHERIT;
425         else {
426             printf("invalid argument for -s2scrypt: %s\n", s2s_crypt_behavior);
427             return -1;
428         }
429         free(s2s_crypt_behavior);
430     }
431
432     return 0;
433 }
434
435 #include "AFS_component_version_number.c"
436 int
437 main(int argc, char **argv)
438 {
439     afs_int32 code;
440     struct rx_securityClass **securityClasses;
441     afs_int32 numClasses;
442     struct rx_service *service;
443     int rxpackets = 100;
444     char hoststr[16];
445     afs_uint32 host = ntohl(INADDR_ANY);
446     VolumePackageOptions opts;
447
448 #ifdef  AFS_AIX32_ENV
449     /*
450      * The following signal action for AIX is necessary so that in case of a
451      * crash (i.e. core is generated) we can include the user's data section
452      * in the core dump. Unfortunately, by default, only a partial core is
453      * generated which, in many cases, isn't too useful.
454      */
455     struct sigaction nsa;
456
457     sigemptyset(&nsa.sa_mask);
458     nsa.sa_handler = SIG_DFL;
459     nsa.sa_flags = SA_FULLDUMP;
460     sigaction(SIGABRT, &nsa, NULL);
461     sigaction(SIGSEGV, &nsa, NULL);
462 #endif
463     osi_audit_init();
464     osi_audit(VS_StartEvent, 0, AUD_END);
465
466     /* Initialize dirpaths */
467     if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
468 #ifdef AFS_NT40_ENV
469         ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
470 #endif
471         fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
472                 argv[0]);
473         exit(2);
474     }
475
476     configDir = strdup(AFSDIR_SERVER_ETC_DIRPATH);
477
478     if (ParseArgs(argc, argv)) {
479         exit(1);
480     }
481
482     if (auditFileName) {
483         osi_audit_file(auditFileName);
484         osi_audit(VS_StartEvent, 0, AUD_END);
485     }
486 #ifdef AFS_SGI_VNODE_GLUE
487     if (afs_init_kernel_config(-1) < 0) {
488         printf
489             ("Can't determine NUMA configuration, not starting volserver.\n");
490         exit(1);
491     }
492 #endif
493     InitErrTabs();
494
495 #ifdef AFS_PTHREAD_ENV
496     SetLogThreadNumProgram( rx_GetThreadNum );
497 #endif
498
499 #ifdef AFS_NT40_ENV
500     if (afs_winsockInit() < 0) {
501         ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
502         printf("Volume server unable to start winsock, exiting.\n");
503         exit(1);
504     }
505 #endif
506
507     OpenLog(&logopts);
508
509     VOptDefaults(volumeServer, &opts);
510     if (VInitVolumePackage2(volumeServer, &opts)) {
511         Log("Shutting down: errors encountered initializing volume package\n");
512         exit(1);
513     }
514     /* For nuke() */
515     Lock_Init(&localLock);
516     DInit(40);
517 #ifndef AFS_PTHREAD_ENV
518     vol_PollProc = IOMGR_Poll;  /* tell vol pkg to poll io system periodically */
519 #endif
520 #if !defined( AFS_NT40_ENV ) && !defined(AFS_DARWIN160_ENV)
521     rxi_syscallp = volser_syscall;
522 #endif
523     rx_nPackets = rxpackets;    /* set the max number of packets */
524     if (udpBufSize)
525         rx_SetUdpBufSize(udpBufSize);   /* set the UDP buffer size for receive */
526     if (rxBind) {
527         afs_int32 ccode;
528         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
529             AFSDIR_SERVER_NETINFO_FILEPATH) {
530             char reason[1024];
531             ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
532                                           ADDRSPERSITE, reason,
533                                           AFSDIR_SERVER_NETINFO_FILEPATH,
534                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
535         } else
536         {
537             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
538         }
539         if (ccode == 1)
540             host = SHostAddrs[0];
541     }
542
543     Log("Volserver binding rx to %s:%d\n",
544         afs_inet_ntoa_r(host, hoststr), AFSCONF_VOLUMEPORT);
545     code = rx_InitHost(host, (int)htons(AFSCONF_VOLUMEPORT));
546     if (code) {
547         fprintf(stderr, "rx init failed on socket AFSCONF_VOLUMEPORT %u\n",
548                 AFSCONF_VOLUMEPORT);
549         VS_EXIT(1);
550     }
551     if (!rxJumbograms) {
552         /* Don't allow 3.4 vos clients to send jumbograms and we don't send. */
553         rx_SetNoJumbo();
554     }
555     if (rxMaxMTU != -1) {
556         if (rx_SetMaxMTU(rxMaxMTU) != 0) {
557             fprintf(stderr, "rxMaxMTU %d is invalid\n", rxMaxMTU);
558             VS_EXIT(1);
559         }
560     }
561     rx_GetIFInfo();
562     rx_SetRxDeadTime(420);
563     memset(busyFlags, 0, sizeof(busyFlags));
564
565 #ifdef AFS_PTHREAD_ENV
566     opr_softsig_Init();
567     SetupLogSoftSignals();
568 #else
569     SetupLogSignals();
570 #endif
571
572     {
573 #ifdef AFS_PTHREAD_ENV
574         pthread_t tid;
575         pthread_attr_t tattr;
576         opr_Verify(pthread_attr_init(&tattr) == 0);
577         opr_Verify(pthread_attr_setdetachstate(&tattr,
578                                                PTHREAD_CREATE_DETACHED) == 0);
579         opr_Verify(pthread_create(&tid, &tattr, BKGLoop, NULL) == 0);
580 #else
581         PROCESS pid;
582         LWP_CreateProcess(BKGLoop, 16*1024, 3, 0, "vol bkg daemon", &pid);
583 #endif
584     }
585
586     /* Create a single security object, in this case the null security object, for unauthenticated connections, which will be used to control security on connections made to this server */
587
588     tdir = afsconf_Open(configDir);
589     if (!tdir) {
590         Abort("volser: could not open conf files in %s\n",
591               configDir);
592         AFS_UNREACHED(VS_EXIT(1));
593     }
594
595     /* initialize audit user check */
596     osi_audit_set_user_check(tdir, vol_IsLocalRealmMatch);
597
598     afsconf_BuildServerSecurityObjects(tdir, &securityClasses, &numClasses);
599     if (securityClasses[0] == NULL)
600         Abort("rxnull_NewServerSecurityObject");
601     service =
602         rx_NewServiceHost(host, 0, VOLSERVICE_ID, "VOLSER", securityClasses,
603                           numClasses, AFSVolExecuteRequest);
604     if (service == (struct rx_service *)0)
605         Abort("rx_NewService");
606     rx_SetBeforeProc(service, MyBeforeProc);
607     rx_SetAfterProc(service, MyAfterProc);
608     rx_SetIdleDeadTime(service, 0);     /* never timeout */
609     if (lwps < 4)
610         lwps = 4;
611     rx_SetMaxProcs(service, lwps);
612 #if defined(AFS_XBSD_ENV)
613     rx_SetStackSize(service, (128 * 1024));
614 #elif defined(AFS_SGI_ENV)
615     rx_SetStackSize(service, (48 * 1024));
616 #else
617     rx_SetStackSize(service, (32 * 1024));
618 #endif
619
620     if (rxkadDisableDotCheck) {
621         code = rx_SetSecurityConfiguration(service, RXS_CONFIG_FLAGS,
622                                            (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
623         if (code) {
624             fprintf(stderr,
625                     "volser: failed to allow dotted principals: code %d\n",
626                     code);
627             VS_EXIT(1);
628         }
629     }
630
631     service =
632         rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", securityClasses,
633                       numClasses, RXSTATS_ExecuteRequest);
634     if (service == (struct rx_service *)0)
635         Abort("rx_NewService");
636     rx_SetMinProcs(service, 2);
637     rx_SetMaxProcs(service, 4);
638
639     LogCommandLine(argc, argv, "Volserver", VolserVersion, "Starting AFS",
640                    Log);
641     if (afsconf_GetLatestKey(tdir, NULL, NULL) == 0) {
642         LogDesWarning();
643     }
644
645     /* allow super users to manage RX statistics */
646     rx_SetRxStatUserOk(vol_rxstat_userok);
647
648     rx_StartServer(1);          /* Donate this process to the server process pool */
649
650     osi_audit(VS_FinishEvent, (-1), AUD_END);
651     Abort("StartServer returned?");
652     AFS_UNREACHED(return 0);
653 }