Skip to content

Commit

Permalink
Make file.symlink/_symlink_check() respect follow_symlinks
Browse files Browse the repository at this point in the history
Fixes: #66980
  • Loading branch information
Tom Doherty committed Oct 18, 2024
1 parent ef2fb24 commit 8ed8317
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/66980.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
make file.symlink/_symlink_check() respect follow_symlinks
8 changes: 5 additions & 3 deletions salt/states/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,12 +983,14 @@ def _set_symlink_ownership(path, user, group, win_owner):
return _check_symlink_ownership(path, user, group, win_owner)


def _symlink_check(name, target, force, user, group, win_owner):
def _symlink_check(name, target, force, user, group, win_owner, follow_symlinks=False):
"""
Check the symlink function
"""
changes = {}
if not os.path.exists(name) and not __salt__["file.is_link"](name):
exists = os.path.exists if follow_symlinks else os.path.lexists

if not exists(name) and not __salt__["file.is_link"](name):
changes["new"] = name
return (
None,
Expand Down Expand Up @@ -1788,7 +1790,7 @@ def symlink(
return _error(ret, msg)

tresult, tcomment, tchanges = _symlink_check(
name, target, force, user, group, win_owner
name, target, force, user, group, win_owner, follow_symlinks
)

if not os.path.isdir(os.path.dirname(name)):
Expand Down

0 comments on commit 8ed8317

Please sign in to comment.