Skip to content

Commit 2f16047

Browse files
committed
acl attribute can now override immutable bit
The acl 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 86b4a6e commit 2f16047

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cf-agent/acl_posix.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <rlist.h>
3434
#include <eval_context.h>
3535
#include <unix.h> /* GetGroupID(), GetUserID() */
36+
#include <override_fsattrs.h>
37+
#include "fsattrs.h"
3638

3739
#ifdef HAVE_ACL_H
3840
# include <acl.h>
@@ -389,6 +391,11 @@ static bool CheckPosixLinuxACEs(EvalContext *ctx, Rlist *aces, AclMethod method,
389391
acl_free(acl_text_str);
390392
return false;
391393
}
394+
395+
bool was_immutable = false;
396+
const bool override_immutable = EvalContextOverrideImmutableGet(ctx);
397+
FSAttrsResult res = TemporarilyClearImmutableBit(changes_path, override_immutable, &was_immutable);
398+
392399
if ((retv = acl_set_file(changes_path, acl_type, acl_new)) != 0)
393400
{
394401
RecordFailure(ctx, pp, a,
@@ -406,6 +413,8 @@ static bool CheckPosixLinuxACEs(EvalContext *ctx, Rlist *aces, AclMethod method,
406413
}
407414
acl_free(acl_text_str);
408415

416+
ResetTemporarilyClearedImmutableBit(changes_path, override_immutable, res, was_immutable);
417+
409418
RecordChange(ctx, pp, a, "%s ACL on '%s' successfully changed", acl_type_str, file_path);
410419
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
411420
}

0 commit comments

Comments
 (0)