Merge "Replace security_context_t type"

This commit is contained in:
Thiébaud Weksteen
2021-09-20 07:06:33 +00:00
committed by Gerrit Code Review

View File

@@ -1129,14 +1129,14 @@ static void isolateAppDataPerPackage(int userId, std::string_view package_name,
} }
// Relabel directory // Relabel directory
static void relabelDir(const char* path, security_context_t context, fail_fn_t fail_fn) { static void relabelDir(const char* path, const char* context, fail_fn_t fail_fn) {
if (setfilecon(path, context) != 0) { if (setfilecon(path, context) != 0) {
fail_fn(CREATE_ERROR("Failed to setfilecon %s %s", path, strerror(errno))); fail_fn(CREATE_ERROR("Failed to setfilecon %s %s", path, strerror(errno)));
} }
} }
// Relabel all directories under a path non-recursively. // Relabel all directories under a path non-recursively.
static void relabelAllDirs(const char* path, security_context_t context, fail_fn_t fail_fn) { static void relabelAllDirs(const char* path, const char* context, fail_fn_t fail_fn) {
DIR* dir = opendir(path); DIR* dir = opendir(path);
if (dir == nullptr) { if (dir == nullptr) {
fail_fn(CREATE_ERROR("Failed to opendir %s", path)); fail_fn(CREATE_ERROR("Failed to opendir %s", path));
@@ -1211,7 +1211,7 @@ static void isolateAppData(JNIEnv* env, const std::vector<std::string>& merged_d
snprintf(internalDePath, PATH_MAX, "/data/user_de"); snprintf(internalDePath, PATH_MAX, "/data/user_de");
snprintf(externalPrivateMountPath, PATH_MAX, "/mnt/expand"); snprintf(externalPrivateMountPath, PATH_MAX, "/mnt/expand");
security_context_t dataDataContext = nullptr; char* dataDataContext = nullptr;
if (getfilecon(internalDePath, &dataDataContext) < 0) { if (getfilecon(internalDePath, &dataDataContext) < 0) {
fail_fn(CREATE_ERROR("Unable to getfilecon on %s %s", internalDePath, fail_fn(CREATE_ERROR("Unable to getfilecon on %s %s", internalDePath,
strerror(errno))); strerror(errno)));