Nov_12_2023-Dev

This commit is contained in:
Ned Wright
2023-11-12 18:50:17 +00:00
parent 0869b8f24d
commit 3061342b45
114 changed files with 3627 additions and 1305 deletions

View File

@@ -22,6 +22,16 @@ DeclarativePolicyUtils::init()
RestAction::SET, "apply-policy"
);
registerListener();
char *automatic_load = getenv("autoPolicyLoad");
if (automatic_load != nullptr && automatic_load == string("true")) {
auto mainloop = Singleton::Consume<I_MainLoop>::by<DeclarativePolicyUtils>();
mainloop->addRecurringRoutine(
I_MainLoop::RoutineType::Offline,
chrono::minutes(1),
[&] () { periodicPolicyLoad(); },
"Automatic Policy Loading"
);
}
}
// LCOV_EXCL_START Reason: no test exist
@@ -170,3 +180,19 @@ DeclarativePolicyUtils::getUpdate(CheckUpdateRequest &request)
curr_version = maybe_new_version.unpack();
return policy_response;
}
void
DeclarativePolicyUtils::periodicPolicyLoad()
{
auto new_checksum = getLocalPolicyChecksum();
if (!new_checksum.ok()) {
dbgWarning(D_ORCHESTRATOR) << "Failed to calculate checksum";
return;
}
if (*new_checksum == curr_checksum) return;
should_apply_policy = true;
curr_checksum = *new_checksum;
}