Skip to content

Commit a9a4132

Browse files
committed
Added sys.policy_release_id
Ticket: ENT-4664 Signed-off-by: Victor Moene <[email protected]>
1 parent 6a52b58 commit a9a4132

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cf-agent/cf-agent.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,27 @@ static PromiseResult DefaultVarPromiseWrapper(EvalContext *ctx, const Promise *p
267267
return DefaultVarPromise(ctx, pp);
268268
}
269269

270+
/*******************************************************************/
271+
272+
static void SysPolicyReleaseId(EvalContext *ctx, Policy *policy)
273+
{
274+
DataType type;
275+
const char *entry_dirname = EvalContextVariableGetSpecial(ctx, SPECIAL_SCOPE_SYS, "policy_entry_dirname", &type);
276+
if (entry_dirname == NULL)
277+
{
278+
return;
279+
}
280+
char *release_id;
281+
xasprintf(&release_id, "%s/%s", entry_dirname, policy->release_id);
282+
283+
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_SYS,
284+
"policy_release_id",
285+
release_id,
286+
CF_DATA_TYPE_STRING, "source=agent,attribute_name=Policy Release Id");
287+
free(release_id);
288+
}
289+
290+
270291
/*******************************************************************/
271292

272293
int main(int argc, char *argv[])
@@ -321,6 +342,7 @@ int main(int argc, char *argv[])
321342

322343
BeginAudit();
323344

345+
SysPolicyReleaseId(ctx, policy);
324346
KeepPromises(ctx, policy, config);
325347

326348
if (EvalAborted(ctx))

0 commit comments

Comments
 (0)