Merge "Switch to new project ID constants."

This commit is contained in:
Martijn Coenen 2020-02-20 08:58:56 +00:00 committed by Android (Google) Code Review
commit 6a4d95d08e
2 changed files with 12 additions and 8 deletions

View file

@ -40,6 +40,7 @@
#include <unistd.h>
#include <private/android_filesystem_config.h>
#include <private/android_projectid_config.h>
#include "android/os/IVold.h"
@ -814,7 +815,8 @@ bool fscrypt_prepare_user_storage(const std::string& volume_uuid, userid_t user_
// Setup quota project ID and inheritance policy
if (!IsFilesystemSupported("sdcardfs")) {
if (SetQuotaInherit(media_ce_path) != 0) return false;
if (SetQuotaProjectId(media_ce_path, multiuser_get_uid(user_id, AID_MEDIA_RW)) != 0) {
if (SetQuotaProjectId(media_ce_path,
multiuser_get_uid(user_id, PROJECT_ID_EXT_DEFAULT)) != 0) {
return false;
}
}

View file

@ -29,6 +29,7 @@
#include <cutils/fs.h>
#include <logwrap/logwrap.h>
#include <private/android_filesystem_config.h>
#include <private/android_projectid_config.h>
#include <dirent.h>
#include <fcntl.h>
@ -321,7 +322,13 @@ int PrepareAppDirFromRoot(const std::string& path, const std::string& root, int
}
std::string pathToCreate = root + appDir;
int depth = 0;
bool withinCache = false;
// Derive initial project ID
if (appDir == kAppDataDir || appDir == kAppMediaDir) {
projectId = uid - AID_APP_START + PROJECT_ID_EXT_DATA_START;
} else if (appDir == kAppObbDir) {
projectId = uid - AID_APP_START + PROJECT_ID_EXT_OBB_START;
}
while ((pos = leftToCreate.find('/')) != std::string::npos) {
std::string component = leftToCreate.substr(0, pos + 1);
leftToCreate = leftToCreate.erase(0, pos + 1);
@ -332,12 +339,7 @@ int PrepareAppDirFromRoot(const std::string& path, const std::string& root, int
// Android/data, eg Android/data/com.foo/cache
// Note that this "sticks" - eg subdirs of this dir need the same
// project ID.
withinCache = true;
}
if (withinCache) {
projectId = uid - AID_APP_START + AID_CACHE_GID_START;
} else {
projectId = uid - AID_APP_START + AID_EXT_GID_START;
projectId = uid - AID_APP_START + PROJECT_ID_EXT_CACHE_START;
}
if (fixupExisting && access(pathToCreate.c_str(), F_OK) == 0) {