Commit Graph

2701 Commits

Author SHA1 Message Date
Tom Cherry 64ae77e526 Merge "init: chroot from recovery to /first_stage_ramdisk" 2018-11-09 17:01:41 +00:00
Tom Cherry 56999b41af init: chroot from recovery to /first_stage_ramdisk
When using the recovery image as a trampoline to boot the system,
first chroot from the recovery image to /first_stage_ramdisk, to
minimize differences between these two boot paths.

Primary motivation is due to the fact that the basename of each mount
point is used by device-manager to name its nodes, and the previous
code that created used /system_recovery_mount as the mount point for
system.img broke AVB.  Instead of hacking around that issue, this
change unified mounting for the recovery trampoline and true first
stage ramdisk paths.

Bug: 114062208
Test: AVB works with blueline_mainline
Change-Id: Iffb154962b6e160150917e068f1e7d0bf7cb84e7
2018-11-08 15:47:36 -08:00
Treehugger Robot 76b420f38d Merge "Fix bootchart" 2018-11-07 07:36:35 +00:00
David Anderson f89b1df1a5 init: Regenerate uevents for dependent super partition devices.
This patch adds another uevent-regeneration pass to the first stage
mount. When the super partition spans multiple block devices, we need
/dev/block/by-name symlinks to have been created before we begin mapping
dynamic partitions.

Bug: 116802789
Test: retrofit device boots
Change-Id: I00bb277e1d81385a457c5b4205a95d8fbe365bb2
2018-11-05 17:53:49 -08:00
Treehugger Robot 82c88d9b00 Merge "ueventd: don't skip restorecon after the cold boot" 2018-11-02 22:57:27 +00:00
Oleksiy Avramchenko dd5802a27e ueventd: don't skip restorecon after the cold boot
We need to do restorecon after the cold boot, otherwise the newly
created sysfs nodes won't be labelled.

Bug: 118861992
Test: manual - do insmod, check sysfs nodes are properly labelled
Change-Id: I4bdfb4a68206724a568d8cbb6c644ba8764b5fa7
2018-11-02 15:43:11 +00:00
Evgenii Stepanov 1f47f4add4 Do not hwasanitize init_first_stage.
Current hwasan implementation breaks when stderr (fd 2) is missing.

Bug: 118776698
Test: hwasan boots without serial console
Change-Id: Id095a87212096526a497563adab3d7f2f9fe8ab0
2018-11-01 13:43:50 -07:00
Peter Collingbourne 166ae693d4 Merge "Introduce additional service options for controlling memory cgroups." 2018-11-01 17:55:34 +00:00
Justin Yun 6bab0a9c23 Mount vendor overlay from the system partition
Using overlayfs, the system partition may provide files for older
version of vendor partitions by overlaying on the vendor partition.
Directories in /system/vendor_overlay will be overlaid on the
directories in /vendor to override existing files or provide new
files.

This feature works only if the kernel support overlayfs and has a
patch for override_creds. Otherwise, no-op.

Bug: 114679254
Test: Build and boot: nothing affected without overlayfs, or
                      vendor file is overrided with overlayfs

Change-Id: Iff3a308945299034123ba7bcb40dc787e102730e
2018-11-01 10:26:12 +09:00
Peter Collingbourne d7157c22af Introduce additional service options for controlling memory cgroups.
The memcg.limit_percent option can be used to limit the cgroup's
max RSS to the given value as a percentage of the device's physical
memory. The memcg.limit_property option specifies the name of a
property that can be used to control the cgroup's max RSS. These
new options correspond to the arguments to the limitProcessMemory
function in frameworks/av/media/libmedia/MediaUtils.cpp; this will
allow us to add these options to the rc files for the programs that
call this function and then remove the callers in a later change.

There is also a change in semantics: the memcg.* options now have
an effect on all devices which support memory cgroups, not just
those with ro.config.low_ram or ro.config.per_app_memcg set to true.
This change also brings the semantics in line with the documentation,
so it looks like the previous semantics were unintentional.

Change-Id: I9495826de6e477b952e23866743b5fa600adcacb
Bug: 118642754
2018-10-31 17:09:59 -07:00
Victor Chang 6b15a6b1ad Fix bootchart
Found the following 2 binary is not in the path
system/core/init/grab-bootchart.sh: line 20: bootchart: command not found
system/core/init/grab-bootchart.sh: line 21: gnome-open: command not found

Use a more commonly available command to create bootchart

Test: system/core/init/grab-bootchart.sh started a bootchart
successfully

Change-Id: I6d5b4a692af2fd53ea636b768f55c697586e6898
2018-10-31 21:00:19 +00:00
Eric Biggers 82c6ba74e2 Merge "init: use libfscrypt for file-based encryption setup" 2018-10-29 17:19:39 +00:00
Tom Cherry 668f70f6ef Merge "init: fix error messages when an invalid section header is found" 2018-10-26 22:31:52 +00:00
Tom Cherry 0166fd606d init: fix error messages when an invalid section header is found
If a section header such as 'on' or 'service' has an error with it,
the rest of the commands / options are currently reported as errors
since there is no valid parser object to parse them.  For example,

service !@#$%%^&*() /system/bin/false
    user root
    group blah
    blah blah

Generates:

init: /system/etc/init/bad.rc: 2: invalid service name '!@#$%%^&*()'
init: /system/etc/init/bad.rc: 3: Invalid section keyword found
init: /system/etc/init/bad.rc: 4: Invalid section keyword found
init: /system/etc/init/bad.rc: 5: Invalid section keyword found

This change suppresses the extraneous 'Invalid section keyword found'
messages.

Test: faulty error messages are suppressed.
Change-Id: Ieeb2d5b8b7eea33e191a88ce5a0d41701686943f
2018-10-26 12:33:52 -07:00
Tom Cherry fa79ae87f1 init: allow vendor init to action on any vendor or odm property
Partial revert of "init: if vendor_init can read a property, let it be
a trigger too" (b35f827c97).

We made a mistake when we allowed vendor init to action on any vendor
or odm property, since when a new SELinux label is created for a
vendor property, vendor_init does not automatically get read
permissions for it.

Recently, we tried to use read permissions instead of the built-in
list in init, but that broke due to the above mistaken.  Since we have
already launched with these permissions as is, we must restore them.

Bug: 118457755
Test: no denials for vendor init actionable properties on crosshatch
Change-Id: I7a9a560c9a54a177c6b83d28309e2f288f05d400
2018-10-26 08:50:45 -07:00
Eric Biggers f05da4a4be init: use libfscrypt for file-based encryption setup
The file-based encryption setup code is being refactored into its own
library because it applies to both ext4 and f2fs, not just ext4.  Update
init to use the new location.   For fs_mgr, just remove the include of
ext4_crypt_init_extensions.h since it was unneeded.

Test: built, booted device with f2fs encryption
Change-Id: I392a763e3349f001bdbc09eb9ca975aa3451fd68
2018-10-25 17:10:15 -07:00
Tom Cherry b35f827c97 init: if vendor_init can read a property, let it be a trigger too
There is a list of 'stable_properties' that vendor_init can use as
property triggers for Treble property compliance.  This list came about
since init parses init scripts before all partitions are mounted and
therefore before all property context files are available, such that
init cannot use the normal SELinux mechanisms for determining if a
given property is vendor_init readable.

Currently though, we require all partitions that would contain
property context files to be mounted during first stage mount, so we
can use the normal SELinux mechanisms here, so this change deprecates
the stable_properties list and moves init to use SELinux to determine
if a property can be a trigger.

Bug: 71814576
Test: vendor_init fails to use non-readable properties as a trigger
Test: vendor_init successfully uses readable properties as a trigger
Change-Id: I6a914e8c212a3418cbf4a8a07215056aad2e0162
2018-10-22 16:16:03 -07:00
Tom Cherry 5083be5d72 Merge "init: Add some ASAN helpers" 2018-10-19 20:41:24 +00:00
Tom Cherry e0042419f8 init: Add some ASAN helpers
Init is special.

It starts early and does not pick up the Android ASAN options provided
on the environment.  Therefore we pull in /system/asan.options in
explicitly if it exists.  We provide sane defaults that will allow the
system to boot otherwise.

Logging is complicated because it needs to go to the kernel log.
So use sanitizer functions to install log functions.

Bug: 117879229
Test: m && m SANITIZE_TARGET=address
Test: init boots with ASAN enabled
Change-Id: I72c033a1f86ba5d6b2e4f943e7a3acd0d399c8bf
2018-10-19 11:18:58 -07:00
Tom Cherry 7a08c896dd Merge changes Iea270320,Ib9063185
* changes:
  init: allow properties to be used for the keycodes option
  init: use rvalues references for callees of ParseLineSection()
2018-10-19 15:43:43 +00:00
Nick Kralevich 2991949001 Add O_CLOEXEC
Prevent an FD from accidentally leaking across an exec() boundary.

Test: code compiles.
Change-Id: I90ca6e332802700403f401db016cc6c0c72b0ea3
2018-10-18 16:09:40 -07:00
Tom Cherry 791668462a init: allow properties to be used for the keycodes option
Bug: 117828597
Test: bugreport launches with a test property set to appropriate keys
Test: bugreport doesn't launch with the test property unset
Test: no errors seen in build or boot in either of the above cases
Change-Id: Iea27032080a0a7863932b1c1b573857ac66b56b5
2018-10-17 11:30:53 -07:00
Tom Cherry 018a438ff0 init: use rvalues references for callees of ParseLineSection()
ParseLineSection() provides 'args' as an rvalue reference, so its
callers can and should use it as such.  This saves some copying
overhead and cleans up the code a bit.

Test: boot
Change-Id: Ib906318583dc81de9ea585f5f09fdff35403be1b
2018-10-17 11:30:53 -07:00
Tom Cherry 89bf115a70 Merge "init: separate init packaging for mainline" 2018-10-16 20:29:47 +00:00
Tom Cherry 29e5348f18 init: separate init packaging for mainline
With system-as-root, both first and second stage init belong to
system, but without system-as-root, first stage belongs to vendor and
second stage belongs to system.  This change creates two phony
packages to achieve this correctly in the build system.

Bug: 117606184
Test: mainline builds work properly
Change-Id: I19263e76c217c2e70bc06c180be3a460e9144f18
2018-10-16 09:49:00 -07:00
Tom Cherry ad9e7eaf2d init: clarify some text/README about 'critical' services
'Critical' services have rebooted into bootloader, like all other
catastrophic init crashes, for years now.  Update the text to match.

Test: n/a
Change-Id: Icfc41bf3e383958f14ecfaab9ca187e2c3dc7fd9
2018-10-15 17:21:48 -07:00
Steven Moreland 48aed8f02d init: clarify multiple 'interface' keyword use
This keyword can (and should) be used multiple times when multiple
services are served together. I've documented this here.

Bug: N/A
Test: N/A
Change-Id: Ie986c9cac486db346555f359e9ccbed93d8d1d22
2018-10-15 18:00:36 +00:00
Minchan Kim d37dd4a6f0 Merge "export dumpstatez into stable_properties" 2018-10-12 07:23:23 +00:00
Tom Cherry 4c67290da6 Merge "init: add [[nodiscard]] to Result" 2018-10-11 20:34:04 +00:00
Tom Cherry d987264625 init: add [[nodiscard]] to Result
It's better to either check these results or explicitly ignore them.
Only a few callers weren't already doing this, so it's relatively
trivial to enforce.

Test: build
Change-Id: I44cdc342e46128f66cac914aaa0b9b4559cacd8c
2018-10-11 10:39:33 -07:00
Minchan Kim b7f6c5a1cd export dumpstatez into stable_properties
Vendor might want to pause/resume some operations while a bugreport is captured
so that we need to export dumpstatez into stable_properties.h for vendor to get
property event when dumpstatez launch.

Test: confirmed manually with "adb bugreport"
Bug: 117536084
Change-Id: Ib743c5e59ca20cc44470110c814d85e4cbb90c0c
Signed-off-by: Minchan Kim <minchan@google.com>
2018-10-11 18:02:58 +09:00
Wei Wang b5de088262 init: increase thermal shutdown timeout to 3s
1) increase thermal shutdown timeout to 3s for process to save work
2) respect property "ro.build.shutdown_timeout" in thermal shutdown if
   it is set less than default time - "3s"

Bug: 112432890
Test: Build
Change-Id: Idc2b24dd44c1fab8f9b047fd2468de2ee45ff783
2018-10-09 12:53:30 -07:00
Tom Cherry 64990d5b45 Merge "init: move InitKernelLogging() to first stage init" 2018-10-05 20:41:23 +00:00
Tom Cherry 48e83e629f init: move InitKernelLogging() to first stage init
The kernel opens /dev/console and uses that fd for stdin/stdout/stderr
if there is a serial console enabled and no initramfs, otherwise it
does not provide any fds for stdin/stdout/stderr.  InitKernelLogging()
is used to close these existing fds if they exist and replace them
with /dev/null.

Currently, InitKernelLogging() is only called in second stage init,
which means that processes exec'ed from first stage init will inherit
the kernel provided fds if any are provided.

In the case that they are provided, the exec of second stage init
causes an SELinux denial as it does not have access to /dev/console.
In the case that they are not provided, exec of any further process is
potentially dangerous as the first fd's opened by that process will
take the stdin/stdout/stderr fileno's, which can cause issues if
printf(), etc is then used by that process.

Lastly, simply moving InitKernelLogging() to first stage init is not
enough, since first stage init still runs in kernel context and future
child processes will not have permissions to access kernel context
resources.  Therefore, it must be done for a second time in second
stage init.

Bug: 117281017
Test: no audits when booting marlin.
Change-Id: If27edab5c32b27765e24c32fbed506ef625889de
2018-10-05 10:36:38 -07:00
Chih-Hung Hsieh 747eb149d0 Add noexcept to move constructors and assignment operators.
Bug: 116614593
Test: build with WITH_TIDY=1
Change-Id: I5a7461386946ca623ab509609092aa0ac8418b80
2018-10-05 16:43:47 +00:00
Tom Cherry 5f2a21d244 Merge "init: allow customizable restart and timeout periods for services" 2018-10-05 16:15:23 +00:00
Tom Cherry 73f535e33b init: allow customizable restart and timeout periods for services
Allow services to specify a custom restart period via the
restart_period service option.  This will allow services to be run
periodically, such as a service that needs to run every hour.

Allow services to specify a timeout period via the timeout_period
service option.  This will allow services to be killed after the
timeout expires if they are still running.  This can be combined with
restart_period for creating period services.

Test: test app restarts every minute
Change-Id: Iad017820f9a602f9826104fb8cafc91bfb4b28d6
2018-10-04 19:52:37 -07:00
Mark Salyzyn e511e3a3b1 fs_mgr: Add fs_mgr_overlayfs_required_devices()
Added fs_mgr_overlayfs_required_devices() as hint to init to make sure
the device gets created before fs_mgr_overlayfs_mount_all().

Test: manual
Bug: 109821005
Change-Id: Iab038f3e0252a357b082bb08db3679512b9badec
2018-10-04 15:15:02 -07:00
Treehugger Robot 02678f32be Merge "Don't hardcode the super partition name." 2018-10-04 19:29:34 +00:00
Treehugger Robot 29e9833e39 Merge "fs_mgr/init: use unique_ptr + CLO_EXEC for setmntent()/fopen()" 2018-10-03 21:22:50 +00:00
Tom Cherry f274e78eeb fs_mgr/init: use unique_ptr + CLO_EXEC for setmntent()/fopen()
We ran into an issue with an fd leaking due to missing both CLO_EXEC
and fclose() in related code, so let's make sure we're safe here too.

Test: boot
Change-Id: Ief893c936859815c78fa6d7e06cb88ad34aadbac
2018-10-03 13:19:04 -07:00
Treehugger Robot 8bd7d5238f Merge "init: IsDmLinearEnabled() replace with check if logical partitions present in fstab" 2018-10-03 20:03:26 +00:00
Tom Cherry 32638a1ef6 Merge "init: clarify why we mount /mnt/... in first stage init" 2018-10-02 21:55:08 +00:00
Tom Cherry 21824dddeb init: clarify why we mount /mnt/... in first stage init
Test: n/a
Change-Id: I55974fb285c55756536d038f4e20cb45d11906ee
2018-10-02 10:21:03 -07:00
David Anderson 5cbd2e43ee Don't hardcode the super partition name.
If a device has logical partitions but does not use a partition called
"super", we will need this to be configurable. Note that the "slot"
argument is currently unused, but will be necessary for update_engine if
there are A and B super partitions.

Bug: 116608795
Test: super partition works
Change-Id: Ieb548a158faeb423f3561230f26d582325efbc6b
2018-10-01 14:13:22 -07:00
Tom Cherry e3745bc57a Merge "init: use '/system' as the system mount point for force_normal_boot" 2018-09-27 00:35:22 +00:00
Mark Salyzyn 9b1e7a34b9 init: IsDmLinearEnabled() replace with check if logical partitions present in fstab
IsDmLinearEnabled() true if logical partitions present in fstab.

Test: boot on logical device
Bug: 109821005
Change-Id: Ic083b0b8d9f7e9511d78bdc05c9f848521f1feb5
2018-09-26 21:04:24 +00:00
Tom Cherry c382957789 init: use '/system' as the system mount point for force_normal_boot
We need to keep the right mount points in the fstab for other
processes to access (/ for system-as-root or /system otherwise).
Force_normal_boot devices are defacto not system-as-root,
since they're booting through the recovery ramdisk and therefore must
use /system as the system mount point.

Bug: 114062208
Test: boot pixel from recovery with force_normal_boot
Change-Id: Ib0e4e4f8a29299ecdcd35e8f1415551c4c9745ad
2018-09-26 13:27:16 -07:00
Treehugger Robot 5952034c25 Merge "Set device lock status from kernel command line." 2018-09-26 02:02:13 +00:00
Hridya Valsaraju 5ed32780b4 Set device lock status from kernel command line.
Device is considered to be unlocked if
androidboot.verifiedbootstate is "orange".

Test: adb shell getprop ro.boot.flash.locked

Change-Id: Id3aeec757908ea63a37e28ad880a6c71d53083ac
2018-09-25 15:49:59 -07:00
Treehugger Robot 37d8bbdf9c Merge "fs_mgr: init: adb: add fstab argument to fs_mgr_overlayfs_mount_all" 2018-09-25 20:37:15 +00:00
Treehugger Robot 6544056d54 Merge "Support 'adb reboot fastboot' command conditionally." 2018-09-25 17:17:08 +00:00
Mark Salyzyn f35db9b11b fs_mgr: init: adb: add fstab argument to fs_mgr_overlayfs_mount_all
Add an fstab argument for fs_mgr_overlayfs_mount_all so that it can
leverage the locally and timely acquired fstab entries.  Affects all
callers, adb and init.

Test: manual
Bug: 109821005
Bug: 115751838
Change-Id: I96e2045d88525a6ce39bef63327a0fcf0704e9bc
2018-09-25 07:30:55 -07:00
Hridya Valsaraju 542582689d Support 'adb reboot fastboot' command conditionally.
Devices not supporting logical partitions do not require the command.

Bug: 78793464
Test: 'adb reboot fastboot' reboots to bootloader for a device
not supporting logical partitions.

Change-Id: I0a7b6d4335040e24efbf461e2dd2d56ab1985b7f
2018-09-25 03:52:12 +00:00
Treehugger Robot f86e85cb0a Merge "init: Cleanly exit subcontext processes upon init's death" 2018-09-22 00:12:09 +00:00
Luis Hector Chavez 7235359d2e init: Cleanly exit subcontext processes upon init's death
This change makes the subcontext processes cleanly exit in the event of
the init's socket being closed. If that was an accident, init will
respawn the process immediately. Otherwise, it will just quietly go
away.

Bug: 80425914
Test: kill -9 $INIT_PID  # Outside of an Android container
Change-Id: I664f11d1b3700ea46857abf24857335fe28e92fa
2018-09-21 12:29:52 -07:00
Treehugger Robot 903eb5125e Merge "init: annotate intended fallthrough" 2018-09-20 00:07:24 +00:00
Tom Cherry ae8a6b9af3 init: annotate intended fallthrough
Bug: 116020901
Test: treehugger
Change-Id: I5f4a5ebf09572501f564dce506ee0978354fde67
2018-09-19 14:34:51 -07:00
Tom Cherry d9e53dacf5 init: move selinux and seccomp set up to 2nd stage init.
If there is no valid pre-compiled SEPolicy policy, init may call
secilc, which exists on the system partition.  1st stage init won't
always live on this partition, so we need to move this SELinux setup
to 2nd stage init, which always lives on the system partition, to
ensure that both secilc and its caller are updated together.

Bug: 114059212
Test: hikey boots, sailfish boots
Change-Id: Iaf7b4af4a5c2ace16755ec2e54510ab95c53f041
2018-09-18 11:24:56 -07:00
Treehugger Robot 146fd24c4b Merge "Fix clang-tidy performance warnings in system/core." 2018-09-18 17:32:20 +00:00
Chih-Hung Hsieh 42bf30651b Fix clang-tidy performance warnings in system/core.
* Use more efficient overloaded string methods.

Bug: 30411878
Test: build with WITH_TIDY=1
Change-Id: I449347565f83fae14ea337d0b3173beb5a56e0ca
2018-09-17 15:18:57 -07:00
Xin Li 17216455ad Don't attempt to create 'mkdir' and '-p' directories.
Test: build
Bug: 115920063
Change-Id: I65c60bfe0ca758a4213f10754bc872ea9885ca19
2018-09-17 14:20:16 -07:00
Tom Cherry bbb1d1a698 init: allow using the recovery image for 1st stage init
For A/B devices, the recovery image is typically provided as a ramdisk
paired with boot.img.  Instead of repartitioning these devices to have
a separate recovery partition and have the new 1st stage ramdisk
paired with the boot.img, this allows setting
androidboot.force_normal_boot=1 on the kernel command line to have init
in recovery boot directly to a normal boot.

This requires /system_recovery_mount to be added in the DT fstab for
the system partition.

Bug: 114062208
Test: hikey boots
Change-Id: I1e331b5cca91152d20ca92549779ab41aa9cd431
2018-09-13 23:45:58 +00:00
Martijn Coenen 62e985a954 init: Allow restricted use of binder.
Allow init to use binder, but in a restricted way:
- No binder threadpool
- Other processes can't initiate calls to init
- No death recipients

This change adds libbinder/libutils and calls into ProcessState,
which also calls into the kernel driver and sets up state there.
No other binder calls are made, so that we can let this soak for
a while to see if there any bad side effects of just loading
these libraries and initializing the kernel driver.

This introduces about 120kB of additional memory usage (PSS),
mostly due to pulling in libbinder and libutils and the private
state they have.

We also don't include these libraries in the recovery version of
init, because space on the recovery partition is limited.

Bug: 112684055
Test: device still boots, /d/binder/proc/1 shows init state
Change-Id: I972b1eebdb16337f52e20d1f614e3a0dce0f06d2
2018-09-07 15:47:21 +02:00
Mark Salyzyn eafc1c3d58 init: First Stage Mount observe nofail mount flag
MountPartitions should respect nofail.  The nofail flag makes the
partition optional.

Test: manual (future code using feature), and smoke test
Bug: 109821005
Bug: 78914864
Change-Id: I715a66ef1abbe223b0cefe5bd2758f63352b1afc
2018-08-30 13:16:24 -07:00
Tom Cherry 7b02605bf2 Merge "Switch root to /system in first stage mount" 2018-08-29 17:05:40 +00:00
Nick Kralevich 7ab971acf4 keychords.cpp: O_RDWR -> O_RDONLY
The keycodes functionality in init only needs to read key events. It
doesn't need to inject key events. A read-only file descriptor is
perfectly sufficient.

Test: pressing volume-up/volume-down/power still generates a bugreport
Change-Id: Iecbf21c544914334006ac6258c03df390f417e80
2018-08-27 12:20:34 -07:00
Tao Bao a3d36a8ce7 init: Build init_tests only for the first arch.
Not all the dependent shared libs are installed on device with both
arches. For example, we don't have 32-bit `libfs_mgr.so` or
`libbootloader_message.so` on marlin, which would cause 32-bit
`init_tests` to fail.

Bug: 112494634
Test: Run (64-bit) init_tests on marlin.
Test: `m -j continuous_native_tests` with aosp_marlin-userdebug. Check
      that only 64-bit init_tests is included in
      `continuous_native_tests.zip`.
Change-Id: I999d58750d48c34df7dbabccf8863a6ccaf0b83c
2018-08-24 11:28:54 -07:00
Tao Bao 66209ca9bf init: init_defaults uses more shared libraries.
This CL switches init_defaults and thus init_second_stage to depend on
commonly used shared libraries. In particular, use the following shared
libs that have been available on device (under both of normal boot and
recovery):
 - libbootloader_message
 - libext4_utils
 - libfs_mgr
 - libhidl-gen-utils
 - libkeyutils
 - liblogwrap

The following transitive dependencies have been dropped. They were only
needed when including the above libs statically. Dropping them doesn't
further affect the size though.
 - libfec
 - libfec_rs
 - libsquashfs_utils

With the change, the second stage init size has been reduced from
1094328 to 627992 bytes (aosp_taimen-userdebug), with no new shared libs
installed.

Also evaluated the impact of using `libprotobuf-cpp-lite.so` and
`libseccomp_policy.so`. It doesn't look beneficial -- at least not right
now with `init` as the singler user.
 - statically linked them both: 627992-byte
 - with libprotobuf-cpp-lite.so: 605880 (init) + 262624 (.so)
 - with libseccomp_policy.so: 605848 (init) + 32208 (.so)

Bug: 112494634
Test: `mmma -j system/core/init` with aosp_marlin-userdebug
Test: Flash the marlin build on device. Run init_test.
Test: Boot into recovery successfully.
Change-Id: I49debe9066ff36dfda55b08266862e29e2bfc96b
2018-08-24 10:54:24 -07:00
Tom Cherry 4590a2aeb7 Switch root to /system in first stage mount
Bug: 79173823
Bug: 79758715
Test: boot hikey and observe that /system is the new root
Change-Id: I22f58f1332150ebae8e7e24eccfe780ff29eba7f
2018-08-23 11:12:57 -07:00
Tom Cherry d68121f670 Merge "init: always allow clearing a property" 2018-08-23 01:59:45 +00:00
Tom Cherry 2096558837 init: always allow clearing a property
An unintended consequence of property types is that it makes clearing
a property, by setting it to an empty string, impossible.  This change
explicitly allows that case:

Test: new (and old) unit tests
Change-Id: I188693bfd3a71b64c194c3858544230b87d8d891
2018-08-22 15:41:56 -07:00
Tom Cherry ab434c70ce init: accept -1 or 'unlimited' for an infinite rlimit
Due to a bug with ParseUint(), init would defacto accept -1 for an
infinite rlimit, but only on 64bit devices.  That bug is now fixed,
such that -1 would be rejected by ParseUint() for all devices.

This change explicitly checks for -1 for all devices or 'unlimited' to
match ulimit's reporting and accepts either as an infinite rlimit.

Bug: 112668205
Test: new (and old) unit tests
Change-Id: Ie28ff622cdf375a65ceb5f32ffb14fb3d5d9f2ba
2018-08-22 15:07:53 -07:00
Dario Freni ab5583b585 s/product-services/product_services/g
Attempting to reduce the number of different spellings we have for
"product services" partition in the codebase.

Bug: 112431447
Test: m
Change-Id: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71
Merged-In: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71
2018-08-20 17:46:42 +00:00
Anton Hansson 904bbd8405 Remove init_second_stage.recovery dep.
This makes the init module only produce artifacts in
/system. A simultaneous change in the core product
makefiles explicitly adds init_second_stage.recovery.

Bug: 112318375
Test: lunch mainline_arm64 && m nothing
Change-Id: I33f0f0c869dfb1ffe781fc682eeb20589a4ffe90
2018-08-15 08:50:43 +01:00
Treehugger Robot 3231be66ce Merge "Add sideload, fastboot as reboot targets in init" 2018-08-14 21:25:50 +00:00
Mark Salyzyn d88b52e7f4 Merge changes from topic "squashfs+overlayfs"
* changes:
  init: add fs_mgr_overlayfs_mount_all to FirstStageMount
  adb: add overlayfs handling for readonly system filesystems
  fs_mgr: get fs_mgr_mount_all to call fs_mgr_overlayfs_mount_all
  fs_mgr: add overlayfs handling for squashfs system filesystems
2018-08-09 20:44:20 +00:00
Tom Cherry e85b2addca init: clarify comment for the restorecon of second stage init
Test: we actually do need this restorecon for recovery.
Change-Id: I46a8d6ea5c08b18d79fa6dd8df0f4a98695363e2
2018-08-09 10:40:51 -07:00
Mark Salyzyn 934db8a4a5 init: add fs_mgr_overlayfs_mount_all to FirstStageMount
Test: compile & smoke
Bug: 109821005
Bug: 110985612
Change-Id: I51a4b7fc123e736035f74e126f71288721dc9fab
2018-08-08 15:42:46 -07:00
Xin Li 5d707816ac Merge "Merge Android Pie into master" 2018-08-07 16:51:24 +00:00
Tom Cherry 31438489c0 split first stage init into a separate executable
In the future, systems with dm-linear will require a ramdisk to set up
the mount for system.  In this world, first stage init will be a part
of this ramdisk and handle setting up dm-linear, mounting the
necessary partitions, then pivoting to the system image, which will
become the root partition.

This also enables previous devices without system-as-root, to be
unified with system-as-root devices for all aspects of boot after the
pivot_root.

Bug: 79758715
Test: boot hikey
Test: boot sailfish, boot sailfish into recovery
Change-Id: Iefa88a3ec5994e7989aa9f26f2de0351ffa5468b
2018-08-06 10:36:43 -07:00
Tom Cherry 5744e4d7d2 Merge "Split init's source files init first stage and second stage"
am: e0f6dc46d8

Change-Id: Iec525d3fb0e09550895d67709ed958f8337d9e34
2018-08-03 16:00:05 -07:00
Tom Cherry 44aceed016 Split init's source files init first stage and second stage
This is a baseline for splitting init first and second stage into
their own executables.

Bug: 79758715
Test: sailfish boots
Change-Id: I549ad4502893b3a5e4c2a9886f66850f6d31b619
2018-08-03 13:40:17 -07:00
Tom Cherry 3676564019 Merge "Move watchdogd out of init"
am: 132615b803

Change-Id: Icfc2511dfa3b905e25d6b8187557871960c0f9b1
2018-08-03 12:37:22 -07:00
Tom Cherry 132615b803 Merge "Move watchdogd out of init" 2018-08-03 19:28:14 +00:00
Hridya Valsaraju 71fb82a271 Add sideload, fastboot as reboot targets in init
Rebooting to these targets requires writing bootloader
messages and thus root. Moving them into init means that
adb, reboot don't need root to use these targets.

Test: try rebooting to these targets
Bug: 78793464
Change-Id: Ia002d1e3b1cb0c0616f60435fb9af4dce162cf84
2018-08-03 10:03:41 -07:00
Tom Cherry 106e66e475 Merge "ueventd: require opt-in for modalias handling"
am: d52b17ff0a

Change-Id: Id827bf76f889ebd996954448648365d20350ca01
2018-08-02 12:32:55 -07:00
Tom Cherry 40acb379cd Move watchdogd out of init
We're moving past a world where static executables are needed,
including watchdogd, so treat this like any other executable and place
it in /system/bin.

Bug: 73660730
Test: watchdogd still runs
Change-Id: I1f7508fd55dce6e9ee72a6ab7a085011a76c0053
2018-08-02 12:25:58 -07:00
Tom Cherry d52b17ff0a Merge "ueventd: require opt-in for modalias handling" 2018-08-02 19:22:13 +00:00
Tom Cherry 780d80b5a6 Merge "init: run fsck for early mount partitions"
am: 6e05552e35

Change-Id: I6b44584616557ef3c58039eff6ce7eaf3c2d7623
2018-08-01 14:11:19 -07:00
Tom Cherry 6e05552e35 Merge "init: run fsck for early mount partitions" 2018-08-01 21:02:35 +00:00
Tom Cherry 457e28f129 ueventd: require opt-in for modalias handling
Some devices have modules.alias and modules.dep for modprobe and other
purposes but do not want to opt into ueventd auto loading their
modules.  Therefore we add a flag that can be added to ueventd
configuration files to opt into this behavior.

Bug: 111916071
Bug: 112048758
Test: check that modules are loaded with this opt-in
Test: check that modules are not loaded without this opt-in
Change-Id: Ifb281b273059b4671eea1ca5bc726c9e79f3adfb
2018-08-01 13:29:05 -07:00
Tom Cherry 81ae07509d init: run fsck for early mount partitions
Bug: 111883560
Test: fsck runs successfully during early mount
Change-Id: I19bcd2610f87f5331f94c228fcbec8f9379fc5e8
2018-07-31 13:58:17 -07:00
David Anderson 4444219482 Merge "liblp: Allow building liblp as a shared library."
am: 2756339c77

Change-Id: I20ea48eff3843461cdc00c470643088d350195f6
2018-07-28 15:57:51 -07:00
Treehugger Robot 2756339c77 Merge "liblp: Allow building liblp as a shared library." 2018-07-28 22:52:23 +00:00
Luis Hector Chavez 01448be93e Merge "init: Cleanly shut down subcontext processes"
am: f6b823141e

Change-Id: Ic1cf8485da1baec8fd329e3e3ff59029140603e2
2018-07-27 19:36:08 -07:00
David Anderson f792e4163d liblp: Allow building liblp as a shared library.
Bug: 79173901
Test: system image, partition_tools both build
Change-Id: I70f45d4cebfbddc39d03aa3fb3a56b6c48a20d7e
2018-07-27 19:34:56 -07:00
Treehugger Robot f6b823141e Merge "init: Cleanly shut down subcontext processes" 2018-07-28 02:30:22 +00:00
Jerry Zhang 3051d54902 Merge "Move recovery to /system/bin"
am: 0937a84521

Change-Id: Ic3f3eb82178e6c5af22945e3aaaac3f86beb4ec8
2018-07-27 13:34:11 -07:00
Treehugger Robot 0937a84521 Merge "Move recovery to /system/bin" 2018-07-27 20:25:53 +00:00
Luis Hector Chavez 92c49bcb30 init: Cleanly shut down subcontext processes
This change adds an explicit cleanup for the subcontext processes and
avoids them from respawning, which causes a bunch of LOG(FATAL)s when
the system is going down.

Bug: 80425914
Test: kill -TERM $INIT_PID, no crashes for subcontext inits

Change-Id: I135191d959c1dd921b102af316b24d2bc161d6c9
2018-07-27 11:19:44 -07:00
Treehugger Robot 18be1e2f7e Merge "Add support for /product-services partition." 2018-07-27 17:15:05 +00:00
Tom Cherry dd62c204da Merge "ueventd: Add dynamic kernel module loading"
am: 8b25b87074

Change-Id: I5163ae98e70cba3e89ea2ae538579f504e03256d
2018-07-26 15:08:21 -07:00
Dario Freni 3613710099 Add support for /product-services partition.
This CL is largely and adaptation of
Ie996def20e25dc1afe0c74af2096af844934b2dc

Bug: 80741439
Test: Successfully built product-services.img with one module in it, and
flashed on device. Also successfully built image with
/system/product-services and no dedicated /product-services partition.

Change-Id: I1046dfe19bf874da929c9131b76a1f85422fbb80
Merged-In: I1046dfe19bf874da929c9131b76a1f85422fbb80
2018-07-26 16:27:28 +00:00
Dario Freni d99a836380 Merge "Add support for /product-services partition." into stage-aosp-master 2018-07-26 16:16:38 +00:00
Andrew F. Davis 9963847419 ueventd: Add dynamic kernel module loading
For some platforms it is not known at build time what devices
will be attached at runtime. Building into the kernel or pre-loading
at init all the modules that could be needed would unnecessary bloat
the kernel. The solution is dynamic kernel module loading.

The kernel will generate uevents when devices are added, userspace
should monitor for these events and load the compatible modules.

The init process already monitors for uevents, add here the ability
to respond to modalias events and preform the correct action.

Adding this to init is preferred over an external program as we
can read and process the module alias and dependency files once,
instead of for each module needing to be loaded.

Test: Run on Beagle-X15, check all needed modules are loaded (lsmod)
Change-Id: I1b57d9aeb0a9770f309207183dc4bc2b7b905f14
Signed-off-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
2018-07-26 09:42:22 -05:00
Jerry Zhang 5de2be5cd5 Move recovery to /system/bin
Executables should be in /system/bin
rather than sbin. Change lookup paths
in a few places to reflect this.

Test: recovery is in system/bin
Bug: 78793464
Change-Id: Ibcdff7abf1f21e2566e02cad8bdb3c26ee500534
2018-07-24 21:42:23 -07:00
Tom Cherry 4d71e6fb45 Merge "init: fix typo in error message"
am: 2efcb522df

Change-Id: I36cc5ebced34cbd288123a71081997c909361890
2018-07-24 17:55:51 -07:00
Tom Cherry 8c901dda30 init: fix typo in error message
Test: none
Change-Id: Ie8417c7c6e3f6600544006c4a84b5bdfaff9725f
2018-07-24 15:54:33 -07:00
TreeHugger Robot c67c7f9a3a Merge "Revert "Use more shared libraries in adb and init."" into stage-aosp-master 2018-07-23 19:18:34 +00:00
Hridya Valsaraju 22c2202e75 Revert "Use more shared libraries in adb and init."
This reverts commit fbd79687e6.

Reason for revert: b/111734137

Change-Id: I70e23ed20d16821a555b448d4ac76fe9e130afa5
2018-07-23 17:48:57 +00:00
Dario Freni 4fa866a467 Add support for /product-services partition.
This CL is largely and adaptation of
Ie996def20e25dc1afe0c74af2096af844934b2dc

Bug: 80741439
Test: Successfully built product-services.img with one module in it, and
flashed on device. Also successfully built image with
/system/product-services and no dedicated /product-services partition.
Change-Id: I1046dfe19bf874da929c9131b76a1f85422fbb80
2018-07-23 16:14:36 +01:00
Tom Cherry 9ad886c3cb Merge "init: rename init_first_stage"
am: 1d2b29a902

Change-Id: Ic92fae3ca17b0f05eabd8172548f8072d0eb6060
2018-07-20 21:19:13 -07:00
Tom Cherry 3203244471 Merge "init: clean up logging initialization"
am: 258109ce4a

Change-Id: I4918bc14048dc9fed10293b7a15cfb3b059f6181
2018-07-20 21:18:36 -07:00
Tom Cherry 1272c0ec21 Merge "init: removed unused includes"
am: 21d03d83fa

Change-Id: I31669436a744cca21127e8321c39d02967cc81ea
2018-07-20 21:17:59 -07:00
Treehugger Robot 1d2b29a902 Merge "init: rename init_first_stage" 2018-07-21 02:47:36 +00:00
Tom Cherry 258109ce4a Merge "init: clean up logging initialization" 2018-07-21 02:01:14 +00:00
Tom Cherry f02506938e init: removed unused includes
Test: build
Change-Id: Ie3020491f67f6930acebe6397be6997b59477b96
2018-07-20 22:48:51 +00:00
Tom Cherry 38a11ccdd1 init: rename init_first_stage
In preparation for splitting first stage init from the rest of the
init executable, rename these files which are specifically involved in
first stage mount operations to a more appropriate name.

Test: builds
Change-Id: I8a2d4e8c7e1deea1bab45cc8e738727bc2ceb3e5
2018-07-20 15:31:36 -07:00
Tom Cherry 74069d1734 init: clean up logging initialization
Clean up a few mistakes in logging initialization

1) Only init needs to clear stdout/stderr/stdin, so remove this from
   ueventd, watchdogd, and subcontext init
2) Only init should reboot due to FATAL errors. This was true even
   before this change due to getpid() checks, but there's no reason to
   not just use the DefaultAborter for other processes.
3) It's probably a mistake for FATAL logs in init to try to gracefully
   shutdown the system, so simply call RebootSystem() here.
4) Lastly, remove log.cpp since it's not actually shared code anymore

Test: build
Change-Id: Ic8c323393dc7ee98ed6bb9691361b51d0d915267
2018-07-20 15:30:14 -07:00
Jerry Zhang fbd79687e6 Use more shared libraries in adb and init.
fs_mgr is used by several different
processes in both system and recovery,
so it makes sense for it to be a shared
library to save space.

libadbd is used by adbd, recovery (as minadbd)
and fastbootd so it should be shared as well.

Bug: 78793464
Test: compiles
Change-Id: I4225f4d1a44e6e5811c68a55595d1f94f0773114
Merged-In: I4225f4d1a44e6e5811c68a55595d1f94f0773114
(cherry picked from commit aacfc68acf)
2018-07-20 17:54:44 +00:00
David Anderson 37716f6c81 Merge "fs_mgr: Remove early prototype code."
am: 881be58f41

Change-Id: I4215c6e183ddbda94cbb0de77f271a68fe21640b
2018-07-19 16:39:56 -07:00
Treehugger Robot 881be58f41 Merge "fs_mgr: Remove early prototype code." 2018-07-19 23:32:33 +00:00
David Anderson 241506b00b Merge "init: Don't look for logical partitions via uevents."
am: 8ab1fd076d

Change-Id: Ic4019cf8dfb24df708104cac4c8d81597e4c1ecc
2018-07-19 14:51:38 -07:00
Treehugger Robot 8ab1fd076d Merge "init: Don't look for logical partitions via uevents." 2018-07-19 21:42:55 +00:00
David Anderson e0384bbc69 fs_mgr: Remove early prototype code.
This early code is no longer needed now that logical partitions can be
created and flashed normally.

Bug: 79173901
Test: N/A
Change-Id: I393ef23b3d3ce1cd9c80833358051838d0e9f333
2018-07-19 14:38:33 -07:00
David Anderson ab8414dd6c init: Don't look for logical partitions via uevents.
When using AVB, init's first stage regenerates uevent to find the paths
of block devices for verified partitions. If it can't find them all, it
will panic, causing the device to boot to recovery.

This does not work with logical partitions, since devices for those
partitions are created later in the first stage. In fact, they cannot be
created until uevent regeneration completes, since logical partitions are
are created by finding the "super" partition.

To address this we exclude logical partitions (as marked in fstab) from
the device finding process. Note that partitions moved from GPT to liblp
will no longer appear in by_name_symlink_map_.

Bug: 79173901
Test: AVB 2.0 device boots after deleting the vendor partition,
      creating a super partition, and flashing it with a dynamic
      vendor partition.

Change-Id: I19371b05912240480dc50864a2c04131258a7103
2018-07-19 14:38:27 -07:00
Tom Cherry e98e1f55be Merge "Fix loading ueventd.${ro.hardware}.rc."
am: 1fefb9f129

Change-Id: I7573922226736ece024e31e15fc1a7b9e2d08a9f
2018-07-19 08:09:29 -07:00
Sen Jiang d76f174a78 Fix loading ueventd.${ro.hardware}.rc.
Regression introduced in aosp/717324.

Bug: 111543389
Test: device boots further
Change-Id: I4cf57381104aa1a801cf82a42b1c5ae1a2273e89
2018-07-18 18:10:36 -07:00
Tom Cherry 97c0fd5287 Merge "ueventd: add a test for ueventd_parser.cpp"
am: bd130567f8

Change-Id: I7337e84645a9f18ffc263b681eca88285d95b69d
2018-07-18 10:04:04 -07:00
Tom Cherry 5f0198bfbb ueventd: add a test for ueventd_parser.cpp
Test: this unit test
Change-Id: Ib23f23ea5b362bb458adf8208573e5dc80ad6cf0
2018-07-17 15:28:51 -07:00
Tom Cherry 689d86a029 Merge "ueventd: let scripts provide firmware directories"
am: b504f38d7e

Change-Id: I6dd9cfe20b733fad5afb066b07484c33eb599c02
2018-07-16 17:15:18 -07:00
Tom Cherry b504f38d7e Merge "ueventd: let scripts provide firmware directories" 2018-07-16 23:00:53 +00:00
Tom Cherry 7421fa1aed ueventd: let scripts provide firmware directories
Since some vendors will have firmware in mount points in
/mnt/vendor/..., we extend the ueventd script language to allow
specifying the firmware directories.

Also, move the existing 4 directories to ueventd.rc as a primary user
of this mechanism.

Bug: 111337229
Test: boot sailfish; firmwares load
Change-Id: I0854b0b786ad761e40d2332312c637610432fce2
2018-07-13 15:34:25 -07:00
Tom Cherry f4657d4b80 Merge "init: actually remount /sys when changing network namespaces"
am: a8df2b95cb

Change-Id: I00330bacd9fd7bcb825298ef72ca54d134206c99
2018-07-13 13:09:53 -07:00
Tom Cherry 9bb0a4de46 init: actually remount /sys when changing network namespaces
Fix a typo from before.

Bug: 73334854
Test: build
Change-Id: I66631a6f251960be0e02d8a119fa0ff7a00fb24c
2018-07-13 11:07:11 -07:00
Bowgo Tsai 7c4bb66d83 Merge "Add /mnt/product rw mount point for product partitions."
am: 35f2704226

Change-Id: I631decdbb3549d72478279da83ec4a5f99023b24
2018-07-02 19:03:38 -07:00
Bowgo Tsai acc31cee1b Add /mnt/product rw mount point for product partitions.
1. init creates /mnt/product used to mount product-specific rw partitions.
2. If a device tree fstab entry for early mount specifies a mount point
   under /mnt/product e.g. /mnt/product/foo, init will create
   /mnt/product/foo mount point.

Bug: 110808288
Test: change dt fstab entry to mount /mnt/product/foo; mount point is
      created correctly, and partition is mounted in early mount.

Change-Id: I321e314992abe1084fd67a382c205f5c0c92bf3d
2018-06-29 10:36:03 +08:00
Tom Cherry 588391fd69 Merge "init: add unit tests for tokenizer.cpp"
am: 749ee86faf

Change-Id: I64f78aefbd64b4154e776cfe8cd48ca91b93693f
2018-06-27 16:10:34 -07:00
Tom Cherry 749ee86faf Merge "init: add unit tests for tokenizer.cpp" 2018-06-27 23:01:27 +00:00
Tom Cherry 117ea4f45a Merge "init: fix the parse error when meeting escape characters"
am: 78ea17a641

Change-Id: I55967f9ca86d92468dffa3ff5c0488dfe603bba9
2018-06-27 13:50:02 -07:00
Tom Cherry 2a5a4e72f3 init: add unit tests for tokenizer.cpp
Test: this unit test
Change-Id: Iae24f3bf7850dd4b298281f6608bce195096d60a
2018-06-27 13:22:16 -07:00
liwugang 332afef5f4 init: fix the parse error when meeting escape characters
After dealing with some specical escape characters('\n','\r','\t','\\',"\r\n")
it doesn't goto the next position in the next loop, so it process the current
character twice.

For example, when parsing the string "test\ntoken" we expect the
"test'\n'token" but actually we got the "test'\n'ntoken"

Test: have espace characters in init .rc files
Change-Id: I015c087a5c6e5ee9c490f29a83b15b89443f7f81
Signed-off-by: liwugang <liwugang@xiaomi.com>
2018-06-26 13:30:54 +08:00
Christopher Morin 00ac033d6c Merge "init: Don't set ro.serialno when androidboot.serialno is not set"
am: 27eda482be

Change-Id: I5ea45a03ef91395b43fce85ad6a36a59c4cd3839
2018-06-22 13:26:09 -07:00
Chris Morin 39d124b92c init: Don't set ro.serialno when androidboot.serialno is not set
This functionality is useful for improving boottimes on the ARC++
project. Without this change, ro.serialno would be set to the empty
string when androidboot.serialno was unset in the kernel commandline.

Bug: 62039211
Test: boot with androidboot.serialno unset and ensure ro.serialno is
unset

Change-Id: Iaee339dfa3f0c871e5e9c1fc0534347f2b3e8a07
2018-06-21 18:54:28 -07:00
Wei Wang 736d63c7d1 Merge "init: print service name when started waiting"
am: d41a1f9add

Change-Id: I3672fe86c4fb75ca22d4a5862a291d79062822b0
2018-06-21 12:23:54 -07:00
Treehugger Robot d41a1f9add Merge "init: print service name when started waiting" 2018-06-21 19:17:08 +00:00
Yifan Hong 6dd458a67c Merge "Revert "init: dummy host_init_verifier for mac""
am: 16bb55cb7b

Change-Id: Ibcb16e6a5b297650687c81bee1a8b86852a51fd5
2018-06-20 16:04:28 -07:00
Yifan Hong 16bb55cb7b Merge "Revert "init: dummy host_init_verifier for mac"" 2018-06-20 22:56:39 +00:00
Wei Wang 2c4ee75b1e init: print service name when started waiting
Bug: 110479595
Test: Boot
Change-Id: I448a64cec4c1cd5b736f8b9d04cd26429067bb71
2018-06-20 15:55:10 -07:00
Yifan Hong 3c4aa11cab Revert "init: dummy host_init_verifier for mac"
This reverts commit f567367584.

Reason for revert: mac build

Change-Id: Icd5d08206c50854d6645e07c4fb29705222bd226
2018-06-20 22:49:48 +00:00
Tom Cherry b3badbac58 Merge "init: dummy host_init_verifier for mac"
am: b0e193c609

Change-Id: I39069f0ae304895751eaeb524f0fb0053cf2b4cc
2018-06-20 14:27:34 -07:00
Treehugger Robot b0e193c609 Merge "init: dummy host_init_verifier for mac" 2018-06-20 21:19:49 +00:00
Tom Cherry eedd4cd77a Merge "init: document what host init verifier checks"
am: ab8131f18f

Change-Id: I68d3ffd44b64f5de8608c43e170516fe39479900
2018-06-20 14:10:28 -07:00
Treehugger Robot ab8131f18f Merge "init: document what host init verifier checks" 2018-06-20 21:00:42 +00:00
Tom Cherry f567367584 init: dummy host_init_verifier for mac
Let's start by fixing the build, then see how possible this will be to do fully.

Bug: 110477913
Test: n/a
Change-Id: If52e15bd070781a405c5494631ede033c1067903
2018-06-20 12:29:59 -07:00
Tom Cherry 47111aee40 init: document what host init verifier checks
Bug: 36970783
Test: n/a
Change-Id: Ic42a55d7b5bb4fec364ac3b5d9a67bcd38cbcc8d
2018-06-20 10:21:37 -07:00
Tom Cherry 50cc21a9e2 Merge "Don't check permissions bits on init scripts for host_init_verifier"
am: 81101cb216

Change-Id: I2d62e2121a8c2740d893d253f7abedc1ec824ee2
2018-06-20 10:09:28 -07:00
Tom Cherry 81101cb216 Merge "Don't check permissions bits on init scripts for host_init_verifier" 2018-06-20 17:06:11 +00:00
David Anderson 39d0c5bef4 Merge "init: Create logical partitions via liblp."
am: 08839ff904

Change-Id: I8630d57e48a3016173a43b6dbd68ab974e6d5e01
2018-06-19 18:14:39 -07:00
Treehugger Robot 08839ff904 Merge "init: Create logical partitions via liblp." 2018-06-20 01:09:35 +00:00
Jiyong Park c4e89cde85 Merge "libselinux is dynamically linked from init"
am: 20480a22a1

Change-Id: I0f76ee0fe718cb73818c87cb3938b517f710122b
2018-06-19 17:10:29 -07:00
Treehugger Robot 20480a22a1 Merge "libselinux is dynamically linked from init" 2018-06-20 00:00:38 +00:00
Tom Cherry d72432de93 Don't check permissions bits on init scripts for host_init_verifier
Also get rid of the copy in parser.  There's no incentive to switch to
a tokenizer that doesn't modify the input, nor is there a reason to
waste cycles making a copy of every init script as its processed.

Bug: 36970783
Test: boot
Change-Id: I8aca9c9d6f1961e1ab35dee50691a6791fc6ec66
2018-06-19 15:18:40 -07:00
David Anderson 6590df2763 init: Create logical partitions via liblp.
Currently, init can create logical partitions by hardcoding them in
fs_mgr or by specifying them in device-tree. This change allows init to
also create logical partitions by using liblp, which stores partition
tables in a physical partition. The current name for this partition is
"android".

Two aspects of this code will change long-term. One, the prototype code
using device-tree will be deleted once fastboot supports logical
partitions. Two, libdm will obsolete most of the code in
fs_mgr_dm_linear.cpp. For now however we preserve how the prototype code
functions and we layer liblp on top of the existing dm_linear logic.

Bug: 79173901
Test: N/A
Change-Id: If014a109da78fa12269bf0df0dda39028ac2d1aa
2018-06-19 14:03:58 -07:00
Jiyong Park 012171d3af libselinux is dynamically linked from init
init is now dynamically linked to libselinux. This gives us about 100KB
extra space, which is valuable in the recovery partition.

Bug: 63673171
Test: m -j
Test: adb reboot recovery
Change-Id: I72c4f886cbbb9ce54f8221f05547f5b9f0e1adb0
2018-06-19 16:55:05 +09:00
Tom Cherry e33a115a39 Merge "Support oem_#### users/groups for host_init_verifier"
am: fe80d069a0

Change-Id: Ie59394a402c0d8c6cb5d9a3be574ccdb6e71eacc
2018-06-18 09:05:18 -07:00
Tom Cherry fe80d069a0 Merge "Support oem_#### users/groups for host_init_verifier" 2018-06-18 15:50:52 +00:00
Tom Cherry 831e67192c Merge "Relax host init parser to work with the build system"
am: 4632f4e868

Change-Id: I583443a7e546b7b32454b7cf5ef2e60f3b73cc09
2018-06-15 10:07:13 -07:00
Tom Cherry 4632f4e868 Merge "Relax host init parser to work with the build system" 2018-06-15 17:03:42 +00:00
Tom Cherry 290427b442 Support oem_#### users/groups for host_init_verifier
Bug: 36970783
Test: oem_#### users and groups no longer fail in host_init_verifier
Change-Id: I48174f528994d1b225ed897328cc207bdebf07a8
2018-06-14 21:12:02 +00:00
Tom Cherry 863d808c2e Relax host init parser to work with the build system
It's not going to be possible to safely assume $OUT has the right init
scripts to be parsed at a given point, so instead we fall back to
parsing init scripts individually.

This isn't a full revert of the previous commits.  We retain parsing
correctness of the 'import' statements and we retain using the new
host side property functionality.

Also, fix a bug where main was not actually returning -1 on failure

Bug: 36970783
Test: testing individual files still works correctly
Change-Id: I4ae5620f234caa08993deb2c30825904a75f6654
2018-06-14 14:08:33 -07:00
Wei Wang fb0500e0aa Merge "Revert "init: Add warning in init first stage mount""
am: 62dbf90225

Change-Id: If44dbd27d97e629ffe101578ed017676dde8a62b
2018-06-14 13:56:18 -07:00
Treehugger Robot 62dbf90225 Merge "Revert "init: Add warning in init first stage mount"" 2018-06-14 20:40:17 +00:00
Wei Wang 37acac49e2 Revert "init: Add warning in init first stage mount"
This reverts commit fdafb3d0ec.

Reason for revert: coldboot time increase
 
Bug: 110210279
Test: Boot

Change-Id: Ibb92c1856f3fc114685c40df67556131409a9231
2018-06-14 18:51:43 +00:00
Jiyong Park aa39f52a56 Merge changes from topic "sharedlib_in_recovery"
am: 91061985f5

Change-Id: Icaabb1cb46057771f71eb3fa0fad7be49d50dc64
2018-06-13 16:44:02 -07:00
Treehugger Robot 91061985f5 Merge changes from topic "sharedlib_in_recovery"
* changes:
  Build init with shared libraries
  Shared libs are supported in recovery mode
2018-06-13 23:14:29 +00:00
Wei Wang 849ea35725 Merge "init: Add warning in init first stage mount"
am: 4aa8421203

Change-Id: I5f8d12857a40ae68fecb86f5f3c069182e0261ef
2018-06-13 13:51:33 -07:00
Wei Wang fdafb3d0ec init: Add warning in init first stage mount
init need find required devices and it some times takes a long time due
to rogue drivers. Add a warning if the timing is longer than 50ms.

Bug: 80494921
Test: Reboot
Change-Id: I8f937d7ca7127dc89ed76bb6e5f1781459d5c94a
2018-06-13 11:02:13 -07:00
Tom Cherry daa054fa11 Merge "ueventd: fix extraneous 'Invalid section' error"
am: 86e65e9cac

Change-Id: Ia317ea6029f9251639c5b8875eaa5536880ae5f2
2018-06-12 15:18:34 -07:00
Tom Cherry 86e65e9cac Merge "ueventd: fix extraneous 'Invalid section' error" 2018-06-12 22:05:48 +00:00
Tom Cherry 6e31a2b9ae Merge "init: Actually check the return value for calls during first stage init"
am: 413bf61e48

Change-Id: I35a8be44f0d59458aaabac5c571f404e6c1fbec2
2018-06-12 14:53:38 -07:00
Tom Cherry 788fc8229c init: Actually check the return value for calls during first stage init
Init never checked the return values of the calls made during first
stage init (since of course they're not going to fail, right?).  But
of course commands can fail and they might not necessarily be obvious
when they do, so let's make it obvious.

Since the kernel log isn't up until later, this creates a list of the
failures that can then be sent to the kernel log once it's ready
(pending of course failures in setting it up...)

Test: boot bullhead, don't see errors
Change-Id: I8c12c61fa12e4368346e8b0e1c0bb0844b5d0377
2018-06-12 11:18:17 -07:00
Tom Cherry d5d626c9f7 ueventd: fix extraneous 'Invalid section' error
When adding a new error case for host_init_parser, I didn't handle the
individual line callbacks used for ueventd correctly.  This change
fixes that.

Test: bullhead boots without extraneous ueventd warnings
Change-Id: I56cad854b0defd936a7fbcab73fe2f2963c0e2e4
2018-06-12 10:59:12 -07:00
Jiyong Park 787322c55f Build init with shared libraries
recovery partition now supports shared librarys. Therefore, init can now
be built as a dynamic executable both for normal and recovery modes.

To save save in the recovery mode, not all libs are dynamically linked.
Libs that are only used by init in the recovery mode are still
statically linked.

Note: init is still a static executable for legacy devices where
system-as-root is not on, because the dynamic linker and shared libs
which are in /system are not available when init starts.

Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: device boots to the UI in normal mode.
Test: do that for both walleye (system-as-root) and bullhead (legacy
ramdisk).
Change-Id: I30c84ae6a8e507e507ad0bb71acad281316d9e90
2018-06-10 08:32:33 +09:00
Yifan Hong 7dc09a089d Merge "androidboot.lrap => logical_partitions" am: 05625ab420
am: 8b328e403d

Change-Id: I37a8f05759e060cc7cab26411a822ad7be16a36b
2018-05-31 18:12:13 -07:00
Yifan Hong 05625ab420 Merge "androidboot.lrap => logical_partitions" 2018-05-31 22:05:06 +00:00
Yifan Hong 59bd65bdf6 androidboot.lrap => logical_partitions
Test: boots with prototype
Bug: 79885414
Change-Id: Ia84d052800b71ff9cfa1630def0ce72c57f76b81
2018-05-31 13:08:01 -07:00
Tom Cherry 4fc2cd7caa Merge "init: implement getpwnam for host init verifier" am: 1c15b02b54
am: 83c7fdcc1c

Change-Id: Ia2d557642c3167ca368e72faa137cb9c57592784
2018-05-31 11:37:53 -07:00
Tom Cherry d1cc7a94d4 Merge "init: handle properties and imports for host init verifier" am: 279de56b3e
am: 758102af2b

Change-Id: I40073678d64544f74706dbb7026798f537aed8cc
2018-05-31 11:31:55 -07:00
Tom Cherry 31525f5cb6 init: implement getpwnam for host init verifier
Bug: 36970783
Test: test bullhead successfully at TOT
Test: create errors and check that they're caught
Test: create uid in passwd and check that it's successful
Change-Id: I237fb8df16a294757fe898bdbbd42e850bcb8301
2018-05-30 15:43:40 -07:00
Tom Cherry 194b5d1da9 init: handle properties and imports for host init verifier
Allow specifying properties on the command line when running host init
verifier.  This is needed particularly for importing files that have a
property expansion in their path.

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

Bug: 36970783
Test: verify that bullhead imports the correct files and checks them
Change-Id: I4fe263016b3764a372708b559bc0c739b1b7e5e3
2018-05-30 15:43:32 -07:00
Mark Salyzyn 94d6035077 Merge "init: add keychords_test" am: 680bc0b6b5
am: aac3972dd3

Change-Id: I46dc9bf77569f1c0c39e094b52f96e736306c5b4
2018-05-30 10:47:59 -07:00
Treehugger Robot 680bc0b6b5 Merge "init: add keychords_test" 2018-05-30 17:27:35 +00:00
Mark Salyzyn 654b1e2a02 Merge "init: switch out keychord id with std::vector match of chords" am: e6a878644c
am: b93b91c7ef

Change-Id: I79bd04e2e2c8b1a2a380ea7a79eaad01686b6129
2018-05-30 09:29:04 -07:00
Treehugger Robot e6a878644c Merge "init: switch out keychord id with std::vector match of chords" 2018-05-30 16:12:36 +00:00
Mark Salyzyn 75b901d4a8 init: add keychords_test
Test: init_tests --gtest_filter=keychords.*
Bug: 64114943
Change-Id: I357d0c1bd56660ac28bc02b76d5632ef1b9328b7
2018-05-30 08:38:11 -07:00
Elliott Hughes a391213d8a Merge "init; remove dead cruft." am: dfc4ad2a9c
am: 8d69c92b6d

Change-Id: Icb02fb3fa4580fe69cd72fc6f288bc6d92347df9
2018-05-29 21:44:51 -07:00
Elliott Hughes ba3a589d1e Merge "libbase: add host properties support." am: d580c441ab
am: 10200e4c21

Change-Id: I6577c9f68378f16c9d2e543218c0eab4d54f4d52
2018-05-29 18:01:46 -07:00
Mark Salyzyn e55e0c3d3d Merge "init: turn keychords into a standalone class" am: 420fe5fe90
am: f29bb19686

Change-Id: If128cedc913065565e9ea367c2a7c34b217ac2a7
2018-05-29 18:01:12 -07:00