X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=CryptCommandListener.cpp;h=779338f5a3b89c72e329f35961a32abe72e4d4ce;hb=46bb69f49a8630cc97e84976d0327495b7dd5708;hp=0c2509cdebffd56b32bfb0d754bd83e572f13d45;hpb=f71ace310eec3e39f0efefd51f62c9ccf4180f48;p=android-x86%2Fsystem-vold.git diff --git a/CryptCommandListener.cpp b/CryptCommandListener.cpp index 0c2509c..779338f 100644 --- a/CryptCommandListener.cpp +++ b/CryptCommandListener.cpp @@ -50,6 +50,7 @@ #include "ResponseCode.h" #include "cryptfs.h" #include "Ext4Crypt.h" +#include "MetadataCrypt.h" #include "Utils.h" #define DUMP_ARGS 0 @@ -201,6 +202,15 @@ int CryptCommandListener::CryptfsCmd::runCommand(SocketClient *cli, dumpArgs(argc, argv, -1); rc = cryptfs_crypto_complete(); } else if (subcommand == "enablecrypto") { + if (e4crypt_is_native()) { + if (argc != 5 || strcmp(argv[2], "inplace") || strcmp(argv[3], "default") + || strcmp(argv[4], "noui")) { + cli->sendMsg(ResponseCode::CommandSyntaxError, + "Usage with ext4crypt: cryptfs enablecrypto inplace default noui", false); + return 0; + } + return sendGenericOkFailOnBool(cli, e4crypt_enable_crypto()); + } const char* syntax = "Usage: cryptfs enablecrypto " "default|password|pin|pattern [passwd] [noui]"; @@ -318,6 +328,9 @@ int CryptCommandListener::CryptfsCmd::runCommand(SocketClient *cli, SLOGD("cryptfs mountdefaultencrypted"); dumpArgs(argc, argv, -1); + if (e4crypt_is_native()) { + return sendGenericOkFailOnBool(cli, e4crypt_mount_metadata_encrypted()); + } // Spawn as thread so init can issue commands back to vold without // causing deadlock, usually as a result of prep_data_fs. std::thread(&cryptfs_mount_default_encrypted).detach(); @@ -414,6 +427,11 @@ int CryptCommandListener::CryptfsCmd::runCommand(SocketClient *cli, return sendGenericOkFailOnBool(cli, e4crypt_destroy_user_storage(parseNull(argv[2]), atoi(argv[3]), atoi(argv[4]))); + } else if (subcommand == "secdiscard") { + if (!check_argc(cli, subcommand, argc, 3, "")) return 0; + return sendGenericOkFailOnBool(cli, + e4crypt_secdiscard(parseNull(argv[2]))); + } else { dumpArgs(argc, argv, -1); cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown cryptfs subcommand", false);