Support file based encryption and several small updates

This commit is contained in:
topjohnwu 2017-06-03 02:26:12 +08:00
parent 3ec9ff7467
commit 20903784a4
3 changed files with 2 additions and 7 deletions

View File

@ -243,12 +243,11 @@ static void cpio_dmverity(struct vector *v) {
static void cpio_forceencrypt(struct vector *v) { static void cpio_forceencrypt(struct vector *v) {
cpio_file *f; cpio_file *f;
size_t read, write; size_t read, write;
#define ENCRYPT_LIST_SIZE 2 const char *ENCRYPT_LIST[] = { "forceencrypt", "forcefdeorfbe", "fileencryptioninline", NULL };
const char *ENCRYPT_LIST[ENCRYPT_LIST_SIZE] = { "forceencrypt", "forcefdeorfbe" };
vec_for_each(v, f) { vec_for_each(v, f) {
if (strstr(f->filename, "fstab") != NULL && S_ISREG(f->mode)) { if (strstr(f->filename, "fstab") != NULL && S_ISREG(f->mode)) {
for (read = 0, write = 0; read < f->filesize; ++read, ++write) { for (read = 0, write = 0; read < f->filesize; ++read, ++write) {
for (int i = 0 ; i < ENCRYPT_LIST_SIZE; ++i) { for (int i = 0 ; ENCRYPT_LIST[i]; ++i) {
if (strncmp(f->data + read, ENCRYPT_LIST[i], strlen(ENCRYPT_LIST[i])) == 0) { if (strncmp(f->data + read, ENCRYPT_LIST[i], strlen(ENCRYPT_LIST[i])) == 0) {
memcpy(f->data + write, "encryptable", 11); memcpy(f->data + write, "encryptable", 11);
printf("Replace [%s] with [%s] in [%s]\n", ENCRYPT_LIST[i], "encryptable", f->filename); printf("Replace [%s] with [%s] in [%s]\n", ENCRYPT_LIST[i], "encryptable", f->filename);

View File

@ -132,8 +132,5 @@ void repack(const char* orig_image, const char* out_image) {
print_info(); print_info();
munmap(orig, size); munmap(orig, size);
if (lseek(fd, 0, SEEK_END) > size) {
LOGE(2, "Boot partition too small!\n");
}
close(fd); close(fd);
} }

View File

@ -139,7 +139,6 @@ void cleanup() {
unlink(RAMDISK_FILE ".unsupport"); unlink(RAMDISK_FILE ".unsupport");
unlink(SECOND_FILE); unlink(SECOND_FILE);
unlink(DTB_FILE); unlink(DTB_FILE);
unlink(NEW_BOOT);
for (int i = 0; SUP_EXT_LIST[i]; ++i) { for (int i = 0; SUP_EXT_LIST[i]; ++i) {
sprintf(name, "%s.%s", RAMDISK_FILE, SUP_EXT_LIST[i]); sprintf(name, "%s.%s", RAMDISK_FILE, SUP_EXT_LIST[i]);
unlink(name); unlink(name);