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 <sys/types.h>
29 #include <WINNT/afsevent.h>
32 #include <netinet/in.h>
34 #endif /* AFS_NT40_ENV */
35 #include <afs/cellconfig.h>
38 #include <rx/rx_globals.h>
41 #include "bosprototypes.h"
44 #include <afs/ktime.h>
45 #include <afs/afsutil.h>
46 #include <afs/fileutil.h>
47 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
48 #if defined(AFS_SGI_ENV)
49 #include <afs/afs_args.h>
52 #define BOZO_LWP_STACKSIZE 16000
53 extern int BOZO_ExecuteRequest();
54 extern int RXSTATS_ExecuteRequest();
55 extern struct bnode_ops fsbnode_ops, dafsbnode_ops, ezbnode_ops, cronbnode_ops;
57 struct afsconf_dir *bozo_confdir = 0; /* bozo configuration dir */
58 static PROCESS bozo_pid;
59 struct rx_securityClass *bozo_rxsc[3];
60 const char *bozo_fileName;
66 int DoSyslogFacility = LOG_DAEMON;
68 static afs_int32 nextRestart;
69 static afs_int32 nextDay;
71 struct ktime bozo_nextRestartKT, bozo_nextDayKT;
74 int rxkadDisableDotCheck = 0;
76 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
77 afs_uint32 SHostAddrs[ADDRSPERSITE];
79 #ifdef BOS_RESTRICTED_MODE
80 int bozo_isrestricted = 0;
81 int bozo_restdisable = 0;
84 bozo_insecureme(int sig)
86 signal(SIGFPE, bozo_insecureme);
87 bozo_isrestricted = 0;
96 /* check whether caller is authorized to manage RX statistics */
98 bozo_rxstat_userok(struct rx_call *call)
100 return afsconf_SuperUser(bozo_confdir, call, NULL);
103 /* restart bozo process */
108 /* exit with restart code; SCM integrator process will restart bosserver */
109 int status = BOSEXIT_RESTART;
111 /* if noauth flag is set, pass "-noauth" to new bosserver */
112 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
113 status |= BOSEXIT_NOAUTH_FLAG;
115 /* if logging is on, pass "-log" to new bosserver */
117 status |= BOSEXIT_LOGGING_FLAG;
121 /* exec new bosserver process */
125 argv[i] = (char *)AFSDIR_SERVER_BOSVR_FILEPATH;
128 /* if noauth flag is set, pass "-noauth" to new bosserver */
129 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
133 /* if logging is on, pass "-log" to new bosserver */
139 /* if syslog logging is on, pass "-syslog" to new bosserver */
141 char *arg = (char *)malloc(40); /* enough for -syslog=# */
142 if (DoSyslogFacility != LOG_DAEMON) {
143 snprintf(arg, 40, "-syslog=%d", DoSyslogFacility);
145 strcpy(arg, "-syslog");
152 /* null-terminate argument list */
155 /* close random fd's */
156 for (i = 3; i < 64; i++) {
160 execv(argv[0], argv); /* should not return */
162 #endif /* AFS_NT40_ENV */
165 /* make sure a dir exists */
167 MakeDir(const char *adir)
170 register afs_int32 code;
171 if (stat(adir, &tstat) < 0 || (tstat.st_mode & S_IFMT) != S_IFDIR) {
174 reqPerm = GetRequiredDirPerm(adir);
178 /* underlying filesystem may not support directory protection */
181 code = mkdir(adir, reqPerm);
188 /* create all the bozo dirs */
193 (AFSDIR_USR_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
194 strlen(AFSDIR_USR_DIRPATH)))
197 (AFSDIR_USR_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
198 strlen(AFSDIR_USR_DIRPATH)))) {
199 MakeDir(AFSDIR_USR_DIRPATH);
202 (AFSDIR_SERVER_AFS_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
203 strlen(AFSDIR_SERVER_AFS_DIRPATH))) {
204 MakeDir(AFSDIR_SERVER_AFS_DIRPATH);
206 MakeDir(AFSDIR_SERVER_BIN_DIRPATH);
207 MakeDir(AFSDIR_SERVER_ETC_DIRPATH);
208 MakeDir(AFSDIR_SERVER_LOCAL_DIRPATH);
209 MakeDir(AFSDIR_SERVER_DB_DIRPATH);
210 MakeDir(AFSDIR_SERVER_LOGS_DIRPATH);
213 (AFSDIR_CLIENT_VICE_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
214 strlen(AFSDIR_CLIENT_VICE_DIRPATH))) {
215 MakeDir(AFSDIR_CLIENT_VICE_DIRPATH);
217 MakeDir(AFSDIR_CLIENT_ETC_DIRPATH);
219 symlink(AFSDIR_SERVER_THISCELL_FILEPATH, AFSDIR_CLIENT_THISCELL_FILEPATH);
220 symlink(AFSDIR_SERVER_CELLSERVDB_FILEPATH,
221 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
222 #endif /* AFS_NT40_ENV */
226 /* strip the \\n from the end of the line, if it is present */
228 StripLine(register char *abuffer)
232 tp = abuffer + strlen(abuffer); /* starts off pointing at the null */
234 return 0; /* null string, no last character to check */
235 tp--; /* aim at last character */
241 /* write one bnode's worth of entry into the file */
243 bzwrite(register struct bnode *abnode, register struct bztemp *at)
246 char tbuffer[BOZO_BSSIZE];
247 register afs_int32 code;
249 if (abnode->notifier)
250 fprintf(at->file, "bnode %s %s %d %s\n", abnode->type->name,
251 abnode->name, abnode->fileGoal, abnode->notifier);
253 fprintf(at->file, "bnode %s %s %d\n", abnode->type->name,
254 abnode->name, abnode->fileGoal);
256 code = bnode_GetParm(abnode, i, tbuffer, BOZO_BSSIZE);
262 fprintf(at->file, "parm %s\n", tbuffer);
264 fprintf(at->file, "end\n");
270 ReadBozoFile(char *aname)
272 register FILE *tfile;
273 char tbuffer[BOZO_BSSIZE];
275 char *instp, *typep, *notifier, *notp;
276 register afs_int32 code;
277 afs_int32 ktmask, ktday, kthour, ktmin, ktsec;
280 char *parms[MAXPARMS];
281 #ifdef BOS_RESTRICTED_MODE
285 /* rename BozoInit to BosServer for the user */
287 /* if BozoInit exists and BosConfig doesn't, try a rename */
288 if (access(AFSDIR_SERVER_BOZINIT_FILEPATH, 0) == 0
289 && access(AFSDIR_SERVER_BOZCONF_FILEPATH, 0) != 0) {
291 renamefile(AFSDIR_SERVER_BOZINIT_FILEPATH,
292 AFSDIR_SERVER_BOZCONF_FILEPATH);
294 perror("bosconfig rename");
296 #ifdef BOS_NEW_CONFIG
297 if (access(AFSDIR_SERVER_BOZCONFNEW_FILEPATH, 0) == 0) {
299 renamefile(AFSDIR_SERVER_BOZCONFNEW_FILEPATH,
300 AFSDIR_SERVER_BOZCONF_FILEPATH);
302 perror("bosconfig rename");
307 /* setup default times we want to do restarts */
308 bozo_nextRestartKT.mask = KTIME_HOUR | KTIME_MIN | KTIME_DAY;
309 bozo_nextRestartKT.hour = 4; /* 4 am */
310 bozo_nextRestartKT.min = 0;
311 bozo_nextRestartKT.day = 0; /* Sunday */
312 bozo_nextDayKT.mask = KTIME_HOUR | KTIME_MIN;
313 bozo_nextDayKT.hour = 5;
314 bozo_nextDayKT.min = 0;
316 for (code = 0; code < MAXPARMS; code++)
318 instp = typep = notifier = NULL;
321 aname = (char *)bozo_fileName;
322 tfile = fopen(aname, "r");
325 instp = (char *)malloc(BOZO_BSSIZE);
326 typep = (char *)malloc(BOZO_BSSIZE);
327 notifier = notp = (char *)malloc(BOZO_BSSIZE);
329 /* ok, read lines giving parms and such from the file */
330 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
332 break; /* all done */
334 if (strncmp(tbuffer, "restarttime", 11) == 0) {
336 sscanf(tbuffer, "restarttime %d %d %d %d %d", &ktmask, &ktday,
337 &kthour, &ktmin, &ktsec);
342 /* otherwise we've read in the proper ktime structure; now assign
343 * it and continue processing */
344 bozo_nextRestartKT.mask = ktmask;
345 bozo_nextRestartKT.day = ktday;
346 bozo_nextRestartKT.hour = kthour;
347 bozo_nextRestartKT.min = ktmin;
348 bozo_nextRestartKT.sec = ktsec;
352 if (strncmp(tbuffer, "checkbintime", 12) == 0) {
354 sscanf(tbuffer, "checkbintime %d %d %d %d %d", &ktmask,
355 &ktday, &kthour, &ktmin, &ktsec);
360 /* otherwise we've read in the proper ktime structure; now assign
361 * it and continue processing */
362 bozo_nextDayKT.mask = ktmask; /* time to restart the system */
363 bozo_nextDayKT.day = ktday;
364 bozo_nextDayKT.hour = kthour;
365 bozo_nextDayKT.min = ktmin;
366 bozo_nextDayKT.sec = ktsec;
369 #ifdef BOS_RESTRICTED_MODE
370 if (strncmp(tbuffer, "restrictmode", 12) == 0) {
371 code = sscanf(tbuffer, "restrictmode %d", &rmode);
376 if (rmode != 0 && rmode != 1) {
380 bozo_isrestricted = rmode;
385 if (strncmp("bnode", tbuffer, 5) != 0) {
391 sscanf(tbuffer, "bnode %s %s %d %s", typep, instp, &goal,
396 } else if (code == 3)
399 for (i = 0; i < MAXPARMS; i++) {
400 /* now read the parms, until we see an "end" line */
401 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
407 if (!strncmp(tbuffer, "end", 3))
409 if (strncmp(tbuffer, "parm ", 5)) {
411 goto fail; /* no "parm " either */
413 if (!parms[i]) /* make sure there's space */
414 parms[i] = (char *)malloc(BOZO_BSSIZE);
415 strcpy(parms[i], tbuffer + 5); /* remember the parameter for later */
418 /* ok, we have the type and parms, now create the object */
420 bnode_Create(typep, instp, &tb, parms[0], parms[1], parms[2],
421 parms[3], parms[4], notifier,
422 goal ? BSTAT_NORMAL : BSTAT_SHUTDOWN, 0);
426 /* bnode created in 'temporarily shutdown' state;
427 * check to see if we are supposed to run this guy,
428 * and if so, start the process up */
430 bnode_SetStat(tb, BSTAT_NORMAL); /* set goal, taking effect immediately */
432 bnode_SetStat(tb, BSTAT_SHUTDOWN);
443 for (i = 0; i < MAXPARMS; i++)
451 /* write a new bozo file */
453 WriteBozoFile(char *aname)
455 register FILE *tfile;
456 char tbuffer[AFSDIR_PATH_MAX];
457 register afs_int32 code;
461 aname = (char *)bozo_fileName;
462 strcpy(tbuffer, aname);
463 strcat(tbuffer, ".NBZ");
464 tfile = fopen(tbuffer, "w");
468 #ifdef BOS_RESTRICTED_MODE
469 fprintf(tfile, "restrictmode %d\n", bozo_isrestricted);
471 fprintf(tfile, "restarttime %d %d %d %d %d\n", bozo_nextRestartKT.mask,
472 bozo_nextRestartKT.day, bozo_nextRestartKT.hour,
473 bozo_nextRestartKT.min, bozo_nextRestartKT.sec);
474 fprintf(tfile, "checkbintime %d %d %d %d %d\n", bozo_nextDayKT.mask,
475 bozo_nextDayKT.day, bozo_nextDayKT.hour, bozo_nextDayKT.min,
477 code = bnode_ApplyInstance(bzwrite, &btemp);
478 if (code || (code = ferror(tfile))) { /* something went wrong */
483 /* close the file, check for errors and snap new file into place */
484 if (fclose(tfile) == EOF) {
488 code = renamefile(tbuffer, aname);
497 bdrestart(register struct bnode *abnode, char *arock)
499 register afs_int32 code;
501 if (abnode->fileGoal != BSTAT_NORMAL || abnode->goal != BSTAT_NORMAL)
502 return 0; /* don't restart stopped bnodes */
504 code = bnode_RestartP(abnode);
506 /* restart the dude */
507 bnode_SetStat(abnode, BSTAT_SHUTDOWN);
508 bnode_WaitStatus(abnode, BSTAT_SHUTDOWN);
509 bnode_SetStat(abnode, BSTAT_NORMAL);
511 bnode_Release(abnode);
512 return 0; /* keep trying all bnodes */
515 #define BOZO_MINSKIP 3600 /* minimum to advance clock */
516 /* lwp to handle system restarts */
518 BozoDaemon(void *unused)
520 register afs_int32 now;
522 /* now initialize the values */
526 now = FT_ApproxTime();
528 #ifdef BOS_RESTRICTED_MODE
529 if (bozo_restdisable) {
530 bozo_Log("Restricted mode disabled by signal\n");
531 bozo_restdisable = 0;
534 if (bozo_newKTs) { /* need to recompute restart times */
535 bozo_newKTs = 0; /* done for a while */
536 nextRestart = ktime_next(&bozo_nextRestartKT, BOZO_MINSKIP);
537 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
540 /* see if we should do a restart */
541 if (now > nextRestart) {
542 SBOZO_ReBozo(0); /* doesn't come back */
545 /* see if we should restart a server */
547 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
549 /* call the bnode restartp function, and restart all that require it */
550 bnode_ApplyInstance(bdrestart, 0);
562 int s, sb_max, ipfragttl;
566 f = popen("/usr/sbin/no -o sb_max", "r");
567 s = fscanf(f, "sb_max = %d", &sb_max);
571 f = popen("/usr/sbin/no -o ipfragttl", "r");
572 s = fscanf(f, "ipfragttl = %d", &ipfragttl);
582 sprintf(c, "/usr/sbin/no -o sb_max=%d -o ipfragttl=%d", sb_max,
591 * This routine causes the calling process to go into the background and
592 * to lose its controlling tty.
594 * It does not close or otherwise alter the standard file descriptors.
596 * It writes warning messages to the standard error output if certain
597 * fundamental errors occur.
599 * This routine requires
601 * #include <sys/types.h>
602 * #include <sys/stat.h>
604 * #include <unistd.h>
605 * #include <stdlib.h>
607 * and has been tested on:
623 * A process is a process group leader if its process ID
624 * (getpid()) and its process group ID (getpgrp()) are the same.
628 * To create a new session (and thereby lose our controlling
629 * terminal) we cannot be a process group leader.
631 * To guarantee we are not a process group leader, we fork and
632 * let the parent process exit.
635 if (getpid() == getpgrp()) {
640 abort(); /* leave footprints */
644 default: /* parent */
651 * By here, we are not a process group leader, so we can make a
652 * new session and become the session leader.
656 pid_t sid = setsid();
659 static char err[] = "bosserver: WARNING: setsid() failed\n";
660 write(STDERR_FILENO, err, sizeof err - 1);
665 * Once we create a new session, the current process is a
666 * session leader without a controlling tty.
668 * On some systems, the first tty device the session leader
669 * opens automatically becomes the controlling tty for the
672 * So, to guarantee we do not acquire a controlling tty, we fork
673 * and let the parent process exit. The child process is not a
674 * session leader, and so it will not acquire a controlling tty
675 * even if it should happen to open a tty device.
678 if (getpid() == getpgrp()) {
683 abort(); /* leave footprints */
687 default: /* parent */
694 * check that we no longer have a controlling tty
700 fd = open("/dev/tty", O_RDONLY);
704 "bosserver: WARNING: /dev/tty still attached\n";
706 write(STDERR_FILENO, err, sizeof err - 1);
710 #endif /* ! AFS_NT40_ENV */
713 /* start a process and monitor it */
715 #include "AFS_component_version_number.c"
718 main(int argc, char **argv, char **envp)
720 struct rx_service *tservice;
721 register afs_int32 code;
722 struct afsconf_dir *tdir;
725 char namebuf[AFSDIR_PATH_MAX];
727 afs_uint32 host = htonl(INADDR_ANY);
733 struct sigaction nsa;
735 /* for some reason, this permits user-mode RX to run a lot faster.
736 * we do it here in the bosserver, so we don't have to do it
737 * individually in each server.
742 * The following signal action for AIX is necessary so that in case of a
743 * crash (i.e. core is generated) we can include the user's data section
744 * in the core dump. Unfortunately, by default, only a partial core is
745 * generated which, in many cases, isn't too useful.
747 sigemptyset(&nsa.sa_mask);
748 nsa.sa_handler = SIG_DFL;
749 nsa.sa_flags = SA_FULLDUMP;
750 sigaction(SIGSEGV, &nsa, NULL);
751 sigaction(SIGABRT, &nsa, NULL);
754 #ifdef BOS_RESTRICTED_MODE
755 signal(SIGFPE, bozo_insecureme);
759 /* Initialize winsock */
760 if (afs_winsockInit() < 0) {
761 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
762 fprintf(stderr, "%s: Couldn't initialize winsock.\n", argv[0]);
767 /* Initialize dirpaths */
768 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
770 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
772 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
777 /* some path inits */
778 bozo_fileName = AFSDIR_SERVER_BOZCONF_FILEPATH;
780 /* initialize the list of dirpaths that the bosserver has
781 * an interest in monitoring */
784 #if defined(AFS_SGI_ENV)
785 /* offer some protection if AFS isn't loaded */
786 if (syscall(AFS_SYSCALL, AFSOP_ENDLOG) < 0 && errno == ENOPKG) {
787 printf("bosserver: AFS doesn't appear to be configured in O.S..\n");
793 for (code = 1; code < argc; code++) {
794 if (strcmp(argv[code], "-noauth") == 0) {
795 /* set noauth flag */
797 } else if (strcmp(argv[code], "-log") == 0) {
798 /* set extra logging flag */
802 else if (strcmp(argv[code], "-syslog") == 0) {
803 /* set syslog logging flag */
805 } else if (strncmp(argv[code], "-syslog=", 8) == 0) {
807 DoSyslogFacility = atoi(argv[code] + 8);
808 } else if (strcmp(argv[code], "-nofork") == 0) {
812 else if (strcmp(argv[code], "-enable_peer_stats") == 0) {
813 rx_enablePeerRPCStats();
814 } else if (strcmp(argv[code], "-enable_process_stats") == 0) {
815 rx_enableProcessRPCStats();
817 #ifdef BOS_RESTRICTED_MODE
818 else if (strcmp(argv[code], "-restricted") == 0) {
819 bozo_isrestricted = 1;
822 else if (strcmp(argv[code], "-rxbind") == 0) {
825 else if (strcmp(argv[code], "-allow-dotted-principals") == 0) {
826 rxkadDisableDotCheck = 1;
828 else if (!strcmp(argv[code], "-rxmaxmtu")) {
829 if ((code + 1) >= argc) {
830 fprintf(stderr, "missing argument for -rxmaxmtu\n");
833 rxMaxMTU = atoi(argv[++code]);
834 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
835 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
836 printf("rxMaxMTU %d invalid; must be between %d-%d\n",
837 rxMaxMTU, RX_MIN_PACKET_SIZE,
838 RX_MAX_PACKET_DATA_SIZE);
842 else if (strcmp(argv[code], "-auditlog") == 0) {
845 char oldName[MAXPATHLEN];
846 char *fileName = argv[++code];
851 if ((lstat(fileName, &statbuf) == 0)
852 && (S_ISFIFO(statbuf.st_mode))) {
853 flags = O_WRONLY | O_NONBLOCK;
857 strcpy(oldName, fileName);
858 strcat(oldName, ".old");
859 renamefile(fileName, oldName);
860 flags = O_WRONLY | O_TRUNC | O_CREAT;
862 tempfd = open(fileName, flags, 0666);
864 auditout = fdopen(tempfd, "a");
866 osi_audit_file(auditout);
868 printf("Warning: auditlog %s not writable, ignored.\n", fileName);
870 printf("Warning: auditlog %s not writable, ignored.\n", fileName);
874 /* hack to support help flag */
877 printf("Usage: bosserver [-noauth] [-log] "
878 "[-auditlog <log path>] "
879 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
880 "[-syslog[=FACILITY]] "
881 "[-enable_peer_stats] [-enable_process_stats] "
882 "[-nofork] " "[-help]\n");
884 printf("Usage: bosserver [-noauth] [-log] "
885 "[-auditlog <log path>] "
886 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
887 "[-enable_peer_stats] [-enable_process_stats] "
897 if (geteuid() != 0) {
898 printf("bosserver: must be run as root.\n");
905 printf("bosserver: could not init bnode package, code %d\n", code);
909 bnode_Register("fs", &fsbnode_ops, 3);
910 bnode_Register("dafs", &dafsbnode_ops, 4);
911 bnode_Register("simple", &ezbnode_ops, 1);
912 bnode_Register("cron", &cronbnode_ops, 2);
914 /* create useful dirs */
917 /* chdir to AFS log directory */
918 chdir(AFSDIR_SERVER_LOGS_DIRPATH);
921 fputs(AFS_GOVERNMENT_MESSAGE, stdout);
925 /* go into the background and remove our controlling tty, close open
932 #endif /* ! AFS_NT40_ENV */
936 && ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) &&
937 !(S_ISFIFO(sb.st_mode)))
940 strcpy(namebuf, AFSDIR_BOZLOG_FILE);
941 strcat(namebuf, ".old");
942 renamefile(AFSDIR_BOZLOG_FILE, namebuf); /* try rename first */
943 bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a");
945 printf("bosserver: can't initialize log file (%s).\n",
946 AFSDIR_SERVER_BOZLOG_FILEPATH);
949 /* keep log closed normally, so can be removed */
950 fclose(bozo_logFile);
953 openlog("bosserver", LOG_PID, DoSyslogFacility);
957 /* Write current state of directory permissions to log file */
960 for (i = 0; i < 10; i++) {
961 code = rx_Init(htons(AFSCONF_NANNYPORT));
963 bozo_Log("can't initialize rx: code=%d\n", code);
969 bozo_Log("Bos giving up, can't initialize rx\n");
973 code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
974 (void *) /*parm */ 0, "bozo-the-clown",
977 /* try to read the key from the config file */
978 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
980 /* try to create local cell config file */
981 struct afsconf_cell tcell;
982 strcpy(tcell.name, "localcell");
983 tcell.numServers = 1;
984 code = gethostname(tcell.hostName[0], MAXHOSTCHARS);
986 bozo_Log("failed to get hostname, code %d\n", errno);
989 if (tcell.hostName[0][0] == 0) {
990 bozo_Log("host name not set, can't start\n");
991 bozo_Log("try the 'hostname' command\n");
994 memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */
996 afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH,
1000 ("could not create cell database in '%s' (code %d), quitting\n",
1001 AFSDIR_SERVER_ETC_DIRPATH, code);
1004 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1007 ("failed to open newly-created cell database, quitting\n");
1012 /* read init file, starting up programs */
1013 if (code = ReadBozoFile(0)) {
1015 ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
1016 code, AFSDIR_SERVER_BOZCONF_FILEPATH);
1020 /* opened the cell databse */
1021 bozo_confdir = tdir;
1023 /* allow super users to manage RX statistics */
1024 rx_SetRxStatUserOk(bozo_rxstat_userok);
1026 /* have bcrypt key now */
1028 afsconf_SetNoAuthFlag(tdir, noAuth);
1030 bozo_rxsc[0] = rxnull_NewServerSecurityObject();
1031 bozo_rxsc[1] = (struct rx_securityClass *)0;
1033 rxkad_NewServerSecurityObject(0, tdir, afsconf_GetKey, NULL);
1035 /* Disable jumbograms */
1038 if (rxMaxMTU != -1) {
1039 rx_SetMaxMTU(rxMaxMTU);
1044 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
1045 AFSDIR_SERVER_NETINFO_FILEPATH) {
1047 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
1048 ADDRSPERSITE, reason,
1049 AFSDIR_SERVER_NETINFO_FILEPATH,
1050 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
1053 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
1056 host = SHostAddrs[0];
1059 tservice = rx_NewServiceHost(host, /* port */ 0, /* service id */ 1,
1060 /*service name */ "bozo",
1061 /* security classes */
1063 /* numb sec classes */ 3, BOZO_ExecuteRequest);
1064 rx_SetMinProcs(tservice, 2);
1065 rx_SetMaxProcs(tservice, 4);
1066 rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE); /* so gethostbyname works (in cell stuff) */
1067 if (rxkadDisableDotCheck) {
1068 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
1069 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
1073 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats", bozo_rxsc,
1074 3, RXSTATS_ExecuteRequest);
1075 rx_SetMinProcs(tservice, 2);
1076 rx_SetMaxProcs(tservice, 4);
1077 rx_StartServer(1); /* donate this process */
1082 bozo_Log(char *format, ...)
1088 va_start(ap, format);
1091 #ifndef AFS_NT40_ENV
1092 vsyslog(LOG_INFO, format, ap);
1096 strcpy(tdate, ctime(&myTime)); /* copy out of static area asap */
1099 /* log normally closed, so can be removed */
1101 bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a");
1102 if (bozo_logFile == NULL) {
1103 printf("bosserver: WARNING: problem with %s\n",
1104 AFSDIR_SERVER_BOZLOG_FILEPATH);
1105 printf("%s ", tdate);
1106 vprintf(format, ap);
1109 fprintf(bozo_logFile, "%s ", tdate);
1110 vfprintf(bozo_logFile, format, ap);
1112 /* close so rm BosLog works */
1113 fclose(bozo_logFile);