提交 06feee38 编写于 作者: B bchristi

7199674: (props) user.home property does not return an accessible location in...

7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
Summary: On MacOS X set user.home to value of NSHomeDirectory()
Reviewed-by: alanb, ddehaven, mduigou
上级 1d3245a3
......@@ -397,12 +397,10 @@ else
INCLUDE_SA = true
endif
ifdef CROSS_COMPILE_ARCH
# X11 headers are not under /usr/include
OTHER_CFLAGS += -I$(OPENWIN_HOME)/include
OTHER_CXXFLAGS += -I$(OPENWIN_HOME)/include
OTHER_CPPFLAGS += -I$(OPENWIN_HOME)/include
endif
# X11 headers are not under /usr/include
OTHER_CFLAGS += -I$(OPENWIN_HOME)/include
OTHER_CXXFLAGS += -I$(OPENWIN_HOME)/include
OTHER_CPPFLAGS += -I$(OPENWIN_HOME)/include
LIB_LOCATION ?= $(LIBDIR)
......
......@@ -105,6 +105,7 @@ FILES_java += java/util/prefs/MacOSXPreferences.java \
java/util/prefs/MacOSXPreferencesFactory.java
CFLAGS_$(VARIANT)/java_props_md.o = -Os -x objective-c
CFLAGS_$(VARIANT)/java_props_macosx.o = -Os -x objective-c
endif
#
......
......@@ -211,6 +211,7 @@ ifneq ($(OPENJDK_TARGET_OS),macosx)
LIBJAVA_EXCLUDE_FILES += java_props_macosx.c
else
BUILD_LIBJAVA_java_props_md.c_CFLAGS:=-x objective-c
BUILD_LIBJAVA_java_props_macosx.c_CFLAGS:=-x objective-c
endif
ifeq ($(OPENJDK_TARGET_OS),windows)
......@@ -252,6 +253,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA,\
LDFLAGS_SUFFIX_linux:=$(LIBDL) $(BUILD_LIBFDLIBM),\
LDFLAGS_SUFFIX_macosx:=-L$(JDK_OUTPUTDIR)/objs/ -lfdlibm \
-framework CoreFoundation \
-framework Foundation \
-framework Security -framework SystemConfiguration, \
LDFLAGS_SUFFIX_windows:=-export:winFileHandleOpen -export:handleLseek \
jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
......
......@@ -31,6 +31,7 @@
#include <Security/AuthSession.h>
#include <CoreFoundation/CoreFoundation.h>
#include <SystemConfiguration/SystemConfiguration.h>
#include <Foundation/Foundation.h>
#include "java_props_macosx.h"
......@@ -271,9 +272,20 @@ static char * createConvertedException(CFStringRef cf_original) {
return c_exception;
}
/*
* Method for fetching the user.home path and storing it in the property list.
* For signed .apps running in the Mac App Sandbox, user.home is set to the
* app's sandbox container.
*/
void setUserHome(java_props_t *sprops) {
if (sprops == NULL) { return; }
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
sprops->user_home = createUTF8CString((CFStringRef)NSHomeDirectory());
[pool drain];
}
/*
* Method for fetching proxy info and storing it in the propery list.
* Method for fetching proxy info and storing it in the property list.
*/
void setProxyProperties(java_props_t *sProps) {
if (sProps == NULL) return;
......
......@@ -27,6 +27,7 @@
char *setupMacOSXLocale(int cat);
void setOSNameAndVersion(java_props_t *sprops);
void setUserHome(java_props_t *sprops);
void setProxyProperties(java_props_t *sProps);
enum PreferredToolkit_enum {
......
......@@ -591,7 +591,14 @@ GetJavaProperties(JNIEnv *env)
{
struct passwd *pwent = getpwuid(getuid());
sprops.user_name = pwent ? strdup(pwent->pw_name) : "?";
sprops.user_home = pwent ? strdup(pwent->pw_dir) : "?";
#ifdef MACOSX
setUserHome(&sprops);
#else
sprops.user_home = pwent ? strdup(pwent->pw_dir) : NULL;
#endif
if (sprops.user_home == NULL) {
sprops.user_home = "?";
}
}
/* User TIMEZONE */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册