summaryrefslogtreecommitdiffstats
path: root/CommandListener.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CommandListener.cpp')
-rw-r--r--CommandListener.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/CommandListener.cpp b/CommandListener.cpp
index 3a83d2a..97ed2ce 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -28,6 +28,7 @@
#include <cutils/log.h>
#include <sysutils/SocketClient.h>
+#include <private/android_filesystem_config.h>
#include "CommandListener.h"
#include "VolumeManager.h"
@@ -498,6 +499,11 @@ CommandListener::CryptfsCmd::CryptfsCmd() :
int CommandListener::CryptfsCmd::runCommand(SocketClient *cli,
int argc, char **argv) {
+ if ((cli->getUid() != 0) && (cli->getUid() != AID_SYSTEM)) {
+ cli->sendMsg(ResponseCode::CommandNoPermission, "No permission to run cryptfs commands", false);
+ return 0;
+ }
+
if (argc < 2) {
cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false);
return 0;
@@ -540,6 +546,13 @@ int CommandListener::CryptfsCmd::runCommand(SocketClient *cli,
}
SLOGD("cryptfs changepw {}");
rc = cryptfs_changepw(argv[2]);
+ } else if (!strcmp(argv[1], "verifypw")) {
+ if (argc != 3) {
+ cli->sendMsg(ResponseCode::CommandSyntaxError, "Usage: cryptfs verifypw <passwd>", false);
+ return 0;
+ }
+ SLOGD("cryptfs verifypw {}");
+ rc = cryptfs_verify_passwd(argv[2]);
} else {
dumpArgs(argc, argv, -1);
cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown cryptfs cmd", false);