Commit graph

21 commits

Author SHA1 Message Date
Jingwen Chen
f643b354fe Make the host_init_verifier init.rc parser follow symlinks.
Bazel's intermediates/inputs are symlinks in its execution root, unlike Soong.

e.g.

$ file $(readlink -f out/bazel/output/execroot/__main__/packages/modules/adb/apex/adbd.rc)
/usr/local/google/home/jingwen/aosp/master-with-phones/packages/modules/adb/apex/adbd.rc:
ASCII text

Test: presubmits
Change-Id: I3977a37ee989e07bee56abb019a21055b8cef567
2023-03-17 02:47:21 +00:00
Jooyung Han
6b88d1684c Parser::ParseConfigFile returns Result<void>
ParseApexConfigs() uses Parser::ParseConfigFile() to parse .rc files in
the target apex. ParseConfigFile() returning bool (with logging on
error) doesn't propagate the error message back to the callers
(including apexd or PackageManager).

We'd better to migrate other Parse*() methods of Parser class to return
Result<T>. But this change focuses on plumbing error progagation for
APEX configs.

Bug: 238820991
Test: atest CtsInitTestCases
Change-Id: Ifad97635dbb53a70053ec73a7a5b7e742466daf6
2023-01-11 17:20:16 +09:00
Deyao Ren
238e909349 Remove and add service and action during apex load and unload
Bug: 232114573
Test: atest CtsInitTestCases ApexTestCases
Change-Id: I1f91ada1d44ac2380e2faf8fc25e0a521cc1a826
2022-08-30 17:31:00 +00:00
Daniel Norman
f1200fb117 Adds an init host lib for use in host_apex_verifier.
Includes extracting the APEX-specific SDK version naming scheme filter
logic so it can be reused when host_apex_verifier looks at rc files
inside the APEX.

Bug: 222121216
Test: Use in host_apex_verifier
Change-Id: I0396a455f30d2de71525ccd3fa69c75576054048
2022-03-21 15:45:44 -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
Jiyong Park
c240440eec init parses *.rc files from APEXes
Init now parses *.rc files from the APEXs when the apexd notifies the
mount event via apexd.status sysprop.

Bug: 117403679
Test: m apex.test; adb root; adb push <builtfile> /data/apex; adb reboot
adb root; adb shell setprop ctl.start apex.test; dmesg shows that init
tries to start the service which doesn't exist.

[   47.979657] init: Could not ctl.start for 'apex.test': Cannot find '/apex/com.android.example.apex/bin/test': No such file or directory

Change-Id: I3f12355346eeb212eca4de85b6b73257283fa054
2018-11-10 04:18:09 +09:00
Tom Cherry
d72432de93 Don't check permissions bits on init scripts for host_init_verifier
Also get rid of the copy in parser.  There's no incentive to switch to
a tokenizer that doesn't modify the input, nor is there a reason to
waste cycles making a copy of every init script as its processed.

Bug: 36970783
Test: boot
Change-Id: I8aca9c9d6f1961e1ab35dee50691a6791fc6ec66
2018-06-19 15:18:40 -07:00
Tom Cherry
194b5d1da9 init: handle properties and imports for host init verifier
Allow specifying properties on the command line when running host init
verifier.  This is needed particularly for importing files that have a
property expansion in their path.

Handle the import statement on host, basing paths off of the out
directory of Android builds.

Bug: 36970783
Test: verify that bullhead imports the correct files and checks them
Change-Id: I4fe263016b3764a372708b559bc0c739b1b7e5e3
2018-05-30 15:43:32 -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
Steven Moreland
7d0a5c3656 EndSection returns Result<Success>
Allow it to fail. When there is an error for a section ending,
print the error pointing to the line where the section starts.

Bug: 69050941
Test: boot, init_tests
Change-Id: I1d8ed25f4b74cc9ac24d38b8075751c7d606aea8
2017-11-15 10:39:29 -08:00
Steven Moreland
b480d441ac Fix out of date SectionParser comment.
It has since been refactored with different
return types.

Bug: 69050941
Test: boot, init_tests
Change-Id: I54c0e6745640136f060ba1876b2f26d95bddc9d6
2017-11-14 13:47:59 -08:00
Tom Cherry
b592dd8aff init: use Result<T> for the parsing functions
Test: boot bullhead
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
2017-08-14 10:27:33 -07:00
Tom Cherry
67dee626e0 init: remove Parser singleton and related cleanup
* Remove the Parser singleton (Hooray!)
* Rename parser.* to tokenizer.* as this is actually a tokenizer
* Rename init_parser.* to parser.* as this is a generic parser
* Move contents of init_parser_test.cpp to service_test.cpp as this
  actually is a test of the parsing in MakeExecOneshotService() and
  nothing related to (init_)parser.cpp

Test: boot bullhead
Test: bool sailfish
Test: init unit tests
Change-Id: I4fe39e6483f58ebd3ce5ee715a45dbba0acf5d91
2017-07-27 13:23:32 -07:00
Tom Cherry
81f5d3ebef init: create android::init:: namespace
With some small fixups along the way

Test: Boot bullhead
Test: init unit tests
Change-Id: I7beaa473cfa9397f845f810557d1631b4a462d6a
2017-06-23 13:21:20 -07:00
Tom Cherry
ad6741c6f8 init: remove unused parts of parser.cpp
Now that ueventd is using init's parser, we no longer need anything
other than the tokenizer from parser.cpp.

Test: Boot bullhead
Change-Id: I1f70f2c4479af576174bd74dd919d81817500216
2017-04-25 11:24:33 -07:00
Elliott Hughes
c0e919c920 Stop using #if for conditional compilation.
Use regular 'if' to prevent bitrot.

Also remove remaining typedefs.

Change-Id: I2e6ca928e2db29b88b643cf990ff05cfb0be94a6
2015-02-04 17:16:11 -08:00
Greg Hackmann
d68db71e75 init: limit visibility of init_parser.c helpers
To prevent clashing with forthcoming changes to uevent_parser.c

Change-Id: I2ee183261c7f43e0e4104a16a280c7ee73d7df96
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-11-25 11:24:16 -08:00
Dima Zavin
304f12270d init: delay importing files until after parsing the current file
If we process the import directive inline, then the ordering of the
commands for the "on xxx" sections would be a little unexpected. The
init.rc files do not really have an implied  order as to which section
appears and gets processed first. The init code itself provides that
ordering explicitly. For the user, the expectation is that if both the
current file and the imported file define a section (e.g. "on init"),
then the commands in the current file will be executed first, and then
the ones from the imported file(s).

The current implementation did not do that. It processed the import
directive inline, and thus the imported (i.e. dependent) files would
appear first in the command lists for the sections. This created
unintended side effects and the solution would have been to try and
put the import lines somewhere in the middle of the init file. This
would be difficult to notice and hard to extract the dependencies.

To solve this, we add the imports to a list for each file being parsed
and process the list after finishing parsing the file. This provides
predictable order for imports and provides a logical flow from the
user perspective: the currently parsed file gets to run its commands
before the files being imported.

Change-Id: I06dc35ff286314060e16b18923683cd2787269de
Signed-off-by: Dima Zavin <dima@android.com>
2012-01-05 15:02:00 -08:00
Colin Cross
6310a8261c init: Split parser into generic parser and init parser
Change-Id: I451ebc4ff12f2ac660eb533fa10ad561fa25c9dd
2010-04-21 19:43:40 -07:00
Colin Cross
ebc6ff105a init: Handle commands in event queue loop
Change-Id: I679059dae43143f3c8f16b68de5694539b699e50
2010-04-16 19:02:32 -07:00
Colin Cross
ca7648ddfb init: Move parser prototypes to parser.h
Change-Id: I31db51eb8e8a33a0bd06b41206bc9f9147d16d41
2010-04-13 22:51:12 -07:00