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>
26 #ifdef HAVE_SYS_TIME_H
29 #ifdef HAVE_SYS_RESOURCE_H
30 #include <sys/resource.h>
36 #include <WINNT/afsevent.h>
39 #include <netinet/in.h>
41 #endif /* AFS_NT40_ENV */
42 #include <afs/cellconfig.h>
45 #include <rx/rx_globals.h>
48 #include "bosprototypes.h"
50 #include <rx/rxstat.h>
52 #include <afs/ktime.h>
53 #include <afs/afsutil.h>
54 #include <afs/fileutil.h>
55 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
56 #include <afs/audit.h>
57 #include <afs/cellconfig.h>
58 #if defined(AFS_SGI_ENV)
59 #include <afs/afs_args.h>
62 #define BOZO_LWP_STACKSIZE 16000
63 extern struct bnode_ops fsbnode_ops, dafsbnode_ops, ezbnode_ops, cronbnode_ops;
65 struct afsconf_dir *bozo_confdir = 0; /* bozo configuration dir */
66 static PROCESS bozo_pid;
67 const char *bozo_fileName;
74 int DoSyslogFacility = LOG_DAEMON;
76 static afs_int32 nextRestart;
77 static afs_int32 nextDay;
79 struct ktime bozo_nextRestartKT, bozo_nextDayKT;
82 int rxkadDisableDotCheck = 0;
84 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
85 afs_uint32 SHostAddrs[ADDRSPERSITE];
87 int bozo_isrestricted = 0;
88 int bozo_restdisable = 0;
91 bozo_insecureme(int sig)
93 signal(SIGFPE, bozo_insecureme);
94 bozo_isrestricted = 0;
102 /* check whether caller is authorized to manage RX statistics */
104 bozo_rxstat_userok(struct rx_call *call)
106 return afsconf_SuperUser(bozo_confdir, call, NULL);
109 /* restart bozo process */
114 /* exit with restart code; SCM integrator process will restart bosserver */
115 int status = BOSEXIT_RESTART;
117 /* if noauth flag is set, pass "-noauth" to new bosserver */
118 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
119 status |= BOSEXIT_NOAUTH_FLAG;
121 /* if logging is on, pass "-log" to new bosserver */
123 status |= BOSEXIT_LOGGING_FLAG;
127 /* exec new bosserver process */
131 argv[i] = (char *)AFSDIR_SERVER_BOSVR_FILEPATH;
134 /* if noauth flag is set, pass "-noauth" to new bosserver */
135 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
139 /* if logging is on, pass "-log" to new bosserver */
145 /* if syslog logging is on, pass "-syslog" to new bosserver */
147 char *arg = (char *)malloc(40); /* enough for -syslog=# */
148 if (DoSyslogFacility != LOG_DAEMON) {
149 snprintf(arg, 40, "-syslog=%d", DoSyslogFacility);
151 strcpy(arg, "-syslog");
158 /* null-terminate argument list */
161 /* close random fd's */
162 for (i = 3; i < 64; i++) {
166 execv(argv[0], argv); /* should not return */
168 #endif /* AFS_NT40_ENV */
171 /* make sure a dir exists */
173 MakeDir(const char *adir)
176 register afs_int32 code;
177 if (stat(adir, &tstat) < 0 || (tstat.st_mode & S_IFMT) != S_IFDIR) {
180 reqPerm = GetRequiredDirPerm(adir);
184 /* underlying filesystem may not support directory protection */
187 code = mkdir(adir, reqPerm);
194 /* create all the bozo dirs */
196 CreateDirs(const char *coredir)
199 (AFSDIR_USR_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
200 strlen(AFSDIR_USR_DIRPATH)))
203 (AFSDIR_USR_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
204 strlen(AFSDIR_USR_DIRPATH)))) {
205 MakeDir(AFSDIR_USR_DIRPATH);
208 (AFSDIR_SERVER_AFS_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
209 strlen(AFSDIR_SERVER_AFS_DIRPATH))) {
210 MakeDir(AFSDIR_SERVER_AFS_DIRPATH);
212 MakeDir(AFSDIR_SERVER_BIN_DIRPATH);
213 MakeDir(AFSDIR_SERVER_ETC_DIRPATH);
214 MakeDir(AFSDIR_SERVER_LOCAL_DIRPATH);
215 MakeDir(AFSDIR_SERVER_DB_DIRPATH);
216 MakeDir(AFSDIR_SERVER_LOGS_DIRPATH);
219 (AFSDIR_CLIENT_VICE_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
220 strlen(AFSDIR_CLIENT_VICE_DIRPATH))) {
221 MakeDir(AFSDIR_CLIENT_VICE_DIRPATH);
223 MakeDir(AFSDIR_CLIENT_ETC_DIRPATH);
225 symlink(AFSDIR_SERVER_THISCELL_FILEPATH, AFSDIR_CLIENT_THISCELL_FILEPATH);
226 symlink(AFSDIR_SERVER_CELLSERVDB_FILEPATH,
227 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
228 #endif /* AFS_NT40_ENV */
234 /* strip the \\n from the end of the line, if it is present */
236 StripLine(register char *abuffer)
240 tp = abuffer + strlen(abuffer); /* starts off pointing at the null */
242 return 0; /* null string, no last character to check */
243 tp--; /* aim at last character */
249 /* write one bnode's worth of entry into the file */
251 bzwrite(register struct bnode *abnode, void *arock)
253 register struct bztemp *at = (struct bztemp *)arock;
255 char tbuffer[BOZO_BSSIZE];
256 register afs_int32 code;
258 if (abnode->notifier)
259 fprintf(at->file, "bnode %s %s %d %s\n", abnode->type->name,
260 abnode->name, abnode->fileGoal, abnode->notifier);
262 fprintf(at->file, "bnode %s %s %d\n", abnode->type->name,
263 abnode->name, abnode->fileGoal);
265 code = bnode_GetParm(abnode, i, tbuffer, BOZO_BSSIZE);
271 fprintf(at->file, "parm %s\n", tbuffer);
273 fprintf(at->file, "end\n");
279 ReadBozoFile(char *aname)
281 register FILE *tfile;
282 char tbuffer[BOZO_BSSIZE];
284 char *instp, *typep, *notifier, *notp;
285 register afs_int32 code;
286 afs_int32 ktmask, ktday, kthour, ktmin, ktsec;
289 char *parms[MAXPARMS];
292 /* rename BozoInit to BosServer for the user */
294 /* if BozoInit exists and BosConfig doesn't, try a rename */
295 if (access(AFSDIR_SERVER_BOZINIT_FILEPATH, 0) == 0
296 && access(AFSDIR_SERVER_BOZCONF_FILEPATH, 0) != 0) {
298 renamefile(AFSDIR_SERVER_BOZINIT_FILEPATH,
299 AFSDIR_SERVER_BOZCONF_FILEPATH);
301 perror("bosconfig rename");
303 if (access(AFSDIR_SERVER_BOZCONFNEW_FILEPATH, 0) == 0) {
305 renamefile(AFSDIR_SERVER_BOZCONFNEW_FILEPATH,
306 AFSDIR_SERVER_BOZCONF_FILEPATH);
308 perror("bosconfig rename");
312 /* don't do server restarts by default */
313 bozo_nextRestartKT.mask = KTIME_NEVER;
314 bozo_nextRestartKT.hour = 0;
315 bozo_nextRestartKT.min = 0;
316 bozo_nextRestartKT.day = 0;
318 /* restart processes at 5am if their binaries have changed */
319 bozo_nextDayKT.mask = KTIME_HOUR | KTIME_MIN;
320 bozo_nextDayKT.hour = 5;
321 bozo_nextDayKT.min = 0;
323 for (code = 0; code < MAXPARMS; code++)
325 instp = typep = notifier = NULL;
328 aname = (char *)bozo_fileName;
329 tfile = fopen(aname, "r");
332 instp = (char *)malloc(BOZO_BSSIZE);
333 typep = (char *)malloc(BOZO_BSSIZE);
334 notifier = notp = (char *)malloc(BOZO_BSSIZE);
336 /* ok, read lines giving parms and such from the file */
337 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
339 break; /* all done */
341 if (strncmp(tbuffer, "restarttime", 11) == 0) {
343 sscanf(tbuffer, "restarttime %d %d %d %d %d", &ktmask, &ktday,
344 &kthour, &ktmin, &ktsec);
349 /* otherwise we've read in the proper ktime structure; now assign
350 * it and continue processing */
351 bozo_nextRestartKT.mask = ktmask;
352 bozo_nextRestartKT.day = ktday;
353 bozo_nextRestartKT.hour = kthour;
354 bozo_nextRestartKT.min = ktmin;
355 bozo_nextRestartKT.sec = ktsec;
359 if (strncmp(tbuffer, "checkbintime", 12) == 0) {
361 sscanf(tbuffer, "checkbintime %d %d %d %d %d", &ktmask,
362 &ktday, &kthour, &ktmin, &ktsec);
367 /* otherwise we've read in the proper ktime structure; now assign
368 * it and continue processing */
369 bozo_nextDayKT.mask = ktmask; /* time to restart the system */
370 bozo_nextDayKT.day = ktday;
371 bozo_nextDayKT.hour = kthour;
372 bozo_nextDayKT.min = ktmin;
373 bozo_nextDayKT.sec = ktsec;
377 if (strncmp(tbuffer, "restrictmode", 12) == 0) {
378 code = sscanf(tbuffer, "restrictmode %d", &rmode);
383 if (rmode != 0 && rmode != 1) {
387 bozo_isrestricted = rmode;
391 if (strncmp("bnode", tbuffer, 5) != 0) {
397 sscanf(tbuffer, "bnode %s %s %d %s", typep, instp, &goal,
402 } else if (code == 3)
405 for (i = 0; i < MAXPARMS; i++) {
406 /* now read the parms, until we see an "end" line */
407 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
413 if (!strncmp(tbuffer, "end", 3))
415 if (strncmp(tbuffer, "parm ", 5)) {
417 goto fail; /* no "parm " either */
419 if (!parms[i]) /* make sure there's space */
420 parms[i] = (char *)malloc(BOZO_BSSIZE);
421 strcpy(parms[i], tbuffer + 5); /* remember the parameter for later */
424 /* ok, we have the type and parms, now create the object */
426 bnode_Create(typep, instp, &tb, parms[0], parms[1], parms[2],
427 parms[3], parms[4], notifier,
428 goal ? BSTAT_NORMAL : BSTAT_SHUTDOWN, 0);
432 /* bnode created in 'temporarily shutdown' state;
433 * check to see if we are supposed to run this guy,
434 * and if so, start the process up */
436 bnode_SetStat(tb, BSTAT_NORMAL); /* set goal, taking effect immediately */
438 bnode_SetStat(tb, BSTAT_SHUTDOWN);
449 for (i = 0; i < MAXPARMS; i++)
457 /* write a new bozo file */
459 WriteBozoFile(char *aname)
461 register FILE *tfile;
462 char tbuffer[AFSDIR_PATH_MAX];
463 register afs_int32 code;
467 aname = (char *)bozo_fileName;
468 strcpy(tbuffer, aname);
469 strcat(tbuffer, ".NBZ");
470 tfile = fopen(tbuffer, "w");
475 fprintf(tfile, "restrictmode %d\n", bozo_isrestricted);
476 fprintf(tfile, "restarttime %d %d %d %d %d\n", bozo_nextRestartKT.mask,
477 bozo_nextRestartKT.day, bozo_nextRestartKT.hour,
478 bozo_nextRestartKT.min, bozo_nextRestartKT.sec);
479 fprintf(tfile, "checkbintime %d %d %d %d %d\n", bozo_nextDayKT.mask,
480 bozo_nextDayKT.day, bozo_nextDayKT.hour, bozo_nextDayKT.min,
482 code = bnode_ApplyInstance(bzwrite, &btemp);
483 if (code || (code = ferror(tfile))) { /* something went wrong */
488 /* close the file, check for errors and snap new file into place */
489 if (fclose(tfile) == EOF) {
493 code = renamefile(tbuffer, aname);
502 bdrestart(register struct bnode *abnode, void *arock)
504 register afs_int32 code;
506 if (abnode->fileGoal != BSTAT_NORMAL || abnode->goal != BSTAT_NORMAL)
507 return 0; /* don't restart stopped bnodes */
509 code = bnode_RestartP(abnode);
511 /* restart the dude */
512 bnode_SetStat(abnode, BSTAT_SHUTDOWN);
513 bnode_WaitStatus(abnode, BSTAT_SHUTDOWN);
514 bnode_SetStat(abnode, BSTAT_NORMAL);
516 bnode_Release(abnode);
517 return 0; /* keep trying all bnodes */
520 #define BOZO_MINSKIP 3600 /* minimum to advance clock */
521 /* lwp to handle system restarts */
523 BozoDaemon(void *unused)
525 register afs_int32 now;
527 /* now initialize the values */
531 now = FT_ApproxTime();
533 if (bozo_restdisable) {
534 bozo_Log("Restricted mode disabled by signal\n");
535 bozo_restdisable = 0;
538 if (bozo_newKTs) { /* need to recompute restart times */
539 bozo_newKTs = 0; /* done for a while */
540 nextRestart = ktime_next(&bozo_nextRestartKT, BOZO_MINSKIP);
541 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
544 /* see if we should do a restart */
545 if (now > nextRestart) {
546 SBOZO_ReBozo(0); /* doesn't come back */
549 /* see if we should restart a server */
551 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
553 /* call the bnode restartp function, and restart all that require it */
554 bnode_ApplyInstance(bdrestart, 0);
566 int s, sb_max, ipfragttl;
570 f = popen("/usr/sbin/no -o sb_max", "r");
571 s = fscanf(f, "sb_max = %d", &sb_max);
575 f = popen("/usr/sbin/no -o ipfragttl", "r");
576 s = fscanf(f, "ipfragttl = %d", &ipfragttl);
586 sprintf(c, "/usr/sbin/no -o sb_max=%d -o ipfragttl=%d", sb_max,
595 * This routine causes the calling process to go into the background and
596 * to lose its controlling tty.
598 * It does not close or otherwise alter the standard file descriptors.
600 * It writes warning messages to the standard error output if certain
601 * fundamental errors occur.
603 * This routine requires
605 * #include <sys/types.h>
606 * #include <sys/stat.h>
608 * #include <unistd.h>
609 * #include <stdlib.h>
611 * and has been tested on:
627 * A process is a process group leader if its process ID
628 * (getpid()) and its process group ID (getpgrp()) are the same.
632 * To create a new session (and thereby lose our controlling
633 * terminal) we cannot be a process group leader.
635 * To guarantee we are not a process group leader, we fork and
636 * let the parent process exit.
639 if (getpid() == getpgrp()) {
644 abort(); /* leave footprints */
648 default: /* parent */
655 * By here, we are not a process group leader, so we can make a
656 * new session and become the session leader.
660 pid_t sid = setsid();
663 static char err[] = "bosserver: WARNING: setsid() failed\n";
664 write(STDERR_FILENO, err, sizeof err - 1);
669 * Once we create a new session, the current process is a
670 * session leader without a controlling tty.
672 * On some systems, the first tty device the session leader
673 * opens automatically becomes the controlling tty for the
676 * So, to guarantee we do not acquire a controlling tty, we fork
677 * and let the parent process exit. The child process is not a
678 * session leader, and so it will not acquire a controlling tty
679 * even if it should happen to open a tty device.
682 if (getpid() == getpgrp()) {
687 abort(); /* leave footprints */
691 default: /* parent */
698 * check that we no longer have a controlling tty
704 fd = open("/dev/tty", O_RDONLY);
708 "bosserver: WARNING: /dev/tty still attached\n";
710 write(STDERR_FILENO, err, sizeof err - 1);
714 #endif /* ! AFS_NT40_ENV */
717 /* start a process and monitor it */
719 #include "AFS_component_version_number.c"
722 main(int argc, char **argv, char **envp)
724 struct rx_service *tservice;
725 register afs_int32 code;
726 struct afsconf_dir *tdir;
729 char namebuf[AFSDIR_PATH_MAX];
731 afs_uint32 host = htonl(INADDR_ANY);
732 char *auditFileName = NULL;
733 struct rx_securityClass **securityClasses;
734 afs_int32 numClasses;
740 struct sigaction nsa;
742 /* for some reason, this permits user-mode RX to run a lot faster.
743 * we do it here in the bosserver, so we don't have to do it
744 * individually in each server.
749 * The following signal action for AIX is necessary so that in case of a
750 * crash (i.e. core is generated) we can include the user's data section
751 * in the core dump. Unfortunately, by default, only a partial core is
752 * generated which, in many cases, isn't too useful.
754 sigemptyset(&nsa.sa_mask);
755 nsa.sa_handler = SIG_DFL;
756 nsa.sa_flags = SA_FULLDUMP;
757 sigaction(SIGSEGV, &nsa, NULL);
758 sigaction(SIGABRT, &nsa, NULL);
761 signal(SIGFPE, bozo_insecureme);
764 /* Initialize winsock */
765 if (afs_winsockInit() < 0) {
766 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
767 fprintf(stderr, "%s: Couldn't initialize winsock.\n", argv[0]);
772 /* Initialize dirpaths */
773 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
775 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
777 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
782 /* some path inits */
783 bozo_fileName = AFSDIR_SERVER_BOZCONF_FILEPATH;
784 DoCore = AFSDIR_SERVER_LOGS_DIRPATH;
786 /* initialize the list of dirpaths that the bosserver has
787 * an interest in monitoring */
790 #if defined(AFS_SGI_ENV)
791 /* offer some protection if AFS isn't loaded */
792 if (syscall(AFS_SYSCALL, AFSOP_ENDLOG) < 0 && errno == ENOPKG) {
793 printf("bosserver: AFS doesn't appear to be configured in O.S..\n");
799 for (code = 1; code < argc; code++) {
800 if (strcmp(argv[code], "-noauth") == 0) {
801 /* set noauth flag */
803 } else if (strcmp(argv[code], "-log") == 0) {
804 /* set extra logging flag */
808 else if (strcmp(argv[code], "-syslog") == 0) {
809 /* set syslog logging flag */
811 } else if (strncmp(argv[code], "-syslog=", 8) == 0) {
813 DoSyslogFacility = atoi(argv[code] + 8);
814 } else if (strncmp(argv[code], "-cores=", 7) == 0) {
815 if (strcmp((argv[code]+7), "none") == 0)
818 DoCore = (argv[code]+7);
819 } else if (strcmp(argv[code], "-nofork") == 0) {
823 else if (strcmp(argv[code], "-enable_peer_stats") == 0) {
824 rx_enablePeerRPCStats();
825 } else if (strcmp(argv[code], "-enable_process_stats") == 0) {
826 rx_enableProcessRPCStats();
828 else if (strcmp(argv[code], "-restricted") == 0) {
829 bozo_isrestricted = 1;
831 else if (strcmp(argv[code], "-rxbind") == 0) {
834 else if (strcmp(argv[code], "-allow-dotted-principals") == 0) {
835 rxkadDisableDotCheck = 1;
837 else if (!strcmp(argv[code], "-rxmaxmtu")) {
838 if ((code + 1) >= argc) {
839 fprintf(stderr, "missing argument for -rxmaxmtu\n");
842 rxMaxMTU = atoi(argv[++code]);
843 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
844 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
845 printf("rxMaxMTU %d invalid; must be between %d-%" AFS_SIZET_FMT "\n",
846 rxMaxMTU, RX_MIN_PACKET_SIZE,
847 RX_MAX_PACKET_DATA_SIZE);
851 else if (strcmp(argv[code], "-auditlog") == 0) {
852 auditFileName = argv[++code];
854 } else if (strcmp(argv[code], "-audit-interface") == 0) {
855 char *interface = argv[++code];
857 if (osi_audit_interface(interface)) {
858 printf("Invalid audit interface '%s'\n", interface);
864 /* hack to support help flag */
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 "[-syslog[=FACILITY]] "
872 "[-enable_peer_stats] [-enable_process_stats] "
873 "[-cores=<none|path>] \n"
874 "[-nofork] " "[-help]\n");
876 printf("Usage: bosserver [-noauth] [-log] "
877 "[-auditlog <log path>] "
878 "[-audit-interafce <file|sysvmq> (default is file)] "
879 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
880 "[-enable_peer_stats] [-enable_process_stats] "
881 "[-cores=<none|path>] \n"
890 osi_audit_file(auditFileName);
894 if (geteuid() != 0) {
895 printf("bosserver: must be run as root.\n");
902 printf("bosserver: could not init bnode package, code %d\n", code);
906 bnode_Register("fs", &fsbnode_ops, 3);
907 bnode_Register("dafs", &dafsbnode_ops, 4);
908 bnode_Register("simple", &ezbnode_ops, 1);
909 bnode_Register("cron", &cronbnode_ops, 2);
911 /* create useful dirs */
914 /* 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 #if defined(RLIMIT_CORE) && defined(HAVE_GETRLIMIT)
960 getrlimit(RLIMIT_CORE, &rlp);
964 rlp.rlim_max = rlp.rlim_cur = RLIM_INFINITY;
965 setrlimit(RLIMIT_CORE, &rlp);
966 getrlimit(RLIMIT_CORE, &rlp);
967 bozo_Log("Core limits now %d %d\n",(int)rlp.rlim_cur,(int)rlp.rlim_max);
971 /* Write current state of directory permissions to log file */
974 for (i = 0; i < 10; i++) {
975 code = rx_Init(htons(AFSCONF_NANNYPORT));
977 bozo_Log("can't initialize rx: code=%d\n", code);
983 bozo_Log("Bos giving up, can't initialize rx\n");
987 code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
988 /* param */ NULL , "bozo-the-clown",
991 /* try to read the key from the config file */
992 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
994 /* try to create local cell config file */
995 struct afsconf_cell tcell;
996 strcpy(tcell.name, "localcell");
997 tcell.numServers = 1;
998 code = gethostname(tcell.hostName[0], MAXHOSTCHARS);
1000 bozo_Log("failed to get hostname, code %d\n", errno);
1003 if (tcell.hostName[0][0] == 0) {
1004 bozo_Log("host name not set, can't start\n");
1005 bozo_Log("try the 'hostname' command\n");
1008 memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */
1010 afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH,
1014 ("could not create cell database in '%s' (code %d), quitting\n",
1015 AFSDIR_SERVER_ETC_DIRPATH, code);
1018 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1021 ("failed to open newly-created cell database, quitting\n");
1026 /* read init file, starting up programs */
1027 if ((code = ReadBozoFile(0))) {
1029 ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
1030 code, AFSDIR_SERVER_BOZCONF_FILEPATH);
1034 /* opened the cell databse */
1035 bozo_confdir = tdir;
1037 /* allow super users to manage RX statistics */
1038 rx_SetRxStatUserOk(bozo_rxstat_userok);
1040 afsconf_SetNoAuthFlag(tdir, noAuth);
1041 afsconf_BuildServerSecurityObjects(tdir, 0, &securityClasses, &numClasses);
1043 /* Disable jumbograms */
1046 if (rxMaxMTU != -1) {
1047 rx_SetMaxMTU(rxMaxMTU);
1052 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
1053 AFSDIR_SERVER_NETINFO_FILEPATH) {
1055 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
1056 ADDRSPERSITE, reason,
1057 AFSDIR_SERVER_NETINFO_FILEPATH,
1058 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
1061 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
1064 host = SHostAddrs[0];
1067 tservice = rx_NewServiceHost(host, 0, /* service id */ 1,
1068 "bozo", securityClasses, numClasses,
1069 BOZO_ExecuteRequest);
1070 rx_SetMinProcs(tservice, 2);
1071 rx_SetMaxProcs(tservice, 4);
1072 rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE); /* so gethostbyname works (in cell stuff) */
1073 if (rxkadDisableDotCheck) {
1074 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
1075 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
1079 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats",
1080 securityClasses, numClasses, RXSTATS_ExecuteRequest);
1081 rx_SetMinProcs(tservice, 2);
1082 rx_SetMaxProcs(tservice, 4);
1083 rx_StartServer(1); /* donate this process */
1088 bozo_Log(char *format, ...)
1094 va_start(ap, format);
1097 #ifndef AFS_NT40_ENV
1098 vsyslog(LOG_INFO, format, ap);
1102 strcpy(tdate, ctime(&myTime)); /* copy out of static area asap */
1105 /* log normally closed, so can be removed */
1107 bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a");
1108 if (bozo_logFile == NULL) {
1109 printf("bosserver: WARNING: problem with %s\n",
1110 AFSDIR_SERVER_BOZLOG_FILEPATH);
1111 printf("%s ", tdate);
1112 vprintf(format, ap);
1115 fprintf(bozo_logFile, "%s ", tdate);
1116 vfprintf(bozo_logFile, format, ap);
1118 /* close so rm BosLog works */
1119 fclose(bozo_logFile);