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

[v2] s3: Handle unlinked current working directory #8939

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

stoeckmann
Copy link

Issue #, if available:

Description of changes:

The relative_path function can also fail on Unix-like systems if the current working directory has been unlinked.

Add this except block next to already existing one for Windows systems where different drives might be in use.

Proof of Concept:

  1. Get yourself into an unlinked current working directory
MYDIR=$(mktemp -d)
cd $MYDIR
rmdir $MYDIR
  1. Try to copy a file with absolute path to an s3 bucket
aws s3 cp /bin/ls s3://bucket

You can see the following output:

fatal error: [Errno 2] No such file or directory

If you analyze the aws call with strace, you can see that actually getcwd fails and that the error message is not about /bin/ls at all:

[pid 56266] getcwd(0x558ff0681790, 1024) = -1 ENOENT (No such file or directory)

With this patch applied, aws continues operation and just prints the absolute path instead of relative one.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The relative_path function can also fail on Unix-like systems if the
current working directory has been unlinked.

Add this except block next to already existing one for Windows systems
where different drives might be in use.
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.

1 participant