Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 17 | #define ATRACE_TAG ATRACE_TAG_PACKAGE_MANAGER |
| 18 | |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 19 | #include "VoldNativeService.h" |
Jeff Sharkey | 01a0e7f | 2017-10-17 16:06:32 -0600 | [diff] [blame] | 20 | #include "Benchmark.h" |
Jeff Sharkey | 2048a28 | 2017-06-15 09:59:43 -0600 | [diff] [blame] | 21 | #include "CheckEncryption.h" |
| 22 | #include "IdleMaint.h" |
Jeff Sharkey | 01a0e7f | 2017-10-17 16:06:32 -0600 | [diff] [blame] | 23 | #include "MoveStorage.h" |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 24 | #include "Process.h" |
Jeff Sharkey | 2048a28 | 2017-06-15 09:59:43 -0600 | [diff] [blame] | 25 | #include "VolumeManager.h" |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 26 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 27 | #include "cryptfs.h" |
| 28 | #include "Ext4Crypt.h" |
| 29 | #include "MetadataCrypt.h" |
| 30 | |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 31 | #include <fstream> |
Jeff Sharkey | 01a0e7f | 2017-10-17 16:06:32 -0600 | [diff] [blame] | 32 | #include <thread> |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 33 | |
| 34 | #include <android-base/logging.h> |
| 35 | #include <android-base/stringprintf.h> |
| 36 | #include <android-base/strings.h> |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 37 | #include <ext4_utils/ext4_crypt.h> |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 38 | #include <fs_mgr.h> |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 39 | #include <private/android_filesystem_config.h> |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 40 | #include <utils/Trace.h> |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 41 | |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 42 | using android::base::StringPrintf; |
| 43 | using std::endl; |
| 44 | |
| 45 | namespace android { |
| 46 | namespace vold { |
| 47 | |
| 48 | namespace { |
| 49 | |
| 50 | constexpr const char* kDump = "android.permission.DUMP"; |
| 51 | |
| 52 | static binder::Status ok() { |
| 53 | return binder::Status::ok(); |
| 54 | } |
| 55 | |
| 56 | static binder::Status exception(uint32_t code, const std::string& msg) { |
| 57 | return binder::Status::fromExceptionCode(code, String8(msg.c_str())); |
| 58 | } |
| 59 | |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 60 | static binder::Status error(const std::string& msg) { |
| 61 | PLOG(ERROR) << msg; |
| 62 | return binder::Status::fromServiceSpecificError(errno, String8(msg.c_str())); |
| 63 | } |
| 64 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 65 | static binder::Status translate(int status) { |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 66 | if (status == 0) { |
| 67 | return binder::Status::ok(); |
| 68 | } else { |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 69 | return binder::Status::fromServiceSpecificError(status); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 70 | } |
| 71 | } |
| 72 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 73 | static binder::Status translateBool(bool status) { |
| 74 | if (status) { |
| 75 | return binder::Status::ok(); |
| 76 | } else { |
| 77 | return binder::Status::fromServiceSpecificError(status); |
| 78 | } |
| 79 | } |
| 80 | |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 81 | binder::Status checkPermission(const char* permission) { |
| 82 | pid_t pid; |
| 83 | uid_t uid; |
| 84 | |
| 85 | if (checkCallingPermission(String16(permission), reinterpret_cast<int32_t*>(&pid), |
| 86 | reinterpret_cast<int32_t*>(&uid))) { |
| 87 | return ok(); |
| 88 | } else { |
| 89 | return exception(binder::Status::EX_SECURITY, |
| 90 | StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, permission)); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | binder::Status checkUid(uid_t expectedUid) { |
| 95 | uid_t uid = IPCThreadState::self()->getCallingUid(); |
| 96 | if (uid == expectedUid || uid == AID_ROOT) { |
| 97 | return ok(); |
| 98 | } else { |
| 99 | return exception(binder::Status::EX_SECURITY, |
| 100 | StringPrintf("UID %d is not expected UID %d", uid, expectedUid)); |
| 101 | } |
| 102 | } |
| 103 | |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 104 | binder::Status checkArgumentId(const std::string& id) { |
| 105 | if (id.empty()) { |
| 106 | return exception(binder::Status::EX_ILLEGAL_ARGUMENT, "Missing ID"); |
| 107 | } |
| 108 | for (const char& c : id) { |
| 109 | if (!std::isalnum(c) && c != ':' && c != ',') { |
| 110 | return exception(binder::Status::EX_ILLEGAL_ARGUMENT, |
| 111 | StringPrintf("ID %s is malformed", id.c_str())); |
| 112 | } |
| 113 | } |
| 114 | return ok(); |
| 115 | } |
| 116 | |
| 117 | binder::Status checkArgumentPath(const std::string& path) { |
| 118 | if (path.empty()) { |
| 119 | return exception(binder::Status::EX_ILLEGAL_ARGUMENT, "Missing path"); |
| 120 | } |
| 121 | if (path[0] != '/') { |
| 122 | return exception(binder::Status::EX_ILLEGAL_ARGUMENT, |
| 123 | StringPrintf("Path %s is relative", path.c_str())); |
| 124 | } |
Jeff Sharkey | 01a0e7f | 2017-10-17 16:06:32 -0600 | [diff] [blame] | 125 | if ((path + '/').find("/../") != std::string::npos) { |
| 126 | return exception(binder::Status::EX_ILLEGAL_ARGUMENT, |
| 127 | StringPrintf("Path %s is shady", path.c_str())); |
| 128 | } |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 129 | for (const char& c : path) { |
| 130 | if (c == '\0' || c == '\n') { |
| 131 | return exception(binder::Status::EX_ILLEGAL_ARGUMENT, |
| 132 | StringPrintf("Path %s is malformed", path.c_str())); |
| 133 | } |
| 134 | } |
| 135 | return ok(); |
| 136 | } |
| 137 | |
| 138 | binder::Status checkArgumentHex(const std::string& hex) { |
| 139 | // Empty hex strings are allowed |
| 140 | for (const char& c : hex) { |
| 141 | if (!std::isxdigit(c) && c != ':' && c != '-') { |
| 142 | return exception(binder::Status::EX_ILLEGAL_ARGUMENT, |
| 143 | StringPrintf("Hex %s is malformed", hex.c_str())); |
| 144 | } |
| 145 | } |
| 146 | return ok(); |
| 147 | } |
| 148 | |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 149 | #define ENFORCE_UID(uid) { \ |
| 150 | binder::Status status = checkUid((uid)); \ |
| 151 | if (!status.isOk()) { \ |
| 152 | return status; \ |
| 153 | } \ |
| 154 | } |
| 155 | |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 156 | #define CHECK_ARGUMENT_ID(id) { \ |
| 157 | binder::Status status = checkArgumentId((id)); \ |
| 158 | if (!status.isOk()) { \ |
| 159 | return status; \ |
| 160 | } \ |
| 161 | } |
| 162 | |
| 163 | #define CHECK_ARGUMENT_PATH(path) { \ |
| 164 | binder::Status status = checkArgumentPath((path)); \ |
| 165 | if (!status.isOk()) { \ |
| 166 | return status; \ |
| 167 | } \ |
| 168 | } |
| 169 | |
| 170 | #define CHECK_ARGUMENT_HEX(hex) { \ |
| 171 | binder::Status status = checkArgumentHex((hex)); \ |
| 172 | if (!status.isOk()) { \ |
| 173 | return status; \ |
| 174 | } \ |
| 175 | } |
| 176 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 177 | #define ACQUIRE_LOCK \ |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 178 | std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getLock()); \ |
| 179 | ATRACE_CALL(); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 180 | |
| 181 | #define ACQUIRE_CRYPT_LOCK \ |
Jeff Sharkey | 67b8c49 | 2017-09-21 17:08:43 -0600 | [diff] [blame] | 182 | std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getCryptLock()); \ |
| 183 | ATRACE_CALL(); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 184 | |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 185 | } // namespace |
| 186 | |
| 187 | status_t VoldNativeService::start() { |
| 188 | IPCThreadState::self()->disableBackgroundScheduling(true); |
| 189 | status_t ret = BinderService<VoldNativeService>::publish(); |
| 190 | if (ret != android::OK) { |
| 191 | return ret; |
| 192 | } |
| 193 | sp<ProcessState> ps(ProcessState::self()); |
| 194 | ps->startThreadPool(); |
| 195 | ps->giveThreadPoolName(); |
| 196 | return android::OK; |
| 197 | } |
| 198 | |
| 199 | status_t VoldNativeService::dump(int fd, const Vector<String16> & /* args */) { |
| 200 | auto out = std::fstream(StringPrintf("/proc/self/fd/%d", fd)); |
| 201 | const binder::Status dump_permission = checkPermission(kDump); |
| 202 | if (!dump_permission.isOk()) { |
| 203 | out << dump_permission.toString8() << endl; |
| 204 | return PERMISSION_DENIED; |
| 205 | } |
| 206 | |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 207 | ACQUIRE_LOCK; |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 208 | out << "vold is happy!" << endl; |
| 209 | out.flush(); |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 210 | return NO_ERROR; |
| 211 | } |
| 212 | |
Jeff Sharkey | 814e9d3 | 2017-09-13 11:49:44 -0600 | [diff] [blame] | 213 | binder::Status VoldNativeService::setListener( |
| 214 | const android::sp<android::os::IVoldListener>& listener) { |
| 215 | ENFORCE_UID(AID_SYSTEM); |
| 216 | ACQUIRE_LOCK; |
| 217 | |
| 218 | VolumeManager::Instance()->setListener(listener); |
| 219 | return ok(); |
| 220 | } |
| 221 | |
Jeff Sharkey | cbe69fc | 2017-09-15 16:50:28 -0600 | [diff] [blame] | 222 | binder::Status VoldNativeService::monitor() { |
| 223 | ENFORCE_UID(AID_SYSTEM); |
| 224 | |
| 225 | // Simply acquire/release each lock for watchdog |
| 226 | { |
| 227 | ACQUIRE_LOCK; |
| 228 | } |
| 229 | { |
| 230 | ACQUIRE_CRYPT_LOCK; |
| 231 | } |
| 232 | |
| 233 | return ok(); |
| 234 | } |
| 235 | |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 236 | binder::Status VoldNativeService::reset() { |
| 237 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 238 | ACQUIRE_LOCK; |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 239 | |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 240 | return translate(VolumeManager::Instance()->reset()); |
| 241 | } |
| 242 | |
| 243 | binder::Status VoldNativeService::shutdown() { |
| 244 | ENFORCE_UID(AID_SYSTEM); |
| 245 | ACQUIRE_LOCK; |
| 246 | |
| 247 | return translate(VolumeManager::Instance()->shutdown()); |
| 248 | } |
| 249 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 250 | binder::Status VoldNativeService::mountAll() { |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 251 | ENFORCE_UID(AID_SYSTEM); |
| 252 | ACQUIRE_LOCK; |
| 253 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 254 | struct fstab* fstab = fs_mgr_read_fstab_default(); |
| 255 | int res = fs_mgr_mount_all(fstab, MOUNT_MODE_DEFAULT); |
| 256 | fs_mgr_free_fstab(fstab); |
| 257 | return translate(res); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | binder::Status VoldNativeService::onUserAdded(int32_t userId, int32_t userSerial) { |
| 261 | ENFORCE_UID(AID_SYSTEM); |
| 262 | ACQUIRE_LOCK; |
| 263 | |
| 264 | return translate(VolumeManager::Instance()->onUserAdded(userId, userSerial)); |
| 265 | } |
| 266 | |
| 267 | binder::Status VoldNativeService::onUserRemoved(int32_t userId) { |
| 268 | ENFORCE_UID(AID_SYSTEM); |
| 269 | ACQUIRE_LOCK; |
| 270 | |
| 271 | return translate(VolumeManager::Instance()->onUserRemoved(userId)); |
| 272 | } |
| 273 | |
| 274 | binder::Status VoldNativeService::onUserStarted(int32_t userId) { |
| 275 | ENFORCE_UID(AID_SYSTEM); |
| 276 | ACQUIRE_LOCK; |
| 277 | |
| 278 | return translate(VolumeManager::Instance()->onUserStarted(userId)); |
| 279 | } |
| 280 | |
| 281 | binder::Status VoldNativeService::onUserStopped(int32_t userId) { |
| 282 | ENFORCE_UID(AID_SYSTEM); |
| 283 | ACQUIRE_LOCK; |
| 284 | |
| 285 | return translate(VolumeManager::Instance()->onUserStopped(userId)); |
| 286 | } |
| 287 | |
Jeff Sharkey | 401b260 | 2017-12-14 22:15:20 -0700 | [diff] [blame^] | 288 | binder::Status VoldNativeService::onSecureKeyguardStateChanged(bool isShowing) { |
| 289 | ENFORCE_UID(AID_SYSTEM); |
| 290 | ACQUIRE_LOCK; |
| 291 | |
| 292 | return translate(VolumeManager::Instance()->onSecureKeyguardStateChanged(isShowing)); |
| 293 | } |
| 294 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 295 | binder::Status VoldNativeService::partition(const std::string& diskId, int32_t partitionType, |
| 296 | int32_t ratio) { |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 297 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 298 | CHECK_ARGUMENT_ID(diskId); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 299 | ACQUIRE_LOCK; |
| 300 | |
| 301 | auto disk = VolumeManager::Instance()->findDisk(diskId); |
| 302 | if (disk == nullptr) { |
| 303 | return error("Failed to find disk " + diskId); |
| 304 | } |
| 305 | switch (partitionType) { |
| 306 | case PARTITION_TYPE_PUBLIC: return translate(disk->partitionPublic()); |
| 307 | case PARTITION_TYPE_PRIVATE: return translate(disk->partitionPrivate()); |
| 308 | case PARTITION_TYPE_MIXED: return translate(disk->partitionMixed(ratio)); |
| 309 | default: return error("Unknown type " + std::to_string(partitionType)); |
| 310 | } |
| 311 | } |
| 312 | |
Jeff Sharkey | 3ce1825 | 2017-10-24 11:08:45 -0600 | [diff] [blame] | 313 | binder::Status VoldNativeService::forgetPartition(const std::string& partGuid, |
| 314 | const std::string& fsUuid) { |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 315 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 316 | CHECK_ARGUMENT_HEX(partGuid); |
Jeff Sharkey | 3ce1825 | 2017-10-24 11:08:45 -0600 | [diff] [blame] | 317 | CHECK_ARGUMENT_HEX(fsUuid); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 318 | ACQUIRE_LOCK; |
| 319 | |
Jeff Sharkey | 3ce1825 | 2017-10-24 11:08:45 -0600 | [diff] [blame] | 320 | return translate(VolumeManager::Instance()->forgetPartition(partGuid, fsUuid)); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 321 | } |
| 322 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 323 | binder::Status VoldNativeService::mount(const std::string& volId, int32_t mountFlags, |
| 324 | int32_t mountUserId) { |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 325 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 326 | CHECK_ARGUMENT_ID(volId); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 327 | ACQUIRE_LOCK; |
| 328 | |
| 329 | auto vol = VolumeManager::Instance()->findVolume(volId); |
| 330 | if (vol == nullptr) { |
| 331 | return error("Failed to find volume " + volId); |
| 332 | } |
| 333 | |
| 334 | vol->setMountFlags(mountFlags); |
| 335 | vol->setMountUserId(mountUserId); |
| 336 | |
| 337 | int res = vol->mount(); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 338 | if ((mountFlags & MOUNT_FLAG_PRIMARY) != 0) { |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 339 | VolumeManager::Instance()->setPrimary(vol); |
| 340 | } |
| 341 | return translate(res); |
| 342 | } |
| 343 | |
| 344 | binder::Status VoldNativeService::unmount(const std::string& volId) { |
| 345 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 346 | CHECK_ARGUMENT_ID(volId); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 347 | ACQUIRE_LOCK; |
| 348 | |
| 349 | auto vol = VolumeManager::Instance()->findVolume(volId); |
| 350 | if (vol == nullptr) { |
| 351 | return error("Failed to find volume " + volId); |
| 352 | } |
| 353 | return translate(vol->unmount()); |
| 354 | } |
| 355 | |
| 356 | binder::Status VoldNativeService::format(const std::string& volId, const std::string& fsType) { |
| 357 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 358 | CHECK_ARGUMENT_ID(volId); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 359 | ACQUIRE_LOCK; |
| 360 | |
| 361 | auto vol = VolumeManager::Instance()->findVolume(volId); |
| 362 | if (vol == nullptr) { |
| 363 | return error("Failed to find volume " + volId); |
| 364 | } |
| 365 | return translate(vol->format(fsType)); |
| 366 | } |
| 367 | |
Jeff Sharkey | 2048a28 | 2017-06-15 09:59:43 -0600 | [diff] [blame] | 368 | static binder::Status pathForVolId(const std::string& volId, std::string* path) { |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 369 | if (volId == "private" || volId == "null") { |
Jeff Sharkey | 2048a28 | 2017-06-15 09:59:43 -0600 | [diff] [blame] | 370 | *path = "/data"; |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 371 | } else { |
| 372 | auto vol = VolumeManager::Instance()->findVolume(volId); |
| 373 | if (vol == nullptr) { |
| 374 | return error("Failed to find volume " + volId); |
| 375 | } |
| 376 | if (vol->getType() != VolumeBase::Type::kPrivate) { |
| 377 | return error("Volume " + volId + " not private"); |
| 378 | } |
| 379 | if (vol->getState() != VolumeBase::State::kMounted) { |
| 380 | return error("Volume " + volId + " not mounted"); |
| 381 | } |
Jeff Sharkey | 2048a28 | 2017-06-15 09:59:43 -0600 | [diff] [blame] | 382 | *path = vol->getPath(); |
| 383 | if (path->empty()) { |
| 384 | return error("Volume " + volId + " missing path"); |
| 385 | } |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 386 | } |
Jeff Sharkey | 2048a28 | 2017-06-15 09:59:43 -0600 | [diff] [blame] | 387 | return ok(); |
| 388 | } |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 389 | |
Jeff Sharkey | 2048a28 | 2017-06-15 09:59:43 -0600 | [diff] [blame] | 390 | binder::Status VoldNativeService::benchmark( |
| 391 | const std::string& volId, const android::sp<android::os::IVoldTaskListener>& listener) { |
| 392 | ENFORCE_UID(AID_SYSTEM); |
| 393 | CHECK_ARGUMENT_ID(volId); |
| 394 | ACQUIRE_LOCK; |
| 395 | |
| 396 | std::string path; |
| 397 | auto status = pathForVolId(volId, &path); |
| 398 | if (!status.isOk()) return status; |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 399 | |
Jeff Sharkey | 01a0e7f | 2017-10-17 16:06:32 -0600 | [diff] [blame] | 400 | std::thread([=]() { |
| 401 | android::vold::Benchmark(path, listener); |
| 402 | }).detach(); |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 403 | return ok(); |
| 404 | } |
| 405 | |
Jeff Sharkey | 2048a28 | 2017-06-15 09:59:43 -0600 | [diff] [blame] | 406 | binder::Status VoldNativeService::checkEncryption(const std::string& volId) { |
| 407 | ENFORCE_UID(AID_SYSTEM); |
| 408 | CHECK_ARGUMENT_ID(volId); |
| 409 | ACQUIRE_LOCK; |
| 410 | |
| 411 | std::string path; |
| 412 | auto status = pathForVolId(volId, &path); |
| 413 | if (!status.isOk()) return status; |
| 414 | return translate(android::vold::CheckEncryption(path)); |
| 415 | } |
| 416 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 417 | binder::Status VoldNativeService::moveStorage(const std::string& fromVolId, |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 418 | const std::string& toVolId, const android::sp<android::os::IVoldTaskListener>& listener) { |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 419 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 420 | CHECK_ARGUMENT_ID(fromVolId); |
| 421 | CHECK_ARGUMENT_ID(toVolId); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 422 | ACQUIRE_LOCK; |
| 423 | |
| 424 | auto fromVol = VolumeManager::Instance()->findVolume(fromVolId); |
| 425 | auto toVol = VolumeManager::Instance()->findVolume(toVolId); |
| 426 | if (fromVol == nullptr) { |
| 427 | return error("Failed to find volume " + fromVolId); |
| 428 | } else if (toVol == nullptr) { |
| 429 | return error("Failed to find volume " + toVolId); |
| 430 | } |
Jeff Sharkey | 01a0e7f | 2017-10-17 16:06:32 -0600 | [diff] [blame] | 431 | |
| 432 | std::thread([=]() { |
| 433 | android::vold::MoveStorage(fromVol, toVol, listener); |
| 434 | }).detach(); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 435 | return ok(); |
| 436 | } |
| 437 | |
| 438 | binder::Status VoldNativeService::remountUid(int32_t uid, int32_t remountMode) { |
| 439 | ENFORCE_UID(AID_SYSTEM); |
| 440 | ACQUIRE_LOCK; |
| 441 | |
| 442 | std::string tmp; |
| 443 | switch (remountMode) { |
| 444 | case REMOUNT_MODE_NONE: tmp = "none"; break; |
| 445 | case REMOUNT_MODE_DEFAULT: tmp = "default"; break; |
| 446 | case REMOUNT_MODE_READ: tmp = "read"; break; |
| 447 | case REMOUNT_MODE_WRITE: tmp = "write"; break; |
| 448 | default: return error("Unknown mode " + std::to_string(remountMode)); |
| 449 | } |
| 450 | return translate(VolumeManager::Instance()->remountUid(uid, tmp)); |
| 451 | } |
| 452 | |
| 453 | binder::Status VoldNativeService::mkdirs(const std::string& path) { |
| 454 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 455 | CHECK_ARGUMENT_PATH(path); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 456 | ACQUIRE_LOCK; |
| 457 | |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 458 | return translate(VolumeManager::Instance()->mkdirs(path)); |
Jeff Sharkey | 9462bdd | 2017-09-07 15:27:28 -0600 | [diff] [blame] | 459 | } |
| 460 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 461 | binder::Status VoldNativeService::createObb(const std::string& sourcePath, |
| 462 | const std::string& sourceKey, int32_t ownerGid, std::string* _aidl_return) { |
| 463 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 464 | CHECK_ARGUMENT_PATH(sourcePath); |
| 465 | CHECK_ARGUMENT_HEX(sourceKey); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 466 | ACQUIRE_LOCK; |
| 467 | |
| 468 | return translate( |
| 469 | VolumeManager::Instance()->createObb(sourcePath, sourceKey, ownerGid, _aidl_return)); |
| 470 | } |
| 471 | |
| 472 | binder::Status VoldNativeService::destroyObb(const std::string& volId) { |
| 473 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | ec4fda2 | 2017-09-12 13:19:24 -0600 | [diff] [blame] | 474 | CHECK_ARGUMENT_ID(volId); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 475 | ACQUIRE_LOCK; |
| 476 | |
| 477 | return translate(VolumeManager::Instance()->destroyObb(volId)); |
| 478 | } |
| 479 | |
Jeff Sharkey | 52f7a91 | 2017-09-15 12:57:44 -0600 | [diff] [blame] | 480 | binder::Status VoldNativeService::fstrim(int32_t fstrimFlags, |
| 481 | const android::sp<android::os::IVoldTaskListener>& listener) { |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 482 | ENFORCE_UID(AID_SYSTEM); |
| 483 | ACQUIRE_LOCK; |
| 484 | |
Jeff Sharkey | 01a0e7f | 2017-10-17 16:06:32 -0600 | [diff] [blame] | 485 | std::thread([=]() { |
| 486 | android::vold::Trim(listener); |
| 487 | }).detach(); |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 488 | return ok(); |
| 489 | } |
| 490 | |
Jin Qian | a370c14 | 2017-10-17 15:41:45 -0700 | [diff] [blame] | 491 | binder::Status VoldNativeService::runIdleMaint( |
| 492 | const android::sp<android::os::IVoldTaskListener>& listener) { |
| 493 | ENFORCE_UID(AID_SYSTEM); |
| 494 | ACQUIRE_LOCK; |
| 495 | |
| 496 | std::thread([=]() { |
| 497 | android::vold::RunIdleMaint(listener); |
| 498 | }).detach(); |
| 499 | return ok(); |
| 500 | } |
| 501 | |
| 502 | binder::Status VoldNativeService::abortIdleMaint( |
| 503 | const android::sp<android::os::IVoldTaskListener>& listener) { |
| 504 | ENFORCE_UID(AID_SYSTEM); |
| 505 | ACQUIRE_LOCK; |
| 506 | |
| 507 | std::thread([=]() { |
| 508 | android::vold::AbortIdleMaint(listener); |
| 509 | }).detach(); |
| 510 | return ok(); |
| 511 | } |
| 512 | |
Jeff Sharkey | 11c2d38 | 2017-09-11 10:32:01 -0600 | [diff] [blame] | 513 | binder::Status VoldNativeService::mountAppFuse(int32_t uid, int32_t pid, int32_t mountId, |
| 514 | android::base::unique_fd* _aidl_return) { |
| 515 | ENFORCE_UID(AID_SYSTEM); |
| 516 | ACQUIRE_LOCK; |
| 517 | |
| 518 | return translate(VolumeManager::Instance()->mountAppFuse(uid, pid, mountId, _aidl_return)); |
| 519 | } |
| 520 | |
| 521 | binder::Status VoldNativeService::unmountAppFuse(int32_t uid, int32_t pid, int32_t mountId) { |
| 522 | ENFORCE_UID(AID_SYSTEM); |
| 523 | ACQUIRE_LOCK; |
| 524 | |
| 525 | return translate(VolumeManager::Instance()->unmountAppFuse(uid, pid, mountId)); |
| 526 | } |
| 527 | |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 528 | binder::Status VoldNativeService::fdeCheckPassword(const std::string& password) { |
| 529 | ENFORCE_UID(AID_SYSTEM); |
| 530 | ACQUIRE_CRYPT_LOCK; |
| 531 | |
| 532 | return translate(cryptfs_check_passwd(password.c_str())); |
| 533 | } |
| 534 | |
| 535 | binder::Status VoldNativeService::fdeRestart() { |
| 536 | ENFORCE_UID(AID_SYSTEM); |
| 537 | ACQUIRE_CRYPT_LOCK; |
| 538 | |
| 539 | // Spawn as thread so init can issue commands back to vold without |
| 540 | // causing deadlock, usually as a result of prep_data_fs. |
| 541 | std::thread(&cryptfs_restart).detach(); |
| 542 | return ok(); |
| 543 | } |
| 544 | |
| 545 | binder::Status VoldNativeService::fdeComplete(int32_t* _aidl_return) { |
| 546 | ENFORCE_UID(AID_SYSTEM); |
| 547 | ACQUIRE_CRYPT_LOCK; |
| 548 | |
| 549 | *_aidl_return = cryptfs_crypto_complete(); |
| 550 | return ok(); |
| 551 | } |
| 552 | |
| 553 | static int fdeEnableInternal(int32_t passwordType, const std::string& password, |
| 554 | int32_t encryptionFlags) { |
| 555 | bool noUi = (encryptionFlags & VoldNativeService::ENCRYPTION_FLAG_NO_UI) != 0; |
| 556 | |
| 557 | std::string how; |
| 558 | if ((encryptionFlags & VoldNativeService::ENCRYPTION_FLAG_IN_PLACE) != 0) { |
| 559 | how = "inplace"; |
| 560 | } else if ((encryptionFlags & VoldNativeService::ENCRYPTION_FLAG_WIPE) != 0) { |
| 561 | how = "wipe"; |
| 562 | } else { |
| 563 | LOG(ERROR) << "Missing encryption flag"; |
| 564 | return -1; |
| 565 | } |
| 566 | |
| 567 | for (int tries = 0; tries < 2; ++tries) { |
| 568 | int rc; |
| 569 | if (passwordType == VoldNativeService::PASSWORD_TYPE_DEFAULT) { |
| 570 | rc = cryptfs_enable_default(how.c_str(), noUi); |
| 571 | } else { |
| 572 | rc = cryptfs_enable(how.c_str(), passwordType, password.c_str(), noUi); |
| 573 | } |
| 574 | |
| 575 | if (rc == 0) { |
| 576 | return 0; |
| 577 | } else if (tries == 0) { |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 578 | KillProcessesWithOpenFiles(DATA_MNT_POINT, SIGKILL); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 579 | } |
| 580 | } |
| 581 | |
| 582 | return -1; |
| 583 | } |
| 584 | |
| 585 | binder::Status VoldNativeService::fdeEnable(int32_t passwordType, |
| 586 | const std::string& password, int32_t encryptionFlags) { |
| 587 | ENFORCE_UID(AID_SYSTEM); |
| 588 | ACQUIRE_CRYPT_LOCK; |
| 589 | |
| 590 | if (e4crypt_is_native()) { |
| 591 | if (passwordType != PASSWORD_TYPE_DEFAULT) { |
| 592 | return error("Unexpected password type"); |
| 593 | } |
| 594 | if (encryptionFlags != (ENCRYPTION_FLAG_IN_PLACE | ENCRYPTION_FLAG_NO_UI)) { |
| 595 | return error("Unexpected flags"); |
| 596 | } |
| 597 | return translateBool(e4crypt_enable_crypto()); |
| 598 | } |
| 599 | |
| 600 | // Spawn as thread so init can issue commands back to vold without |
| 601 | // causing deadlock, usually as a result of prep_data_fs. |
| 602 | std::thread(&fdeEnableInternal, passwordType, password, encryptionFlags).detach(); |
| 603 | return ok(); |
| 604 | } |
| 605 | |
| 606 | binder::Status VoldNativeService::fdeChangePassword(int32_t passwordType, |
| 607 | const std::string& password) { |
| 608 | ENFORCE_UID(AID_SYSTEM); |
| 609 | ACQUIRE_CRYPT_LOCK; |
| 610 | |
| 611 | return translate(cryptfs_changepw(passwordType, password.c_str())); |
| 612 | } |
| 613 | |
| 614 | binder::Status VoldNativeService::fdeVerifyPassword(const std::string& password) { |
| 615 | ENFORCE_UID(AID_SYSTEM); |
| 616 | ACQUIRE_CRYPT_LOCK; |
| 617 | |
| 618 | return translate(cryptfs_verify_passwd(password.c_str())); |
| 619 | } |
| 620 | |
| 621 | binder::Status VoldNativeService::fdeGetField(const std::string& key, |
| 622 | std::string* _aidl_return) { |
| 623 | ENFORCE_UID(AID_SYSTEM); |
| 624 | ACQUIRE_CRYPT_LOCK; |
| 625 | |
| 626 | char buf[PROPERTY_VALUE_MAX]; |
| 627 | if (cryptfs_getfield(key.c_str(), buf, sizeof(buf)) != CRYPTO_GETFIELD_OK) { |
| 628 | return error(StringPrintf("Failed to read field %s", key.c_str())); |
| 629 | } else { |
| 630 | *_aidl_return = buf; |
| 631 | return ok(); |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | binder::Status VoldNativeService::fdeSetField(const std::string& key, |
| 636 | const std::string& value) { |
| 637 | ENFORCE_UID(AID_SYSTEM); |
| 638 | ACQUIRE_CRYPT_LOCK; |
| 639 | |
| 640 | return translate(cryptfs_setfield(key.c_str(), value.c_str())); |
| 641 | } |
| 642 | |
| 643 | binder::Status VoldNativeService::fdeGetPasswordType(int32_t* _aidl_return) { |
| 644 | ENFORCE_UID(AID_SYSTEM); |
| 645 | ACQUIRE_CRYPT_LOCK; |
| 646 | |
| 647 | *_aidl_return = cryptfs_get_password_type(); |
| 648 | return ok(); |
| 649 | } |
| 650 | |
| 651 | binder::Status VoldNativeService::fdeGetPassword(std::string* _aidl_return) { |
| 652 | ENFORCE_UID(AID_SYSTEM); |
| 653 | ACQUIRE_CRYPT_LOCK; |
| 654 | |
| 655 | const char* res = cryptfs_get_password(); |
| 656 | if (res != nullptr) { |
| 657 | *_aidl_return = res; |
| 658 | } |
| 659 | return ok(); |
| 660 | } |
| 661 | |
| 662 | binder::Status VoldNativeService::fdeClearPassword() { |
| 663 | ENFORCE_UID(AID_SYSTEM); |
| 664 | ACQUIRE_CRYPT_LOCK; |
| 665 | |
| 666 | cryptfs_clear_password(); |
| 667 | return ok(); |
| 668 | } |
| 669 | |
| 670 | binder::Status VoldNativeService::fbeEnable() { |
| 671 | ENFORCE_UID(AID_SYSTEM); |
| 672 | ACQUIRE_CRYPT_LOCK; |
| 673 | |
| 674 | return translateBool(e4crypt_initialize_global_de()); |
| 675 | } |
| 676 | |
| 677 | binder::Status VoldNativeService::mountDefaultEncrypted() { |
| 678 | ENFORCE_UID(AID_SYSTEM); |
| 679 | ACQUIRE_CRYPT_LOCK; |
| 680 | |
| 681 | if (e4crypt_is_native()) { |
| 682 | return translateBool(e4crypt_mount_metadata_encrypted()); |
| 683 | } else { |
| 684 | // Spawn as thread so init can issue commands back to vold without |
| 685 | // causing deadlock, usually as a result of prep_data_fs. |
| 686 | std::thread(&cryptfs_mount_default_encrypted).detach(); |
| 687 | return ok(); |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | binder::Status VoldNativeService::initUser0() { |
| 692 | ENFORCE_UID(AID_SYSTEM); |
| 693 | ACQUIRE_CRYPT_LOCK; |
| 694 | |
| 695 | return translateBool(e4crypt_init_user0()); |
| 696 | } |
| 697 | |
| 698 | binder::Status VoldNativeService::isConvertibleToFbe(bool* _aidl_return) { |
| 699 | ENFORCE_UID(AID_SYSTEM); |
| 700 | ACQUIRE_CRYPT_LOCK; |
| 701 | |
| 702 | *_aidl_return = cryptfs_isConvertibleToFBE() != 0; |
| 703 | return ok(); |
| 704 | } |
| 705 | |
| 706 | binder::Status VoldNativeService::createUserKey(int32_t userId, int32_t userSerial, |
| 707 | bool ephemeral) { |
| 708 | ENFORCE_UID(AID_SYSTEM); |
| 709 | ACQUIRE_CRYPT_LOCK; |
| 710 | |
| 711 | return translateBool(e4crypt_vold_create_user_key(userId, userSerial, ephemeral)); |
| 712 | } |
| 713 | |
| 714 | binder::Status VoldNativeService::destroyUserKey(int32_t userId) { |
| 715 | ENFORCE_UID(AID_SYSTEM); |
| 716 | ACQUIRE_CRYPT_LOCK; |
| 717 | |
| 718 | return translateBool(e4crypt_destroy_user_key(userId)); |
| 719 | } |
| 720 | |
| 721 | binder::Status VoldNativeService::addUserKeyAuth(int32_t userId, int32_t userSerial, |
| 722 | const std::string& token, const std::string& secret) { |
| 723 | ENFORCE_UID(AID_SYSTEM); |
| 724 | ACQUIRE_CRYPT_LOCK; |
| 725 | |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 726 | return translateBool(e4crypt_add_user_key_auth(userId, userSerial, token, secret)); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | binder::Status VoldNativeService::fixateNewestUserKeyAuth(int32_t userId) { |
| 730 | ENFORCE_UID(AID_SYSTEM); |
| 731 | ACQUIRE_CRYPT_LOCK; |
| 732 | |
| 733 | return translateBool(e4crypt_fixate_newest_user_key_auth(userId)); |
| 734 | } |
| 735 | |
| 736 | binder::Status VoldNativeService::unlockUserKey(int32_t userId, int32_t userSerial, |
| 737 | const std::string& token, const std::string& secret) { |
| 738 | ENFORCE_UID(AID_SYSTEM); |
| 739 | ACQUIRE_CRYPT_LOCK; |
| 740 | |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 741 | return translateBool(e4crypt_unlock_user_key(userId, userSerial, token, secret)); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | binder::Status VoldNativeService::lockUserKey(int32_t userId) { |
| 745 | ENFORCE_UID(AID_SYSTEM); |
| 746 | ACQUIRE_CRYPT_LOCK; |
| 747 | |
| 748 | return translateBool(e4crypt_lock_user_key(userId)); |
| 749 | } |
| 750 | |
| 751 | binder::Status VoldNativeService::prepareUserStorage(const std::unique_ptr<std::string>& uuid, |
| 752 | int32_t userId, int32_t userSerial, int32_t flags) { |
| 753 | ENFORCE_UID(AID_SYSTEM); |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 754 | std::string empty_string = ""; |
| 755 | auto uuid_ = uuid ? *uuid : empty_string; |
Paul Crowley | 06f762d | 2017-10-16 10:59:51 -0700 | [diff] [blame] | 756 | CHECK_ARGUMENT_HEX(uuid_); |
| 757 | |
| 758 | ACQUIRE_CRYPT_LOCK; |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 759 | return translateBool(e4crypt_prepare_user_storage(uuid_, userId, userSerial, flags)); |
| 760 | } |
| 761 | |
| 762 | binder::Status VoldNativeService::destroyUserStorage(const std::unique_ptr<std::string>& uuid, |
| 763 | int32_t userId, int32_t flags) { |
| 764 | ENFORCE_UID(AID_SYSTEM); |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 765 | std::string empty_string = ""; |
| 766 | auto uuid_ = uuid ? *uuid : empty_string; |
Paul Crowley | 06f762d | 2017-10-16 10:59:51 -0700 | [diff] [blame] | 767 | CHECK_ARGUMENT_HEX(uuid_); |
| 768 | |
| 769 | ACQUIRE_CRYPT_LOCK; |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 770 | return translateBool(e4crypt_destroy_user_storage(uuid_, userId, flags)); |
| 771 | } |
| 772 | |
| 773 | binder::Status VoldNativeService::secdiscard(const std::string& path) { |
| 774 | ENFORCE_UID(AID_SYSTEM); |
Jeff Sharkey | 01a0e7f | 2017-10-17 16:06:32 -0600 | [diff] [blame] | 775 | CHECK_ARGUMENT_PATH(path); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 776 | ACQUIRE_CRYPT_LOCK; |
| 777 | |
Paul Crowley | 3b71fc5 | 2017-10-09 10:55:21 -0700 | [diff] [blame] | 778 | return translateBool(e4crypt_secdiscard(path)); |
Jeff Sharkey | 83b559c | 2017-09-12 16:30:52 -0600 | [diff] [blame] | 779 | } |
| 780 | |
Jeff Sharkey | 068c6be | 2017-09-06 13:47:40 -0600 | [diff] [blame] | 781 | } // namespace vold |
| 782 | } // namespace android |