mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 01:30:20 +00:00
If mode changes set perms["cmode"] in file.check_perms
This mirrors the user/group checks which set `perms["cuser"]` etc when there are changes expected. These values are used to determine if we need to return changes in `ret["changes"]`. Before this commit `file.chec_perms` was returning `mode` changes for new files which didn't match the original behaviour.
This commit is contained in:
parent
405d48bd28
commit
95ba6566b1
4 changed files with 15 additions and 11 deletions
2
changelog/62818.fixed
Normal file
2
changelog/62818.fixed
Normal file
|
@ -0,0 +1,2 @@
|
|||
Include UID and GID checks in modules.file.check_perms as well as comparing
|
||||
ownership by username and group name.
|
|
@ -5169,13 +5169,12 @@ def check_perms(
|
|||
|
||||
# Mode changes if needed
|
||||
if mode is not None:
|
||||
# File is a symlink, ignore the mode setting
|
||||
# if follow_symlinks is False
|
||||
if not (is_link and not follow_symlinks):
|
||||
if __opts__["test"] is True:
|
||||
ret["changes"]["mode"] = mode
|
||||
else:
|
||||
if not __opts__["test"] is True:
|
||||
# File is a symlink, ignore the mode setting
|
||||
# if follow_symlinks is False
|
||||
if not (is_link and not follow_symlinks):
|
||||
if not mode == cur["mode"]:
|
||||
perms["cmode"] = mode
|
||||
set_mode(name, mode)
|
||||
|
||||
# verify user/group/mode changes
|
||||
|
@ -5217,9 +5216,12 @@ def check_perms(
|
|||
# if follow_symlinks is False
|
||||
if not (is_link and not follow_symlinks):
|
||||
if not mode == post["mode"]:
|
||||
ret["result"] = False
|
||||
ret["comment"].append("Failed to change mode to {}".format(mode))
|
||||
else:
|
||||
if __opts__["test"] is True:
|
||||
ret["changes"]["mode"] = mode
|
||||
else:
|
||||
ret["result"] = False
|
||||
ret["comment"].append("Failed to change mode to {}".format(mode))
|
||||
elif "cmode" in perms:
|
||||
ret["changes"]["mode"] = mode
|
||||
|
||||
# Modify attributes of file if needed
|
||||
|
|
|
@ -755,7 +755,7 @@ def _check_directory(
|
|||
if (
|
||||
group is not None
|
||||
and not group == stats.get("group")
|
||||
and not user == stats.get("gid")
|
||||
and not group == stats.get("gid")
|
||||
):
|
||||
fchange["group"] = group
|
||||
smode = salt.utils.files.normalize_mode(stats.get("mode"))
|
||||
|
|
|
@ -112,7 +112,7 @@ def test_file_check_perms(tfile3):
|
|||
"name": tfile3,
|
||||
"result": True,
|
||||
},
|
||||
{"luser": "root", "lmode": "0644", "lgroup": "root"},
|
||||
{"cmode": "0664", "luser": "root", "lmode": "0644", "lgroup": "root"},
|
||||
)
|
||||
|
||||
# Disable lsattr calls
|
||||
|
|
Loading…
Add table
Reference in a new issue