Merge "Log pid for writes to sys.powerctl"
am: 2827106d7d
Change-Id: I2fb780c5809d4c18950c114c07a7363723aa121a
This commit is contained in:
commit
c1968fb0c9
1 changed files with 16 additions and 0 deletions
|
|
@ -45,6 +45,7 @@
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <bootimg.h>
|
#include <bootimg.h>
|
||||||
#include <fs_mgr.h>
|
#include <fs_mgr.h>
|
||||||
|
|
@ -56,6 +57,7 @@
|
||||||
#include "persistent_properties.h"
|
#include "persistent_properties.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
using android::base::StringPrintf;
|
||||||
using android::base::Timer;
|
using android::base::Timer;
|
||||||
|
|
||||||
#define RECOVERY_MOUNT_POINT "/recovery"
|
#define RECOVERY_MOUNT_POINT "/recovery"
|
||||||
|
|
@ -418,6 +420,20 @@ static void handle_property_set(SocketConnection& socket,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (check_mac_perms(name, source_ctx, &cr)) {
|
if (check_mac_perms(name, source_ctx, &cr)) {
|
||||||
|
// sys.powerctl is a special property that is used to make the device reboot. We want to log
|
||||||
|
// any process that sets this property to be able to accurately blame the cause of a shutdown.
|
||||||
|
if (name == "sys.powerctl") {
|
||||||
|
std::string cmdline_path = StringPrintf("proc/%d/cmdline", cr.pid);
|
||||||
|
std::string process_cmdline;
|
||||||
|
std::string process_log_string;
|
||||||
|
if (android::base::ReadFileToString(cmdline_path, &process_cmdline)) {
|
||||||
|
// Since cmdline is null deliminated, .c_str() conveniently gives us just the process path.
|
||||||
|
process_log_string = StringPrintf(" (%s)", process_cmdline.c_str());
|
||||||
|
}
|
||||||
|
LOG(INFO) << "Received sys.powerctl='" << value << "' from pid: " << cr.pid
|
||||||
|
<< process_log_string;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t result = property_set(name, value);
|
uint32_t result = property_set(name, value);
|
||||||
if (!legacy_protocol) {
|
if (!legacy_protocol) {
|
||||||
socket.SendUint32(result);
|
socket.SendUint32(result);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue