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

Modified the NodeInstaller to use a custom method for copying files c… #668

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

Conversation

marcajimenez
Copy link

…opyDirectoryContents() rather than using the FileUtils.copyDirectory() which does not preserve file attributes. Also modified the ArchiveExtractor class to use a umask of 0001 when checking to set execute permission on files being unpacked.

Summary

We recently upgraded the version of Node for our webapp application to 6.11.3 and when using the frontend-maven-plugin to help with installation we ran into a permission error at build time. Several scripts included in the Node 6.11.3 archive which should have execute permission were not longer set to executable after the plugin's lifecycle. This fix is meant to cover this issue posted: #667

The root cause of the issue was in the plugin's use of FileUtils.copyDirectory which does not preserve File attributes. To fix this issue I have implemented a new method to copyDirectory contents which is used instead of the FileUtils method.

We have tested the fix on our local developer machines and jenkins machine and have confirmed that our Node installation has all of the correct permissions now.

…opyDirectoryContents() rather than using the FileUtils.copyDirectory() which does not preserve file attributes. Also modified the ArchiveExtractor class to use a umask of 0001 when checking to set execute permission on files being unpacked.
@eirslett
Copy link
Owner

Is it possible to do this with the native Java API? https://stackoverflow.com/questions/6838221/how-to-preserve-file-permissions-when-using-fileutils-copydirectory
I haven't looked much into it.

@marcajimenez
Copy link
Author

I came across the same article and this is what I used to implement the copyDirectory function. The limitation of Files.copy() api is that it only copies a target file or directory but not the contents of a directory.

https://docs.oracle.com/javase/tutorial/essential/io/copy.html

My copyDirectory function will use Files.copy as it recurses the directory and sub-directories copying all contents.

@eirslett
Copy link
Owner

Ah ok, I see.

  1. Maybe move that function into its own file, as a utility class with a static method in it?
  2. Is it possible to shoehorn a test case into one of the integration test cases, to verify that permissions etc are correct?
  3. Looks like the Travis build is failing :-/

@marcajimenez
Copy link
Author

Shouldn't be a problem to add a test, and I'll move it to it's own file. I should be able to get to that early this week.

Also created an integration test called UtilsIT.java

Modified the pom.xml to include the use of profiles on unix or mac which
will activate and run the integration test which will test the
copyDirectoryContents method and validate that all file permisisons are
correct using the maven-failsafe-plugin.
@thombaynes
Copy link

I've also run into this issue. I am unable to run jest tests with Node 8.9.3 and npm 5.5.1.

[INFO] > [email protected] basicTests /Users/thombaynes/Projects/Development/design/target/test-classes [INFO] > jest --config=./config/basicConfig.json --forceExit; exit 0 [INFO] [ERROR] sh: /Users/thombaynes/Projects/Development/design/target/test-classes/node_modules/.bin/jest: Permission denied

@rjimgal
Copy link

rjimgal commented May 8, 2018

Is there anything preventing this PR to be merged? I've come across this issue as well, and I'm happy to help if needed.

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

Successfully merging this pull request may close these issues.

None yet

4 participants