| Summary: | Copied resources have user only access rights (-rw-------) instead of group (-rw-rw-r--) like classes | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Laurent Chaply <chaply> | ||||
| Component: | Resources | Assignee: | Szymon Brandys <Szymon.Brandys> | ||||
| Status: | RESOLVED DUPLICATE | QA Contact: | |||||
| Severity: | major | ||||||
| Priority: | P3 | CC: | jamesblackburn+eclipse, Olivier_Thomann, ppdkseth222, richardfearn, sptaszkiewicz, Szymon.Brandys | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Laurent Chaply
The builder is using: org.eclipse.core.resources.IResource.copy(IPath, int, IProgressMonitor) to copy resources. So the problem might come from the underlying resource layer. Moving to Platform/Resources for comment. Note that I could not reproduce myself as I don't have access to a Linux box right now. (In reply to comment #0) When a build is performed, Java files from the source directory are built and appropriate class files are created in the target directory. For newly created files Umask is used to set the attributes. I guess that Umask on your machine is -rw-rw-r--. What do you mean by 'resources are copied from source directory to target directory'? Do you copy them manually? And how do you create files in your source directory. Can you explain that? (In reply to comment #2) > What do you mean by 'resources are copied from source directory to target > directory'? Do you copy them manually? The Java builder copies all non ".java" resources directly from the source to the target directory. As Olivier says they just use the IResource API to perform that copying. (In reply to comment #3) > The Java builder copies all non ".java" resources directly from the source to > the target directory. As Olivier says they just use the IResource API to > perform that copying. Thanks John. It was not clear for me from the Olivier's comment. Laurent, could you explain how you create files in your source directory? Do you change their access rights before the build is performed? Hi, I did the test again: Fresh install of eclipse helios (unpacked from eclipse.org jar as root in /opt/eclipse/helios, and ran with standard user "laurent") Fresh workspace in /home/laurent/workspace New -> Java project TestProject In src, new -> file test.properties It's copied automatically in bin which is the default target directory. ls -al /home/laurent/workspace/TestProject/bin/test.properties -rw------- 1 laurent laurent 0 2010-09-06 10:48 /home/laurent/workspace/TestProject/bin/test.properties Exact same test with Galileo (installed the same way as helios: unpacked from eclipse.org jar as root in /opt/eclipse/galileo, and ran with same standard user "laurent") in a new fresh workspace workspace2 ls -al /home/laurent/workspace2/TestProject/bin/test.properties -rw-rw-r-- 1 laurent laurent 0 2010-09-06 10:56 /home/laurent/workspace2/TestProject/bin/test.properties Regards, Laurent (In reply to comment #4) > (In reply to comment #3) > > The Java builder copies all non ".java" resources directly from the source to > > the target directory. As Olivier says they just use the IResource API to > > perform that copying. > > Thanks John. It was not clear for me from the Olivier's comment. > > Laurent, could you explain how you create files in your source directory? Do > you change their access rights before the build is performed? I reproduced this on: - Linux 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux Distributor ID: Ubuntu Description: Ubuntu 9.10 Release: 9.10 Codename: karmic - Helios Service Release 1, according to About box, Build id=20100917-0705, according to Configuration Details->Configuration, eclipse.buildId=M20100909-0800 - java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Oracle JRockit(R) (build R28.0.1-21-133393-1.6.0_20-20100512-2126-linux-ia32, compiled mode) - libgtk 2.18.3-1ubuntu2.2 - umask 0022 It seems that this issue applies only to files (resources, not source files) that are automatically copied to the output directory as part of the build process. If i manually copy a file through the Navigator, using Copy & Paste, the destination's permissions are right (i.e. same as the source). Created attachment 188520 [details]
Proposed fix for this bug
I traced the problem into JDT's AbstractImageBuilder and specifically into this method:
protected void copyResource(IResource source, IResource destination) throws CoreException {
IPath destPath = destination.getFullPath();
try {
source.copy(destPath, IResource.FORCE | IResource.DERIVED, null);
} catch (CoreException e) {
// handle the case when the source resource is deleted
source.refreshLocal(0, null);
if (!source.exists()) return; // source resource was deleted so skip it
throw e;
}
Util.setReadOnly(destination, false); // just in case the original was read only
}
What happens is that after copying the file (including its filesystem attributes), for some unknown reason ("just in case the original was read only") we overwrite them by using Util.setReadOnly(..)
I attached a patch/fix, i believe it's appropriate.
. *** This bug has been marked as a duplicate of bug 323681 *** |