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

Fix for issue #2302 - NativeLibraryLoader fails due to no write permissions #2303

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

terranprog
Copy link

This fixes an an issue I encountered while running a jmonkey application in Linux. #2302 - NativeLibraryLoader fails due to no write permissions.
The cause of the bug is a bit of an edge case, but it results in the native library not being extracted and the application not starting.

The main change I made is to extract the native library to a folder directly beneath the user temp folder, instead of using an intermediate tmp/jme subfolder. The reason for this is to avoid the scenario where the /tmp/jme folder is owned by one user and another user tries to write to it.
Note that this change is optional and I could modify the PR to not include it. We can still use /tmp/jme and fall back to calling setExtractionFolderToUserCache() if the /tmp/jme folder is not writable.

The other changes are to tighten the logic so the code will call setExtractionFolderToUserCache() instead of crashing.

  • Check the result of the call to mkdir. If it fails, call call setExtractionFolderToUserCache()
  • Check if the extraction folder is actually writable. If not, call setExtractionFolderToUserCache()
  • Updated log message: since a previous change we no longer extract to the working directory.

Some general notes about this PR:
I tried to limit the scope to only fix the immediate issue.
There are other issues with NativeLibraryLoader that this PR does not address

  • There are other places in NativeLibraryLoader where the result of mkdir is not checked.
  • It should potentially use mkdirs() instead of mkdir()

…o write permissions

Extract native library to a folder directly beneath the user temp folder. Do not use an intermediate /jme subfolder.
Check the result of the call to mkdir. Use UserCache if creation failed.
Check if the extraction folder is actually writable. If not use the UserCache.
Updated log message: since a previous change we no longer extract to the working directory.
@stephengold stephengold added the defect Something that is supposed to work, but doesn't. Less severe than a "bug" label Oct 28, 2024
@stephengold stephengold added this to the Future Release milestone Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something that is supposed to work, but doesn't. Less severe than a "bug"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants