Commit Graph

1535 Commits

Author SHA1 Message Date
Jaekyun Seok e83b252a9c Merge "Update persist.sys.usb.config on runtime" am: 41346e553b am: ac945881b3 am: 33e7e21645
am: 01d4504a6c

Change-Id: If1e4279f05d74eccf5ce23eef41a466b7d8e3bde
2017-04-25 04:04:35 +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 330be8147c Merge "init: set ro.boot.avb_version in recovery mode" am: f1bd536efd am: a1da077454 am: aacfa4f8c2
am: 6433e8dca2

Change-Id: Iac754f72903c38336d6af1aa5ba083889dda6ffb
2017-04-25 00:43:53 +00:00
Bowgo Tsai 8d6e30701a Merge "init: moving early mount logic into init_first_stage.cpp" am: bcd36a20d4 am: 2d7818a104 am: 47fe14b456
am: 58357f2b7e

Change-Id: Iff24a3fb330045bf8d32175435af147f2488b16d
2017-04-25 00:43:21 +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 a5bdc20cf6 Merge "Sepolicy load: use -N flag to skip neverallow checks" into oc-dev am: c53ae9ed3e
am: fb62e61ec0

Change-Id: I29e27fe4ee809aaa14de77fd9529e91f175253c1
2017-04-24 22:57:20 +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 64b51491d3 Merge changes Ic446c026,I86568a5b am: 51b7cb006f am: 41dbec9791 am: fea35fc7e4
am: d0ea8a98cd

Change-Id: I4f8fe713f768748e521ad4d6c18edf0e4b382591
2017-04-24 19:52:47 +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
Paul Lawrence 9dbe97b4d5 Support metadata encryption
Bug: 29189559
Test: Angler, Marlin build and boot
Change-Id: Ia7b070781f5f16ff8bfd934569a2209c80c28385
2017-04-21 14:26:00 -07:00
Tom Cherry b6e038efc6 Merge "init: fix errno handling on KillProcessGroup" am: f890ca9a1f am: db9f2cb46d am: c7e559ca40
am: 01d9b0e11c

Change-Id: I0b2f5c4992a736c0416b2ebbe576d57f8dbe58da
2017-04-20 21:02:42 +00: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
Tom Cherry 16df0f1336 Merge "init: Stop combining actions" am: 8d644d2c96 am: a0b0c8a18e am: 779e922866
am: d949df5f57

Change-Id: I2b8b3e244089ea45a7b80fa7b88a8cd9d41e6896
2017-04-19 20:17:57 +00: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 4abeb2b01b Merge "init: add warning that `start` is not synchronous" am: 06039e58d8 am: 2b78f9c0a9 am: 0a4ff0fb31
am: 0a03f5cb59

Change-Id: Ifbddec02bf5527dab86af605a619b6e74eb0c6df
2017-04-19 18:24:37 +00: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 3b6367af46 Merge "init: handle sys.powerctl immediately" am: 14ed55bae8 am: e6bfb53196 am: 8972f887d2
am: 1f49801ab1

Change-Id: I6af3f4e1850593f13f27a3fd48f1310e0c3e369c
2017-04-18 18:39:20 +00: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 c54a16e36c Merge "ueventd: create classes for dev and sys permissions" am: ffa38cfc1e am: e29fa61725 am: b7ef4726ff
am: c4b1a2f230

Change-Id: I28f4213dc1459b02c3929101b7b781eb8c024030
2017-04-17 22:42:26 +00: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 698384ef10 Merge "Set libavb version into system property for Treble OTA" am: e8311491da am: 7b08869382 am: 6f3ec3d759
am: 6e69b2ea2a

Change-Id: I1a6acaf7f42140a7a31dd95006a876dfd4919d9b
2017-04-15 06:11:02 +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 1abf533ae8 Merge "Revert "Send property_service AVC messages to the kernel audit system"" am: eea60804f6 am: aee26df200 am: 246a7e57b8
am: 77fc053638

Change-Id: I1edd70a8b2ec0dab7f72d2797bafcf39520a0984
2017-04-15 00:32:19 +00: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