From 71dd7064cc6119a675c5ba2d8101159366288fa1 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Fri, 11 Dec 2020 09:26:55 -0800 Subject: [PATCH] ueventd: deprecate paths without /etc/ ueventd.rc scripts belong in the /etc/ directory of their given partition, not the root of the partition. This can cause problems, especially since Android.bp cannot write to the root directly, forcing vendors to use Android.mk for these files. Note that /system/etc/ueventd.rc moved long ago. Test: Tree-hugger Change-Id: I2dcaafc3c3f687f76ab6bc38af979c8b43346db0 --- init/ueventd.cpp | 14 +++++++++++++- init/ueventd_parser.cpp | 6 ++++-- init/ueventd_parser.h | 2 +- rootdir/ueventd.rc | 5 ++--- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/init/ueventd.cpp b/init/ueventd.cpp index 923d76906..331255b1e 100644 --- a/init/ueventd.cpp +++ b/init/ueventd.cpp @@ -16,6 +16,7 @@ #include "ueventd.h" +#include #include #include #include @@ -266,6 +267,17 @@ void ColdBoot::Run() { LOG(INFO) << "Coldboot took " << cold_boot_timer.duration().count() / 1000.0f << " seconds"; } +static UeventdConfiguration GetConfiguration() { + // TODO: Remove these legacy paths once Android S is no longer supported. + if (android::base::GetIntProperty("ro.product.first_api_level", 10000) <= __ANDROID_API_S__) { + auto hardware = android::base::GetProperty("ro.hardware", ""); + return ParseConfig({"/system/etc/ueventd.rc", "/vendor/ueventd.rc", "/odm/ueventd.rc", + "/ueventd." + hardware + ".rc"}); + } + + return ParseConfig({"/system/etc/ueventd.rc"}); +} + int ueventd_main(int argc, char** argv) { /* * init sets the umask to 077 for forked processes. We need to @@ -283,7 +295,7 @@ int ueventd_main(int argc, char** argv) { std::vector> uevent_handlers; - auto ueventd_configuration = ParseConfig("/system/etc/ueventd.rc"); + auto ueventd_configuration = GetConfiguration(); uevent_handlers.emplace_back(std::make_unique( std::move(ueventd_configuration.dev_permissions), diff --git a/init/ueventd_parser.cpp b/init/ueventd_parser.cpp index 26051584b..cab988bb3 100644 --- a/init/ueventd_parser.cpp +++ b/init/ueventd_parser.cpp @@ -230,7 +230,7 @@ Result SubsystemParser::EndSection() { return {}; } -UeventdConfiguration ParseConfig(const std::string& config) { +UeventdConfiguration ParseConfig(const std::vector& configs) { Parser parser; UeventdConfiguration ueventd_configuration; @@ -260,7 +260,9 @@ UeventdConfiguration ParseConfig(const std::string& config) { std::bind(ParseEnabledDisabledLine, _1, &ueventd_configuration.enable_parallel_restorecon)); - parser.ParseConfig(config); + for (const auto& config : configs) { + parser.ParseConfig(config); + } return ueventd_configuration; } diff --git a/init/ueventd_parser.h b/init/ueventd_parser.h index 2672626c9..eaafa5aa7 100644 --- a/init/ueventd_parser.h +++ b/init/ueventd_parser.h @@ -36,7 +36,7 @@ struct UeventdConfiguration { bool enable_parallel_restorecon = false; }; -UeventdConfiguration ParseConfig(const std::string& config); +UeventdConfiguration ParseConfig(const std::vector& configs); } // namespace init } // namespace android diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc index aebcd5f23..e9293b51e 100644 --- a/rootdir/ueventd.rc +++ b/rootdir/ueventd.rc @@ -1,6 +1,5 @@ -import /vendor/ueventd.rc -import /odm/ueventd.rc -import /ueventd.${ro.hardware}.rc +import /vendor/etc/ueventd.rc +import /odm/etc/ueventd.rc firmware_directories /etc/firmware/ /odm/firmware/ /vendor/firmware/ /firmware/image/ uevent_socket_rcvbuf_size 16M