Bug 563697 - Regression in canWrite() for location where access cannot be determined
Summary: Regression in canWrite() for location where access cannot be determined
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Launcher (show other bugs)
Version: 4.15   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: 4.17 M3   Edit
Assignee: Mikael Sterner CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-05-29 02:50 EDT by Mikael Sterner CLA
Modified: 2020-07-27 09:59 EDT (History)
4 users (show)

See Also:


Attachments
Patch that reintroduces old test as fallback (1.18 KB, patch)
2020-05-29 02:50 EDT, Mikael Sterner CLA
no flags Details | Diff
Screenshot of error message (4.68 KB, image/png)
2020-05-29 02:52 EDT, Mikael Sterner CLA
no flags Details
Screenshot of creating a secretive folder, Properties window (22.81 KB, image/png)
2020-05-29 02:53 EDT, Mikael Sterner CLA
no flags Details
Screenshot of creating a secretive folder, changing owner (43.61 KB, image/png)
2020-05-29 02:53 EDT, Mikael Sterner CLA
no flags Details
Screenshot of creating a secretive folder, denying reading permissions (33.47 KB, image/png)
2020-05-29 02:54 EDT, Mikael Sterner CLA
no flags Details
Screenshot of creating a secretive folder, Advanced window end-result (35.05 KB, image/png)
2020-05-29 02:55 EDT, Mikael Sterner CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mikael Sterner CLA 2020-05-29 02:50:39 EDT
Created attachment 283070 [details]
Patch that reintroduces old test as fallback

The fix for bug 558612 seems to have caused a regression when the configuration is in a location which is writable but for which access cannot be determined by Files.isWritable(). For such locations, Files.isWritable() is documented to return false, which the new code falsely assumes to mean that write access would be denied.

Repeat on Windows:
1. Create a folder C:\tmp\secretivefolder where reading permissions is denied*.
2. Launch (4.15+) eclipse.exe -configuration C:/tmp/secretivefolder
3. Note that an error message about write access appears

Expected: The launcher should happily accept this secretive location, like earlier versions do (e.g. 4.7.2).

*One way to create a secretive folder:
1. Go into "Properties" and click "Advanced"
2. Change the owner to someone else, e.g. the local "Administrators" group (since if you own the folder yourself, you can always read permissions)
3. Add an explicit deny rule for yourself for "Read permissions"
4. Apply

Of course, the regression wasn't noticed by creating strange permissions like this but rather because of the configuration location being in a home directory on a Samba file share that apparently effectively was secretive about its permissions.

I have attached the fix I applied locally. With this fix, canWrite() still uses Files.isWritable() as an early exit opportunity when it returns true, for which its documentation is less ambiguous, but after that it also tries the old algorithm from before the fix for bug 558612.

I believe that the proposed fix strikes a good balance between keeping the behavior of the fix for bug 558612 for 99% of all cases, but still not regressing in which configuration locations are accepted (and also being true to the letter of the Files.isWritable() documentation). I.e. if your folder is secretive about its permissions, you'll have to live with Eclipse creating a file inside it to find out for itself. Notably, if Files.isWritable() returns false due to the folder actually not being writable (also 99% of such cases), trying to write into it shouldn't do any harm since it will fail.

PS. The code brought back from the dead contains a comment that was questioned in bug 5444263, and a spelling error ("writtable"). I didn't touch either to make it clear that it's a revert, but maybe now is a good chance to sneak in a correction/clarification.
Comment 1 Mikael Sterner CLA 2020-05-29 02:52:03 EDT
Created attachment 283071 [details]
Screenshot of error message
Comment 2 Mikael Sterner CLA 2020-05-29 02:53:05 EDT
Created attachment 283072 [details]
Screenshot of creating a secretive folder, Properties window
Comment 3 Mikael Sterner CLA 2020-05-29 02:53:49 EDT
Created attachment 283073 [details]
Screenshot of creating a secretive folder, changing owner
Comment 4 Mikael Sterner CLA 2020-05-29 02:54:24 EDT
Created attachment 283074 [details]
Screenshot of creating a secretive folder, denying reading permissions
Comment 5 Mikael Sterner CLA 2020-05-29 02:55:09 EDT
Created attachment 283075 [details]
Screenshot of creating a secretive folder, Advanced window end-result
Comment 6 Andrey Loskutov CLA 2020-05-29 04:00:07 EDT
@Mickael, can you please sign ECA (click on the red badge next to your name) and push a Gerrit? It is not allowed to accept patches from contributions without ECA.
Comment 7 Thomas Watson CLA 2020-05-29 08:50:42 EDT
Should fix in 4.17 now that we are in our final RC for 4.16.
Comment 8 Eclipse Genie CLA 2020-05-29 09:13:40 EDT
New Gerrit change created: https://git.eclipse.org/r/163842
Comment 9 Mikael Sterner CLA 2020-05-29 10:00:53 EDT
Sorry for the newbie question, but should I interpret the failed gerrit build as it being my responsibility to update the manifest version of org.eclipse.equinox.launcher in my commit?

[ERROR] Failed to execute goal org.eclipse.tycho.extras:tycho-p2-extras-plugin:1.7.0:compare-version-with-baselines (compare-attached-artifacts-with-release) on project org.eclipse.equinox.launcher: Only qualifier changed for (org.eclipse.equinox.launcher/1.5.700.v20200529-1312). Expected to have bigger x.y.z than what is available in baseline (1.5.700.v20200207-2156) -> [Help 1]
Comment 10 Andrey Loskutov CLA 2020-05-29 10:36:44 EDT
(In reply to Mikael Sterner from comment #9)
> Sorry for the newbie question, but should I interpret the failed gerrit
> build as it being my responsibility to update the manifest version of
> org.eclipse.equinox.launcher in my commit?

Exact, additionally also pom.xml where the same version must be updated too. Please note, that we are in RC2 period, so no merges are planned except you have a really good reason and project lead approves. So expect the patch to be reviewed / merged for 4.17.
Comment 11 Thomas Watson CLA 2020-05-29 10:39:41 EDT
(In reply to Mikael Sterner from comment #9)
> Sorry for the newbie question, but should I interpret the failed gerrit
> build as it being my responsibility to update the manifest version of
> org.eclipse.equinox.launcher in my commit?

For a newbie you were quick to get the gerrit going!  Thanks for the contribution we should be able to get this in for early 4.17 M1.
Comment 12 Mikael Sterner CLA 2020-05-29 10:59:08 EDT
Thanks, I have updated my submission. Targeting 4.17 is completely fine with me.
Comment 13 Thomas Watson CLA 2020-07-09 08:29:24 EDT
Apologies for not getting this in for M1.  I will release a fix as soon as M1 is done this week.  We do need the same fix in org.eclipse.osgi.storage.StorageUtil.canWrite(File)
Comment 15 Thomas Watson CLA 2020-07-27 09:59:06 EDT
Will be in the next milestone.