Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file.find module: fix handling of broken symlinks #34239

Merged
merged 1 commit into from
Jun 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions salt/utils/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,24 @@ def find(self, path):
for criterion in self.criteria:
if fstat is None and criterion.requires() & _REQUIRES_STAT:
fullpath = os.path.join(dirpath, name)
fstat = os.stat(fullpath)
try:
fstat = os.stat(fullpath)
except OSError:
fstat = os.lstat(fullpath)
if not criterion.match(dirpath, name, fstat):
matches = False
break

if matches:
if fullpath is None:
fullpath = os.path.join(dirpath, name)
for action in self.actions:
if (fstat is None and
action.requires() & _REQUIRES_STAT):
fstat = os.stat(fullpath)
try:
fstat = os.stat(fullpath)
except OSError:
fstat = os.lstat(fullpath)
result = action.execute(fullpath, fstat, test=self.test)
if result is not None:
yield result
Expand Down