author | Tellen Yu <tellen.yu@amlogic.com> | 2016-10-12 10:24:04 (GMT) |
---|---|---|
committer | Gerrit Code Review <gituser@scgit.amlogic.com> | 2016-10-12 10:24:05 (GMT) |
commit | 77c1c39a85f7a6e31f07c48f9c4af9cd33fdc411 (patch) | |
tree | 2941af96b271600c9f942d090fb137f53f63c489 | |
parent | 2720a402cea4de9836e4f46ef6f10033b57dc212 (diff) | |
parent | acecf5c3c5f3bf1cc137276db985909791f743e1 (diff) | |
download | pppoe-77c1c39a85f7a6e31f07c48f9c4af9cd33fdc411.zip pppoe-77c1c39a85f7a6e31f07c48f9c4af9cd33fdc411.tar.gz pppoe-77c1c39a85f7a6e31f07c48f9c4af9cd33fdc411.tar.bz2 |
Merge "PD#132499:fix pppoe selinux error" into n-amlogic
-rw-r--r-- | Android.mk | 10 | ||||
-rw-r--r-- | jni/src/netwrapper.c | 18 |
2 files changed, 15 insertions, 13 deletions
@@ -29,10 +29,10 @@ LOCAL_SRC_FILES := jni/src/pppoe.c \ jni/src/discovery.c \ jni/src/netwrapper.c #LOCAL_C_INCLUDES := $(KERNEL_HEADERS) -LOCAL_C_INCLUDES += external/selinux/libselinux/include/ \ +#LOCAL_C_INCLUDES += external/selinux/libselinux/include/ \ external/selinux/libselinux/src -LOCAL_SHARED_LIBRARIES := libcutils +LOCAL_SHARED_LIBRARIES := libcutils libselinux LOCAL_MODULE = pppoe LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := -DVERSION=$(PPPOE_VERSION) @@ -53,7 +53,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES += libandroid_runtime libnativehelper LOCAL_SHARED_LIBRARIES += libc libcutils libnetutils LOCAL_C_INCLUDES := $(JNI_H_INCLUDE) $(LOCAL_PATH)/jni/src -LOCAL_C_INCLUDES += external/selinux/libselinux/include/ \ +#LOCAL_C_INCLUDES += external/selinux/libselinux/include/ \ external/selinux/libselinux/src LOCAL_MODULE_TAGS := optional LOCAL_MODULE := libpppoejni @@ -66,7 +66,7 @@ LOCAL_SRC_FILES:= jni/src/pppoe_cli.c \ jni/src/common.c \ jni/src/netwrapper.c -LOCAL_C_INCLUDES += external/selinux/libselinux/include/ \ +#LOCAL_C_INCLUDES += external/selinux/libselinux/include/ \ external/selinux/libselinux/src LOCAL_MODULE_TAGS := optional @@ -85,7 +85,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/include -LOCAL_C_INCLUDES += external/selinux/libselinux/include/ \ +#LOCAL_C_INCLUDES += external/selinux/libselinux/include/ \ external/selinux/libselinux/src LOCAL_CFLAGS := -DANDROID_CHANGES diff --git a/jni/src/netwrapper.c b/jni/src/netwrapper.c index dd62e65..518fe9f 100644 --- a/jni/src/netwrapper.c +++ b/jni/src/netwrapper.c @@ -37,8 +37,10 @@ #include <cutils/properties.h> #include <sys/un.h> -#include <selinux/label.h> //#include <selinux/label_internal.h> +#include <selinux/selinux.h> +#include <selinux/label.h> +#include <selinux/android.h> #include <cutils/sockets.h> @@ -80,7 +82,7 @@ struct netwrapper_ctrl * netwrapper_ctrl_open int tries = 0; struct stat buf; uid_t uid,euid; - //sehandle = selinux_android_file_context_handle(); + sehandle = selinux_android_file_context_handle(); ctrl = malloc(sizeof(*ctrl)); if (ctrl == NULL) return NULL; @@ -88,8 +90,8 @@ struct netwrapper_ctrl * netwrapper_ctrl_open ctrl->s = socket(PF_UNIX, SOCK_DGRAM, 0); if (ctrl->s < 0) { - free(ctrl); - return NULL; + free(ctrl); + return NULL; } ctrl->local.sun_family = AF_UNIX; @@ -104,11 +106,11 @@ try_again: tries++; ret = unlink(ctrl->local.sun_path); if (ret != 0 && errno != ENOENT) { - __android_log_print(ANDROID_LOG_INFO, LOCAL_TAG,"Failed to unlink old socket : %s\n",strerror(errno)); + __android_log_print(ANDROID_LOG_ERROR, LOCAL_TAG,"Failed to unlink old socket : %s\n",strerror(errno)); } filecon = NULL; if (0 == stat(ctrl->local.sun_path , &buf)) - __android_log_print(ANDROID_LOG_INFO, LOCAL_TAG,"stat sun path filed"); + __android_log_print(ANDROID_LOG_INFO, LOCAL_TAG,"stat sun path filed"); if (bind(ctrl->s, (struct sockaddr *) &ctrl->local, sizeof(ctrl->local)) < 0) { if (errno == EADDRINUSE && tries < 2) { @@ -135,7 +137,7 @@ try_again: free(ctrl); return NULL; } - __android_log_print(ANDROID_LOG_INFO, LOCAL_TAG,"%s: error: %d\n", __FUNCTION__, chmod(ctrl->dest.sun_path, 0x777)); + __android_log_print(ANDROID_LOG_ERROR, LOCAL_TAG,"%s: error: %d sun_path: %s\n", __FUNCTION__, chmod(ctrl->dest.sun_path, 0x777), ctrl->dest.sun_path); if (connect(ctrl->s, (struct sockaddr *) &ctrl->dest, sizeof(ctrl->dest)) < 0) { close(ctrl->s); @@ -263,7 +265,7 @@ int netwrapper_main(const char *server_path) int i, len, clilen = 0; int ret; char *filecon; - //sehandle = selinux_android_file_context_handle(); + sehandle = selinux_android_file_context_handle(); socket_fd = socket(PF_UNIX, SOCK_DGRAM, 0); if (socket_fd < 0) { __android_log_print(ANDROID_LOG_ERROR, LOCAL_TAG, |