Loading cmds/dumpstate/Android.mk +1 −1 Original line number Original line Diff line number Diff line Loading @@ -10,7 +10,7 @@ LOCAL_SRC_FILES := dumpstate.cpp utils.cpp LOCAL_MODULE := dumpstate LOCAL_MODULE := dumpstate LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux libbase libhardware_legacy LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux libbase # ZipArchive support, the order matters here to get all symbols. # ZipArchive support, the order matters here to get all symbols. LOCAL_STATIC_LIBRARIES := libziparchive libz libcrypto_static LOCAL_STATIC_LIBRARIES := libziparchive libz libcrypto_static LOCAL_HAL_STATIC_LIBRARIES := libdumpstate LOCAL_HAL_STATIC_LIBRARIES := libdumpstate Loading cmds/dumpstate/dumpstate.cpp +8 −33 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include <memory> #include <memory> #include <regex> #include <regex> #include <set> #include <set> #include <signal.h> #include <stdbool.h> #include <stdbool.h> #include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <stdlib.h> Loading @@ -40,7 +39,6 @@ #include <android-base/unique_fd.h> #include <android-base/unique_fd.h> #include <android-base/file.h> #include <android-base/file.h> #include <cutils/properties.h> #include <cutils/properties.h> #include <hardware_legacy/power.h> #include <private/android_filesystem_config.h> #include <private/android_filesystem_config.h> #include <private/android_logger.h> #include <private/android_logger.h> Loading Loading @@ -83,7 +81,6 @@ static std::string suffix; #define TOMBSTONE_MAX_LEN (sizeof(TOMBSTONE_FILE_PREFIX) + 4) #define TOMBSTONE_MAX_LEN (sizeof(TOMBSTONE_FILE_PREFIX) + 4) #define NUM_TOMBSTONES 10 #define NUM_TOMBSTONES 10 #define WLUTIL "/vendor/xbin/wlutil" #define WLUTIL "/vendor/xbin/wlutil" #define WAKE_LOCK_NAME "dumpstate_wakelock" typedef struct { typedef struct { char name[TOMBSTONE_MAX_LEN]; char name[TOMBSTONE_MAX_LEN]; Loading Loading @@ -1071,31 +1068,11 @@ static void usage() { VERSION_DEFAULT.c_str()); VERSION_DEFAULT.c_str()); } } static void wake_lock_releaser() { static void sigpipe_handler(int n) { if (release_wake_lock(WAKE_LOCK_NAME) < 0) { // don't complain to stderr or stdout MYLOGE("Failed to release wake lock: %s \n", strerror(errno)); } else { MYLOGD("Wake lock released.\n"); } } static void sig_handler(int signo) { wake_lock_releaser(); _exit(EXIT_FAILURE); _exit(EXIT_FAILURE); } } static void register_sig_handler() { struct sigaction sa; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = sig_handler; sigaction(SIGPIPE, &sa, NULL); // broken pipe sigaction(SIGSEGV, &sa, NULL); // segment fault sigaction(SIGINT, &sa, NULL); // ctrl-c sigaction(SIGTERM, &sa, NULL); // killed sigaction(SIGQUIT, &sa, NULL); // quit } /* adds the temporary report to the existing .zip file, closes the .zip file, and removes the /* adds the temporary report to the existing .zip file, closes the .zip file, and removes the temporary file. temporary file. */ */ Loading Loading @@ -1164,6 +1141,7 @@ static std::string SHA256_file_hash(std::string filepath) { } } int main(int argc, char *argv[]) { int main(int argc, char *argv[]) { struct sigaction sigact; int do_add_date = 0; int do_add_date = 0; int do_zip_file = 0; int do_zip_file = 0; int do_vibrate = 1; int do_vibrate = 1; Loading @@ -1180,14 +1158,6 @@ int main(int argc, char *argv[]) { MYLOGI("begin\n"); MYLOGI("begin\n"); if (acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME) < 0) { MYLOGE("Failed to acquire wake lock: %s \n", strerror(errno)); } else { MYLOGD("Wake lock acquired.\n"); atexit(wake_lock_releaser); register_sig_handler(); } /* gets the sequential id */ /* gets the sequential id */ char last_id[PROPERTY_VALUE_MAX]; char last_id[PROPERTY_VALUE_MAX]; property_get("dumpstate.last_id", last_id, "0"); property_get("dumpstate.last_id", last_id, "0"); Loading @@ -1196,6 +1166,11 @@ int main(int argc, char *argv[]) { property_set("dumpstate.last_id", last_id); property_set("dumpstate.last_id", last_id); MYLOGI("dumpstate id: %lu\n", id); MYLOGI("dumpstate id: %lu\n", id); /* clear SIGPIPE handler */ memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = sigpipe_handler; sigaction(SIGPIPE, &sigact, NULL); /* set as high priority, and protect from OOM killer */ /* set as high priority, and protect from OOM killer */ setpriority(PRIO_PROCESS, 0, -20); setpriority(PRIO_PROCESS, 0, -20); Loading cmds/dumpstate/utils.cpp +3 −6 Original line number Original line Diff line number Diff line Loading @@ -828,8 +828,7 @@ bool drop_root_user() { } } gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW, gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW, AID_MOUNT, AID_INET, AID_NET_BW_STATS, AID_READPROC, AID_WAKELOCK, AID_MOUNT, AID_INET, AID_NET_BW_STATS, AID_READPROC, AID_BLUETOOTH }; AID_BLUETOOTH }; if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { MYLOGE("Unable to setgroups, aborting: %s\n", strerror(errno)); MYLOGE("Unable to setgroups, aborting: %s\n", strerror(errno)); return false; return false; Loading @@ -850,10 +849,8 @@ bool drop_root_user() { capheader.version = _LINUX_CAPABILITY_VERSION_3; capheader.version = _LINUX_CAPABILITY_VERSION_3; capheader.pid = 0; capheader.pid = 0; capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = CAP_TO_MASK(CAP_SYSLOG); (CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_BLOCK_SUSPEND)); capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = CAP_TO_MASK(CAP_SYSLOG); capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = (CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_BLOCK_SUSPEND)); capdata[0].inheritable = 0; capdata[0].inheritable = 0; capdata[1].inheritable = 0; capdata[1].inheritable = 0; Loading Loading
cmds/dumpstate/Android.mk +1 −1 Original line number Original line Diff line number Diff line Loading @@ -10,7 +10,7 @@ LOCAL_SRC_FILES := dumpstate.cpp utils.cpp LOCAL_MODULE := dumpstate LOCAL_MODULE := dumpstate LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux libbase libhardware_legacy LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux libbase # ZipArchive support, the order matters here to get all symbols. # ZipArchive support, the order matters here to get all symbols. LOCAL_STATIC_LIBRARIES := libziparchive libz libcrypto_static LOCAL_STATIC_LIBRARIES := libziparchive libz libcrypto_static LOCAL_HAL_STATIC_LIBRARIES := libdumpstate LOCAL_HAL_STATIC_LIBRARIES := libdumpstate Loading
cmds/dumpstate/dumpstate.cpp +8 −33 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include <memory> #include <memory> #include <regex> #include <regex> #include <set> #include <set> #include <signal.h> #include <stdbool.h> #include <stdbool.h> #include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <stdlib.h> Loading @@ -40,7 +39,6 @@ #include <android-base/unique_fd.h> #include <android-base/unique_fd.h> #include <android-base/file.h> #include <android-base/file.h> #include <cutils/properties.h> #include <cutils/properties.h> #include <hardware_legacy/power.h> #include <private/android_filesystem_config.h> #include <private/android_filesystem_config.h> #include <private/android_logger.h> #include <private/android_logger.h> Loading Loading @@ -83,7 +81,6 @@ static std::string suffix; #define TOMBSTONE_MAX_LEN (sizeof(TOMBSTONE_FILE_PREFIX) + 4) #define TOMBSTONE_MAX_LEN (sizeof(TOMBSTONE_FILE_PREFIX) + 4) #define NUM_TOMBSTONES 10 #define NUM_TOMBSTONES 10 #define WLUTIL "/vendor/xbin/wlutil" #define WLUTIL "/vendor/xbin/wlutil" #define WAKE_LOCK_NAME "dumpstate_wakelock" typedef struct { typedef struct { char name[TOMBSTONE_MAX_LEN]; char name[TOMBSTONE_MAX_LEN]; Loading Loading @@ -1071,31 +1068,11 @@ static void usage() { VERSION_DEFAULT.c_str()); VERSION_DEFAULT.c_str()); } } static void wake_lock_releaser() { static void sigpipe_handler(int n) { if (release_wake_lock(WAKE_LOCK_NAME) < 0) { // don't complain to stderr or stdout MYLOGE("Failed to release wake lock: %s \n", strerror(errno)); } else { MYLOGD("Wake lock released.\n"); } } static void sig_handler(int signo) { wake_lock_releaser(); _exit(EXIT_FAILURE); _exit(EXIT_FAILURE); } } static void register_sig_handler() { struct sigaction sa; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = sig_handler; sigaction(SIGPIPE, &sa, NULL); // broken pipe sigaction(SIGSEGV, &sa, NULL); // segment fault sigaction(SIGINT, &sa, NULL); // ctrl-c sigaction(SIGTERM, &sa, NULL); // killed sigaction(SIGQUIT, &sa, NULL); // quit } /* adds the temporary report to the existing .zip file, closes the .zip file, and removes the /* adds the temporary report to the existing .zip file, closes the .zip file, and removes the temporary file. temporary file. */ */ Loading Loading @@ -1164,6 +1141,7 @@ static std::string SHA256_file_hash(std::string filepath) { } } int main(int argc, char *argv[]) { int main(int argc, char *argv[]) { struct sigaction sigact; int do_add_date = 0; int do_add_date = 0; int do_zip_file = 0; int do_zip_file = 0; int do_vibrate = 1; int do_vibrate = 1; Loading @@ -1180,14 +1158,6 @@ int main(int argc, char *argv[]) { MYLOGI("begin\n"); MYLOGI("begin\n"); if (acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME) < 0) { MYLOGE("Failed to acquire wake lock: %s \n", strerror(errno)); } else { MYLOGD("Wake lock acquired.\n"); atexit(wake_lock_releaser); register_sig_handler(); } /* gets the sequential id */ /* gets the sequential id */ char last_id[PROPERTY_VALUE_MAX]; char last_id[PROPERTY_VALUE_MAX]; property_get("dumpstate.last_id", last_id, "0"); property_get("dumpstate.last_id", last_id, "0"); Loading @@ -1196,6 +1166,11 @@ int main(int argc, char *argv[]) { property_set("dumpstate.last_id", last_id); property_set("dumpstate.last_id", last_id); MYLOGI("dumpstate id: %lu\n", id); MYLOGI("dumpstate id: %lu\n", id); /* clear SIGPIPE handler */ memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = sigpipe_handler; sigaction(SIGPIPE, &sigact, NULL); /* set as high priority, and protect from OOM killer */ /* set as high priority, and protect from OOM killer */ setpriority(PRIO_PROCESS, 0, -20); setpriority(PRIO_PROCESS, 0, -20); Loading
cmds/dumpstate/utils.cpp +3 −6 Original line number Original line Diff line number Diff line Loading @@ -828,8 +828,7 @@ bool drop_root_user() { } } gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW, gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW, AID_MOUNT, AID_INET, AID_NET_BW_STATS, AID_READPROC, AID_WAKELOCK, AID_MOUNT, AID_INET, AID_NET_BW_STATS, AID_READPROC, AID_BLUETOOTH }; AID_BLUETOOTH }; if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { MYLOGE("Unable to setgroups, aborting: %s\n", strerror(errno)); MYLOGE("Unable to setgroups, aborting: %s\n", strerror(errno)); return false; return false; Loading @@ -850,10 +849,8 @@ bool drop_root_user() { capheader.version = _LINUX_CAPABILITY_VERSION_3; capheader.version = _LINUX_CAPABILITY_VERSION_3; capheader.pid = 0; capheader.pid = 0; capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = CAP_TO_MASK(CAP_SYSLOG); (CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_BLOCK_SUSPEND)); capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = CAP_TO_MASK(CAP_SYSLOG); capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = (CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_BLOCK_SUSPEND)); capdata[0].inheritable = 0; capdata[0].inheritable = 0; capdata[1].inheritable = 0; capdata[1].inheritable = 0; Loading