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

Commit 12578125 authored by Tom Cherry's avatar Tom Cherry
Browse files

init: do not impose vendor_init restrictions on old vendor images

Do not restrict vendor_init restrictions on vendor images that were
built before P, as they will not have the correct permissions.

Bug: 77732028
Test: test new devices and see vendor_init still works
Merged-In: I636a07b54fbfb248e1d1a68a8f3c4d047fd5a9e9
Change-Id: I636a07b54fbfb248e1d1a68a8f3c4d047fd5a9e9
(cherry picked from commit a1dbeb8d)
parent c43dd751
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -35,6 +35,11 @@ namespace base {

std::string GetProperty(const std::string& key, const std::string& default_value);
bool GetBoolProperty(const std::string& key, bool default_value);
template <typename T>
T GetIntProperty(const std::string&, T default_value, T = std::numeric_limits<T>::min(),
                 T = std::numeric_limits<T>::max()) {
    return default_value;
}

}  // namespace base
}  // namespace android
+6 −3
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@

using namespace std::literals;

using android::base::GetIntProperty;
using android::base::ReadFileToString;
using android::base::Split;
using android::base::StartsWith;
@@ -541,11 +542,13 @@ static void LoadProperties(char* data, const char* filter, const char* filename)
    size_t flen = 0;

    const char* context = kInitContext.c_str();
    if (GetIntProperty("ro.vndk.version", 28) >= 28) {
        for (const auto& [path_prefix, secontext] : paths_and_secontexts) {
            if (StartsWith(filename, path_prefix)) {
                context = secontext;
            }
        }
    }

    if (filter) {
        flen = strlen(filter);
+7 −2
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@
#include "util.h"

#if defined(__ANDROID__)
#include <android-base/properties.h>

#include "property_service.h"
#include "selinux.h"
#else
@@ -37,6 +39,7 @@
#endif

using android::base::GetExecutablePath;
using android::base::GetIntProperty;
using android::base::Join;
using android::base::Socketpair;
using android::base::Split;
@@ -354,9 +357,11 @@ Result<std::vector<std::string>> Subcontext::ExpandArgs(const std::vector<std::s
static std::vector<Subcontext> subcontexts;

std::vector<Subcontext>* InitializeSubcontexts() {
    if (GetIntProperty("ro.vndk.version", 28) >= 28) {
        for (const auto& [path_prefix, secontext] : paths_and_secontexts) {
            subcontexts.emplace_back(path_prefix, secontext);
        }
    }
    return &subcontexts;
}