am 8120c3d1: Merge "Adding e4crypt support"

* commit '8120c3d1b2a8b4c6570c36bcdaf7c55392f5fa45':
  Adding e4crypt support
gugelfrei
Paul Lawrence 9 years ago committed by Android Git Automerger
commit 836e78608d

@ -708,7 +708,7 @@ int CommandListener::CryptfsCmd::runCommand(SocketClient *cli,
} else if (!strcmp(argv[1], "getpw")) { } else if (!strcmp(argv[1], "getpw")) {
SLOGD("cryptfs getpw"); SLOGD("cryptfs getpw");
dumpArgs(argc, argv, -1); dumpArgs(argc, argv, -1);
char* password = cryptfs_get_password(); const char* password = cryptfs_get_password();
if (password) { if (password) {
char* message = 0; char* message = 0;
int size = asprintf(&message, "{{sensitive}} %s", password); int size = asprintf(&message, "{{sensitive}} %s", password);

@ -53,6 +53,7 @@
#include "VolumeManager.h" #include "VolumeManager.h"
#include "VoldUtil.h" #include "VoldUtil.h"
#include "crypto_scrypt.h" #include "crypto_scrypt.h"
#include "ext4_crypt.h"
#include "ext4_utils.h" #include "ext4_utils.h"
#include "f2fs_sparseblock.h" #include "f2fs_sparseblock.h"
#include "CheckBattery.h" #include "CheckBattery.h"
@ -1674,11 +1675,37 @@ static int cryptfs_restart_internal(int restart_main)
int cryptfs_restart(void) int cryptfs_restart(void)
{ {
SLOGI("cryptfs_restart");
if (e4crypt_crypto_complete(DATA_MNT_POINT) == 0) {
struct fstab_rec* rec;
int rc;
if (e4crypt_restart(DATA_MNT_POINT)) {
SLOGE("Can't unmount e4crypt temp volume\n");
return -1;
}
rec = fs_mgr_get_entry_for_mount_point(fstab, DATA_MNT_POINT);
if (!rec) {
SLOGE("Can't get fstab record for %s\n", DATA_MNT_POINT);
return -1;
}
rc = fs_mgr_do_mount(fstab, DATA_MNT_POINT, rec->blk_device, 0);
if (rc) {
SLOGE("Can't mount %s\n", DATA_MNT_POINT);
return rc;
}
property_set("vold.decrypt", "trigger_restart_framework");
return 0;
}
/* Call internal implementation forcing a restart of main service group */ /* Call internal implementation forcing a restart of main service group */
return cryptfs_restart_internal(1); return cryptfs_restart_internal(1);
} }
static int do_crypto_complete(char *mount_point UNUSED) static int do_crypto_complete(char *mount_point)
{ {
struct crypt_mnt_ftr crypt_ftr; struct crypt_mnt_ftr crypt_ftr;
char encrypted_state[PROPERTY_VALUE_MAX]; char encrypted_state[PROPERTY_VALUE_MAX];
@ -1690,6 +1717,10 @@ static int do_crypto_complete(char *mount_point UNUSED)
return CRYPTO_COMPLETE_NOT_ENCRYPTED; return CRYPTO_COMPLETE_NOT_ENCRYPTED;
} }
if (e4crypt_crypto_complete(mount_point) == 0) {
return CRYPTO_COMPLETE_ENCRYPTED;
}
if (get_crypt_ftr_and_key(&crypt_ftr)) { if (get_crypt_ftr_and_key(&crypt_ftr)) {
fs_mgr_get_crypt_info(fstab, key_loc, 0, sizeof(key_loc)); fs_mgr_get_crypt_info(fstab, key_loc, 0, sizeof(key_loc));
@ -2012,6 +2043,11 @@ char* adjust_passwd(const char* passwd)
int cryptfs_check_passwd(char *passwd) int cryptfs_check_passwd(char *passwd)
{ {
SLOGI("cryptfs_check_passwd");
if (e4crypt_crypto_complete(DATA_MNT_POINT) == 0) {
return e4crypt_check_passwd(DATA_MNT_POINT, passwd);
}
struct crypt_mnt_ftr crypt_ftr; struct crypt_mnt_ftr crypt_ftr;
int rc; int rc;
@ -3302,6 +3338,10 @@ int cryptfs_enable_default(char *howarg, int allow_reboot)
int cryptfs_changepw(int crypt_type, const char *newpw) int cryptfs_changepw(int crypt_type, const char *newpw)
{ {
if (e4crypt_crypto_complete(DATA_MNT_POINT) == 0) {
return e4crypt_change_password(DATA_MNT_POINT, crypt_type, newpw);
}
struct crypt_mnt_ftr crypt_ftr; struct crypt_mnt_ftr crypt_ftr;
/* This is only allowed after we've successfully decrypted the master key */ /* This is only allowed after we've successfully decrypted the master key */
@ -3709,6 +3749,10 @@ int cryptfs_mount_default_encrypted(void)
*/ */
int cryptfs_get_password_type(void) int cryptfs_get_password_type(void)
{ {
if (e4crypt_crypto_complete(DATA_MNT_POINT) == 0) {
return e4crypt_get_password_type(DATA_MNT_POINT);
}
struct crypt_mnt_ftr crypt_ftr; struct crypt_mnt_ftr crypt_ftr;
if (get_crypt_ftr_and_key(&crypt_ftr)) { if (get_crypt_ftr_and_key(&crypt_ftr)) {
@ -3723,8 +3767,12 @@ int cryptfs_get_password_type(void)
return crypt_ftr.crypt_type; return crypt_ftr.crypt_type;
} }
char* cryptfs_get_password() const char* cryptfs_get_password()
{ {
if (e4crypt_crypto_complete(DATA_MNT_POINT) == 0) {
return e4crypt_get_password(DATA_MNT_POINT);
}
struct timespec now; struct timespec now;
clock_gettime(CLOCK_BOOTTIME, &now); clock_gettime(CLOCK_BOOTTIME, &now);
if (now.tv_sec < password_expiry_time) { if (now.tv_sec < password_expiry_time) {

@ -243,7 +243,7 @@ extern "C" {
int cryptfs_setfield(const char *fieldname, const char *value); int cryptfs_setfield(const char *fieldname, const char *value);
int cryptfs_mount_default_encrypted(void); int cryptfs_mount_default_encrypted(void);
int cryptfs_get_password_type(void); int cryptfs_get_password_type(void);
char* cryptfs_get_password(void); const char* cryptfs_get_password(void);
void cryptfs_clear_password(void); void cryptfs_clear_password(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

Loading…
Cancel
Save