init: V devices need to specify user
This also specifies user on an adbd service declaration which was missing before. It seems that certain services are declared mulitple times. Fixes: 276813155 Test: boot (on CF, the only V device in the tree) Test: remove 'user' specification and see error Change-Id: I138f3ace72d46f221551ad61e75ba4c01632da59
This commit is contained in:
parent
7d53332195
commit
e5349196b2
2 changed files with 36 additions and 2 deletions
|
@ -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";
|
||||
|
|
|
@ -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,8 +679,13 @@ Result<void> ServiceParser::EndSection() {
|
|||
}
|
||||
|
||||
if (service_->proc_attr_.parsed_uid == std::nullopt) {
|
||||
LOG(WARNING) << "No user specified for service '" << service_->name()
|
||||
<< "'. Defaults to root.";
|
||||
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_) {
|
||||
|
|
Loading…
Reference in a new issue