Skip to content

Commit 42049b6

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 42049b6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lib/files.cf

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

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

0 commit comments

Comments
 (0)