diff options
author | Tom Cherry | 2018-04-12 17:31:02 -0500 |
---|---|---|
committer | Gerrit Code Review | 2018-04-12 17:31:02 -0500 |
commit | 4396bb85da4fc7f4c9b4cb153d56af504c781ca1 (patch) | |
tree | d65037787ea4c489ace30854b5dd09e7a8b33b56 | |
parent | 183b575e7856e831c5f6f8b9ea0ca32e4f3fe2f9 (diff) | |
parent | a1dbeb8d338017715ae7747e5a7a3999a54e7213 (diff) | |
download | platform-system-core-4396bb85da4fc7f4c9b4cb153d56af504c781ca1.tar.gz platform-system-core-4396bb85da4fc7f4c9b4cb153d56af504c781ca1.tar.xz platform-system-core-4396bb85da4fc7f4c9b4cb153d56af504c781ca1.zip |
Merge "init: do not impose vendor_init restrictions on old vendor images"
-rw-r--r-- | init/host_init_stubs.h | 5 | ||||
-rw-r--r-- | init/property_service.cpp | 9 | ||||
-rw-r--r-- | init/subcontext.cpp | 9 |
3 files changed, 18 insertions, 5 deletions
diff --git a/init/host_init_stubs.h b/init/host_init_stubs.h index f31ece60c..ddfb7ae7d 100644 --- a/init/host_init_stubs.h +++ b/init/host_init_stubs.h | |||
@@ -35,6 +35,11 @@ namespace base { | |||
35 | 35 | ||
36 | std::string GetProperty(const std::string& key, const std::string& default_value); | 36 | std::string GetProperty(const std::string& key, const std::string& default_value); |
37 | bool GetBoolProperty(const std::string& key, bool default_value); | 37 | bool GetBoolProperty(const std::string& key, bool default_value); |
38 | template <typename T> | ||
39 | T GetIntProperty(const std::string&, T default_value, T = std::numeric_limits<T>::min(), | ||
40 | T = std::numeric_limits<T>::max()) { | ||
41 | return default_value; | ||
42 | } | ||
38 | 43 | ||
39 | } // namespace base | 44 | } // namespace base |
40 | } // namespace android | 45 | } // namespace android |
diff --git a/init/property_service.cpp b/init/property_service.cpp index 95ef35c30..99d3c83b1 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp | |||
@@ -64,6 +64,7 @@ | |||
64 | 64 | ||
65 | using namespace std::literals; | 65 | using namespace std::literals; |
66 | 66 | ||
67 | using android::base::GetIntProperty; | ||
67 | using android::base::ReadFileToString; | 68 | using android::base::ReadFileToString; |
68 | using android::base::Split; | 69 | using android::base::Split; |
69 | using android::base::StartsWith; | 70 | using android::base::StartsWith; |
@@ -541,9 +542,11 @@ static void LoadProperties(char* data, const char* filter, const char* filename) | |||
541 | size_t flen = 0; | 542 | size_t flen = 0; |
542 | 543 | ||
543 | const char* context = kInitContext.c_str(); | 544 | const char* context = kInitContext.c_str(); |
544 | for (const auto& [path_prefix, secontext] : paths_and_secontexts) { | 545 | if (GetIntProperty("ro.vndk.version", 28) >= 28) { |
545 | if (StartsWith(filename, path_prefix)) { | 546 | for (const auto& [path_prefix, secontext] : paths_and_secontexts) { |
546 | context = secontext; | 547 | if (StartsWith(filename, path_prefix)) { |
548 | context = secontext; | ||
549 | } | ||
547 | } | 550 | } |
548 | } | 551 | } |
549 | 552 | ||
diff --git a/init/subcontext.cpp b/init/subcontext.cpp index c1846f76d..9c0c0bb4f 100644 --- a/init/subcontext.cpp +++ b/init/subcontext.cpp | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "util.h" | 30 | #include "util.h" |
31 | 31 | ||
32 | #if defined(__ANDROID__) | 32 | #if defined(__ANDROID__) |
33 | #include <android-base/properties.h> | ||
34 | |||
33 | #include "property_service.h" | 35 | #include "property_service.h" |
34 | #include "selinux.h" | 36 | #include "selinux.h" |
35 | #else | 37 | #else |
@@ -37,6 +39,7 @@ | |||
37 | #endif | 39 | #endif |
38 | 40 | ||
39 | using android::base::GetExecutablePath; | 41 | using android::base::GetExecutablePath; |
42 | using android::base::GetIntProperty; | ||
40 | using android::base::Join; | 43 | using android::base::Join; |
41 | using android::base::Socketpair; | 44 | using android::base::Socketpair; |
42 | using android::base::Split; | 45 | using android::base::Split; |
@@ -354,8 +357,10 @@ Result<std::vector<std::string>> Subcontext::ExpandArgs(const std::vector<std::s | |||
354 | static std::vector<Subcontext> subcontexts; | 357 | static std::vector<Subcontext> subcontexts; |
355 | 358 | ||
356 | std::vector<Subcontext>* InitializeSubcontexts() { | 359 | std::vector<Subcontext>* InitializeSubcontexts() { |
357 | for (const auto& [path_prefix, secontext] : paths_and_secontexts) { | 360 | if (GetIntProperty("ro.vndk.version", 28) >= 28) { |
358 | subcontexts.emplace_back(path_prefix, secontext); | 361 | for (const auto& [path_prefix, secontext] : paths_and_secontexts) { |
362 | subcontexts.emplace_back(path_prefix, secontext); | ||
363 | } | ||
359 | } | 364 | } |
360 | return &subcontexts; | 365 | return &subcontexts; |
361 | } | 366 | } |