Issue Details (XML | Word | Printable)

Key: DERBY-2673
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Daniel John Debrunner
Reporter: Daniel John Debrunner
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

If derby.system.home does not exist Derby should only attempt to create that specific folder, not any missing parents (ie. use File.mkdir(), not File.mkdirs())

Created: 18/May/07 08:00 PM   Updated: 30/Jun/09 12:14 AM
Return to search
Component/s: Services
Affects Version/s: 10.3.1.4
Fix Version/s: 10.3.1.4

Time Tracking:
Not Specified

Bug behavior facts: Security
Resolution Date: 18/May/07 10:11 PM


 Description  « Hide
Currently if the system property derby.system.home is set and the folder does not exist then derby will attempt to create the folder using File.mkdirs() on the value of derby.system.home.

This operation actually requires *read* permission on the parent directory (at least, maybe all folders in the path). E.g. when running the junit tests using ant:

 derby.system.home=/home/djd/derby/trunk/junit_20070518_1216/system

and thus read permission is required on the parent

 /home/djd/derby/trunk/junit_20070518_1216

The requirement to have this permission was added (I think) in JDK 1.5 and is intentional, see Sun bug 4932924

 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4932924

The testing policy file does not include this permission thus some of the tests fail when running using ant. [I think most tests pass because the driver gets loaded outside of the security manager, thus allowing the mkdirs() to succeed.]

I'm not sure that this permission should simply be added to the test policy file. This would mean that users would also have to add such an entry in their policy file. Of course the entry would need to be the explicit parent path, I don't think ${derby.system.home}${/}.. would be portable.
[actually

The reason for not adding it is that from a security point of view it expands the range of files Derby can read to be outside of the ${derby.system.home}. I think being able to encapsulate Derby's permissions to files under ${derby.system.home} is a better security model.

The simple change in Derby behaviour that seems to fix this is to change the mkdirs() to a mkdir(). The visible change to users would be that parent folder of derby.system.home must exist, previously Derby would have created all non-existent parent directories.

I think this is an acceptable change in behaviour for a security issue and unlikely to cause many issues for users.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kathey Marsden added a comment - 18/May/07 08:31 PM
The mkdirs() call in rg.apache.derby.impl.store.raw.RawStore.backup seems to be causing some of the Encryption failures in DERBY-2644. Is it reasonable to change this to mkdir() as well or would we expect to be able to create the parent directories.

Daniel John Debrunner added a comment - 18/May/07 08:55 PM
I would have thought that for databases under derby.system.home (which is the case in DERBY-2644) then intermediate folders should be created.
Especially since the permission failing is stack traces is granted to derby.jar by the testing policy file, thus something else is going on.

Knut Anders Hatlen added a comment - 18/May/07 09:10 PM
What about replacing file.mkdirs() with (file.mkdir() || file.mkdirs())? Wouldn't that preserve the old behaviour for those applications which need the parents to be created, and also remove the need for read permission if the parent directory exists?

Daniel John Debrunner added a comment - 18/May/07 09:34 PM
Interesting idea Knut Anders, I'll try it out.

Daniel John Debrunner added a comment - 18/May/07 10:00 PM
Knut Anders' cool trick will mean no change in behaviour. Thanks!

Daniel John Debrunner added a comment - 18/May/07 10:11 PM
Committed revision 539614 - patch with code as described by Knu Anders (plus comments).