United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-7199674 : (props) user.home property does not return an accessible location in sandboxed environment [macosx]

Details
Type:
Enhancement
Submit Date:
2012-09-19
Status:
Closed
Updated Date:
2014-09-04
Project Name:
JDK
Resolved Date:
2013-09-13
Component:
core-libs
OS:
os_x
Sub-Component:
java.lang
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
7u8
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
On Mac OS X we obtain the path for user.home with getpwuid(). Normally this will return /Users/<username>. However, if an application is signed and running in an OS X sandboxed environment this path is not accessible to the application, which must run in a container. In that case user.home should return the application's sandbox directory.

The easy way to fix this is use NSHomeDirectory(), which does the right thing in a sandboxed or non-sandboxed environment. Likewise, NSUserName() is a better choice for getting the current user name.

                                    

Comments
Moved the NSUserName() change into its own bug, JDK-8024357.

                                     
2013-09-05
Webrev is at http://cr.openjdk.java.net/~bchristi/7199674/

I have confirmed that this works as expected under the Mac App Sandbox.  I created test case, bundled it as a Mac .app, and signed it with the "com.apple.security.app-sandbox" entitlement.  When the signed app is run, my usual home directory is reported as !File.canRead(), and the user.home property returns a path under ~/Library/Containers/, which is readable.

                                     
2013-09-05
Attached my notes on how to setup testing.
                                     
2013-09-05
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/5f81a12fed4d
User:  mduigou
Date:  2013-09-13 19:03:10 +0000

                                     
2013-09-13
noreg-hard: Testing requires signing of the .app so it will run in the Mac Sandbox.  This would require keychain pre-setup for any Mac to successfully run the test.

                                     
2013-09-16
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/5f81a12fed4d
User:  lana
Date:  2013-09-18 00:31:25 +0000

                                     
2013-09-18
SQE is ok to take the fix in 7u60.
                                     
2014-01-27



Hardware and Software, Engineered to Work Together