From efec3f2927c45979db2b78e7a6228d08aafb5e42 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Thu, 3 Apr 2014 20:55:47 +0000 Subject: [PATCH] Revert "Encrypt phone even if pattern or no keyguard" This reverts commit 5cc86c57416eccb70dcc949d68587f08726f96fa. Without two more commits, this will break encryption. I'll re-commit when the other two pass code review. Change-Id: I71720d065c16cf0f7f534e74ffe883f1e113c477 --- CommandListener.cpp | 52 +++++++++++++++++---------------------------- cryptfs.c | 8 +++++-- cryptfs.h | 2 +- 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/CommandListener.cpp b/CommandListener.cpp index 3e984a1..1177602 100644 --- a/CommandListener.cpp +++ b/CommandListener.cpp @@ -526,21 +526,6 @@ CommandListener::CryptfsCmd::CryptfsCmd() : VoldCommand("cryptfs") { } -static int getType(const char* type) -{ - if (!strcmp(type, "default")) { - return CRYPT_TYPE_DEFAULT; - } else if (!strcmp(type, "password")) { - return CRYPT_TYPE_PASSWORD; - } else if (!strcmp(type, "pin")) { - return CRYPT_TYPE_PIN; - } else if (!strcmp(type, "pattern")) { - return CRYPT_TYPE_PATTERN; - } else { - return -1; - } -} - int CommandListener::CryptfsCmd::runCommand(SocketClient *cli, int argc, char **argv) { if ((cli->getUid() != 0) && (cli->getUid() != AID_SYSTEM)) { @@ -577,28 +562,21 @@ int CommandListener::CryptfsCmd::runCommand(SocketClient *cli, dumpArgs(argc, argv, -1); rc = cryptfs_crypto_complete(); } else if (!strcmp(argv[1], "enablecrypto")) { - const char* syntax = "Usage: cryptfs enablecrypto " - "default|password|pin|pattern [passwd]"; - if ( (argc != 4 && argc != 5) + if ( (argc != 4 && argc != 3) || (strcmp(argv[2], "wipe") && strcmp(argv[2], "inplace")) ) { - cli->sendMsg(ResponseCode::CommandSyntaxError, syntax, false); + cli->sendMsg(ResponseCode::CommandSyntaxError, + "Usage: cryptfs enablecrypto [passwd]", + false); return 0; } - dumpArgs(argc, argv, 4); + dumpArgs(argc, argv, 3); int tries; for (tries = 0; tries < 2; ++tries) { - int type = getType(argv[3]); - if (type == -1) { - cli->sendMsg(ResponseCode::CommandSyntaxError, syntax, - false); - return 0; - } else if (type == CRYPT_TYPE_DEFAULT) { - rc = cryptfs_enable_default(argv[2], /*allow_reboot*/false); - } else { - rc = cryptfs_enable(argv[2], type, argv[4], - /*allow_reboot*/false); - } + if(argc == 3) + rc = cryptfs_enable_default(argv[2], /*allow_reboot*/false); + else + rc = cryptfs_enable(argv[2], argv[3], /*allow_reboot*/false); if (rc == 0) { break; @@ -618,8 +596,16 @@ int CommandListener::CryptfsCmd::runCommand(SocketClient *cli, cli->sendMsg(ResponseCode::CommandSyntaxError, syntax, false); return 0; } - int type = getType(argv[2]); - if (type == -1) { + int type = 0; + if (!strcmp(argv[2], "default")) { + type = CRYPT_TYPE_DEFAULT; + } else if (!strcmp(argv[2], "password")) { + type = CRYPT_TYPE_PASSWORD; + } else if (!strcmp(argv[2], "pin")) { + type = CRYPT_TYPE_PIN; + } else if (!strcmp(argv[2], "pattern")) { + type = CRYPT_TYPE_PATTERN; + } else { cli->sendMsg(ResponseCode::CommandSyntaxError, syntax, false); return 0; } diff --git a/cryptfs.c b/cryptfs.c index 40a473f..3d0f30b 100644 --- a/cryptfs.c +++ b/cryptfs.c @@ -2408,9 +2408,13 @@ error_shutting_down: return -1; } -int cryptfs_enable(char *howarg, int type, char *passwd, int allow_reboot) +int cryptfs_enable(char *howarg, char *passwd, int allow_reboot) { - return cryptfs_enable_internal(howarg, type, passwd, allow_reboot); + /** @todo If we keep this route (user selected encryption) + * need to take a type in and pass it to here. + */ + return cryptfs_enable_internal(howarg, CRYPT_TYPE_PASSWORD, + passwd, allow_reboot); } int cryptfs_enable_default(char *howarg, int allow_reboot) diff --git a/cryptfs.h b/cryptfs.h index c95d2c2..0e60d77 100644 --- a/cryptfs.h +++ b/cryptfs.h @@ -162,7 +162,7 @@ extern "C" { int cryptfs_check_passwd(char *pw); int cryptfs_verify_passwd(char *newpw); int cryptfs_restart(void); - int cryptfs_enable(char *flag, int type, char *passwd, int allow_reboot); + int cryptfs_enable(char *flag, char *passwd, int allow_reboot); int cryptfs_changepw(int type, const char *newpw); int cryptfs_enable_default(char *flag, int allow_reboot); int cryptfs_setup_volume(const char *label, int major, int minor,