On Wed, 23 Feb 2022 19:59:35 GMT, Naoto Sato <na...@openjdk.org> wrote:

>> In some Linux configurations, the Linux home directory provided by getpwent 
>> is not usable.
>> The value of the system property `user.home` should fallback to the value of 
>> $HOME 
>> if getpwent.user_home is null or less that 2 characters long. "/" is not a 
>> valid home directory name.
>> 
>> If $HOME is undefined or empty, the value of the getpwent.user_home is 
>> retained.
>> 
>> There are more details in the Jira issue: 
>> https://bugs.openjdk.java.net/browse/JDK-8280357
>> 
>> The fix has been tested manually on Ubuntu 20.0.4 using the suggested 
>> systemd command line and variations.
>
> src/java.base/unix/native/libjava/java_props_md.c line 498:
> 
>> 496:             if ((user_home != NULL) && (user_home[0] != '\0')) {
>> 497:                 sprops.user_home = user_home;
>> 498:             }
> 
> Is there any possibility where `user.home` is not initialized, and later 
> causes SEGV or NPE? I just wonder the previous version always init to `?` 
> which is odd, but guaranteed not to cause those errors.

I can't imagine it not being set. But it is easier to track down the source of 
a "?" than the source of null.
I thought of changing from "?" to "UNKNOWN" or "NOHOMEDIR" or something but it 
seems quite remote
after adding the fallback to $HOME.

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

PR: https://git.openjdk.java.net/jdk/pull/7534

Reply via email to