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>
27 #include <WINNT/afsevent.h>
30 #include <netinet/in.h>
32 #endif /* AFS_NT40_ENV */
33 #include <afs/cellconfig.h>
36 #include <rx/rx_globals.h>
39 #include "bosprototypes.h"
41 #include <rx/rxstat.h>
43 #include <afs/ktime.h>
44 #include <afs/afsutil.h>
45 #include <afs/fileutil.h>
46 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
47 #include <afs/audit.h>
48 #include <afs/cellconfig.h>
49 #if defined(AFS_SGI_ENV)
50 #include <afs/afs_args.h>
53 #define BOZO_LWP_STACKSIZE 16000
54 extern struct bnode_ops fsbnode_ops, dafsbnode_ops, ezbnode_ops, cronbnode_ops;
56 struct afsconf_dir *bozo_confdir = 0; /* bozo configuration dir */
57 static PROCESS bozo_pid;
58 struct rx_securityClass *bozo_rxsc[3];
59 const char *bozo_fileName;
65 int DoSyslogFacility = LOG_DAEMON;
67 static afs_int32 nextRestart;
68 static afs_int32 nextDay;
70 struct ktime bozo_nextRestartKT, bozo_nextDayKT;
73 int rxkadDisableDotCheck = 0;
75 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
76 afs_uint32 SHostAddrs[ADDRSPERSITE];
78 #ifdef BOS_RESTRICTED_MODE
79 int bozo_isrestricted = 0;
80 int bozo_restdisable = 0;
83 bozo_insecureme(int sig)
85 signal(SIGFPE, bozo_insecureme);
86 bozo_isrestricted = 0;
95 /* check whether caller is authorized to manage RX statistics */
97 bozo_rxstat_userok(struct rx_call *call)
99 return afsconf_SuperUser(bozo_confdir, call, NULL);
102 /* restart bozo process */
107 /* exit with restart code; SCM integrator process will restart bosserver */
108 int status = BOSEXIT_RESTART;
110 /* if noauth flag is set, pass "-noauth" to new bosserver */
111 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
112 status |= BOSEXIT_NOAUTH_FLAG;
114 /* if logging is on, pass "-log" to new bosserver */
116 status |= BOSEXIT_LOGGING_FLAG;
120 /* exec new bosserver process */
124 argv[i] = (char *)AFSDIR_SERVER_BOSVR_FILEPATH;
127 /* if noauth flag is set, pass "-noauth" to new bosserver */
128 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
132 /* if logging is on, pass "-log" to new bosserver */
138 /* if syslog logging is on, pass "-syslog" to new bosserver */
140 char *arg = (char *)malloc(40); /* enough for -syslog=# */
141 if (DoSyslogFacility != LOG_DAEMON) {
142 snprintf(arg, 40, "-syslog=%d", DoSyslogFacility);
144 strcpy(arg, "-syslog");
151 /* null-terminate argument list */
154 /* close random fd's */
155 for (i = 3; i < 64; i++) {
159 execv(argv[0], argv); /* should not return */
161 #endif /* AFS_NT40_ENV */
164 /* make sure a dir exists */
166 MakeDir(const char *adir)
169 register afs_int32 code;
170 if (stat(adir, &tstat) < 0 || (tstat.st_mode & S_IFMT) != S_IFDIR) {
173 reqPerm = GetRequiredDirPerm(adir);
177 /* underlying filesystem may not support directory protection */
180 code = mkdir(adir, reqPerm);
187 /* create all the bozo dirs */
192 (AFSDIR_USR_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
193 strlen(AFSDIR_USR_DIRPATH)))
196 (AFSDIR_USR_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
197 strlen(AFSDIR_USR_DIRPATH)))) {
198 MakeDir(AFSDIR_USR_DIRPATH);
201 (AFSDIR_SERVER_AFS_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
202 strlen(AFSDIR_SERVER_AFS_DIRPATH))) {
203 MakeDir(AFSDIR_SERVER_AFS_DIRPATH);
205 MakeDir(AFSDIR_SERVER_BIN_DIRPATH);
206 MakeDir(AFSDIR_SERVER_ETC_DIRPATH);
207 MakeDir(AFSDIR_SERVER_LOCAL_DIRPATH);
208 MakeDir(AFSDIR_SERVER_DB_DIRPATH);
209 MakeDir(AFSDIR_SERVER_LOGS_DIRPATH);
212 (AFSDIR_CLIENT_VICE_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
213 strlen(AFSDIR_CLIENT_VICE_DIRPATH))) {
214 MakeDir(AFSDIR_CLIENT_VICE_DIRPATH);
216 MakeDir(AFSDIR_CLIENT_ETC_DIRPATH);
218 symlink(AFSDIR_SERVER_THISCELL_FILEPATH, AFSDIR_CLIENT_THISCELL_FILEPATH);
219 symlink(AFSDIR_SERVER_CELLSERVDB_FILEPATH,
220 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
221 #endif /* AFS_NT40_ENV */
225 /* strip the \\n from the end of the line, if it is present */
227 StripLine(register char *abuffer)
231 tp = abuffer + strlen(abuffer); /* starts off pointing at the null */
233 return 0; /* null string, no last character to check */
234 tp--; /* aim at last character */
240 /* write one bnode's worth of entry into the file */
242 bzwrite(register struct bnode *abnode, void *arock)
244 register struct bztemp *at = (struct bztemp *)arock;
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, void *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);
728 char *auditFileName = NULL;
734 struct sigaction nsa;
736 /* for some reason, this permits user-mode RX to run a lot faster.
737 * we do it here in the bosserver, so we don't have to do it
738 * individually in each server.
743 * The following signal action for AIX is necessary so that in case of a
744 * crash (i.e. core is generated) we can include the user's data section
745 * in the core dump. Unfortunately, by default, only a partial core is
746 * generated which, in many cases, isn't too useful.
748 sigemptyset(&nsa.sa_mask);
749 nsa.sa_handler = SIG_DFL;
750 nsa.sa_flags = SA_FULLDUMP;
751 sigaction(SIGSEGV, &nsa, NULL);
752 sigaction(SIGABRT, &nsa, NULL);
755 #ifdef BOS_RESTRICTED_MODE
756 signal(SIGFPE, bozo_insecureme);
760 /* Initialize winsock */
761 if (afs_winsockInit() < 0) {
762 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
763 fprintf(stderr, "%s: Couldn't initialize winsock.\n", argv[0]);
768 /* Initialize dirpaths */
769 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
771 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
773 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
778 /* some path inits */
779 bozo_fileName = AFSDIR_SERVER_BOZCONF_FILEPATH;
781 /* initialize the list of dirpaths that the bosserver has
782 * an interest in monitoring */
785 #if defined(AFS_SGI_ENV)
786 /* offer some protection if AFS isn't loaded */
787 if (syscall(AFS_SYSCALL, AFSOP_ENDLOG) < 0 && errno == ENOPKG) {
788 printf("bosserver: AFS doesn't appear to be configured in O.S..\n");
794 for (code = 1; code < argc; code++) {
795 if (strcmp(argv[code], "-noauth") == 0) {
796 /* set noauth flag */
798 } else if (strcmp(argv[code], "-log") == 0) {
799 /* set extra logging flag */
803 else if (strcmp(argv[code], "-syslog") == 0) {
804 /* set syslog logging flag */
806 } else if (strncmp(argv[code], "-syslog=", 8) == 0) {
808 DoSyslogFacility = atoi(argv[code] + 8);
809 } else if (strcmp(argv[code], "-nofork") == 0) {
813 else if (strcmp(argv[code], "-enable_peer_stats") == 0) {
814 rx_enablePeerRPCStats();
815 } else if (strcmp(argv[code], "-enable_process_stats") == 0) {
816 rx_enableProcessRPCStats();
818 #ifdef BOS_RESTRICTED_MODE
819 else if (strcmp(argv[code], "-restricted") == 0) {
820 bozo_isrestricted = 1;
823 else if (strcmp(argv[code], "-rxbind") == 0) {
826 else if (strcmp(argv[code], "-allow-dotted-principals") == 0) {
827 rxkadDisableDotCheck = 1;
829 else if (!strcmp(argv[code], "-rxmaxmtu")) {
830 if ((code + 1) >= argc) {
831 fprintf(stderr, "missing argument for -rxmaxmtu\n");
834 rxMaxMTU = atoi(argv[++code]);
835 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
836 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
837 printf("rxMaxMTU %d invalid; must be between %d-%lu\n",
838 rxMaxMTU, RX_MIN_PACKET_SIZE,
839 RX_MAX_PACKET_DATA_SIZE);
843 else if (strcmp(argv[code], "-auditlog") == 0) {
844 auditFileName = argv[++code];
846 } else if (strcmp(argv[code], "-audit-interface") == 0) {
847 char *interface = argv[++code];
849 if (osi_audit_interface(interface)) {
850 printf("Invalid audit interface '%s'\n", interface);
856 /* hack to support help flag */
859 printf("Usage: bosserver [-noauth] [-log] "
860 "[-auditlog <log path>] "
861 "[-audit-interafce <file|sysvmq> (default is file)] "
862 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
863 "[-syslog[=FACILITY]] "
864 "[-enable_peer_stats] [-enable_process_stats] "
865 "[-nofork] " "[-help]\n");
867 printf("Usage: bosserver [-noauth] [-log] "
868 "[-auditlog <log path>] "
869 "[-audit-interafce <file|sysvmq> (default is file)] "
870 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
871 "[-enable_peer_stats] [-enable_process_stats] "
880 osi_audit_file(auditFileName);
884 if (geteuid() != 0) {
885 printf("bosserver: must be run as root.\n");
892 printf("bosserver: could not init bnode package, code %d\n", code);
896 bnode_Register("fs", &fsbnode_ops, 3);
897 bnode_Register("dafs", &dafsbnode_ops, 4);
898 bnode_Register("simple", &ezbnode_ops, 1);
899 bnode_Register("cron", &cronbnode_ops, 2);
901 /* create useful dirs */
904 /* chdir to AFS log directory */
905 chdir(AFSDIR_SERVER_LOGS_DIRPATH);
908 fputs(AFS_GOVERNMENT_MESSAGE, stdout);
912 /* go into the background and remove our controlling tty, close open
919 #endif /* ! AFS_NT40_ENV */
923 && ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) &&
924 !(S_ISFIFO(sb.st_mode)))
927 strcpy(namebuf, AFSDIR_BOZLOG_FILE);
928 strcat(namebuf, ".old");
929 renamefile(AFSDIR_BOZLOG_FILE, namebuf); /* try rename first */
930 bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a");
932 printf("bosserver: can't initialize log file (%s).\n",
933 AFSDIR_SERVER_BOZLOG_FILEPATH);
936 /* keep log closed normally, so can be removed */
937 fclose(bozo_logFile);
940 openlog("bosserver", LOG_PID, DoSyslogFacility);
944 /* Write current state of directory permissions to log file */
947 for (i = 0; i < 10; i++) {
948 code = rx_Init(htons(AFSCONF_NANNYPORT));
950 bozo_Log("can't initialize rx: code=%d\n", code);
956 bozo_Log("Bos giving up, can't initialize rx\n");
960 code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
961 /* param */ NULL , "bozo-the-clown",
964 /* try to read the key from the config file */
965 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
967 /* try to create local cell config file */
968 struct afsconf_cell tcell;
969 strcpy(tcell.name, "localcell");
970 tcell.numServers = 1;
971 code = gethostname(tcell.hostName[0], MAXHOSTCHARS);
973 bozo_Log("failed to get hostname, code %d\n", errno);
976 if (tcell.hostName[0][0] == 0) {
977 bozo_Log("host name not set, can't start\n");
978 bozo_Log("try the 'hostname' command\n");
981 memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */
983 afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH,
987 ("could not create cell database in '%s' (code %d), quitting\n",
988 AFSDIR_SERVER_ETC_DIRPATH, code);
991 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
994 ("failed to open newly-created cell database, quitting\n");
999 /* read init file, starting up programs */
1000 if ((code = ReadBozoFile(0))) {
1002 ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
1003 code, AFSDIR_SERVER_BOZCONF_FILEPATH);
1007 /* opened the cell databse */
1008 bozo_confdir = tdir;
1010 /* allow super users to manage RX statistics */
1011 rx_SetRxStatUserOk(bozo_rxstat_userok);
1013 /* have bcrypt key now */
1015 afsconf_SetNoAuthFlag(tdir, noAuth);
1017 bozo_rxsc[0] = rxnull_NewServerSecurityObject();
1018 bozo_rxsc[1] = (struct rx_securityClass *)0;
1020 rxkad_NewServerSecurityObject(0, tdir, afsconf_GetKey, NULL);
1022 /* Disable jumbograms */
1025 if (rxMaxMTU != -1) {
1026 rx_SetMaxMTU(rxMaxMTU);
1031 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
1032 AFSDIR_SERVER_NETINFO_FILEPATH) {
1034 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
1035 ADDRSPERSITE, reason,
1036 AFSDIR_SERVER_NETINFO_FILEPATH,
1037 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
1040 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
1043 host = SHostAddrs[0];
1046 tservice = rx_NewServiceHost(host, /* port */ 0, /* service id */ 1,
1047 /*service name */ "bozo",
1048 /* security classes */
1050 /* numb sec classes */ 3, BOZO_ExecuteRequest);
1051 rx_SetMinProcs(tservice, 2);
1052 rx_SetMaxProcs(tservice, 4);
1053 rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE); /* so gethostbyname works (in cell stuff) */
1054 if (rxkadDisableDotCheck) {
1055 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
1056 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
1060 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats", bozo_rxsc,
1061 3, RXSTATS_ExecuteRequest);
1062 rx_SetMinProcs(tservice, 2);
1063 rx_SetMaxProcs(tservice, 4);
1064 rx_StartServer(1); /* donate this process */
1069 bozo_Log(char *format, ...)
1075 va_start(ap, format);
1078 #ifndef AFS_NT40_ENV
1079 vsyslog(LOG_INFO, format, ap);
1083 strcpy(tdate, ctime(&myTime)); /* copy out of static area asap */
1086 /* log normally closed, so can be removed */
1088 bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a");
1089 if (bozo_logFile == NULL) {
1090 printf("bosserver: WARNING: problem with %s\n",
1091 AFSDIR_SERVER_BOZLOG_FILEPATH);
1092 printf("%s ", tdate);
1093 vprintf(format, ap);
1096 fprintf(bozo_logFile, "%s ", tdate);
1097 vfprintf(bozo_logFile, format, ap);
1099 /* close so rm BosLog works */
1100 fclose(bozo_logFile);