void KeepPromises() { KeepContextBundles(); KeepControlPromises(); KeepPromiseBundles(); }
void KeepPromises(EvalContext *ctx, const Policy *policy, GenericAgentConfig *config) { if (paths_acl != NULL || classes_acl != NULL || vars_acl != NULL || literals_acl != NULL || query_acl != NULL || bundles_acl != NULL || roles_acl != NULL || SV.path_shortcuts != NULL) { UnexpectedError("ACLs are not NULL - we are probably leaking memory!"); } paths_acl = calloc(1, sizeof(*paths_acl)); classes_acl = calloc(1, sizeof(*classes_acl)); vars_acl = calloc(1, sizeof(*vars_acl)); literals_acl = calloc(1, sizeof(*literals_acl)); query_acl = calloc(1, sizeof(*query_acl)); bundles_acl = calloc(1, sizeof(*bundles_acl)); roles_acl = calloc(1, sizeof(*roles_acl)); SV.path_shortcuts = StringMapNew(); if (paths_acl == NULL || classes_acl == NULL || vars_acl == NULL || literals_acl == NULL || query_acl == NULL || bundles_acl == NULL || roles_acl == NULL || SV.path_shortcuts == NULL) { Log(LOG_LEVEL_CRIT, "calloc: %s", GetErrorStr()); exit(255); } KeepControlPromises(ctx, policy, config); KeepPromiseBundles(ctx, policy); }
void KeepPromises() { double efficiency; BeginAudit(); KeepControlPromises(); KeepPromiseBundles(); EndAudit(); // TOPICS counts the number of currently defined promises // OCCUR counts the number of objects touched while verifying config efficiency = 100.0*CF_OCCUR/(double)(CF_OCCUR+CF_TOPICS); NoteEfficiency(efficiency); CfOut(cf_verbose,""," -> Checked %d objects with %d promises, efficiency %.2lf",CF_OCCUR,CF_TOPICS,efficiency); }
static void KeepPromises(Policy *policy, GenericAgentConfig *config, const ReportContext *report_context) { double efficiency, model; KeepControlPromises(policy); KeepPromiseBundles(policy, config, report_context); // TOPICS counts the number of currently defined promises // OCCUR counts the number of objects touched while verifying config efficiency = 100.0 * CF_OCCUR / (double) (CF_OCCUR + CF_TOPICS); model = 100.0 * (1.0 - CF_TOPICS / (double)(PR_KEPT + PR_NOTKEPT + PR_REPAIRED)); NoteEfficiency(efficiency); CfOut(cf_verbose, "", " -> Checked %d objects with %d promises, i.e. model efficiency %.2lf%%", CF_OCCUR, CF_TOPICS, efficiency); CfOut(cf_verbose, "", " -> The %d declared promise patterns actually expanded into %d individual promises, i.e. declaration efficiency %.2lf%%", (int) CF_TOPICS, PR_KEPT + PR_NOTKEPT + PR_REPAIRED, model); }
int main(int argc, char *argv[]) { Rlist *rp; Promise *pp; #if !defined(__MINGW32__) int count = 0; int status; int pid; #endif GenericAgentConfig *config = CheckOpts(argc, argv); ReportContext *report_context = OpenReports("runagent"); Policy *policy = GenericInitialize("runagent", config, report_context); ThisAgentInit(); KeepControlPromises(policy); // Set RUNATTR using copy if (BACKGROUND && INTERACTIVE) { CfOut(cf_error, "", " !! You cannot specify background mode and interactive mode together"); exit(1); } pp = MakeDefaultRunAgentPromise(); /* HvB */ if (HOSTLIST) { rp = HOSTLIST; while (rp != NULL) { #ifdef __MINGW32__ if (BACKGROUND) { CfOut(cf_verbose, "", "Windows does not support starting processes in the background - starting in foreground"); BACKGROUND = false; } #else if (BACKGROUND) /* parallel */ { if (count <= MAXCHILD) { if (fork() == 0) /* child process */ { HailServer(rp->item, RUNATTR, pp); exit(0); } else /* parent process */ { rp = rp->next; count++; } } else { pid = wait(&status); CfDebug("child = %d, child number = %d\n", pid, count); count--; } } else /* serial */ #endif /* __MINGW32__ */ { HailServer(rp->item, RUNATTR, pp); rp = rp->next; } } /* end while */ } /* end if HOSTLIST */ #ifndef __MINGW32__ if (BACKGROUND) { printf("Waiting for child processes to finish\n"); while (count > 1) { pid = wait(&status); CfOut(cf_verbose, "", "Child = %d ended, number = %d\n", pid, count); count--; } } #endif DeletePromise(pp); GenericAgentConfigDestroy(config); ReportContextDestroy(report_context); return 0; }
void KeepPromises(EvalContext *ctx, Policy *policy, GenericAgentConfig *config) { KeepContextBundles(ctx, policy); KeepControlPromises(ctx, policy, config); KeepPromiseBundles(ctx, policy); }
void KeepPromises(EvalContext *ctx, Policy *policy, GenericAgentConfig *config, const ReportContext *report_context) { KeepContextBundles(ctx, policy, report_context); KeepControlPromises(ctx, policy, config); KeepPromiseBundles(ctx, policy, report_context); }
int main(int argc, char *argv[]) { Rlist *rp; #if !defined(__MINGW32__) int count = 0; int status; int pid; #endif EvalContext *ctx = EvalContextNew(); GenericAgentConfig *config = CheckOpts(ctx, argc, argv); GenericAgentConfigApply(ctx, config); GenericAgentDiscoverContext(ctx, config); Policy *policy = GenericAgentLoadPolicy(ctx, config); WarnAboutDeprecatedFeatures(ctx); CheckForPolicyHub(ctx); ThisAgentInit(); KeepControlPromises(ctx, policy); // Set RUNATTR using copy if (BACKGROUND && INTERACTIVE) { CfOut(OUTPUT_LEVEL_ERROR, "", " !! You cannot specify background mode and interactive mode together"); exit(1); } /* HvB */ if (HOSTLIST) { rp = HOSTLIST; while (rp != NULL) { #ifdef __MINGW32__ if (BACKGROUND) { CfOut(OUTPUT_LEVEL_VERBOSE, "", "Windows does not support starting processes in the background - starting in foreground"); BACKGROUND = false; } #else if (BACKGROUND) /* parallel */ { if (count <= MAXCHILD) { if (fork() == 0) /* child process */ { HailServer(ctx, rp->item); exit(0); } else /* parent process */ { rp = rp->next; count++; } } else { pid = wait(&status); CfDebug("child = %d, child number = %d\n", pid, count); count--; } } else /* serial */ #endif /* __MINGW32__ */ { HailServer(ctx, rp->item); rp = rp->next; } } /* end while */ } /* end if HOSTLIST */ #ifndef __MINGW32__ if (BACKGROUND) { printf("Waiting for child processes to finish\n"); while (count > 1) { pid = wait(&status); CfOut(OUTPUT_LEVEL_VERBOSE, "", "Child = %d ended, number = %d\n", pid, count); count--; } } #endif GenericAgentConfigDestroy(config); return 0; }
int main(int argc, char *argv[]) { #if !defined(__MINGW32__) int count = 0; int status; int pid; #endif GenericAgentConfig *config = CheckOpts(argc, argv); EvalContext *ctx = EvalContextNew(); GenericAgentConfigApply(ctx, config); GenericAgentDiscoverContext(ctx, config); Policy *policy = LoadPolicy(ctx, config); ThisAgentInit(); KeepControlPromises(ctx, policy); // Set RUNATTR using copy if (BACKGROUND && INTERACTIVE) { Log(LOG_LEVEL_ERR, "You cannot specify background mode and interactive mode together"); exit(EXIT_FAILURE); } /* HvB */ if (HOSTLIST) { const Rlist *rp = HOSTLIST; while (rp != NULL) { #ifdef __MINGW32__ if (BACKGROUND) { Log(LOG_LEVEL_VERBOSE, "Windows does not support starting processes in the background - starting in foreground"); BACKGROUND = false; } #else if (BACKGROUND) /* parallel */ { if (count <= MAXCHILD) { if (fork() == 0) /* child process */ { HailServer(ctx, config, RlistScalarValue(rp)); exit(EXIT_SUCCESS); } else /* parent process */ { rp = rp->next; count++; } } else { pid = wait(&status); Log(LOG_LEVEL_DEBUG, "child = %d, child number = %d", pid, count); count--; } } else /* serial */ #endif /* __MINGW32__ */ { HailServer(ctx, config, RlistScalarValue(rp)); rp = rp->next; } } /* end while */ } /* end if HOSTLIST */ #ifndef __MINGW32__ if (BACKGROUND) { Log(LOG_LEVEL_NOTICE, "Waiting for child processes to finish"); while (count > 1) { pid = wait(&status); Log(LOG_LEVEL_VERBOSE, "Child %d ended, number %d", pid, count); count--; } } #endif PolicyDestroy(policy); GenericAgentFinalize(ctx, config); return 0; }