On Tue, 30 Dec 2025 22:37:02 GMT, Martin Doerr <[email protected]> wrote:

>> Weijun Wang has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   rewrite without jextract
>
> src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java
>  line 152:
> 
>> 150:             int out = (int) getpwuid_r.invokeExact(
>> 151:                     tmpUid, resbuf, pwd_buf, GETPW_R_SIZE_MAX, pwd);
>> 152:             if (out != 0 || pwd.get(ValueLayout.ADDRESS, 
>> 0).equals(MemorySegment.NULL)) {
> 
> The additional `|| pwd.get(ValueLayout.ADDRESS, 
> 0).equals(MemorySegment.NULL)` breaks AIX. The included test passes when we 
> remove it and we get the correct username.
> @JoKern65, @varada1110: Do you know why `getpwuid_r` writes nullptr (or 
> nothing) to `result` on a successful query?

First, thank you so much for the experiments.

Here, I think I follow the C checks in the old `Unix.c`:

    if (getpwuid_r(getuid(), &resbuf, pwd_buf, sizeof(pwd_buf), &pwd) == 0 &&
            pwd != NULL) {

How did it run in AIX?

> src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java
>  line 155:
> 
>> 153:                 uid = tmpUid;
>> 154:                 gid = (int)getgid.invokeExact();
>> 155:                 username = null;
> 
> Setting it to `null` will cause `NullPointerException` in the `UnixPrincipal` 
> constructor.

Hmm, maybe this has never happened before. If the username is really not 
available, we should not add a `UnixPrincipal`.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28931#discussion_r2656083411
PR Review Comment: https://git.openjdk.org/jdk/pull/28931#discussion_r2656083377

Reply via email to