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

UnixUser constructor uses a pam function to get groups that is not thread safe. #28

Open
MatthijsM opened this issue Nov 20, 2020 · 0 comments

Comments

@MatthijsM
Copy link

We recently noticed that the UnixUser getGroups method was occasionally returning garbage; other user names, incorrect groups and even strings containing non-alphanumeric characters. It turns out that the getgrgid function used in the constructor of UnixUser is not thread safe so when authenticating users in multiple threads concurrently you can get these unexpected results. The getgrgid function needs to be swapped out for getgrgid_r. Unfortunately I'm not a JNA expert so as a quick fix I just put a synchronize block around the for loop that gets the group names. I will post a proper fix when I get some time to learn JNA.

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

No branches or pull requests

1 participant