mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Remove NOP pass statements from file.check_perms
While refactoring the `mode` update section the `else` statements were removed which rendered the `if ...: pass` a NOP. The PR negates the `if is_link and not follow_symlinks` so we only continue to change the mode for non-links and link targets if `follow_symlinks == True`.
This commit is contained in:
parent
be05e799fe
commit
405d48bd28
1 changed files with 13 additions and 19 deletions
|
@ -5171,14 +5171,12 @@ def check_perms(
|
|||
if mode is not None:
|
||||
# File is a symlink, ignore the mode setting
|
||||
# if follow_symlinks is False
|
||||
if is_link and not follow_symlinks:
|
||||
pass
|
||||
|
||||
if __opts__["test"] is True:
|
||||
ret["changes"]["mode"] = mode
|
||||
else:
|
||||
if not mode == cur["mode"]:
|
||||
set_mode(name, mode)
|
||||
if not (is_link and not follow_symlinks):
|
||||
if __opts__["test"] is True:
|
||||
ret["changes"]["mode"] = mode
|
||||
else:
|
||||
if not mode == cur["mode"]:
|
||||
set_mode(name, mode)
|
||||
|
||||
# verify user/group/mode changes
|
||||
post = stats(name, follow_symlinks=follow_symlinks)
|
||||
|
@ -5217,22 +5215,18 @@ def check_perms(
|
|||
if mode is not None:
|
||||
# File is a symlink, ignore the mode setting
|
||||
# if follow_symlinks is False
|
||||
if is_link and not follow_symlinks:
|
||||
pass
|
||||
|
||||
if not mode == post["mode"]:
|
||||
ret["result"] = False
|
||||
ret["comment"].append("Failed to change mode to {}".format(mode))
|
||||
else:
|
||||
ret["changes"]["mode"] = mode
|
||||
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:
|
||||
ret["changes"]["mode"] = mode
|
||||
|
||||
# Modify attributes of file if needed
|
||||
if attrs is not None and not is_dir:
|
||||
# File is a symlink, ignore the mode setting
|
||||
# if follow_symlinks is False
|
||||
if is_link and not follow_symlinks:
|
||||
pass
|
||||
else:
|
||||
if not (is_link and not follow_symlinks):
|
||||
diff_attrs = _cmp_attrs(name, attrs)
|
||||
if diff_attrs and any(attr for attr in diff_attrs):
|
||||
changes = {
|
||||
|
|
Loading…
Add table
Reference in a new issue