mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2026-04-25 05:16:00 +03:00
[PR #2399] [MERGED] fix: List Bucket/IAM Edge Cases #2519
Labels
No labels
bug
bug
dataloss
duplicate
enhancement
feature request
help wanted
invalid
need info
performance
pull-request
question
question
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/s3fs-fuse#2519
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/s3fs-fuse/s3fs-fuse/pull/2399
Author: @jmcarpenter2
Created: 1/23/2024
Status: ✅ Merged
Merged: 2/3/2024
Merged by: @ggtakec
Base:
master← Head:jmc/fix-list-bucket📝 Commits (1)
bf85b38fix: ListBucket edge cases📊 Changes
1 file changed (+2 additions, -3 deletions)
View changed files
📝
src/s3fs.cpp(+2 -3)📄 Description
This pull request resolves an edge case when the XML fails to add objects to the ListBucket response, and correctly identifies that there are still objects under the
pathprovided. This can be caused by slightly restricted (but still correct) IAM permissions, where you add a condition on the s3:prefix to the s3:ListBucket permissions. Specifically, this issue only occurs in special cases where there are special characters in the prefix/object path.Relevant Issue (if applicable)
https://github.com/s3fs-fuse/s3fs-fuse/issues/2129#issuecomment-1889763779
Details
There are two changes in this pull request.
reiterstring before checking ifreiteris an empty directory. This resolves anAccess Deniedresponse from S3, because for some reason the full path did not include the/separator between the base prefix and the rest of the path.directory_emptyfunction returns-ENOTEMPTY, which implies that while adding objects from the XML response of the ListBucket CURL command, it failed but there are still objects under the path provided. This failure mode appears to happen with the special IAM policy condition mentioned above in combination with special characters in the object or prefix path. By handling this special case we getStatCacheData from the updated dirpath instead and proceed with the s3 prefix appearing in the mount.Demonstration of fix
Basic setup
Version of s3fs being used (s3fs --version)
1.93Version of fuse being used (pkg-config --modversion fuse, rpm -qi fuse or dpkg -s fuse)
2.9.9Kernel information (uname -r)
4.14.334-252.552.amzn2.x86_64GNU/Linux Distribution, if applicable (cat /etc/os-release)
Toy example, based on real issue
How to run s3fs, if applicable
s3fs syslog messages (grep s3fs /var/log/syslog, journalctl | grep s3fs, or s3fs outputs)
IAM Policy
We are trying to list bucket which has contents like the following
Details
It appears that the spaces in the object key Life and Health History Survey-responses.json under the david_stuff prefix is causing issues somehow in relationship with the listbucket permissions on home/David/*
To demonstrate how this fixes the issue, elaborating here on the failure mode workflow, given the example setup:
david-bucket:/home/Davidto/home/jovyan/work/personal, with prefix under itdavid_stuff/readdir_multi_headinvoked on mount prefix/home/Daviddirectory_emptyinvoked on pathdavid_stufflist_bucket,append_objects_from_xmlis invokedappend_objects_from_xml_xeis invoked, trying to parse the Contents/Key or the CommonPrefixes/Prefixcontents_xp ->nodesetval is emptydirectory_empty, we get one of two responses.-1onAccess Deniedfrom AWS S3. This is because thedavid_stuffpath is missing the/prefix, which was noticed by viewing the CURL commands to AWS S3. Without the/prefix, the constrained IAM permissions cause the access denied to get returned by AWS S3-39which responds to-ENOTEMPTY-ENOTEMPTYin this case means that, although we got the expression evaluation trying to append objects from xml.head, which is of typeS3ObjList, still has objects under it. Which means that there are in fact objects under the path/david_stuff.david_stuff-ENOTEMPTYcase and now display the s3 prefixdavid_stuffas a directory🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.