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

Commit c19a7dd3 authored by Alistair Delva's avatar Alistair Delva Committed by Gerrit Code Review
Browse files

Merge changes from topic "bootconfig-selinux-property"

* changes:
  Allow selinux to be set by bootconfig
  Allow android_dt_dir to be set by bootconfig
parents 43defd97 63594a4d
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ namespace {

enum EnforcingStatus { SELINUX_PERMISSIVE, SELINUX_ENFORCING };

EnforcingStatus StatusFromCmdline() {
EnforcingStatus StatusFromProperty() {
    EnforcingStatus status = SELINUX_ENFORCING;

    ImportKernelCmdline([&](const std::string& key, const std::string& value) {
@@ -101,12 +101,20 @@ EnforcingStatus StatusFromCmdline() {
        }
    });

    if (status == SELINUX_ENFORCING) {
        ImportBootconfig([&](const std::string& key, const std::string& value) {
            if (key == "androidboot.selinux" && value == "permissive") {
                status = SELINUX_PERMISSIVE;
            }
        });
    }

    return status;
}

bool IsEnforcing() {
    if (ALLOW_PERMISSIVE_SELINUX) {
        return StatusFromCmdline() == SELINUX_ENFORCING;
        return StatusFromProperty() == SELINUX_ENFORCING;
    }
    return true;
}
+9 −0
Original line number Diff line number Diff line
@@ -376,6 +376,15 @@ static std::string init_android_dt_dir() {
            android_dt_dir = value;
        }
    });
    // ..Or bootconfig
    if (android_dt_dir == kDefaultAndroidDtDir) {
        ImportBootconfig([&](const std::string& key, const std::string& value) {
            if (key == "androidboot.android_dt_dir") {
                android_dt_dir = value;
            }
        });
    }

    LOG(INFO) << "Using Android DT directory " << android_dt_dir;
    return android_dt_dir;
}