Skip to content

Conversation

@sashamatveev
Copy link
Member

@sashamatveev sashamatveev commented Apr 30, 2025

  • Symbolic links will not be followed for --app-content on all platforms.
  • Added test to cover this case.
  • MacHelper updated to use "cp -R" instead of "cp -r" when unpacking DMG, since "cp -r" on macOS is not documented option and when used cp will follow symbolic links which breaks test. "cp -R" does not follow symbolic links.

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8352480: Don't follow symlinks in additional content for app images (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24974/head:pull/24974
$ git checkout pull/24974

Update a local copy of the PR:
$ git checkout pull/24974
$ git pull https://git.openjdk.org/jdk.git pull/24974/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24974

View PR using the GUI difftool:
$ git pr show -t 24974

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24974.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 30, 2025

👋 Welcome back almatvee! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 30, 2025

@sashamatveev This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8352480: Don't follow symlinks in additional content for app images

Reviewed-by: asemenyuk

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 56 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 30, 2025
@openjdk
Copy link

openjdk bot commented Apr 30, 2025

@sashamatveev The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Apr 30, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 30, 2025

Webrevs

@alexeysemenyukoracle
Copy link
Member

I don't like the idea of changing behavior on only one platform. It should be consistent across all platforms. Let's not follow symlinks on other platforms, either.

@sashamatveev sashamatveev changed the title 8352480: [macos] Don't follow symlinks in additional content for app images 8352480: Don't follow symlinks in additional content for app images Apr 30, 2025
* --jpt-run=AppContentTest
*/
public class AppContentTest {

Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: do you think it might be worth it to add a bug id to the @test?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. I do not see a need. This is a generic test and not something specific to particular JBS issue.

@sashamatveev sashamatveev marked this pull request as draft May 6, 2025 21:44
@openjdk openjdk bot removed the rfr Pull request is ready for review label May 6, 2025
@sashamatveev sashamatveev marked this pull request as ready for review May 7, 2025 01:28
@openjdk openjdk bot added the rfr Pull request is ready for review label May 7, 2025
@sashamatveev
Copy link
Member Author

I don't like the idea of changing behavior on only one platform. It should be consistent across all platforms. Let's not follow symlinks on other platforms, either.

Fix is updated not to follow links on all platforms. Test is updated as well.

Path contentDir = cmd.appLayout().contentDirectory();
if (copyInResources) {
return contentDir.resolve("Resources");
// Links are always created in "Resources"

Choose a reason for hiding this comment

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

Links are always created in "Resources"

All additional content on macOS is created in the "Resources" directory. On Linux there is no such requirement.

The return value of getAppContentPath() is not supposed to depend on the additional content type; the new "name" parameter doesn't make sense to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

For links we creating link and corresponding text file, so for it we should put both files into folder and add it to --app-content app-content-0/Resources. Note app-content-0 is temp folder with random name and if we using it directly we end up copying app-content-0 into application bundle. In such case it will not be possible to figure out location of link without putting it under known folder name such as "Resources".

"name" is to figure out if it link and if link it should be under "Resources".

Choose a reason for hiding this comment

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

I can see you reverted the getAppContentPath() back. I guess it happened after your comment :)

Path appContentArg = TKit.createTempDirectory("app-content").resolve("Resources");
var srcPath = TKit.TEST_SRC_ROOT.resolve(appContentPath);
var dstPath = appContentArg.resolve(srcPath.getFileName());
Path dstPath = appContentArg.resolve(srcPath.getFileName());

Choose a reason for hiding this comment

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

This is a redundant change

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.


private static Path copyAppContentPath(Path appContentPath) throws IOException {
var appContentArg = TKit.createTempDirectory("app-content").resolve("Resources");
Path appContentArg = TKit.createTempDirectory("app-content").resolve("Resources");

Choose a reason for hiding this comment

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

This is a redundant change

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

private static List<Path> initAppContentPaths(List<Path> appContentPaths) {
if (copyInResources) {
boolean copy = (copyInResources || appContentPaths.stream()
.anyMatch(s -> s.toString().contains("Link")));

Choose a reason for hiding this comment

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

s.toString().contains("Link") is a lousy way to detect if the path is a symlink. "s" can be an absolute path (to the local OpenJDK repo) that may have a "Link" substring in one of path components, like "/home/BLink/my-projects/open/test/jdk/tools/jpackage/non-existant". The test will fail, and we will have a very hard time figuring out the cause. I'd fix it by narrowing the scope from the full path to the filename; create a dedicated function for detecting if the given path is supposed to be a symlink instead of repeating .toString().contains("Link"):

private static boolean isSymlinkPath(Path v) {
    return v.getFileName().toString().contains("Link");
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@sashamatveev
Copy link
Member Author

8352480: [macos] Don't follow symlinks in additional content for app images [v6]

  • Fixed latest comments.
  • Link will be created under "Links" folder to avoid confusion with reusing "Resources"
  • Link creation moved under separate function createAppContentLink from copyAppContentPath to avoid confusion.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 9, 2025
@sashamatveev
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented May 9, 2025

Going to push as commit 601f05e.
Since your change was applied there have been 71 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 9, 2025
@openjdk openjdk bot closed this May 9, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 9, 2025
@openjdk
Copy link

openjdk bot commented May 9, 2025

@sashamatveev Pushed as commit 601f05e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants