Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true [v2]

2022-02-24 Thread Alan Bateman
On Wed, 23 Feb 2022 22:00:19 GMT, Roger Riggs  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.
>
> Roger Riggs has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   fallback to '?' for user.home if both the pw_dir and /Users/rriggs are not 
> valid

Marked as reviewed by alanb (Reviewer).

-

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


Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true [v2]

2022-02-23 Thread Roger Riggs
> 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.

Roger Riggs has updated the pull request incrementally with one additional 
commit since the last revision:

  fallback to '?' for user.home if both the pw_dir and /Users/rriggs are not 
valid

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/7534/files
  - new: https://git.openjdk.java.net/jdk/pull/7534/files/d67d2c44..ad7c0287

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=7534=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=7534=00-01

  Stats: 2 lines in 1 file changed: 2 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7534.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7534/head:pull/7534

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


Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true [v2]

2022-02-23 Thread Naoto Sato
On Wed, 23 Feb 2022 21:51:50 GMT, Roger Riggs  wrote:

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

Another option is an empty string `""`, but I don't have a strong preference if 
it won't throw any errors.

-

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


Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true [v2]

2022-02-23 Thread Naoto Sato
On Wed, 23 Feb 2022 22:00:19 GMT, Roger Riggs  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.
>
> Roger Riggs has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   fallback to '?' for user.home if both the pw_dir and /Users/rriggs are not 
> valid

Marked as reviewed by naoto (Reviewer).

-

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


Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true

2022-02-23 Thread Roger Riggs
On Wed, 23 Feb 2022 19:59:35 GMT, Naoto Sato  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


Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true

2022-02-23 Thread Naoto Sato
On Fri, 18 Feb 2022 15:29:34 GMT, Roger Riggs  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.

-

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


Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true

2022-02-23 Thread Roger Riggs
On Fri, 18 Feb 2022 15:29:34 GMT, Roger Riggs  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.

The CSR has been approved, please review the PR and the Release note: 
https://bugs.openjdk.java.net/browse/JDK-8282101

-

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


Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true

2022-02-18 Thread Alan Bateman
On Fri, 18 Feb 2022 16:15:18 GMT, Roger Riggs  wrote:

> I'm uncertain whether the fallback should only be done on Linux to cover the 
> `systemd` case and Docker.
> The need for a fallback seems less applicable on macOs, but since $HOME is 
> usually set to the same value, may be harmless.

I think what you have is okay because it is only used when getpwent doesn't 
return something useful. It would add complexity if you tried to limit it 
systemd or containers. I can't think of scenarios on macOS that might trigger 
the fallback, but it's not a bad fallback to have there too.

-

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


Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true

2022-02-18 Thread Roger Riggs
On Fri, 18 Feb 2022 15:29:34 GMT, Roger Riggs  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.

I'm uncertain whether the fallback should only be done on Linux to cover the 
`systemd` case and Docker.
The need for a fallback seems less applicable on macOs, but since $HOME is 
usually set to the same value, may be harmless.

-

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


Re: RFR: 8280357: user.home = "?" when running with systemd DynamicUser=true

2022-02-18 Thread Alan Bateman
On Fri, 18 Feb 2022 15:29:34 GMT, Roger Riggs  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.

There is an argument that the JDK should read $HOME first but changing it after 
20+ years could be risky, probably difficult to get a list of 
configurations/environments where the two might yield different locations. So I 
think the approach is reasonable. Even if "/" were a configured as the home 
directory in the user entry then $HOME would need to agree so that I think the 
<2 check is okay too.

-

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