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>
13 #ifdef IGNORE_SOME_GCC_WARNINGS
14 # pragma GCC diagnostic warning "-Wdeprecated-declarations"
18 #include <sys/types.h>
30 #include <WINNT/afsevent.h>
33 #include <netinet/in.h>
35 #endif /* AFS_NT40_ENV */
36 #include <afs/cellconfig.h>
39 #include <rx/rx_globals.h>
42 #include "bosprototypes.h"
44 #include <rx/rxstat.h>
46 #include <afs/ktime.h>
47 #include <afs/afsutil.h>
48 #include <afs/fileutil.h>
49 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
50 #include <afs/audit.h>
51 #include <afs/cellconfig.h>
52 #if defined(AFS_SGI_ENV)
53 #include <afs/afs_args.h>
56 #define BOZO_LWP_STACKSIZE 16000
57 extern struct bnode_ops fsbnode_ops, dafsbnode_ops, ezbnode_ops, cronbnode_ops;
59 struct afsconf_dir *bozo_confdir = 0; /* bozo configuration dir */
60 static PROCESS bozo_pid;
61 struct rx_securityClass *bozo_rxsc[3];
62 const char *bozo_fileName;
68 int DoSyslogFacility = LOG_DAEMON;
70 static afs_int32 nextRestart;
71 static afs_int32 nextDay;
73 struct ktime bozo_nextRestartKT, bozo_nextDayKT;
76 int rxkadDisableDotCheck = 0;
78 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
79 afs_uint32 SHostAddrs[ADDRSPERSITE];
81 int bozo_isrestricted = 0;
82 int bozo_restdisable = 0;
85 bozo_insecureme(int sig)
87 signal(SIGFPE, bozo_insecureme);
88 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, void *arock)
245 register struct bztemp *at = (struct bztemp *)arock;
247 char tbuffer[BOZO_BSSIZE];
248 register afs_int32 code;
250 if (abnode->notifier)
251 fprintf(at->file, "bnode %s %s %d %s\n", abnode->type->name,
252 abnode->name, abnode->fileGoal, abnode->notifier);
254 fprintf(at->file, "bnode %s %s %d\n", abnode->type->name,
255 abnode->name, abnode->fileGoal);
257 code = bnode_GetParm(abnode, i, tbuffer, BOZO_BSSIZE);
263 fprintf(at->file, "parm %s\n", tbuffer);
265 fprintf(at->file, "end\n");
271 ReadBozoFile(char *aname)
273 register FILE *tfile;
274 char tbuffer[BOZO_BSSIZE];
276 char *instp, *typep, *notifier, *notp;
277 register afs_int32 code;
278 afs_int32 ktmask, ktday, kthour, ktmin, ktsec;
281 char *parms[MAXPARMS];
284 /* rename BozoInit to BosServer for the user */
286 /* if BozoInit exists and BosConfig doesn't, try a rename */
287 if (access(AFSDIR_SERVER_BOZINIT_FILEPATH, 0) == 0
288 && access(AFSDIR_SERVER_BOZCONF_FILEPATH, 0) != 0) {
290 renamefile(AFSDIR_SERVER_BOZINIT_FILEPATH,
291 AFSDIR_SERVER_BOZCONF_FILEPATH);
293 perror("bosconfig rename");
295 if (access(AFSDIR_SERVER_BOZCONFNEW_FILEPATH, 0) == 0) {
297 renamefile(AFSDIR_SERVER_BOZCONFNEW_FILEPATH,
298 AFSDIR_SERVER_BOZCONF_FILEPATH);
300 perror("bosconfig rename");
304 /* don't do server restarts by default */
305 bozo_nextRestartKT.mask = KTIME_NEVER;
306 bozo_nextRestartKT.hour = 0;
307 bozo_nextRestartKT.min = 0;
308 bozo_nextRestartKT.day = 0;
310 /* restart processes at 5am if their binaries have changed */
311 bozo_nextDayKT.mask = KTIME_HOUR | KTIME_MIN;
312 bozo_nextDayKT.hour = 5;
313 bozo_nextDayKT.min = 0;
315 for (code = 0; code < MAXPARMS; code++)
317 instp = typep = notifier = NULL;
320 aname = (char *)bozo_fileName;
321 tfile = fopen(aname, "r");
324 instp = (char *)malloc(BOZO_BSSIZE);
325 typep = (char *)malloc(BOZO_BSSIZE);
326 notifier = notp = (char *)malloc(BOZO_BSSIZE);
328 /* ok, read lines giving parms and such from the file */
329 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
331 break; /* all done */
333 if (strncmp(tbuffer, "restarttime", 11) == 0) {
335 sscanf(tbuffer, "restarttime %d %d %d %d %d", &ktmask, &ktday,
336 &kthour, &ktmin, &ktsec);
341 /* otherwise we've read in the proper ktime structure; now assign
342 * it and continue processing */
343 bozo_nextRestartKT.mask = ktmask;
344 bozo_nextRestartKT.day = ktday;
345 bozo_nextRestartKT.hour = kthour;
346 bozo_nextRestartKT.min = ktmin;
347 bozo_nextRestartKT.sec = ktsec;
351 if (strncmp(tbuffer, "checkbintime", 12) == 0) {
353 sscanf(tbuffer, "checkbintime %d %d %d %d %d", &ktmask,
354 &ktday, &kthour, &ktmin, &ktsec);
359 /* otherwise we've read in the proper ktime structure; now assign
360 * it and continue processing */
361 bozo_nextDayKT.mask = ktmask; /* time to restart the system */
362 bozo_nextDayKT.day = ktday;
363 bozo_nextDayKT.hour = kthour;
364 bozo_nextDayKT.min = ktmin;
365 bozo_nextDayKT.sec = ktsec;
369 if (strncmp(tbuffer, "restrictmode", 12) == 0) {
370 code = sscanf(tbuffer, "restrictmode %d", &rmode);
375 if (rmode != 0 && rmode != 1) {
379 bozo_isrestricted = rmode;
383 if (strncmp("bnode", tbuffer, 5) != 0) {
389 sscanf(tbuffer, "bnode %s %s %d %s", typep, instp, &goal,
394 } else if (code == 3)
397 for (i = 0; i < MAXPARMS; i++) {
398 /* now read the parms, until we see an "end" line */
399 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
405 if (!strncmp(tbuffer, "end", 3))
407 if (strncmp(tbuffer, "parm ", 5)) {
409 goto fail; /* no "parm " either */
411 if (!parms[i]) /* make sure there's space */
412 parms[i] = (char *)malloc(BOZO_BSSIZE);
413 strcpy(parms[i], tbuffer + 5); /* remember the parameter for later */
416 /* ok, we have the type and parms, now create the object */
418 bnode_Create(typep, instp, &tb, parms[0], parms[1], parms[2],
419 parms[3], parms[4], notifier,
420 goal ? BSTAT_NORMAL : BSTAT_SHUTDOWN, 0);
424 /* bnode created in 'temporarily shutdown' state;
425 * check to see if we are supposed to run this guy,
426 * and if so, start the process up */
428 bnode_SetStat(tb, BSTAT_NORMAL); /* set goal, taking effect immediately */
430 bnode_SetStat(tb, BSTAT_SHUTDOWN);
441 for (i = 0; i < MAXPARMS; i++)
449 /* write a new bozo file */
451 WriteBozoFile(char *aname)
453 register FILE *tfile;
454 char tbuffer[AFSDIR_PATH_MAX];
455 register afs_int32 code;
459 aname = (char *)bozo_fileName;
460 strcpy(tbuffer, aname);
461 strcat(tbuffer, ".NBZ");
462 tfile = fopen(tbuffer, "w");
467 fprintf(tfile, "restrictmode %d\n", bozo_isrestricted);
468 fprintf(tfile, "restarttime %d %d %d %d %d\n", bozo_nextRestartKT.mask,
469 bozo_nextRestartKT.day, bozo_nextRestartKT.hour,
470 bozo_nextRestartKT.min, bozo_nextRestartKT.sec);
471 fprintf(tfile, "checkbintime %d %d %d %d %d\n", bozo_nextDayKT.mask,
472 bozo_nextDayKT.day, bozo_nextDayKT.hour, bozo_nextDayKT.min,
474 code = bnode_ApplyInstance(bzwrite, &btemp);
475 if (code || (code = ferror(tfile))) { /* something went wrong */
480 /* close the file, check for errors and snap new file into place */
481 if (fclose(tfile) == EOF) {
485 code = renamefile(tbuffer, aname);
494 bdrestart(register struct bnode *abnode, void *arock)
496 register afs_int32 code;
498 if (abnode->fileGoal != BSTAT_NORMAL || abnode->goal != BSTAT_NORMAL)
499 return 0; /* don't restart stopped bnodes */
501 code = bnode_RestartP(abnode);
503 /* restart the dude */
504 bnode_SetStat(abnode, BSTAT_SHUTDOWN);
505 bnode_WaitStatus(abnode, BSTAT_SHUTDOWN);
506 bnode_SetStat(abnode, BSTAT_NORMAL);
508 bnode_Release(abnode);
509 return 0; /* keep trying all bnodes */
512 #define BOZO_MINSKIP 3600 /* minimum to advance clock */
513 /* lwp to handle system restarts */
515 BozoDaemon(void *unused)
517 register afs_int32 now;
519 /* now initialize the values */
523 now = FT_ApproxTime();
525 if (bozo_restdisable) {
526 bozo_Log("Restricted mode disabled by signal\n");
527 bozo_restdisable = 0;
530 if (bozo_newKTs) { /* need to recompute restart times */
531 bozo_newKTs = 0; /* done for a while */
532 nextRestart = ktime_next(&bozo_nextRestartKT, BOZO_MINSKIP);
533 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
536 /* see if we should do a restart */
537 if (now > nextRestart) {
538 SBOZO_ReBozo(0); /* doesn't come back */
541 /* see if we should restart a server */
543 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
545 /* call the bnode restartp function, and restart all that require it */
546 bnode_ApplyInstance(bdrestart, 0);
558 int s, sb_max, ipfragttl;
562 f = popen("/usr/sbin/no -o sb_max", "r");
563 s = fscanf(f, "sb_max = %d", &sb_max);
567 f = popen("/usr/sbin/no -o ipfragttl", "r");
568 s = fscanf(f, "ipfragttl = %d", &ipfragttl);
578 sprintf(c, "/usr/sbin/no -o sb_max=%d -o ipfragttl=%d", sb_max,
587 * This routine causes the calling process to go into the background and
588 * to lose its controlling tty.
590 * It does not close or otherwise alter the standard file descriptors.
592 * It writes warning messages to the standard error output if certain
593 * fundamental errors occur.
595 * This routine requires
597 * #include <sys/types.h>
598 * #include <sys/stat.h>
600 * #include <unistd.h>
601 * #include <stdlib.h>
603 * and has been tested on:
619 * A process is a process group leader if its process ID
620 * (getpid()) and its process group ID (getpgrp()) are the same.
624 * To create a new session (and thereby lose our controlling
625 * terminal) we cannot be a process group leader.
627 * To guarantee we are not a process group leader, we fork and
628 * let the parent process exit.
631 if (getpid() == getpgrp()) {
636 abort(); /* leave footprints */
640 default: /* parent */
647 * By here, we are not a process group leader, so we can make a
648 * new session and become the session leader.
652 pid_t sid = setsid();
655 static char err[] = "bosserver: WARNING: setsid() failed\n";
656 write(STDERR_FILENO, err, sizeof err - 1);
661 * Once we create a new session, the current process is a
662 * session leader without a controlling tty.
664 * On some systems, the first tty device the session leader
665 * opens automatically becomes the controlling tty for the
668 * So, to guarantee we do not acquire a controlling tty, we fork
669 * and let the parent process exit. The child process is not a
670 * session leader, and so it will not acquire a controlling tty
671 * even if it should happen to open a tty device.
674 if (getpid() == getpgrp()) {
679 abort(); /* leave footprints */
683 default: /* parent */
690 * check that we no longer have a controlling tty
696 fd = open("/dev/tty", O_RDONLY);
700 "bosserver: WARNING: /dev/tty still attached\n";
702 write(STDERR_FILENO, err, sizeof err - 1);
706 #endif /* ! AFS_NT40_ENV */
709 /* start a process and monitor it */
711 #include "AFS_component_version_number.c"
714 main(int argc, char **argv, char **envp)
716 struct rx_service *tservice;
717 register afs_int32 code;
718 struct afsconf_dir *tdir;
721 char namebuf[AFSDIR_PATH_MAX];
723 afs_uint32 host = htonl(INADDR_ANY);
724 char *auditFileName = NULL;
730 struct sigaction nsa;
732 /* for some reason, this permits user-mode RX to run a lot faster.
733 * we do it here in the bosserver, so we don't have to do it
734 * individually in each server.
739 * The following signal action for AIX is necessary so that in case of a
740 * crash (i.e. core is generated) we can include the user's data section
741 * in the core dump. Unfortunately, by default, only a partial core is
742 * generated which, in many cases, isn't too useful.
744 sigemptyset(&nsa.sa_mask);
745 nsa.sa_handler = SIG_DFL;
746 nsa.sa_flags = SA_FULLDUMP;
747 sigaction(SIGSEGV, &nsa, NULL);
748 sigaction(SIGABRT, &nsa, NULL);
751 signal(SIGFPE, bozo_insecureme);
754 /* Initialize winsock */
755 if (afs_winsockInit() < 0) {
756 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
757 fprintf(stderr, "%s: Couldn't initialize winsock.\n", argv[0]);
762 /* Initialize dirpaths */
763 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
765 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
767 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
772 /* some path inits */
773 bozo_fileName = AFSDIR_SERVER_BOZCONF_FILEPATH;
775 /* initialize the list of dirpaths that the bosserver has
776 * an interest in monitoring */
779 #if defined(AFS_SGI_ENV)
780 /* offer some protection if AFS isn't loaded */
781 if (syscall(AFS_SYSCALL, AFSOP_ENDLOG) < 0 && errno == ENOPKG) {
782 printf("bosserver: AFS doesn't appear to be configured in O.S..\n");
788 for (code = 1; code < argc; code++) {
789 if (strcmp(argv[code], "-noauth") == 0) {
790 /* set noauth flag */
792 } else if (strcmp(argv[code], "-log") == 0) {
793 /* set extra logging flag */
797 else if (strcmp(argv[code], "-syslog") == 0) {
798 /* set syslog logging flag */
800 } else if (strncmp(argv[code], "-syslog=", 8) == 0) {
802 DoSyslogFacility = atoi(argv[code] + 8);
803 } else if (strcmp(argv[code], "-nofork") == 0) {
807 else if (strcmp(argv[code], "-enable_peer_stats") == 0) {
808 rx_enablePeerRPCStats();
809 } else if (strcmp(argv[code], "-enable_process_stats") == 0) {
810 rx_enableProcessRPCStats();
812 else if (strcmp(argv[code], "-restricted") == 0) {
813 bozo_isrestricted = 1;
815 else if (strcmp(argv[code], "-rxbind") == 0) {
818 else if (strcmp(argv[code], "-allow-dotted-principals") == 0) {
819 rxkadDisableDotCheck = 1;
821 else if (!strcmp(argv[code], "-rxmaxmtu")) {
822 if ((code + 1) >= argc) {
823 fprintf(stderr, "missing argument for -rxmaxmtu\n");
826 rxMaxMTU = atoi(argv[++code]);
827 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
828 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
829 printf("rxMaxMTU %d invalid; must be between %d-%" AFS_SIZET_FMT "\n",
830 rxMaxMTU, RX_MIN_PACKET_SIZE,
831 RX_MAX_PACKET_DATA_SIZE);
835 else if (strcmp(argv[code], "-auditlog") == 0) {
836 auditFileName = argv[++code];
838 } else if (strcmp(argv[code], "-audit-interface") == 0) {
839 char *interface = argv[++code];
841 if (osi_audit_interface(interface)) {
842 printf("Invalid audit interface '%s'\n", interface);
848 /* hack to support help flag */
851 printf("Usage: bosserver [-noauth] [-log] "
852 "[-auditlog <log path>] "
853 "[-audit-interafce <file|sysvmq> (default is file)] "
854 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
855 "[-syslog[=FACILITY]] "
856 "[-enable_peer_stats] [-enable_process_stats] "
857 "[-nofork] " "[-help]\n");
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 "[-enable_peer_stats] [-enable_process_stats] "
872 osi_audit_file(auditFileName);
876 if (geteuid() != 0) {
877 printf("bosserver: must be run as root.\n");
884 printf("bosserver: could not init bnode package, code %d\n", code);
888 bnode_Register("fs", &fsbnode_ops, 3);
889 bnode_Register("dafs", &dafsbnode_ops, 4);
890 bnode_Register("simple", &ezbnode_ops, 1);
891 bnode_Register("cron", &cronbnode_ops, 2);
893 /* create useful dirs */
896 /* chdir to AFS log directory */
897 chdir(AFSDIR_SERVER_LOGS_DIRPATH);
900 fputs(AFS_GOVERNMENT_MESSAGE, stdout);
904 /* go into the background and remove our controlling tty, close open
911 #endif /* ! AFS_NT40_ENV */
915 && ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) &&
916 !(S_ISFIFO(sb.st_mode)))
919 strcpy(namebuf, AFSDIR_BOZLOG_FILE);
920 strcat(namebuf, ".old");
921 renamefile(AFSDIR_BOZLOG_FILE, namebuf); /* try rename first */
922 bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a");
924 printf("bosserver: can't initialize log file (%s).\n",
925 AFSDIR_SERVER_BOZLOG_FILEPATH);
928 /* keep log closed normally, so can be removed */
929 fclose(bozo_logFile);
932 openlog("bosserver", LOG_PID, DoSyslogFacility);
936 /* Write current state of directory permissions to log file */
939 for (i = 0; i < 10; i++) {
940 code = rx_Init(htons(AFSCONF_NANNYPORT));
942 bozo_Log("can't initialize rx: code=%d\n", code);
948 bozo_Log("Bos giving up, can't initialize rx\n");
952 code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
953 /* param */ NULL , "bozo-the-clown",
956 /* try to read the key from the config file */
957 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
959 /* try to create local cell config file */
960 struct afsconf_cell tcell;
961 strcpy(tcell.name, "localcell");
962 tcell.numServers = 1;
963 code = gethostname(tcell.hostName[0], MAXHOSTCHARS);
965 bozo_Log("failed to get hostname, code %d\n", errno);
968 if (tcell.hostName[0][0] == 0) {
969 bozo_Log("host name not set, can't start\n");
970 bozo_Log("try the 'hostname' command\n");
973 memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */
975 afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH,
979 ("could not create cell database in '%s' (code %d), quitting\n",
980 AFSDIR_SERVER_ETC_DIRPATH, code);
983 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
986 ("failed to open newly-created cell database, quitting\n");
991 /* read init file, starting up programs */
992 if ((code = ReadBozoFile(0))) {
994 ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
995 code, AFSDIR_SERVER_BOZCONF_FILEPATH);
999 /* opened the cell databse */
1000 bozo_confdir = tdir;
1002 /* allow super users to manage RX statistics */
1003 rx_SetRxStatUserOk(bozo_rxstat_userok);
1005 /* have bcrypt key now */
1007 afsconf_SetNoAuthFlag(tdir, noAuth);
1009 bozo_rxsc[0] = rxnull_NewServerSecurityObject();
1010 bozo_rxsc[1] = (struct rx_securityClass *)0;
1012 rxkad_NewServerSecurityObject(0, tdir, afsconf_GetKey, NULL);
1014 /* Disable jumbograms */
1017 if (rxMaxMTU != -1) {
1018 rx_SetMaxMTU(rxMaxMTU);
1023 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
1024 AFSDIR_SERVER_NETINFO_FILEPATH) {
1026 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
1027 ADDRSPERSITE, reason,
1028 AFSDIR_SERVER_NETINFO_FILEPATH,
1029 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
1032 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
1035 host = SHostAddrs[0];
1038 tservice = rx_NewServiceHost(host, /* port */ 0, /* service id */ 1,
1039 /*service name */ "bozo",
1040 /* security classes */
1042 /* numb sec classes */ 3, BOZO_ExecuteRequest);
1043 rx_SetMinProcs(tservice, 2);
1044 rx_SetMaxProcs(tservice, 4);
1045 rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE); /* so gethostbyname works (in cell stuff) */
1046 if (rxkadDisableDotCheck) {
1047 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
1048 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
1052 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats", bozo_rxsc,
1053 3, RXSTATS_ExecuteRequest);
1054 rx_SetMinProcs(tservice, 2);
1055 rx_SetMaxProcs(tservice, 4);
1056 rx_StartServer(1); /* donate this process */
1061 bozo_Log(char *format, ...)
1067 va_start(ap, format);
1070 #ifndef AFS_NT40_ENV
1071 vsyslog(LOG_INFO, format, ap);
1075 strcpy(tdate, ctime(&myTime)); /* copy out of static area asap */
1078 /* log normally closed, so can be removed */
1080 bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a");
1081 if (bozo_logFile == NULL) {
1082 printf("bosserver: WARNING: problem with %s\n",
1083 AFSDIR_SERVER_BOZLOG_FILEPATH);
1084 printf("%s ", tdate);
1085 vprintf(format, ap);
1088 fprintf(bozo_logFile, "%s ", tdate);
1089 vfprintf(bozo_logFile, format, ap);
1091 /* close so rm BosLog works */
1092 fclose(bozo_logFile);