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

Commit ef7cc54e authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge changes I138f3ace,I19f7fc51 am: b8304d15

parents f2e17bf7 b8304d15
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -180,9 +180,11 @@ TEST(init, OverrideService) {
    std::string init_script = R"init(
service A something
    class first
    user nobody

service A something
    class second
    user nobody
    override

)init";
@@ -610,6 +612,31 @@ TEST(init, LazilyLoadedActionsCanBeTriggeredByTheNextTrigger) {
    EXPECT_EQ(2, num_executed);
}

TEST(init, RejectsNoUserStartingInV) {
    std::string init_script =
            R"init(
service A something
    class first
)init";

    TemporaryFile tf;
    ASSERT_TRUE(tf.fd != -1);
    ASSERT_TRUE(android::base::WriteStringToFd(init_script, tf.fd));

    ServiceList service_list;
    Parser parser;
    parser.AddSectionParser("service",
                            std::make_unique<ServiceParser>(&service_list, nullptr, std::nullopt));

    ASSERT_TRUE(parser.ParseConfig(tf.path));

    if (GetIntProperty("ro.vendor.api_level", 0) > __ANDROID_API_U__) {
        ASSERT_EQ(1u, parser.parse_error_count());
    } else {
        ASSERT_EQ(0u, parser.parse_error_count());
    }
}

TEST(init, RejectsCriticalAndOneshotService) {
    if (GetIntProperty("ro.product.first_api_level", 10000) < 30) {
        GTEST_SKIP() << "Test only valid for devices launching with R or later";
@@ -619,6 +646,7 @@ TEST(init, RejectsCriticalAndOneshotService) {
            R"init(
service A something
  class first
  user root
  critical
  oneshot
)init";
+8 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@

#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <hidl-util/FQName.h>
#include <processgroup/processgroup.h>
@@ -678,9 +679,14 @@ Result<void> ServiceParser::EndSection() {
    }

    if (service_->proc_attr_.parsed_uid == std::nullopt) {
        if (android::base::GetIntProperty("ro.vendor.api_level", 0) > __ANDROID_API_U__) {
            return Error() << "No user specified for service '" << service_->name()
                           << "'. Defaults to root.";
        } else {
            LOG(WARNING) << "No user specified for service '" << service_->name()
                         << "'. Defaults to root.";
        }
    }

    if (interface_inheritance_hierarchy_) {
        if (const auto& check_hierarchy_result = CheckInterfaceInheritanceHierarchy(
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ service adbd /system/bin/adbd --root_seclabel=u:r:su:s0
    disabled
    updatable
    seclabel u:r:adbd:s0
    user root

on property:vendor.sys.usb.adb.disabled=*
    setprop sys.usb.adb.disabled ${vendor.sys.usb.adb.disabled}