Skip to content

Commit 1265e21

Browse files
committed
Added immutable option to fsattrs body
This introduces a new fsattrs immutable body for use with the files promise type. When applied, it ensures that the promised file has the immutable (i) attribute set. The agent will transparently manage the attribute, removing it before any necessary file modifications and restoring it afterwards. Ticket: CFE-4582 Changelog: Title
1 parent 2655c7b commit 1265e21

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/files.cf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,31 @@ body delete tidy
19361936
rmdirs => "true";
19371937
}
19381938

1939+
##-------------------------------------------------------
1940+
## fsattrs
1941+
##-------------------------------------------------------
1942+
1943+
body fsattrs immutable
1944+
# @brief Ensure promised file is immutable
1945+
#
1946+
# **Example:**
1947+
#
1948+
# ```cf3
1949+
# files:
1950+
# "/etc/motd"
1951+
# content => "There are, in fact, rules. You have been notified.",
1952+
# fsatters => immutable,
1953+
# perms => mog( "644", "root", "root" );
1954+
# ````
1955+
{
1956+
# When true the end state of the file is immutable. If the promise
1957+
# necessitates a change in the file, the agent will handle immutability
1958+
# transparently with the bit being removed just before modification
1959+
# and restored immediately after the atomic change is made.
1960+
1961+
immutable => "true"; # The i attribute supported by chattr
1962+
}
1963+
19391964
##-------------------------------------------------------
19401965
## rename
19411966
##-------------------------------------------------------

0 commit comments

Comments
 (0)