Skip to content

Commit 8577f6a

Browse files
committed
Handle Android devices with APEX + multiple zygote processes
1 parent ecac7cc commit 8577f6a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/interceptors/android/adb-commands.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,12 @@ export async function injectSystemCertificate(
306306
# First we get the Zygote process(es), which launch each app
307307
ZYGOTE_PID=$(pidof zygote || true)
308308
ZYGOTE64_PID=$(pidof zygote64 || true)
309-
# N.b. some devices appear to have both!
309+
Z_PIDS="$ZYGOTE_PID $ZYGOTE64_PID"
310+
# N.b. some devices appear to have both, some have >1 of each (!)
310311
311312
# Apps inherit the Zygote's mounts at startup, so we inject here to ensure all newly
312313
# started apps will see these certs straight away:
313-
for Z_PID in "$ZYGOTE_PID" "$ZYGOTE64_PID"; do
314+
for Z_PID in $Z_PIDS; do
314315
if [ -n "$Z_PID" ]; then
315316
nsenter --mount=/proc/$Z_PID/ns/mnt -- \
316317
/bin/mount --bind /system/etc/security/cacerts /apex/com.android.conscrypt/cacerts
@@ -323,7 +324,7 @@ export async function injectSystemCertificate(
323324
324325
# Get the PID of every process whose parent is one of the Zygotes:
325326
APP_PIDS=$(
326-
echo "$ZYGOTE_PID $ZYGOTE64_PID" | \
327+
echo $Z_PIDS | \
327328
xargs -n1 ps -o 'PID' -P | \
328329
grep -v PID
329330
)

0 commit comments

Comments
 (0)