Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions droid-hal-device.inc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ BuildRequires: oneshot
BuildRequires: systemd
BuildRequires: qt5-qttools-kmap2qmap >= 5.1.0+git5
BuildRequires: rsync
%if 0%{?with_system_keys:1}
BuildRequires: system-keys-kernel
BuildRequires: system-keys-bootloader
%endif
# starting from Android 8
BuildRequires: python
%{?custom_build_requires}
Expand Down Expand Up @@ -385,6 +389,25 @@ if (grep -q '^TARGET_ARCH := arm64' %{android_root}/device/*/*/BoardConfig*.mk);
fi
%endif

%if 0%{?with_system_keys:1}
KERNEL_DIRS=$(find %android_root -maxdepth 1 -type d \( -name "kernel-*.*" -o -name "kernel" \) &&
find %android_root -maxdepth 2 -type d -path "*/linux/kernel")

# Copy trusted keys into kernel source directory
echo "$KERNEL_DIRS" |
while IFS= read -r kernel; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly pass the find output to read, see: https://github.com/koalaman/shellcheck/wiki/SC2044

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing output directly is a bash-specific thing, it won't work with plain POSIX shell. Is it okay to use bashisms here?

cp -r /etc/keys/kernel/* ${kernel}/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks weird how could or should come these keys from the rootfs of the build host?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are supposed to be provided by system-keys-kernel package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't they go then into /usr/lib?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/usr/lib is intended for storing object files and libraries. But keys are neither of them, they are much closer to configuration files (which should go into /etc/*). Also, Linux Kernel is using /etc/keys/ path by default for storing IMA certificate.

So, /etc/keys seems to be a better fit here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package supplied configuration files that should not be edited are now days in /usr/lib not in /etc, etc is for file created outside of the package-manager or those that should be edit.
Also note that the FHS is out of date and doesn't reflect the current state of things (see e.g. UsrMove).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I am agree on moving static data to /usr (which especially makes sense on RO filesystems), I'm not really sure that /usr/lib fits well for storing keys and certificates.

Maybe /usr/share then? As /usr/lib is primarily targeted for storing executable things (e.g. libraries and plugins), and quite rarely used for storing arbitrary data.

done

# Override aboot OEM keystore
if [ -d bootable/bootloader/lk/include ]; then
cp /etc/keys/bootloader/oem_keystore.h bootable/bootloader/lk/include
fi
if [ -d vendor/mediatek/proprietary/bootable/bootloader/lk/include ]; then
cp /etc/keys/bootloader/oem_keystore.h vendor/mediatek/proprietary/bootable/bootloader/lk/include
fi
%endif

%if 0%{?_obs_build_project:1}

# Set up kernel extra version for OBS kernel builds
Expand Down