|
Here's a tested policy file for the example in http://db.apache.org/derby/docs/dev/adminguide/tadminnetservrun.html .
(1) nsrv.policy file: //Recommended set of permissions to start and use the Network Server, //assuming the 'd:/derby/lib' directory has been secured. //Fine tune based on your environment settings grant codeBase "file:d:/derby/lib/-" { permission java.io.FilePermission "${derby.system.home}", "read"; permission java.io.FilePermission "${derby.system.home}${/}-", "read, write, delete"; permission java.io.FilePermission "${user.dir}${/}-", "read, write, delete"; permission java.util.PropertyPermission "derby.*", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.lang.RuntimePermission "createClassLoader"; permission java.net.SocketPermission "localhost", "accept"; }; //Required set of permissions to stop the Network Server, assuming you have // secured the 'd:/derby/lib' directory //Remember to fine tune this as per your environment. grant codeBase "file:d:/derby/lib/-" { //Following is required when server is started with "-h localhost" //or without the -h option permission java.net.SocketPermission "localhost", "accept, connect,resolve"; permission java.net.SocketPermission "127.0.0.1", "accept, connect,resolve"; //The following is only required if the server is started with the -h <host> //option (else shutdown access will be denied). permission java.net.SocketPermission "localhost:*", "accept, connect,resolve"; }; (2) Start the network server using this policy file: java -Djava.security.manager -Djava.security.policy=d:/nsrv.policy org.apache.derby.drda.NetworkServerControl start (3) Here's a simple example that shows how the policy restricts where users can create a new database. The user can create a database in the default derby system home: ij> connect 'jdbc:derby://localhost:1527/MyDbTest;create=true'; The user is prevented from creating a database in another location: ij> connect 'jdbc:derby://localhost:1527//BadTst;create=true'; ERROR XJ040: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ040, SQLERRMC: Failed to start database '/BadTst', see the next exception for details.::SQLSTATE: XJ00 1Java exception: 'access denied (java.io.FilePermission C:\BadTst\service.properties read): java.security.AccessControlException'. Attached patch applies the requested change to the three Java 2 security policy file examples as requested. HTML files are included for review.
Attached patch addresses changes to both the Server Gd. and to the Dev. Gd. HTML files are included for review.
Patch derby701-2.diff looks good -- and I actually ran the network server example to make sure it works. Committed to the trunk, revision 374798. Modified files:
$ svn status M src/adminguide/tadminnetservrun.dita M src/devguide/rdevcsecure871406.dita M src/devguide/rdevcsecure871439.dita M src/devguide/rdevcsecure871422.dita Reopen to merge fix to 10.1.3.
Fix merged from 10.2, committed revision 397015.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
http://db.apache.org/derby/docs/dev/adminguide/tadminnetservrun.html