Commit graph

14 commits

Author SHA1 Message Date
Jooyung Han
99fa346c35 init: Disable 'on' for non-Vendor APEXes
Mainline modules are not supposed to rely on 'on' action triggers in
their init scripts because events/properties are not guranteed to be
stable across many devices.

To reduce the potential risk of enabling 'on' for APEXes, for now, we
enable it for only Vendor APEXes.

When an init script in a non-Vendor APEX contains 'on' section, init
emits an error on parsing the script and skip the section.

For example, when init.rc in the ADBD APEX has 'on' section,
the following error is emitted on parsing the script.

  init: Parsing file /apex/com.android.adbd/etc/init.rc...
  init: /apex/com.android.adbd/etc/init.rc: 8: ParseSection() failed:
    'on' is supported for only Vendor APEXes.

Bug: 232543017
Test: see above
Change-Id: I6509c8d2c6b632369d215128f740f9ed78858605
2022-05-20 09:31:08 +00:00
Tom Cherry
a2f9136b2c Refactor libinit_test_utils to not use libinit and expose its libraries
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-20 11:31:35 -08:00
Bernie Innocenti
cecebbbacc Convert system/core to Result::ok()
No functionality changes, this is a mechanical cleanup.

Test: m
Test: cd system/core && atest
Change-Id: Ifdaa3ce1947ed578f656d5a446978726eb416c36
2020-02-06 17:04:27 +00:00
Nikita Ioffe
aaab596687 Only allow alphanumerical characters, '-' and '_' in event trigger names
This should help in preventing silly typos like "on foo:"

Test: atest CtsInitTestCases
Test: builds
Bug: 135984674
Change-Id: I6e4e18970e957d25dea9f557f0d31a759fbe6150
2019-10-11 17:44:54 +01:00
Tom Cherry
14c2472734 init: degeneralize subcontext init into only vendor_init
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-18 14:02:14 -07:00
Tom Cherry
bbcbc2ffb3 init: replace Result<Success> with Result<void>
Now that Result<T> is actually expected<T, ...>, and the expected
proposal states expected<void, ...> as the way to indicate an expected
object that returns either successfully with no object or an error,
let's move init's Result<Success> to the preferred Result<void>.

Bug: 132145659
Test: boot, init unit tests
Change-Id: Ib2f98396d8e6e274f95a496fcdfd8341f77585ee
2019-06-10 12:39:18 -07:00
Tom Cherry
fa79ae87f1 init: allow vendor init to action on any vendor or odm property
Partial revert of "init: if vendor_init can read a property, let it be
a trigger too" (b35f827c97).

We made a mistake when we allowed vendor init to action on any vendor
or odm property, since when a new SELinux label is created for a
vendor property, vendor_init does not automatically get read
permissions for it.

Recently, we tried to use read permissions instead of the built-in
list in init, but that broke due to the above mistaken.  Since we have
already launched with these permissions as is, we must restore them.

Bug: 118457755
Test: no denials for vendor init actionable properties on crosshatch
Change-Id: I7a9a560c9a54a177c6b83d28309e2f288f05d400
2018-10-26 08:50:45 -07:00
Tom Cherry
b35f827c97 init: if vendor_init can read a property, let it be a trigger too
There is a list of 'stable_properties' that vendor_init can use as
property triggers for Treble property compliance.  This list came about
since init parses init scripts before all partitions are mounted and
therefore before all property context files are available, such that
init cannot use the normal SELinux mechanisms for determining if a
given property is vendor_init readable.

Currently though, we require all partitions that would contain
property context files to be mounted during first stage mount, so we
can use the normal SELinux mechanisms here, so this change deprecates
the stable_properties list and moves init to use SELinux to determine
if a property can be a trigger.

Bug: 71814576
Test: vendor_init fails to use non-readable properties as a trigger
Test: vendor_init successfully uses readable properties as a trigger
Change-Id: I6a914e8c212a3418cbf4a8a07215056aad2e0162
2018-10-22 16:16:03 -07:00
Tom Cherry
8c901dda30 init: fix typo in error message
Test: none
Change-Id: Ie8417c7c6e3f6600544006c4a84b5bdfaff9725f
2018-07-24 15:54:33 -07:00
Elliott Hughes
b0aba0fff9 init; remove dead cruft.
Bug: N/A
Test: builds
Change-Id: Ia38ef6959e8615b4f103b924ae51c19f916daa48
2018-05-29 17:05:56 -07:00
Elliott Hughes
dc80312628 libbase: add host properties support.
Move init and libprocessgroup away from their existing hacks.

Bug: N/A
Test: ran tests
Change-Id: Ifabdd38e0cc4ab2582f1ea59d32159d386f48eb6
2018-05-24 18:04:31 -07:00
Tom Cherry
de6bd50d42 init: add host side parser for init
Create a host side parser for init such that init rc files can be
verified for syntax correctness before being used on the device.

Bug: 36970783
Test: run the parser on init files on host

Change-Id: I7e8772e278ebaff727057308596ebacf28b6fdda
2018-02-28 10:45:45 -08:00
Tom Cherry
9cbf57048c Move all Action parsing into ActionParser
Bug: 36970783
Test: Build
Change-Id: Iea2d97fb45c3e88bc83fb72d6fa67049be42cfa9
2018-02-14 16:37:17 -08:00
Tom Cherry
0f6417f232 Move ActionParser to its own file
Bug: 36970783
Test: build
Change-Id: Idd5b923e4789760bb9ef67c10982b2642bc6a31a
2018-02-13 15:26:14 -08:00