summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Cherry2018-04-12 17:31:02 -0500
committerGerrit Code Review2018-04-12 17:31:02 -0500
commit4396bb85da4fc7f4c9b4cb153d56af504c781ca1 (patch)
treed65037787ea4c489ace30854b5dd09e7a8b33b56
parent183b575e7856e831c5f6f8b9ea0ca32e4f3fe2f9 (diff)
parenta1dbeb8d338017715ae7747e5a7a3999a54e7213 (diff)
downloadplatform-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.h5
-rw-r--r--init/property_service.cpp9
-rw-r--r--init/subcontext.cpp9
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
36std::string GetProperty(const std::string& key, const std::string& default_value); 36std::string GetProperty(const std::string& key, const std::string& default_value);
37bool GetBoolProperty(const std::string& key, bool default_value); 37bool GetBoolProperty(const std::string& key, bool default_value);
38template <typename T>
39T 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
65using namespace std::literals; 65using namespace std::literals;
66 66
67using android::base::GetIntProperty;
67using android::base::ReadFileToString; 68using android::base::ReadFileToString;
68using android::base::Split; 69using android::base::Split;
69using android::base::StartsWith; 70using 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
39using android::base::GetExecutablePath; 41using android::base::GetExecutablePath;
42using android::base::GetIntProperty;
40using android::base::Join; 43using android::base::Join;
41using android::base::Socketpair; 44using android::base::Socketpair;
42using android::base::Split; 45using android::base::Split;
@@ -354,8 +357,10 @@ Result<std::vector<std::string>> Subcontext::ExpandArgs(const std::vector<std::s
354static std::vector<Subcontext> subcontexts; 357static std::vector<Subcontext> subcontexts;
355 358
356std::vector<Subcontext>* InitializeSubcontexts() { 359std::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}