Replace security_context_t type

security_context_t has been marked as deprecated in libselinux from
version 3.2. Update to the `char*` type.

Bug: 190808996
Test: m
Change-Id: Ia632230e28c313d08119286973a5cf6401ef6910
This commit is contained in:
Thiébaud Weksteen
2021-09-15 19:49:24 +02:00
parent baea19f18f
commit 1fa50e17f4

View File

@@ -1129,14 +1129,14 @@ static void isolateAppDataPerPackage(int userId, std::string_view package_name,
}
// 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) {
fail_fn(CREATE_ERROR("Failed to setfilecon %s %s", path, strerror(errno)));
}
}
// 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);
if (dir == nullptr) {
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(externalPrivateMountPath, PATH_MAX, "/mnt/expand");
security_context_t dataDataContext = nullptr;
char* dataDataContext = nullptr;
if (getfilecon(internalDePath, &dataDataContext) < 0) {
fail_fn(CREATE_ERROR("Unable to getfilecon on %s %s", internalDePath,
strerror(errno)));