|
|
@ -24,9 +24,9 @@
|
|
|
|
#include "Process.h"
|
|
|
|
#include "Process.h"
|
|
|
|
#include "VolumeManager.h"
|
|
|
|
#include "VolumeManager.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "cryptfs.h"
|
|
|
|
|
|
|
|
#include "Ext4Crypt.h"
|
|
|
|
#include "Ext4Crypt.h"
|
|
|
|
#include "MetadataCrypt.h"
|
|
|
|
#include "MetadataCrypt.h"
|
|
|
|
|
|
|
|
#include "cryptfs.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <thread>
|
|
|
|
#include <thread>
|
|
|
@ -83,11 +83,11 @@ binder::Status checkPermission(const char* permission) {
|
|
|
|
uid_t uid;
|
|
|
|
uid_t uid;
|
|
|
|
|
|
|
|
|
|
|
|
if (checkCallingPermission(String16(permission), reinterpret_cast<int32_t*>(&pid),
|
|
|
|
if (checkCallingPermission(String16(permission), reinterpret_cast<int32_t*>(&pid),
|
|
|
|
reinterpret_cast<int32_t*>(&uid))) {
|
|
|
|
reinterpret_cast<int32_t*>(&uid))) {
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return exception(binder::Status::EX_SECURITY,
|
|
|
|
return exception(binder::Status::EX_SECURITY,
|
|
|
|
StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, permission));
|
|
|
|
StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, permission));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -97,7 +97,7 @@ binder::Status checkUid(uid_t expectedUid) {
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return exception(binder::Status::EX_SECURITY,
|
|
|
|
return exception(binder::Status::EX_SECURITY,
|
|
|
|
StringPrintf("UID %d is not expected UID %d", uid, expectedUid));
|
|
|
|
StringPrintf("UID %d is not expected UID %d", uid, expectedUid));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -108,7 +108,7 @@ binder::Status checkArgumentId(const std::string& id) {
|
|
|
|
for (const char& c : id) {
|
|
|
|
for (const char& c : id) {
|
|
|
|
if (!std::isalnum(c) && c != ':' && c != ',') {
|
|
|
|
if (!std::isalnum(c) && c != ':' && c != ',') {
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
StringPrintf("ID %s is malformed", id.c_str()));
|
|
|
|
StringPrintf("ID %s is malformed", id.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
@ -120,16 +120,16 @@ binder::Status checkArgumentPath(const std::string& path) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (path[0] != '/') {
|
|
|
|
if (path[0] != '/') {
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
StringPrintf("Path %s is relative", path.c_str()));
|
|
|
|
StringPrintf("Path %s is relative", path.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((path + '/').find("/../") != std::string::npos) {
|
|
|
|
if ((path + '/').find("/../") != std::string::npos) {
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
StringPrintf("Path %s is shady", path.c_str()));
|
|
|
|
StringPrintf("Path %s is shady", path.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const char& c : path) {
|
|
|
|
for (const char& c : path) {
|
|
|
|
if (c == '\0' || c == '\n') {
|
|
|
|
if (c == '\0' || c == '\n') {
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
StringPrintf("Path %s is malformed", path.c_str()));
|
|
|
|
StringPrintf("Path %s is malformed", path.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
@ -140,45 +140,49 @@ binder::Status checkArgumentHex(const std::string& hex) {
|
|
|
|
for (const char& c : hex) {
|
|
|
|
for (const char& c : hex) {
|
|
|
|
if (!std::isxdigit(c) && c != ':' && c != '-') {
|
|
|
|
if (!std::isxdigit(c) && c != ':' && c != '-') {
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
|
|
|
|
StringPrintf("Hex %s is malformed", hex.c_str()));
|
|
|
|
StringPrintf("Hex %s is malformed", hex.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define ENFORCE_UID(uid) { \
|
|
|
|
#define ENFORCE_UID(uid) \
|
|
|
|
binder::Status status = checkUid((uid)); \
|
|
|
|
{ \
|
|
|
|
if (!status.isOk()) { \
|
|
|
|
binder::Status status = checkUid((uid)); \
|
|
|
|
return status; \
|
|
|
|
if (!status.isOk()) { \
|
|
|
|
} \
|
|
|
|
return status; \
|
|
|
|
}
|
|
|
|
} \
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define CHECK_ARGUMENT_ID(id) { \
|
|
|
|
#define CHECK_ARGUMENT_ID(id) \
|
|
|
|
binder::Status status = checkArgumentId((id)); \
|
|
|
|
{ \
|
|
|
|
if (!status.isOk()) { \
|
|
|
|
binder::Status status = checkArgumentId((id)); \
|
|
|
|
return status; \
|
|
|
|
if (!status.isOk()) { \
|
|
|
|
} \
|
|
|
|
return status; \
|
|
|
|
}
|
|
|
|
} \
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define CHECK_ARGUMENT_PATH(path) { \
|
|
|
|
#define CHECK_ARGUMENT_PATH(path) \
|
|
|
|
binder::Status status = checkArgumentPath((path)); \
|
|
|
|
{ \
|
|
|
|
if (!status.isOk()) { \
|
|
|
|
binder::Status status = checkArgumentPath((path)); \
|
|
|
|
return status; \
|
|
|
|
if (!status.isOk()) { \
|
|
|
|
} \
|
|
|
|
return status; \
|
|
|
|
}
|
|
|
|
} \
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define CHECK_ARGUMENT_HEX(hex) { \
|
|
|
|
#define CHECK_ARGUMENT_HEX(hex) \
|
|
|
|
binder::Status status = checkArgumentHex((hex)); \
|
|
|
|
{ \
|
|
|
|
if (!status.isOk()) { \
|
|
|
|
binder::Status status = checkArgumentHex((hex)); \
|
|
|
|
return status; \
|
|
|
|
if (!status.isOk()) { \
|
|
|
|
} \
|
|
|
|
return status; \
|
|
|
|
}
|
|
|
|
} \
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define ACQUIRE_LOCK \
|
|
|
|
#define ACQUIRE_LOCK \
|
|
|
|
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getLock()); \
|
|
|
|
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getLock()); \
|
|
|
|
ATRACE_CALL();
|
|
|
|
ATRACE_CALL();
|
|
|
|
|
|
|
|
|
|
|
|
#define ACQUIRE_CRYPT_LOCK \
|
|
|
|
#define ACQUIRE_CRYPT_LOCK \
|
|
|
|
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getCryptLock()); \
|
|
|
|
std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getCryptLock()); \
|
|
|
|
ATRACE_CALL();
|
|
|
|
ATRACE_CALL();
|
|
|
|
|
|
|
|
|
|
|
@ -196,7 +200,7 @@ status_t VoldNativeService::start() {
|
|
|
|
return android::OK;
|
|
|
|
return android::OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t VoldNativeService::dump(int fd, const Vector<String16> & /* args */) {
|
|
|
|
status_t VoldNativeService::dump(int fd, const Vector<String16>& /* args */) {
|
|
|
|
auto out = std::fstream(StringPrintf("/proc/self/fd/%d", fd));
|
|
|
|
auto out = std::fstream(StringPrintf("/proc/self/fd/%d", fd));
|
|
|
|
const binder::Status dump_permission = checkPermission(kDump);
|
|
|
|
const binder::Status dump_permission = checkPermission(kDump);
|
|
|
|
if (!dump_permission.isOk()) {
|
|
|
|
if (!dump_permission.isOk()) {
|
|
|
@ -211,7 +215,7 @@ status_t VoldNativeService::dump(int fd, const Vector<String16> & /* args */) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::setListener(
|
|
|
|
binder::Status VoldNativeService::setListener(
|
|
|
|
const android::sp<android::os::IVoldListener>& listener) {
|
|
|
|
const android::sp<android::os::IVoldListener>& listener) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
|
|
|
|
|
|
|
@ -223,12 +227,8 @@ binder::Status VoldNativeService::monitor() {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
|
|
|
|
|
|
|
|
// Simply acquire/release each lock for watchdog
|
|
|
|
// Simply acquire/release each lock for watchdog
|
|
|
|
{
|
|
|
|
{ ACQUIRE_LOCK; }
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
{ ACQUIRE_CRYPT_LOCK; }
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -283,7 +283,7 @@ binder::Status VoldNativeService::onSecureKeyguardStateChanged(bool isShowing) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::partition(const std::string& diskId, int32_t partitionType,
|
|
|
|
binder::Status VoldNativeService::partition(const std::string& diskId, int32_t partitionType,
|
|
|
|
int32_t ratio) {
|
|
|
|
int32_t ratio) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
CHECK_ARGUMENT_ID(diskId);
|
|
|
|
CHECK_ARGUMENT_ID(diskId);
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
ACQUIRE_LOCK;
|
|
|
@ -293,15 +293,19 @@ binder::Status VoldNativeService::partition(const std::string& diskId, int32_t p
|
|
|
|
return error("Failed to find disk " + diskId);
|
|
|
|
return error("Failed to find disk " + diskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (partitionType) {
|
|
|
|
switch (partitionType) {
|
|
|
|
case PARTITION_TYPE_PUBLIC: return translate(disk->partitionPublic());
|
|
|
|
case PARTITION_TYPE_PUBLIC:
|
|
|
|
case PARTITION_TYPE_PRIVATE: return translate(disk->partitionPrivate());
|
|
|
|
return translate(disk->partitionPublic());
|
|
|
|
case PARTITION_TYPE_MIXED: return translate(disk->partitionMixed(ratio));
|
|
|
|
case PARTITION_TYPE_PRIVATE:
|
|
|
|
default: return error("Unknown type " + std::to_string(partitionType));
|
|
|
|
return translate(disk->partitionPrivate());
|
|
|
|
|
|
|
|
case PARTITION_TYPE_MIXED:
|
|
|
|
|
|
|
|
return translate(disk->partitionMixed(ratio));
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return error("Unknown type " + std::to_string(partitionType));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::forgetPartition(const std::string& partGuid,
|
|
|
|
binder::Status VoldNativeService::forgetPartition(const std::string& partGuid,
|
|
|
|
const std::string& fsUuid) {
|
|
|
|
const std::string& fsUuid) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
CHECK_ARGUMENT_HEX(partGuid);
|
|
|
|
CHECK_ARGUMENT_HEX(partGuid);
|
|
|
|
CHECK_ARGUMENT_HEX(fsUuid);
|
|
|
|
CHECK_ARGUMENT_HEX(fsUuid);
|
|
|
@ -311,7 +315,7 @@ binder::Status VoldNativeService::forgetPartition(const std::string& partGuid,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::mount(const std::string& volId, int32_t mountFlags,
|
|
|
|
binder::Status VoldNativeService::mount(const std::string& volId, int32_t mountFlags,
|
|
|
|
int32_t mountUserId) {
|
|
|
|
int32_t mountUserId) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
CHECK_ARGUMENT_ID(volId);
|
|
|
|
CHECK_ARGUMENT_ID(volId);
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
ACQUIRE_LOCK;
|
|
|
@ -387,9 +391,7 @@ binder::Status VoldNativeService::benchmark(
|
|
|
|
auto status = pathForVolId(volId, &path);
|
|
|
|
auto status = pathForVolId(volId, &path);
|
|
|
|
if (!status.isOk()) return status;
|
|
|
|
if (!status.isOk()) return status;
|
|
|
|
|
|
|
|
|
|
|
|
std::thread([=]() {
|
|
|
|
std::thread([=]() { android::vold::Benchmark(path, listener); }).detach();
|
|
|
|
android::vold::Benchmark(path, listener);
|
|
|
|
|
|
|
|
}).detach();
|
|
|
|
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -404,8 +406,9 @@ binder::Status VoldNativeService::checkEncryption(const std::string& volId) {
|
|
|
|
return translate(android::vold::CheckEncryption(path));
|
|
|
|
return translate(android::vold::CheckEncryption(path));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::moveStorage(const std::string& fromVolId,
|
|
|
|
binder::Status VoldNativeService::moveStorage(
|
|
|
|
const std::string& toVolId, const android::sp<android::os::IVoldTaskListener>& listener) {
|
|
|
|
const std::string& fromVolId, const std::string& toVolId,
|
|
|
|
|
|
|
|
const android::sp<android::os::IVoldTaskListener>& listener) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
CHECK_ARGUMENT_ID(fromVolId);
|
|
|
|
CHECK_ARGUMENT_ID(fromVolId);
|
|
|
|
CHECK_ARGUMENT_ID(toVolId);
|
|
|
|
CHECK_ARGUMENT_ID(toVolId);
|
|
|
@ -419,9 +422,7 @@ binder::Status VoldNativeService::moveStorage(const std::string& fromVolId,
|
|
|
|
return error("Failed to find volume " + toVolId);
|
|
|
|
return error("Failed to find volume " + toVolId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::thread([=]() {
|
|
|
|
std::thread([=]() { android::vold::MoveStorage(fromVol, toVol, listener); }).detach();
|
|
|
|
android::vold::MoveStorage(fromVol, toVol, listener);
|
|
|
|
|
|
|
|
}).detach();
|
|
|
|
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -431,11 +432,20 @@ binder::Status VoldNativeService::remountUid(int32_t uid, int32_t remountMode) {
|
|
|
|
|
|
|
|
|
|
|
|
std::string tmp;
|
|
|
|
std::string tmp;
|
|
|
|
switch (remountMode) {
|
|
|
|
switch (remountMode) {
|
|
|
|
case REMOUNT_MODE_NONE: tmp = "none"; break;
|
|
|
|
case REMOUNT_MODE_NONE:
|
|
|
|
case REMOUNT_MODE_DEFAULT: tmp = "default"; break;
|
|
|
|
tmp = "none";
|
|
|
|
case REMOUNT_MODE_READ: tmp = "read"; break;
|
|
|
|
break;
|
|
|
|
case REMOUNT_MODE_WRITE: tmp = "write"; break;
|
|
|
|
case REMOUNT_MODE_DEFAULT:
|
|
|
|
default: return error("Unknown mode " + std::to_string(remountMode));
|
|
|
|
tmp = "default";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REMOUNT_MODE_READ:
|
|
|
|
|
|
|
|
tmp = "read";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REMOUNT_MODE_WRITE:
|
|
|
|
|
|
|
|
tmp = "write";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return error("Unknown mode " + std::to_string(remountMode));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return translate(VolumeManager::Instance()->remountUid(uid, tmp));
|
|
|
|
return translate(VolumeManager::Instance()->remountUid(uid, tmp));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -449,14 +459,15 @@ binder::Status VoldNativeService::mkdirs(const std::string& path) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::createObb(const std::string& sourcePath,
|
|
|
|
binder::Status VoldNativeService::createObb(const std::string& sourcePath,
|
|
|
|
const std::string& sourceKey, int32_t ownerGid, std::string* _aidl_return) {
|
|
|
|
const std::string& sourceKey, int32_t ownerGid,
|
|
|
|
|
|
|
|
std::string* _aidl_return) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
CHECK_ARGUMENT_PATH(sourcePath);
|
|
|
|
CHECK_ARGUMENT_PATH(sourcePath);
|
|
|
|
CHECK_ARGUMENT_HEX(sourceKey);
|
|
|
|
CHECK_ARGUMENT_HEX(sourceKey);
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
|
|
|
|
|
|
|
|
return translate(
|
|
|
|
return translate(
|
|
|
|
VolumeManager::Instance()->createObb(sourcePath, sourceKey, ownerGid, _aidl_return));
|
|
|
|
VolumeManager::Instance()->createObb(sourcePath, sourceKey, ownerGid, _aidl_return));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::destroyObb(const std::string& volId) {
|
|
|
|
binder::Status VoldNativeService::destroyObb(const std::string& volId) {
|
|
|
@ -467,41 +478,35 @@ binder::Status VoldNativeService::destroyObb(const std::string& volId) {
|
|
|
|
return translate(VolumeManager::Instance()->destroyObb(volId));
|
|
|
|
return translate(VolumeManager::Instance()->destroyObb(volId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::fstrim(int32_t fstrimFlags,
|
|
|
|
binder::Status VoldNativeService::fstrim(
|
|
|
|
const android::sp<android::os::IVoldTaskListener>& listener) {
|
|
|
|
int32_t fstrimFlags, const android::sp<android::os::IVoldTaskListener>& listener) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
|
|
|
|
|
|
|
|
std::thread([=]() {
|
|
|
|
std::thread([=]() { android::vold::Trim(listener); }).detach();
|
|
|
|
android::vold::Trim(listener);
|
|
|
|
|
|
|
|
}).detach();
|
|
|
|
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::runIdleMaint(
|
|
|
|
binder::Status VoldNativeService::runIdleMaint(
|
|
|
|
const android::sp<android::os::IVoldTaskListener>& listener) {
|
|
|
|
const android::sp<android::os::IVoldTaskListener>& listener) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
|
|
|
|
|
|
|
|
std::thread([=]() {
|
|
|
|
std::thread([=]() { android::vold::RunIdleMaint(listener); }).detach();
|
|
|
|
android::vold::RunIdleMaint(listener);
|
|
|
|
|
|
|
|
}).detach();
|
|
|
|
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::abortIdleMaint(
|
|
|
|
binder::Status VoldNativeService::abortIdleMaint(
|
|
|
|
const android::sp<android::os::IVoldTaskListener>& listener) {
|
|
|
|
const android::sp<android::os::IVoldTaskListener>& listener) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
|
|
|
|
|
|
|
|
std::thread([=]() {
|
|
|
|
std::thread([=]() { android::vold::AbortIdleMaint(listener); }).detach();
|
|
|
|
android::vold::AbortIdleMaint(listener);
|
|
|
|
|
|
|
|
}).detach();
|
|
|
|
|
|
|
|
return ok();
|
|
|
|
return ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::mountAppFuse(int32_t uid, int32_t pid, int32_t mountId,
|
|
|
|
binder::Status VoldNativeService::mountAppFuse(int32_t uid, int32_t pid, int32_t mountId,
|
|
|
|
android::base::unique_fd* _aidl_return) {
|
|
|
|
android::base::unique_fd* _aidl_return) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
ACQUIRE_LOCK;
|
|
|
|
|
|
|
|
|
|
|
@ -541,7 +546,7 @@ binder::Status VoldNativeService::fdeComplete(int32_t* _aidl_return) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int fdeEnableInternal(int32_t passwordType, const std::string& password,
|
|
|
|
static int fdeEnableInternal(int32_t passwordType, const std::string& password,
|
|
|
|
int32_t encryptionFlags) {
|
|
|
|
int32_t encryptionFlags) {
|
|
|
|
bool noUi = (encryptionFlags & VoldNativeService::ENCRYPTION_FLAG_NO_UI) != 0;
|
|
|
|
bool noUi = (encryptionFlags & VoldNativeService::ENCRYPTION_FLAG_NO_UI) != 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (int tries = 0; tries < 2; ++tries) {
|
|
|
|
for (int tries = 0; tries < 2; ++tries) {
|
|
|
@ -562,8 +567,8 @@ static int fdeEnableInternal(int32_t passwordType, const std::string& password,
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::fdeEnable(int32_t passwordType,
|
|
|
|
binder::Status VoldNativeService::fdeEnable(int32_t passwordType, const std::string& password,
|
|
|
|
const std::string& password, int32_t encryptionFlags) {
|
|
|
|
int32_t encryptionFlags) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
|
|
|
|
|
|
|
@ -581,7 +586,7 @@ binder::Status VoldNativeService::fdeEnable(int32_t passwordType,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::fdeChangePassword(int32_t passwordType,
|
|
|
|
binder::Status VoldNativeService::fdeChangePassword(int32_t passwordType,
|
|
|
|
const std::string& password) {
|
|
|
|
const std::string& password) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
|
|
|
|
|
|
|
@ -595,8 +600,7 @@ binder::Status VoldNativeService::fdeVerifyPassword(const std::string& password)
|
|
|
|
return translate(cryptfs_verify_passwd(password.c_str()));
|
|
|
|
return translate(cryptfs_verify_passwd(password.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::fdeGetField(const std::string& key,
|
|
|
|
binder::Status VoldNativeService::fdeGetField(const std::string& key, std::string* _aidl_return) {
|
|
|
|
std::string* _aidl_return) {
|
|
|
|
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
|
|
|
|
|
|
|
@ -609,8 +613,7 @@ binder::Status VoldNativeService::fdeGetField(const std::string& key,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::fdeSetField(const std::string& key,
|
|
|
|
binder::Status VoldNativeService::fdeSetField(const std::string& key, const std::string& value) {
|
|
|
|
const std::string& value) {
|
|
|
|
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
|
|
|
|
|
|
|
@ -692,8 +695,7 @@ binder::Status VoldNativeService::encryptFstab(const std::string& mountPoint) {
|
|
|
|
return translateBool(e4crypt_mount_metadata_encrypted(mountPoint, true));
|
|
|
|
return translateBool(e4crypt_mount_metadata_encrypted(mountPoint, true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::createUserKey(int32_t userId, int32_t userSerial,
|
|
|
|
binder::Status VoldNativeService::createUserKey(int32_t userId, int32_t userSerial, bool ephemeral) {
|
|
|
|
bool ephemeral) {
|
|
|
|
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
|
|
|
|
|
|
|
@ -708,7 +710,8 @@ binder::Status VoldNativeService::destroyUserKey(int32_t userId) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::addUserKeyAuth(int32_t userId, int32_t userSerial,
|
|
|
|
binder::Status VoldNativeService::addUserKeyAuth(int32_t userId, int32_t userSerial,
|
|
|
|
const std::string& token, const std::string& secret) {
|
|
|
|
const std::string& token,
|
|
|
|
|
|
|
|
const std::string& secret) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
|
|
|
|
|
|
|
@ -723,7 +726,8 @@ binder::Status VoldNativeService::fixateNewestUserKeyAuth(int32_t userId) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::unlockUserKey(int32_t userId, int32_t userSerial,
|
|
|
|
binder::Status VoldNativeService::unlockUserKey(int32_t userId, int32_t userSerial,
|
|
|
|
const std::string& token, const std::string& secret) {
|
|
|
|
const std::string& token,
|
|
|
|
|
|
|
|
const std::string& secret) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
ACQUIRE_CRYPT_LOCK;
|
|
|
|
|
|
|
|
|
|
|
@ -738,7 +742,8 @@ binder::Status VoldNativeService::lockUserKey(int32_t userId) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::prepareUserStorage(const std::unique_ptr<std::string>& uuid,
|
|
|
|
binder::Status VoldNativeService::prepareUserStorage(const std::unique_ptr<std::string>& uuid,
|
|
|
|
int32_t userId, int32_t userSerial, int32_t flags) {
|
|
|
|
int32_t userId, int32_t userSerial,
|
|
|
|
|
|
|
|
int32_t flags) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
std::string empty_string = "";
|
|
|
|
std::string empty_string = "";
|
|
|
|
auto uuid_ = uuid ? *uuid : empty_string;
|
|
|
|
auto uuid_ = uuid ? *uuid : empty_string;
|
|
|
@ -749,7 +754,7 @@ binder::Status VoldNativeService::prepareUserStorage(const std::unique_ptr<std::
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
binder::Status VoldNativeService::destroyUserStorage(const std::unique_ptr<std::string>& uuid,
|
|
|
|
binder::Status VoldNativeService::destroyUserStorage(const std::unique_ptr<std::string>& uuid,
|
|
|
|
int32_t userId, int32_t flags) {
|
|
|
|
int32_t userId, int32_t flags) {
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
ENFORCE_UID(AID_SYSTEM);
|
|
|
|
std::string empty_string = "";
|
|
|
|
std::string empty_string = "";
|
|
|
|
auto uuid_ = uuid ? *uuid : empty_string;
|
|
|
|
auto uuid_ = uuid ? *uuid : empty_string;
|
|
|
|