Skip to content

Commit

Permalink
8280357: user.home = "?" when running with systemd DynamicUser=true
Browse files Browse the repository at this point in the history
Reviewed-by: naoto, alanb
  • Loading branch information
Roger Riggs committed Feb 24, 2022
1 parent b6843a1 commit bf19fc6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/java.base/unix/native/libjava/java_props_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,16 @@ GetJavaProperties(JNIEnv *env)
#else
sprops.user_home = pwent ? strdup(pwent->pw_dir) : NULL;
#endif
if (sprops.user_home == NULL) {
sprops.user_home = "?";
if (sprops.user_home == NULL || sprops.user_home[0] == '\0' ||
sprops.user_home[1] == '\0') {
// If the OS supplied home directory is not defined or less than two characters long
// $HOME is the backup source for the home directory, if defined
char* user_home = getenv("HOME");
if ((user_home != NULL) && (user_home[0] != '\0')) {
sprops.user_home = user_home;
} else {
sprops.user_home = "?";
}
}
}

Expand Down

1 comment on commit bf19fc6

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.