简体   繁体   English

新创建的服务的 AndroidP-SELinux 权限被拒绝

[英]AndroidP-SELinux Permission Denied for a new created service

when i add a new service, and find the error as follow:当我添加一个新服务时,发现错误如下:

SELinux : avc:  denied  { add } for service=xxxManagerService pid=3798 uid=1000 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_service:s0 tclass=service_manager permissive=0

then i add allow in system_server.te :然后我在system_server.te添加允许:

allow system_server default_android_service:service_manager { add };

but build error happened:但是发生了构建错误:

libsepol.report_failure: neverallow on line 517 of system/sepolicy/public/domain.te (or line 10355 of policy.conf) violated by allow system_server default_android_service:service_manager { add };
libsepol.check_assertions: 1 neverallow failures occurred
Error while expanding policy
out/host/linux-x86/bin/checkpolicy:  loading policy configuration from out/target/product/sti6030d111/obj/ETC/sepolicy_neverallows_intermediates/policy.conf
[ 11% 22/200] target thumb C++: libpqcontrol <= vendor/amlogic/common/frameworks/services/systemcontrol/PQ/SSMAction.cpp

what should i do to make it, and pass cts.我应该怎么做才能成功,并通过 cts。

Android comes with a long list of neverallow rules that make sure you don't give permissions which break the security of your device. Android 带有一长串neverallow规则,可确保您不会授予破坏设备安全性的权限。 Fortunately, these neverallow rules are well documented in the code.幸运的是,这些neverallow规则在代码中都有详细说明。 If you look up line 517 in system/sepolicy/public/domain.te you'll find this:如果您在system/sepolicy/public/domain.te查找第 517 行,您会发现:

Do not allow service_manager add for default service labels.不允许为默认服务标签添加 service_manager。 Instead domains should use a more specific type such as system_app_service rather than the generic type.相反,域应该使用更具体的类型,例如 system_app_service 而不是通用类型。 New service_types are defined in {,hw,vnd}service.te and new mappings from service name to service_type are defined in {,hw,vnd}service_contexts. {,hw,vnd}service.te 中定义了新的 service_types,{,hw,vnd}service_contexts 中定义了从服务名称到 service_type 的新映射。

You probably used the audit2allow to create the rule.您可能使用了audit2allow来创建规则。 This seems to be an easy solution at first, but it will almost always result in rule set that is hard to read.起初这似乎是一个简单的解决方案,但它几乎总是会导致难以阅读的规则集。 In the end there is no other way than understanding the basics of SELinux in Android.最后,除了了解 Android 中 SELinux 的基础知识之外,别无他法。

See here for more information.请参阅此处了解更多信息。

I cannot give you an example of what to do now as the things you need to do depend on the type of service you want to add.我无法举例说明现在要做什么,因为您需要做的事情取决于您要添加的服务类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM