diff options
Diffstat (limited to 'cmds/dumpstate')
-rw-r--r-- | cmds/dumpstate/Android.mk | 2 | ||||
-rw-r--r-- | cmds/dumpstate/dumpstate.c | 10 | ||||
-rw-r--r-- | cmds/dumpstate/utils.c | 5 |
3 files changed, 15 insertions, 2 deletions
diff --git a/cmds/dumpstate/Android.mk b/cmds/dumpstate/Android.mk index 094dbc2..3194dbf 100644 --- a/cmds/dumpstate/Android.mk +++ b/cmds/dumpstate/Android.mk @@ -9,7 +9,7 @@ LOCAL_SRC_FILES := dumpstate.c utils.c LOCAL_MODULE := dumpstate -LOCAL_SHARED_LIBRARIES := libcutils liblog +LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux ifdef BOARD_LIB_DUMPSTATE LOCAL_STATIC_LIBRARIES := $(BOARD_LIB_DUMPSTATE) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 9a332a9..89bea91 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -315,7 +315,13 @@ static void usage() { ); } +static void sigpipe_handler(int n) { + (void)n; + exit(EXIT_FAILURE); +} + int main(int argc, char *argv[]) { + struct sigaction sigact; int do_add_date = 0; int do_compress = 0; int do_vibrate = 1; @@ -336,7 +342,9 @@ int main(int argc, char *argv[]) { } ALOGI("begin\n"); - signal(SIGPIPE, SIG_IGN); + memset(&sigact, 0, sizeof(sigact)); + sigact.sa_handler = sigpipe_handler; + sigaction(SIGPIPE, &sigact, NULL); /* set as high priority, and protect from OOM killer */ setpriority(PRIO_PROCESS, 0, -20); diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c index 9b0013e..fe716ac 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.c @@ -38,6 +38,8 @@ #include <cutils/sockets.h> #include <private/android_filesystem_config.h> +#include <selinux/android.h> + #include "dumpstate.h" /* list of native processes to include in the native dumps */ @@ -467,6 +469,9 @@ const char *dump_traces() { if (!mkdir(anr_traces_dir, 0775)) { chown(anr_traces_dir, AID_SYSTEM, AID_SYSTEM); 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) { fprintf(stderr, "mkdir(%s): %s\n", anr_traces_dir, strerror(errno)); return NULL; |