Commit graph

103 commits

Author SHA1 Message Date
Steven Moreland
98322a3775 Explicit init .rc user.
Set the user explicitly.
Bug: 276813155
Test: boot

Change-Id: I26ee9db2a82dc89b35e551782b6b1d942e72c8cd
2023-04-14 16:12:23 +00:00
Bob Badour
29be3f6ef1 [LSC] Add LOCAL_LICENSE_KINDS to bootable/recovery
Added SPDX-license-identifier-Apache-2.0 to:
  applypatch/Android.bp
  bootloader_message/Android.bp
  edify/Android.bp
  fuse_sideload/Android.bp
  install/Android.bp
  minadbd/Android.bp
  minui/Android.bp
  otautil/Android.bp
  recovery_ui/Android.bp
  recovery_utils/Android.bp
  tests/Android.bp
  tools/image_generator/Android.bp
  tools/recovery_l10n/Android.bp
  uncrypt/Android.bp
  update_verifier/Android.bp
  updater/Android.bp
  updater/Android.mk
  updater_sample/Android.bp
  updater_sample/tests/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
    SPDX-license-identifier-OFL
to:
  Android.bp
  Android.mk

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I3da761b525452838977297f773974000d4de7bd6
2021-02-14 10:37:20 -08:00
Chih-Hung Hsieh
5fce3a1cbe Fix clang-analyzer-core.uninitialized.Branch warnings
Bug: 154760495
Test: make with WITH_TIDY=1 and DEFAULT_GLOBAL_TIDY_CHECKS=clang-analyzer-core.uninitialized.Branch
Change-Id: I03af58f9491f4abcface9abb12c80a35e0f97a40
2020-04-23 14:36:59 -07:00
Tom Cherry
72a114a3e1 Add android::fs_mgr namespace for new Fstab code
Also add libfstab dependencies where needed.  Previously the
`typedef struct FstabEntry Volume;` line served to both define a
`struct FstabEntry` as well as alias Volume to it.  With the new
namespace for android::fs_mgr::FstabEntry, `struct FstabEntry` isn't
compatible anymore, so we need to alias Volume to the real
android::fs_mgr::FstabEntry.

In doing so, we need to include <fstab/fstab.h> and this requires
libfstab as a library, which a few modules did not have before.

Test: treehugger
Change-Id: I655209a0efb304b3e0568db0748bd5cf7cecbdb7
2019-01-31 09:00:40 -08:00
Tao Bao
bb134b2613 uncrypt: Fix the comparison in FindBlockDevice().
Previously it considered a match if the given path (i.e. path to an
update package) fully equals to a mount_point.  For example, `uncrypt
/data block.map` or `uncrypt /vendor block.map` would exit successfully,
without producing a block map.

Test: `uncrypt /path/to/package.zip block.map`
Test: `uncrypt /vendor block.map` fails.
Change-Id: Id946ab1c0b158b623013f89463cbb1960141d8b5
2018-12-05 14:44:32 -08:00
Tao Bao
d1670a064d uncrypt: Replace a few C-strings with std::string.
Also use android::base::{Dirname,Realpath,StartsWith}.

Test: Run uncrypt on device (`uncrypt package block.map`).
Change-Id: Ifacd01d6b35d85ea4afcb93a0dbc0235bb765a75
2018-12-05 14:44:24 -08:00
Tom Cherry
772c93ca5c Move some small users of fstab to new C++ Fstab
Bug: 62292478
Test: tree-hugger
Change-Id: Ie2cc10e5168ef3b9dcc42f88e67a1ccd1175fcc5
2018-12-04 11:11:14 -08:00
Jaegeuk Kim
051b9d87e2 uncrypt: write permission for f2fs_pin_file
We need a write permission to set a flag in the file.

Change-Id: I4896ecbe0fc04374e01d006b1c8acdb932e5d16d
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-11-21 12:52:29 -08:00
Devin Kim
29472c7566 uncrypt: fix ioctl direction for F2FS_IOC_GET_PIN_FILE
The direction should be set as READ, not WRITE

Change-Id: Id695276f25c1d75bca3a02d87e4a59623e95cb00
2018-09-12 09:55:33 -07:00
Tao Bao
d881d4f205 uncrypt: Depend on commonly used shared libs.
We already have these shared libraries on device. And `uncrypt` doesn't
need to be statically linked (it wasn't, even prior to this change).

With this change, the size of uncrypt goes down from 139KiB to 33KiB
(aosp_marlin-userdebug).

Test: Build and flash on marlin. Trigger a factory reset (which calls
      `uncrypt` to set up the BCB).
Change-Id: I77e3c82e8ce3734019da75c48928d881cb7ef0f0
2018-08-22 17:59:21 -07:00
Jaegeuk Kim
2669da0d01 uncrypt: fix f2fs ioctl argument for pin_file
This patch fixes missing f2fs ioctl call.

Change-Id: Id840b76b9d5c580041aaee4501ac8e69fc3fb818
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-08-01 03:52:51 +00:00
Jaegeuk Kim
b6e6ee7587 f2fs: support f2fs by setting unmovable bit for package file
This enables to use uncrypt for f2fs update-on-reboot.
It requires kernel patch named:
    "f2fs: add an ioctl to disable GC for specific file"

If any operation fails during uncrypt, please delete package file as soon as
possible, and create the file again to move forward. IOWs, don't leave the
package file for a long time.

Bug: 70309376
Bug: 30170612
Change-Id: I3b4233e7da756f107be35364521699deaf2e7139
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2018-03-22 12:10:08 -07:00
Tao Bao
a2a68a522e uncrypt: Move to Soong.
Test: mmma -j bootable/recovery
Change-Id: I405f2a70f51904c02c49a287c23cbc115a4c5132
2017-11-09 12:34:00 -08:00
Tao Bao
1fc5bf353a Revert "Revert "Move error_code.h into otautil.""
This reverts commit 26436d6d60 to re-land
"Move error_code.h into otautil.".

This way it stops requiring relative path ".." in LOCAL_C_INCLUDES
(uncrypt and edify). Soong doesn't accept non-local ".." in
"local_include_dirs".

This CL needs to land with device-specific module changes (e.g. adding
the dependency on libotautil).

Test: lunch aosp_{angler,bullhead,dragon,fugu,sailfish}-userdebug;
      mmma bootable/recovery
Change-Id: If193241801af2dae73eccd31ce57cd2b81c9fd96
2017-10-09 14:07:54 -07:00
Tao Bao
26436d6d60 Revert "Move error_code.h into otautil."
This reverts commit 623fe7e701.

Reason for revert: Need to address device-specific modules.

Change-Id: Ib7a4191e7f193dfff49b02d3de76dda856800251
2017-10-05 17:16:31 +00:00
Tao Bao
623fe7e701 Move error_code.h into otautil.
This way it stops requiring relative path ".." in LOCAL_C_INCLUDES
(uncrypt and edify). Soong doesn't accept non-local ".." in
"local_include_dirs".

Test: mmma bootable/recovery
Change-Id: Ia4649789cef2aaeb2785483660e9ea5a8b389c62
2017-10-04 08:55:24 -07:00
Tianjie Xu
c89d1e7e2a Turn on -Wall for recovery modules
Turn on -Wall for all modules. Also remove the obsolete file_cmp() in
apply_patch test and now() in wear_ui.

The only exception is lib_edify due to the unused functions in the
intermediate cpp files generated from the lex files. It will be handled
in a seperate CL.

Bug: 64939312
Test: mma, unit tests pass
Change-Id: Ic53f76b60b6401ab20db3d98130d674c08e3702f
2017-08-28 21:56:33 -07:00
Tianjie Xu
6f30535229 Merge "Add more specific error codes for uncrypt failures"
am: 3ff8a5e2a4

Change-Id: Iee5b01f59b2e0532232393c0133f0bd3b11d9ccd
2017-07-27 21:31:52 +00:00
Tianjie Xu
8b8e23d5cc Add more specific error codes for uncrypt failures
Add the error codes when we fail to find the realpath, or fail to find
the block_device.

Bug: 63737759
Test: mma
Change-Id: Icf15368ad3e7345c747d9083da2f049cc8acd571
2017-07-27 21:28:18 +00:00
Tao Bao
1d510671c7 Merge "Remove LOCAL_CLANG"
am: 231c627a55

Change-Id: Idfd30503b9ebd8e3d59af7ab703911a500ad6c09
2017-07-25 21:58:22 +00:00
Lennart Wieboldt
5e5e334b3b Remove LOCAL_CLANG
clang is the default compiler since Android nougat

Change-Id: I930bba431dc49970cb4491ed5fcf44b5e00e97df
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-07-25 21:48:39 +02:00
Bowgo Tsai
1bd484f941 Merge "recovery: replacing fs_mgr_read_fstab() with new fs_mgr APIs" am: 7a0dfec771 am: 1a23257214
am: 1a76f4a3bc

Change-Id: I8869ddf69589c2a1bb0e8dd493df67f9126db585
2017-03-10 16:17:39 +00:00
Bowgo Tsai
d13b6cf29c recovery: replacing fs_mgr_read_fstab() with new fs_mgr APIs
The fstab settings of early-mounted partitions (e.g., /vendor) will be in
kernel device tree. Switch to the new API to get the whole settings with
those in device tree:

    fs_mgr_read_fstab_with_dt("/etc/recovery.fstab")

The original default /fstab.{ro.hardware} might be moved to
/vendor/etc/. or /odm/etc/. Use another new API to get the default fstab
instead of using the hard-coded /fstab.{ro.hardware}. This API also
includes the settings from device tree:

    fs_mgr_read_fstab_default()

Bug: 35811655
Test: boot sailfish recovery
Change-Id: Iaa56ac7f7b4c4dfc7180c65f03e9a37b94f1de09
2017-03-10 17:27:31 +08:00
Tianjie Xu
8ff296be1a Merge "Retry ioctl in uncrypt if it returns block# 0" am: ceafe69fb8 am: 06b4254a70 am: 5ec75851a7
am: 4536c470f8

Change-Id: I399f35a1bc1575f9e1fcfa5d2bb537390360505e
2017-01-07 01:28:03 +00:00
Tianjie Xu
ceafe69fb8 Merge "Retry ioctl in uncrypt if it returns block# 0" 2017-01-07 01:11:13 +00:00
Tao Bao
97b2fa2fbf Merge "Add tests for setup-bcb and clear-bcb via uncrypt." am: 4e48a6c1a1 am: af62097c08 am: b1e8150c44
am: 51ccca4b8c

Change-Id: Ifa6579a34df60e48ff53689397bb53464a5d15ee
2016-12-14 05:46:01 +00:00
Tao Bao
1033408801 Add tests for setup-bcb and clear-bcb via uncrypt.
Bug: http://b/33534933
Test: recovery_component_test passes (and fails on buggy build due to
      the CL in [1]).

[1]: commit 7e31f421a5

Change-Id: I120498048ec1db8f9fcbb3cf135c05d3a48cfcdf
2016-12-13 17:46:03 -08:00
Tianjie Xu
bc42603a8d Retry ioctl in uncrypt if it returns block# 0
In some conditions, ioctl(fd, FIBMAP, &block) returns block number 0.This
is a failure to locate the actual block number of the update package and
will result in an invalid block.map. This CL retries ioctl a few times
if it returns block number as 0.

Bug: 31632090
Test: On N9, uncrypt retries ioctl and produces the correct blockmap.
Change-Id: I913f98cf5c112915c2e803d0683db273c89053b6
2016-12-05 11:59:58 -08:00
Tianjie Xu
f2574b8206 Merge "Allow uncrypt to work without socket communication"
am: 4c1f3eda98

Change-Id: I8e86d4201d2fac0293e70df54e0816c96e85a9b7
2016-11-12 01:02:33 +00:00
Tianjie Xu
7ceff3e003 Allow uncrypt to work without socket communication
It was inconvenient to uncrypt a update package under adb shell
because the uncrypt executable required a socket to start its job.
Add a workaround to allow uncrypt executes without socket
communication.

Test: run uncrypt under adb shell, and the block map generates successfully
Bug: 29906218

Change-Id: Ibc328b31636d925dc429ede8dcec7392a721dd53
(cherry picked from commit 28c1e5d3aa)
2016-11-11 13:51:15 -08:00
Yabin Cui
fd99a318fe Verify wipe package when wiping A/B device in recovery.
To increase the security of wiping A/B devices, let uncrypt write
wipe package in misc partition. Then recovery verifies the wipe
package before wiping the device.

Based on the original cherrypick, this CL also has additional changes to
address the LOG statements and libziparchive changes.

Bug: 29159185
Test: Build and boot into recovery.

Change-Id: I186691bab1928d3dc036bc5542abd64a81bc2168
(cherry picked from commit 6faf0265c9)
2016-10-19 11:19:15 -07:00
Tao Bao
e2a706824e resolve merge conflicts of e89bf25 to stage-aosp-master am: 69c117c2ff
am: 2a576e2097

Change-Id: Iee6000f594a04a0862b3687f1d87daa809fb3804
2016-10-18 23:08:05 +00:00
Tao Bao
69c117c2ff resolve merge conflicts of e89bf25 to stage-aosp-master
Change-Id: I3b0ddb23daf264d407370cd8ace31eceb230a11a
2016-10-18 15:08:07 -07:00
Yabin Cui
8b309f6970 Create bootloader_message static library.
bootloader_messages merges bootloader_message_writer
and bootloader.cpp, so we can use the same library to
manage bootloader_message in normal boot and recovery mode.

Bug: 29582118

Change-Id: I9efdf776ef8f02b53911ff43a518e035e0c29618
(cherry picked from commit 2f272c0551)
2016-10-18 11:37:05 -07:00
Tianjie Xu
10e223c181 Turn on -Werror for recovery
am: 17e316cce0

Change-Id: Ia0e1948491edf7cca8b64d7e7f0cac91314c2025
2016-09-30 20:34:23 +00:00
Tianjie Xu
17e316cce0 Turn on -Werror for recovery
Also remove the 0xff comparison when validating the bootloader
message fields. As the fields won't be erased to 0xff after we
remove the MTD support.

Bug: 28202046
Test: The recovery folder compiles for aosp_x86-eng
Change-Id: Ibb30ea1b2b28676fb08c7e92a1e5f7b6ef3247ab
(cherry picked from commit 7aa88748f6)
2016-09-30 11:18:01 -07:00
Tianjie Xu
7aa88748f6 Turn on -Werror for recovery
Also remove the 0xff comparison when validating the bootloader
message fields. As the fields won't be erased to 0xff after we
remove the MTD support.

Bug: 28202046
Test: The recovery folder compiles for aosp_x86-eng
Change-Id: Ibb30ea1b2b28676fb08c7e92a1e5f7b6ef3247ab
2016-09-29 19:21:24 -07:00
Tianjie Xu
c8fbbc786c Report uncrypt errors in details
am: 68fc81e860

Change-Id: I57eff7b0aaa388c32dc8e99318e68ca25ff5c02d
2016-09-29 19:44:26 +00:00
Tianjie Xu
68fc81e860 Report uncrypt errors in details
Add the error codes for uncrypt and report the failure details in
uncrypt_status.

Test: uncrypt_error logs correctly in last_install
Bug: 31603820
Change-Id: I8e0de845ce1707b6f8f5ae84564c5e93fd5f5ef5
(cherry picked from commit 0c68675f5ae80cd669e0bf014a69689b6fe08eee)
2016-09-29 11:27:46 -07:00
Tianjie Xu
553d47bf91 Merge "Report uncrypt errors in details" am: af8b9363c6 am: 7582609d61 am: fc887a8fba
am: b0d0ee3c7d

Change-Id: Ie44169accea9196457d7cae696836c3a6fe14c8e
2016-09-27 21:27:56 +00:00
Tianjie Xu
b0d0ee3c7d Merge "Report uncrypt errors in details" am: af8b9363c6 am: 7582609d61
am: fc887a8fba

Change-Id: I5e83be10f4443c8b107821975b3506381fcbdf0c
2016-09-27 21:25:26 +00:00
Tianjie Xu
da44cf18f3 Report uncrypt errors in details
Add the error codes for uncrypt and report the failure details in
uncrypt_status.

Test: uncrypt_error logs correctly in last_install
Bug: 31603820
Change-Id: I8e0de845ce1707b6f8f5ae84564c5e93fd5f5ef5
2016-09-26 22:48:45 -07:00
Elliott Hughes
130f6c86f5 resolve merge conflicts of d5c7d6b to nyc-mr1-dev-plus-aosp
Change-Id: Ia041044547351a3e65b647bb9913aa18c7d2c97c
2016-09-26 12:53:52 -07:00
Elliott Hughes
cb22040c63 Switch to <android-base/properties.h>.
Bug: http://b/23102347
Test: boot into recovery.
Change-Id: Ib2ca560f1312961c21fbaa294bb068de19cb883e
Merged-In: Ib2ca560f1312961c21fbaa294bb068de19cb883e
2016-09-26 09:51:37 -07:00
Elliott Hughes
91e3aee9bd Switch to <android-base/properties.h>.
Bug: http://b/23102347
Test: boot into recovery.
Change-Id: Ib2ca560f1312961c21fbaa294bb068de19cb883e
2016-09-23 18:16:35 -07:00
Tianjie Xu
e8437b5340 save uncrypt status to last_install am: e16e799dfd am: 4769f209dc
am: 707583a4ab

Change-Id: I22b520ceaea408cad4e267d5a87c21ec80cd5e1d
2016-09-13 02:29:39 +00:00
Tianjie Xu
707583a4ab save uncrypt status to last_install am: e16e799dfd
am: 4769f209dc

Change-Id: Ic9056d4af518df3747743ec6b2886fa437029395
2016-09-13 01:50:40 +00:00
Tianjie Xu
e16e799dfd save uncrypt status to last_install
Save the uncrypt time cost to /cache/recovery/uncrypt_status. Recovery
reads the file and saves its contents to last_install.

Bug: 31383361
Test: Tested on angler and uncrypt_time reports correctly.

(cherry picked from commit fe16b5ccaf)

Change-Id: Id69681a35c7eb2f0eb21b48e3616dcda82ce41b8
2016-09-12 16:59:48 -07:00
Tianjie Xu
fe16b5ccaf save uncrypt status to last_install
Save the uncrypt time cost to /cache/recovery/uncrypt_status. Recovery
reads the file and saves its contents to last_install.

Bug: 31383361
Test: Tested on angler and uncrypt_time reports correctly.

Change-Id: I5cd3f7b6ca069d69086d09acfea8fc4f1215c833
Merged-In: I5cd3f7b6ca069d69086d09acfea8fc4f1215c833
2016-09-12 22:55:36 +00:00
Tianjie Xu
c21edd4654 Switch recovery to libbase logging
Clean up the recovery image and switch to libbase logging.

Bug: 28191554
Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
(cherry picked from commit 747781433f)
2016-09-01 14:32:55 -07:00