volser: Avoid calling osi_audit before audit init
[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 RPC statistics by peer");
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
465     /* Initialize dirpaths */
466     if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
467 #ifdef AFS_NT40_ENV
468         ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
469 #endif
470         fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
471                 argv[0]);
472         exit(2);
473     }
474
475     configDir = strdup(AFSDIR_SERVER_ETC_DIRPATH);
476
477     if (ParseArgs(argc, argv)) {
478         exit(1);
479     }
480
481     if (auditFileName) {
482         if (osi_audit_file(auditFileName)) {
483             fprintf(stderr, "error from opening auditlog %s\n", auditFileName);
484             exit(1);
485         }
486     }
487     osi_audit(VS_StartEvent, 0, AUD_END);
488 #ifdef AFS_SGI_VNODE_GLUE
489     if (afs_init_kernel_config(-1) < 0) {
490         printf
491             ("Can't determine NUMA configuration, not starting volserver.\n");
492         exit(1);
493     }
494 #endif
495     InitErrTabs();
496
497 #ifdef AFS_PTHREAD_ENV
498     SetLogThreadNumProgram( rx_GetThreadNum );
499 #endif
500
501 #ifdef AFS_NT40_ENV
502     if (afs_winsockInit() < 0) {
503         ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
504         printf("Volume server unable to start winsock, exiting.\n");
505         exit(1);
506     }
507 #endif
508
509     OpenLog(&logopts);
510
511     VOptDefaults(volumeServer, &opts);
512     if (VInitVolumePackage2(volumeServer, &opts)) {
513         Log("Shutting down: errors encountered initializing volume package\n");
514         exit(1);
515     }
516     /* For nuke() */
517     Lock_Init(&localLock);
518     DInit(40);
519 #ifndef AFS_PTHREAD_ENV
520     vol_PollProc = IOMGR_Poll;  /* tell vol pkg to poll io system periodically */
521 #endif
522 #if !defined( AFS_NT40_ENV ) && !defined(AFS_DARWIN160_ENV)
523     rxi_syscallp = volser_syscall;
524 #endif
525     rx_nPackets = rxpackets;    /* set the max number of packets */
526     if (udpBufSize)
527         rx_SetUdpBufSize(udpBufSize);   /* set the UDP buffer size for receive */
528     if (rxBind) {
529         afs_int32 ccode;
530         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
531             AFSDIR_SERVER_NETINFO_FILEPATH) {
532             char reason[1024];
533             ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
534                                           ADDRSPERSITE, reason,
535                                           AFSDIR_SERVER_NETINFO_FILEPATH,
536                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
537         } else
538         {
539             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
540         }
541         if (ccode == 1)
542             host = SHostAddrs[0];
543     }
544
545     Log("Volserver binding rx to %s:%d\n",
546         afs_inet_ntoa_r(host, hoststr), AFSCONF_VOLUMEPORT);
547     code = rx_InitHost(host, (int)htons(AFSCONF_VOLUMEPORT));
548     if (code) {
549         fprintf(stderr, "rx init failed on socket AFSCONF_VOLUMEPORT %u\n",
550                 AFSCONF_VOLUMEPORT);
551         VS_EXIT(1);
552     }
553     if (!rxJumbograms) {
554         /* Don't allow 3.4 vos clients to send jumbograms and we don't send. */
555         rx_SetNoJumbo();
556     }
557     if (rxMaxMTU != -1) {
558         if (rx_SetMaxMTU(rxMaxMTU) != 0) {
559             fprintf(stderr, "rxMaxMTU %d is invalid\n", rxMaxMTU);
560             VS_EXIT(1);
561         }
562     }
563     rx_GetIFInfo();
564     rx_SetRxDeadTime(420);
565     memset(busyFlags, 0, sizeof(busyFlags));
566
567 #ifdef AFS_PTHREAD_ENV
568     opr_softsig_Init();
569     SetupLogSoftSignals();
570 #else
571     SetupLogSignals();
572 #endif
573
574     {
575 #ifdef AFS_PTHREAD_ENV
576         pthread_t tid;
577         pthread_attr_t tattr;
578         opr_Verify(pthread_attr_init(&tattr) == 0);
579         opr_Verify(pthread_attr_setdetachstate(&tattr,
580                                                PTHREAD_CREATE_DETACHED) == 0);
581         opr_Verify(pthread_create(&tid, &tattr, BKGLoop, NULL) == 0);
582 #else
583         PROCESS pid;
584         LWP_CreateProcess(BKGLoop, 16*1024, 3, 0, "vol bkg daemon", &pid);
585 #endif
586     }
587
588     /* 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 */
589
590     tdir = afsconf_Open(configDir);
591     if (!tdir) {
592         Abort("volser: could not open conf files in %s\n",
593               configDir);
594         AFS_UNREACHED(VS_EXIT(1));
595     }
596
597     /* initialize audit user check */
598     osi_audit_set_user_check(tdir, vol_IsLocalRealmMatch);
599
600     afsconf_BuildServerSecurityObjects(tdir, &securityClasses, &numClasses);
601     if (securityClasses[0] == NULL)
602         Abort("rxnull_NewServerSecurityObject");
603     service =
604         rx_NewServiceHost(host, 0, VOLSERVICE_ID, "VOLSER", securityClasses,
605                           numClasses, AFSVolExecuteRequest);
606     if (service == (struct rx_service *)0)
607         Abort("rx_NewService");
608     rx_SetBeforeProc(service, MyBeforeProc);
609     rx_SetAfterProc(service, MyAfterProc);
610     rx_SetIdleDeadTime(service, 0);     /* never timeout */
611     if (lwps < 4)
612         lwps = 4;
613     rx_SetMaxProcs(service, lwps);
614 #if defined(AFS_XBSD_ENV)
615     rx_SetStackSize(service, (128 * 1024));
616 #elif defined(AFS_SGI_ENV)
617     rx_SetStackSize(service, (48 * 1024));
618 #else
619     rx_SetStackSize(service, (32 * 1024));
620 #endif
621
622     if (rxkadDisableDotCheck) {
623         code = rx_SetSecurityConfiguration(service, RXS_CONFIG_FLAGS,
624                                            (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
625         if (code) {
626             fprintf(stderr,
627                     "volser: failed to allow dotted principals: code %d\n",
628                     code);
629             VS_EXIT(1);
630         }
631     }
632
633     service =
634         rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", securityClasses,
635                       numClasses, RXSTATS_ExecuteRequest);
636     if (service == (struct rx_service *)0)
637         Abort("rx_NewService");
638     rx_SetMinProcs(service, 2);
639     rx_SetMaxProcs(service, 4);
640
641     LogCommandLine(argc, argv, "Volserver", VolserVersion, "Starting AFS",
642                    Log);
643     if (afsconf_CountKeys(tdir) == 0) {
644         Log("WARNING: No encryption keys found! "
645             "All authenticated accesses will fail. "
646             "Run akeyconvert or asetkey to import encryption keys.\n");
647     } else if (afsconf_GetLatestKey(tdir, NULL, NULL) == 0) {
648         LogDesWarning();
649     }
650
651     /* allow super users to manage RX statistics */
652     rx_SetRxStatUserOk(vol_rxstat_userok);
653
654     rx_StartServer(1);          /* Donate this process to the server process pool */
655
656     osi_audit(VS_FinishEvent, (-1), AUD_END);
657     Abort("StartServer returned?");
658     AFS_UNREACHED(return 0);
659 }