Commit Graph

2061 Commits

Author SHA1 Message Date
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 ae66073276 Merge "init: shutdown services in the opposite order that they started" am: 8e7942cbd1 am: 9f030d89dc
am: 70c71dfe58

Change-Id: If82ec58b0c7f3dc028d61365c280ee0b0f7d3cc5
2017-07-27 17:52:21 +00:00
Tom Cherry 70c71dfe58 Merge "init: shutdown services in the opposite order that they started" am: 8e7942cbd1
am: 9f030d89dc

Change-Id: I5c83460633c56fcf740ca939b0dd931bee6854ab
2017-07-27 17:50:13 +00:00
Tom Cherry 9f030d89dc Merge "init: shutdown services in the opposite order that they started"
am: 8e7942cbd1

Change-Id: Ibd6b25f77dc3f4033902ec25323ff4e6cab024a2
2017-07-27 17:48:12 +00:00
Tom Cherry 8e7942cbd1 Merge "init: shutdown services in the opposite order that they started" 2017-07-27 17:42:46 +00:00
Ben Fennema 2953e1af9b Merge "init: fix type of 2nd argument passed to prctl" am: 1b506c54c2 am: f01f4e9d4a
am: ec7afe31a0

Change-Id: I2b46745a6d68b4c5fb4b1a91deecb28b0388d6b9
2017-07-27 07:03:30 +00:00
Ben Fennema ec7afe31a0 Merge "init: fix type of 2nd argument passed to prctl" am: 1b506c54c2
am: f01f4e9d4a

Change-Id: Ie84551e47139dbdbbf7a9a27a849718b43e00fa7
2017-07-27 07:00:28 +00:00
Ben Fennema f01f4e9d4a Merge "init: fix type of 2nd argument passed to prctl"
am: 1b506c54c2

Change-Id: I5b4de3ee0e55d99e8d63f98fdcbd39de70ff0337
2017-07-27 06:57:58 +00:00
Ben Fennema a72436067d init: fix type of 2nd argument passed to prctl
prctl(PR_SET_SECUREBITS, ...) expects an unsigned long as its 2nd argument.
Passing in a int64_t happens to work with a 64-bit kernel, but does not
work with a 32-bit kernel.

Bug: 63680332
Test: boot 32-bit kernel; verify services with capabilities can successfully
      set those capabilties
Change-Id: I60250d107a77b54b2e9fe3419b4480b921c7e2f8
Signed-off-by: Ben Fennema <fennema@google.com>
2017-07-27 03:31:18 +00:00
Tom Cherry a12e34cc31 Merge "init: only use signed-integer-overflow sanitizer" am: a19f481c8c am: 2eada2af9c
am: 9d36683fd7

Change-Id: I31be7dc0620e55dea1e97f2f26f59dce028cb563
2017-07-27 01:26:33 +00:00
Tom Cherry 9d36683fd7 Merge "init: only use signed-integer-overflow sanitizer" am: a19f481c8c
am: 2eada2af9c

Change-Id: Ic0da94313de22222d4312cf097fd5dcd43c76344
2017-07-27 00:58:03 +00:00
Tom Cherry 2eada2af9c Merge "init: only use signed-integer-overflow sanitizer"
am: a19f481c8c

Change-Id: I7f1e3ad1008f4d7d3588bbeca7c72bb0d9defeec
2017-07-27 00:49:55 +00:00
Tom Cherry 5938379e91 init: shutdown services in the opposite order that they started
Currently, the order that we kill to services during shutdown is the
order of services_ in ServiceManager and that is defacto the order in
which they were parsed, which is not a very useful ordering.

Related to this, we have seen a few issues during shutdown that may be
related to services with dependencies on other services, where the
dependency is killed first and the dependent service then misbehaves.

This change allows services to keep track of the order in which they
were started and shutdown then uses that information to kill running
services in the opposite order that they were started.

Bug: 64067984
Test: Boot and reboot bullhead

Change-Id: I6b4cacb03aed2a72ae98a346bce41ed5434a09c2
2017-07-26 16:48:06 -07:00
Tom Cherry 2ffd65e1d1 init: only use signed-integer-overflow sanitizer
We've blown up twice in init due to the unsigned integer overflow
sanitizer despite the overflows in question being both defined and
intentional.

Test: boot
Change-Id: I08effe3202ac1367d858982ff5478b3a088bab37
2017-07-26 14:25:25 -07:00
Lennart Wieboldt e1332dd01b Merge "Remove LOCAL_CLANG and clang: true" am: 80ec81cf4b am: f7b315c985
am: 8a8b97b271

Change-Id: I7e691abe2e2ccec5d9477c528d603c081c0a5661
2017-07-25 22:35:56 +00:00
Lennart Wieboldt 8a8b97b271 Merge "Remove LOCAL_CLANG and clang: true" am: 80ec81cf4b
am: f7b315c985

Change-Id: Id5ebeb3271a36f21bf28c186f7ec227d31bb10ac
2017-07-25 22:33:27 +00:00
Lennart Wieboldt f7b315c985 Merge "Remove LOCAL_CLANG and clang: true"
am: 80ec81cf4b

Change-Id: Ia7f79d8e25ee9870fe44d198568d0e5dabdff811
2017-07-25 22:28:56 +00:00
Treehugger Robot 80ec81cf4b Merge "Remove LOCAL_CLANG and clang: true" 2017-07-25 22:20:23 +00:00
Wei Wang 081c1921e0 Merge "Do not umount roofs even if it is R/W." am: 43567e39dc am: 22782a7269
am: 34e13498dc

Change-Id: I8b3c0cefd23d5e7e44da02e13cc173472834b070
2017-07-25 20:47:48 +00:00
Wei Wang 34e13498dc Merge "Do not umount roofs even if it is R/W." am: 43567e39dc
am: 22782a7269

Change-Id: I84024bff22fee8569c0f1193d6f3d8417d3cbc1b
2017-07-25 20:44:21 +00:00
Wei Wang 22782a7269 Merge "Do not umount roofs even if it is R/W."
am: 43567e39dc

Change-Id: I89bfb662469c28559eb628e48aee1ecb262ad2ee
2017-07-25 20:41:19 +00:00
Treehugger Robot 43567e39dc Merge "Do not umount roofs even if it is R/W." 2017-07-25 20:35:50 +00:00
Steve Muckle aa4bb9552f Merge "init: add support for global seccomp boot option" am: 9f1980e2fc am: 5a79972238
am: eb7db75c28

Change-Id: I5fabba13d6b269ffca8731fc83dbd590ae388239
2017-07-25 20:33:53 +00:00
Steve Muckle eb7db75c28 Merge "init: add support for global seccomp boot option" am: 9f1980e2fc
am: 5a79972238

Change-Id: Ide7500d4ff4d9eebf2fea1d81ff77044a6d63c57
2017-07-25 20:30:30 +00:00
Steve Muckle 5a79972238 Merge "init: add support for global seccomp boot option"
am: 9f1980e2fc

Change-Id: I35532202b360ef32cdb21c048cd3d2e1139b7d67
2017-07-25 20:26:29 +00:00
Treehugger Robot 9f1980e2fc Merge "init: add support for global seccomp boot option" 2017-07-25 20:18:51 +00:00
Wei Wang a01c27eef8 Do not umount roofs even if it is R/W.
Latest device has rootfs instead of "/system" mount point

Bug: 37737296
Test: adb remount, reboot, and check log
Change-Id: I315ecf71e85255fc55c3a80619920b456bad0956
2017-07-25 10:55:10 -07:00
Lennart Wieboldt cd15fc7ba8 Remove LOCAL_CLANG and clang: true
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: I34adaeef2f6558a09f26027271222bad94780507
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-07-25 14:29:50 +02:00
Wei Wang 9a63ee349d Merge "init: Fire shutdown trigger for thermal shutdown" am: 603cae8b48 am: b0a6129c43
am: fc2f0a0ce7

Change-Id: I1611d973239dd15b01799fc21bdc812dfacc8036
2017-07-24 22:20:19 +00:00
Wei Wang fc2f0a0ce7 Merge "init: Fire shutdown trigger for thermal shutdown" am: 603cae8b48
am: b0a6129c43

Change-Id: I3f88302f280809e9df98dc55dd2ca6ebd269e7bb
2017-07-24 22:17:50 +00:00
Wei Wang b0a6129c43 Merge "init: Fire shutdown trigger for thermal shutdown"
am: 603cae8b48

Change-Id: I0bbd26f22887afcf7b2145b78239c9f8e2c45047
2017-07-24 22:15:20 +00:00
Steve Muckle af1a9bfb8f init: add support for global seccomp boot option
Setting androidboot.seccomp=global on the kernel command line shall
enable seccomp for all processes rather than just in zygote. Doing
this has a performance impact, for now it shall just be used to audit
syscall usage during testing.

Bug: 37960259
Change-Id: I6b9fc95e9bec5e2bcfe6ef0b4343a5b422e30152
2017-07-24 13:33:54 -07:00
Wei Wang 1be2212319 init: Fire shutdown trigger for thermal shutdown
Recent change in init has bring normal shutdown sequence in
thermal-shutdown condition. This CL will make sure init fire shutdown
trigger where holds custom shutdown actions for vendor SoC/platform.

Bug: 63686426
Test: adb shell setprop sys.powerctl thermal-shutdown
Change-Id: Ieb8579fdf9c30c1a81d60466a7375c9784f3ca98
2017-07-24 13:12:22 -07:00
Tom Cherry 78f18a3e37 Merge "init: use delegating constructor for Service" am: ce3b2de809 am: 9549d6889a
am: d78477cf59

Change-Id: I9f43b6f3a35ff831efb4c7feb7f6cc27866bce31
2017-07-24 16:38:51 +00:00
Tom Cherry d78477cf59 Merge "init: use delegating constructor for Service" am: ce3b2de809
am: 9549d6889a

Change-Id: I5b2c03c405b8261a2613905d8597c58b73ca4bb9
2017-07-24 16:33:03 +00:00
Tom Cherry 9549d6889a Merge "init: use delegating constructor for Service"
am: ce3b2de809

Change-Id: Ic9bd63b44f57b505b1cd379948786349e92c0c45
2017-07-24 16:27:35 +00:00
Tom Cherry 5d17d044c7 init: use delegating constructor for Service
Test: init unit tests
Change-Id: Ida0be6195a3675bfca3d979db03855b45417b11e
2017-07-21 12:42:07 -07:00
Jin Qian 998de96766 Merge changes from topic 'mke2fs_2' am: 176827e166
am: 3f531ac5cf

Change-Id: Ic83be85a8955df27adf84e9ab9a2c5e40c0166e5
2017-07-21 19:10:35 +00:00
Jin Qian 3f531ac5cf Merge changes from topic 'mke2fs_2'
am: 176827e166

Change-Id: I933e0d96d9c81c5800e4cf406582277b140f3e2b
2017-07-21 19:06:03 +00:00
Treehugger Robot 176827e166 Merge changes from topic 'mke2fs_2'
* changes:
  fastboot: add mke2fs and e2fsdroid to build package
  fastboot: call mke2fs tools to generate ext4 image
  fs_mgr: call format_f2fs correctly with -f
  init: require e2fsdroid and mke2fs when building init
  init: rename mke2fs tools with _static suffix
2017-07-21 19:00:46 +00:00
Jin Qian 00456978a2 init: require e2fsdroid and mke2fs when building init
init calls fs_mgr to format ext4 partitions. This requires
e2fsdroid and mke2fs in /system/bin/

Bug: 35219933
Change-Id: Ia32fe438cd9b9332f8e18e0cbe7f61bd050adcb1
(cherry picked from commit 041f849548)
2017-07-20 11:54:02 -07:00
Jin Qian 278b15c84c init: rename mke2fs tools with _static suffix
We build a static version for recovery mode. Give them
different names to avoid conflicts with regular version
in /system/bin/

Bug: 35219933
Change-Id: I738655ad9b9ad71c63ae604d9a4d659b0b671121
(cherry picked from commit a2421041bf)
2017-07-20 11:53:44 -07:00
Keun-young Park 44dce1fed7 Merge "init: Do full shutdown even for thermal shutdown" am: d5b36f38ef am: a064892e1a
am: 614ccd7a02

Change-Id: Id714910ec5bdf4b94bfeee238484f4d47a9bdf01
2017-07-20 03:33:42 +00:00
Keun-young Park 614ccd7a02 Merge "init: Do full shutdown even for thermal shutdown" am: d5b36f38ef
am: a064892e1a

Change-Id: Ia6ddd5a680caa8283cf9d2a75c1eb49e1c79e413
2017-07-20 03:30:39 +00:00
Keun-young Park a064892e1a Merge "init: Do full shutdown even for thermal shutdown"
am: d5b36f38ef

Change-Id: If0bcd287d2656279a1d364761b0145ca4464299b
2017-07-20 03:27:38 +00:00
Treehugger Robot d5b36f38ef Merge "init: Do full shutdown even for thermal shutdown" 2017-07-20 03:21:41 +00:00
Tom Cherry 5b1202976e Merge "ueventd: fixup ueventd_test.cpp" am: 9aaf66b61f am: 34d4d57b87
am: 5d256bc555

Change-Id: I430e26f820653edfe35ededffa853dcf5e1324ad
2017-07-20 01:20:30 +00:00
Tom Cherry 5d256bc555 Merge "ueventd: fixup ueventd_test.cpp" am: 9aaf66b61f
am: 34d4d57b87

Change-Id: I7468e871785ea74e6cd5b070bd6f18153f6304a7
2017-07-20 01:17:31 +00:00
Tom Cherry 34d4d57b87 Merge "ueventd: fixup ueventd_test.cpp"
am: 9aaf66b61f

Change-Id: I7792c9ec68b6011e0186af2d40ca07d0801a4c2f
2017-07-20 01:15:00 +00:00
Tom Cherry 9aaf66b61f Merge "ueventd: fixup ueventd_test.cpp" 2017-07-20 01:05:28 +00:00
Keun-young Park 30173874fc init: Do full shutdown even for thermal shutdown
- Skipping SIGTERM / SIGKILL / umount brings race between block
  device driver and fs layer. Do umount before shutting down.
- Reduce timeout to 1 sec for thermal shutdown and skip other time
  taking part like fsck.
- Refactor waiting part to check time in ms so that 1 sec can
  have enough resolution.

bug: 63686426
Test: adb shell setprop sys.powerctl thermal-shutdown, adb shell setprop sys.powerctl reboot and check dmesg
Change-Id: I048bac767b328c8d656a97fe65dde5f2b5bf4ae5
2017-07-19 17:27:05 -07:00
Keun-young Park f0a13c35f2 Merge "dump stack before kill all" am: c13a2da2f4 am: 4e24aa2bc3
am: 2b33d96db1

Change-Id: Ic9c86ce7ddf8591a9fb2d3b1cdf72057c21d4111
2017-07-19 22:29:51 +00:00
Tom Cherry 2ef572be30 ueventd: fixup ueventd_test.cpp
Use ASSERT_EQ() instead of EXPECT_EQ() to prevent segfaults after
failed API calls.

Do not run setfscreatecon_IsPerThread unless we're in permissive mode
as it will not pass otherwise.

Test: init unit tests
Change-Id: I70525d438e89f1ec036255890169a50b5007b4c4
2017-07-19 15:29:20 -07:00
Keun-young Park 2b33d96db1 Merge "dump stack before kill all" am: c13a2da2f4
am: 4e24aa2bc3

Change-Id: If924fe081a81c2061ed06e741fc5e6984e24b1f9
2017-07-19 22:26:22 +00:00
Keun-young Park 4e24aa2bc3 Merge "dump stack before kill all"
am: c13a2da2f4

Change-Id: Ie09fd8a7e95686c41d2a7af9e9e291f89c673036
2017-07-19 22:23:48 +00:00
Keun-young Park c13a2da2f4 Merge "dump stack before kill all" 2017-07-19 22:17:06 +00:00
Keun-young Park c59b822d1f dump stack before kill all
- If problematic process is from user, kill all kills
  it and dump does not show problematic process.

bug: 37737296
Test: reboot and check log
Change-Id: Iaa4f7d12f5a40fa7528c6672567c36e30b140372
2017-07-18 18:52:25 -07:00
Robert Benea eab1c14aba Merge "Add memcg related configs to init." am: b84666cbc0 am: 7564622f88
am: 5cf308bcde

Change-Id: Ic86a3200b5080438ad6cb33f9bc3f6ff2ecca22b
2017-07-19 01:12:40 +00:00
Robert Benea 5cf308bcde Merge "Add memcg related configs to init." am: b84666cbc0
am: 7564622f88

Change-Id: Ia9f5b5d524eb437598e9d453ca05e35d52445cc1
2017-07-19 01:03:32 +00:00
Robert Benea 7564622f88 Merge "Add memcg related configs to init."
am: b84666cbc0

Change-Id: I437c5d05582c6a3cce632f92835ee91f419a7190
2017-07-19 01:01:27 +00:00
Robert Benea b84666cbc0 Merge "Add memcg related configs to init." 2017-07-19 00:54:41 +00:00
Robert Benea d485226951 Add memcg related configs to init.
Allow configuring memory.swappiness, memory.soft_limit_in_bytes
and memory.limit_in_bytes by init; by doing so there is better
control of memory consumption per native app.

Test: tested on gobo branch.
bug: 63765067
Change-Id: I8906f3ff5ef77f75a0f4cdfbf9d424a579ed52bb
2017-07-18 15:58:40 -07:00
Quang Luong 6bcf4fb8b5 Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp" am: a022ea424d am: c1e78e1331
am: be2a262b47

Change-Id: I223ebf56a8bbefb38735ebbcfe45c7d2a78cd50c
2017-07-18 22:39:00 +00:00
Quang Luong be2a262b47 Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp" am: a022ea424d
am: c1e78e1331

Change-Id: I81d4f619f38a6f511562d98fe7a0dd64c7290f81
2017-07-18 21:26:19 +00:00
Quang Luong c1e78e1331 Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp"
am: a022ea424d

Change-Id: Ie4b2131525373fef14dfa2c7a7ec1e23a50dc56a
2017-07-18 21:20:26 +00:00
Treehugger Robot a022ea424d Merge "uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp" 2017-07-18 21:16:30 +00:00
Quang Luong dd6a85ccd5 uml: init: add USER_MODE_LINUX cflag, USER_MODE_LINUX case in init.cpp
Modified Android.mk to define cflag "USER_MODE_LINUX" if
TARGET_USER_MODE_LINUX := true in BoardCofig.mk.
Modified set_mmap_rnd_bits_action to return 0 if "USER_MODE_LINUX" is
defined. This is needed since uml does not support the mmap_rnd_bits
sysctl, and init would otherwise crash without this check.

Test: manual

Bug: 32523022
Change-Id: I409ef64a1fa253bfb3f9fb59d0267be159819bb8
Signed-off-by: Quang Luong <qal@google.com>
2017-07-18 18:18:31 +00:00
Keun-young Park ab54410f0d Merge "Do not umount /vendor, /system, and /oem even if they are R/W." am: 11649e8925 am: c9f601a178
am: 10b74ed2a6

Change-Id: Ie0339f41eb166e156ab61133e6a2c19e4bbd28a2
2017-07-18 03:18:07 +00:00
Keun-young Park 10b74ed2a6 Merge "Do not umount /vendor, /system, and /oem even if they are R/W." am: 11649e8925
am: c9f601a178

Change-Id: Ia5f3096e339ed8d088482c5c11ed5e5b906e9205
2017-07-18 03:15:36 +00:00
Keun-young Park c9f601a178 Merge "Do not umount /vendor, /system, and /oem even if they are R/W."
am: 11649e8925

Change-Id: I1b4db022ca316648dfccfa12c3f8e886e6b15b08
2017-07-18 03:12:37 +00:00
Keun-young Park 6e12b3887e Do not umount /vendor, /system, and /oem even if they are R/W.
- /vendor, /system, /oem can be remounted to R/W for development
  purpose.

- In such case, umounting these partitions can lead into some processes
  not running properly during shutdown or blocking umount of fs.

- So skip them. As it is dev feature, it is up to each developer to
  understand the risk. But for normal adb sync - reboot should be ok
  as shutdown involves sync operations.

bug: 37737296
Test: adb remount,reboot, and check last kmsg
Change-Id: Iab6a6374bc558375d359b3b49b14db93d363b1ad
2017-07-17 17:32:26 -07:00
Tom Cherry 643307dbd0 Merge "ueventd: add tests for setegid()/setfscreatecon() and threads" am: 0ba56096d5 am: 730a5ddf27
am: 92b34b76b5

Change-Id: I07b8b06af95c0c0bf8889dce0f256bb901264bcc
2017-07-17 20:01:06 +00:00
Tom Cherry 92b34b76b5 Merge "ueventd: add tests for setegid()/setfscreatecon() and threads" am: 0ba56096d5
am: 730a5ddf27

Change-Id: I8da0974f3a8a42e2bdfb4f97af9ddc44b7483beb
2017-07-17 19:58:37 +00:00
Tom Cherry 730a5ddf27 Merge "ueventd: add tests for setegid()/setfscreatecon() and threads"
am: 0ba56096d5

Change-Id: Ib1619e4c52402710de09e971a1e96fd7caf0f75a
2017-07-17 19:56:06 +00:00
Tom Cherry c2e181cf1d ueventd: add tests for setegid()/setfscreatecon() and threads
setegid() and setfscreatecon() on Android both operate on a per-thread
basis, not a per-process basis.

Ueventd may take advantage of this in the future, so this CL
introduces tests that ensure that this functionality remains
consistent.

Bug: 63441941
Test: newly added unit tests
Change-Id: I8b1c62cc322b6fe44b748550a4cea8658d9efd88
2017-07-17 11:08:41 -07:00
Tom Cherry c0a9cf648b Merge "Move Timer from init to libbase" am: 896297b2ef am: 7ff0b008f7
am: 4e5c4f18d8

Change-Id: Iffad0dcde94fce7dac627ebf0530420f9cfd38d1
2017-07-10 18:36:54 +00:00
Tom Cherry 4e5c4f18d8 Merge "Move Timer from init to libbase" am: 896297b2ef
am: 7ff0b008f7

Change-Id: I3d1dd6eabbf17d701eefbf7363bfe6107d4de8a4
2017-07-10 18:32:54 +00:00
Tom Cherry 7ff0b008f7 Merge "Move Timer from init to libbase"
am: 896297b2ef

Change-Id: I1990fa013fa1fe69a61711faf032db45216f6f47
2017-07-10 18:28:25 +00:00
Tom Cherry ede0d53850 Move Timer from init to libbase
Test: boot bullhead
Test: new libbase unit tests

Change-Id: Ic398a1daa1fe92c10ea7bc1e6ac3f781cee9a5b5
2017-07-10 09:28:24 -07:00
Jin Qian f361c2560c init: require e2fsdroid and mke2fs when building init
am: 041f849548

Change-Id: Icf49587d20a210cdcf130aacc25ecbcbfd31f06c
2017-07-06 20:55:36 +00:00
Jin Qian 041f849548 init: require e2fsdroid and mke2fs when building init
init calls fs_mgr to format ext4 partitions. This requires
e2fsdroid and mke2fs in /system/bin/

Bug: 35219933
Change-Id: Ia32fe438cd9b9332f8e18e0cbe7f61bd050adcb1
2017-07-06 11:45:06 -07:00
Keun-young Park 3b15f44041 Merge "add "shutdown critical" to service" into oc-dr1-dev 2017-07-06 17:14:23 +00:00
Tom Cherry c680bfeaf2 init: add info logs in first stage mount if we have to poll
It's not a error case if we do not find a device that we're attempting
to regenerate uevents for during first stage mount, but it is likely
to increase boot time, so we log a message to attribute this delay.

Bug: 63327193
Test: Boot bullhead, sailfish

Merged-In: I97c2e5aefd218bbdd87717ff3c375381f725de08
Change-Id: I97c2e5aefd218bbdd87717ff3c375381f725de08
(cherry picked from commit 322e176f6a)
2017-07-06 13:04:23 +08:00
Tom Cherry 71ed340d1e Merge "init: add info logs in first stage mount if we have to poll" am: 6a9d56775f am: 11d5611ba5
am: 7b600f8012

Change-Id: I4abc2b23c0b86059d44965b0139256f7617f48dd
2017-07-06 04:53:38 +00:00
Tom Cherry 7b600f8012 Merge "init: add info logs in first stage mount if we have to poll" am: 6a9d56775f
am: 11d5611ba5

Change-Id: Ib08ea62f6fb13cfaed6bc894bcbc548ccd8c3d55
2017-07-06 04:51:08 +00:00
Tom Cherry 11d5611ba5 Merge "init: add info logs in first stage mount if we have to poll"
am: 6a9d56775f

Change-Id: I7948db4cf1d6af6f4e6d0ddb2a2788f62317126f
2017-07-06 04:48:38 +00:00
Treehugger Robot 6a9d56775f Merge "init: add info logs in first stage mount if we have to poll" 2017-07-06 04:46:05 +00:00
Tom Cherry 7c4b63be8c Merge "ueventd: don't double fork firmware handlers" am: 0f4fb5497a am: e944b7e0a4
am: 1eee2122ca

Change-Id: I726a412b0b01c4f829847b8ebdef97be4df5abef
2017-07-06 02:33:52 +00:00
Tom Cherry 1eee2122ca Merge "ueventd: don't double fork firmware handlers" am: 0f4fb5497a
am: e944b7e0a4

Change-Id: Ifc8c586aa3b06ecb42bf20284c461b4b7c159bc7
2017-07-06 02:21:26 +00:00
Tom Cherry e944b7e0a4 Merge "ueventd: don't double fork firmware handlers"
am: 0f4fb5497a

Change-Id: I2a40b76e937853fd2f1eed61cc0fe4f6fa465ba2
2017-07-06 02:10:57 +00:00
Tom Cherry 0f4fb5497a Merge "ueventd: don't double fork firmware handlers" 2017-07-06 02:02:33 +00:00
Keun-young Park bedc5faea7 Merge "add "shutdown critical" to service" am: b3915d113d am: a4ad5d0328
am: 19ec8e7bcf

Change-Id: Ide84d7f87a9884068ebc1cc9680c997507727af3
2017-07-06 01:13:19 +00:00
Keun-young Park 19ec8e7bcf Merge "add "shutdown critical" to service" am: b3915d113d
am: a4ad5d0328

Change-Id: I6467657616371e84468975e56ac086855a298efb
2017-07-06 00:56:18 +00:00
Keun-young Park d266d37e4c add "shutdown critical" to service
- "shutdown critical" prevents killing the service during
  shutdown. And the service will be started if not running.
- Without it, services will be killed by SIGTERM / SIGKILL during shutdown.
- Even services with "shutdown critical" will be killed if shutdown
  times out.
- Removes ueventd and vold from hard coded list. Each service's rc will
  be updated to add "shutdown critical". watchdogd is still kept in the list.

bug: 37626581
Test: reboot and check last kmsg

(cherry picked from commit cccb34fce8)

Change-Id: I3c6aeb7151e64beca4b435f843ae64455217262d
2017-07-06 00:54:02 +00:00
Keun-young Park a4ad5d0328 Merge "add "shutdown critical" to service"
am: b3915d113d

Change-Id: I25b6f42478efda7077e00141042a427245393d28
2017-07-06 00:46:31 +00:00
Treehugger Robot b3915d113d Merge "add "shutdown critical" to service" 2017-07-06 00:40:55 +00:00
Wei Wang 2a38e6d119 Merge "init: Support custom shutdown actions" am: c1bc4241f8 am: 5b89535442
am: b39890048c

Change-Id: I57a0422f47094cc061163510138e9562648fdd98
2017-07-05 23:58:51 +00:00
Wei Wang b39890048c Merge "init: Support custom shutdown actions" am: c1bc4241f8
am: 5b89535442

Change-Id: I57b87dac016b4d7d6f982ee0057823eb1119bab7
2017-07-05 23:56:50 +00:00
Wei Wang 5b89535442 Merge "init: Support custom shutdown actions"
am: c1bc4241f8

Change-Id: I6bb1789dbc5edbb10f2f4d712e9ca83e6302fdf4
2017-07-05 23:54:56 +00:00
Treehugger Robot c1bc4241f8 Merge "init: Support custom shutdown actions" 2017-07-05 23:49:41 +00:00
Tom Cherry 0f296e06d6 ueventd: don't double fork firmware handlers
ueventd may be asked to handle firmware during the time critical
coldboot process.  If we double fork to avoid needing to reap the
firmware handler, then we may add significant delay to this process,
as the first child may not get scheduled quickly enough for waitpid()
to complete without delay.

Bug: 63081260
Test: boot bullhead and sailfish, check that firmwares are loaded,
      no zombie ueventd processes remain, and no new errors are shown
Change-Id: I2bac3b1fbc3a58557a00326e491c104656db27ae
2017-07-05 16:41:11 -07:00
Tom Cherry 07999f8677 Merge "ueventd: remove character device symlinks (/dev/usb/*)" am: f3ae82f57f am: 6e0b51825b
am: bef2bbdf62

Change-Id: Ice5ec0702cbdae53d7a78bceb7a24e923a488319
2017-07-05 23:37:46 +00:00
Tom Cherry fc479afbb6 Merge "init: reap zombies only after kill(-pid, ...)" am: a51c40ce35 am: 0924b32c1f
am: 419a9ef8f1

Change-Id: I0f2e6b2b2dfed4dab480acf2562df78da8d2f65e
2017-07-05 23:37:21 +00:00
Tom Cherry bef2bbdf62 Merge "ueventd: remove character device symlinks (/dev/usb/*)" am: f3ae82f57f
am: 6e0b51825b

Change-Id: Ic31e720cd9014de76f0fd999af44ce3c3ffcd482
2017-07-05 23:01:53 +00:00
Tom Cherry 419a9ef8f1 Merge "init: reap zombies only after kill(-pid, ...)" am: a51c40ce35
am: 0924b32c1f

Change-Id: I18a3c9a9a96a2488c7714113175f3e8115bd697f
2017-07-05 23:01:35 +00:00
Tom Cherry 6e0b51825b Merge "ueventd: remove character device symlinks (/dev/usb/*)"
am: f3ae82f57f

Change-Id: Ib601af84ed3b186705caaed05706d6b1f3c5746c
2017-07-05 22:50:35 +00:00
Tom Cherry 0924b32c1f Merge "init: reap zombies only after kill(-pid, ...)"
am: a51c40ce35

Change-Id: I4f1b7a05cdff1fe7851b528d0bdeda354011b599
2017-07-05 22:50:17 +00:00
Tom Cherry f3ae82f57f Merge "ueventd: remove character device symlinks (/dev/usb/*)" 2017-07-05 22:41:55 +00:00
Jin Qian 3ca00a3c98 Merge "init: rename mke2fs tools with _static suffix" into oc-dr1-dev
am: 5c5c544e80

Change-Id: Ifee5b6516fe3aee03df845a46421753295cbc740
2017-07-05 22:40:42 +00:00
Tom Cherry a51c40ce35 Merge "init: reap zombies only after kill(-pid, ...)" 2017-07-05 22:39:51 +00:00
TreeHugger Robot 5c5c544e80 Merge "init: rename mke2fs tools with _static suffix" into oc-dr1-dev 2017-07-05 22:33:35 +00:00
Keun-young Park cccb34fce8 add "shutdown critical" to service
- "shutdown critical" prevents killing the service during
  shutdown. And the service will be started if not running.
- Without it, services will be killed by SIGTERM / SIGKILL during shutdown.
- Even services with "shutdown critical" will be killed if shutdown
  times out.
- Removes ueventd and vold from hard coded list. Each service's rc will
  be updated to add "shutdown critical". watchdogd is still kept in the list.

bug: 37626581
Test: reboot and check last kmsg

Change-Id: Ie8cc699d1efbc59b9a2561bdd40fec64aed5a4bb
2017-07-05 14:55:22 -07:00
Wei Wang eeab491efd init: Support custom shutdown actions
We have been seeing panics and errors during shutdown sequence in
some vendor's platform, and it is required to disable error handling
during shutdown.

This CL separates the shutdown request to execute another "shutdown"
trigger at the beginning of shutdown stage. And vendor can use this
trigger to add custom commands needed for shutting down gracefully.

Bug: 38203024
Bug: 62084631
Test: device reboot/shutdown
Change-Id: I3fac4ed59f06667d86e477ee55ed391cf113717f
2017-07-05 14:49:57 -07:00
Tom Cherry 322e176f6a init: add info logs in first stage mount if we have to poll
It's not a error case if we do not find a device that we're attempting
to regenerate uevents for during first stage mount, but it is likely
to increase boot time, so we log a message to attribute this delay.

Bug: 63327193
Test: Boot bullhead, sailfish

Change-Id: I97c2e5aefd218bbdd87717ff3c375381f725de08
2017-07-05 14:05:03 -07:00
Nick Kralevich 4192d74a83 Merge "Remove unnecessary SELinux dependencies" am: 22de50d351 am: e9b9b10c58
am: 0056e6bccc

Change-Id: Id160e23a6bd53238ad279bb5b28e7ca8a08c0805
2017-07-01 16:49:35 +00:00
Nick Kralevich 0056e6bccc Merge "Remove unnecessary SELinux dependencies" am: 22de50d351
am: e9b9b10c58

Change-Id: Ifead418ceb9fe806d76102d9068a32539a8b99d0
2017-07-01 16:44:36 +00:00
Nick Kralevich e9b9b10c58 Merge "Remove unnecessary SELinux dependencies"
am: 22de50d351

Change-Id: Icbd6b0df4378980eb2a7878bab1896f6ecefb6a8
2017-07-01 16:39:37 +00:00
Nick Kralevich 33391dad15 Remove unnecessary SELinux dependencies
These are unused.

Test: code compiles.
Change-Id: Idd707dfcc8f6daac3a489c791ecc364841cf31f9
2017-07-01 07:41:48 -07:00
Luis Hector Chavez dd79958ecb Merge "init: Read previous state of securebits before modifying" am: c10e14110a am: 19f32317b3
am: 9dabbbaa6a

Change-Id: Id5cdc260c7f6800e493c0f3b4e0da08ddca34b63
2017-07-01 00:39:42 +00:00
Luis Hector Chavez 9dabbbaa6a Merge "init: Read previous state of securebits before modifying" am: c10e14110a
am: 19f32317b3

Change-Id: I87084032373a71b507ed0604c7ff38ec076fc74a
2017-07-01 00:35:11 +00:00
Luis Hector Chavez 19f32317b3 Merge "init: Read previous state of securebits before modifying"
am: c10e14110a

Change-Id: I0a9b2dc97ebbc449288de2ce3e2745a1f60a4372
2017-07-01 00:30:42 +00:00
Luis Hector Chavez f5965519d1 init: Read previous state of securebits before modifying
When Android is running in a container, some of the securebits might be
locked, which makes prctl(PR_SET_SECUREBITS) fail.

This change gets the previous state of the process' securebits and adds
the desired bits.

Bug: 62388055
Test: aosp_bullhead-eng boots
Test: If init has non-zero securebits, it can also boot
Change-Id: Ie03bf2538f9dca40955bc58314d269246f5731bd
2017-06-30 14:42:46 -07:00
Tom Cherry 8d13d808a5 init: reap zombies only after kill(-pid, ...)
When init gets SIGCHLD, it uses waitpid() to get the pid of an exited
process.  It then calls kill(-pid, ...) to ensure that all processes
in the process group started by that process are killed as well.

There is a bug here however as waitpid() reaps the pid when it
returns, meaning that the call to kill(-pid, ...) may fail with ESRCH
as there are no remaining references to that pid.  Or worse, if the
pid is reused, the wrong processes may get the signal.

This fixes the bug by using waitid() with WNOWAIT to get the pid of an
exited process, which does not reap the pid.  It then uses waitpid()
with the returned pid to do the reap only after the above kill(-pid,
...) and other operations have completed.

Bug: 38164998
Test: kill surfaceflinger and see that processes exit and are reaped
      appropriately
Test: `adb reboot` and observe that the extraneous kill() failed
      messages do not appear

Change-Id: Ic0213e1c97e0141e6c13129dc2abbfed86de138b
2017-06-30 13:52:48 -07:00
Luis Hector Chavez 1b42dbf22c Merge changes I0a95f87a,I36b22986 am: a703202093 am: 835d259e7a
am: 40e88b22f2

Change-Id: I04e3d91d34d2c50d15ab2357db175b1f69796af1
2017-06-30 04:33:30 +00:00
Luis Hector Chavez 40e88b22f2 Merge changes I0a95f87a,I36b22986 am: a703202093
am: 835d259e7a

Change-Id: I329bddc9b470da86d07bde3ce3ab8a69c37a38e2
2017-06-30 04:29:28 +00:00
Luis Hector Chavez 835d259e7a Merge changes I0a95f87a,I36b22986
am: a703202093

Change-Id: Id0ab2a68ade41db6c1327d9b96489bf0f9a223cb
2017-06-30 04:24:32 +00:00
Luis Hector Chavez 7bb360230d init: Use ScopedCaps for cap_init()
This change homogenizes the use of std::unique_ptr for storing
capabilities in system/core/.

Bug: None
Test: m
Change-Id: I0a95f87a27b0261e9d321841d5140fc000473293
2017-06-29 14:41:23 -07:00
Luis Hector Chavez 519e5f0592 init: Reland "Terminate gracefully when CAP_SYS_BOOT is absent"
This change makes it possible for Android running in a container to
terminate cleanly instead of calling abort() when requested to shut
down.

Bug: 62388055
Test: `adb reboot` on bullhead causes no kernel panics
Test: `adb reboot` on a system without CAP_SYS_BOOT makes init terminate
       nicely

Change-Id: I36b2298610f5b4a2bf8b05103d04804883df2c88
2017-06-29 14:41:23 -07:00
Hung-ying Tyan 42388236a4 Merge "Load default prop from /system/etc/prop.default" into oc-dr1-dev
am: d334d69b70

Change-Id: I358c9b60bf20d7852d81006bb37a9efab0dd19ad
2017-06-28 06:31:08 +00:00
TreeHugger Robot d334d69b70 Merge "Load default prop from /system/etc/prop.default" into oc-dr1-dev 2017-06-28 06:28:09 +00:00
Guang Zhu 387f28c18a Merge "Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent"" am: b5b4136ac4 am: aa447d7aa5
am: 3734cd3442

Change-Id: I5dc1e8c2ad06b162e3971aa2385dc7c00d5a37d0
2017-06-28 02:29:19 +00:00
Guang Zhu aa447d7aa5 Merge "Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent""
am: b5b4136ac4

Change-Id: Icd0a76aeb770cec04c029d30114bb3cf645a850c
2017-06-28 02:22:49 +00:00
Guang Zhu c22f93856f Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent"
Bug: 63080844

This reverts commit 683ebc8059.

Change-Id: I6074ff09300fd30bfc66881ded1c4f868a845a91
2017-06-28 02:10:33 +00:00
Luis Hector Chavez e955adacb7 Merge "init: Terminate gracefully when CAP_SYS_BOOT is absent" am: fbb482f499 am: ec8a5f2aa6
am: 6d815a554d

Change-Id: I1ca1bb153b3e3725f695107d56cc36a54a0379f1
2017-06-27 23:07:18 +00:00
Luis Hector Chavez ec8a5f2aa6 Merge "init: Terminate gracefully when CAP_SYS_BOOT is absent"
am: fbb482f499

Change-Id: I7cff66250e7f5d0b9d55feb2ddb6d74608aa4dd9
2017-06-27 23:01:19 +00:00
Luis Hector Chavez 683ebc8059 init: Terminate gracefully when CAP_SYS_BOOT is absent
This change makes it possible for Android running in a container to
terminate cleanly instead of calling abort() when requested to shut
down.

Bug: 62388055
Test: setprop sys.powerctl reboot makes init terminate nicely

Change-Id: I31c7b475d89d7cbd665e135d9b8951dfd4bca80d
2017-06-27 13:51:46 -07:00
Jin Qian 5eb6e5bd73 init: rename mke2fs tools with _static suffix
We build a static version for recovery mode. Give them
different names to avoid conflicts with regular version
in /system/bin/

Bug: 35219933
Change-Id: I738655ad9b9ad71c63ae604d9a4d659b0b671121
Merged-In: I738655ad9b9ad71c63ae604d9a4d659b0b671121
2017-06-26 17:15:15 -07:00
Tom Cherry b4dd881ffd ueventd: remove character device symlinks (/dev/usb/*)
While refactoring ueventd, I was looking for code the character device
symlinks (/dev/usb/*) that ueventd creates, such that I could test it
on a real device.  I found none in our tree, and history showing Xoom,
which was last supported years ago, was the last user.  If this code
is in fact obsolete, let's remove it.

Test: boot bullhead
Test: init unit tests

Change-Id: I601f7165eb06d36b31b6dcf69ee9e0a449d81a96
2017-06-26 13:58:57 -07:00
Hung-ying Tyan aef2b092f5 Load default prop from /system/etc/prop.default
/default.prop is moved to /system/etc/prop.default for full Treblized
devices. Modifies property_service to load it from there first.
In recovery mode, the file is renamed as /prop.default. This path is
tried if /system/etc/prop.default is not available.

Bug: 37815285
Test: Tested with ag/2419001. Booted pixel phones, checked the location
      of prop.default, verified the symlink at /default.prop, checked a
      few properties via adb shell and manually tested a few apps.
      Booted to recovery and ran 'adb sideload' successfully.
Change-Id: I485231f21fc86b0aec58edf867e229a31e77d85e
Merged-In: I485231f21fc86b0aec58edf867e229a31e77d85e
(cherry-picked from 527d80d945)
2017-06-26 01:33:59 +00:00
Bowgo Tsai 1773266f95 AVB: allow no metadata in the generic system.img for project Treble
The generic system.img released from project Treble can't contain any verity
metadata (e.g., vboot 1.0, AVB, or any other implementation) because it's
*generic*. To make any device can boot with it, `avbctl disable-verification`
is introduced to set a new flag AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED
in the top-level vbmeta to disable the entire AVB verification process. This
should be done prior to flash the generic system.img. See the following link
for details:

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

This CL checks whether AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED is
set in the top-level vbmeta. When set, skip verifying the vbmeta structs
against androidboot.vbmeta.{hash_alg, size, digest} because it will be
absent in kernel cmdline. Also, only top-level vbmeta struct is read then
returned by libavb in this case.

Note that another flag AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED, usually
set by `adb disable-verity`, is used to signal fs_mgr to skip setting up
dm-verity, but libavb still verifies all vbmeta structs. fs_mgr will
also verify all vbmeta structs against androidboot.vbmeta.{hash_alg,
size, digest} from kernel cmdline as well.

Also rename SetUpAvb() to SetUpAvbHashtree() to better fit its usage.
This function will return kDisabled when any of the above two flags is set.

Finally, regardless of which flag is set or not set, we still only allow two
return values from avb_slot_verify():

   - AVB_SLOT_VERIFY_RESULT_OK: it's still possible to get this value
     when any of these flags are set in build time. e.g.,
     BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2

   - AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION: in most cases we should
     get this value, because the flags are likely set at run time.

Bug: 62523303
Test: boot device with 'avbctl disable-verification'.
Test: boot device with 'avbctl enable-verification'.
Test: boot device with 'adb disable-verity'.
Test: boot device with 'adb enable-verity'.

Test: build image with BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2, then boot device.
      repeat the above steps to boot device again.

Merged-In: Ie8436f3e0e82c78490208f3b85eac5238a9fdfdb
Change-Id: Ie8436f3e0e82c78490208f3b85eac5238a9fdfdb
(cherry picked from commit 60f19a0792)
2017-06-24 10:01:32 +08:00
Bowgo Tsai 61cdb66230 Merge "AVB: allow no metadata in the generic system.img for project Treble" am: c70bf5836c am: caa5b4417f
am: 2410d0c792

Change-Id: I5b03a7ac1cdb883df27aca8122c4a1383d805126
2017-06-24 01:51:47 +00:00
Bowgo Tsai 2410d0c792 Merge "AVB: allow no metadata in the generic system.img for project Treble" am: c70bf5836c
am: caa5b4417f

Change-Id: I4859e15d3bf05c22a708761e91b2e52fbb28ca1f
2017-06-24 01:40:33 +00:00
Treehugger Robot c70bf5836c Merge "AVB: allow no metadata in the generic system.img for project Treble" 2017-06-24 01:28:25 +00:00
Bowgo Tsai 60f19a0792 AVB: allow no metadata in the generic system.img for project Treble
The generic system.img released from project Treble can't contain any verity
metadata (e.g., vboot 1.0, AVB, or any other implementation) because it's
*generic*. To make any device can boot with it, `avbctl disable-verification`
is introduced to set a new flag AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED
in the top-level vbmeta to disable the entire AVB verification process. This
should be done prior to flash the generic system.img. See the following link
for details:

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

This CL checks whether AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED is
set in the top-level vbmeta. When set, skip verifying the vbmeta structs
against androidboot.vbmeta.{hash_alg, size, digest} because it will be
absent in kernel cmdline. Also, only top-level vbmeta struct is read then
returned by libavb in this case.

Note that another flag AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED, usually
set by `adb disable-verity`, is used to signal fs_mgr to skip setting up
dm-verity, but libavb still verifies all vbmeta structs. fs_mgr will
also verify all vbmeta structs against androidboot.vbmeta.{hash_alg,
size, digest} from kernel cmdline as well.

Also rename SetUpAvb() to SetUpAvbHashtree() to better fit its usage.
This function will return kDisabled when any of the above two flags is set.

Finally, regardless of which flag is set or not set, we still only allow two
return values from avb_slot_verify():

   - AVB_SLOT_VERIFY_RESULT_OK: it's still possible to get this value
     when any of these flags are set in build time. e.g.,
     BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2

   - AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION: in most cases we should
     get this value, because the flags are likely set at run time.

Bug: 62523303
Test: boot device with 'avbctl disable-verification'.
Test: boot device with 'avbctl enable-verification'.
Test: boot device with 'adb disable-verity'.
Test: boot device with 'adb enable-verity'.

Test: build image with BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2, then boot device.
      repeat the above steps to boot device again.

Change-Id: Ie8436f3e0e82c78490208f3b85eac5238a9fdfdb
2017-06-24 09:20:15 +08:00
Tom Cherry 99d93f4462 Merge "init: create android::init:: namespace" am: 040212706b am: d3d79b2196
am: b57e1180e3

Change-Id: Ic6d35273820d70136a6085bf49dcf3afcbb24f24
2017-06-23 23:24:21 +00:00
Tom Cherry b57e1180e3 Merge "init: create android::init:: namespace" am: 040212706b
am: d3d79b2196

Change-Id: I3dccff251dda7d7452e33a7e71178c59f0c22169
2017-06-23 23:19:53 +00:00
Jeff Vander Stoep d47d328b41 Merge "Revert "crash_dump: during early boot, output to kmsg on userdebug."" into oc-dr1-dev
am: 75a32dead5

Change-Id: Ia893832c1428858afd8d8726a789a5989dafa9a0
2017-06-23 23:01:27 +00:00
TreeHugger Robot 75a32dead5 Merge "Revert "crash_dump: during early boot, output to kmsg on userdebug."" into oc-dr1-dev 2017-06-23 22:45:48 +00:00
Jeff Vander Stoep 5fdc4cc746 Revert "crash_dump: during early boot, output to kmsg on userdebug."
This reverts commit bf2dd48241.

Addresses:
avc: denied { relabelto } for name="kmsg_debug" dev="tmpfs" ino=10642
scontext=u:r:init:s0 tcontext=u:object_r:device:s0 tclass=chr_file

Bug: 62101480, 35197529
Test: build and boot device. Verify selinux denial no longer occurs.
Change-Id: I28ce16f50eec20ef15c1721f41b66f22a84e7cca
2017-06-23 13:37:54 -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 1a23b2aef5 Merge "init: cleanup some string usage" am: 84c2eebbdd am: 77382acf42
am: 288fb7c2cc

Change-Id: I61e6ee578e55ebe343112c8114816ac4e18b9c7e
2017-06-23 20:01:41 +00:00
Tom Cherry 288fb7c2cc Merge "init: cleanup some string usage" am: 84c2eebbdd
am: 77382acf42

Change-Id: I068291aeb16249a1b82e047dc894c283114a2bef
2017-06-23 19:55:39 +00:00
Tom Cherry 1c3a53f03c init: cleanup some string usage
1) property_set() takes const std::string& for both of its arguments,
   so stop using .c_str() with its parameters
2) Simplify a few places where StringPrintf() is used to concatenate strings
3) Use std::to_string() instead of StringPrintf() where it's better suited

Test: Boot bullhead
Test: init unit tests
Change-Id: I68ebda0e469f6230c8f9ad3c8d5f9444e0c4fdfd
2017-06-22 17:24:22 -07:00
Sandeep Patil 2980f49447 Merge changes from topic 'eng_first_stage_mount' am: b7e2f272ee am: e5341cf56a
am: 91b5f4b172

Change-Id: Iea367c4aa1a9fe381c4b5b4b23f6365035b4939d
2017-06-22 00:15:48 +00:00
Sandeep Patil 91b5f4b172 Merge changes from topic 'eng_first_stage_mount' am: b7e2f272ee
am: e5341cf56a

Change-Id: I285217db1c18adfcc10d31280c1ec55d80052e43
2017-06-22 00:08:17 +00:00
Sandeep Patil 1266930e8a Revert "Revert "init: poll in first stage mount if required devices are not found""
This reverts commit d6fccea093.

Bug: 62681642
Bug: 62682821
Bug: 62864413

Merged-In: Ic9c27552acbd2ae312e44ea2cdf060dcf493bfe6
Change-Id: Ic9c27552acbd2ae312e44ea2cdf060dcf493bfe6
Signed-off-by: Sandeep Patil <sspatil@google.com>
(cherry picked from commit 4cbedee541)
2017-06-21 17:02:12 -07:00
Sandeep Patil 5d0299906e Revert "Revert "ueventd: remove PlatformDeviceList""
This reverts commit 516ff99711.

Bug: 62864413
Bug: 62864413

Merged-In: Ie3980cd536c2c83adace063f0950128f68561105
Change-Id: Ie3980cd536c2c83adace063f0950128f68561105
Signed-off-by: Sandeep Patil <sspatil@google.com>
(cherry picked from commit cd2ba0d184)
2017-06-21 17:02:03 -07:00
Sandeep Patil fa59bba6af fs_mgr: differentiate if fs_mgr_set_verity() was skipped or disabled
In case of non-secure builds (eng variant) fs_mgr_setup_verity() skips
verity checks regardless of fstab options. This is slightly different
than 'adb disable-verity' where it would first read the verity metadata
to check if verity is disabled.

So, this change adds a new return value of FS_MGR_SETUP_VERITY_SKIPPED
instead of piggy backing on the FS_MGR_SETUP_VERITY_DISABLED.

Bug: 62864413
Test: Boot sailfish

Merged-In: I42bf2bdce0ecb18b4c3b568e2bc96bf1590dfb35
Change-Id: I42bf2bdce0ecb18b4c3b568e2bc96bf1590dfb35
Signed-off-by: Sandeep Patil <sspatil@google.com>
(cherry picked from commit 95366e97dd)
2017-06-21 17:01:48 -07:00
Sandeep Patil 4cbedee541 Revert "Revert "init: poll in first stage mount if required devices are not found""
This reverts commit d6fccea093.

Bug: 62681642
Bug: 62682821
Bug: 62864413

Change-Id: Ic9c27552acbd2ae312e44ea2cdf060dcf493bfe6
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-06-21 15:04:57 -07:00
Sandeep Patil cd2ba0d184 Revert "Revert "ueventd: remove PlatformDeviceList""
This reverts commit 516ff99711.

Bug: 62864413
Bug: 62864413

Change-Id: Ie3980cd536c2c83adace063f0950128f68561105
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-06-21 15:04:57 -07:00
Sandeep Patil 95366e97dd fs_mgr: differentiate if fs_mgr_set_verity() was skipped or disabled
In case of non-secure builds (eng variant) fs_mgr_setup_verity() skips
verity checks regardless of fstab options. This is slightly different
than 'adb disable-verity' where it would first read the verity metadata
to check if verity is disabled.

So, this change adds a new return value of FS_MGR_SETUP_VERITY_SKIPPED
instead of piggy backing on the FS_MGR_SETUP_VERITY_DISABLED.

Bug: 62864413
Test: Boot sailfish

Change-Id: I42bf2bdce0ecb18b4c3b568e2bc96bf1590dfb35
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-06-21 15:04:46 -07:00
Tom Cherry e6699f4507 Merge "Revert "ueventd: remove PlatformDeviceList"" am: 9c5f614945
am: b0350407f0

Change-Id: I6aa99f64455604b8919284c77a9faa5d8caa332e
2017-06-21 19:00:15 +00:00
Tom Cherry 4ee2b6feee Merge "Revert "init: poll in first stage mount if required devices are not found"" am: c9a27f79ad
am: 57579dd8c9

Change-Id: I48874fd559731a9ecdf973440cfca1021790b84f
2017-06-21 18:59:53 +00:00
Tom Cherry 516ff99711 Revert "ueventd: remove PlatformDeviceList"
Bug: 62864413

This reverts commit c94ce7b130.

Change-Id: I014360251e5cda89c87adfec46d8b1e5000f3a9c
2017-06-21 18:42:07 +00:00
Tom Cherry d6fccea093 Revert "init: poll in first stage mount if required devices are not found"
Bug: 62864413

This reverts commit ccf0d39316.

Change-Id: I343e304db4c0e7af2402397ef468cc743a3f08a9
2017-06-21 18:40:58 +00:00
Tom Cherry e3d4e91ac6 Merge "Revert "ueventd: remove PlatformDeviceList"" into oc-dr1-dev
am: eb9edefdc8

Change-Id: I6e09235736cab3878abfb71d7583c9662639070d
2017-06-21 18:27:39 +00:00
Tom Cherry 756ea2a3e0 Merge "Revert "init: poll in first stage mount if required devices are not found"" into oc-dr1-dev
am: b829811587

Change-Id: I7a17326debd21624bd6810d0e723a0ab7dc88277
2017-06-21 18:27:14 +00:00
Tom Cherry 3fa8396f3b Revert "ueventd: remove PlatformDeviceList"
Bug: 62864413

This reverts commit f51657ccef.

Change-Id: I1397ca2de716395782139688542c69848a31d62f
2017-06-21 18:11:03 +00:00
Tom Cherry 5bd4704db2 Revert "init: poll in first stage mount if required devices are not found"
Bug: 62864413

This reverts commit bea663d04c.

Change-Id: Ief069cae9de4393a59d1a499bc4861efb65e8250
2017-06-21 18:10:58 +00:00
Tom Cherry 82701687ec Merge "init: poll in first stage mount if required devices are not found" am: 20e9312344 am: 492a595091
am: e34a158b1a

Change-Id: I65fb2040429a94731a533dfae88c0aeb449839f7
2017-06-20 21:41:35 +00:00
Tom Cherry ff19eaaf2e Merge "ueventd: remove PlatformDeviceList" am: 137ee511bd am: 1632742602
am: d989cf8f57

Change-Id: I47c38be8cb96e7231b017ef67cc999bfff27e120
2017-06-20 21:41:11 +00:00
Tom Cherry e34a158b1a Merge "init: poll in first stage mount if required devices are not found" am: 20e9312344
am: 492a595091

Change-Id: I9123faa9377e8bb058d146e744106ea6e0522951
2017-06-20 21:36:31 +00:00
Tom Cherry d989cf8f57 Merge "ueventd: remove PlatformDeviceList" am: 137ee511bd
am: 1632742602

Change-Id: I0e3ba605b26c525364371c984c6b3ebecb5f7f82
2017-06-20 21:36:04 +00:00
Tom Cherry bea663d04c init: poll in first stage mount if required devices are not found
First stage mount in init currently attempts to regenerate uevents for
specific devices to create the corresponding dev nodes.  However, this
is racy as first stage mount happens early in the boot process and
it's possible that some of these devices have not yet been created by
the kernel.

To fix this issue, init will poll on the uevent socket for up to 10
seconds waiting for the kernel to create the required device.  It will
return false and panic if this 10 second timeout passes.

Note that the same uevent socket is used in the uevent regeneration
and the polling code, so there is no race if the device is created
after the uevent regeneration and before polling starts; the first
poll will pick up the device.

Bug: 62681642
Bug: 62682821
Test: Boot bullhead
Test: Boot sailfish
Test: Boot hikey + hotplug/unplug sdcard
Merged-In: I4a6ff043eb7115b729ca4954ebc6c9e000132993
Change-Id: I4a6ff043eb7115b729ca4954ebc6c9e000132993
(cherry picked from commit c4ff5e803917f04574fe98f846875db77d0fd8f5)
2017-06-20 14:26:44 -07:00
Tom Cherry f51657ccef ueventd: remove PlatformDeviceList
In order to create symlinks for USB and block devices, the path for
their parent platform device must be known.

Previously, ueventd would save each platform device that it encounters
to a list and query this list when creating the symlinks.  That,
however, is racy because the uevent socket does not differentiate
uevents from RegenerateUevents() and uevents sent by the kernel when
probing a device first the first time.  The below scenario is the
faulty  case:

1) Kernel probes parent platform device for a block device
2) ueventd calls RegenerateUevents() and starts processing uevents
3) Kernel probes block device and sends its uevents
4) ueventd picks up the block device uevent during its uevent processing,
   without yet regenerating the platform device uevent, causing improper
   symlinks to be created.

This change stops storing the platform devices in a list, and instead
traverses up the directory structure for each USB or block device
until it reaches a platform device, defined as one whose subsystem is
the platform bus.  This fixes the race and simplifies the ueventd
code.

Bug: 62436493
Bug: 62681642
Test: Boot bullhead
Test: Boot sailfish
Test: Init unit tests
Test: Boot hikey + hotplug/unplug sdcard
Merged-In: I21636355d8e434f30e0cba568598a6cf139e67f9
Change-Id: I21636355d8e434f30e0cba568598a6cf139e67f9
(cherry picked from commit c94ce7b130)
2017-06-20 14:26:15 -07:00
Tom Cherry ccf0d39316 init: poll in first stage mount if required devices are not found
First stage mount in init currently attempts to regenerate uevents for
specific devices to create the corresponding dev nodes.  However, this
is racy as first stage mount happens early in the boot process and
it's possible that some of these devices have not yet been created by
the kernel.

To fix this issue, init will poll on the uevent socket for up to 10
seconds waiting for the kernel to create the required device.  It will
return false and panic if this 10 second timeout passes.

Note that the same uevent socket is used in the uevent regeneration
and the polling code, so there is no race if the device is created
after the uevent regeneration and before polling starts; the first
poll will pick up the device.

Bug: 62681642
Bug: 62682821
Test: Boot bullhead
Test: Boot sailfish
Test: Boot hikey + hotplug/unplug sdcard
Change-Id: I4a6ff043eb7115b729ca4954ebc6c9e000132993
2017-06-20 21:23:42 +00:00
Tom Cherry 137ee511bd Merge "ueventd: remove PlatformDeviceList" 2017-06-20 21:23:17 +00:00
Tom Cherry c94ce7b130 ueventd: remove PlatformDeviceList
In order to create symlinks for USB and block devices, the path for
their parent platform device must be known.

Previously, ueventd would save each platform device that it encounters
to a list and query this list when creating the symlinks.  That,
however, is racy because the uevent socket does not differentiate
uevents from RegenerateUevents() and uevents sent by the kernel when
probing a device first the first time.  The below scenario is the
faulty  case:

1) Kernel probes parent platform device for a block device
2) ueventd calls RegenerateUevents() and starts processing uevents
3) Kernel probes block device and sends its uevents
4) ueventd picks up the block device uevent during its uevent processing,
   without yet regenerating the platform device uevent, causing improper
   symlinks to be created.

This change stops storing the platform devices in a list, and instead
traverses up the directory structure for each USB or block device
until it reaches a platform device, defined as one whose subsystem is
the platform bus.  This fixes the race and simplifies the ueventd
code.

Bug: 62436493
Bug: 62681642
Test: Boot bullhead
Test: Boot sailfish
Test: Init unit tests
Test: Boot hikey + hotplug/unplug sdcard
Change-Id: I21636355d8e434f30e0cba568598a6cf139e67f9
2017-06-20 21:21:14 +00:00
Tom Cherry 2787894768 Merge "Move restorecon() of /sys from init to ueventd." 2017-06-20 01:13:37 +00:00
Tom Cherry d2fd54e0ff Move restorecon() of /sys from init to ueventd.
ueventd already does restorecon() for /sys/{block,class,devices}, so
instead of duplicating this effort with init, move the restorecon()
that init does for all of /sys to ueventd.

Bug: 62420036
Change-Id: I6125f8ff5316a0cf45872d1100d089d71802958f
Merged-In: I6125f8ff5316a0cf45872d1100d089d71802958f
Test: Boot sailfish, bullhead
2017-06-20 00:02:05 +00:00
Tom Cherry a2e2281896 Merge "Move restorecon() of /sys from init to ueventd." into oc-dev-plus-aosp
am: a3598113ad

Change-Id: I3ec4d5957fddcf04e4a82bc00fc418b2327354e5
2017-06-19 19:44:20 +00:00
TreeHugger Robot a3598113ad Merge "Move restorecon() of /sys from init to ueventd." into oc-dev-plus-aosp 2017-06-19 19:36:56 +00:00
Tom Marshall 2d9293954c Merge "init: Run restorecon_recursive asynchronously" am: ad4aa9e169 am: 0329b8d03e
am: ebd6a64694

Change-Id: Id6ff385d4421af87834abe431c11bddd98583fe1
2017-06-19 18:11:43 +00:00
Tom Marshall ebd6a64694 Merge "init: Run restorecon_recursive asynchronously" am: ad4aa9e169
am: 0329b8d03e

Change-Id: I1cd56fc9521451742b04d7f56bc0b657a0672314
2017-06-19 18:06:14 +00:00
Tom Cherry c3e955123c Move restorecon() of /sys from init to ueventd.
ueventd already does restorecon() for /sys/{block,class,devices}, so
instead of duplicating this effort with init, move the restorecon()
that init does for all of /sys to ueventd.

Bug: 62420036
Change-Id: I6125f8ff5316a0cf45872d1100d089d71802958f
Test: Boot sailfish, bullhead
2017-06-19 10:59:06 -07:00
Tom Marshall 62696908ff init: Run restorecon_recursive asynchronously
restorecon_recursive may take a long time if there are a lot of files on
the volume.  This can trigger a watchdog timeout in any process that
tries to set a property while it is running.  Fix this by running
restorecon_recursive in its own process.

See https://jira.lineageos.org/browse/BUGBASH-555

Change-Id: I2ce26ff2b5bfc9a133ea42f4dbac50a3ac289c04
2017-06-16 18:00:08 -07:00
Hung-ying Tyan 527d80d945 Load default prop from /system/etc/prop.default
/default.prop is moved to /system/etc/prop.default for full Treblized
devices. Modifies property_service to load it from there first.
In recovery mode, the file is renamed as /prop.default. This path is
tried if /system/etc/prop.default is not available.

Bug: 37815285
Test: Tested with ag/2419001. Booted pixel phones, checked the location
      of prop.default, verified the symlink at /default.prop, checked a
      few properties via adb shell and manually tested a few apps.
      Booted to recovery and ran 'adb sideload' successfully.
Change-Id: I485231f21fc86b0aec58edf867e229a31e77d85e
2017-06-16 22:46:15 +08:00
Chih-Hung Hsieh f13c54c5ed Merge "Revert workaround of clang-tidy segmentation fault." am: 243ab9cc7e am: b547153143
am: 952005b1df

Change-Id: I1f168da658d44af26f121384f76a3d3246804560
2017-06-15 19:10:56 +00:00
Chih-Hung Hsieh 952005b1df Merge "Revert workaround of clang-tidy segmentation fault." am: 243ab9cc7e
am: b547153143

Change-Id: I59dea6f8aa2a6558594280efe07314070643642a
2017-06-15 19:08:30 +00:00
Treehugger Robot 243ab9cc7e Merge "Revert workaround of clang-tidy segmentation fault." 2017-06-15 18:57:51 +00:00
Tom Cherry 98dd8978aa Merge "init: move killing of process groups to libprocessgroup" am: fbbb3bd49a am: 8040f8eb82
am: 9f91d2692c

Change-Id: Ide2da0ed71dfa132425cddaf654b45b712da97f3
2017-06-15 17:30:19 +00:00
Tom Cherry 9f91d2692c Merge "init: move killing of process groups to libprocessgroup" am: fbbb3bd49a
am: 8040f8eb82

Change-Id: Ie63521a9114ca407c3c40aae3099cf3e94fdfac6
2017-06-15 17:27:55 +00:00
Tom Cherry 6f45ffc961 init: move killing of process groups to libprocessgroup
libprocessgroup kills the cgroup associated with a given pid and uid,
but not the POSIX process group associated with it.  This means that
to kill both, two of the same signals must be sent, which may cause
some issues.

This change kills all POSIX process groups whose group leaders are
found within a cgroup.  It only then kills processes in the cgroup
that are not part of the POSIX process groups that have been killed.

Bug: 37853905
Bug: 62418791
Test: Boot, kill zygote, reboot
Change-Id: Id1d96935745899b4c454c36c351ec16a0b1d3827
(cherry picked from commit 70a5ed49ef)
2017-06-15 10:21:05 -07:00
Tom Cherry fbbb3bd49a Merge "init: move killing of process groups to libprocessgroup" 2017-06-15 17:17:22 +00:00
Chih-Hung Hsieh 47bd75701b Revert workaround of clang-tidy segmentation fault.
Problem was fixed in new rebased clang-tidy.
Bug: 38002385
Test: build with WITH_TIDY=1
Change-Id: Ic22d016fb2d402c3eee16226be507f5d4cfa2818
2017-06-15 10:05:04 -07:00
Bowgo Tsai 81af8c7362 first stage mount: removing the restriction of mount points
Current first stage mount only allows three mount points: system, vendor
and/or odm. This was introduced by project Treble to mount those
verified partitions early. However, there might be some other custom
partitions needs to be mounted early as well. This CL removes the
restriction and does first stage mount for whatever specified in
fstab-dt.

Bug: 62423887
Test: first stage mount /vendor with vboot 1.0
Test: first stage mount /vendor with vboot 2.0 (AVB)

Change-Id: I6c146c64e673c35c2823523ccbde193590430c48
Merged-In: I6c146c64e673c35c2823523ccbde193590430c48
(cherry picked from commit 06ed613e73)
2017-06-09 12:47:17 +08:00
Bowgo Tsai 539518269d Merge "first stage mount: removing the restriction of mount points" am: 5218d69817 am: 7d491a0a7b
am: 7f6df5ddf9

Change-Id: I173bcf7f3989c38d4bf2b08d5cae627b5f47ffc4
2017-06-09 02:00:38 +00:00
Bowgo Tsai 7f6df5ddf9 Merge "first stage mount: removing the restriction of mount points" am: 5218d69817
am: 7d491a0a7b

Change-Id: Idd5dc13632631de213aa341ddcfca9186c2f8510
2017-06-09 01:58:10 +00:00
Bowgo Tsai 06ed613e73 first stage mount: removing the restriction of mount points
Current first stage mount only allows three mount points: system, vendor
and/or odm. This was introduced by project Treble to mount those
verified partitions early. However, there might be some other custom
partitions needs to be mounted early as well. This CL removes the
restriction and does first stage mount for whatever specified in
fstab-dt.

Bug: 62423887
Test: first stage mount /vendor with vboot 1.0
Test: first stage mount /vendor with vboot 2.0 (AVB)

Change-Id: I6c146c64e673c35c2823523ccbde193590430c48
2017-06-08 11:30:12 +08:00
Tom Cherry 70a5ed49ef init: move killing of process groups to libprocessgroup
libprocessgroup kills the cgroup associated with a given pid and uid,
but not the POSIX process group associated with it.  This means that
to kill both, two of the same signals must be sent, which may cause
some issues.

This change kills all POSIX process groups whose group leaders are
found within a cgroup.  It only then kills processes in the cgroup
that are not part of the POSIX process groups that have been killed.

Bug: 37853905
Bug: 62418791
Test: Boot, kill zygote, reboot
Change-Id: Id1d96935745899b4c454c36c351ec16a0b1d3827
2017-06-07 13:20:21 -07:00
Tom Cherry 2d707e0955 Merge "ueventd: parallelize uevent handling" am: 70431b1f22 am: ed75c00f72 am: 27fc35ace4
am: 573287de3a

Change-Id: I3e5917ff58df1d59ae8ed7bf75bf5fa01eb7f137
2017-06-02 22:06:07 +00:00
Tom Cherry 573287de3a Merge "ueventd: parallelize uevent handling" am: 70431b1f22 am: ed75c00f72
am: 27fc35ace4

Change-Id: Ib243f67c5be0822805c457106f5b8ab7cd013989
2017-06-02 22:02:42 +00:00
Tom Cherry c583305ed7 ueventd: parallelize uevent handling
fork() subprocesses to handle uevents in parallel.

This reduces coldboot time on bullhead from ~446ms to ~230ms.
This reduces coldboot time on sailfish from ~690ms to ~360ms.
This reduces coldboot time on ryu from ~187ms to ~122ms.

Bug: 33785894

Test: boot bullhead x40, observe no major differences in /dev and /sys
Test: boot sailfish x40, observe no major differences in /dev and /sys
Test: boot ryu x40, observe no major differences in /dev and /sys
Test: boottime tests on bullhead and sailfish
Test: init unit tests

Change-Id: Ie2f63e000b8af78d187477d31fe109f20304d749
2017-06-02 21:45:56 +00:00
Tom Cherry f53603bf73 Merge "init: allow ':' in property names" am: af95ecdb04 am: 6d2a27768d am: 3d2aa93e1d
am: 6eac551c34

Change-Id: I5b12c6e69f2ac1e124b48eaca32a6800a37f64d6
2017-05-31 00:08:41 +00:00
Tom Cherry 6eac551c34 Merge "init: allow ':' in property names" am: af95ecdb04 am: 6d2a27768d
am: 3d2aa93e1d

Change-Id: I7082ab0c50b7eda1e32b241c2408460c15b7e936
2017-05-31 00:01:39 +00:00
Tom Cherry 1369379e33 init: allow ':' in property names
Bug: 62114389
Test: boot bullhead, get/set properties with ':' via command line
Test: trigger an init trigger with a property containing a ':'
Change-Id: Ib51853a1ef9d4f79d510c8175c0d9684e2025e23
2017-05-30 13:45:28 -07:00
Tom Cherry 17b0eeb732 Merge "ueventd: Break devices.cpp into discrete classes" am: c495e059b7 am: 18d0144e6c am: cc0e43c8dd
am: c3579f0b06

Change-Id: I13665c1c9a4d66f50fd3c993e2bcd7d8765cdb8e
2017-05-26 00:25:36 +00:00
Tom Cherry c3579f0b06 Merge "ueventd: Break devices.cpp into discrete classes" am: c495e059b7 am: 18d0144e6c
am: cc0e43c8dd

Change-Id: I91dd47dcc55093a79a4b87f992191bcabe19f6bc
2017-05-26 00:22:10 +00:00
Tom Cherry ed506f7356 ueventd: Break devices.cpp into discrete classes
devices.cpp handles too many things for creating one class.  This
change breaks it up into various files and classes.

* Parsing is moved to ueventd_parser.cpp
* Reading from the uevent socket and Cold booting is moved to a
  UeventListener class, in uevent_listener.cpp
* Firmware handling is moved to firmware_handler.cpp
* The remaining contents form a DeviceHandler class within devices.cpp

Bug: 33785894

Test: boot bullhead x40, observe no major differences in /dev and /sys
Test: boot sailfish x40, observe no major differences in /dev and /sys
Test: init unit tests

Change-Id: I846a2e5995fbb344c7a8e349065c18a934fa6aba
2017-05-25 16:17:19 -07:00
Elliott Hughes 99f28f61c2 Merge "Revert "Load {default,build}.prop from /{system,vendor,odm}/etc/"" am: f9259b59e8 am: b2f12e42ca am: 22cdddecba
am: 3e9223f460

Change-Id: Icedc316c4b33a94cc19683213dbdd76e787362bb
2017-05-25 18:21:13 +00:00
Elliott Hughes 3e9223f460 Merge "Revert "Load {default,build}.prop from /{system,vendor,odm}/etc/"" am: f9259b59e8 am: b2f12e42ca
am: 22cdddecba

Change-Id: I6e41d84c76a0d1f31e54d5422638817905f202f4
2017-05-25 18:18:40 +00:00
Hung-ying Tyan 3346338919 Revert "Load {default,build}.prop from /{system,vendor,odm}/etc/"
This reverts commit 723f1a2b31.

Bug: 62075509
2017-05-25 19:18:17 +08:00
Hung-ying Tyan b1211e9368 Merge "Load {default,build}.prop from /{system,vendor,odm}/etc/" am: a9aa77d259 am: 26c4bcfadd am: 0cd0d52147
am: a22e004f57

Change-Id: Ife17941907dd35507b95c56fe587f83003341684
2017-05-25 02:49:11 +00:00
Hung-ying Tyan a22e004f57 Merge "Load {default,build}.prop from /{system,vendor,odm}/etc/" am: a9aa77d259 am: 26c4bcfadd
am: 0cd0d52147

Change-Id: Ide638286886cef323e8bb049f5baf4bbe659c47a
2017-05-25 02:46:10 +00:00
Treehugger Robot a9aa77d259 Merge "Load {default,build}.prop from /{system,vendor,odm}/etc/" 2017-05-25 02:32:37 +00:00
Hung-ying Tyan 723f1a2b31 Load {default,build}.prop from /{system,vendor,odm}/etc/
/default.prop may be moved to /system/etc/ and renamed as prop.default.
/{system,vendor,odm}/build.prop may be moved to /{system,vendor,odm}/etc/
and renamed as prop.build.
This patch makes property_service load prop.* from the new locations
first. Also replaces NULL with nullptr for C++ cleanup.

Bug: 37815285
Test: Booted pixel phones, checked the locations of prop.*, verified
      symlinks, checked a few properties (via adb shell getprop)
      and manually tested a few apps (Camera, Maps etc).
      ODM is not tested as it does not exist on the tested device.
Change-Id: Id8eeb3c1a5728dd04005dfad4733b8e6336f9093
2017-05-25 08:41:08 +08:00
Tom Cherry 7343f9e306 Merge "init: start move to Android.bp" am: 276f765984 am: 062657cf2b am: b37cabbfef
am: ed7c02aadf

Change-Id: I57621ed582c6e82f0ecc07b1da566ce19b9faeda
2017-05-23 02:32:15 +00:00
Tom Cherry ed7c02aadf Merge "init: start move to Android.bp" am: 276f765984 am: 062657cf2b
am: b37cabbfef

Change-Id: Id1960b4bfb537719e52023edc4c3f808d47996ab
2017-05-23 02:29:04 +00:00
Tom Cherry 14fc01301d init: start move to Android.bp
Move libinit, init_tests, and test_service to Android.bp
Leave init in Android.mk as it has unfulfilled dependencies, but
create a comment in Android.bp for future use.
Remove libinit_parser and init_parser_tests as that code was never
used in init.

Bug: 36970783
Bug: 37512442
Test: Build, boot bullhead, init unit tests
Change-Id: Id81cd10ea09453a5fd762ba9189276aad79d5444
2017-05-22 13:30:04 -07:00
Tom Cherry fe6e19cbeb Revert "Add test config to init_tests"
This reverts commit bdfd395e47.

We want to keep AOSP and internal master in sync and since this isn't
being used, instead of cherry-picking to AOSP, we'll revert from internal.

Test: Build
Change-Id: I161b4c7187ec260841605149b7eee7df64434246
2017-05-22 13:27:17 -07:00
Elliott Hughes 7826f29f86 Merge "Merge "init should #include <sys/sysmacros.h>" am: 64e3f88d69 am: 29b41dce6d am: 8cdef644b3" into oc-dev-plus-aosp
am: 22c5e80458

Change-Id: I74601341eca56298c0404e05e098f40ea05b80da
2017-05-18 23:08:35 +00:00
Elliott Hughes f42957f907 Merge "init should #include <sys/sysmacros.h>" am: 64e3f88d69 am: 29b41dce6d
am: 8cdef644b3

Change-Id: I57cbaa68240c2c0127a246f7536e0dc8d9cd4f80
2017-05-18 23:03:32 +00:00
Treehugger Robot 64e3f88d69 Merge "init should #include <sys/sysmacros.h>" 2017-05-18 22:47:59 +00:00
Keun-young Park 84f262b3f3 Merge "add ueventd to shutdown critial process" am: 7fe28d9d9a am: aa3c4e9def am: 939f0b03e8
am: 39f7c6b296

Change-Id: I23eff785c507587c47a557b27b2d9b2129c66462
2017-05-18 21:19:22 +00:00
Keun-young Park 39f7c6b296 Merge "add ueventd to shutdown critial process" am: 7fe28d9d9a am: aa3c4e9def
am: 939f0b03e8

Change-Id: I77544ec21c3db09edc515af79f329bc6d44116e9
2017-05-18 21:14:51 +00:00
Keun-young Park 7264bee975 add ueventd to shutdown critial process
- In some devices, some drivers still try to load firmware while shutting
  down, and crashes the kernel. So keep ueventd to prevent such case.

bug: 38203024
Test: reboots
Change-Id: I4f1910723254ccb69f8e9c78e8727fbd8c7eed3e
2017-05-18 20:58:10 +00:00
Elliott Hughes 51056c49d2 init should #include <sys/sysmacros.h>
Bug: https://github.com/android-ndk/ndk/issues/398
Test: builds
Change-Id: I6428a6344a3ce649bd03ff9e9b0f156425c67f0c
2017-05-18 09:13:15 -07:00
Elliott Hughes 62ee93d7a8 Merge "Add libkeyutils." am: 81824ebf1f am: dce08d5572
am: 971e77c5c0

Change-Id: Ibe5aa5bfca03727c3c1d1dbee8941c451d76885f
2017-05-13 00:44:29 +00:00
Elliott Hughes 81824ebf1f Merge "Add libkeyutils." 2017-05-13 00:28:28 +00:00
Elliott Hughes 8fc5f81efe Merge "Add libkeyutils." 2017-05-11 17:38:17 +00:00
Chih-Hung Hsieh 64dbdb53d4 Merge "Work around clang-tidy segmentation fault." am: d761dd747e am: 4a926efc49 am: 3f9923cf7f
am: 0d1879dd8c

Change-Id: I97b1f3f49cafe5e4beeb10ddb76fc47b7cc54850
2017-05-11 01:07:17 +00:00
Chih-Hung Hsieh 0d1879dd8c Merge "Work around clang-tidy segmentation fault." am: d761dd747e am: 4a926efc49
am: 3f9923cf7f

Change-Id: I5207bb2b06902b248137edeef6be3ac167ee62de
2017-05-11 00:23:21 +00:00
Treehugger Robot d761dd747e Merge "Work around clang-tidy segmentation fault." 2017-05-10 23:11:19 +00:00
Elliott Hughes 1eeee96676 Add libkeyutils.
Also move init over to it.

Bug: http://b/37991155
Test: builds+boots
Change-Id: I5113a9d96a5ce0a0f3bad71134d6cc4f7b41a57e
2017-05-10 14:53:28 -07:00
Elliott Hughes f8627cea7f Add libkeyutils.
Also move init over to it.

Bug: http://b/37991155
Test: builds+boots
Change-Id: I5113a9d96a5ce0a0f3bad71134d6cc4f7b41a57e
2017-05-10 10:40:11 -07:00
Bowgo Tsai 8301fcfcf5 Merge "first stage mount: removing the requirement of by-name prefix for AVB" am: cdad92fdad am: c82235ebbd am: fec0b13902
am: acef4a9a09

Change-Id: I51e8a7df3db76a7cd626ee2ad2960abc5ec2256d
2017-05-10 03:20:12 +00:00
Bowgo Tsai acef4a9a09 Merge "first stage mount: removing the requirement of by-name prefix for AVB" am: cdad92fdad am: c82235ebbd
am: fec0b13902

Change-Id: I7dec7f517b5b1c601b4372a431789aba1375fbee
2017-05-10 02:11:06 +00:00
Treehugger Robot cdad92fdad Merge "first stage mount: removing the requirement of by-name prefix for AVB" 2017-05-10 01:37:28 +00:00
Tom Cherry 1863fe56d7 Merge changes I172acf0f,I97b6e17a am: 4963b42d7b am: 09b0da7b10 am: 7c0f21074e
am: 795b3296ed

Change-Id: I6c101b2ce7d43cb692aebefbd3411bd0e81728dd
2017-05-09 19:24:52 +00:00
Tom Cherry 795b3296ed Merge changes I172acf0f,I97b6e17a am: 4963b42d7b am: 09b0da7b10
am: 7c0f21074e

Change-Id: I5c261b9cd4ac7a3e4f10b7c39af057d93f3c74c1
2017-05-09 18:49:39 +00:00
Tom Cherry 4963b42d7b Merge changes I172acf0f,I97b6e17a
* changes:
  init: change kill order and fix error reporting in KillProcessGroup()
  Better logging in libprocessgroup and make resources clean up themselves
2017-05-09 17:45:48 +00:00
Bowgo Tsai 20651f62d0 first stage mount: removing the requirement of by-name prefix for AVB
Current first stage mount for AVB requires specifying a common prefix of
by-name symlink for all AVB partitions. It limits all AVB partitions to be on
the same block device.

firmware {
    android {
        compatible = "android,firmware";
        vbmeta {
            compatible = "android,vbmeta";
            parts = "vbmeta,boot,system,vendor";
            by_name_prefix="/dev/block/platform/soc.0/f9824900.sdhci/by-name"  <-- *removing this*
        };
        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";
            };
        };
    };
};

For normal mount with AVB, it extracts the by-name prefix of /misc
partition and use it as the prefix for all other partitions:
    - /dev/block/platform/soc.0/f9824900.sdhci/by-name/misc ->
    - /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor_a

Fix this by adding an internal map in FsManagerAvbOps to record the mapping
from partition name to its by-name symlink:

    ByNameSymlinkMap["vendor_a"] = "/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor_a"

Two overloaded factory methods are then provided for FsManagerAvbUniquePtr:
    - FsManagerAvbUniquePtr Open(ByNameSymlinkMap&& by_name_symlink_map):
      for first stage mount, where the by-name symlink map will be
      constructed externally, from the uevents processed by init, before
      invoking this factory method.

    - FsManagerAvbUniquePtr Open(const fstab& fstab): for normal mount,
      where the by-name symlink map will be constructed from the input fstab
      internally.

Bug: 37552224
Test: first stage mount /vendor with vboot 1.0
Test: first stage mount /vendor with vboot 2.0 (AVB)
Test: normal mount /vendor with vboot 2.0 (AVB)
Change-Id: Id17e8566da87ea22b8923fcd6e47db8d45bc7d6a
2017-05-09 11:03:49 +08:00
Tom Cherry 482f36cf74 init: remove restorecon() from util.cpp
restorecon() has become nothing more than a small wrapper around
selinux_android_restore().  This itself isn't super problematic, but
it is an obstacle for compiling util.cpp on the host as that function
is not available on the host.

Bug: 36970783
Test: Boot bullhead
Merged-In: I7e209ece6898f9a0d5eb9e5d5d8155c2f1ba9faf
Change-Id: I7e209ece6898f9a0d5eb9e5d5d8155c2f1ba9faf
2017-05-09 02:25:32 +00:00
Tom Cherry d71154268d Merge "init: remove restorecon() from util.cpp" into oc-dev-plus-aosp
am: 2813d87484

Change-Id: Ib6619f696fb08b99410b3a33221fe8eacebf89d6
2017-05-09 01:20:35 +00:00
Tom Cherry c2ef2f0d8d init: remove restorecon() from util.cpp
restorecon() has become nothing more than a small wrapper around
selinux_android_restore().  This itself isn't super problematic, but
it is an obstacle for compiling util.cpp on the host as that function
is not available on the host.

Bug: 36970783
Test: Boot bullhead
Change-Id: I7e209ece6898f9a0d5eb9e5d5d8155c2f1ba9faf
2017-05-08 16:41:13 -07:00
Mark Salyzyn 1136ebe74d Merge "init: add "+passcred" for socket to set SO_PASSCRED" am: 9811cd33ac am: 00d97b2327 am: a650c328f1
am: 1a830d5daa

Change-Id: I285fce8204b44b6e14494ff14b140088ba4e7a88
2017-05-08 23:30:36 +00:00
Mark Salyzyn 1a830d5daa Merge "init: add "+passcred" for socket to set SO_PASSCRED" am: 9811cd33ac am: 00d97b2327
am: a650c328f1

Change-Id: Id14c1e3c3aa3fdbf6e927d08720d2524d2e9b800
2017-05-08 23:27:27 +00:00
Mark Salyzyn b066fccc5c init: add "+passcred" for socket to set SO_PASSCRED
In the init scripts for socket, the type can have a suffix of
"+passcred" to request that the socket be bound to report SO_PASSCRED
credentials as part of socket transactions.

Test: gTest logd-unit-tests --gtest_filter=logd.statistics right after boot
      (fails without logd.rc change)
Bug: 37985222
Change-Id: Ie5b50e99fb92fa9bec9a32463a0e6df26a968bfd
2017-05-08 14:04:13 -07:00
Tom Cherry 3decb98f75 Merge changes I46690d1c,I84c11aa5 am: 0dda322d4a am: 18b23afa4b am: 3f9ba91d8f
am: 756ee8ded9

Change-Id: Ib005ef875bfc8116c320007acc10e7cf9accdc10
2017-05-08 16:27:47 +00:00
Tom Cherry 756ee8ded9 Merge changes I46690d1c,I84c11aa5 am: 0dda322d4a am: 18b23afa4b
am: 3f9ba91d8f

Change-Id: Ied40226f25303091aad079cf4e8ea1f9ca0379a7
2017-05-08 16:21:15 +00:00