36 lines
870 B
Bash
36 lines
870 B
Bash
#!/system/bin/sh
|
|
# Temporarily trust a CA system-wide on Android 14+ (APEX conscrypt store).
|
|
# Effective until reboot. Run as root: sh inject_ca.sh /data/local/tmp/<hash>.0
|
|
CERT="$1"
|
|
DIR=/data/local/tmp/cacerts
|
|
APEX=/apex/com.android.conscrypt/cacerts
|
|
|
|
[ -f "$CERT" ] || { echo "cert not found: $CERT"; exit 1; }
|
|
|
|
rm -rf "$DIR"
|
|
mkdir -p "$DIR"
|
|
cp "$APEX"/* "$DIR"/
|
|
cp "$CERT" "$DIR"/
|
|
chown -R root:root "$DIR"
|
|
chmod 755 "$DIR"
|
|
chmod 644 "$DIR"/*
|
|
chcon -R u:object_r:system_file:s0 "$DIR"
|
|
echo "certs prepared: $(ls "$DIR" | wc -l)"
|
|
|
|
bind_into() {
|
|
nsenter --mount=/proc/$1/ns/mnt -- /system/bin/mount --bind "$DIR" "$APEX" 2>/dev/null
|
|
}
|
|
|
|
ZYGOTES="$(pidof zygote) $(pidof zygote64)"
|
|
for Z in $ZYGOTES; do
|
|
bind_into "$Z" && echo "zygote $Z ok"
|
|
done
|
|
|
|
for Z in $ZYGOTES; do
|
|
for P in $(ps -o PID= -P "$Z"); do
|
|
bind_into "$P" &
|
|
done
|
|
done
|
|
wait
|
|
echo done
|