Skip to content

Commit a8327e3

Browse files
committed
fix: merge cert for system
Signed-off-by: WindSpiritSR <simon343riley@gmail.com>
1 parent a14f398 commit a8327e3

2 files changed

Lines changed: 39 additions & 28 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
id: tag
1919
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
2020

21-
- name: Update update.json
21+
- name: Update update.json and module.prop
2222
env:
2323
VERSION: ${{ steps.tag.outputs.VERSION }}
2424
REPO: ${{ github.repository }}
@@ -30,13 +30,15 @@ jobs:
3030
--arg cl "https://github.com/${REPO}/releases/tag/${VERSION}" \
3131
'.version=$v | .versionCode=$c | .zipUrl=$z | .changelog=$cl' \
3232
update.json > tmp.json && mv tmp.json update.json
33+
sed -i "s/^version=.*/version=${VERSION}/" module.prop
34+
sed -i "s/^versionCode=.*/versionCode=${NEW_CODE}/" module.prop
3335
34-
- name: Commit update.json
36+
- name: Commit update.json and module.prop
3537
run: |
3638
git config user.name "github-actions[bot]"
3739
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
38-
git add update.json
39-
git diff --cached --quiet || git commit -m "Update update.json for ${{ steps.tag.outputs.VERSION }}"
40+
git add update.json module.prop
41+
git diff --cached --quiet || git commit -m "Update update.json and module.prop for ${{ steps.tag.outputs.VERSION }}"
4042
git push origin HEAD:main
4143
4244
- name: Build zip

post-fs-data.sh

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,47 @@ set_context() {
2020
fi
2121
}
2222

23-
chown -R 0:0 ${MODDIR}/system/etc/security/cacerts
24-
set_context /system/etc/security/cacerts ${MODDIR}/system/etc/security/cacerts
23+
merge_ca_certs() {
24+
target_path="$1"
25+
tmpfs_path="$2"
2526

26-
# Android 14 support
27-
# Since Magisk ignore /apex for module file injections, use non-Magisk way
28-
if [ -d /apex/com.android.conscrypt/cacerts ]; then
29-
# Clone directory into tmpfs
30-
rm -f /data/local/tmp/sys-ca-copy
31-
mkdir -p /data/local/tmp/sys-ca-copy
32-
mount -t tmpfs tmpfs /data/local/tmp/sys-ca-copy
33-
cp -f /apex/com.android.conscrypt/cacerts/* /data/local/tmp/sys-ca-copy/
34-
35-
# Do the same as in Magisk module
36-
cp -f ${MODDIR}/system/etc/security/cacerts/* /data/local/tmp/sys-ca-copy
37-
chown -R 0:0 /data/local/tmp/sys-ca-copy
38-
set_context /apex/com.android.conscrypt/cacerts /data/local/tmp/sys-ca-copy
39-
40-
# Mount directory inside APEX if it is valid, and remove temporary one.
41-
CERTS_NUM="$(ls -1 /data/local/tmp/sys-ca-copy | wc -l)"
27+
rm -f "${tmpfs_path}"
28+
mkdir -p "${tmpfs_path}"
29+
mount -t tmpfs tmpfs "${tmpfs_path}"
30+
cp -f "${target_path}"/* "${tmpfs_path}/"
31+
32+
cp -f ${MODDIR}/system/etc/security/cacerts/* "${tmpfs_path}"
33+
chown -R 0:0 "${tmpfs_path}"
34+
set_context "${target_path}" "${tmpfs_path}"
35+
36+
CERTS_NUM="$(ls -1 "${tmpfs_path}" | wc -l)"
4237
if [ "$CERTS_NUM" -gt 10 ]; then
43-
mount --bind /data/local/tmp/sys-ca-copy /apex/com.android.conscrypt/cacerts
38+
mount --bind "${tmpfs_path}" "${target_path}"
4439
for pid in 1 $(pgrep zygote) $(pgrep zygote64); do
4540
nsenter --mount=/proc/${pid}/ns/mnt -- \
46-
mount --bind /data/local/tmp/sys-ca-copy /apex/com.android.conscrypt/cacerts
41+
mount --bind "${tmpfs_path}" "${target_path}"
4742
done
4843
else
49-
echo "Cancelling replacing CA storage due to safety"
44+
echo "Cancelling replacing ${target_path} due to safety"
5045
fi
5146
for pid in 1 $(pgrep zygote) $(pgrep zygote64); do
5247
nsenter --mount=/proc/${pid}/ns/mnt -- \
53-
umount /data/local/tmp/sys-ca-copy
48+
umount "${tmpfs_path}"
5449
done
55-
umount /data/local/tmp/sys-ca-copy
56-
rmdir /data/local/tmp/sys-ca-copy
50+
umount "${tmpfs_path}"
51+
rmdir "${tmpfs_path}"
52+
}
53+
54+
chown -R 0:0 ${MODDIR}/system/etc/security/cacerts
55+
set_context /system/etc/security/cacerts ${MODDIR}/system/etc/security/cacerts
56+
57+
# Android 14+ APEX Conscrypt store
58+
# Since Magisk ignores /apex for module file injections, use non-Magisk way
59+
if [ -d /apex/com.android.conscrypt/cacerts ]; then
60+
merge_ca_certs /apex/com.android.conscrypt/cacerts /data/local/tmp/sys-ca-copy
61+
fi
62+
63+
# System CA store (for Flutter/dart:io HttpClient and other legacy clients)
64+
if [ -d /system/etc/security/cacerts ]; then
65+
merge_ca_certs /system/etc/security/cacerts /data/local/tmp/sys-ca-copy-system
5766
fi

0 commit comments

Comments
 (0)