Merge commit '43b80c229bdee7f32654e2ec561078c5c94c8851'
empty merge with -s ours
Change-Id: I4c7d6fb13e175af819cab784704e08e9189f6739
diff --git a/Android.mk b/Android.mk
index bba6122..54abb23 100644
--- a/Android.mk
+++ b/Android.mk
@@ -53,7 +53,7 @@
LOCAL_C_INCLUDES := $(common_c_includes)
-LOCAL_CFLAGS :=
+LOCAL_CFLAGS := -Werror=format
LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)
diff --git a/CommandListener.cpp b/CommandListener.cpp
index 97ed2ce..33af9e5 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -40,7 +40,7 @@
#include "cryptfs.h"
CommandListener::CommandListener() :
- FrameworkListener("vold") {
+ FrameworkListener("vold", true) {
registerCmd(new DumpCmd());
registerCmd(new VolumeCmd());
registerCmd(new AsecCmd());
@@ -566,4 +566,3 @@
return 0;
}
-
diff --git a/cryptfs.c b/cryptfs.c
index 052c033..5bd6de7 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -40,6 +40,7 @@
#include <linux/kdev_t.h>
#include "cryptfs.h"
#define LOG_TAG "Cryptfs"
+#include "cutils/android_reboot.h"
#include "cutils/log.h"
#include "cutils/properties.h"
#include "hardware_legacy/power.h"
@@ -730,6 +731,7 @@
char fs_options[PROPERTY_VALUE_MAX];
unsigned long mnt_flags;
char encrypted_state[PROPERTY_VALUE_MAX];
+ char key_loc[PROPERTY_VALUE_MAX];
property_get("ro.crypto.state", encrypted_state, "");
if (strcmp(encrypted_state, "encrypted") ) {
@@ -743,8 +745,21 @@
}
if (get_crypt_ftr_and_key(real_blkdev, &crypt_ftr, encrypted_master_key, salt)) {
- SLOGE("Error getting crypt footer and key\n");
- return -1;
+ property_get(KEY_LOC_PROP, key_loc, KEY_IN_FOOTER);
+ /*
+ * Only report this error if key_loc is a file and it exists.
+ * If the device was never encrypted, and /data is not mountable for
+ * some reason, returning 1 should prevent the UI from presenting the
+ * a "enter password" screen, or worse, a "press button to wipe the
+ * device" screen.
+ */
+ if ((key_loc[0] == '/') && (access("key_loc", F_OK) == -1)) {
+ SLOGE("master key file does not exist, aborting");
+ return 1;
+ } else {
+ SLOGE("Error getting crypt footer and key\n");
+ return -1;
+ }
}
if (crypt_ftr.flags & CRYPT_ENCRYPTION_IN_PROGRESS) {
@@ -1372,8 +1387,26 @@
sleep(2); /* Give the UI a chance to show 100% progress */
android_reboot(ANDROID_RB_RESTART, 0, 0);
} else {
- property_set("vold.encrypt_progress", "error_partially_encrypted");
- release_wake_lock(lockid);
+ char value[PROPERTY_VALUE_MAX];
+
+ property_get("ro.vold.wipe_on_cyrypt_fail", value, "0");
+ if (!strcmp(value, "1")) {
+ /* wipe data if encryption failed */
+ SLOGE("encryption failed - rebooting into recovery to wipe data\n");
+ mkdir("/cache/recovery", 0700);
+ int fd = open("/cache/recovery/command", O_RDWR|O_CREAT|O_TRUNC);
+ if (fd >= 0) {
+ write(fd, "--wipe_data", strlen("--wipe_data") + 1);
+ close(fd);
+ } else {
+ SLOGE("could not open /cache/recovery/command\n");
+ }
+ android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
+ } else {
+ /* set property to trigger dialog */
+ property_set("vold.encrypt_progress", "error_partially_encrypted");
+ release_wake_lock(lockid);
+ }
return -1;
}
diff --git a/logwrapper.c b/logwrapper.c
index 13c076d..34a1e5a 100644
--- a/logwrapper.c
+++ b/logwrapper.c
@@ -25,6 +25,7 @@
#include "private/android_filesystem_config.h"
#include "cutils/log.h"
+#include "cutils/sched_policy.h"
int parent(const char *tag, int parent_read) {
int status;
@@ -43,7 +44,7 @@
} else if (buffer[b] == '\n') {
buffer[b] = '\0';
- LOG(LOG_INFO, tag, "%s", &buffer[a]);
+ ALOG(LOG_INFO, tag, "%s", &buffer[a]);
a = b + 1;
}
}
@@ -51,7 +52,7 @@
if (a == 0 && b == sizeof(buffer) - 1) {
// buffer is full, flush
buffer[b] = '\0';
- LOG(LOG_INFO, tag, "%s", &buffer[a]);
+ ALOG(LOG_INFO, tag, "%s", &buffer[a]);
b = 0;
} else if (a != b) {
// Keep left-overs
@@ -67,24 +68,24 @@
// Flush remaining data
if (a != b) {
buffer[b] = '\0';
- LOG(LOG_INFO, tag, "%s", &buffer[a]);
+ ALOG(LOG_INFO, tag, "%s", &buffer[a]);
}
status = 0xAAAA;
if (wait(&status) != -1) { // Wait for child
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) != 0) {
- LOG(LOG_INFO, "logwrapper", "%s terminated by exit(%d)", tag,
+ ALOG(LOG_INFO, "logwrapper", "%s terminated by exit(%d)", tag,
WEXITSTATUS(status));
}
return WEXITSTATUS(status);
} else if (WIFSIGNALED(status))
- LOG(LOG_INFO, "logwrapper", "%s terminated by signal %d", tag,
+ ALOG(LOG_INFO, "logwrapper", "%s terminated by signal %d", tag,
WTERMSIG(status));
else if (WIFSTOPPED(status))
- LOG(LOG_INFO, "logwrapper", "%s stopped by signal %d", tag,
+ ALOG(LOG_INFO, "logwrapper", "%s stopped by signal %d", tag,
WSTOPSIG(status));
} else
- LOG(LOG_INFO, "logwrapper", "%s wait() failed: %s (%d)", tag,
+ ALOG(LOG_INFO, "logwrapper", "%s wait() failed: %s (%d)", tag,
strerror(errno), errno);
return -EAGAIN;
}
@@ -97,7 +98,7 @@
// XXX: PROTECT FROM VIKING KILLER
if (execv(argv_child[0], argv_child)) {
- LOG(LOG_ERROR, "logwrapper",
+ ALOG(LOG_ERROR, "logwrapper",
"executing %s failed: %s", argv_child[0], strerror(errno));
exit(-1);
}
@@ -114,21 +115,21 @@
/* Use ptty instead of socketpair so that STDOUT is not buffered */
parent_ptty = open("/dev/ptmx", O_RDWR);
if (parent_ptty < 0) {
- LOG(LOG_ERROR, "logwrapper", "Cannot create parent ptty");
- return -errno;
+ ALOG(LOG_ERROR, "logwrapper", "Cannot create parent ptty");
+ return -errno;
}
if (grantpt(parent_ptty) || unlockpt(parent_ptty) ||
((child_devname = (char*)ptsname(parent_ptty)) == 0)) {
close(parent_ptty);
- LOG(LOG_ERROR, "logwrapper", "Problem with /dev/ptmx");
- return -1;
+ ALOG(LOG_ERROR, "logwrapper", "Problem with /dev/ptmx");
+ return -1;
}
pid = fork();
if (pid < 0) {
close(parent_ptty);
- LOG(LOG_ERROR, "logwrapper", "Failed to fork");
+ ALOG(LOG_ERROR, "logwrapper", "Failed to fork");
return -errno;
} else if (pid == 0) {
/*
@@ -137,7 +138,7 @@
child_ptty = open(child_devname, O_RDWR);
if (child_ptty < 0) {
close(parent_ptty);
- LOG(LOG_ERROR, "logwrapper", "Problem with child ptty");
+ ALOG(LOG_ERROR, "logwrapper", "Problem with child ptty");
return -errno;
}
@@ -148,18 +149,10 @@
close(child_ptty);
if (background) {
- int fd = open("/dev/cpuctl/bg_non_interactive/tasks", O_WRONLY);
- if (fd >= 0) {
- char text[64];
- sprintf(text, "%d", getpid());
- if (write(fd, text, strlen(text)) < 0) {
- LOG(LOG_WARN, "logwrapper",
- "Unable to background process (%s)", strerror(errno));
- }
- close(fd);
- } else {
- LOG(LOG_WARN, "logwrapper",
- "Unable to background process (%s)", strerror(errno));
+ int err = set_sched_policy(getpid(), SP_BACKGROUND);
+ if (err < 0) {
+ ALOG(LOG_WARN, "logwrapper",
+ "Unable to background process (%s)", strerror(-err));
}
}
diff --git a/vdc.c b/vdc.c
index 1eb674c..7dad143 100644
--- a/vdc.c
+++ b/vdc.c
@@ -55,7 +55,7 @@
}
static int do_cmd(int sock, int argc, char **argv) {
- char final_cmd[255] = { '\0' };
+ char final_cmd[255] = "0 "; /* 0 is a (now required) sequence number */
int i;
int ret;