On Mon, 22 Dec 2025 14:47:41 GMT, Weijun Wang <[email protected]> wrote:
>> Rewrite the native calls with FFM.
>
> Weijun Wang has updated the pull request incrementally with one additional
> commit since the last revision:
>
> rewrite without jextract
I've made some AIX experiments.
src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixLoginModule.java
line 131:
> 129: // might fail on other *nix systems. Especially, the
> `passwd`
> 130: // struct could be defined differently, although I've
> checked
> 131: // several and an extra 100 chars at the end seems enough.
The `passwd` struct on AIX is compatible.
src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixLoginModule.java
line 146:
> 144: throw error;
> 145: }
> 146: userPrincipal = new UnixPrincipal(ss.getUsername());
We get a `NullPointerException` in the `UnixPrincipal` constructor if `username
= null;` was used.
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?
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.
-------------
PR Review: https://git.openjdk.org/jdk/pull/28931#pullrequestreview-3619486191
PR Review Comment: https://git.openjdk.org/jdk/pull/28931#discussion_r2654077249
PR Review Comment: https://git.openjdk.org/jdk/pull/28931#discussion_r2654137745
PR Review Comment: https://git.openjdk.org/jdk/pull/28931#discussion_r2654080934
PR Review Comment: https://git.openjdk.org/jdk/pull/28931#discussion_r2654083865