Skip to content

Commit d4e7957

Browse files
committed
perms attribute can now override immutable bit
The perms attribute of the files promise can now override the immutable bit. Ticket: ENT-10961, CFE-1840 Changelog: Commit Signed-off-by: Lars Erik Wik <[email protected]>
1 parent fb78427 commit d4e7957

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cf-agent/verify_files_utils.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,8 @@ static PromiseResult VerifyName(EvalContext *ctx, char *path, const struct stat
23202320

23212321
if (MakingChanges(ctx, pp, attr, &result, "rename file '%s' to '%s'", path, newname))
23222322
{
2323-
if (safe_chmod(changes_path, newperm) == 0)
2323+
const bool override_immutable = EvalContextOverrideImmutableGet(ctx);
2324+
if (OverrideImmutableChmod(changes_path, newperm, override_immutable))
23242325
{
23252326
RecordChange(ctx, pp, attr, "Changed permissions of '%s' to 'mode %04jo'",
23262327
path, (uintmax_t)newperm);
@@ -2335,7 +2336,6 @@ static PromiseResult VerifyName(EvalContext *ctx, char *path, const struct stat
23352336

23362337
if (!FileInRepository(newname))
23372338
{
2338-
const bool override_immutable = EvalContextOverrideImmutableGet(ctx);
23392339
if (!OverrideImmutableRename(changes_path, changes_newname, override_immutable))
23402340
{
23412341
RecordFailure(ctx, pp, attr, "Error occurred while renaming '%s'", path);
@@ -2653,7 +2653,8 @@ static PromiseResult VerifyFileAttributes(EvalContext *ctx, const char *file, co
26532653
if (MakingChanges(ctx, pp, attr, &result, "change permissions of '%s' from %04jo to %04jo",
26542654
file, (uintmax_t)dstat->st_mode & 07777, (uintmax_t)newperm & 07777))
26552655
{
2656-
if (safe_chmod(changes_file, newperm & 07777) == -1)
2656+
const bool override_immutable = EvalContextOverrideImmutableGet(ctx);
2657+
if (!OverrideImmutableChmod(changes_file, newperm & 07777, override_immutable))
26572658
{
26582659
RecordFailure(ctx, pp, attr, "Failed to change permissions of '%s'. (chmod: %s)",
26592660
file, GetErrorStr());

0 commit comments

Comments
 (0)