summaryrefslogtreecommitdiff
path: root/init/service_parser.cpp
AgeCommit message (Collapse)Author
2022-05-02init: Skip interface duplicates if service is an overrideAlexander Koskovich
These aren't actually duplicate interfaces because we are overriding the service so interfaces in the original definition will never be used. Test: Verify 'm dist' works without complaining about duplicate interfaces. Change-Id: Iab5e1d8bb4cb7d5b2608028c3cee73af94c47424
2020-11-19Returns a service parse error on overrides across the treble boundary.Daniel Norman
Also includes new --out_<partition> flags for system,system_ext,product,vendor,odm to allow host_init_verifier to work with a collection of init rc files. Test: host_init_verifier --out_system=... --out_vendor=... where vendor contains an init rc file that overrides a service present in system. Observe parse failure and non-zero exit. Bug: 163089173 Change-Id: I520fef613e0036df8a7d47a98d47405eaa969110
2020-10-26init/service_parser: Add arguments `window' and `target' for `critical'Woody Lin
The critical services can now using the interface `critical [window=<fatal crash window mins>] [target=<fatal reboot target>]` to setup the timing window that when there are more than 4 crashes in it, the init will regard it as a fatal system error and reboot the system. Config `window=${zygote.critical_window.minute:-off}' and `target=zygote-fatal' for all system-server services, so platform that configures ro.boot.zygote_critical_window can escape the system-server crash-loop via init fatal handler. Bug: 146818493 Change-Id: Ib2dc253616be6935ab9ab52184a1b6394665e813
2020-05-01Reject services that are both critical and oneshotNikita Ioffe
Test: atest CtsInitTestCases Test: builds Test: device boots Bug: 155275196 Merged-In: I1bb9099371bd1a3f339396ef343c49b054fcef66 Change-Id: I1bb9099371bd1a3f339396ef343c49b054fcef66 (cherry picked from commit 6a3c94b3aa9545b6a955caf558e5120ef4c12ee5)
2020-04-30init: Add task_profiles init commandSuren Baghdasaryan
Introduce new command to allow setting task profiles from inside .rc script. This is to replace usage of writepid when a service is trying to join a cgroup. Usage example from a .rc file: service surfaceflinger /system/bin/surfaceflinger task_profiles HighPerformance Bug: 155419956 Test: change .rc file and confirm task profile is applied Signed-off-by: Suren Baghdasaryan <surenb@google.com> Change-Id: I0add9c3b363a7cb1ea89778780896cae1c8a303c
2020-03-10Revert "init: handle property service callbacks asynchronously"Tom Cherry
This is apparently causing problems with reboot. This reverts commit 7205c6293341c82701e849fa29cfab66916d1052. Bug: 150863651 Test: build Change-Id: Ib8a4835cdc8358a54c7acdebc5c95038963a0419
2020-02-20init: handle property service callbacks asynchronouslyTom Cherry
A previous change moved property_service into its own thread, since there was otherwise a deadlock whenever a process called by init would try to set a property. This new thread, however, would send a message via a blocking socket to init for each property that it received, since init may need to take action depending on which property it is. Unfortunately, this means that the deadlock is still possible, the only difference is the socket's buffer must be filled before init deadlocks. There are possible partial solutions here: the socket's buffer may be increased or property_service may only send messages for the properties that init will take action on, however all of these solutions still lead to eventual deadlock. The only complete solution is to handle these messages asynchronously. This change, therefore, adds the following: 1) A lock for instructing init to reboot 2) A lock for waiting on properties 3) A lock for queueing new properties 4) A lock for any actions with ServiceList or any Services, enforced through thread annotations, particularly since this code was not designed with the intention of being multi-threaded. Bug: 146877356 Bug: 148236233 Test: boot Test: kill hwservicemanager without deadlock Change-Id: I84108e54217866205a48c45e8b59355012c32ea8
2020-02-20Refactor libinit_test_utils to not use libinit and expose its librariesTom Cherry
Users of libinit_test_utils must include all libraries that it uses. If it uses libinit, then there is a large number of libraries that must be included. To avoid this, make libinit_test_utils only use init_common_sources and the small number of required libraries that go along with those sources. Additionally, expose these sources as a default for users of libinit_test_utils. Test: build Change-Id: I224fa7e0590d073e4cd40412b5dcb6f72a64b6bf
2020-02-06Convert system/core to Result::ok()Bernie Innocenti
No functionality changes, this is a mechanical cleanup. Test: m Test: cd system/core && atest Change-Id: Ifdaa3ce1947ed578f656d5a446978726eb416c36
2020-02-04Delete dangerous comparison operators from base::expectedBernie Innocenti
These operators were included because they're present in the draft standard proposal of std::expected, but they were deemed to lead to bugs, particularly when T is implicitly convertible to bool. Change-Id: Ib149decf1f230198f358dc1ae0eaed71961363f6 Test: m
2019-12-05Remove service defined in an APEX during userspace rebootNikita Ioffe
Such services will be re-parsed and added back to the service list during post-fs-data stage. Test: adb reboot userspace Test: atest CtsInitTestCases Bug: 145669993 Bug: 135984674 Change-Id: Ibb393dfe0f101c4ebe37bc763733fd5d981d3691
2019-11-07init: Add support for native service registration with lmkdSuren Baghdasaryan
init should be able to register native services with lmkd so that they can be killed when needed. Only processes with oom_score_adjust not equal to the default -1000 will be registered with lmkd because with the score that low the process is unkillable anyway. Inform lmkd when a registered process is killed so that the record can be removed. Change init.rc to start lmkd during init phase so that it is there to register other services. Replace hardcoded oom_score_adj values with appropriate definitions. Bug: 129011369 Test: boot and verify native service registration Change-Id: Ie5ed62203395120d86dc1c8250fae01aa0b3c511 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-10-31init: hack for /charger symlinkYifan Hong
Legacy symlink from /charger to /system/bin/charger is removed. Instead, all Android R devices are required to use /system/bin/charger instead. See hardware/interfaces/health/2.1/README.md for details. Bug: 142286265 Test: charger mode Change-Id: Ib478a864ef68647bc9fc14650ca3d382952b80c8
2019-09-24init: add stdio_to_kmsg optionTom Cherry
Some services are not native android services and therefore don't log via the normal mechanisms. This gives developers an option to have their stdout/stderr logs sent directly to kmsg. Test: see test prints to kernel log Change-Id: I7973ea74d5cab3a90c2cd9a3d5de2266439d0c01
2019-09-18init: degeneralize subcontext init into only vendor_initTom Cherry
This code is more generic than it needs to be and one of the side effects is that an extra init process is forked for odm_init, despite it having the same context as vendor_init. I don't think anything is going to change regarding that soon, so this change stops forking that extra process to save its memory and simplifies the code overall. Bug: 141164879 Test: init still uses vendor_init for vendor_scripts Test: init unit tests Test: init only has one subcontext process Change-Id: I0d224455604a681711e32f89fb20132378f69060
2019-09-13init: add reboot_on_failure service optionTom Cherry
This replaces the recently added `exec_reboot_on_failure` builtin, since it'll be cleaner to extend service definitions than extending `exec`. This is in line with what we decided when adding `exec_start` instead of extending `exec` to add parameters for priority. Test: `exec_start` a service with a reboot_on_failure option and watch the system reboot appropriately when the service is not found and when the service terminates with a non-zero exit code. Change-Id: I332bf9839fa94840d159a810c4a6ba2522189d0b
2019-09-09Allow AIDL interfaces in service parsingJon Spivack
Bug: 138756857 Test: Manual (using mediaextractor as a test service) Change-Id: Ice2c695fca7062d6a115df13a6ac1d6fe82a3a98
2019-08-06Adds check_interface_{restart,start,stop} check_builtins.Daniel Norman
Includes refactoring out interface inheritance hierarchy logic to a new interface_utils file. Bug: 137397100 Test: 'm' with an init_rc that misspells an interface in an interface_start, interface_restart, or interface_stop line. Change-Id: I9f650289d64ae2b13435a81e1693c7ab5e6e9ecf
2019-08-01init: don't log in expand_props directlyTom Cherry
It's better to pass the error message to the caller to determine how best to print the error. Test: build Change-Id: Id8857c459df2f26c031650166609608d20e4d051
2019-07-23init: simplify keyword_mapTom Cherry
I've heard that keyword_map is too complex, in particular the tuple and the pair in BuiltinFunctionMap, so this change removes a lot of that complexity and, more importantly, better documents how all of this works. Test: boot, init unit tests Change-Id: I74e5f9de7f2ec524cb6127bb9da2956b5f307f56
2019-07-15init: clean up file / socket descriptor creationTom Cherry
clang-tidy hinted that some of this code wasn't right. Looking deeper, there is really not much related to file and socket descriptors, except that they're published in similar ways to the environment. All of the abstraction into a 'Descriptor' class takes us further away from specifying what we really mean. This removes that abstraction, adds stricter checks and better errors for parsing init scripts, reports sockets and files that are unable to be acquired before exec, and updates the README.md for the passcred option. Test: build, logd (uses files and sockets) works Change-Id: I59e611e95c85bdbefa779ef69b32b9dd4ee203e2
2019-07-11Checks the interface inheritance hierarchy in init_rc files.Daniel Norman
Bug: 118016875 Test: Added 'interface' lines to an init_rc file and observed errors when misspelled or missing entire inheritance hierarchy. Change-Id: I681420f15539742d8415808b2a0dcbf0bf6faaf1
2019-06-28Checks each interface in an init_rc file is a known hidl_interface.Daniel Norman
Test: Adding a misspelling to an init_rc's interface line and observing build failure. Bug: 77646540 Change-Id: I58f66d73f0bd9b4203e8259161843b56ad428d73
2019-06-26Move actual parsing from Service to ServiceParserTom Cherry
This is how this should have been done since the beginning. Test: build, boot Change-Id: Ifd795776c71a2e666da7fab90cbb3f356af93d4f
2019-06-26Split out ServiceList and ServiceParser from service.cpp/.hTom Cherry
These always should have been in their own files. Test: build Change-Id: I201109b5ee63016e78901bbfd404846d45e1d4e6