init: support setting rlimits per service
Add a new service option, `rlimit` that allows a given rlimit to be
set for a specific service instead of globally.
Use the same parsing, now allowing text such as 'cpu' or 'rtprio'
instead of relying on the enum value for the `setrlimit` builtin
command as well.
Bug: 63882119
Bug: 64894637
Test: boot bullhead, run a test app that attempts to set its rtprio to
95, see that the priority set fails normally but passes when
`rlimit rtprio 99 99` is used as its service option.
See that this fails when `rlimit rtprio 50 50` is used as well.
Test: new unit tests
Change-Id: I4a13ca20e8529937d8b4bc11718ffaaf77523a52
diff --git a/init/Android.bp b/init/Android.bp
index efa5a02..33dfe56 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -76,6 +76,7 @@
"security.cpp",
"selinux.cpp",
"service.cpp",
+ "rlimit_parser.cpp",
"tokenizer.cpp",
"uevent_listener.cpp",
"ueventd_parser.cpp",
@@ -163,6 +164,7 @@
"init_test.cpp",
"property_service_test.cpp",
"result_test.cpp",
+ "rlimit_parser_test.cpp",
"service_test.cpp",
"ueventd_test.cpp",
"util_test.cpp",