Commit graph

1660 commits

Author SHA1 Message Date
Tom Cherry
517e1f17cf init: Check DecodeUid() result and use error string
Check the result of DecodeUid() and return failure when uids/gids are
unable to be decoded.

Also, use an error string instead of logging directly such that more
context can be added when decoding fails.

Bug: 38038887
Test: Boot bullhead
Test: Init unit tests
Change-Id: I84c11aa5a8041bf5d2f754ee9af748344b789b37
2017-05-05 14:37:01 -07:00
Chih-Hung Hsieh
7275802917 Work around clang-tidy segmentation fault.
This should affect only builds that call clang-tidy.
Without this change, clang-tidy has segmentation fault
when compiling several files in the system/core/init directory.

Bug: 38002385
Test: build with WITH_TIDY=1
Change-Id: I63b898370c43e1d6b02671751137b1027ba4cdac
2017-05-04 16:30:14 -07:00
William Roberts
1b9708bc54 Merge "init: cleanup exec_service documentation" am: 61559e491e am: b46b61049b
am: bd633d8e2a

Change-Id: I531326d860dae9d80a02b6f322553b9b38bcbfec
2017-05-04 20:14:32 +00:00
Treehugger Robot
61559e491e Merge "init: cleanup exec_service documentation" 2017-05-04 19:54:17 +00:00
Tom Cherry
33838b1156 init: change kill order and fix error reporting in KillProcessGroup()
First kill the process group before killing the cgroup to catch
the hopeful case that killing the cgroup becomes a no-op as all of its
processes have already been killed.

Do not report an error if kill fails due to ESRCH, as this happens
often when reaping processes due to the order in which we call
waitpid() and kill().

Do not call killProcessGroup in libprocessgroup if we have already
successfully killed and removed a process group.

Bug: 36661364
Bug: 36701253
Bug: 37540956

Test: Reboot bullhead
Test: Start and stop services
Test: Init unit tests
Change-Id: I172acf0f8e00189f910f865f4635a7b1782fc7e3
2017-05-04 12:33:19 -07:00
William Roberts
323d5791b4 init: cleanup exec_service documentation
The exec_service documentation was difficult to read, clarify it.

Tests:
Run grip.py to verify that the markdown still works correctly.
Run aspell to verify spelling.

Change-Id: I29bdd456f3d3ea2a91c9d4772bd09a5a195f97a9
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2017-05-04 11:14:23 -07:00
Jin Qian
6cfade736d Merge "init: manually restorecon mke2fs tools on ramdisk" am: e2629c5682 am: 06c1500a14
am: 2ce5eb91c0

Change-Id: I401394f4569ee0783b8bac17a1187634558cf553
2017-05-04 02:17:50 +00:00
Treehugger Robot
e2629c5682 Merge "init: manually restorecon mke2fs tools on ramdisk" 2017-05-04 02:07:02 +00:00
Mark Salyzyn
b48c99a93d Merge changes Ieb44fa8f,I01b26fe5 am: e1e3e20337 am: d8dc29df8e
am: b519cb5e14

Change-Id: I0154f15f4b8b0dc7216ee16bc3f9eeb79fc90458
2017-05-03 23:38:40 +00:00
Treehugger Robot
e1e3e20337 Merge changes Ieb44fa8f,I01b26fe5
* changes:
  init: setup keyring before ueventd starts
  logd: refine permissions to access /data/system/packages.list
2017-05-03 23:24:14 +00:00
Jin Qian
2d019f859b init: manually restorecon mke2fs tools on ramdisk
Files in the ramdisk by default have the rootfs label and must be
manually restoreconed.

Bug: 35219933
Change-Id: I2a749f128dc3a609907101ce703747f8990b4386
2017-05-03 16:15:45 -07:00
Tom Cherry
10cdd5bbf1 Merge "init: use do_exec() for init_user0" am: 5ad06cbb1c am: 577c75e78c
am: bc8a4ad7aa

Change-Id: I9985eb2751d14c6562b7559ffa6d0c72253df591
2017-05-03 22:30:41 +00:00
Mark Salyzyn
4599627492 init: setup keyring before ueventd starts
Invent keyutils.h to supply capability to set session keyring.
The keyring will hold things like the FBE encryption keys.

Test: gTest logd-unit-tests --gtest_filter=logd.statistics
Bug: 37751120
Bug: 36645158
Change-Id: Ieb44fa8f53dda6cf506a6243498c72d7f7f3cde7
2017-05-03 21:51:04 +00:00
Tom Cherry
5a86cb7694 init: use do_exec() for init_user0
Similar to what installkey used to do, init_user0 forks and
synchronously waits for vdc to return.  This is dangerous to do in
init however as init also processes properties from a single thread.

I'm not aware of any specific issues that this is currently causing,
but it's a good preventative measure to match what installkey does and
use do_exec().

Test: Boot bullhead, see that init_user0 still happens
Change-Id: I853c61594fe3d97e91bbb2319ebddf2bbe80d457
2017-05-03 13:25:08 -07:00
Tom Cherry
214e45a5a7 Merge "ueventd: do not reference init's sehandle" am: 672dd970f4 am: e4988c9a34
am: 4c664d8c5c

Change-Id: I7da9e9417afcd8a2cfa9d7ac75d58c75cc39f21d
2017-05-03 18:25:46 +00:00
Tom Cherry
672dd970f4 Merge "ueventd: do not reference init's sehandle" 2017-05-03 18:14:38 +00:00
Bowgo Tsai
ec0d2ce60e Merge "init: fix first stage mount failure due to /dev/device-mapper not found" am: 0447a3e5d1 am: ad7c7fe1aa
am: fd13c70104

Change-Id: Ia9da2e7f83350a955ee7ec9c920b2b7eabc87ead
2017-05-03 01:42:09 +00:00
Bowgo Tsai
ea5fca4cd0 init: fix first stage mount failure due to /dev/device-mapper not found
It has been reported that fs_mgr failed to open /dev/device-mapper
during the first stage mount. It's because other uevent (e.g., i2c
charger device) happens to be sent at the same time we're triggering
the device-mapper uevent to be sent. Current implementation returns
COLDBOOT_STOP unconditionally so it will only process the first received
uevent, leaving device-mapper uevent unhandled when the race happens.

Fix this by only returning COLDBOOT_STOP when the received uevent->path
matches that of device mapper.

Bug: 37745254

Test: first stage mount /vendor with vboot 2.0 (avb) on bullhead
Test: first stage mount /vendor with vboot 1.0 on sailfish
Change-Id: I4a77093ec8f90a5ca981a088f34d082d0270533b
2017-05-03 00:38:43 +08:00
Tom Cherry
67dfc3e691 Merge "init: add an initializer for keychord_id_" am: 7c3f147070 am: e2865c0f54
am: ea3434e0dd

Change-Id: Ib640d4e04f223d353e6dd8f762acf57792532150
2017-05-02 00:38:32 +00:00
Tom Cherry
7c3f147070 Merge "init: add an initializer for keychord_id_" 2017-05-02 00:30:17 +00:00
Tom Cherry
e7656b7200 ueventd: do not reference init's sehandle
Init exposes a global 'sehandle' that ueventd references as part of
devices.cpp and util.cpp.  This is particularly dangerous in
device_init() in which both uevent and init write to this global.

This change creates a separate local copy for devices.cpp and puts
restrictions on where init.h can be included to make sure the global
used by init is not reference by non-init code.  Future changes to
init should remove this global.

Test: Boot bullhead

Change-Id: Ifefa9e1932e9d647d06cca2618f5c8e5a7a85460
2017-05-01 17:22:49 -07:00
Tom Cherry
31c0221c04 Merge "ueventd: remove leftovers of the SELinux policy update mechanism" am: 6a8314c8bf am: c2c8f5e0dc
am: e1977a3afb

Change-Id: I9f1df3427e3b3c7f1fa62d86f9b6996d86e21b22
2017-05-01 22:59:29 +00:00
Tom Cherry
d5b743c3f3 Merge "ueventd: fix typo from previous patchset" am: c8877530c7 am: 4be091d588
am: 977f21e7bc

Change-Id: I8823eb8f73249424ebc57d7d3551b21e01e8badf
2017-05-01 22:51:21 +00:00
Tom Cherry
6a8314c8bf Merge "ueventd: remove leftovers of the SELinux policy update mechanism" 2017-05-01 22:48:29 +00:00
Tom Cherry
7da548578c init: add an initializer for keychord_id_
Add unit test to ensure all POD types of Service are initialized.

Bug: 37855222
Test: Ensure bugreport is triggered via keychord properly.
Test: New unit tests
Change-Id: If2cfea15a74ab417a7b909a60c264cb8eb990de7
2017-05-01 15:35:07 -07:00
Tom Cherry
f51c66b23b ueventd: fix typo from previous patchset
An forward declaration for a function that was removed in later
patchsets was merged anyway.  Since it's not used anywhere, this CL
removes it.

Test: build bullhead
Change-Id: Ie7223f7d23305b71438cb063b64a574ce32f96bb
2017-05-01 10:53:39 -07:00
Tom Cherry
6daf514448 ueventd: remove leftovers of the SELinux policy update mechanism
Reloading sepolicy has been removed from the system, so this support
code can also now be removed.

Bug: 26544104
Test: Boot bullhead
Change-Id: If9dbc9d540d9a69340c1dd6a483c1f8fe5feb287
2017-05-01 10:39:03 -07:00
Keun-young Park
58689cb421 Merge "combine wait for exec log with service exit log" am: 483d2f9a59 am: 010efc6a1c
am: b85523e64e

Change-Id: If4e052913653de1feebde4799d19c282255f5ede
2017-04-28 20:40:13 +00:00
Keun-young Park
4de31e1481 combine wait for exec log with service exit log
- allows easier tracking of wait time from monitoring tools
- this change also reduces unnecessary log spam
- service exit log looks like this:
  init: Service 'exec 4 (/system/bin/otapreopt_slot)' (pid 611) exited with status 0 waiting took 0.060771 seconds

bug: 37752410
Test: reboot and check log
Change-Id: I122902538697f33939eede548e39f155ec419e03
2017-04-28 11:20:12 -07:00
Tom Cherry
07ea1a8833 Merge "init: fix last_reboot_reason string" am: 59c74a3bd1 am: 2be5884903
am: 8705f89826

Change-Id: Idaf8218594f50b860fdd9e5d12b8e6f7a4fe0e68
2017-04-27 20:29:32 +00:00
Treehugger Robot
59c74a3bd1 Merge "init: fix last_reboot_reason string" 2017-04-27 19:39:53 +00:00
Keun-young Park
6c61e087e4 Merge "set default shutdown timeout to 6 secs" am: 47d15ed5b9 am: 0020d4c076
am: 09c780db3a

Change-Id: I38ec920f5034b2adc9ab8354144cae1fe554d753
2017-04-26 22:49:02 +00:00
Keun-young Park
47d15ed5b9 Merge "set default shutdown timeout to 6 secs" 2017-04-26 22:35:26 +00:00
Keun-young Park
b549370bf3 Merge "do not start shutdown animation from init" am: 84d43c8df7 am: 76a3b3ce5c
am: a15436569f

Change-Id: I5fea05ff1c4d5cfb2d50b9aab7805d229c43d89b
2017-04-26 21:27:01 +00:00
Keun-young Park
5b1300c154 Merge "add additional dump for timeout" am: 8cde09064e am: fadad58262
am: 606df0e2cb

Change-Id: I386ee368f2fd08575b69cc776ea2ccee55bdd225
2017-04-26 21:26:43 +00:00
Treehugger Robot
84d43c8df7 Merge "do not start shutdown animation from init" 2017-04-26 20:59:56 +00:00
Keun-young Park
7feab68238 set default shutdown timeout to 6 secs
- Test data shows that most shutdown finishes in 6 secs.
- The original 10 secs is too long wih no shutdown animation
  running in screen.

bug: 36657139
Test: check time with reboot
Change-Id: I9a805ddfde8156b066485902048d0cd01365c453
2017-04-26 13:58:31 -07:00
Keun-young Park
8cde09064e Merge "add additional dump for timeout" 2017-04-26 20:53:21 +00:00
Tom Cherry
a52ce58d2e Merge changes Ibe91fd2d,I59e2bd9e am: b0a14f8feb am: 4ba72d9b73
am: 9ef76bdc72

Change-Id: I49823a29c3f9aaee75ca1d6d2bd092ed2cddd3f4
2017-04-26 19:59:49 +00:00
Treehugger Robot
b0a14f8feb Merge changes Ibe91fd2d,I59e2bd9e
* changes:
  init: remove 'computing context for service'... message
  init: use full command for exec services' names
2017-04-26 19:46:04 +00:00
Keun-young Park
1663e97fe1 add additional dump for timeout
- add sysrq-trigger current tasks dump
- This helps detecting kernel thread stuck in a specific driver

bug: 37573746
Test: python packages/services/Car/tools/bootanalyze/bootanalyze.py -r -c packages/services/Car/tools/bootanalyze/config.yaml -n 2000 -f -e 15 -w 30  -v -a

Change-Id: Icb20b5fba63d601bb937f004f5889a9bc8340b34
2017-04-26 10:16:23 -07:00
Tom Cherry
47336cebc3 init: fix last_reboot_reason string
This got moved when refactoring the reboot commands.

Bug: 37540660
Test: verify bullhead's last_reboot_reason is correct
Change-Id: I3b86496fc469ca41645df7e7ba8bb51dd25b6b38
2017-04-26 16:17:08 +00:00
Tom Cherry
6f7ef2fb34 init: remove 'computing context for service'... message
This line shows up immediately before starting a service for each
service without a 'seclabel' option, essentially becoming log spam.

We already log if we fail to compute the context as well.

Test: Boot bullhead

Change-Id: Ibe91fd2dd9f53a8ae2ca95ccea1636ecef2af224
2017-04-25 17:46:13 -07:00
Tom Cherry
86e31a8123 init: use full command for exec services' names
Before:
init: starting service 'exec 4 (/system/bin/vdc)'...
init: starting service 'exec 5 (/system/bin/tzdatacheck)'...
init: starting service 'exec 6 (/system/bin/bootstat)'...
init: starting service 'exec 7 (/system/bin/bootstat)'...

After:
init: starting service 'exec 4 (/system/bin/vdc --wait cryptfs mountdefaultencrypted)'...
init: starting service 'exec 5 (/system/bin/tzdatacheck /system/usr/share/zoneinfo /data/misc/zoneinfo)'...
init: starting service 'exec 6 (/system/bin/bootstat -r post_decrypt_time_elapsed)'...
init: starting service 'exec 7 (/system/bin/bootstat --record_boot_complete)'...

Test: Boot bullhead, observe above logging change
Change-Id: I59e2bd9e3d341bbed9537c972e47246d0a12769d
2017-04-25 17:35:46 -07:00
Bowgo Tsai
eac5c8859d Merge "init: fix first stage mount failure when two fstab entries have verity_loc" am: 8df35dcb1c am: 8954cd9379
am: 225177279a

Change-Id: I7bc19c9b430d23282e824797ddc3652a1efea383
2017-04-26 00:19:58 +00:00
Treehugger Robot
8df35dcb1c Merge "init: fix first stage mount failure when two fstab entries have verity_loc" 2017-04-26 00:06:47 +00:00
Tom Cherry
e8b8045f96 Merge "init: rename 'Trigger' to 'Event' and convert to std::variant" am: d9ebf06117 am: d45b6f44d5
am: f9557f175c

Change-Id: Ie900559a7b7d1b70aac2b9e52b1a06727348eae8
2017-04-25 21:59:03 +00:00
Tom Cherry
7bd11f7f1b Merge changes I1f70f2c4,I698ca962,Idbbf2682 am: 960ed3ce1b am: 4cd8d5e9f5
am: bfbe459ff1

Change-Id: I90526601990c7d4d3cbd2b8f3a35bf2c4c8a2ef8
2017-04-25 21:58:47 +00:00
Tom Cherry
d9ebf06117 Merge "init: rename 'Trigger' to 'Event' and convert to std::variant" 2017-04-25 21:44:19 +00:00
Tom Cherry
960ed3ce1b Merge changes I1f70f2c4,I698ca962,Idbbf2682
* changes:
  init: remove unused parts of parser.cpp
  ueventd: replace ueventd_parser.cpp with init_parser.cpp
  init: add Parser::AddSingleLineParser()
2017-04-25 21:44:07 +00: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
Tom Cherry
fe062055cb ueventd: replace ueventd_parser.cpp with init_parser.cpp
Previously init_parser.cpp was made generic and capable of parsing any
number of differently named 'sections' or prefixed lines.  We now use
these capabilities to do the parsing for ueventd.

Bug: 36250207
Bug: 33785894

Test: boot bullhead and ensure the right /dev nodes exist
      with the right permissions set
Test: verify no boot time difference
Change-Id: I698ca962d414f8135af32f6c9cd778841b2b8b53
2017-04-25 11:24:24 -07:00
Bowgo Tsai
71881fffd6 init: fix first stage mount failure when two fstab entries have verity_loc
The previous check is incorrect because it compares the basename of
previous verity_loc with the full path of current verity_loc.

Changes it to compare the full device file path instead of just the basename
of verity_loc. This can catch the case of two different verity_loc
values with the same basename, e.g.,

  - verify=/dev/block/platform/SOC.0/by-name/metadata
  - verify=/dev/block/platform/SOC.1/by-name/metadata

Bug: 37413399
Bug: 37619597
Test: first stage mount /system and /vendor with the following fs_mgr_flags on bullhead
        - wait,verify=/dev/block/platform/soc.0/f9824900.sdhci/by-name/metadataa
Test: first stage mount /system and /vendor with different verity_loc values
      on bullhead, checks it bails out
Change-Id: I017c8bd9f0790d45e08e57df9a2878e4f62c5f9c
2017-04-26 01:23:19 +08:00
Tom Cherry
35c5bcc89c init: add Parser::AddSingleLineParser()
Add the ability to override the current section being parsed and
instead parse a line by itself if a given line starts with a specific
prefix.

Test: Boot bullhead
Change-Id: Idbbf2682b78996b41d05f3db655c8937a8c6ccda
2017-04-25 10:19:37 -07:00
Tom Cherry
26ed9cb706 init: rename 'Trigger' to 'Event' and convert to std::variant
The term 'trigger' should be used in 'Action' to indicate what causes
the 'Action' to be executed.

The term 'event' should be used in ActionManager's queue to indicate
a state change that is checked against the 'triggers' of an 'Action' to
see if it should execute.

Convert the previous Trigger class to std::variant, as the latter is
better suited for this use.

Change-Id: I2558367c8318b536aa69fcec93793f1c12857ef5
2017-04-25 17:14:23 +00:00
Jaekyun Seok
01d4504a6c Merge "Update persist.sys.usb.config on runtime" am: 41346e553b am: ac945881b3
am: 33e7e21645

Change-Id: I1e5ad9da360bfb3cb4970e12a76522fd0a5126b8
2017-04-25 04:02:35 +00:00
Treehugger Robot
41346e553b Merge "Update persist.sys.usb.config on runtime" 2017-04-25 03:51:17 +00:00
Jaekyun Seok
0cf3a07e14 Update persist.sys.usb.config on runtime
persist.sys.usb.config values can't be combined on build-time when
property files are split into each partition.
So we need to apply the same rule of
build/make/tools/post_process_props.py on runtime.

Test: building succeeded and tested on sailfish.
Bug: 37617113
Bug: 37648659

Change-Id: I78cdffee446d3ae6a89f138faed5f3149e4b507d
2017-04-25 01:31:19 +00:00
Bowgo Tsai
6433e8dca2 Merge "init: set ro.boot.avb_version in recovery mode" am: f1bd536efd am: a1da077454
am: aacfa4f8c2

Change-Id: I6d38d066f4b23bd01e9b3aaf5143563a19d45cbd
2017-04-25 00:41:37 +00:00
Bowgo Tsai
58357f2b7e Merge "init: moving early mount logic into init_first_stage.cpp" am: bcd36a20d4 am: 2d7818a104
am: 47fe14b456

Change-Id: Ie677f3e01fe6a8f0cee96b70d29ab54d5b9cdaa8
2017-04-25 00:41:22 +00:00
Treehugger Robot
f1bd536efd Merge "init: set ro.boot.avb_version in recovery mode" 2017-04-25 00:31:41 +00:00
Treehugger Robot
bcd36a20d4 Merge "init: moving early mount logic into init_first_stage.cpp" 2017-04-25 00:31:27 +00:00
Jeff Vander Stoep
fb62e61ec0 Merge "Sepolicy load: use -N flag to skip neverallow checks" into oc-dev
am: c53ae9ed3e

Change-Id: I4d59716ee79fdc4514d84c771fa6b45693691f50
2017-04-24 22:46:32 +00:00
Jeff Vander Stoep
955e36492e Sepolicy load: use -N flag to skip neverallow checks
Fixes issue where attributes used exclusively in neverallow
rules were removed from policy.

Bug: 37357742
Test: Force on-device compile by removing precompiled policy.
      Verify no increase in compile time.

Change-Id: I0d145fd311c2ddcb226a827f2a997f10c20a8379
2017-04-24 21:12:13 +00:00
Tom Cherry
d0ea8a98cd Merge changes Ic446c026,I86568a5b am: 51b7cb006f am: 41dbec9791
am: fea35fc7e4

Change-Id: Ia5e7465015618317132c63cdfaddd8cb63c2425a
2017-04-24 19:23:38 +00:00
Bowgo Tsai
fd18a452be init: set ro.boot.avb_version in recovery mode
Previously we set ro.boot.avb_version during the first stage mount in normal mode:
  - https://android-review.googlesource.com/#/c/371774/

As the first stage mount is not performed in recovery mode, we need to set the
property separately in recovery mode.

Bug: 37414003

Test: first stage mount /vendor with vboot 2.0 (avb) on bullhead in normal mode
Test: first stage mount /system with without verity on bullhead in normal mode
Test: checks ro.boot.avb_version is 1.0 on bullhead in recovery mode

Test: first mount /vendor with with vboot 1.0 on sailfish in normal mode
Test: checks ro.boot.avb_version doesn't exist on sailfish in recovery mode

Change-Id: I262e75b8b557c4de7609b4049ccb01793644245e
2017-04-24 23:10:59 +08:00
Bowgo Tsai
d262017fef init: moving early mount logic into init_first_stage.cpp
Also renames "early mount" to "first stage mount" to prevent confusion
with "mount_all --early", which is run in the init second stage.

Also creates a base class: FirstStageMount and two derived classes:
FirstStageMountVBootV1 and FirstStageMountVBootV2 to replace/refactor
existing functions:

   - early_mount() -> DoFirstStageMount() and FirstStageMount::DoFirstStageMount()

   - vboot_1_0_early_partitions -> FirstStageMountVBootV1::GetRequiredDevices()
   - vboot_2_0_early_partitions -> FirstStageMountVBootV2::GetRequiredDevices()

   - vboot_1_0_mount_partitions ->
       FirstStageMount::MountPartitions() and
       FirstStageMountVBootV1::SetUpDmVerity()

   - vboot_2_0_mount_partitions ->
       FirstStageMount::MountPartitions() and
       FirstStageMountVBootV2::SetUpDmVerity()

Bug: 37413399
Test: first stage mount /vendor with vboot 2.0 (avb) on bullhead
Test: first stage mount /system with without verity on bullhead
Test: first stage mount /vendor with with vboot 1.0 on sailfish
Change-Id: I6584bdf7d832c9fbc8740f97c9b8b94e68a90783
2017-04-24 23:10:10 +08:00
Tom Cherry
ad54d094cd init: create init_tests.cpp
Start a init_tests.cpp file for end-to-end tests that parse small init script
segments and verify that they act as expected.

The first tests ensure that the execution order of event triggers
happens appropriately.

Test: Boot bullhead, run unit tests

Change-Id: Ic446c02605ab796fd41e0596ce1fd381aee80ce0
2017-04-21 18:27:42 -07:00
Tom Cherry
30a6f276fd init: clean up the SectionParser interface and Parser class
Remove the dependency on Action and Service from what should be a
generic Parser class.

Make ActionParser, ImportParser, and ServiceParser take a pointer to
their associated classes instead of accessing them through a
singleton.

Misc fixes to SectionParser Interface:
1) Make SectionParser::ParseLineSection() non-const as it always should
have been.
2) Use Rvalue references where appropriate
3) Remove extra std::string& filename in SectionParser::EndFile()
4) Only have SectionParser::ParseSection() as pure virtual

Document SectionParser.

Make ImportParser report the filename and line number of failed imports.

Make ServiceParser report the filename and line number of duplicated services.

Test: Boot bullhead

Change-Id: I86568a5b375fb4f27f4cb235ed1e37635f01d630
2017-04-21 18:26:40 -07:00
Tom Cherry
01d9b0e11c Merge "init: fix errno handling on KillProcessGroup" am: f890ca9a1f am: db9f2cb46d
am: c7e559ca40

Change-Id: I297778909c6b134178928462cb995f3e65d44b9a
2017-04-20 21:00:43 +00:00
William Roberts
e6ec2661b7 init: fix errno handling on KillProcessGroup
KillProcessGroup can return -1 without errno set, which produces error
messages like this:

init: Sending signal 15 to service 'vold' (pid 1806) process group...
init: failed to kill 2 processes for processgroup 1806
init: killProcessGroup(0, 1806, 15) failed: Success

Test: boot and reboot hikey.

Change-Id: I51f242da234daee84795a3fbdffe9ad1f4567140
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2017-04-19 17:21:44 -07:00
Keun-young Park
e2b04b71ae do not start shutdown animation from init
- init will only keep animation related services as shutdown critical.
- external component like system server can start shutdown animation.

bug: 37500823
Test: reboot
Change-Id: Ief328306eba7e3b15402ae27e6236767095f508c
2017-04-19 14:30:25 -07:00
Tom Cherry
d949df5f57 Merge "init: Stop combining actions" am: 8d644d2c96 am: a0b0c8a18e
am: 779e922866

Change-Id: I83cb780715d5949a47155b98be8714604ddacb72
2017-04-19 20:10:00 +00:00
Tom Cherry
012c573e26 init: Stop combining actions
In the past, I had thought it didn't make sense to have multiple
Action classes with identical triggers within ActionManager::actions_,
and opted to instead combine these into a single action.  In theory,
it should reduce memory overhead as only one copy of the triggers
needs to be stored.

In practice, this ends up not being a good idea.

Most importantly, given a file with the below three sections in this
same order:

on boot
  setprop a b

on boot && property:true=true
  setprop c d

on boot
  setprop e f

Assuming that property 'true' == 'true', when the `boot` event
happens, the order of the setprop commands will actually be:

setprop a b
setprop e f
setprop c d

instead of the more intuitive order of:

setprop a b
setprop c d
setprop e f

This is a mistake and this CL fixes it.  It also documents this order.

Secondly, with a given 'Action' now spanning multiple files, in order
to keep track of which file a command is run from, the 'Command'
itself needs to store this.  Ironically to the original intention,
this increases total ram usage.  This change now only stores the file
name in each 'Action' instead of each 'Command'.  All in all this is a
negligible trade off of ram usage.

Thirdly, this requires a bunch of extra code and assumptions that
don't help anything else.  In particular it forces to keep property triggers
sorted for easy comparison, which I'm using an std::map for currently,
but that is not the best data structure to contain them.

Lastly, I added the filename and line number to the 'processing
action' LOG(INFO) message.

Test: Boot bullhead, observe above changes
Test: Boot sailfish, observe no change in boot time
Change-Id: I3fbcac4ee677351314e33012c758145be82346e9
2017-04-19 11:26:29 -07:00
Tom Cherry
0a03f5cb59 Merge "init: add warning that start is not synchronous" am: 06039e58d8 am: 2b78f9c0a9
am: 0a4ff0fb31

Change-Id: I32cd3f13e4f7b63da66332ff616fefa23cb5cab8
2017-04-19 18:21:51 +00:00
Wei Wang
0af7ee4a1f Merge changes from topic 'cpuset_setall' into oc-dev
* changes:
  init: use read_file and write_file to implement do_copy builtin
  init: Use std::string for write_file()
2017-04-19 16:49:59 +00:00
Yongqin Liu
67f6a530ba init: use read_file and write_file to implement do_copy builtin
this will make the implementation more cleaner,
and has error message output when failed on some operations

also add the O_TRUNC flag explicitly for the open function
called in write_file.

And add more test on read_file and write_file functions

Bug: 36726045
Bug: 36576280
Test: manual with hikey
Test: boot and init tests on bullhead
Test: cast with fugu, per b/36726045
Merged-In: If3c30a2fff58cfece2fcd27e69c30382146e6808

Change-Id: If3c30a2fff58cfece2fcd27e69c30382146e6808
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
(cherry picked from commit dbe88e7953)
2017-04-19 16:49:39 +00:00
Tom Cherry
ef52ae14ab init: Use std::string for write_file()
The content parameter of write_file() previously took a char* that was
then converted to a std::string in WriteStringToFd().  One unfortunate
effect of this, is that it is impossible to write data that contains
'\0' within it, as the new string will only contain characters up
until the '\0'.

This changes write_file() to take an std::string, such that
std::string::size() is used to determine the length of the string,
allowing it to contain null characters.

Also change the path parameter of read_file() and write_file() for
consistency.

Lastly, add a test for handling strings with '\0' in them.

Bug: 36726045
Bug: 36576280
Test: Boot bullhead, run unit tests
Change-Id: Idad60e4228ee2de741ab3ab6a4917065b5e63cd8
(cherry picked from commit 53089aa25c)
2017-04-19 16:39:08 +00:00
Bowgo Tsai
a190551d2e Merge "Set libavb version into system property for Treble OTA" into oc-dev 2017-04-19 06:13:56 +00:00
Tom Cherry
19866bf19f init: add warning that start is not synchronous
Bug: 36571736
Bug: 37481363
Change-Id: I5d360cbb3635f00453a492ee4e3650fb80f390f5
2017-04-19 00:46:44 +00:00
Tom Cherry
5ceb7b3ebd init: handle sys.powerctl immediately
Currently if a process sets the sys.powerctl property, init adds this
property change into the event queue, just like any other property.
The actual logic to shutdown the device is not executed until init
gets to the action associated with the property change.

This is bad for multiple reasons, but explicitly causes deadlock in
the follow scenario:

A service is started with `exec` or `exec_start`
The same service sets sys.powerctl indicating to the system to
shutdown
The same service then waits infinitely

In this case, init doesn't process any further commands until the exec
service completes, including the command to reboot the device.

This change causes init to immediately handle sys.powerctl and reboot
the device regardless of the state of the event queue, wait for exec,
or wait for property conditions.

Bug: 37209359
Bug: 37415192

Test: Init reboots normally
Test: Update verifier can reboot the system
Change-Id: Iff2295aed970840f47e56c4bacc93001b791fa35
(cherry picked from commit 98ad32a967)
2017-04-18 12:24:58 -07:00
Tom Cherry
1f49801ab1 Merge "init: handle sys.powerctl immediately" am: 14ed55bae8 am: e6bfb53196
am: 8972f887d2

Change-Id: I3af0841fc3c23e2758ec5f330e9ba03f7695d50f
2017-04-18 18:33:17 +00:00
Tom Cherry
14ed55bae8 Merge "init: handle sys.powerctl immediately" 2017-04-18 18:14:18 +00:00
Tom Cherry
98ad32a967 init: handle sys.powerctl immediately
Currently if a process sets the sys.powerctl property, init adds this
property change into the event queue, just like any other property.
The actual logic to shutdown the device is not executed until init
gets to the action associated with the property change.

This is bad for multiple reasons, but explicitly causes deadlock in
the follow scenario:

A service is started with `exec` or `exec_start`
The same service sets sys.powerctl indicating to the system to
shutdown
The same service then waits infinitely

In this case, init doesn't process any further commands until the exec
service completes, including the command to reboot the device.

This change causes init to immediately handle sys.powerctl and reboot
the device regardless of the state of the event queue, wait for exec,
or wait for property conditions.

Bug: 37209359
Bug: 37415192

Test: Init reboots normally
Test: Update verifier can reboot the system
Change-Id: Iff2295aed970840f47e56c4bacc93001b791fa35
2017-04-17 16:40:06 -07:00
Tom Cherry
c4b1a2f230 Merge "ueventd: create classes for dev and sys permissions" am: ffa38cfc1e am: e29fa61725
am: b7ef4726ff

Change-Id: I2b64de1007adb68ef3364f0ed6bbd51b297d292e
2017-04-17 21:56:27 +00:00
Tom Cherry
cc054c9da8 ueventd: create classes for dev and sys permissions
Create classes for dev and sys permissions and store these permissions
in std::vector instead of the C list.

Test: boot bullhead
Test: init unit tests

Change-Id: I874039a3db29b4c70149506da8e407123ab7eca2
2017-04-17 19:33:04 +00:00
TreeHugger Robot
29ab67b0c1 Merge "Revert "Send property_service AVC messages to the kernel audit system"" into oc-dev 2017-04-15 07:37:38 +00:00
Bowgo Tsai
6e69b2ea2a Merge "Set libavb version into system property for Treble OTA" am: e8311491da am: 7b08869382
am: 6f3ec3d759

Change-Id: I2c97b605e75c479e485ac36e1e90c039467df04e
2017-04-15 06:07:10 +00:00
Bowgo Tsai
451801223b Set libavb version into system property for Treble OTA
Set ro.boot.avb_version to "AVB_VERSION_MAJOR.AVB_VERSION_MINOR".
During Treble OTA match, the major version must be the same as that in
the avb metadata on disk, while the minor version can be equal or
greater to that in the avb metadata on disk.

See how avb versioning work on the following link:

  https://android-review.googlesource.com/#/c/342757/

Also renames AvbHashtreeDisabled() -> hashtree_disabled().

Bug: 35322304
Test: Early mount with AVB, checks [ro.boot.avb_version]: [1.0] exists.
Test: Not enable AVB, checks [ro.boot.avb_version] doesn't exists.

Change-Id: I5aaf476ca53c4fe817779518ba14b68ebcfdc6d6
Merged-In: I5aaf476ca53c4fe817779518ba14b68ebcfdc6d6
(cherry picked from commit 1a898c25f9)
2017-04-15 14:01:06 +08:00
Bowgo Tsai
1a898c25f9 Set libavb version into system property for Treble OTA
Set ro.boot.avb_version to "AVB_VERSION_MAJOR.AVB_VERSION_MINOR".
During Treble OTA match, the major version must be the same as that in
the avb metadata on disk, while the minor version can be equal or
greater to that in the avb metadata on disk.

See how avb versioning work on the following link:

  https://android-review.googlesource.com/#/c/342757/

Also renames AvbHashtreeDisabled() -> hashtree_disabled().

Bug: 35322304
Test: Early mount with AVB, checks [ro.boot.avb_version]: [1.0] exists.
Test: Not enable AVB, checks [ro.boot.avb_version] doesn't exists.

Change-Id: I5aaf476ca53c4fe817779518ba14b68ebcfdc6d6
2017-04-15 09:47:31 +08:00
Elliott Hughes
a39515ce8d Revert "Send property_service AVC messages to the kernel audit system"
This reverts commit 8adb4d9d12.

(cherrypick of d8f9356bec)

Change-Id: I0db29617f323ef31ca5a270d02b7668092e9c9e1
2017-04-14 17:44:22 -07:00
Elliott Hughes
77fc053638 Merge "Revert "Send property_service AVC messages to the kernel audit system"" am: eea60804f6 am: aee26df200
am: 246a7e57b8

Change-Id: Ibf1c376d96c1d9000b44b89432d6c959d050309b
2017-04-15 00:29:22 +00:00
Elliott Hughes
eea60804f6 Merge "Revert "Send property_service AVC messages to the kernel audit system"" 2017-04-15 00:13:47 +00:00
Tom Cherry
d374d59c09 Merge changes I9d0482d1,Ib82833be am: b87f1c1728 am: 43473d3a54
am: dfb81ce15a

Change-Id: Iadacb505e72b41ee3845ad48dda192094ca6f53e
2017-04-14 21:56:25 +00:00
Elliott Hughes
d8f9356bec Revert "Send property_service AVC messages to the kernel audit system"
This reverts commit 8adb4d9d12.

Change-Id: I0db29617f323ef31ca5a270d02b7668092e9c9e1
2017-04-14 12:53:19 -07:00
Tom Cherry
1ab8f55344 ueventd: convert platform_names from C list to std::vector
Also simplify this code a bit.

There's only one consumer that removes the /devices/platform prefix,
so have them handle it instead of storing two copies of the string.

Remove an unneeded search for '/' in get_character_device_symlinks()
as a / will always be the next character after a parent path, by
nature of FindPlatformDevice().

Test: boot bullhead
Test: init unit tests

Change-Id: I9d0482d137b1342ae7509ae993ff99198be814f0
2017-04-14 10:23:52 -07:00
Tom Cherry
e3e48214b7 ueventd: replace char* with std::string in struct uevent
Bug: 36250207

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: Ib82833bea56bdafbe1d7a045126aaa91a8725d98
2017-04-14 10:23:52 -07:00
Treehugger Robot
e771b69e72 Merge changes I6a29c678,I76212f65
* changes:
  reboot: fix owner and permissions of last_reboot_reason file
  init.rc: create /data/misc/reboot owned by system
2017-04-14 14:16:20 +00:00
Bowgo Tsai
92ca58b5bd fs_mgr: support AVB in fs_mgr_update_verity_state()
fs_mgr_update_verity_state() is invoked by 'verity_update_state' in
init.rc. It will then set property "partition.system.verified" and
"partition.vendor.verified" to verify_mode. We should support this for
AVB as well.

Also change the order of static libs in init to fix the build error
after this change:
  system/extras/ext4_utils/ext4_crypt.cpp:69: error: undefined reference to 'property_get'

Bug: 35416769
Test: Mount /system and /vendor with vboot 2.0 (AVB), check the following properties exist.
      - [partition.system.verified]: [2]
      - [partition.vendor.verified]: [2]
Test: Mount /system and /vendor with vboot 1.0, check the following properties exist.
      - [partition.system.verified]: [0]
      - [partition.vendor.verified]: [0]

Change-Id: I4328d66a8cb93f26e7960e620a0b2292d5f15900
Merged-In: I4328d66a8cb93f26e7960e620a0b2292d5f15900
(cherry picked from commit aaf70e77dc)
2017-04-14 21:53:49 +08:00
Bowgo Tsai
51c027285b init: support early_mount with vboot 2.0 (external/avb/libavb)
libavb requires verifying AVB metadata on all verified partitions at
once. For example, /vbmeta, /boot, /system and /vendor. We need to
invoke device_init() for those partitions even if we only want to early
mount some of them, like /vendor and /system.

This CL gets all AVB partitions and the early mount partitions from
device tree through "firmware/android/vbmeta" and "firmware/fstab",
respectively. The following is an example to early mount /vendor
partition on bullhead:

firmware {
    android {
        compatible = "android,firmware";
        vbmeta {
            compatible = "android,vbmeta";
            parts = "boot,system,vendor";
            by_name_prefix="/dev/block/platform/soc.0/f9824900.sdhci/by-name"
        };
        fstab {
            compatible = "android,fstab";
            vendor {
                compatible = "android,vendor";
                dev = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor";
                type = "ext4";
                mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
                fsmgr_flags = "wait,avb";
            };
        };
    };
};

Bug: 33254008
Test: early mount /vendor with vboot 2.0 (AVB) on bullhead
Test: early mount /system without dm-verity on bullhead
Test: early mount /vendor with vboot 1.0 on sailfish

Change-Id: I89a1f77c97124f309346b33d9e700544b92ecf05
Merged-In: I89a1f77c97124f309346b33d9e700544b92ecf05
(cherry picked from commit 8bba52fc4b)
2017-04-14 21:53:39 +08:00
Bowgo Tsai
4d70aa5541 Merge changes from topic 'avb-early-mount' am: d7381375bb am: 04989a7a4b
am: 0b2d83a64b

Change-Id: I3911b1be010b7f79f2b3975a9264eb914044392f
2017-04-14 06:40:58 +00:00
Treehugger Robot
d7381375bb Merge changes from topic 'avb-early-mount'
* changes:
  fs_mgr: support AVB in fs_mgr_update_verity_state()
  init: support early_mount with vboot 2.0 (external/avb/libavb)
2017-04-14 06:20:42 +00:00
Bowgo Tsai
aaf70e77dc fs_mgr: support AVB in fs_mgr_update_verity_state()
fs_mgr_update_verity_state() is invoked by 'verity_update_state' in
init.rc. It will then set property "partition.system.verified" and
"partition.vendor.verified" to verify_mode. We should support this for
AVB as well.

Also change the order of static libs in init to fix the build error
after this change:
  system/extras/ext4_utils/ext4_crypt.cpp:69: error: undefined reference to 'property_get'

Bug: 35416769
Test: Mount /system and /vendor with vboot 2.0 (AVB), check the following properties exist.
      - [partition.system.verified]: [2]
      - [partition.vendor.verified]: [2]
Test: Mount /system and /vendor with vboot 1.0, check the following properties exist.
      - [partition.system.verified]: [0]
      - [partition.vendor.verified]: [0]

Change-Id: I4328d66a8cb93f26e7960e620a0b2292d5f15900
2017-04-14 12:10:49 +08:00
Bowgo Tsai
8bba52fc4b init: support early_mount with vboot 2.0 (external/avb/libavb)
libavb requires verifying AVB metadata on all verified partitions at
once. For example, /vbmeta, /boot, /system and /vendor. We need to
invoke device_init() for those partitions even if we only want to early
mount some of them, like /vendor and /system.

This CL gets all AVB partitions and the early mount partitions from
device tree through "firmware/android/vbmeta" and "firmware/fstab",
respectively. The following is an example to early mount /vendor
partition on bullhead:

firmware {
    android {
        compatible = "android,firmware";
        vbmeta {
            compatible = "android,vbmeta";
            parts = "boot,system,vendor";
            by_name_prefix="/dev/block/platform/soc.0/f9824900.sdhci/by-name"
        };
        fstab {
            compatible = "android,fstab";
            vendor {
                compatible = "android,vendor";
                dev = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor";
                type = "ext4";
                mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
                fsmgr_flags = "wait,avb";
            };
        };
    };
};

Bug: 33254008
Test: early mount /vendor with vboot 2.0 (AVB) on bullhead
Test: early mount /system without dm-verity on bullhead
Test: early mount /vendor with vboot 1.0 on sailfish

Change-Id: I89a1f77c97124f309346b33d9e700544b92ecf05
2017-04-14 12:10:20 +08:00
Todd Poynor
a03b4dc574 Merge changes I76212f65,I6a29c678 into oc-dev
am: 5975d4e337

Change-Id: I0441dc1f8a9ff11429a253d0510790b20b42e3b4
2017-04-14 01:37:03 +00:00
Todd Poynor
fc827be3f9 reboot: fix owner and permissions of last_reboot_reason file
Default signature WriteStringToFile creates world-writeable files.
Set owner and group system and remove read/write for non-owner.

Bug: 37251463
Test: Manual: reboot, inspect
Change-Id: I6a29c678168dcae611b120dc52170f4eee7069a9
2017-04-13 18:03:59 -07:00
Todd Poynor
dff584659c reboot: fix owner and permissions of last_reboot_reason file
Default signature WriteStringToFile creates world-writeable files.
Set owner and group system and remove read/write for non-owner.

Bug: 37251463
Test: Manual: reboot, inspect
Change-Id: I6a29c678168dcae611b120dc52170f4eee7069a9
2017-04-13 15:48:11 -07:00
Tom Cherry
aa85663027 Merge changes Ie5ec609a,I5a2ac369,I690137b5 am: 659b78ed10 am: 01b87aac9c
am: 8d9eee4f2b

Change-Id: I5cd7d00f71bfd3970189481f381629cedc358c9b
2017-04-13 21:45:58 +00:00
Tom Cherry
659b78ed10 Merge changes Ie5ec609a,I5a2ac369,I690137b5
* changes:
  ueventd: Fix up string handling in handle_*_device_event()
  ueventd: convert mkdir_recursive() to std::string
  ueventd: move subsystem logic from code to ueventd.rc
2017-04-13 21:22:45 +00:00
Jeffrey Vander Stoep
be2bfc55f7 Merge "init: expand generated attributes on sepolicy compile" into oc-dev
am: 57d4c59559

Change-Id: If3230f31ab3d680c411351d61dc68e5963355d33
2017-04-13 18:37:43 +00:00
Jeffrey Vander Stoep
57d4c59559 Merge "init: expand generated attributes on sepolicy compile" into oc-dev 2017-04-13 18:11:08 +00:00
Jeff Vander Stoep
d278253378 init: expand generated attributes on sepolicy compile
Expand auto generated attributes in selinux policy when doing
on-device compile of platform + vendor selinux policy.

Bug: 3650825
Test: Build and boot Marlin
Change-Id: Icc1c3af0b504236ae13fd8a5155c2109befd7688
2017-04-13 17:32:51 +00:00
Martijn Coenen
30ec708335 Merge "restorecon hwservice_contexts." into oc-dev
am: f8952a196c

Change-Id: If828fe3afd399f15fcc351f39dc0cdc7531ed635
2017-04-13 03:43:51 +00:00
Martijn Coenen
f8952a196c Merge "restorecon hwservice_contexts." into oc-dev 2017-04-13 03:34:48 +00:00
Martijn Coenen
6887273a28 restorecon hwservice_contexts.
Test: marlin boots, angler boots
Bug: 34454312
Change-Id: I5da8b0b10a7a4c0e6e0c9aea39004852889e8d97
2017-04-12 18:02:33 -07:00
Dmitri Plotnikov
bcb5e5008c Merge "Passing additional parameter to powerctl" am: e0ab2557d4 am: 0c146e6572
am: cff6544e2e

Change-Id: I6e21babe911996ac0f91e9a61aeb46499c4949c0
2017-04-13 00:52:00 +00:00
Tom Cherry
3fa467338f ueventd: Fix up string handling in handle_*_device_event()
Bug: 36250207

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: Ie5ec609a3f74bb03f5920734ada4d7de57508de4
2017-04-12 16:36:53 -07:00
Tom Cherry
060b74baad ueventd: convert mkdir_recursive() to std::string
Bug: 36250207

Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: I5a2ac369d846e044230b709fd07eb21ad12d47bb
2017-04-12 16:36:44 -07:00
Tom Cherry
780a71e779 ueventd: move subsystem logic from code to ueventd.rc
Test: Boot bullhead
Test: Boot sailfish, observe no boot time regression
Test: init unit tests

Change-Id: I690137b584fcc2b9cd2dd932a2678f75a56d6737
2017-04-12 16:36:20 -07:00
Dmitri Plotnikov
00e1c4f330 Passing additional parameter to powerctl
Test: adb reboot recovery,foo and verify that the parameter reaches bootloader
Change-Id: I9690cf96cf9730e5324b9f5310c3d0341fe25fe2
2017-04-12 14:38:23 -07:00
Dan Cashman
18ff05146f init: use platform sepolicy version indicated by /vendor.
am: 692c3e4d38

Change-Id: I81874aea3896c1156295616f12c211e9423d5ca7
2017-04-12 20:43:31 +00:00
Dan Cashman
692c3e4d38 init: use platform sepolicy version indicated by /vendor.
It's possible, in the event of a platform update, for the platform
SELinux policy to change from the policy on which the vendor SELinux
policy was originally based.  In this case, a different mapping file
to bridge the differences between the new policy and the old needs to
be selected.

Make init choose which mapping policy file to use based on the version
reported in /vendor/etc/selinux/plat_sepolicy_vers.txt.

Bug: 36783775
Test: Force compilation of sepolicy on-device with mapping file changed
to new location and name, using the value reported on /vendor.

Change-Id: I63c883ccb79dd31c92dabe44a55c4ab50a3735e6
2017-04-12 10:45:08 -07:00
Tom Cherry
6289bb1341 Merge "ueventd: remove /dev/log" am: 120add07ab am: 9ae606d659
am: 6c2e8b10fe

Change-Id: Ic257774710a74e72a97f4187e48587150ee3d613
2017-04-12 08:17:29 +00:00
Treehugger Robot
120add07ab Merge "ueventd: remove /dev/log" 2017-04-12 07:58:33 +00:00
Tom Cherry
420a937e3e Merge "ueventd: replace char** links with std::vector<std::string>" am: 162118928e am: a778c81e11
am: ed5f8ca6e9

Change-Id: Ie64fbebc87bd419f9aba5655a5c223d08b0424e9
2017-04-12 01:15:46 +00:00
Treehugger Robot
162118928e Merge "ueventd: replace char** links with std::vector<std::string>" 2017-04-12 00:57:35 +00:00
Tom Cherry
d4ff8d83d3 ueventd: remove /dev/log
This was marked deprecated in 2014 and removed in 2015, let's remove
the uevent rule now too.

Test: see that logging still works on bullhead
Change-Id: Idaf3f49a1afe7046eba6c976628b9f1c8b3ec094
2017-04-11 21:35:46 +00:00
Keun-young Park
ae56bc7efa Merge "poll umount completion from /proc/mounts" am: 625a098573 am: cb4dadfb08
am: 4c44243c45

Change-Id: Iee3fac59672d5f7f6bfdad35e374fec3f5a29f29
2017-04-11 01:04:55 +00:00
Keun-young Park
0e90dee9e0 poll umount completion from /proc/mounts
- umount operation is asynchronous except for root partition.
  Returning from umount does not guarantee completion of
  umount. Poll /proc/mounts to confirm completion of umount.
- Treat all devices mounting to /data as emulated devices. This is
  future proof when fs other than sdcardfs is used.
- Drop quota sync from sync step. There is no differences in
  frequencies of quota error.
- Run umount in reverse order from mounting order so that any
  hidden dependency can be auto-resolved.
- Add dump of lsof and /proc/mounts when umount fails. lsof only runs
  when selinux is toggled into permissive mode. The dump is enabled
  only for non-user build.
- Keep logcat until vold shutdown in case vold has any error to report.

bug: 36551218
Test: python packages/services/Car/tools/bootanalyze/bootanalyze.py -r -c packages/services/Car/tools/bootanalyze/config.yaml -n 1000 -f -e 20 -w 30

Change-Id: I87b17b966d7004c205452d81460b02c6acf50d45
(cherry picked from commit 2ba5c8103d)
2017-04-10 17:48:19 -07:00
Keun-young Park
2ba5c8103d poll umount completion from /proc/mounts
- umount operation is asynchronous except for root partition.
  Returning from umount does not guarantee completion of
  umount. Poll /proc/mounts to confirm completion of umount.
- Treat all devices mounting to /data as emulated devices. This is
  future proof when fs other than sdcardfs is used.
- Drop quota sync from sync step. There is no differences in
  frequencies of quota error.
- Run umount in reverse order from mounting order so that any
  hidden dependency can be auto-resolved.
- Add dump of lsof and /proc/mounts when umount fails. lsof only runs
  when selinux is toggled into permissive mode. The dump is enabled
  only for non-user build.
- Keep logcat until vold shutdown in case vold has any error to report.

bug: 36551218
Test: python packages/services/Car/tools/bootanalyze/bootanalyze.py -r -c packages/services/Car/tools/bootanalyze/config.yaml -n 1000 -f -e 20 -w 30

Change-Id: I87b17b966d7004c205452d81460b02c6acf50d45
2017-04-10 15:41:15 -07:00
Josh Gao
a0ff3d7b6b Merge "crash_dump: during early boot, output to kmsg on userdebug." am: 72ca48e5cb am: 35b7a274ac
am: e80f6668f5

Change-Id: Ic9b44bd3cf50240c1f34edb8aa35a821a75e202c
2017-04-10 21:13:05 +00:00
Josh Gao
72ca48e5cb Merge "crash_dump: during early boot, output to kmsg on userdebug." 2017-04-10 20:51:59 +00:00
Tom Cherry
2e344f9d22 ueventd: replace char** links with std::vector<std::string>
Additionally replace the associated C string parsing with C++ and write
unit tests.

Bug: 33785894
Bug: 36250207
Test: Boot bullhead + unit tests
Change-Id: Iee1f72d248bca3bd2e1227045628935b3dd6195a
2017-04-08 00:05:50 +00:00
Tom Cherry
7dd593a887 Merge "init: clean up more headers" am: 4f6feec25b am: a7d0718907
am: 99b26e5ab1

Change-Id: I6cfffc3c756dd02263adfe1aac1456a70d76ce03
2017-04-07 23:14:51 +00:00
Treehugger Robot
4f6feec25b Merge "init: clean up more headers" 2017-04-07 22:56:32 +00:00
Tom Cherry
f57c0bfab2 init: clean up more headers
We don't need everyone including <sys/system_properties.h>

Test: boot bullhead
Change-Id: I73d507e4f273678eaf15947725741e1e3b966cc6
2017-04-07 13:49:12 -07:00
Treehugger Robot
a74635d33e Merge "Reflect move of mapping file to /system." 2017-04-07 14:25:33 +00:00
Tom Cherry
25c351ccb8 Merge "init: more header cleanup" am: ab5ab1ebd4 am: 6510908bd1
am: d93ffe7260

Change-Id: I987514d698ac2c67036ad8dc084ca36c8a300767
2017-04-07 02:59:38 +00:00
Treehugger Robot
ab5ab1ebd4 Merge "init: more header cleanup" 2017-04-07 02:44:07 +00:00
Tom Cherry
3f5eaae526 init: more header cleanup
Remove includes of "log.h" that really want <android-base/logging.h>
Fix header include order
Remove headers included in .cpp files that their associated .h already includes
Remove some unused headers

Test: boot bullhead
Change-Id: I2b415adfe86a5c8bbe4fb1ebc53c7b0ee2253824
2017-04-06 18:06:34 -07:00
Tom Cherry
f2cb84724b Merge "ueventd: Write tests for the get_*_symlinks() functions" am: e7fbd6a2b4 am: e6b70f5913
am: 9cf2cd358c

Change-Id: Ifca39b2f2ffc66c81c2abc7defe8018fab4d6a5c
2017-04-07 00:30:23 +00:00
Josh Gao
bf2dd48241 crash_dump: during early boot, output to kmsg on userdebug.
Crashes that happen before tombstoned is running are extremely hard to
diagnose, because tombstones aren't written to disk, and the window of
opportunity to get logs via `adb logcat` is small (potentially
nonexistent).

Solve this by adding a world-writable /dev/kmsg_debug on userdebug
builds, and writing to it in addition to logcat when tombstoned hasn't
started yet.

Bug: http://b/36574794
Test: stop tombstoned; crasher; dmesg
Change-Id: Ib22c02a002afb602933155fb2c9b7a8abbe9ed38
2017-04-06 15:00:52 -07:00
Dan Cashman
299231152e Reflect move of mapping file to /system.
Bug: 36783775
Test: boot device with matching sha256 and non-matching and verify that
device boots and uses either precompiled or compiled policy as needed. Also
verify that mapping_sepolicy.cil has moved.

(cherry-pick of commit: 39ffec779a)
Change-Id: I9c3df2e7ed3f0eadd98e98529ebed360fec66dba
2017-04-06 12:52:33 -07:00
Dan Cashman
620ec3bd5b Reflect move of mapping file to /system.
am: 39ffec779a

Change-Id: Ib8bd7f2ad3ab37029cc0c86d6aaee72649e6ca93
2017-04-06 19:07:45 +00:00
Dan Cashman
39ffec779a Reflect move of mapping file to /system.
Bug: 36783775
Test: boot device with matching sha256 and non-matching and verify that
device boots and uses either precompiled or compiled policy as needed. Also
verify that mapping_sepolicy.cil has moved.

Change-Id: I9c3df2e7ed3f0eadd98e98529ebed360fec66dba
2017-04-06 09:57:23 -07:00
Tom Cherry
c44f6a4073 ueventd: Write tests for the get_*_symlinks() functions
Bug: 33785894
Bug: 36250207
Test: Boot bullhead + new unit tests
Change-Id: Ia0f290542eb1cffce5ae876dfedb453dde960253
2017-04-05 18:21:39 -07:00
Tom Cherry
554c1fa234 Merge "init: use read_file and write_file to implement do_copy builtin" 2017-04-04 16:42:50 +00:00
Yongqin Liu
dbe88e7953 init: use read_file and write_file to implement do_copy builtin
this will make the implementation more cleaner,
and has error message output when failed on some operations

also add the O_TRUNC flag explicitly for the open function
called in write_file.

And add more test on read_file and write_file functions

Bug: 36726045
Test: manual with hikey
Test: boot and init tests on bullhead
Test: cast with fugu, per b/36726045
Merged-In: If3c30a2fff58cfece2fcd27e69c30382146e6808

Change-Id: If3c30a2fff58cfece2fcd27e69c30382146e6808
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
2017-04-04 06:21:29 +00:00
Yongqin Liu
246e3c4c7c init: use read_file and write_file to implement do_copy builtin
this will make the implementation more cleaner,
and has error message output when failed on some operations

also add the O_TRUNC flag explicitly for the open function
called in write_file.

And add more test on read_file and write_file functions

Bug: 36726045
Test: manual with hikey
Test: boot and init tests on bullhead
Test: cast with fugu, per b/36726045

Change-Id: If3c30a2fff58cfece2fcd27e69c30382146e6808
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
2017-04-03 21:33:59 -07:00
Martijn Coenen
c04403fb6e Merge "Restorecon new vndservice_contexts file." into oc-dev
am: 6c2b3e5fd8

Change-Id: Ida2184388171b5d5febd61cd7d6159c3b958d6a9
2017-04-04 03:51:27 +00:00