From: <pj...@us...> - 2009-03-14 23:21:51
|
Revision: 6095 http://jython.svn.sourceforge.net/jython/?rev=6095&view=rev Author: pjenvey Date: 2009-03-14 23:21:30 +0000 (Sat, 14 Mar 2009) Log Message: ----------- o gracefully handle a System.getenv SecurityException on startup o grant more permissions needed for test_java_integration's test_nonexistent_import_with_security Modified Paths: -------------- trunk/jython/Lib/test/python_home.policy trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/jython/Lib/test/python_home.policy =================================================================== --- trunk/jython/Lib/test/python_home.policy 2009-03-13 01:33:46 UTC (rev 6094) +++ trunk/jython/Lib/test/python_home.policy 2009-03-14 23:21:30 UTC (rev 6095) @@ -1,5 +1,8 @@ grant codeBase "file:${python.home}/-" { + permission java.io.FilePermission "<<ALL FILES>>", "read,write"; + permission java.lang.RuntimePermission "accessDeclaredMembers"; + permission java.lang.RuntimePermission "createClassLoader"; + permission java.lang.RuntimePermission "getProtectionDomain"; permission java.util.PropertyPermission "*", "read,write"; - permission java.io.FilePermission "<<ALL FILES>>", "read,write"; }; Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-03-13 01:33:46 UTC (rev 6094) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-03-14 23:21:30 UTC (rev 6095) @@ -400,12 +400,18 @@ } /** - * Initialize the environ dict from System.getenv. - * + * Initialize the environ dict from System.getenv. environ may be empty when the + * security policy doesn't grant us access. */ public void initEnviron() { environ = new PyDictionary(); - for (Map.Entry<String, String> entry : System.getenv().entrySet()) { + Map<String, String> env; + try { + env = System.getenv(); + } catch (SecurityException se) { + return; + } + for (Map.Entry<String, String> entry : env.entrySet()) { environ.__setitem__(Py.newString(entry.getKey()), Py.newString(entry.getValue())); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |