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); } } } } }
static void KeepPromiseBundles(Policy *policy, GenericAgentConfig *config, const ReportContext *report_context) { Bundle *bp; Rlist *rp, *params; FnCall *fp; char *name; Rval retval; int ok = true; if (config->bundlesequence) { CfOut(cf_inform, "", " >> Using command line specified bundlesequence"); retval = (Rval) { config->bundlesequence, RVAL_TYPE_LIST }; } else if (GetVariable("control_common", "bundlesequence", &retval) == DATA_TYPE_NONE) { // TODO: somewhat frenzied way of telling user about an error CfOut(cf_error, "", " !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CfOut(cf_error, "", " !! No bundlesequence in the common control body"); CfOut(cf_error, "", " !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); exit(1); } // TODO: should've been checked a long time ago, remove? if (retval.type != RVAL_TYPE_LIST) { FatalError("Promised bundlesequence was not a list"); } for (rp = (Rlist *) retval.item; rp != NULL; rp = rp->next) { switch (rp->type) { case RVAL_TYPE_SCALAR: name = (char *) rp->item; params = NULL; if (strcmp(name, CF_NULL_VALUE) == 0) { continue; } break; case RVAL_TYPE_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 (!config->ignore_missing_bundles) { if (!(PolicyGetBundle(policy, NULL, "agent", name) || (PolicyGetBundle(policy, NULL, "common", name)))) { CfOut(cf_error, "", "Bundle \"%s\" listed in the bundlesequence was not found\n", name); ok = false; } } } if (!ok) { FatalError("Errors in agent bundles"); } if (VERBOSE || DEBUG) { printf("%s> -> Bundlesequence => ", VPREFIX); ShowRval(stdout, retval); printf("\n"); } /* If all is okay, go ahead and evaluate */ for (rp = (Rlist *) retval.item; rp != NULL; rp = rp->next) { switch (rp->type) { case RVAL_TYPE_FNCALL: fp = (FnCall *) rp->item; name = (char *) fp->name; params = (Rlist *) fp->args; break; default: name = (char *) rp->item; params = NULL; break; } if ((bp = PolicyGetBundle(policy, NULL, "agent", name)) || (bp = PolicyGetBundle(policy, NULL, "common", name))) { char ns[CF_BUFSIZE]; snprintf(ns,CF_BUFSIZE,"%s_meta", name); NewScope(ns); SetBundleOutputs(bp->name); AugmentScope(bp->name, bp->ns, bp->args, params); BannerBundle(bp, params); THIS_BUNDLE = bp->name; DeletePrivateClassContext(); // Each time we change bundle ScheduleAgentOperations(bp, report_context); ResetBundleOutputs(bp->name); } } }
void KeepPromiseBundles() { struct Bundle *bp; struct Rlist *rp,*params; struct FnCall *fp; char rettype,*name; void *retval; int ok = true; if (CBUNDLESEQUENCE) { CfOut(cf_inform,""," >> Using command line specified bundlesequence"); retval = CBUNDLESEQUENCE; rettype = CF_LIST; } else if (GetVariable("control_common","bundlesequence",&retval,&rettype) == cf_notype) { CfOut(cf_error,""," !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); CfOut(cf_error,""," !! No bundlesequence in the common control body"); CfOut(cf_error,""," !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); exit(1); } if (rettype != CF_LIST) { FatalError("Promised bundlesequence was not a list"); } for (rp = (struct Rlist *)retval; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_SCALAR: name = (char *)rp->item; params = NULL; if (strcmp(name,CF_NULL_VALUE) == 0) { continue; } break; case CF_FNCALL: fp = (struct FnCall *)rp->item; name = (char *)fp->name; params = (struct Rlist *)fp->args; break; default: name = NULL; params = NULL; CfOut(cf_error,"","Illegal item found in bundlesequence: "); ShowRval(stdout,rp->item,rp->type); printf(" = %c\n",rp->type); ok = false; break; } if (!IGNORE_MISSING_BUNDLES) { if (!(GetBundle(name,"agent")||(GetBundle(name,"common")))) { CfOut(cf_error,"","Bundle \"%s\" listed in the bundlesequence was not found\n",name); ok = false; } } } if (!ok) { FatalError("Errors in agent bundles"); } if (VERBOSE || DEBUG) { printf("%s> -> Bundlesequence => ",VPREFIX); ShowRval(stdout,retval,rettype); printf("\n"); } /* If all is okay, go ahead and evaluate */ for (rp = (struct Rlist *)retval; rp != NULL; rp=rp->next) { switch (rp->type) { case CF_FNCALL: fp = (struct FnCall *)rp->item; name = (char *)fp->name; params = (struct Rlist *)fp->args; break; default: name = (char *)rp->item; params = NULL; break; } if ((bp = GetBundle(name,"agent")) || (bp = GetBundle(name,"common"))) { SetBundleOutputs(bp->name); AugmentScope(bp->name,bp->args,params); BannerBundle(bp,params); THIS_BUNDLE = bp->name; DeletePrivateClassContext(); // Each time we change bundle ScheduleAgentOperations(bp); ResetBundleOutputs(bp->name); } } }
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); } } } }