From f1186f3e980f5ebcc3380d8a7f746bf8a45e3531 Mon Sep 17 00:00:00 2001 From: rpcraig Date: Thu, 19 Jul 2012 09:38:06 -0400 Subject: [PATCH] restorecon tombstone directory. Restore the security contexts of tombstone directory when initially created. Change-Id: I25b53730991576eccb62ca57050decd584acc639 Signed-off-by: rpcraig --- debuggerd/Android.mk | 6 ++++++ debuggerd/tombstone.c | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/debuggerd/Android.mk b/debuggerd/Android.mk index 2a516fbed..fe4670688 100644 --- a/debuggerd/Android.mk +++ b/debuggerd/Android.mk @@ -25,6 +25,12 @@ endif # ARCH_ARM_HAVE_VFP_D32 LOCAL_SHARED_LIBRARIES := libcutils libc libcorkscrew +ifeq ($(HAVE_SELINUX),true) +LOCAL_SHARED_LIBRARIES += libselinux +LOCAL_C_INCLUDES += external/libselinux/include +LOCAL_CFLAGS += -DHAVE_SELINUX +endif + include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) diff --git a/debuggerd/tombstone.c b/debuggerd/tombstone.c index 16b49433b..27ab3fe93 100644 --- a/debuggerd/tombstone.c +++ b/debuggerd/tombstone.c @@ -35,6 +35,10 @@ #include #include +#ifdef HAVE_SELINUX +#include +#endif + #include "machine.h" #include "tombstone.h" #include "utility.h" @@ -680,6 +684,13 @@ char* engrave_tombstone(pid_t pid, pid_t tid, int signal, mkdir(TOMBSTONE_DIR, 0755); chown(TOMBSTONE_DIR, AID_SYSTEM, AID_SYSTEM); +#ifdef HAVE_SELINUX + if (selinux_android_restorecon(TOMBSTONE_DIR) == -1) { + *detach_failed = false; + return NULL; + } +#endif + int fd; char* path = find_and_open_tombstone(&fd); if (!path) {