dumpstate: Add SELinux restorecon call.

Set the security context on the directory used
to dump Dalvik and native stack traces.

Change-Id: Iba13783f10e850485ce1a8d4aa5792d55085eb22
Signed-off-by: Robert Craig <rpcraig@tycho.ncsc.mil>
This commit is contained in:
Robert Craig 2013-04-04 06:33:10 -04:00
parent 906bd0422a
commit 957983787d
2 changed files with 6 additions and 1 deletions

View File

@ -9,7 +9,7 @@ LOCAL_SRC_FILES := dumpstate.c utils.c
LOCAL_MODULE := dumpstate LOCAL_MODULE := dumpstate
LOCAL_SHARED_LIBRARIES := libcutils LOCAL_SHARED_LIBRARIES := libcutils libselinux
ifdef BOARD_LIB_DUMPSTATE ifdef BOARD_LIB_DUMPSTATE
LOCAL_STATIC_LIBRARIES := $(BOARD_LIB_DUMPSTATE) LOCAL_STATIC_LIBRARIES := $(BOARD_LIB_DUMPSTATE)

View File

@ -38,6 +38,8 @@
#include <cutils/sockets.h> #include <cutils/sockets.h>
#include <private/android_filesystem_config.h> #include <private/android_filesystem_config.h>
#include <selinux/android.h>
#include "dumpstate.h" #include "dumpstate.h"
/* list of native processes to include in the native dumps */ /* list of native processes to include in the native dumps */
@ -402,6 +404,9 @@ const char *dump_traces() {
if (!mkdir(anr_traces_dir, 0775)) { if (!mkdir(anr_traces_dir, 0775)) {
chown(anr_traces_dir, AID_SYSTEM, AID_SYSTEM); chown(anr_traces_dir, AID_SYSTEM, AID_SYSTEM);
chmod(anr_traces_dir, 0775); chmod(anr_traces_dir, 0775);
if (selinux_android_restorecon(anr_traces_dir) == -1) {
fprintf(stderr, "restorecon failed for %s: %s\n", anr_traces_dir, strerror(errno));
}
} else if (errno != EEXIST) { } else if (errno != EEXIST) {
fprintf(stderr, "mkdir(%s): %s\n", anr_traces_dir, strerror(errno)); fprintf(stderr, "mkdir(%s): %s\n", anr_traces_dir, strerror(errno));
return NULL; return NULL;