Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cfacce23 authored by Pawan Wagh's avatar Pawan Wagh Committed by Automerger Merge Worker
Browse files

Merge "Revert "Treat Microdroid as OS with monolithic sepolicy"" am:...

Merge "Revert "Treat Microdroid as OS with monolithic sepolicy"" am: 61b9935e am: 421bb89a am: 00d9899c

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2626910



Change-Id: I36fe3251ef9478c48e85d1eb178d009c1b0bb13b
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a54eebd0 00d9899c
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -300,8 +300,6 @@ bool GetVendorMappingVersion(std::string* plat_vers) {
}

constexpr const char plat_policy_cil_file[] = "/system/etc/selinux/plat_sepolicy.cil";
constexpr const char kMicrodroidPrecompiledSepolicy[] =
        "/system/etc/selinux/microdroid_precompiled_sepolicy";

bool IsSplitPolicyDevice() {
    return access(plat_policy_cil_file, R_OK) != -1;
@@ -499,19 +497,14 @@ bool OpenSplitPolicy(PolicyFile* policy_file) {

bool OpenMonolithicPolicy(PolicyFile* policy_file) {
    static constexpr char kSepolicyFile[] = "/sepolicy";
    // In Microdroid the precompiled sepolicy is located on /system, since there is no vendor code.
    // TODO(b/287206497): refactor once we start conditionally compiling init for Microdroid.
    std::string monolithic_policy_file = access(kMicrodroidPrecompiledSepolicy, R_OK) == 0
                                                 ? kMicrodroidPrecompiledSepolicy
                                                 : kSepolicyFile;

    LOG(INFO) << "Opening SELinux policy from monolithic file " << monolithic_policy_file;
    policy_file->fd.reset(open(monolithic_policy_file.c_str(), O_RDONLY | O_CLOEXEC | O_NOFOLLOW));

    LOG(VERBOSE) << "Opening SELinux policy from monolithic file";
    policy_file->fd.reset(open(kSepolicyFile, O_RDONLY | O_CLOEXEC | O_NOFOLLOW));
    if (policy_file->fd < 0) {
        PLOG(ERROR) << "Failed to open monolithic SELinux policy";
        return false;
    }
    policy_file->path = monolithic_policy_file;
    policy_file->path = kSepolicyFile;
    return true;
}