Merge "bootstat: Disambiguate boot time on encrypted devices."
diff --git a/init/init.cpp b/init/init.cpp
index 9e6143b..bac27df 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -460,24 +460,6 @@
return true;
}
-int selinux_reload_policy(void)
-{
- INFO("SELinux: Attempting to reload policy files\n");
-
- if (selinux_android_reload_policy() == -1) {
- return -1;
- }
-
- if (sehandle)
- selabel_close(sehandle);
-
- if (sehandle_prop)
- selabel_close(sehandle_prop);
-
- selinux_init_all_handles();
- return 0;
-}
-
static int audit_callback(void *data, security_class_t /*cls*/, char *buf, size_t len) {
property_audit_data *d = reinterpret_cast<property_audit_data*>(data);
diff --git a/init/init.h b/init/init.h
index 345d442..b6a095b 100644
--- a/init/init.h
+++ b/init/init.h
@@ -35,8 +35,6 @@
void property_changed(const char *name, const char *value);
-int selinux_reload_policy(void);
-
void register_epoll_handler(int fd, void (*fn)());
int add_environment(const char* key, const char* val);
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 5c1ae79..8c95f15 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -175,11 +175,7 @@
if (!is_legal_property_name(name, namelen)) return -1;
if (valuelen >= PROP_VALUE_MAX) return -1;
- if (strcmp("selinux.reload_policy", name) == 0 && strcmp("1", value) == 0) {
- if (selinux_reload_policy() != 0) {
- ERROR("Failed to reload policy\n");
- }
- } else if (strcmp("selinux.restorecon_recursive", name) == 0 && valuelen > 0) {
+ if (strcmp("selinux.restorecon_recursive", name) == 0 && valuelen > 0) {
if (restorecon_recursive(value) != 0) {
ERROR("Failed to restorecon_recursive %s\n", value);
}
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 19a3e27..02df8dd 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -1429,8 +1429,16 @@
* possibly causing heap corruption. To avoid this we double check and
* set the length at the maximum (size minus null byte)
*/
- prefixLen += MIN(len, sizeof(prefixBuf) - prefixLen);
- suffixLen = MIN(suffixLen, sizeof(suffixBuf));
+ prefixLen += len;
+ if (prefixLen >= sizeof(prefixBuf)) {
+ prefixLen = sizeof(prefixBuf) - 1;
+ prefixBuf[sizeof(prefixBuf) - 1] = '\0';
+ }
+ if (suffixLen >= sizeof(suffixBuf)) {
+ suffixLen = sizeof(suffixBuf) - 1;
+ suffixBuf[sizeof(suffixBuf) - 2] = '\n';
+ suffixBuf[sizeof(suffixBuf) - 1] = '\0';
+ }
/* the following code is tragically unreadable */
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index 50ecd2d..8893780 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -861,6 +861,60 @@
EXPECT_LE(SIZEOF_MAX_PAYLOAD_BUF, static_cast<size_t>(max_len));
}
+TEST(liblog, __android_log_buf_print__maxtag) {
+ struct logger_list *logger_list;
+
+ pid_t pid = getpid();
+
+ ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
+ LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+
+ log_time ts(android_log_clockid());
+
+ EXPECT_LT(0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
+ max_payload_buf, max_payload_buf));
+ usleep(1000000);
+
+ int count = 0;
+
+ for (;;) {
+ log_msg log_msg;
+ if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+ break;
+ }
+
+ ASSERT_EQ(log_msg.entry.pid, pid);
+
+ if ((log_msg.entry.sec < (ts.tv_sec - 1))
+ || ((ts.tv_sec + 1) < log_msg.entry.sec)
+ || ((size_t)log_msg.entry.len < LOGGER_ENTRY_MAX_PAYLOAD)
+ || (log_msg.id() != LOG_ID_MAIN)) {
+ continue;
+ }
+
+ ++count;
+
+ AndroidLogFormat *logformat = android_log_format_new();
+ EXPECT_TRUE(NULL != logformat);
+ AndroidLogEntry entry;
+ int processLogBuffer = android_log_processLogBuffer(&log_msg.entry_v1,
+ &entry);
+ EXPECT_EQ(0, processLogBuffer);
+ if (processLogBuffer == 0) {
+ fflush(stderr);
+ int printLogLine =
+ android_log_printLogLine(logformat, fileno(stderr), &entry);
+ EXPECT_LE(128, printLogLine);
+ EXPECT_GT(LOGGER_ENTRY_MAX_PAYLOAD, printLogLine);
+ }
+ android_log_format_free(logformat);
+ }
+
+ EXPECT_EQ(1, count);
+
+ android_logger_list_close(logger_list);
+}
+
TEST(liblog, too_big_payload) {
pid_t pid = getpid();
static const char big_payload_tag[] = "TEST_big_payload_XXXX";
diff --git a/rootdir/init-debug.rc b/rootdir/init-debug.rc
index 435d4cb..44d34d8 100644
--- a/rootdir/init-debug.rc
+++ b/rootdir/init-debug.rc
@@ -6,3 +6,6 @@
on property:persist.mmc.cache_size=*
write /sys/block/mmcblk0/cache_size ${persist.mmc.cache_size}
+
+on early-init
+ mount debugfs debugfs /sys/kernel/debug
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 6d5023e..aa32343 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -399,9 +399,6 @@
# symlink to bugreport storage location
symlink /data/data/com.android.shell/files/bugreports /data/bugreports
- # Separate location for storing security policy files on data
- mkdir /data/security 0711 system system
-
# Create all remaining /data root dirs so that they are made through init
# and get proper encryption policy installed
mkdir /data/backup 0700 system system
@@ -413,9 +410,6 @@
setusercryptopolicies /data/user
- # Reload policy from /data/security if present.
- setprop selinux.reload_policy 1
-
# Set SELinux security contexts on upgrade or policy update.
restorecon_recursive /data