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

Use stat() instead of opendir() for checking existence of a dir in sftpHelpers #34

Merged
merged 1 commit into from
Nov 17, 2013

Conversation

harriha
Copy link
Contributor

@harriha harriha commented Oct 20, 2013

Original problem: opendir() fails if given path doesn't have read permissions for
the current user (permissions 0xx).

I'm working with a hosted environment and can't naturally access the root folder. Since the helper function checks existence of directories starting from the root ('/') via trying to open each dir, using sftp with createDirectories=true failed for me. Using stat() instead of opendir() seems to solve the problem, to me it feels like a better way for checking whether a dir exists or not. However, please note that I'm not 100% sure if there were something else behind the way how this helper function is implemented, thus review & testing welcome.

To clarify, the failing scenario with current version can be created as follows:

  • Create a sample dir:
$ pwd
/path/to/home
$ mkdir private
$ chmod ugo-rxw private/
  • Try to sftp nested file structure to /path/to/home/private with createDirectories=true
  • -> Operation will fail

opendir() fails if given path doesn't have read permissions for
the current user.
@andrewrjones andrewrjones merged commit 08540d3 into israelroldan:master Nov 17, 2013
@andrewrjones
Copy link
Collaborator

Thanks for the patch! It looks good to me, and seems to work fine in my tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants