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; }
int main(int argc, char *argv[]) { int ret = 0; GenericAgentConfig *config = CheckOpts(argc, argv); #ifdef HAVE_AVAHI_CLIENT_CLIENT_H #ifdef HAVE_AVAHI_COMMON_ADDRESS_H if (NULL_OR_EMPTY(POLICY_SERVER) && BOOTSTRAP) { int ret = AutomaticBootstrap(); if (ret < 0) { return 1; } } #endif #endif ReportContext *report_context = OpenReports(config->agent_type); GenericAgentDiscoverContext(config, report_context); Policy *policy = GenericAgentLoadPolicy(config, report_context, ALWAYS_VALIDATE); CheckLicenses(); ThisAgentInit(); BeginAudit(); KeepPromises(policy, config, report_context); CloseReports("agent", report_context); // only note class usage when default policy is run if (!config->input_file) { NoteClassUsage(VHEAP, true); NoteClassUsage(VHARDHEAP, true); } #ifdef HAVE_NOVA Nova_NoteVarUsageDB(); Nova_TrackExecution(config->input_file); #endif PurgeLocks(); if (BOOTSTRAP && !VerifyBootstrap()) { ret = 1; } EndAudit(CFA_BACKGROUND); GenericAgentConfigDestroy(config); return ret; }
int main(int argc,char *argv[]) { int ret = 0; CheckOpts(argc,argv); GenericInitialize(argc,argv,"agent"); ThisAgentInit(); KeepPromises(); NoteClassUsage(VHEAP); #ifdef HAVE_NOVA Nova_NoteVarUsageDB(); #endif PurgeLocks(); if(BOOTSTRAP && !VerifyBootstrap()) { ret = 1; } GenericDeInitialize(); return ret; }
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); }
int main(int argc, char *argv[]) { int ret = 0; GenericAgentConfig *config = CheckOpts(argc, argv); #ifdef HAVE_AVAHI_CLIENT_CLIENT_H #ifdef HAVE_AVAHI_COMMON_ADDRESS_H if (NULL_OR_EMPTY(POLICY_SERVER) && BOOTSTRAP) { int ret = AutomaticBootstrap(); if (ret < 0) { return 1; } } #endif #endif ReportContext *report_context = OpenReports(config->agent_type); GenericAgentDiscoverContext(config, report_context); Policy *policy = NULL; if (GenericAgentCheckPolicy(config, report_context, ALWAYS_VALIDATE)) { policy = GenericAgentLoadPolicy(config->agent_type, config, report_context); } else if (config->tty_interactive) { FatalError("CFEngine was not able to get confirmation of promises from cf-promises, please verify input file\n"); } else { CfOut(OUTPUT_LEVEL_ERROR, "", "CFEngine was not able to get confirmation of promises from cf-promises, so going to failsafe\n"); HardClass("failsafe_fallback"); GenericAgentConfigSetInputFile(config, "failsafe.cf"); policy = GenericAgentLoadPolicy(config->agent_type, config, report_context); } CheckLicenses(); ThisAgentInit(); BeginAudit(); KeepPromises(policy, config, report_context); CloseReports("agent", report_context); // only note class usage when default policy is run if (!config->input_file) { NoteClassUsage(VHEAP, true); NoteClassUsage(VHARDHEAP, true); } #ifdef HAVE_NOVA Nova_NoteVarUsageDB(); Nova_TrackExecution(config->input_file); #endif PurgeLocks(); if (BOOTSTRAP && !VerifyBootstrap()) { ret = 1; } EndAudit(CFA_BACKGROUND); GenericAgentConfigDestroy(config); return ret; }