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

[cli] do not crash when listing unaccessible directories #865

Merged
merged 1 commit into from
Sep 3, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## Fixed

- Capture permission errors when searching for files on filesystem [PR #865](https://github.com/3scale/apicast/pull/865)

## [3.3.0-beta1] - 2018-08-31

### Added
Expand Down
5 changes: 4 additions & 1 deletion gateway/src/apicast/cli/filesystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ local co_yield = coroutine.yield
local co_create = coroutine.create
local co_resume = coroutine.resume

local noop = function () end

--- Safely try to get directory iterator
local function ldir(dir)
local ok, iter, state = pcall(pl_path_dir, dir)

if ok then
return iter, state
else
return nil, iter
ngx.log(ngx.DEBUG, 'error listing directory: ', dir, ' err: ', iter)
return noop
end
end

Expand Down