int ScheduleAgentOperations(struct Bundle *bp) { struct SubType *sp; struct Promise *pp; enum typesequence type; int pass; if (PROCESSREFRESH == NULL || (PROCESSREFRESH && IsRegexItemIn(PROCESSREFRESH,bp->name))) { DeleteItemList(PROCESSTABLE); PROCESSTABLE = NULL; } for (pass = 1; pass < CF_DONEPASSES; pass++) { for (type = 0; TYPESEQUENCE[type] != NULL; type++) { ClassBanner(type); if ((sp = GetSubTypeForBundle(TYPESEQUENCE[type],bp)) == NULL) { continue; } BannerSubType(bp->name,sp->name,pass); SetScope(bp->name); if (!NewTypeContext(type)) { continue; } for (pp = sp->promiselist; pp != NULL; pp=pp->next) { SaveClassEnvironment(); ExpandPromise(cf_agent,bp->name,pp,KeepAgentPromise); if (Abort()) { NoteClassUsage(VADDCLASSES); DeleteTypeContext(type); return false; } } DeleteTypeContext(type); } } NoteClassUsage(VADDCLASSES); return true; }
static void KeepPromiseBundles() { Bundle *bp; SubType *sp; Promise *pp; char *scope; /* Dial up the generic promise expansion with a callback */ for (bp = BUNDLES; bp != NULL; bp = bp->next) /* get schedule */ { scope = bp->name; SetNewScope(bp->name); if ((strcmp(bp->type, CF_AGENTTYPES[cf_server]) == 0) || (strcmp(bp->type, CF_AGENTTYPES[cf_common]) == 0)) { DeletePrivateClassContext(); // Each time we change bundle BannerBundle(bp, NULL); scope = bp->name; for (sp = bp->subtypes; sp != NULL; sp = sp->next) /* get schedule */ { if (strcmp(sp->name, "access") != 0 && strcmp(sp->name, "roles") != 0) { continue; } BannerSubType(scope, sp->name, 0); SetScope(scope); AugmentScope(scope, NULL, NULL); for (pp = sp->promiselist; pp != NULL; pp = pp->next) { ExpandPromise(cf_server, scope, pp, KeepServerPromise); } } } } }
int ScheduleAgentOperations(Bundle *bp, const ReportContext *report_context) // NB - this function can be called recursively through "methods" { SubType *sp; enum typesequence type; int pass; int save_pr_kept = PR_KEPT; int save_pr_repaired = PR_REPAIRED; int save_pr_notkept = PR_NOTKEPT; if (PROCESSREFRESH == NULL || (PROCESSREFRESH && IsRegexItemIn(PROCESSREFRESH, bp->name))) { DeleteItemList(PROCESSTABLE); PROCESSTABLE = NULL; } for (pass = 1; pass < CF_DONEPASSES; pass++) { for (type = 0; AGENT_TYPESEQUENCE[type] != NULL; type++) { ClassBanner(type); if ((sp = BundleGetSubType(bp, AGENT_TYPESEQUENCE[type])) == NULL) { continue; } BannerSubType(bp->name, sp->name, pass); SetScope(bp->name); if (!NewTypeContext(type)) { continue; } for (size_t ppi = 0; ppi < SeqLength(sp->promises); ppi++) { Promise *pp = SeqAt(sp->promises, ppi); if (ALLCLASSESREPORT) { SaveClassEnvironment(); } if (pass == 1) // Count the number of promises modelled for efficiency { CF_TOPICS++; } ExpandPromise(AGENT_TYPE_AGENT, bp->name, pp, KeepAgentPromise, report_context); if (Abort()) { NoteClassUsage(VADDCLASSES, false); DeleteTypeContext(bp->parent_policy, type, report_context); NoteBundleCompliance(bp, save_pr_kept, save_pr_repaired, save_pr_notkept); return false; } } DeleteTypeContext(bp->parent_policy, type, report_context); } } NoteClassUsage(VADDCLASSES, false); return NoteBundleCompliance(bp, save_pr_kept, save_pr_repaired, save_pr_notkept); }
static void KeepPromiseBundles() { Bundle *bp; SubType *sp; Promise *pp; Rlist *rp, *params; FnCall *fp; char *name; Rval retval; int ok = true; enum typesequence type; if (GetVariable("control_common", "bundlesequence", &retval) == cf_notype) { CfOut(cf_error, "", " !! No bundlesequence in the common control body"); exit(1); } for (rp = (Rlist *) retval.item; rp != NULL; rp = rp->next) { switch (rp->type) { case CF_SCALAR: name = (char *) rp->item; params = NULL; break; case CF_FNCALL: fp = (FnCall *) rp->item; name = (char *) fp->name; params = (Rlist *) fp->args; break; default: name = NULL; params = NULL; CfOut(cf_error, "", " !! Illegal item found in bundlesequence: "); ShowRval(stdout, (Rval) {rp->item, rp->type}); printf(" = %c\n", rp->type); ok = false; break; } if (!(GetBundle(name, "knowledge") || (GetBundle(name, "common")))) { CfOut(cf_error, "", " !! Bundle \"%s\" listed in the bundlesequence was not found\n", name); ok = false; } } if (!ok) { FatalError("Errors in knowledge bundles"); } /* If all is okay, go ahead and evaluate */ for (type = 0; TYPESEQUENCE[type] != NULL; type++) { for (rp = (Rlist *) retval.item; rp != NULL; rp = rp->next) { switch (rp->type) { case CF_FNCALL: fp = (FnCall *) rp->item; name = (char *) fp->name; params = (Rlist *) fp->args; break; default: name = (char *) rp->item; params = NULL; break; } if ((bp = GetBundle(name, "knowledge")) || (bp = GetBundle(name, "common"))) { BannerBundle(bp, params); AugmentScope(bp->name, bp->args, params); DeletePrivateClassContext(); // Each time we change bundle } if ((sp = GetSubTypeForBundle(TYPESEQUENCE[type], bp)) == NULL) { continue; } BannerSubType(bp->name, sp->name, 1); for (pp = sp->promiselist; pp != NULL; pp = pp->next) { ExpandPromise(cf_know, bp->name, pp, KeepKnowledgePromise); } } } }