Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KNOX-2469 - Fixing Knox keystore path directory creation for symlinks #383

Merged
merged 5 commits into from Nov 21, 2020

Conversation

jameschen1519
Copy link
Contributor

@jameschen1519 jameschen1519 commented Nov 15, 2020

(It is very important that you created an Apache Knox JIRA for this change and that the PR title/commit message includes the Apache Knox JIRA ID!)

What changes were proposed in this pull request?

This patch fixes a potential issue regarding the creation of Knox's keystores. The current logic checks to see if the keystore path exists--if it doesn't, it tries to create the parent folder of the keystore path. However, there is an edge case, as described in JDK-8130464, where the directory creation fails if the final, parent directory of the keystore path is a symlink. This causes a failure during startup. This PR remedies this by checking if the keystore parent directory exists instead of checking the keystore itself, as checking directories is symlink-safe. There is also no extra logic after the keystore creation, so if the keystore does exist, this turns into a no-op.
(Please fill in changes proposed in this fix)

How was this patch tested?

(Please explain how this patch was tested. For instance: running automated unit/integration tests, manual tests. Please write down your test steps as detailed as possible)
(If this patch involves UI changes, please attach a screen-shot; otherwise, remove this)

This PR was tested against an environment in which the keystore path's parent directory is a symlink on Knox 1.4.0. The tests that pass before this change pass after this change, locally.

One issue that may be worth noting is that this does not fix the case where some ancestor directory within the keystore path directory chain is an invalid symlink. If C:\a is a symlink to C:\b but C:\b does not exist, then the attempt to create C:\a\z will fail. However, depending on how we would like to do this, this might be a task best assigned to the users.

Please review Knox Contributing Process before opening a pull request.

@jameschen1519 jameschen1519 changed the title Fixing Knox symlink KNOX-2469- Fixing Knox keystore path directory creation for symlinks Nov 15, 2020
@smolnar82 smolnar82 changed the title KNOX-2469- Fixing Knox keystore path directory creation for symlinks KNOX-2469 - Fixing Knox keystore path directory creation for symlinks Nov 15, 2020
Copy link
Contributor

@lmccay lmccay left a comment

Choose a reason for hiding this comment

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

LGTM
+1

@lmccay lmccay merged commit 94b445e into apache:master Nov 21, 2020
@lmccay
Copy link
Contributor

lmccay commented Nov 21, 2020

@jameschen1519 - thank you for this contribution!
It will be included in the upcoming 1.5.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants