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.
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.