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 #include <afs/procmgmt.h>
16 #ifdef IGNORE_SOME_GCC_WARNINGS
17 # pragma GCC diagnostic warning "-Wdeprecated-declarations"
21 #include <sys/types.h>
29 #ifdef HAVE_SYS_TIME_H
32 #ifdef HAVE_SYS_RESOURCE_H
33 #include <sys/resource.h>
39 #include <WINNT/afsevent.h>
42 #include <netinet/in.h>
44 #endif /* AFS_NT40_ENV */
45 #include <afs/cellconfig.h>
48 #include <rx/rx_globals.h>
51 #include "bosprototypes.h"
53 #include <rx/rxstat.h>
55 #include <afs/ktime.h>
56 #include <afs/afsutil.h>
57 #include <afs/fileutil.h>
58 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
59 #include <afs/audit.h>
60 #include <afs/cellconfig.h>
61 #if defined(AFS_SGI_ENV)
62 #include <afs/afs_args.h>
65 #define BOZO_LWP_STACKSIZE 16000
66 extern struct bnode_ops fsbnode_ops, dafsbnode_ops, ezbnode_ops, cronbnode_ops;
68 struct afsconf_dir *bozo_confdir = 0; /* bozo configuration dir */
69 static PROCESS bozo_pid;
70 const char *bozo_fileName;
77 int DoSyslogFacility = LOG_DAEMON;
79 static afs_int32 nextRestart;
80 static afs_int32 nextDay;
82 struct ktime bozo_nextRestartKT, bozo_nextDayKT;
85 int rxkadDisableDotCheck = 0;
87 #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
88 afs_uint32 SHostAddrs[ADDRSPERSITE];
90 int bozo_isrestricted = 0;
91 int bozo_restdisable = 0;
94 bozo_insecureme(int sig)
96 signal(SIGFPE, bozo_insecureme);
97 bozo_isrestricted = 0;
105 /* check whether caller is authorized to manage RX statistics */
107 bozo_rxstat_userok(struct rx_call *call)
109 return afsconf_SuperUser(bozo_confdir, call, NULL);
112 /* restart bozo process */
117 /* exit with restart code; SCM integrator process will restart bosserver */
118 int status = BOSEXIT_RESTART;
120 /* if noauth flag is set, pass "-noauth" to new bosserver */
121 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
122 status |= BOSEXIT_NOAUTH_FLAG;
124 /* if logging is on, pass "-log" to new bosserver */
126 status |= BOSEXIT_LOGGING_FLAG;
130 /* exec new bosserver process */
134 argv[i] = (char *)AFSDIR_SERVER_BOSVR_FILEPATH;
137 /* if noauth flag is set, pass "-noauth" to new bosserver */
138 if (afsconf_GetNoAuthFlag(bozo_confdir)) {
142 /* if logging is on, pass "-log" to new bosserver */
148 /* if syslog logging is on, pass "-syslog" to new bosserver */
150 char *arg = (char *)malloc(40); /* enough for -syslog=# */
151 if (DoSyslogFacility != LOG_DAEMON) {
152 snprintf(arg, 40, "-syslog=%d", DoSyslogFacility);
154 strcpy(arg, "-syslog");
161 /* null-terminate argument list */
164 /* close random fd's */
165 for (i = 3; i < 64; i++) {
169 execv(argv[0], argv); /* should not return */
171 #endif /* AFS_NT40_ENV */
174 /* make sure a dir exists */
176 MakeDir(const char *adir)
180 if (stat(adir, &tstat) < 0 || (tstat.st_mode & S_IFMT) != S_IFDIR) {
183 reqPerm = GetRequiredDirPerm(adir);
187 /* underlying filesystem may not support directory protection */
190 code = mkdir(adir, reqPerm);
197 /* create all the bozo dirs */
199 CreateDirs(const char *coredir)
202 (AFSDIR_USR_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
203 strlen(AFSDIR_USR_DIRPATH)))
206 (AFSDIR_USR_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
207 strlen(AFSDIR_USR_DIRPATH)))) {
208 MakeDir(AFSDIR_USR_DIRPATH);
211 (AFSDIR_SERVER_AFS_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH,
212 strlen(AFSDIR_SERVER_AFS_DIRPATH))) {
213 MakeDir(AFSDIR_SERVER_AFS_DIRPATH);
215 MakeDir(AFSDIR_SERVER_BIN_DIRPATH);
216 MakeDir(AFSDIR_SERVER_ETC_DIRPATH);
217 MakeDir(AFSDIR_SERVER_LOCAL_DIRPATH);
218 MakeDir(AFSDIR_SERVER_DB_DIRPATH);
219 MakeDir(AFSDIR_SERVER_LOGS_DIRPATH);
222 (AFSDIR_CLIENT_VICE_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH,
223 strlen(AFSDIR_CLIENT_VICE_DIRPATH))) {
224 MakeDir(AFSDIR_CLIENT_VICE_DIRPATH);
226 MakeDir(AFSDIR_CLIENT_ETC_DIRPATH);
228 symlink(AFSDIR_SERVER_THISCELL_FILEPATH, AFSDIR_CLIENT_THISCELL_FILEPATH);
229 symlink(AFSDIR_SERVER_CELLSERVDB_FILEPATH,
230 AFSDIR_CLIENT_CELLSERVDB_FILEPATH);
231 #endif /* AFS_NT40_ENV */
237 /* strip the \\n from the end of the line, if it is present */
239 StripLine(char *abuffer)
243 tp = abuffer + strlen(abuffer); /* starts off pointing at the null */
245 return 0; /* null string, no last character to check */
246 tp--; /* aim at last character */
252 /* write one bnode's worth of entry into the file */
254 bzwrite(struct bnode *abnode, void *arock)
256 struct bztemp *at = (struct bztemp *)arock;
258 char tbuffer[BOZO_BSSIZE];
261 if (abnode->notifier)
262 fprintf(at->file, "bnode %s %s %d %s\n", abnode->type->name,
263 abnode->name, abnode->fileGoal, abnode->notifier);
265 fprintf(at->file, "bnode %s %s %d\n", abnode->type->name,
266 abnode->name, abnode->fileGoal);
268 code = bnode_GetParm(abnode, i, tbuffer, BOZO_BSSIZE);
274 fprintf(at->file, "parm %s\n", tbuffer);
276 fprintf(at->file, "end\n");
282 ReadBozoFile(char *aname)
285 char tbuffer[BOZO_BSSIZE];
287 char *instp, *typep, *notifier, *notp;
289 afs_int32 ktmask, ktday, kthour, ktmin, ktsec;
292 char *parms[MAXPARMS];
293 char *thisparms[MAXPARMS];
296 /* rename BozoInit to BosServer for the user */
298 /* if BozoInit exists and BosConfig doesn't, try a rename */
299 if (access(AFSDIR_SERVER_BOZINIT_FILEPATH, 0) == 0
300 && access(AFSDIR_SERVER_BOZCONF_FILEPATH, 0) != 0) {
302 renamefile(AFSDIR_SERVER_BOZINIT_FILEPATH,
303 AFSDIR_SERVER_BOZCONF_FILEPATH);
305 perror("bosconfig rename");
307 if (access(AFSDIR_SERVER_BOZCONFNEW_FILEPATH, 0) == 0) {
309 renamefile(AFSDIR_SERVER_BOZCONFNEW_FILEPATH,
310 AFSDIR_SERVER_BOZCONF_FILEPATH);
312 perror("bosconfig rename");
316 /* don't do server restarts by default */
317 bozo_nextRestartKT.mask = KTIME_NEVER;
318 bozo_nextRestartKT.hour = 0;
319 bozo_nextRestartKT.min = 0;
320 bozo_nextRestartKT.day = 0;
322 /* restart processes at 5am if their binaries have changed */
323 bozo_nextDayKT.mask = KTIME_HOUR | KTIME_MIN;
324 bozo_nextDayKT.hour = 5;
325 bozo_nextDayKT.min = 0;
327 for (code = 0; code < MAXPARMS; code++)
329 instp = typep = notifier = NULL;
332 aname = (char *)bozo_fileName;
333 tfile = fopen(aname, "r");
336 instp = (char *)malloc(BOZO_BSSIZE);
337 typep = (char *)malloc(BOZO_BSSIZE);
338 notifier = notp = (char *)malloc(BOZO_BSSIZE);
340 /* ok, read lines giving parms and such from the file */
341 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
343 break; /* all done */
345 if (strncmp(tbuffer, "restarttime", 11) == 0) {
347 sscanf(tbuffer, "restarttime %d %d %d %d %d", &ktmask, &ktday,
348 &kthour, &ktmin, &ktsec);
353 /* otherwise we've read in the proper ktime structure; now assign
354 * it and continue processing */
355 bozo_nextRestartKT.mask = ktmask;
356 bozo_nextRestartKT.day = ktday;
357 bozo_nextRestartKT.hour = kthour;
358 bozo_nextRestartKT.min = ktmin;
359 bozo_nextRestartKT.sec = ktsec;
363 if (strncmp(tbuffer, "checkbintime", 12) == 0) {
365 sscanf(tbuffer, "checkbintime %d %d %d %d %d", &ktmask,
366 &ktday, &kthour, &ktmin, &ktsec);
371 /* otherwise we've read in the proper ktime structure; now assign
372 * it and continue processing */
373 bozo_nextDayKT.mask = ktmask; /* time to restart the system */
374 bozo_nextDayKT.day = ktday;
375 bozo_nextDayKT.hour = kthour;
376 bozo_nextDayKT.min = ktmin;
377 bozo_nextDayKT.sec = ktsec;
381 if (strncmp(tbuffer, "restrictmode", 12) == 0) {
382 code = sscanf(tbuffer, "restrictmode %d", &rmode);
387 if (rmode != 0 && rmode != 1) {
391 bozo_isrestricted = rmode;
395 if (strncmp("bnode", tbuffer, 5) != 0) {
401 sscanf(tbuffer, "bnode %s %s %d %s", typep, instp, &goal,
406 } else if (code == 3)
409 memset(thisparms, 0, sizeof(thisparms));
411 for (i = 0; i < MAXPARMS; i++) {
412 /* now read the parms, until we see an "end" line */
413 tp = fgets(tbuffer, sizeof(tbuffer), tfile);
419 if (!strncmp(tbuffer, "end", 3))
421 if (strncmp(tbuffer, "parm ", 5)) {
423 goto fail; /* no "parm " either */
425 if (!parms[i]) /* make sure there's space */
426 parms[i] = (char *)malloc(BOZO_BSSIZE);
427 strcpy(parms[i], tbuffer + 5); /* remember the parameter for later */
428 thisparms[i] = parms[i];
431 /* ok, we have the type and parms, now create the object */
433 bnode_Create(typep, instp, &tb, thisparms[0], thisparms[1],
434 thisparms[2], thisparms[3], thisparms[4], notifier,
435 goal ? BSTAT_NORMAL : BSTAT_SHUTDOWN, 0);
439 /* bnode created in 'temporarily shutdown' state;
440 * check to see if we are supposed to run this guy,
441 * and if so, start the process up */
443 bnode_SetStat(tb, BSTAT_NORMAL); /* set goal, taking effect immediately */
445 bnode_SetStat(tb, BSTAT_SHUTDOWN);
456 for (i = 0; i < MAXPARMS; i++)
464 /* write a new bozo file */
466 WriteBozoFile(char *aname)
469 char tbuffer[AFSDIR_PATH_MAX];
474 aname = (char *)bozo_fileName;
475 strcpy(tbuffer, aname);
476 strcat(tbuffer, ".NBZ");
477 tfile = fopen(tbuffer, "w");
482 fprintf(tfile, "restrictmode %d\n", bozo_isrestricted);
483 fprintf(tfile, "restarttime %d %d %d %d %d\n", bozo_nextRestartKT.mask,
484 bozo_nextRestartKT.day, bozo_nextRestartKT.hour,
485 bozo_nextRestartKT.min, bozo_nextRestartKT.sec);
486 fprintf(tfile, "checkbintime %d %d %d %d %d\n", bozo_nextDayKT.mask,
487 bozo_nextDayKT.day, bozo_nextDayKT.hour, bozo_nextDayKT.min,
489 code = bnode_ApplyInstance(bzwrite, &btemp);
490 if (code || (code = ferror(tfile))) { /* something went wrong */
495 /* close the file, check for errors and snap new file into place */
496 if (fclose(tfile) == EOF) {
500 code = renamefile(tbuffer, aname);
509 bdrestart(struct bnode *abnode, void *arock)
513 if (abnode->fileGoal != BSTAT_NORMAL || abnode->goal != BSTAT_NORMAL)
514 return 0; /* don't restart stopped bnodes */
516 code = bnode_RestartP(abnode);
518 /* restart the dude */
519 bnode_SetStat(abnode, BSTAT_SHUTDOWN);
520 bnode_WaitStatus(abnode, BSTAT_SHUTDOWN);
521 bnode_SetStat(abnode, BSTAT_NORMAL);
523 bnode_Release(abnode);
524 return 0; /* keep trying all bnodes */
527 #define BOZO_MINSKIP 3600 /* minimum to advance clock */
528 /* lwp to handle system restarts */
530 BozoDaemon(void *unused)
534 /* now initialize the values */
538 now = FT_ApproxTime();
540 if (bozo_restdisable) {
541 bozo_Log("Restricted mode disabled by signal\n");
542 bozo_restdisable = 0;
545 if (bozo_newKTs) { /* need to recompute restart times */
546 bozo_newKTs = 0; /* done for a while */
547 nextRestart = ktime_next(&bozo_nextRestartKT, BOZO_MINSKIP);
548 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
551 /* see if we should do a restart */
552 if (now > nextRestart) {
553 SBOZO_ReBozo(0); /* doesn't come back */
556 /* see if we should restart a server */
558 nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP);
560 /* call the bnode restartp function, and restart all that require it */
561 bnode_ApplyInstance(bdrestart, 0);
573 int s, sb_max, ipfragttl;
577 f = popen("/usr/sbin/no -o sb_max", "r");
578 s = fscanf(f, "sb_max = %d", &sb_max);
582 f = popen("/usr/sbin/no -o ipfragttl", "r");
583 s = fscanf(f, "ipfragttl = %d", &ipfragttl);
593 sprintf(c, "/usr/sbin/no -o sb_max=%d -o ipfragttl=%d", sb_max,
602 * This routine causes the calling process to go into the background and
603 * to lose its controlling tty.
605 * It does not close or otherwise alter the standard file descriptors.
607 * It writes warning messages to the standard error output if certain
608 * fundamental errors occur.
610 * This routine requires
612 * #include <sys/types.h>
613 * #include <sys/stat.h>
615 * #include <unistd.h>
616 * #include <stdlib.h>
618 * and has been tested on:
634 * A process is a process group leader if its process ID
635 * (getpid()) and its process group ID (getpgrp()) are the same.
639 * To create a new session (and thereby lose our controlling
640 * terminal) we cannot be a process group leader.
642 * To guarantee we are not a process group leader, we fork and
643 * let the parent process exit.
646 if (getpid() == getpgrp()) {
651 abort(); /* leave footprints */
655 default: /* parent */
662 * By here, we are not a process group leader, so we can make a
663 * new session and become the session leader.
667 pid_t sid = setsid();
670 static char err[] = "bosserver: WARNING: setsid() failed\n";
671 write(STDERR_FILENO, err, sizeof err - 1);
676 * Once we create a new session, the current process is a
677 * session leader without a controlling tty.
679 * On some systems, the first tty device the session leader
680 * opens automatically becomes the controlling tty for the
683 * So, to guarantee we do not acquire a controlling tty, we fork
684 * and let the parent process exit. The child process is not a
685 * session leader, and so it will not acquire a controlling tty
686 * even if it should happen to open a tty device.
689 if (getpid() == getpgrp()) {
694 abort(); /* leave footprints */
698 default: /* parent */
705 * check that we no longer have a controlling tty
711 fd = open("/dev/tty", O_RDONLY);
715 "bosserver: WARNING: /dev/tty still attached\n";
717 write(STDERR_FILENO, err, sizeof err - 1);
721 #endif /* ! AFS_NT40_ENV */
724 /* start a process and monitor it */
726 #include "AFS_component_version_number.c"
729 main(int argc, char **argv, char **envp)
731 struct rx_service *tservice;
733 struct afsconf_dir *tdir;
736 char namebuf[AFSDIR_PATH_MAX];
738 afs_uint32 host = htonl(INADDR_ANY);
739 char *auditFileName = NULL;
740 struct rx_securityClass **securityClasses;
741 afs_int32 numClasses;
747 struct sigaction nsa;
749 /* for some reason, this permits user-mode RX to run a lot faster.
750 * we do it here in the bosserver, so we don't have to do it
751 * individually in each server.
756 * The following signal action for AIX is necessary so that in case of a
757 * crash (i.e. core is generated) we can include the user's data section
758 * in the core dump. Unfortunately, by default, only a partial core is
759 * generated which, in many cases, isn't too useful.
761 sigemptyset(&nsa.sa_mask);
762 nsa.sa_handler = SIG_DFL;
763 nsa.sa_flags = SA_FULLDUMP;
764 sigaction(SIGSEGV, &nsa, NULL);
765 sigaction(SIGABRT, &nsa, NULL);
768 signal(SIGFPE, bozo_insecureme);
771 /* Initialize winsock */
772 if (afs_winsockInit() < 0) {
773 ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
774 fprintf(stderr, "%s: Couldn't initialize winsock.\n", argv[0]);
779 /* Initialize dirpaths */
780 if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
782 ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0);
784 fprintf(stderr, "%s: Unable to obtain AFS server directory.\n",
789 /* some path inits */
790 bozo_fileName = AFSDIR_SERVER_BOZCONF_FILEPATH;
791 DoCore = AFSDIR_SERVER_LOGS_DIRPATH;
793 /* initialize the list of dirpaths that the bosserver has
794 * an interest in monitoring */
797 #if defined(AFS_SGI_ENV)
798 /* offer some protection if AFS isn't loaded */
799 if (syscall(AFS_SYSCALL, AFSOP_ENDLOG) < 0 && errno == ENOPKG) {
800 printf("bosserver: AFS doesn't appear to be configured in O.S..\n");
806 for (code = 1; code < argc; code++) {
807 if (strcmp(argv[code], "-noauth") == 0) {
808 /* set noauth flag */
810 } else if (strcmp(argv[code], "-log") == 0) {
811 /* set extra logging flag */
815 else if (strcmp(argv[code], "-syslog") == 0) {
816 /* set syslog logging flag */
818 } else if (strncmp(argv[code], "-syslog=", 8) == 0) {
820 DoSyslogFacility = atoi(argv[code] + 8);
821 } else if (strncmp(argv[code], "-cores=", 7) == 0) {
822 if (strcmp((argv[code]+7), "none") == 0)
825 DoCore = (argv[code]+7);
826 } else if (strcmp(argv[code], "-nofork") == 0) {
830 else if (strcmp(argv[code], "-enable_peer_stats") == 0) {
831 rx_enablePeerRPCStats();
832 } else if (strcmp(argv[code], "-enable_process_stats") == 0) {
833 rx_enableProcessRPCStats();
835 else if (strcmp(argv[code], "-restricted") == 0) {
836 bozo_isrestricted = 1;
838 else if (strcmp(argv[code], "-rxbind") == 0) {
841 else if (strcmp(argv[code], "-allow-dotted-principals") == 0) {
842 rxkadDisableDotCheck = 1;
844 else if (!strcmp(argv[code], "-rxmaxmtu")) {
845 if ((code + 1) >= argc) {
846 fprintf(stderr, "missing argument for -rxmaxmtu\n");
849 rxMaxMTU = atoi(argv[++code]);
850 if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
851 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
852 printf("rxMaxMTU %d invalid; must be between %d-%" AFS_SIZET_FMT "\n",
853 rxMaxMTU, RX_MIN_PACKET_SIZE,
854 RX_MAX_PACKET_DATA_SIZE);
858 else if (strcmp(argv[code], "-auditlog") == 0) {
859 auditFileName = argv[++code];
861 } else if (strcmp(argv[code], "-audit-interface") == 0) {
862 char *interface = argv[++code];
864 if (osi_audit_interface(interface)) {
865 printf("Invalid audit interface '%s'\n", interface);
871 /* hack to support help flag */
874 printf("Usage: bosserver [-noauth] [-log] "
875 "[-auditlog <log path>] "
876 "[-audit-interafce <file|sysvmq> (default is file)] "
877 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
878 "[-syslog[=FACILITY]] "
879 "[-enable_peer_stats] [-enable_process_stats] "
880 "[-cores=<none|path>] \n"
881 "[-nofork] " "[-help]\n");
883 printf("Usage: bosserver [-noauth] [-log] "
884 "[-auditlog <log path>] "
885 "[-audit-interafce <file|sysvmq> (default is file)] "
886 "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals]"
887 "[-enable_peer_stats] [-enable_process_stats] "
888 "[-cores=<none|path>] \n"
897 osi_audit_file(auditFileName);
901 if (geteuid() != 0) {
902 printf("bosserver: must be run as root.\n");
909 printf("bosserver: could not init bnode package, code %d\n", code);
913 bnode_Register("fs", &fsbnode_ops, 3);
914 bnode_Register("dafs", &dafsbnode_ops, 4);
915 bnode_Register("simple", &ezbnode_ops, 1);
916 bnode_Register("cron", &cronbnode_ops, 2);
918 /* create useful dirs */
921 /* chdir to AFS log directory */
925 chdir(AFSDIR_SERVER_LOGS_DIRPATH);
928 fputs(AFS_GOVERNMENT_MESSAGE, stdout);
932 /* go into the background and remove our controlling tty, close open
939 #endif /* ! AFS_NT40_ENV */
943 && ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) &&
944 !(S_ISFIFO(sb.st_mode)))
947 strcpy(namebuf, AFSDIR_BOZLOG_FILE);
948 strcat(namebuf, ".old");
949 renamefile(AFSDIR_BOZLOG_FILE, namebuf); /* try rename first */
950 bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a");
952 printf("bosserver: can't initialize log file (%s).\n",
953 AFSDIR_SERVER_BOZLOG_FILEPATH);
956 /* keep log closed normally, so can be removed */
957 fclose(bozo_logFile);
960 openlog("bosserver", LOG_PID, DoSyslogFacility);
964 #if defined(RLIMIT_CORE) && defined(HAVE_GETRLIMIT)
967 getrlimit(RLIMIT_CORE, &rlp);
971 rlp.rlim_max = rlp.rlim_cur = RLIM_INFINITY;
972 setrlimit(RLIMIT_CORE, &rlp);
973 getrlimit(RLIMIT_CORE, &rlp);
974 bozo_Log("Core limits now %d %d\n",(int)rlp.rlim_cur,(int)rlp.rlim_max);
978 /* Write current state of directory permissions to log file */
981 for (i = 0; i < 10; i++) {
982 code = rx_Init(htons(AFSCONF_NANNYPORT));
984 bozo_Log("can't initialize rx: code=%d\n", code);
990 bozo_Log("Bos giving up, can't initialize rx\n");
994 code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
995 /* param */ NULL , "bozo-the-clown",
998 /* try to read the key from the config file */
999 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1001 /* try to create local cell config file */
1002 struct afsconf_cell tcell;
1003 strcpy(tcell.name, "localcell");
1004 tcell.numServers = 1;
1005 code = gethostname(tcell.hostName[0], MAXHOSTCHARS);
1007 bozo_Log("failed to get hostname, code %d\n", errno);
1010 if (tcell.hostName[0][0] == 0) {
1011 bozo_Log("host name not set, can't start\n");
1012 bozo_Log("try the 'hostname' command\n");
1015 memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */
1017 afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH,
1021 ("could not create cell database in '%s' (code %d), quitting\n",
1022 AFSDIR_SERVER_ETC_DIRPATH, code);
1025 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
1028 ("failed to open newly-created cell database, quitting\n");
1033 /* read init file, starting up programs */
1034 if ((code = ReadBozoFile(0))) {
1036 ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
1037 code, AFSDIR_SERVER_BOZCONF_FILEPATH);
1041 /* opened the cell databse */
1042 bozo_confdir = tdir;
1044 /* allow super users to manage RX statistics */
1045 rx_SetRxStatUserOk(bozo_rxstat_userok);
1047 afsconf_SetNoAuthFlag(tdir, noAuth);
1048 afsconf_BuildServerSecurityObjects(tdir, 0, &securityClasses, &numClasses);
1050 /* Disable jumbograms */
1053 if (rxMaxMTU != -1) {
1054 rx_SetMaxMTU(rxMaxMTU);
1059 if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
1060 AFSDIR_SERVER_NETINFO_FILEPATH) {
1062 ccode = parseNetFiles(SHostAddrs, NULL, NULL,
1063 ADDRSPERSITE, reason,
1064 AFSDIR_SERVER_NETINFO_FILEPATH,
1065 AFSDIR_SERVER_NETRESTRICT_FILEPATH);
1068 ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
1071 host = SHostAddrs[0];
1074 tservice = rx_NewServiceHost(host, 0, /* service id */ 1,
1075 "bozo", securityClasses, numClasses,
1076 BOZO_ExecuteRequest);
1077 rx_SetMinProcs(tservice, 2);
1078 rx_SetMaxProcs(tservice, 4);
1079 rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE); /* so gethostbyname works (in cell stuff) */
1080 if (rxkadDisableDotCheck) {
1081 rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
1082 (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
1086 rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats",
1087 securityClasses, numClasses, RXSTATS_ExecuteRequest);
1088 rx_SetMinProcs(tservice, 2);
1089 rx_SetMaxProcs(tservice, 4);
1090 rx_StartServer(1); /* donate this process */
1095 bozo_Log(char *format, ...)
1101 va_start(ap, format);
1104 #ifndef AFS_NT40_ENV
1105 vsyslog(LOG_INFO, format, ap);
1109 strcpy(tdate, ctime(&myTime)); /* copy out of static area asap */
1112 /* log normally closed, so can be removed */
1114 bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a");
1115 if (bozo_logFile == NULL) {
1116 printf("bosserver: WARNING: problem with %s\n",
1117 AFSDIR_SERVER_BOZLOG_FILEPATH);
1118 printf("%s ", tdate);
1119 vprintf(format, ap);
1122 fprintf(bozo_logFile, "%s ", tdate);
1123 vfprintf(bozo_logFile, format, ap);
1125 /* close so rm BosLog works */
1126 fclose(bozo_logFile);