docker/docker — pull request #8026 by tonistiigi (2014-09-14 16:15:05+00:00)
Title: Improve ValidateContextDirectory error handling.

I was looking where the panic from #8006 was coming from and found some issues with the `ValidateContextDirectory()` function.

- Errors sent to the walker function functions were ignored. This meant that
one could get a panic when calling methods on a nil FileInfo object. For
example when the file did not exists any more.

- Lstat calls inside walker are reduntant because walker already calls Lstat
and passes the result to the callback.

- Error returned from filepath.Rel() can never be EACCES because it compares
strings and does not care about actual files. That error case will not appear
because of the algorithm used here.

- If Matched() returns error then ValidateContextDirectory() must return error.
Currently it still kept walking although the outcome was already known.

- Function will now fail in case of unknown error(not EACCES nor ENOENT).
Previous implementation did not make a clear decision about this (but
panicked because of the issues above).

Just to be clear, this does not fix #8006 (at least not for all cases) but it will give a correct error message instead of a panic.