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

Fix user and group determination #19

Merged
merged 14 commits into from
Jan 10, 2024
Merged

Fix user and group determination #19

merged 14 commits into from
Jan 10, 2024

Conversation

jmsmkn
Copy link
Member

@jmsmkn jmsmkn commented Jan 10, 2024

Closes #18

@jmsmkn jmsmkn requested a review from pkcakeout January 10, 2024 11:57
Copy link
Member

@pkcakeout pkcakeout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I think!

Could not find the Popen line to suggest the modification from #18 (comment) though. Maybe that should be added, as you suggested!

@jmsmkn
Copy link
Member Author

jmsmkn commented Jan 10, 2024

I explicitly set extra_groups=[] in 0b37f5d. Should that be set to anything else in other situations? We do a lookup of the user in pwd so adding another parameter is no problem.

@pkcakeout
Copy link
Member

I explicitly set extra_groups=[] in 0b37f5d. Should that be set to anything else in other situations? We do a lookup of the user in pwd so adding another parameter is no problem.

Yeah, I do not know. If this was a full Linux system, there will be issues from not assigning supplemental groups. However, within docker, I do not expect issues to appear...

@pkcakeout
Copy link
Member

image

Is there a race condition in the testing framework?!

@pkcakeout
Copy link
Member

Anyway... there seem to be issues with dropping the extra groups in sagemaker afterall... in the commandline you can run:

paul@dingo-linux:~$ groups paul
paul : paul adm cdrom sudo dip plugdev lpadmin lxd sambashare docker libvirt

that list (not this literal one, of course!) should be the list of supplemental groups for the user. It is only available when the user actually exists.

@pkcakeout
Copy link
Member

pkcakeout commented Jan 10, 2024

... id is actually still the simpler option:

paul@dingo-linux:~$ id 1000
uid=1000(paul) gid=1000(paul) groups=1000(paul),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),132(lxd),133(sambashare),999(docker),141(libvirt)

Forgot that it also nicely lists the "groups=..." bit. However, could still be that sagemaker somehow needs access to group 0, then we should just omit the extra_groups=[] afterall. It is "correct" to drop the extra permissions but if it breaks things, it probably is not worth it!

sagemaker_shim/models.py Outdated Show resolved Hide resolved
@jmsmkn jmsmkn merged commit cebf9fe into main Jan 10, 2024
6 checks passed
@jmsmkn jmsmkn deleted the 18_non_db_users branch January 10, 2024 16:24
Comment on lines 118 to 125
[23746, *USER_GROUPS],
),
# User does not exist, but is an int
("23746", 23746, None, None, []),
(f"23746:{grp.getgrgid(0).gr_name}", 23746, 0, None, []),
(f"23746:{os.getgid()}", 23746, os.getgid(), None, []),
(f"23746:{grp.getgrgid(0).gr_name}", 23746, 0, None, [0]),
(f"23746:{os.getgid()}", 23746, os.getgid(), None, [os.getgid()]),
# User and group do not exist, but are ints
("23746:23746", 23746, 23746, None, []),
("23746:23746", 23746, 23746, None, [23746]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

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.

Users sometimes not found
2 participants