NSFS | set supplemental groups dynamically to users groups #8687
+187
−23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explain the changes
getlogin_r
to get the user name for getgrouplist. this function gets the name of the user logged to the terminal. this function uses the/var/run/utmp
. in my implementation I usedgetpwuid
instead which gets the user name by uid using the/etc/passwd
file. I used it because its more flexible and according to documentationgetlogin_r
uses the/etc/passwd
file anyways. alsogetlogin_r
might not work because the uid was switched to be different then the one used to run the process(root)Issues:
Fixed #8712
Gaps
#8710 - list objects fail when using supplemental groups
continue #8552
Testing Instructions:
before running all tests on the code changes please run:
npm run build:native
manual tests (examples for linux):
groupadd -g 1022 new_group
useradd -c test_user2 -m test_user2 -p -u 1033 -g 1034
usermod -a -G new_group test_user2
sudo node src/cmd/manage_nsfs.js account add --name test_user1 --uid 1022 --gid 1022
sudo node src/cmd/manage_nsfs.js account add --name test_user1 --uid 1033 --gid 1034
test_user1_s3api create-bucket --bucket test_bcuket
test_user2_s3api put-object --bucket test_bcuket --key key1 --body <path_to_body>
automatic tests:
sudo node ./node_modules/mocha/bin/mocha src/test/unit_tests/test_nsfs_access.js
Note: building and testing was done on Linux and Mac machines