static char * make_pid_filename(char *ainst, char *aname) { char *buffer = NULL; int length; length = strlen(DoPidFiles) + strlen(ainst) + 6; if (aname && *aname) { length += strlen(aname) + 1; } buffer = malloc(length * sizeof(char)); if (!buffer) { if (aname) { bozo_Log("Failed to alloc pid filename buffer for %s.%s.\n", ainst, aname); } else { bozo_Log("Failed to alloc pid filename buffer for %s.\n", ainst); } } else { if (aname && *aname) { snprintf(buffer, length, "%s/%s.%s.pid", DoPidFiles, ainst, aname); } else { snprintf(buffer, length, "%s/%s.pid", DoPidFiles, ainst); } } return buffer; }
afs_int32 bnode_Create(char *atype, char *ainstance, struct bnode ** abp, char *ap1, char *ap2, char *ap3, char *ap4, char *ap5, char *notifier, int fileGoal, int rewritefile) { struct bnode_type *type; struct bnode *tb; char *notifierpath = NULL; struct stat tstat; if (bnode_FindInstance(ainstance)) return BZEXISTS; type = FindType(atype); if (!type) return BZBADTYPE; if (notifier && strcmp(notifier, NONOTIFIER)) { /* construct local path from canonical (wire-format) path */ if (ConstructLocalBinPath(notifier, ¬ifierpath)) { bozo_Log("BNODE-Create: Notifier program path invalid '%s'\n", notifier); return BZNOCREATE; } if (stat(notifierpath, &tstat)) { bozo_Log("BNODE-Create: Notifier program '%s' not found\n", notifierpath); free(notifierpath); return BZNOCREATE; } } tb = (*type->ops->create) (ainstance, ap1, ap2, ap3, ap4, ap5); if (!tb) { free(notifierpath); return BZNOCREATE; } tb->notifier = notifierpath; *abp = tb; tb->type = type; /* The fs_create above calls bnode_InitBnode() which always sets the ** fileGoal to BSTAT_NORMAL .... overwrite it with whatever is passed into ** this function as a parameter... */ tb->fileGoal = fileGoal; bnode_SetStat(tb, tb->goal); /* nudge it once */ if (rewritefile != 0) WriteBozoFile(0); return 0; }
/* shutdown and restart */ afs_int32 SBOZO_RestartAll(struct rx_call *acall) { afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing RestartAll\n", caller); /* start shutdown of all processes */ code = bnode_ApplyInstance(sdproc, NULL); if (code) goto fail; /* wait for all done */ code = bnode_ApplyInstance(swproc, NULL); if (code) goto fail; /* start them up again */ code = bnode_ApplyInstance(stproc, NULL); fail: osi_auditU(acall, BOS_RestartAllEvent, code, AUD_END); return code; }
afs_int32 SBOZO_Restart(struct rx_call *acall, char *ainstance) { struct bnode *tb; afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing Restart '%s'\n", caller, ainstance); tb = bnode_FindInstance(ainstance); if (!tb) { code = BZNOENT; goto fail; } bnode_Hold(tb); bnode_SetStat(tb, BSTAT_SHUTDOWN); code = bnode_WaitStatus(tb, BSTAT_SHUTDOWN); /* this can fail */ bnode_ResetErrorCount(tb); bnode_SetStat(tb, BSTAT_NORMAL); bnode_Release(tb); fail: osi_auditU(acall, BOS_RestartEvent, code, AUD_STR, ainstance, AUD_END); return code; }
afs_int32 SBOZO_AddKey(struct rx_call *acall, afs_int32 an, struct bozo_key *akey) { afs_int32 code; char caller[MAXKTCNAMELEN]; rxkad_level enc_level = rxkad_clear; int noauth; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } noauth = afsconf_GetNoAuthFlag(bozo_confdir); rxkad_GetServerInfo(rx_ConnectionOf(acall), &enc_level, 0, 0, 0, 0, 0); if ((!noauth) && (enc_level != rxkad_crypt)) { code = BZENCREQ; goto fail; } if (DoLogging) bozo_Log("%s is executing AddKey\n", caller); code = afsconf_AddKey(bozo_confdir, an, akey->data, 0); if (code == AFSCONF_KEYINUSE) code = BZKEYINUSE; /* Unique code for afs rpc calls */ fail: osi_auditU(acall, BOS_AddKeyEvent, code, AUD_END); return code; }
/** * Write a file containing the pid of the named process. * * @param ainst instance name * @param aname sub-process name of the instance, may be null * @param apid process id of the newly started process * * @returns status */ int bozo_CreatePidFile(char *ainst, char *aname, pid_t apid) { int code = 0; char *pidfile = NULL; FILE *fp; pidfile = make_pid_filename(ainst, aname); if (!pidfile) { return ENOMEM; } if ((fp = fopen(pidfile, "w")) == NULL) { bozo_Log("Failed to open pidfile %s; errno=%d\n", pidfile, errno); free(pidfile); return errno; } if (fprintf(fp, "%ld\n", afs_printable_int32_ld(apid)) < 0) { code = errno; } if (fclose(fp) != 0) { code = errno; } free(pidfile); return code; }
struct bnode * cron_create(char *ainstance, char *acommand, char *awhen) { struct cronbnode *te; afs_int32 code; char *cmdpath; extern char *copystr(); /* construct local path from canonical (wire-format) path */ if (ConstructLocalBinPath(acommand, &cmdpath)) { bozo_Log("BNODE: command path invalid '%s'\n", acommand); return NULL; } te = (struct cronbnode *)malloc(sizeof(struct cronbnode)); memset(te, 0, sizeof(struct cronbnode)); code = ktime_ParsePeriodic(awhen, &te->whenToRun); if ((code < 0) || (bnode_InitBnode(te, &cronbnode_ops, ainstance) != 0)) { free(te); free(cmdpath); return NULL; } te->when = ktime_next(&te->whenToRun, 0); te->command = cmdpath; te->whenString = copystr(awhen); return (struct bnode *)te; }
afs_int32 SBOZO_SetStatus(struct rx_call *acall, char *ainstance, afs_int32 astatus) { struct bnode *tb; afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing SetStatus '%s' (status = %d)\n", caller, ainstance, astatus); tb = bnode_FindInstance(ainstance); if (!tb) { code = BZNOENT; goto fail; } bnode_Hold(tb); bnode_SetFileGoal(tb, astatus); code = bnode_SetStat(tb, astatus); bnode_Release(tb); fail: osi_auditU(acall, BOS_SetStatusEvent, code, AUD_STR, ainstance, AUD_END); return code; }
afs_int32 SBOZO_Exec(struct rx_call *acall, char *acmd) { char caller[MAXKTCNAMELEN]; int code; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (bozo_isrestricted) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing the shell command '%s'\n", caller, acmd); /* should copy output to acall, but don't yet cause its hard */ /* hard... NOT! Nnow _at least_ return the exit status */ code = system(acmd); osi_auditU(acall, BOS_ExecEvent, code, AUD_STR, acmd, AUD_END); fail: return code; }
static int ez_procexit(struct bnode *bn, struct bnode_proc *aproc) { struct ezbnode *abnode = (struct ezbnode *)bn; /* process has exited */ afs_int32 code = 0; if (DoPidFiles) { bozo_DeletePidFile(bn->name, NULL); } abnode->waitingForShutdown = 0; abnode->running = 0; abnode->killSent = 0; abnode->proc = NULL; bnode_SetTimeout((struct bnode *) abnode, 0); /* clear timer */ if (abnode->b.goal) code = ez_setstat((struct bnode *) abnode, BSTAT_NORMAL); else if (abnode->b.flags & BNODE_ERRORSTOP && abnode->b.errorStopDelay) { bozo_Log("%s will retry start in %d seconds\n", abnode->b.name, abnode->b.errorStopDelay); bnode_SetTimeout(bn, abnode->b.errorStopDelay); } return code; }
static char * make_pid_filename(char *ainst, char *aname) { char *buffer = NULL; if (aname && *aname) { asprintf(&buffer, "%s/%s.%s.pid", DoPidFiles, ainst, aname); if (buffer == NULL) bozo_Log("Failed to alloc pid filename buffer for %s.%s.\n", ainst, aname); } else { asprintf(&buffer, "%s/%s.pid", DoPidFiles, ainst); if (buffer == NULL) bozo_Log("Failed to alloc pid filename buffer for %s.\n", ainst); } return buffer; }
int hdl_notifier(struct bnode_proc *tp) { #ifndef AFS_NT40_ENV /* NT notifier callout not yet implemented */ int code, pid; struct stat tstat; if (stat(tp->bnode->notifier, &tstat)) { bozo_Log("BNODE: Failed to find notifier '%s'; ignored\n", tp->bnode->notifier); return (1); } if ((pid = fork()) == 0) { FILE *fout; struct bnode *tb = tp->bnode; int ec; #if defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_SGI51_ENV) ec = setsid(); #elif defined(AFS_DARWIN90_ENV) ec = setpgid(0, 0); #elif defined(AFS_LINUX20_ENV) || defined(AFS_AIX_ENV) ec = setpgrp(); #else ec = setpgrp(0, 0); #endif fout = popen(tb->notifier, "w"); if (fout == NULL) { bozo_Log("BNODE: Failed to find notifier '%s'; ignored\n", tb->notifier); perror(tb->notifier); exit(1); } code = SendNotifierData(fileno(fout), tp); pclose(fout); exit(0); } else if (pid < 0) { bozo_Log("Failed to fork creating process to handle notifier '%s'\n", tp->bnode->notifier); return -1; } #endif /* AFS_NT40_ENV */ return (0); }
afs_int32 SBOZO_ListKeys(struct rx_call *acall, afs_int32 an, afs_int32 *akvno, struct bozo_key *akey, struct bozo_keyInfo *akeyinfo) { struct afsconf_keys tkeys; afs_int32 code; struct stat tstat; int noauth = 0; char caller[MAXKTCNAMELEN]; rxkad_level enc_level = rxkad_clear; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing ListKeys\n", caller); code = afsconf_GetKeys(bozo_confdir, &tkeys); if (code) goto fail; if (tkeys.nkeys <= an) { code = BZDOM; goto fail; } *akvno = tkeys.key[an].kvno; memset(akeyinfo, 0, sizeof(struct bozo_keyInfo)); noauth = afsconf_GetNoAuthFlag(bozo_confdir); rxkad_GetServerInfo(rx_ConnectionOf(acall), &enc_level, 0, 0, 0, 0, 0); /* * only return actual keys in noauth or if this is an encrypted connection */ if ((noauth) || (enc_level == rxkad_crypt)) { memcpy(akey, tkeys.key[an].key, 8); } else memset(akey, 0, 8); code = stat(AFSDIR_SERVER_KEY_FILEPATH, &tstat); if (code == 0) { akeyinfo->mod_sec = tstat.st_mtime; } /* This will return an error if the key is 'bad' (bad checksum, weak DES * key, etc). But we don't care, since we can still return the other * information about the key, so ignore the result. */ (void)ka_KeyCheckSum(tkeys.key[an].key, &akeyinfo->keyCheckSum); fail: if (noauth) osi_auditU(acall, BOS_UnAuthListKeysEvent, code, AUD_END); osi_auditU(acall, BOS_ListKeysEvent, code, AUD_END); return code; }
/** * Create the rxbind file of this bosserver. * * @param host bind address of this server * * @returns status */ void bozo_CreateRxBindFile(afs_uint32 host) { char buffer[16]; FILE *fp; if (host == htonl(INADDR_ANY)) { host = htonl(0x7f000001); } afs_inet_ntoa_r(host, buffer); bozo_Log("Listening on %s:%d\n", buffer, AFSCONF_NANNYPORT); if ((fp = fopen(AFSDIR_SERVER_BOZRXBIND_FILEPATH, "w")) == NULL) { bozo_Log("Unable to open rxbind address file: %s, code=%d\n", AFSDIR_SERVER_BOZRXBIND_FILEPATH, errno); } else { fprintf(fp, "%s\n", buffer); fclose(fp); } }
afs_int32 SBOZO_Prune(struct rx_call *acall, afs_int32 aflags) { afs_int32 code; DIR *dirp; struct dirent *tde; int i; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (bozo_isrestricted) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing Prune (flags=%d)\n", caller, aflags); /* first scan AFS binary directory */ dirp = opendir(AFSDIR_SERVER_BIN_DIRPATH); if (dirp) { for (tde = readdir(dirp); tde; tde = readdir(dirp)) { i = strlen(tde->d_name); if (aflags & BOZO_PRUNEOLD) { if (i >= 4 && strncmp(tde->d_name + i - 4, ".OLD", 4) == 0) ZapFile(AFSDIR_SERVER_BIN_DIRPATH, tde->d_name); } if (aflags & BOZO_PRUNEBAK) { if (i >= 4 && strncmp(tde->d_name + i - 4, ".BAK", 4) == 0) ZapFile(AFSDIR_SERVER_BIN_DIRPATH, tde->d_name); } } closedir(dirp); } /* then scan AFS log directory */ dirp = opendir(AFSDIR_SERVER_LOGS_DIRPATH); if (dirp) { for (tde = readdir(dirp); tde; tde = readdir(dirp)) { if (aflags & BOZO_PRUNECORE) { if (strncmp(tde->d_name, AFSDIR_CORE_FILE, 4) == 0) ZapFile(AFSDIR_SERVER_LOGS_DIRPATH, tde->d_name); } } closedir(dirp); } code = 0; fail: osi_auditU(acall, BOS_PruneLogs, code, AUD_END); return code; }
afs_int32 SBOZO_ListKeys(struct rx_call *acall, afs_int32 an, afs_int32 *akvno, struct bozo_key *akey, struct bozo_keyInfo *akeyinfo) { struct afsconf_keys tkeys; afs_int32 code; struct stat tstat; int noauth = 0; char caller[MAXKTCNAMELEN]; rxkad_level enc_level = rxkad_clear; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing ListKeys\n", caller); code = afsconf_GetKeys(bozo_confdir, &tkeys); if (code) goto fail; if (tkeys.nkeys <= an) { code = BZDOM; goto fail; } *akvno = tkeys.key[an].kvno; memset(akeyinfo, 0, sizeof(struct bozo_keyInfo)); noauth = afsconf_GetNoAuthFlag(bozo_confdir); rxkad_GetServerInfo(acall->conn, &enc_level, 0, 0, 0, 0, 0); /* * only return actual keys in noauth or if this is an encrypted connection */ if ((noauth) || (enc_level == rxkad_crypt)) { memcpy(akey, tkeys.key[an].key, 8); } else memset(akey, 0, 8); code = stat(AFSDIR_SERVER_KEY_FILEPATH, &tstat); if (code == 0) { akeyinfo->mod_sec = tstat.st_mtime; } ka_KeyCheckSum(tkeys.key[an].key, &akeyinfo->keyCheckSum); /* only errors is bad key parity */ fail: if (noauth) osi_auditU(acall, BOS_UnAuthListKeysEvent, code, AUD_END); osi_auditU(acall, BOS_ListKeysEvent, code, AUD_END); return code; }
/** * Create the rxbind file of this bosserver. * * @param host bind address of this server * * @returns status */ void bozo_CreateRxBindFile(afs_uint32 host) { char buffer[16]; FILE *fp; afs_inet_ntoa_r(host, buffer); bozo_Log("Listening on %s:%d\n", buffer, AFSCONF_NANNYPORT); if ((fp = fopen(AFSDIR_SERVER_BOZRXBIND_FILEPATH, "w")) == NULL) { bozo_Log("Unable to open rxbind address file: %s, code=%d\n", AFSDIR_SERVER_BOZRXBIND_FILEPATH, errno); } else { /* If listening on any interface, write the loopback interface to the rxbind file to give local scripts a usable addresss. */ if (host == htonl(INADDR_ANY)) { afs_inet_ntoa_r(htonl(0x7f000001), buffer); } fprintf(fp, "%s\n", buffer); fclose(fp); } }
afs_int32 SBOZO_UnInstall(struct rx_call *acall, char *aname) { char *filepath; char fpOld[AFSDIR_PATH_MAX], fpBak[AFSDIR_PATH_MAX]; afs_int32 code; char caller[MAXKTCNAMELEN]; struct stat tstat; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; osi_auditU(acall, BOS_UnInstallEvent, code, AUD_STR, aname, AUD_END); return code; } if (bozo_isrestricted) { code = BZACCESS; osi_auditU(acall, BOS_UnInstallEvent, code, AUD_STR, aname, AUD_END); return code; } /* construct local path from canonical (wire-format) path */ if (ConstructLocalBinPath(aname, &filepath)) { return BZNOENT; } if (DoLogging) bozo_Log("%s is executing UnInstall '%s'\n", caller, filepath); strcpy(fpBak, filepath); strcat(fpBak, ".BAK"); strcpy(fpOld, filepath); strcat(fpOld, ".OLD"); code = rk_rename(fpBak, filepath); if (code) { /* can't find .BAK, try .OLD */ code = rk_rename(fpOld, filepath); if (code && errno == ENOENT) /* If doesn't exist don't fail */ code = 0; } else { /* now rename .OLD to .BAK */ if (stat(fpOld, &tstat) == 0) code = rk_rename(fpOld, fpBak); } if (code) code = errno; osi_auditU(acall, BOS_UnInstallEvent, code, AUD_STR, filepath, AUD_END); free(filepath); return code; }
int DirAccessOK(void) { #ifdef AFS_NT40_ENV /* underlying filesystem may not support directory protection */ return 1; #else static afs_uint32 lastTime = 0; afs_uint32 now = FT_ApproxTime(); static int lastResult = -1; int result; int i; if ((now - lastTime) < 5) return lastResult; lastTime = now; result = 1; for (i = 0; i < bozo_nbosEntryStats; i++) { struct bozo_bosEntryStats *e = &bozo_bosEntryStats[i]; if (!StatEachEntry(e)) { bozo_Log("unhappy with %s which is a %s that should " "have at least rights %o, at most rights %o %s\n", e->path, e->dir ? "dir" : "file", e->reqPerm, (~e->proPerm & 0777), e->rootOwner ? ", owned by root" : ""); result = 0; break; } } if (result != lastResult) { /* log changes */ bozo_Log("Server directory access is %sokay\n", (result ? "" : "not ")); } lastResult = result; return lastResult; #endif /* AFS_NT40_ENV */ }
afs_int32 SBOZO_SetCellName(struct rx_call *acall, char *aname) { struct afsconf_cell tcell; afs_int32 code; char caller[MAXKTCNAMELEN]; char clones[MAXHOSTSPERCELL]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing SetCellName '%s'\n", caller, aname); code = afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell, clones); if (code) goto fail; /* Check that tcell has enough space for the new cellname. */ if (strlen(aname) > sizeof tcell.name - 1) { bozo_Log ("ERROR: SetCellName: cell name '%s' exceeds %ld bytes (cell name not changed)\n", aname, (long)(sizeof tcell.name - 1)); code = BZDOM; goto fail; } strcpy(tcell.name, aname); code = afsconf_SetExtendedCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH, &tcell, clones); fail: osi_auditU(acall, BOS_SetCellEvent, code, AUD_STR, aname, AUD_END); return code; }
static int cron_procexit(struct cronbnode *abnode, struct bnode_proc *aproc) { /* process has exited */ /* log interesting errors for folks */ if (aproc->lastSignal) bozo_Log("cron job %s exited due to signal %d\n", abnode->b.name, aproc->lastSignal); else if (aproc->lastExit) bozo_Log("cron job %s exited with non-zero code %d\n", abnode->b.name, aproc->lastExit); abnode->waitingForShutdown = 0; abnode->running = 0; abnode->killSent = 0; abnode->proc = (struct bnode_proc *)0; /* Figure out when to run next and schedule it */ abnode->when = ktime_next(&abnode->whenToRun, 0); ScheduleCronBnode(abnode); return 0; }
/** * Return true if this name is a member of the local realm. */ int bozo_IsLocalRealmMatch(void *rock, char *name, char *inst, char *cell) { struct afsconf_dir *dir = (struct afsconf_dir *)rock; afs_int32 islocal = 0; /* default to no */ int code; code = afsconf_IsLocalRealmMatch(dir, &islocal, name, inst, cell); if (code) { bozo_Log("Failed local realm check; code=%d, name=%s, inst=%s, cell=%s\n", code, name, inst, cell); } return islocal; }
void * bozo_ShutdownAndExit(void *param) { int asignal = (intptr_t)param; int code; bozo_Log ("Shutdown of BOS server and processes in response to signal %d\n", asignal); /* start shutdown of all processes */ if ((code = bnode_ApplyInstance(sdproc, NULL)) == 0) { /* wait for shutdown to complete */ code = bnode_ApplyInstance(swproc, NULL); } if (code) { bozo_Log("Shutdown incomplete (code = %d); manual cleanup required\n", code); } rx_Finalize(); exit(code); }
/* run at creation or after process exit. figures out if we're all done (if a one shot run) or when we should run again. Sleeps until we should run again. Note that the computation of when we should run again is made in procexit and/or create procs. This guy only schedules the sleep */ int ScheduleCronBnode(register struct cronbnode *abnode) { register afs_int32 code; register afs_int32 temp; struct bnode_proc *tp; /* If this proc is shutdown, tell bproc() to no longer run this job */ if (abnode->b.goal == BSTAT_SHUTDOWN) { bnode_SetTimeout(abnode, 0); return 0; } /* otherwise we're supposed to be running, figure out when */ if (abnode->when == 0) { /* one shot */ if (abnode->everRun) { /* once is enough */ bnode_Delete(abnode); return 0; } /* otherwise start it */ if (!abnode->running) { /* start up */ abnode->lastStart = FT_ApproxTime(); code = bnode_NewProc(abnode, abnode->command, NULL, &tp); if (code) { bozo_Log("cron bnode %s failed to start (code %d)\n", abnode->b.name, code); return code; } abnode->everRun = 1; abnode->running = 1; abnode->proc = tp; return 0; } } else { /* run periodically */ if (abnode->running) return 0; /* otherwise find out when to run it, and do it then */ temp = abnode->when - FT_ApproxTime(); if (temp < 1) temp = 1; /* temp is when to start dude */ bnode_SetTimeout(abnode, temp); } return 0; }
int bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName, struct bnode_proc **aproc) { struct bnode_token *tlist, *tt; afs_int32 code; struct bnode_proc *tp; pid_t cpid; char *argv[MAXVARGS]; int i; code = bnode_ParseLine(aexecString, &tlist); /* try parsing first */ if (code) return code; tp = (struct bnode_proc *)malloc(sizeof(struct bnode_proc)); memset(tp, 0, sizeof(struct bnode_proc)); tp->next = allProcs; tp->bnode = abnode; tp->comLine = aexecString; tp->coreName = coreName; /* may be null */ abnode->procStartTime = FT_ApproxTime(); abnode->procStarts++; /* convert linked list of tokens into argv structure */ for (tt = tlist, i = 0; i < (MAXVARGS - 1) && tt; tt = tt->next, i++) { argv[i] = tt->key; } argv[i] = NULL; /* null-terminated */ cpid = spawnprocve(argv[0], argv, environ, -1); osi_audit(BOSSpawnProcEvent, 0, AUD_STR, aexecString, AUD_END); if (cpid == (pid_t) - 1) { bozo_Log("Failed to spawn process for bnode '%s'\n", abnode->name); bnode_FreeTokens(tlist); free(tp); return errno; } bnode_FreeTokens(tlist); allProcs = tp; *aproc = tp; tp->pid = cpid; tp->flags = BPROC_STARTED; tp->flags &= ~BPROC_EXITED; bnode_Check(abnode); return 0; }
afs_int32 SBOZO_DeleteCellHost(struct rx_call *acall, char *aname) { afs_int32 code; struct afsconf_cell tcell; afs_int32 which; int i; char caller[MAXKTCNAMELEN]; char clones[MAXHOSTSPERCELL]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing DeleteCellHost '%s'\n", caller, aname); code = afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell, clones); if (code) goto fail; which = -1; for (i = 0; i < tcell.numServers; i++) { if (strcmp(tcell.hostName[i], aname) == 0) { which = i; break; } } if (which < 0) { code = BZNOENT; goto fail; } memset(&tcell.hostAddr[which], 0, sizeof(struct sockaddr_in)); memset(tcell.hostName[which], 0, MAXHOSTCHARS); code = afsconf_SetExtendedCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH, &tcell, clones); fail: osi_auditU(acall, BOS_DeleteHostEvent, code, AUD_STR, aname, AUD_END); return code; }
/* make sure all are running */ afs_int32 SBOZO_StartupAll(struct rx_call *acall) { afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing StartupAll\n", caller); code = bnode_ApplyInstance(stproc, NULL); fail: osi_auditU(acall, BOS_StartupAllEvent, code, AUD_END); return code; }
afs_int32 SBOZO_SetNoAuthFlag(struct rx_call *acall, afs_int32 aflag) { afs_int32 code = 0; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing Set No Authentication\n", caller); afsconf_SetNoAuthFlag(bozo_confdir, aflag); fail: osi_auditU(acall, BOS_SetNoAuthEvent, code, AUD_LONG, aflag, AUD_END); return code; }
afs_int32 SBOZO_DeleteKey(struct rx_call *acall, afs_int32 an) { afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing DeleteKey\n", caller); code = afsconf_DeleteKey(bozo_confdir, an); fail: osi_auditU(acall, BOS_DeleteKeyEvent, code, AUD_END); return code; }
afs_int32 SBOZO_AddSUser(struct rx_call *acall, char *aname) { afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; goto fail; } if (DoLogging) bozo_Log("%s is executing Add SuperUser '%s'\n", caller, aname); code = afsconf_AddUser(bozo_confdir, aname); fail: osi_auditU(acall, BOS_AddSUserEvent, code, AUD_END); return code; }