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++)
316 aname = (char *)bozo_fileName;
317 tfile = fopen(aname, "r");
320 instp = malloc(BOZO_BSSIZE);
321 typep = malloc(BOZO_BSSIZE);
322 notifier = notp = malloc(BOZO_BSSIZE);
324 /* ok, read lines giving parms and such from the file */
325 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
327 break; /* all done */
329 if (strncmp(tbuffer, "restarttime", 11) == 0) {
331 sscanf(tbuffer, "restarttime %d %d %d %d %d", &ktmask, &ktday,
332 &kthour, &ktmin, &ktsec);
337 /* otherwise we've read in the proper ktime structure; now assign
338 * it and continue processing */
339 bozo_nextRestartKT.mask = ktmask;
340 bozo_nextRestartKT.day = ktday;
341 bozo_nextRestartKT.hour = kthour;
342 bozo_nextRestartKT.min = ktmin;
343 bozo_nextRestartKT.sec = ktsec;
347 if (strncmp(tbuffer, "checkbintime", 12) == 0) {
349 sscanf(tbuffer, "checkbintime %d %d %d %d %d", &ktmask,
350 &ktday, &kthour, &ktmin, &ktsec);
355 /* otherwise we've read in the proper ktime structure; now assign
356 * it and continue processing */
357 bozo_nextDayKT.mask = ktmask; /* time to restart the system */
358 bozo_nextDayKT.day = ktday;
359 bozo_nextDayKT.hour = kthour;
360 bozo_nextDayKT.min = ktmin;
361 bozo_nextDayKT.sec = ktsec;
365 if (strncmp(tbuffer, "restrictmode", 12) == 0) {
366 code = sscanf(tbuffer, "restrictmode %d", &rmode);
371 if (rmode != 0 && rmode != 1) {
375 bozo_isrestricted = rmode;
379 if (strncmp("bnode", tbuffer, 5) != 0) {
385 sscanf(tbuffer, "bnode %s %s %d %s", typep, instp, &goal,
390 } else if (code == 3)
393 memset(thisparms, 0, sizeof(thisparms));
395 for (i = 0; i < MAXPARMS; i++) {
396 /* now read the parms, until we see an "end" line */
397 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
403 if (!strncmp(tbuffer, "end", 3))
405 if (strncmp(tbuffer, "parm ", 5)) {
407 goto fail; /* no "parm " either */
409 if (!parms[i]) /* make sure there's space */
410 parms[i] = (char *)malloc(BOZO_BSSIZE);
411 strcpy(parms[i], tbuffer + 5); /* remember the parameter for later */
412 thisparms[i] = parms[i];
415 /* ok, we have the type and parms, now create the object */
417 bnode_Create(typep, instp, &tb, thisparms[0], thisparms[1],
418 thisparms[2], thisparms[3], thisparms[4], notifier,
419 goal ? BSTAT_NORMAL : BSTAT_SHUTDOWN, 0);
423 /* bnode created in 'temporarily shutdown' state;
424 * check to see if we are supposed to run this guy,
425 * and if so, start the process up */
427 bnode_SetStat(tb, BSTAT_NORMAL); /* set goal, taking effect immediately */
429 bnode_SetStat(tb, BSTAT_SHUTDOWN);
440 for (i = 0; i < MAXPARMS; i++)
448 /* write a new bozo file */
450 WriteBozoFile(char *aname)
453 char tbuffer[AFSDIR_PATH_MAX];
458 aname = (char *)bozo_fileName;
459 strcpy(tbuffer, aname);
460 strcat(tbuffer, ".NBZ");
461 tfile = fopen(tbuffer, "w");
466 fprintf(tfile, "restrictmode %d\n", bozo_isrestricted);
467 fprintf(tfile, "restarttime %d %d %d %d %d\n", bozo_nextRestartKT.mask,
468 bozo_nextRestartKT.day, bozo_nextRestartKT.hour,
469 bozo_nextRestartKT.min, bozo_nextRestartKT.sec);
470 fprintf(tfile, "checkbintime %d %d %d %d %d\n", bozo_nextDayKT.mask,
471 bozo_nextDayKT.day, bozo_nextDayKT.hour, bozo_nextDayKT.min,
473 code = bnode_ApplyInstance(bzwrite, &btemp);
474 if (code || (code = ferror(tfile))) { /* something went wrong */
479 /* close the file, check for errors and snap new file into place */
480 if (fclose(tfile) == EOF) {
484 code = renamefile(tbuffer, aname);
493 bdrestart(struct bnode *abnode, void *arock)
497 if (abnode->fileGoal != BSTAT_NORMAL || abnode->goal != BSTAT_NORMAL)
498 return 0; /* don't restart stopped bnodes */
500 code = bnode_RestartP(abnode);
502 /* restart the dude */
503 bnode_SetStat(abnode, BSTAT_SHUTDOWN);
504 bnode_WaitStatus(abnode, BSTAT_SHUTDOWN);
505 bnode_SetStat(abnode, BSTAT_NORMAL);
507 bnode_Release(abnode);
508 return 0; /* keep trying all bnodes */
511 #define BOZO_MINSKIP 3600 /* minimum to advance clock */
512 /* lwp to handle system restarts */
514 BozoDaemon(void *unused)
518 /* now initialize the values */
522 now = FT_ApproxTime();
524 if (bozo_restdisable) {
525 bozo_Log("Restricted mode disabled by signal\n");
526 bozo_restdisable = 0;
529 if (bozo_newKTs) { /* need to recompute restart times */
530 bozo_newKTs = 0; /* done for a while */
531 nextRestart = ktime_next(&bozo_nextRestartKT, BOZO_MINSKIP);
532 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
535 /* see if we should do a restart */
536 if (now > nextRestart) {
537 SBOZO_ReBozo(0); /* doesn't come back */
540 /* see if we should restart a server */
542 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
544 /* call the bnode restartp function, and restart all that require it */
545 bnode_ApplyInstance(bdrestart, 0);
557 int s, sb_max, ipfragttl;
561 f = popen("/usr/sbin/no -o sb_max", "r");
562 s = fscanf(f, "sb_max = %d", &sb_max);
566 f = popen("/usr/sbin/no -o ipfragttl", "r");
567 s = fscanf(f, "ipfragttl = %d", &ipfragttl);
577 sprintf(c, "/usr/sbin/no -o sb_max=%d -o ipfragttl=%d", sb_max,
586 * This routine causes the calling process to go into the background and
587 * to lose its controlling tty.
589 * It does not close or otherwise alter the standard file descriptors.
591 * It writes warning messages to the standard error output if certain
592 * fundamental errors occur.
594 * This routine requires
596 * #include <sys/types.h>
597 * #include <sys/stat.h>
599 * #include <unistd.h>
600 * #include <stdlib.h>
602 * and has been tested on:
618 * A process is a process group leader if its process ID
619 * (getpid()) and its process group ID (getpgrp()) are the same.
623 * To create a new session (and thereby lose our controlling
624 * terminal) we cannot be a process group leader.
626 * To guarantee we are not a process group leader, we fork and
627 * let the parent process exit.
630 if (getpid() == getpgrp()) {
635 abort(); /* leave footprints */
639 default: /* parent */
646 * By here, we are not a process group leader, so we can make a
647 * new session and become the session leader.
651 pid_t sid = setsid();
654 static char err[] = "bosserver: WARNING: setsid() failed\n";
655 write(STDERR_FILENO, err, sizeof err - 1);
660 * Once we create a new session, the current process is a
661 * session leader without a controlling tty.
663 * On some systems, the first tty device the session leader
664 * opens automatically becomes the controlling tty for the
667 * So, to guarantee we do not acquire a controlling tty, we fork
668 * and let the parent process exit. The child process is not a
669 * session leader, and so it will not acquire a controlling tty
670 * even if it should happen to open a tty device.
673 if (getpid() == getpgrp()) {
678 abort(); /* leave footprints */
682 default: /* parent */
689 * check that we no longer have a controlling tty
695 fd = open("/dev/tty", O_RDONLY);
699 "bosserver: WARNING: /dev/tty still attached\n";
701 write(STDERR_FILENO, err, sizeof err - 1);
705 #endif /* ! AFS_NT40_ENV */
708 /* start a process and monitor it */
710 #include "AFS_component_version_number.c"
713 main(int argc, char **argv, char **envp)
715 struct rx_service *tservice;
717 struct afsconf_dir *tdir;
720 char namebuf[AFSDIR_PATH_MAX];
722 afs_uint32 host = htonl(INADDR_ANY);
723 char *auditFileName = NULL;
724 struct rx_securityClass **securityClasses;
725 afs_int32 numClasses;
731 struct sigaction nsa;
733 /* for some reason, this permits user-mode RX to run a lot faster.
734 * we do it here in the bosserver, so we don't have to do it
735 * individually in each server.
740 * The following signal action for AIX is necessary so that in case of a
741 * crash (i.e. core is generated) we can include the user's data section
742 * in the core dump. Unfortunately, by default, only a partial core is
743 * generated which, in many cases, isn't too useful.
745 sigemptyset(&nsa.sa_mask);
746 nsa.sa_handler = SIG_DFL;
747 nsa.sa_flags = SA_FULLDUMP;
748 sigaction(SIGSEGV, &nsa, NULL);
749 sigaction(SIGABRT, &nsa, NULL);
752 signal(SIGFPE, bozo_insecureme);
755 /* Initialize winsock */
756 if (afs_winsockInit() < 0) {
757 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
758 fprintf(stderr, "%s: Couldn't initialize winsock.\n", argv[0]);
763 /* Initialize dirpaths */
764 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
766 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
768 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
773 /* some path inits */
774 bozo_fileName = AFSDIR_SERVER_BOZCONF_FILEPATH;
775 DoCore = AFSDIR_SERVER_LOGS_DIRPATH;
777 /* initialize the list of dirpaths that the bosserver has
778 * an interest in monitoring */
781 #if defined(AFS_SGI_ENV)
782 /* offer some protection if AFS isn't loaded */
783 if (syscall(AFS_SYSCALL, AFSOP_ENDLOG) < 0 && errno == ENOPKG) {
784 printf("bosserver: AFS doesn't appear to be configured in O.S..\n");
790 for (code = 1; code < argc; code++) {
791 if (strcmp(argv[code], "-noauth") == 0) {
792 /* set noauth flag */
794 } else if (strcmp(argv[code], "-log") == 0) {
795 /* set extra logging flag */
799 else if (strcmp(argv[code], "-syslog") == 0) {
800 /* set syslog logging flag */
802 } else if (strncmp(argv[code], "-syslog=", 8) == 0) {
804 DoSyslogFacility = atoi(argv[code] + 8);
805 } else if (strncmp(argv[code], "-cores=", 7) == 0) {
806 if (strcmp((argv[code]+7), "none") == 0)
809 DoCore = (argv[code]+7);
810 } else if (strcmp(argv[code], "-nofork") == 0) {
814 else if (strcmp(argv[code], "-enable_peer_stats") == 0) {
815 rx_enablePeerRPCStats();
816 } else if (strcmp(argv[code], "-enable_process_stats") == 0) {
817 rx_enableProcessRPCStats();
819 else if (strcmp(argv[code], "-restricted") == 0) {
820 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-%" AFS_SIZET_FMT "\n",
837 rxMaxMTU, RX_MIN_PACKET_SIZE,
838 RX_MAX_PACKET_DATA_SIZE);
842 else if (strcmp(argv[code], "-auditlog") == 0) {
843 auditFileName = argv[++code];
845 } else if (strcmp(argv[code], "-audit-interface") == 0) {
846 char *interface = argv[++code];
848 if (osi_audit_interface(interface)) {
849 printf("Invalid audit interface '%s'\n", interface);
855 /* hack to support help flag */
858 printf("Usage: bosserver [-noauth] [-log] "
859 "[-auditlog <log path>] "
860 "[-audit-interafce <file|sysvmq> (default is file)] "
861 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
862 "[-syslog[=FACILITY]] "
863 "[-enable_peer_stats] [-enable_process_stats] "
864 "[-cores=<none|path>] \n"
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] "
872 "[-cores=<none|path>] \n"
881 osi_audit_file(auditFileName);
885 if (geteuid() != 0) {
886 printf("bosserver: must be run as root.\n");
893 printf("bosserver: could not init bnode package, code %d\n", code);
897 bnode_Register("fs", &fsbnode_ops, 3);
898 bnode_Register("dafs", &dafsbnode_ops, 4);
899 bnode_Register("simple", &ezbnode_ops, 1);
900 bnode_Register("cron", &cronbnode_ops, 2);
902 /* create useful dirs */
905 /* chdir to AFS log directory */
909 chdir(AFSDIR_SERVER_LOGS_DIRPATH);
912 fputs(AFS_GOVERNMENT_MESSAGE, stdout);
916 /* go into the background and remove our controlling tty, close open
923 #endif /* ! AFS_NT40_ENV */
927 && ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) &&
928 !(S_ISFIFO(sb.st_mode)))
931 strcpy(namebuf, AFSDIR_BOZLOG_FILE);
932 strcat(namebuf, ".old");
933 renamefile(AFSDIR_BOZLOG_FILE, namebuf); /* try rename first */
934 bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a");
936 printf("bosserver: can't initialize log file (%s).\n",
937 AFSDIR_SERVER_BOZLOG_FILEPATH);
940 /* keep log closed normally, so can be removed */
941 fclose(bozo_logFile);
944 openlog("bosserver", LOG_PID, DoSyslogFacility);
948 #if defined(RLIMIT_CORE) && defined(HAVE_GETRLIMIT)
951 getrlimit(RLIMIT_CORE, &rlp);
955 rlp.rlim_max = rlp.rlim_cur = RLIM_INFINITY;
956 setrlimit(RLIMIT_CORE, &rlp);
957 getrlimit(RLIMIT_CORE, &rlp);
958 bozo_Log("Core limits now %d %d\n",(int)rlp.rlim_cur,(int)rlp.rlim_max);
962 /* Write current state of directory permissions to log file */
967 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
968 AFSDIR_SERVER_NETINFO_FILEPATH) {
970 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
971 ADDRSPERSITE, reason,
972 AFSDIR_SERVER_NETINFO_FILEPATH,
973 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
975 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
978 host = SHostAddrs[0];
981 for (i = 0; i < 10; i++) {
983 code = rx_InitHost(host, htons(AFSCONF_NANNYPORT));
985 code = rx_Init(htons(AFSCONF_NANNYPORT));
988 bozo_Log("can't initialize rx: code=%d\n", code);
994 bozo_Log("Bos giving up, can't initialize rx\n");
998 code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
999 /* param */ NULL , "bozo-the-clown",
1002 /* try to read the key from the config file */
1003 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1005 /* try to create local cell config file */
1006 struct afsconf_cell tcell;
1007 strcpy(tcell.name, "localcell");
1008 tcell.numServers = 1;
1009 code = gethostname(tcell.hostName[0], MAXHOSTCHARS);
1011 bozo_Log("failed to get hostname, code %d\n", errno);
1014 if (tcell.hostName[0][0] == 0) {
1015 bozo_Log("host name not set, can't start\n");
1016 bozo_Log("try the 'hostname' command\n");
1019 memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */
1021 afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH,
1025 ("could not create cell database in '%s' (code %d), quitting\n",
1026 AFSDIR_SERVER_ETC_DIRPATH, code);
1029 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1032 ("failed to open newly-created cell database, quitting\n");
1037 /* read init file, starting up programs */
1038 if ((code = ReadBozoFile(0))) {
1040 ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
1041 code, AFSDIR_SERVER_BOZCONF_FILEPATH);
1045 /* opened the cell databse */
1046 bozo_confdir = tdir;
1048 /* allow super users to manage RX statistics */
1049 rx_SetRxStatUserOk(bozo_rxstat_userok);
1051 afsconf_SetNoAuthFlag(tdir, noAuth);
1052 afsconf_BuildServerSecurityObjects(tdir, &securityClasses, &numClasses);
1054 /* Disable jumbograms */
1057 if (rxMaxMTU != -1) {
1058 rx_SetMaxMTU(rxMaxMTU);
1061 tservice = rx_NewServiceHost(host, 0, /* service id */ 1,
1062 "bozo", securityClasses, numClasses,
1063 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",
1074 securityClasses, numClasses, 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);