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>
14 #include <afs/procmgmt.h>
17 #ifdef IGNORE_SOME_GCC_WARNINGS
18 # pragma GCC diagnostic warning "-Wdeprecated-declarations"
21 #ifdef HAVE_SYS_RESOURCE_H
22 #include <sys/resource.h>
27 #include <WINNT/afsevent.h>
28 #endif /* AFS_NT40_ENV */
32 #include <rx/rx_globals.h>
34 #include <rx/rxstat.h>
36 #include <afs/ktime.h>
37 #include <afs/afsutil.h>
38 #include <afs/fileutil.h>
39 #include <afs/audit.h>
40 #include <afs/cellconfig.h>
42 #if defined(AFS_SGI_ENV)
43 #include <afs/afs_args.h>
48 #include "bosprototypes.h"
50 #define BOZO_LWP_STACKSIZE 16000
51 extern struct bnode_ops fsbnode_ops, dafsbnode_ops, ezbnode_ops, cronbnode_ops;
53 struct afsconf_dir *bozo_confdir = 0; /* bozo configuration dir */
54 static PROCESS bozo_pid;
55 const char *bozo_fileName;
62 int DoSyslogFacility = LOG_DAEMON;
64 static afs_int32 nextRestart;
65 static afs_int32 nextDay;
67 struct ktime bozo_nextRestartKT, bozo_nextDayKT;
70 int rxkadDisableDotCheck = 0;
72 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
73 afs_uint32 SHostAddrs[ADDRSPERSITE];
75 int bozo_isrestricted = 0;
76 int bozo_restdisable = 0;
79 bozo_insecureme(int sig)
81 signal(SIGFPE, bozo_insecureme);
82 bozo_isrestricted = 0;
90 /* check whether caller is authorized to manage RX statistics */
92 bozo_rxstat_userok(struct rx_call *call)
94 return afsconf_SuperUser(bozo_confdir, call, NULL);
97 /* restart bozo process */
102 /* exit with restart code; SCM integrator process will restart bosserver */
103 int status = BOSEXIT_RESTART;
105 /* if noauth flag is set, pass "-noauth" to new bosserver */
106 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
107 status |= BOSEXIT_NOAUTH_FLAG;
109 /* if logging is on, pass "-log" to new bosserver */
111 status |= BOSEXIT_LOGGING_FLAG;
115 /* exec new bosserver process */
119 argv[i] = (char *)AFSDIR_SERVER_BOSVR_FILEPATH;
122 /* if noauth flag is set, pass "-noauth" to new bosserver */
123 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
127 /* if logging is on, pass "-log" to new bosserver */
133 /* if syslog logging is on, pass "-syslog" to new bosserver */
135 char *arg = (char *)malloc(40); /* enough for -syslog=# */
136 if (DoSyslogFacility != LOG_DAEMON) {
137 snprintf(arg, 40, "-syslog=%d", DoSyslogFacility);
139 strcpy(arg, "-syslog");
146 /* null-terminate argument list */
149 /* close random fd's */
150 for (i = 3; i < 64; i++) {
154 execv(argv[0], argv); /* should not return */
156 #endif /* AFS_NT40_ENV */
159 /* make sure a dir exists */
161 MakeDir(const char *adir)
165 if (stat(adir, &tstat) < 0 || (tstat.st_mode & S_IFMT) != S_IFDIR) {
168 reqPerm = GetRequiredDirPerm(adir);
172 /* underlying filesystem may not support directory protection */
175 code = mkdir(adir, reqPerm);
182 /* create all the bozo dirs */
184 CreateDirs(const char *coredir)
187 (AFSDIR_USR_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
188 strlen(AFSDIR_USR_DIRPATH)))
191 (AFSDIR_USR_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
192 strlen(AFSDIR_USR_DIRPATH)))) {
193 MakeDir(AFSDIR_USR_DIRPATH);
196 (AFSDIR_SERVER_AFS_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
197 strlen(AFSDIR_SERVER_AFS_DIRPATH))) {
198 MakeDir(AFSDIR_SERVER_AFS_DIRPATH);
200 MakeDir(AFSDIR_SERVER_BIN_DIRPATH);
201 MakeDir(AFSDIR_SERVER_ETC_DIRPATH);
202 MakeDir(AFSDIR_SERVER_LOCAL_DIRPATH);
203 MakeDir(AFSDIR_SERVER_DB_DIRPATH);
204 MakeDir(AFSDIR_SERVER_LOGS_DIRPATH);
207 (AFSDIR_CLIENT_VICE_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
208 strlen(AFSDIR_CLIENT_VICE_DIRPATH))) {
209 MakeDir(AFSDIR_CLIENT_VICE_DIRPATH);
211 MakeDir(AFSDIR_CLIENT_ETC_DIRPATH);
213 symlink(AFSDIR_SERVER_THISCELL_FILEPATH, AFSDIR_CLIENT_THISCELL_FILEPATH);
214 symlink(AFSDIR_SERVER_CELLSERVDB_FILEPATH,
215 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
216 #endif /* AFS_NT40_ENV */
222 /* strip the \\n from the end of the line, if it is present */
224 StripLine(char *abuffer)
228 tp = abuffer + strlen(abuffer); /* starts off pointing at the null */
230 return 0; /* null string, no last character to check */
231 tp--; /* aim at last character */
237 /* write one bnode's worth of entry into the file */
239 bzwrite(struct bnode *abnode, void *arock)
241 struct bztemp *at = (struct bztemp *)arock;
243 char tbuffer[BOZO_BSSIZE];
246 if (abnode->notifier)
247 fprintf(at->file, "bnode %s %s %d %s\n", abnode->type->name,
248 abnode->name, abnode->fileGoal, abnode->notifier);
250 fprintf(at->file, "bnode %s %s %d\n", abnode->type->name,
251 abnode->name, abnode->fileGoal);
253 code = bnode_GetParm(abnode, i, tbuffer, BOZO_BSSIZE);
259 fprintf(at->file, "parm %s\n", tbuffer);
261 fprintf(at->file, "end\n");
267 ReadBozoFile(char *aname)
270 char tbuffer[BOZO_BSSIZE];
272 char *instp, *typep, *notifier, *notp;
274 afs_int32 ktmask, ktday, kthour, ktmin, ktsec;
277 char *parms[MAXPARMS];
278 char *thisparms[MAXPARMS];
281 /* rename BozoInit to BosServer for the user */
283 /* if BozoInit exists and BosConfig doesn't, try a rename */
284 if (access(AFSDIR_SERVER_BOZINIT_FILEPATH, 0) == 0
285 && access(AFSDIR_SERVER_BOZCONF_FILEPATH, 0) != 0) {
287 renamefile(AFSDIR_SERVER_BOZINIT_FILEPATH,
288 AFSDIR_SERVER_BOZCONF_FILEPATH);
290 perror("bosconfig rename");
292 if (access(AFSDIR_SERVER_BOZCONFNEW_FILEPATH, 0) == 0) {
294 renamefile(AFSDIR_SERVER_BOZCONFNEW_FILEPATH,
295 AFSDIR_SERVER_BOZCONF_FILEPATH);
297 perror("bosconfig rename");
301 /* don't do server restarts by default */
302 bozo_nextRestartKT.mask = KTIME_NEVER;
303 bozo_nextRestartKT.hour = 0;
304 bozo_nextRestartKT.min = 0;
305 bozo_nextRestartKT.day = 0;
307 /* restart processes at 5am if their binaries have changed */
308 bozo_nextDayKT.mask = KTIME_HOUR | KTIME_MIN;
309 bozo_nextDayKT.hour = 5;
310 bozo_nextDayKT.min = 0;
312 for (code = 0; code < MAXPARMS; code++)
314 instp = typep = notifier = NULL;
317 aname = (char *)bozo_fileName;
318 tfile = fopen(aname, "r");
321 instp = (char *)malloc(BOZO_BSSIZE);
322 typep = (char *)malloc(BOZO_BSSIZE);
323 notifier = notp = (char *)malloc(BOZO_BSSIZE);
325 /* ok, read lines giving parms and such from the file */
326 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
328 break; /* all done */
330 if (strncmp(tbuffer, "restarttime", 11) == 0) {
332 sscanf(tbuffer, "restarttime %d %d %d %d %d", &ktmask, &ktday,
333 &kthour, &ktmin, &ktsec);
338 /* otherwise we've read in the proper ktime structure; now assign
339 * it and continue processing */
340 bozo_nextRestartKT.mask = ktmask;
341 bozo_nextRestartKT.day = ktday;
342 bozo_nextRestartKT.hour = kthour;
343 bozo_nextRestartKT.min = ktmin;
344 bozo_nextRestartKT.sec = ktsec;
348 if (strncmp(tbuffer, "checkbintime", 12) == 0) {
350 sscanf(tbuffer, "checkbintime %d %d %d %d %d", &ktmask,
351 &ktday, &kthour, &ktmin, &ktsec);
356 /* otherwise we've read in the proper ktime structure; now assign
357 * it and continue processing */
358 bozo_nextDayKT.mask = ktmask; /* time to restart the system */
359 bozo_nextDayKT.day = ktday;
360 bozo_nextDayKT.hour = kthour;
361 bozo_nextDayKT.min = ktmin;
362 bozo_nextDayKT.sec = ktsec;
366 if (strncmp(tbuffer, "restrictmode", 12) == 0) {
367 code = sscanf(tbuffer, "restrictmode %d", &rmode);
372 if (rmode != 0 && rmode != 1) {
376 bozo_isrestricted = rmode;
380 if (strncmp("bnode", tbuffer, 5) != 0) {
386 sscanf(tbuffer, "bnode %s %s %d %s", typep, instp, &goal,
391 } else if (code == 3)
394 memset(thisparms, 0, sizeof(thisparms));
396 for (i = 0; i < MAXPARMS; i++) {
397 /* now read the parms, until we see an "end" line */
398 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
404 if (!strncmp(tbuffer, "end", 3))
406 if (strncmp(tbuffer, "parm ", 5)) {
408 goto fail; /* no "parm " either */
410 if (!parms[i]) /* make sure there's space */
411 parms[i] = (char *)malloc(BOZO_BSSIZE);
412 strcpy(parms[i], tbuffer + 5); /* remember the parameter for later */
413 thisparms[i] = parms[i];
416 /* ok, we have the type and parms, now create the object */
418 bnode_Create(typep, instp, &tb, thisparms[0], thisparms[1],
419 thisparms[2], thisparms[3], thisparms[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)
454 char tbuffer[AFSDIR_PATH_MAX];
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(struct bnode *abnode, void *arock)
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)
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;
718 struct afsconf_dir *tdir;
721 char namebuf[AFSDIR_PATH_MAX];
723 afs_uint32 host = htonl(INADDR_ANY);
724 char *auditFileName = NULL;
725 struct rx_securityClass **securityClasses;
726 afs_int32 numClasses;
732 struct sigaction nsa;
734 /* for some reason, this permits user-mode RX to run a lot faster.
735 * we do it here in the bosserver, so we don't have to do it
736 * individually in each server.
741 * The following signal action for AIX is necessary so that in case of a
742 * crash (i.e. core is generated) we can include the user's data section
743 * in the core dump. Unfortunately, by default, only a partial core is
744 * generated which, in many cases, isn't too useful.
746 sigemptyset(&nsa.sa_mask);
747 nsa.sa_handler = SIG_DFL;
748 nsa.sa_flags = SA_FULLDUMP;
749 sigaction(SIGSEGV, &nsa, NULL);
750 sigaction(SIGABRT, &nsa, NULL);
753 signal(SIGFPE, bozo_insecureme);
756 /* Initialize winsock */
757 if (afs_winsockInit() < 0) {
758 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
759 fprintf(stderr, "%s: Couldn't initialize winsock.\n", argv[0]);
764 /* Initialize dirpaths */
765 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
767 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
769 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
774 /* some path inits */
775 bozo_fileName = AFSDIR_SERVER_BOZCONF_FILEPATH;
776 DoCore = AFSDIR_SERVER_LOGS_DIRPATH;
778 /* initialize the list of dirpaths that the bosserver has
779 * an interest in monitoring */
782 #if defined(AFS_SGI_ENV)
783 /* offer some protection if AFS isn't loaded */
784 if (syscall(AFS_SYSCALL, AFSOP_ENDLOG) < 0 && errno == ENOPKG) {
785 printf("bosserver: AFS doesn't appear to be configured in O.S..\n");
791 for (code = 1; code < argc; code++) {
792 if (strcmp(argv[code], "-noauth") == 0) {
793 /* set noauth flag */
795 } else if (strcmp(argv[code], "-log") == 0) {
796 /* set extra logging flag */
800 else if (strcmp(argv[code], "-syslog") == 0) {
801 /* set syslog logging flag */
803 } else if (strncmp(argv[code], "-syslog=", 8) == 0) {
805 DoSyslogFacility = atoi(argv[code] + 8);
806 } else if (strncmp(argv[code], "-cores=", 7) == 0) {
807 if (strcmp((argv[code]+7), "none") == 0)
810 DoCore = (argv[code]+7);
811 } else if (strcmp(argv[code], "-nofork") == 0) {
815 else if (strcmp(argv[code], "-enable_peer_stats") == 0) {
816 rx_enablePeerRPCStats();
817 } else if (strcmp(argv[code], "-enable_process_stats") == 0) {
818 rx_enableProcessRPCStats();
820 else if (strcmp(argv[code], "-restricted") == 0) {
821 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-%" AFS_SIZET_FMT "\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 "[-cores=<none|path>] \n"
866 "[-nofork] " "[-help]\n");
868 printf("Usage: bosserver [-noauth] [-log] "
869 "[-auditlog <log path>] "
870 "[-audit-interafce <file|sysvmq> (default is file)] "
871 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
872 "[-enable_peer_stats] [-enable_process_stats] "
873 "[-cores=<none|path>] \n"
882 osi_audit_file(auditFileName);
886 if (geteuid() != 0) {
887 printf("bosserver: must be run as root.\n");
894 printf("bosserver: could not init bnode package, code %d\n", code);
898 bnode_Register("fs", &fsbnode_ops, 3);
899 bnode_Register("dafs", &dafsbnode_ops, 4);
900 bnode_Register("simple", &ezbnode_ops, 1);
901 bnode_Register("cron", &cronbnode_ops, 2);
903 /* create useful dirs */
906 /* chdir to AFS log directory */
910 chdir(AFSDIR_SERVER_LOGS_DIRPATH);
913 fputs(AFS_GOVERNMENT_MESSAGE, stdout);
917 /* go into the background and remove our controlling tty, close open
924 #endif /* ! AFS_NT40_ENV */
928 && ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) &&
929 !(S_ISFIFO(sb.st_mode)))
932 strcpy(namebuf, AFSDIR_BOZLOG_FILE);
933 strcat(namebuf, ".old");
934 renamefile(AFSDIR_BOZLOG_FILE, namebuf); /* try rename first */
935 bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a");
937 printf("bosserver: can't initialize log file (%s).\n",
938 AFSDIR_SERVER_BOZLOG_FILEPATH);
941 /* keep log closed normally, so can be removed */
942 fclose(bozo_logFile);
945 openlog("bosserver", LOG_PID, DoSyslogFacility);
949 #if defined(RLIMIT_CORE) && defined(HAVE_GETRLIMIT)
952 getrlimit(RLIMIT_CORE, &rlp);
956 rlp.rlim_max = rlp.rlim_cur = RLIM_INFINITY;
957 setrlimit(RLIMIT_CORE, &rlp);
958 getrlimit(RLIMIT_CORE, &rlp);
959 bozo_Log("Core limits now %d %d\n",(int)rlp.rlim_cur,(int)rlp.rlim_max);
963 /* Write current state of directory permissions to log file */
966 for (i = 0; i < 10; i++) {
967 code = rx_Init(htons(AFSCONF_NANNYPORT));
969 bozo_Log("can't initialize rx: code=%d\n", code);
975 bozo_Log("Bos giving up, can't initialize rx\n");
979 code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
980 /* param */ NULL , "bozo-the-clown",
983 /* try to read the key from the config file */
984 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
986 /* try to create local cell config file */
987 struct afsconf_cell tcell;
988 strcpy(tcell.name, "localcell");
989 tcell.numServers = 1;
990 code = gethostname(tcell.hostName[0], MAXHOSTCHARS);
992 bozo_Log("failed to get hostname, code %d\n", errno);
995 if (tcell.hostName[0][0] == 0) {
996 bozo_Log("host name not set, can't start\n");
997 bozo_Log("try the 'hostname' command\n");
1000 memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */
1002 afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH,
1006 ("could not create cell database in '%s' (code %d), quitting\n",
1007 AFSDIR_SERVER_ETC_DIRPATH, code);
1010 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1013 ("failed to open newly-created cell database, quitting\n");
1018 /* read init file, starting up programs */
1019 if ((code = ReadBozoFile(0))) {
1021 ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
1022 code, AFSDIR_SERVER_BOZCONF_FILEPATH);
1026 /* opened the cell databse */
1027 bozo_confdir = tdir;
1029 /* allow super users to manage RX statistics */
1030 rx_SetRxStatUserOk(bozo_rxstat_userok);
1032 afsconf_SetNoAuthFlag(tdir, noAuth);
1033 afsconf_BuildServerSecurityObjects(tdir, &securityClasses, &numClasses);
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, 0, /* service id */ 1,
1060 "bozo", securityClasses, numClasses,
1061 BOZO_ExecuteRequest);
1062 rx_SetMinProcs(tservice, 2);
1063 rx_SetMaxProcs(tservice, 4);
1064 rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE); /* so gethostbyname works (in cell stuff) */
1065 if (rxkadDisableDotCheck) {
1066 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
1067 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
1071 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats",
1072 securityClasses, numClasses, RXSTATS_ExecuteRequest);
1073 rx_SetMinProcs(tservice, 2);
1074 rx_SetMaxProcs(tservice, 4);
1075 rx_StartServer(1); /* donate this process */
1080 bozo_Log(char *format, ...)
1086 va_start(ap, format);
1089 #ifndef AFS_NT40_ENV
1090 vsyslog(LOG_INFO, format, ap);
1094 strcpy(tdate, ctime(&myTime)); /* copy out of static area asap */
1097 /* log normally closed, so can be removed */
1099 bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a");
1100 if (bozo_logFile == NULL) {
1101 printf("bosserver: WARNING: problem with %s\n",
1102 AFSDIR_SERVER_BOZLOG_FILEPATH);
1103 printf("%s ", tdate);
1104 vprintf(format, ap);
1107 fprintf(bozo_logFile, "%s ", tdate);
1108 vfprintf(bozo_logFile, format, ap);
1110 /* close so rm BosLog works */
1111 fclose(bozo_logFile);