Commit graph

3005 commits

Author SHA1 Message Date
Eric Biggers
eaadc9d426 init/fscrypt_init_extensions: support setting v2 encryption policies
Support setting v2 encryption policies on init-created directories.  The
policy version to set is gotten from a new field in
/data/unencrypted/mode, which is the file that's used to pass the
encryption options from vold to init.

Also don't bother falling back to defaults if fields are missing from
this file, since it's re-written on every boot by vold.

Bug: 140500999
Test: tested as series; see If64028d8580584b2c33c614cabd5d6b93657f608
Change-Id: Ia9c5d4b80199686799e3ac80de78a50ed3bdabf4
2019-09-30 10:27:38 -07:00
Treehugger Robot
34aba6a690 Merge "Separate system_ext_sepolicy.cil out of system sepolicy" 2019-09-28 00:28:57 +00:00
Tom Cherry
3699dbe2e0 Merge "init: add tips for debugging linker errors when launching init services" 2019-09-27 15:31:42 +00:00
Tom Cherry
aef269f11b Merge changes from topic "logwrapper-api-update"
* changes:
  Update init/fs_mgr for new logwrapper function
  logwrap: convert to C++, rename function logwrap_fork_execvp().
2019-09-27 15:31:04 +00:00
Tom Cherry
9328021ce7 init: add tips for debugging linker errors when launching init services
Test: we can see linker errors in dmesg when following these tips
Change-Id: I86b65e01d06ed7c0b908c4512d55872cd5595eca
2019-09-26 15:24:40 -07:00
Treehugger Robot
f0d17fb50e Merge changes from topic "remove_ashmemd"
* changes:
  libcutils: route to /dev/ashmem<boot_id> instead of ashmemd
  ueventd: duplicate /dev/ashmem
2019-09-26 17:56:53 +00:00
Tom Cherry
3a803eb2d4 Update init/fs_mgr for new logwrapper function
Test: cuttlefish boots, fsck logs seen
Change-Id: Icbc01161b44e097be813f4af648fa671739078b9
2019-09-26 10:29:57 -07:00
Colin Cross
2a62d42704 Merge "Use libcrypto_static instead of libcrypto" 2019-09-26 14:32:33 +00:00
Martin Stjernholm
4cbf095493 Merge "Must use libdexfile_support_static in a static executable." 2019-09-26 14:24:46 +00:00
Tom Cherry
993d07fc53 Merge changes from topic "boringssl-kmsg"
* changes:
  Redirect boringssl_self_test stdio to kmsg
  init: add stdio_to_kmsg option
2019-09-25 19:56:03 +00:00
Tri Vo
ff89b8d8c2 ueventd: duplicate /dev/ashmem
We want ashmem to only be used via libcutils API, with long-term goal
being deprecation of ashmem with memfd. To do that we route libcutils to
a new source of ashmem fds. We then phase out uses of /dev/ashmem that
doesn't go through libcutils using SELinux.

In Q, we introduced ashmemd as the source of ashmem fds to libcutils.
However, having a separate process and, consequently, binder hops to
handle /dev/ashmem results in performance/memory overhead.

To address the overhead, replace ashmemd with a duplicate of
/dev/ashmem. Name it /dev/ashmem<boot_id>, where boot_id is a random
number generated on each boot. This way we make sure that developers
don't accidentally depend on /dev/ashmem<boot_id>, as that name can't be
hardcoded.

Bug: 139855428
Test: writing "add"/"remove" to /sys/class/misc/ashmem/uevent correctly
adds/removes /dev/ashmem and /dev/ashmem/boot_id
Change-Id: I36d23116048bfcd99903ba46cc133161835a2cfa
2019-09-25 12:49:38 -07:00
Tom Cherry
f74b7f5756 init: add stdio_to_kmsg option
Some services are not native android services and therefore don't log
via the normal mechanisms.  This gives developers an option to have
their stdout/stderr logs sent directly to kmsg.

Test: see test prints to kernel log
Change-Id: I7973ea74d5cab3a90c2cd9a3d5de2266439d0c01
2019-09-24 12:47:14 -07:00
Martin Stjernholm
2ad47f35a7 Must use libdexfile_support_static in a static executable.
The other one compiles in dlopen() calls that won't work.

Test: Build & boot
Bug: 141485154
Change-Id: I8ab697cfbe41bd21ad47655e47a0218d52738b58
2019-09-24 17:36:30 +01:00
lijiazi
513c989908 Uevent: remove useless dir
There are no uevent fils in these dirs, so there's no need to
traverse these dirs.

Test: manual

Change-Id: I57b82846ad863952d8717e6c3ab80c1e243ee4f8
Signed-off-by: lijiazi <lijiazi@xiaomi.com>
2019-09-24 17:36:45 +08:00
Howard Chen
e6d71689bb Merge "Mount multiple DSU partitions when present." 2019-09-21 02:48:37 +00:00
Tom Cherry
03642ad8b8 Merge "init: create sockets before forking" 2019-09-20 14:59:58 +00:00
Bowgo Tsai
f016f256b5 Separate system_ext_sepolicy.cil out of system sepolicy
Currently system sepolicy can be extended via:
  - BOARD_PLAT_PUBLIC_SEPOLICY_DIR
  - BOARD_PLAT_PRIVATE_SEPOLICY_DIR

To support having a single shared core system sepolicy, those
customization should be moved to the newly added system_ext partition.

System-ext-specific sepolicy files will be installed into
/system_ext/etc/selinux/*. system_ext_sepolicy.cil is merged into
precompiled_sepolicy at build-time. In case precompiled_sepolicy can't
be used (e.g. system-only-ota), the init will merge this file with
the rest of the sepolicy at runtime.

Bug: 137712473
Test: boot aosp_crosshatch with system_ext_sepolicy.cil
Test: boot aosp_crosshatch without system_ext_sepolicy.cil
Change-Id: Ib37622271b559d65462de99ff424be831004508a
2019-09-20 18:20:21 +08:00
Howard Chen
1b094939e5 Mount multiple DSU partitions when present.
There might be partitions like product or system_ext in addition
to the system partition. Those partitions can contain dependencies
required by the system so we need to make the init to recognize
these partitions and mount them accordingly.

Bug: 140092208
Test: gsi_tool install & reboot
Change-Id: Ie5ef063292c3656e79cce9f887f23a8faa1ba2be
2019-09-20 14:10:52 +08:00
Tom Cherry
5241d10049 init: create sockets before forking
There is a race condition with Service::Start and socket creation.
Since socket creation currently happens after the fork(), it's
possible that init can continue executing other commands before the
socket is created.  If init starts another service that relies on that
socket, it isn't guaranteed to be available.

Particularly, we've seen this with hwservicemanager starting after
logd, but hwservicemanager's logs sometimes not showing up.

Bug: 140810300
Test: boot and logging functions correctly

Change-Id: Ib2932e836d345830cd38f3b556598508fd953058
2019-09-19 16:10:30 -07:00
Tom Cherry
2436e6b15a init: reboot immediately if /data isn't mounted
All of the logic in reboot.cpp is meant to safely shutdown services,
safely unmount emulated RW file systems, then finally unmount the
remaining RW file systems, particularly /data.  If /data hasn't been
mounted, then none of this logic is required.

Running this logic caused a lock up when shutting down blueline from
early-init.  Vold, or potentially a related HAL, locked up during the
ShutdownVold() calls.  debuggerd separately locked up in the watchdog
thread.

Therefore, this change immediately reboots if /data is not mounted.
It also removes the lines to call into debuggerd.  debuggerd will not
run due to SELinux in any case, so it can only be used when hands-on
debugging a device.

Bug: 141082587
Test: shutdown with /data mounted continues as normal
Test: shutdown from early-init immediately shuts the device down
Change-Id: I79c72346b17c7dfe57e955d9739bcaf559badc14
2019-09-19 14:05:56 -07:00
Tom Cherry
14c2472734 init: degeneralize subcontext init into only vendor_init
This code is more generic than it needs to be and one of the side
effects is that an extra init process is forked for odm_init, despite
it having the same context as vendor_init.  I don't think anything is
going to change regarding that soon, so this change stops forking that
extra process to save its memory and simplifies the code overall.

Bug: 141164879
Test: init still uses vendor_init for vendor_scripts
Test: init unit tests
Test: init only has one subcontext process
Change-Id: I0d224455604a681711e32f89fb20132378f69060
2019-09-18 14:02:14 -07:00
Colin Cross
f117f34aed Use libcrypto_static instead of libcrypto
Replace libcrypto with libcrypto_static, which can be protected through
visibility to ensure only modules that don't affect FIPS certification
can use it.

Bug: 141248879
Test: m checkbuild
Change-Id: I5f0b9acfb57f68570f6f58f2395f2bb1bc015365
2019-09-18 11:04:35 -07:00
David Anderson
0e70ce26b8 Merge "init: Make sure /dev/block/by-name/userdata is created in snapshot mode." 2019-09-18 00:35:55 +00:00
Elliott Hughes
f3a5ab8b1d Merge "Remove the global seccomp option." 2019-09-17 20:21:09 +00:00
David Anderson
1cfcee0e4d init: Make sure /dev/block/by-name/userdata is created in snapshot mode.
When userdata is used to store COW devices, we need to ensure we've
generated uevents for it.

This patch also refactors FirstStageMount to pass required devices
through arguments rather than a member variable.

Bug: 140761481
Test: manual test
Change-Id: Ie5e1c9699f084da5467a758eea41c7907fecc5ca
2019-09-17 13:19:22 -07:00
Paul Crowley
570d20d2ac Create /data/per_boot
Bug: 140882488
Test: Booted twice, checked logs to ensure encryption
    is different each time, adb created files in directory.
Change-Id: I44f746acd1040f7baa9123d4824ba39b194f287b
2019-09-13 15:50:23 -07:00
Tom Cherry
a550e7f412 Merge "init: add reboot_on_failure service option" 2019-09-13 19:26:49 +00:00
Tobias Thierer
530d8f1d48 Merge "Set LOCAL_INJECT_BSSL_HASH for init_first_stage" 2019-09-13 16:56:06 +00:00
Tom Cherry
60971e6ce2 init: add reboot_on_failure service option
This replaces the recently added `exec_reboot_on_failure` builtin, since
it'll be cleaner to extend service definitions than extending `exec`.
This is in line with what we decided when adding `exec_start` instead
of extending `exec` to add parameters for priority.

Test: `exec_start` a service with a reboot_on_failure option and watch
      the system reboot appropriately when the service is not found and when
      the service terminates with a non-zero exit code.

Change-Id: I332bf9839fa94840d159a810c4a6ba2522189d0b
2019-09-13 16:48:35 +01:00
Colin Cross
58505923e5 Set LOCAL_INJECT_BSSL_HASH for init_first_stage
init_first_stage is built in Make and statically links libcrypto,
so it needs to set LOCAL_INJECT_BSSL_HASH to make the FIPS self
test pass.

Bug: 137267623
Test: m checkbuild
Change-Id: Icd8ec07b731228a162db9a13d7304bf1d73127aa
2019-09-13 03:31:42 +01:00
Tom Cherry
dcb3d15611 ueventd: allow using external firmware handlers
Userspace may want to load a different firmware than the one that the
kernel requests in some cases, therefore this change adds the ability
to ueventd to run an external handler that will determine the name of
the file that should actually be loaded.

Bug: 138352500
Test: unit tests
Change-Id: Ic5da37268fd78109f83ae52d1b903bf7322a5ee5
2019-09-12 12:57:22 -07:00
Tom Cherry
4e46a33c70 Merge "Reland^2: "init: run property service in a thread"" 2019-09-10 17:04:57 +00:00
Tom Cherry
e351e5ed06 Merge "ueventd: make parallel restorecon functionality optional" 2019-09-10 14:52:31 +00:00
Jon Spivack
16fb3f9e42 Allow AIDL interfaces in service parsing
Bug: 138756857
Test: Manual (using mediaextractor as a test service)
Change-Id: Ice2c695fca7062d6a115df13a6ac1d6fe82a3a98
2019-09-09 15:24:42 -07:00
Tom Cherry
4233ec7f66 ueventd: make parallel restorecon functionality optional
5aa6197d5f added the ability to
parallelize restorecon to speed up boot for devices that have not
completely moved to genfscon.  This parallel restorecon happens after
the parallel ueventd handling.

This causes a performance regression for devices that have moved to
genfscon, since previously, the restorecon() was done in the main
ueventd thread in parallel with the uevent handlers.

I also tried to run the fully parallelized restorecon in parallel with
the uevent handlers, but that did not make any change to the cold boot
time, likely due to the additional overhead of parallelizing the work.

Bug: 140458170
Test: blueline coldboot time returns to pre-regression time.
Change-Id: I3cd6a869cc9b62792466813d94ad6c69834e854e
2019-09-09 09:02:48 -07:00
Tobias Thierer
983f76b3c6 Merge "Init: Run boringssl self test via separate binaries." 2019-09-07 23:46:00 +00:00
Wei Wang
d5dff26049 Merge "init: boot into thermal shutdown target on supported devices" 2019-09-06 22:59:07 +00:00
Wei Wang
5f181bc503 init: boot into thermal shutdown target on supported devices
Bug: 137982557
Test: thermal shutdown
Change-Id: I4c7c4647e340be6be7a37a3dde6324b4d7903007
(cherry picked from commit 271014e832)
2019-09-06 11:26:43 -07:00
Treehugger Robot
7b968315ee Merge "init/fscrypt_init_extensions: remove redundant log message" 2019-09-06 17:34:05 +00:00
Tom Cherry
1ab3dfcab4 Reland^2: "init: run property service in a thread"
It's been a long standing issue that init cannot respond to property
set messages when it is running a builtin command.  This is
particularly problematic when the commands involve IPC to vold or
other daemons, as it prevents them from being able to set properties.

This change has init run property service in a thread, which
eliminates the above issue.

This change may also serve as a starting block to running property
service in an entirely different process to better isolate init from
handling property requests.

Reland: during reboot, init stops processing property_changed messages
from property service, since it will not act on these anyway.  This
had an unexpected effect of causing future property_set calls to block
indefinitely, since the buffer between init and property_service was
filling up and the send() call from property_service would then
block.  This change has init tell property_service to stop sending it
property_changed messages once reboot begins.

Test: CF boots, walleye boots, properties are set appropriately
Change-Id: I26902708e8be788caa6dbcf4b6d2968d90962785
2019-09-05 14:42:58 -07:00
Eric Biggers
7a5f6c5912 init/fscrypt_init_extensions: remove redundant log message
On every boot, there is a "duplicate" message logged at INFO level for
every system device-encrypted directory, e.g.:

    1     1 I init    : Setting policy on /data/app-private
    1     1 I init    : Encryption policy of /data/app-private set to 3a19970b1aa3abed modes 127/4

Or:

    1     1 I init    : Setting policy on /data/app-private
    1     1 I init    : Verified that /data/app-private has the encryption policy 3a19970b1aa3abed modes 127/4

(Before I51ee70706bc9ccb216ccefd7bdfbbfc57faae14d the second messages
were slightly different, but were similar and still at INFO level.)

The issue is that set_system_de_policy_on() prints its own log message,
then calls fscrypt_policy_ensure() which prints a message too; and the
second message is essentially a superset of the first.

Clean this up by removing the message from set_system_de_policy_on().

Test: Booted and checked the log.
Change-Id: I2786ba7e2dbb355f159ac9d8fe5ad1f0a4cdbfea
2019-09-05 13:20:25 -07:00
Elliott Hughes
4e6bf2510f Remove the global seccomp option.
Added in af1a9bfb8f, but it's never been
used in practice because of the performance impact, and it's incompatible
with our ability to add new system calls via a bionic module update
because it defaults to disabling all unknown syscalls, and init will
still be using the non-updated bootstrap libc from when it first shipped.

Test: treehugger
Change-Id: I8e396675fcfaf0218a92f464d15e613f43319305
2019-09-04 21:16:26 -07:00
Tobias Thierer
1136f1592a Init: Run boringssl self test via separate binaries.
Instead of init.cpp knowning about the boringssl self
test, use init.rc to exec dedicated self test executables.

Advantages:
 - The self test is run not only both the copy of libcrypto
   in /system but also /apex/com.android.conscrypt.
 - The self test is run not only for the primary (e.g. 64bit)
   ABI but also for a secondarry (e.g. 32bit) ABI.
 - The dependency on libcrypto is kept to the self test binary.
 - The self test binary abstracts the exact native API for
   running the self test (this will change soon because the
   self test will be run when the library is loaded).

Bug: 137267623
Test: Check that logcat shows both binaries being started as root,
      and finishing with exit code 0.

Change-Id: I1e716749ee2133993f0f7b2836483391fd1a62f0
2019-09-05 01:41:08 +01:00
Tom Cherry
7896e7adcc init: add exec_reboot_on_failure builtin
Add exec_reboot_on_failure builtin and refactor the VDC commands that
had similar functionality.  These will now also reboot in the case
that the program cannot be found or run for any reason.

Test: boots normally, reboots if command is not found or if command
      returns status '1'

Change-Id: I1c99498c2b741512a50188e1a325c25e9ec8fba0
2019-09-04 16:23:15 -07:00
Tom Cherry
0589aa4265 Merge "init: Always reap processes before handling properties" 2019-09-03 16:35:27 +00:00
Martin Stjernholm
0c100685dc Merge changes from topic "art-without-bionic"
* changes:
  Include com.android.runtime in the "runtime" linker namespace.
  Update logic for detecting pre-apexd services to check that the ART APEX is mounted.
  Update paths and names for the new ART APEX.
2019-09-02 10:28:30 +00:00
Treehugger Robot
dec467f271 Merge "Fix typo" 2019-08-31 13:39:37 +00:00
Tom Cherry
905a5df83d init: Always reap processes before handling properties
There is a race that manifests like this:

1) A service dies (not processed by init yet).
2) service_manager processes death notification.
3) service_manager gets checkService and calls init to start service.
4) init gets the ctl.start / ctl.interface_start for the service
   but the service already appears started, so it does nothing.
5) init gets sigchld, but doesn't do anything else to restart the
   service

We can avoid all of this if we already reap pending processes before
handling properties in the main loop of init.  Since reaping the
services calls waitid(), there's no race even if the signalfd for
sigchld hasn't triggered yet.  It also won't cost us much efficiency,
since it's only a single system call.

Test: CF boots, init unit tests pass
Change-Id: Ie24ef406055b283797b41b1821c8ebcccead4db4
2019-08-30 14:20:05 -07:00
Paul Lawrence
b2c2d6907f Fix typo
Test: builds
Change-Id: I4b48e8b3d457382579216482249e734f74768c71
2019-08-30 11:15:58 -07:00
Martin Stjernholm
cacf04351f Update logic for detecting pre-apexd services to check that the ART APEX is
mounted.

Necessary to make e.g. bootanimation work, which depends on (at least)
libandroidicu.so in the ART APEX.

Test: Build & boot
Bug: 135753770
Exempt-From-Owner-Approval: Approved internally
Change-Id: Ibab4f5f7a243d0815b9c70a537bae8d77dee2fbb
Merged-In: Ibab4f5f7a243d0815b9c70a537bae8d77dee2fbb
2019-08-30 17:47:31 +01:00
Martin Stjernholm
df96e1f25c Update paths and names for the new ART APEX.
Test: Build & boot
Test: atest CtsJniTestCases
Bug: 135753770
Exempt-From-Owner-Approval: Approved internally
Change-Id: Ic59b7bc8aae7ce521cf3ec9df4ab72aa611d0b75
Merged-In: Ic59b7bc8aae7ce521cf3ec9df4ab72aa611d0b75
2019-08-30 17:47:31 +01:00
Steven Moreland
9800ad839a init: -1 log for control message error paths.
Fixes: 140136969
Test: check logs
Change-Id: Id80f59927b44d1026c6e3389c80ca96baf0733c4
2019-08-29 16:08:36 +00:00
Tom Cherry
4adbd2905a Merge "Revert "Reland: "init: run property service in a thread""" 2019-08-28 17:50:00 +00:00
Tom Cherry
3da2ba6d4a Revert "Reland: "init: run property service in a thread""
This reverts commit 8efca4bbb3.

Reason for revert: Still broken

Change-Id: I3b37b1b00ff4b19f2eec2d8bd72042463d47cee3
2019-08-28 17:47:49 +00:00
Treehugger Robot
88bba95989 Merge "init: set SetKptrRestrict before early-init" 2019-08-28 17:44:55 +00:00
Tom Cherry
34f2537393 Merge "Reland: "init: run property service in a thread"" 2019-08-28 15:01:34 +00:00
Tom Cherry
15c8760403 Merge "ueventd: parallelize restorecon /sys" 2019-08-28 14:58:12 +00:00
Ravi Kumar Siddojigari
33783fc29c init: set SetKptrRestrict before early-init
As part of debugging long run issue we are enabling
module info as part of debug build under the config key
DEBUG_MODULE_LOAD_INFO , But doing so can lead to info leak
as modules/dlkm are loaded in early-init and setting the
kptr_restriction is done after early-init.

So moving setting of kptr_restrict much before early-init.

Bug: 138641073

Change-Id: Ic3c0ca57a94c8b20136a15331dd646bd8825b625
2019-08-28 14:28:08 +02:00
Josh Gao
b245609059 Merge "Mark some tests as requiring root." 2019-08-28 02:40:03 +00:00
Bongkyu Kim
5aa6197d5f ueventd: parallelize restorecon /sys
generate subdir for /sys and /sys/devices, handle restorecon in parallel.

This reduces coldboot time on our target about 300ms.

Change-Id: I9c3d0e97aacff0ca127880d936dfd5fcc2aee125
2019-08-28 09:55:09 +09:00
Tom Cherry
a5c2aed35f Merge "init: send property_set failures to the audit netlink socket" 2019-08-27 23:23:00 +00:00
Josh Gao
6cad139bcc Mark some tests as requiring root.
Bug: http://b/140123924
Test: mma
Change-Id: I3ad277179018631c50d9295cdb173dd9dfa7ac59
2019-08-27 16:09:32 -07:00
Paul Crowley
309d6dde31 Merge changes I1c1445ba,Ic0c8b163
* changes:
  Straighten out do_mkdir
  Convert fscrypt_set_directory_policy to C++
2019-08-27 02:26:25 +00:00
Yifan Hong
8d168c3321 Merge "init: Add first-stage init support for snapshot-based partitions." 2019-08-27 01:56:41 +00:00
Tom Cherry
8efca4bbb3 Reland: "init: run property service in a thread"
It's been a long standing issue that init cannot respond to property
set messages when it is running a builtin command.  This is
particularly problematic when the commands involve IPC to vold or
other daemons, as it prevents them from being able to set properties.

This change has init run property service in a thread, which
eliminates the above issue.

This change may also serve as a starting block to running property
service in an entirely different process to better isolate init from
handling property requests.

Test: CF boots, walleye boots, properties are set appropriately
Change-Id: I13b8bf240c9fcb1d2d5890a8be2f0ef74efd4adf
2019-08-26 17:08:41 -07:00
Treehugger Robot
e3cd3badbd Merge "Move fscrypt_init_extensions into system/core" 2019-08-26 23:24:54 +00:00
Tom Cherry
8180b48c4c init: send property_set failures to the audit netlink socket
Bug: 139816248
Test: see audit messages for failed property set during property file
      reading

Change-Id: I2b6a0448aa4cb494e924070928b0fd0eb5d5c998
2019-08-26 14:53:18 -07:00
Tom Cherry
eb94026231 Merge "Revert "init: run property service in a thread"" 2019-08-26 19:47:02 +00:00
Paul Crowley
1b4e7328ad Straighten out do_mkdir
Use lstat(), and then make only the system calls needed to fix the
directory up.

Bug: 140027478
Test: boots twice, no worrying log messages.
Change-Id: I1c1445baae3ec1c1ce17626ede388aa04d5f7781
2019-08-26 12:06:59 -07:00
Paul Crowley
285e5d6d08 Convert fscrypt_set_directory_policy to C++
Bug: 140027478
Test: compiles, boots
Change-Id: Ic0c8b163fe37b11787cab49cc2eea38a1de377e9
2019-08-26 11:55:36 -07:00
Paul Crowley
052f31c678 Move fscrypt_init_extensions into system/core
Bug: 140027478
Test: treehugger
Change-Id: I9f8b76a501be0b261b6fdd1da98447601e0fd32b
2019-08-26 10:33:17 -07:00
Tom Cherry
f451426205 Revert "init: run property service in a thread"
This reverts commit 26f5e7da3a.

Reason for revert: bluecross boot stability issue

Bug: 140009641
Change-Id: I7ddb9509dfb2c6f644037129aa9d3fb9ff1740aa
2019-08-26 16:33:40 +00:00
Tom Cherry
88eedafbe1 Merge "Add init_tests to CTS" 2019-08-22 22:53:56 +00:00
David Anderson
c5b3c88f8a Merge "liblp: Support sdcards in PartitionOpener." 2019-08-22 19:12:40 +00:00
Tom Cherry
afe45ab5f2 Merge changes Id9534a59,I3ee81536
* changes:
  init: run property service in a thread
  Revert "init: Handle properties in the background of calling fs_mgr"
2019-08-22 17:24:18 +00:00
Tom Cherry
17b2be05a2 Add init_tests to CTS
Test: atest CtsInitTestCases
Test: Cts in presubmit still passes
Change-Id: Ic16dafbaacfbace904947bd3ce2b8586f981348f
2019-08-22 08:37:55 -07:00
David Anderson
c8edf84d45 init: Add first-stage init support for snapshot-based partitions.
Note that /metadata must now be mounted before CreateLogicalPartitions()
is called. This is because SnapshotManager overrides the default
partitioning scheme, and the only way to tell if a SnapshotManager is
needed is via the metadata partition.

Bug: 139204329
Test: manual test
Change-Id: I812df6c4c0d4d8753b1516f63dc70c5bc3e1c09c
2019-08-21 12:27:56 -07:00
David Anderson
251ec05f01 liblp: Support sdcards in PartitionOpener.
Before ImageManager was introduced, gsid avoided using PartitionOpener
when writing to external media. PartitionOpener couldn't interact with
non-boot devices, because it prepends /dev/block/by-name. We hacked
around this in both gsid and in first-stage init, which manually detects
the problem and prepends /dev/block instead.

After the ImageManager refactoring, sdcard support broke in gsid,
because it started relying on PartitionOpener. Let's fix this by allowing
/dev/block for mmcblk* names in PartitionOpener.

Bug: 139204329
Test: fiemap_image_test gtest
Change-Id: Ic1cbdbe0a18fc09522ee38cc62b35fd8193ce250
2019-08-21 12:27:56 -07:00
Tom Cherry
26f5e7da3a init: run property service in a thread
It's been a long standing issue that init cannot respond to property
set messages when it is running a builtin command.  This is
particularly problematic when the commands involve IPC to vold or
other daemons, as it prevents them from being able to set properties.

This change has init run property service in a thread, which
eliminates the above issue.

This change may also serve as a starting block to running property
service in an entirely different process to better isolate init from
handling property requests.

Test: CF boots, walleye boots, properties are set appropriately
Change-Id: Id9534a5916abb2f7d2a49cda54e33c1b69c50c2f
2019-08-21 08:26:09 -07:00
Yi Kong
0f6537c437 Fix ODR violation
host_init_verifier statically links libprocessgroup, which has shared
dependency on libjsoncpp. Right now it also has shared dependency on
libjsoncpp, resulting in ODR violation:

 ERROR: AddressSanitizer: odr-violation (0x7fce895f3220):
 [1] size=8 'Json::kNullRef' external/jsoncpp/src/lib_json/json_value.cpp:37:22
 [2] size=8 'Json::kNullRef' external/jsoncpp/src/lib_json/json_value.cpp:37:22
 These globals were registered at these points:
 [1]:
 #0 0x56276926ef0d (/usr/local/google/buildbot/src/android/master/out/host/linux-x86/bin/host_init_verifier+0xd1f0d)
 #1 0x7fce894ac1d9 (/lib64/ld-linux-x86-64.so.2+0x101d9)

 [2]:
 #0 0x56276926ef0d (/usr/local/google/buildbot/src/android/master/out/host/linux-x86/bin/host_init_verifier+0xd1f0d)
 #1 0x7fce894ac1d9 (/lib64/ld-linux-x86-64.so.2+0x101d9)

Move host_init_verifier to libjsoncpp_headers to fix the ODR violation.

Bug: 139546461
Bug: 131328001
Test: Run ASAN host_init_verifier
Change-Id: I54a51138d61fff37f092ffaa0758817600a0af9d
2019-08-18 17:57:35 -07:00
Tom Cherry
3707d328a1 Revert "init: Handle properties in the background of calling fs_mgr"
This reverts commit 71bdf2820e.
Test: boot
2019-08-15 13:07:24 -07:00
Tom Cherry
53620ca1b1 Merge "Actually add README contents for ueventd" 2019-08-13 14:48:04 +00:00
Treehugger Robot
b85c72caed Merge "init: first stage init tie stdout and stderr to /dev/kmsg" 2019-08-13 12:48:40 +00:00
Tom Cherry
aefb141c67 Actually add README contents for ueventd
A long time coming

Test: n/a
Change-Id: I6050e74d7497d5a7760f615fe2ad7d5c78a66ab9
2019-08-12 13:13:57 -07:00
Tom Cherry
6fd8d3bb1b init: Allow matching empty property values
When we have a property match along with an event trigger, we
currently don't allow matching empty property values, in other words,
properties that are unset.  For example, the below trigger would never
be run:

on zygote-start && property:persist.sys.fuse=""

That doesn't make sense though, it should be possible to match an
empty property value, so this change allows that trigger to match when
persist.sys.fuse is either empty or not set.

This continues to not match a '*' to an empty property, so

on zygote-start && property:persist.sys.fuse=*

will not run if persist.sys.fuse is empty or unset.

Test: the above triggers run appropriately
Change-Id: Ia57de7b96ad352590d0c82ff4ae95060b7361976
2019-08-12 09:31:42 -07:00
Daniel Norman
0d061b258a Merge "Adds check_interface_{restart,start,stop} check_builtins." 2019-08-06 23:21:29 +00:00
Daniel Norman
d2533c3395 Adds check_interface_{restart,start,stop} check_builtins.
Includes refactoring out interface inheritance hierarchy logic to a new
interface_utils file.

Bug: 137397100
Test: 'm' with an init_rc that misspells an interface in an
interface_start, interface_restart, or interface_stop line.
Change-Id: I9f650289d64ae2b13435a81e1693c7ab5e6e9ecf
2019-08-06 11:10:42 -07:00
Tom Cherry
980cbef0c5 Merge "init: Check onrestart commands" 2019-08-06 15:20:11 +00:00
Tom Cherry
e269a721dc Merge "init: ignore ENOENT from fewer builtins" 2019-08-06 15:19:48 +00:00
Tom Cherry
6737a6bf3f init: Check onrestart commands
Test: have bad users/groups in onrestart chown commands fail the build
Change-Id: Ic7fea6395c1f6e09f06800ba373d402a81cb774c
2019-08-05 15:03:58 -07:00
Daniel Norman
a022e47a0b Merge "Fixes incorrect flag info for the inheritance hierarchy file." 2019-08-02 23:00:27 +00:00
Daniel Norman
e6586c4c8e Fixes incorrect flag info for the inheritance hierarchy file.
Test: n/a
Change-Id: I65d6437f4192d969932e01019826827c98a2669c
2019-08-02 15:22:13 -07:00
Daniel Norman
fb54b74fa0 Merge changes from topic "services_serve_interfaces_test"
* changes:
  Adds new property for service name -> PID.
  Adds a library to parse service info from init_rc files for use in tests.
  Adds a visibility rule for init defaults.
2019-08-02 21:51:17 +00:00
Tom Cherry
549ea4801b Merge changes Ied888249,Id8857c45
* changes:
  init: check the arguments of builtins during the build
  init: don't log in expand_props directly
2019-08-01 22:04:30 +00:00
Tom Cherry
4772f1da47 init: check the arguments of builtins during the build
Host init verifier already checks that the names and number of
arguments for builtins are correct, but it can check more.  This
change ensures that property expansions are well formed, and that
arguments that can be parsed on the host are correct.  For example it
checks that UIDs and GIDs exist, that numerical values can be parsed,
and that rlimit strings are correct.

Test: build

Change-Id: Ied8882498a88a9f8324db6b8d1020aeeccc8177b
2019-08-01 10:54:47 -07:00
Tom Cherry
c5cf85db23 init: don't log in expand_props directly
It's better to pass the error message to the caller to determine how
best to print the error.

Test: build
Change-Id: Id8857c459df2f26c031650166609608d20e4d051
2019-08-01 10:34:58 -07:00
Wei Wang
f7c2bfee08 init: add timing log for oneshot and exec_background services
Bug: 136523746
Bug: 138732985
Test: boot
Change-Id: I713edd2ba8a391d5afbea796c6d58ffac9477436
2019-07-31 11:53:18 -07:00
Daniel Norman
c788771da7 Adds new property for service name -> PID.
Bug: 138114550
Test: used in vts_ibase_test
Change-Id: Id21b81aa09b8597d17ad0a132ddd7749fe1182e9
2019-07-31 11:35:32 -07:00
Daniel Norman
d19c5a5076 Adds a library to parse service info from init_rc files for use in tests.
Bug: 138114550
Test: used in vts_ibase_test
Change-Id: Ibadc2a76d6112b5778d3a282a1e05ffc74511623
2019-07-31 11:33:47 -07:00
Daniel Norman
8082ba2f77 Adds a visibility rule for init defaults.
Also ran bpfmt on the file.

Test: n/a
Change-Id: I33f6233a031462debe295ab5576dd75c948ae081
2019-07-31 11:33:35 -07:00
Tom Cherry
d17c37952d init: ignore ENOENT from fewer builtins
Previously we were ignoring ENOENT from all builtins as
rootdir/init.rc has many legacy commands that we need to keep for
backwards compatibility, but are otherwise no longer relevant.

However, this wasn't catching actual issues, for example chown failing
due to not finding the user or group name.  This change therefore
reduces the scope of ignoring ENOENT to the only the extraneous errors
in builtins.

Test: boot CF and walleye without seeing errors from init.rc
Test: see errors from invalid users/groups in chown
Change-Id: Ia8e14fa2591e083cb1736c313a3e55515bc5d15e
2019-07-30 12:44:35 -07:00
Mark Salyzyn
beb6abedcc init: first stage init tie stdout and stderr to /dev/kmsg
It is exceedingly difficult to debug I/O and filesystem corruption
issues during first and selinux initialization stage init.  By
redirecting stderr, and for good measure stdout, to /dev/kmsg in
first stage init before it exec's "/system/bin/init" we can see
the filesystem corruption errors more clearly.

Before this we would see:

init: Skipped setting INIT_AVB_VERSION (not in recovery mode)
Kernel panic - not syncing: Attempted to kill init! exitcode=0x...

and then wonder why?

After this change we can see:

init: Skipped setting INIT_AVB_VERSION (not in recovery mode)
libc: Fatal signal 5 (SIGTRAP), code 128 (SI_KERNEL), fault addr...
Kernel panic - not syncing: Attempted to kill init! exitcode=0x...

-or-

init: Skipped setting INIT_AVB_VERSION (not in recovery mode)
linker: CANNOT LINK EXECUTABLE "/system/bin/init": cannot locate symbol...
Kernel panic - not syncing: Attempted to kill init! exitcode=0x...

(NB: with stutter removed because of stdout and stderr)

Silence from these sources otherwise on successful execution.

Test: boot
Bug: 138459777
Change-Id: I4200b24baeaa6e408a5e0a2c890561bda1e2f1f4
2019-07-29 11:56:51 -07:00
Tom Cherry
d52a5b3c10 init: simplify keyword_map
I've heard that keyword_map is too complex, in particular the tuple
and the pair in BuiltinFunctionMap, so this change removes a lot of
that complexity and, more importantly, better documents how all of
this works.

Test: boot, init unit tests

Change-Id: I74e5f9de7f2ec524cb6127bb9da2956b5f307f56
2019-07-23 14:39:38 -07:00
Tianjie Xu
cccb573f93 Merge "init: Write the reason in BCB on "reboot recovery"" 2019-07-20 05:03:41 +00:00
Tianjie Xu
5e98b633a7 init: Write the reason in BCB on "reboot recovery"
Without this change "adb reboot recovery" leads to normal boot.

Bug: 137523800
Test: peform factory reset, adb reboot recovery
Change-Id: Ie791c8107d3434bf4ae6f5785b24e7d97921a7a9
2019-07-19 13:02:59 -07:00
Treehugger Robot
85bbbe5695 Merge "Revert "init: Write the reason in BCB on "reboot recovery""" 2019-07-19 05:34:43 +00:00
Tianjie Xu
137943d31b Revert "init: Write the reason in BCB on "reboot recovery""
This reverts commit 4d35f2e59c.

Reason for revert: b/137523800 This breaks factory reset on all devices (and potentially rescue party and non-ab updates). Because the init code unconditionally clear the arguments like "--wipe_data" written by framework; as a result, device boots into recovery without doing wipe. 

I guess one fix is to check the content of BCB, and skip the overwrite if it already boots into recovery. Revert the cl first to unblock p1, will submit the fix separately.

Change-Id: Iccaf3dce6999005c2199490a138844d5a5d99e7f
2019-07-18 11:42:14 -07:00
Martijn Coenen
728586f5b2 Ignore class_{reset|start}_post_data on non-updatable APEX.
For devices that use FDE and don't support updatable APEXes, don't
stop and restart all processes - there is no need and it only increases
boot time for these devices.

Additionally, some daemons have never been restarted in the past, and
restarting them exposes certain issues.

Bug: 137251597
Bug: 136777273
Bug: 135627804
Test: verified manually w/ ro.updatable.apex=false
Change-Id: I9590f2c2cdfab0a49f39846896460305d44221ee
2019-07-17 08:49:44 +02:00
Treehugger Robot
a19f51eccc Merge "Reserve 'init'." 2019-07-16 02:35:29 +00:00
Treehugger Robot
100e8ffbcd Merge "Remove obsolete subdirs entry." 2019-07-16 02:02:40 +00:00
Tom Cherry
c8620ddafe Merge "init: clean up file / socket descriptor creation" 2019-07-15 23:20:13 +00:00
Steven Moreland
4c79df91a9 Remove obsolete subdirs entry.
Change-Id: I3327df74179d2ba1ffd66da59e5196f34dfe3974
Bugs: me
Test: N/A
2019-07-15 15:14:34 -07:00
Steven Moreland
ceb36d08f4 Reserve 'init'.
This makes `pathmod init` and `gomod init` work, and it also reserves
the 'init' for potential future usage.

Change-Id: I6990bf421211b93d58d978d84d46474ff243e808
Bugs: me
Test: pathmod init; gomod init
2019-07-15 15:12:56 -07:00
Tom Cherry
2e4c85f157 init: clean up file / socket descriptor creation
clang-tidy hinted that some of this code wasn't right.  Looking
deeper, there is really not much related to file and socket
descriptors, except that they're published in similar ways to the
environment.  All of the abstraction into a 'Descriptor' class takes
us further away from specifying what we really mean.

This removes that abstraction, adds stricter checks and better errors
for parsing init scripts, reports sockets and files that are unable to
be acquired before exec, and updates the README.md for the passcred
option.

Test: build, logd (uses files and sockets) works
Change-Id: I59e611e95c85bdbefa779ef69b32b9dd4ee203e2
2019-07-15 12:17:30 -07:00
David Anderson
c9b797ac25 Merge "libdm: Improve the reliability of dm device paths." 2019-07-12 23:03:41 +00:00
Tom Cherry
8a779ee959 Merge "init: fix clang-tidy performance issues" 2019-07-12 18:49:49 +00:00
Daniel Norman
4b505fe3a8 Merge "Checks the interface inheritance hierarchy in init_rc files." 2019-07-12 18:01:46 +00:00
Tom Cherry
e7a010de01 Merge "init: Write the reason in BCB on "reboot recovery"" 2019-07-12 17:39:32 +00:00
Treehugger Robot
5c296a0003 Merge "init: powerctl support and propagate longer canonical reboot reasons." 2019-07-12 17:37:25 +00:00
David Anderson
924858cd18 libdm: Improve the reliability of dm device paths.
This fixes a race condition where WaitForFile() after
GetDmDevicePathByName appears to succeed, but a subsequent operation on
the path fails. This can happen when CreateDevice() is called
immediately after a call to DeleteDevice (from any process), and the
path is re-used, enqueuing udev events to remove and re-add the block
device.

The fix for this is to introduce a new variant of CreateDevice() that
has a timeout parameter. When the timeout is positive, CreateDevice()
will wait for a /dev/block/mapper/by-uuid symlink to be created, which
signals that ueventd has finished processing the operation.

ueventd will now create these by-uuid symlinks for device-mapper nodes.
Unfortunately, the uuid is only available during "change" events, so we
have to special case device-mapper symlink creation. And since the uuid
is not available during "remove" events, we simply find matching links
to remove them.

This ensures that callers of CreateDevice() can use the device path
knowing that no asynchronous removals are pending. Code that uses the
old CreateDevice+WaitForFile pattern will be transitioned to the new
method.

Note that it is safe to ignore the timeout, or to use the "unsafe"
CreateDevice, if the caller ensures the path by other means. For example
first-stage init has no device removal, and regenerates uevents until
it has acquired all the paths it needs.

Finally, since libdm now inspects sysfs unconditionally, libdm consumers
need r_dir_file perms for sysfs_dm in their sepolicy. Additionally
linking to libdm now requires linking to libext2_uuid.

Bug: 135771280
Test: libdm_test
      device flashes, boots
Change-Id: If5a7383ea38f32a7fbbcf24842dce6a668050a70
2019-07-11 15:39:52 -07:00
Daniel Norman
3f42a767cd Checks the interface inheritance hierarchy in init_rc files.
Bug: 118016875
Test: Added 'interface' lines to an init_rc file and observed errors
when misspelled or missing entire inheritance hierarchy.
Change-Id: I681420f15539742d8415808b2a0dcbf0bf6faaf1
2019-07-11 14:43:11 -07:00
Steven Moreland
4280165ae0 Merge "Remove binder dependency in init." 2019-07-11 20:56:12 +00:00
Sam Protsenko
4d35f2e59c init: Write the reason in BCB on "reboot recovery"
Without this change "adb reboot recovery" leads to normal boot.

Change-Id: I361d0a1f6f6f2c57f3dc80102c21970b462c9b9c
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
2019-07-11 11:25:28 +00:00
Mark Salyzyn
d7931f1149 init: powerctl support and propagate longer canonical reboot reasons.
init: Received sys.powerctl='reboot,userrequested,recovery,ui' ... (/system/bin/recovery)
init: powerctl: unrecognized command 'reboot,userrequested,recovery,ui'

Test: manual & boot_reason_test.sh
Bug: 63736262
Bug: 135078366
Bug: 133326470
Change-Id: I931daf8dc4b74db5ee114c59ee215b1ba54bc31d
2019-07-10 13:06:57 -07:00
Tom Cherry
7c1d87e490 init: fix clang-tidy performance issues
Test: boot, init unit tests
Change-Id: Iccf34d2fedfa543dd9f29e010cbb6d8fe9cf5983
2019-07-10 12:59:02 -07:00
Steven Moreland
4ee27039e0 Remove binder dependency in init.
- unused
- using binder requires twoway calls (since getting a service from
    servicemanager requires two calls)

Bug: 135768100
Test: N/A
Change-Id: Idc41f487bad2d8343e99ded98812f3a84e2b8e37
2019-07-10 17:01:31 +00:00
Justin Yun
7eaf9b58ec Rename product_services to system_ext
Update ld.config.txt and init.

Bug: 134359158
Test: make && check boot and ld.config.txt file
Change-Id: Ie1dce42e690414fb45b26759506ea7f64d06740d
2019-07-09 23:34:17 +00:00
Tom Cherry
247ffbf314 Fix a few clang-tidy issues and add NOLINT for others
android-base:
* Add NOLINT for expanding namespace std for std::string* ostream
  overload

libdm:
* Fix missing parentesis around macro parameters

init:
* Fix missing CLOEXEC usage and add NOLINT for the intended
  usages.
* Fix missing parentesis around macro parameters
* Fix erase() / remove_if() idiom
* Correctly specific unsigned char when intended
* 'namespace flags' should be signed, since 'flags' it signed for
  clone()
* Add clear to property restore vector<string> to empty after move
* Explicit comparison against 0 for strcmp

Test: build
Change-Id: I8c31dafda2c43ebc5aa50124cbbd6e23ed2c4101
2019-07-09 16:17:36 +00:00
Treehugger Robot
3d3f24bc22 Merge "init: fix to avoid loading apex *.rc files twice" 2019-07-09 00:37:31 +00:00
Steve Muckle
d75f30a4f0 first_stage_init: add console
Start and wait on a console if androidboot.first_stage_console=1 is
present on the kernel command line. This only works on eng and
userdebug builds.

Change-Id: I978e9390a89509431b399ea58b284736b27eeb1b
2019-07-08 09:33:24 -07:00
Jooyung Han
9c4fa66706 init: fix to avoid loading apex *.rc files twice
Test: adb shell dmesg | grep "init: Parsing file /apex"
 shows a single entry for each APEX'es *rc file

Change-Id: I9006cc3d0cb7bdfe7532279f29d8095b7d16a807
2019-07-05 11:22:18 +09:00
Daniel Norman
3df8dc58b2 Checks each interface in an init_rc file is a known hidl_interface.
Test: Adding a misspelling to an init_rc's interface line and observing
build failure.
Bug: 77646540
Change-Id: I58f66d73f0bd9b4203e8259161843b56ad428d73
2019-06-28 13:31:54 -07:00
Tom Cherry
3f1bce870b init: switch host_init_verifier to getopt()
Test: host init verifier works

Change-Id: Ia0fe5994079e6e182a64b14a15fdb36328080168
2019-06-27 10:09:12 -07:00
Tom Cherry
f1a044bac4 init: clean up host_init_stubs a bit
In retrospect, these always should have been header only.  We don't
need setgroups() anymore either, since we have the right symbols now.

Test: build
Change-Id: If6fbf6f8ee288ed261576207d90a7ec5674853f9
2019-06-26 15:38:47 -07:00
Tom Cherry
172c83f972 init: remove last init.cpp global
By moving it into builtins.cpp..., but that's less bad than it is
now, especially since this is defunct in code targeting Q+.  Remove
the guards that init.h isn't being included by other files too as it's
not useful anymore.

Test: build
Change-Id: Ic564fcff9e8716ec924098b07a8c9d94ca25f960
2019-06-26 14:46:58 -07:00
Tom Cherry
ff88e30126 init: remove console_init_action
There's no fundamental reason to store this aside.  That property can
only be written by init, so it's not likely that we're going to
corrupt it.

Test: boot and use serial console
Change-Id: I9248fbaf959ea913d09add829d4cb509af99d570
2019-06-26 14:20:53 -07:00
Tom Cherry
b1ffb1ded5 Move actual parsing from Service to ServiceParser
This is how this should have been done since the beginning.

Test: build, boot
Change-Id: Ifd795776c71a2e666da7fab90cbb3f356af93d4f
2019-06-26 14:03:16 -07:00
Tom Cherry
2aeb1addee Split out ServiceList and ServiceParser from service.cpp/.h
These always should have been in their own files.

Test: build
Change-Id: I201109b5ee63016e78901bbfd404846d45e1d4e6
2019-06-26 13:45:07 -07:00
Tom Cherry
84fc269b6e Merge "init: Handle properties in the background of calling fs_mgr" 2019-06-24 22:46:09 +00:00
Tom Cherry
71bdf2820e init: Handle properties in the background of calling fs_mgr
It's been a long standing problem that init calls fs_mgr functions
synchronously and therefore stops handling properties, which causes
deadlocks if either fs_mgr, or vdc, or vold attempt to set
properties.

Previous work, b/21904461, shows that there is a large performance
penalty for adding any amount of locking to properties, so moving
property service into its own thread generically is not a viable
option.  However, we can be sure that init is not setting properties
while the fs_mgr functions are running, so we can poll the property
socket in a thread while we call these functions.

The other alternative would have been to separate the fs_mgr functions
into smaller pieces and revisit the main init loop between each
piece.  Unfortunately, this would be difficult, since
fs_mgr_mount_all() calls out to different processes via logwrapper,
which synchronously polls on a logging FD from the child, among other
complexities that would make this strategy much more difficult than it
would be worth.

Bug: 21904461
Test: device boots, including when setting property in
      fs_mgr_mount_all()

Change-Id: Ib0b7123024035884f9d90f9b489c1e2f5a2e1707
2019-06-24 13:23:49 -07:00
Tom Cherry
af274fd086 Merge "init: use a property instead of file to communicate cold boot done" 2019-06-24 19:39:03 +00:00
Treehugger Robot
411fb88506 Merge "Qualifies the mention of lazily starting services from 'interface'." 2019-06-19 03:03:00 +00:00
Daniel Norman
d6d09c646a Qualifies the mention of lazily starting services from 'interface'.
The 'interface' option is not always used by services that support lazy
startup.

Test: None
Change-Id: I6bfb095d4ecb932933d56cd1859a5eff6df2edbd
2019-06-18 17:03:05 -07:00
Steve Muckle
18b981ea7c create libmodprobe, integrate into first_stage_init
Modprobe functionality is required both within first stage init and also
as a standalone binary. Create a library for this using and extending
the logic in modalias_handler.cpp.

First stage init will attempt to load modules from /lib/modules.

Bug: 129780532
Change-Id: Ie3582358fd839c2f64e1b386b30ed551a86aef5d
2019-06-18 13:24:56 -07:00
Tom Cherry
f4db2aad57 init: use Errorf() now that we have it
Init had some pretty horrid Error() << StringPrintf(...) calls that
are all much better replaced by Errorf(...) now.

Test: build, check that keyword_map errors look correct
Change-Id: I572588c7541b928c72ae1bf140b814acdef1cd60
2019-06-14 22:07:32 +00:00
Dongcheol Shin
a87c0f99ad Support importing property file with expanded name
This change is to support importing property file with its path
variations.

By substitute its filename with another, it can be used to handle
runtime varying filename within single binary.

Here's an example of usage in property defined file.
    import /odm/build_${ro.boot.product.hardware.sku}.prop

Bug: 132592551
Test: boot a device and checks above example import statement in
    "/odm/build.prop" loading expanded filename correctly

Change-Id: If3fdcf620a5d717e0930b1e4e58261bc8f79ec24
2019-06-13 23:40:23 +00:00
Treehugger Robot
b3093ff21a Merge "Read *.rc files from flattened APEX" 2019-06-11 12:11:11 +00:00
Tom Cherry
39fafedc5a init: use a property instead of file to communicate cold boot done
Ueventd can't set properties currently, but this is an artificial
limitation, since ueventd communicates to init that it has finished
cold boot via a file, and init polls this file instead of returning to
the epoll loop, where properties are handled.

This change replaces that file with a property and thus frees ueventd
to be able to set properties.

Bug: 62301678
Test: boot, check that properties are set
Change-Id: I985688e9299456efcb2dfeef9b92668991aa9c05
2019-06-10 18:08:01 -07:00
Tom Cherry
bbcbc2ffb3 init: replace Result<Success> with Result<void>
Now that Result<T> is actually expected<T, ...>, and the expected
proposal states expected<void, ...> as the way to indicate an expected
object that returns either successfully with no object or an error,
let's move init's Result<Success> to the preferred Result<void>.

Bug: 132145659
Test: boot, init unit tests
Change-Id: Ib2f98396d8e6e274f95a496fcdfd8341f77585ee
2019-06-10 12:39:18 -07:00
Jiyong Park
d2217b5167 Read *.rc files from flattened APEX
This change fixes a bug that *.rc files in APEXes are not read when the
APEXes are flattened. This was because init used "/apex/*@*/etc/*.rc"
glob pattern to find the files, which gives 0 result with flattened
APEXes; with flattend APEXes /system/apex is just bind-mounted to /apex,
and therefore, the name@version directories don't exist.

Fixing the issue by globing /apex/*/etc/*.rc and filter-out the paths
with @ to avoid double parsing the *.rc files in case of non-flattend
APEXes.

Bug: 134067086
Test: revert I75ec6b69cca1cef071b50fac9a4cf8b8ceddb142
build sdk_gphone_x86_64 and record a video in the camera app.
The recording works. `ps -A | grep media.swcodec` shows media.swcodec process.
`atest CtsStatsdHostTestCases:android.cts.statsd.atom.UidAtomTests#testAudioState` passes
Test: build sdk_phone_x86_64 and do the same.

Change-Id: I00af1910a8e8a330addc4c6903e5f3695aeb6865
2019-06-10 13:06:39 +09:00