Skip to content

Commit ef3ba0e

Browse files
authored
Merge pull request #41 from NVISOsecurity/v1.3
V1.3
2 parents ff25ffa + a031a74 commit ef3ba0e

4 files changed

Lines changed: 55 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v1.3
2+
3+
* Fixed bug on A14
4+
* Fixed bug on A15/A16
5+
16
## v1.2
27

38
* Added automatic update support

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Features:
88
* Support for Magisk/KernelSU/KernelSU Next
99
* Support for devices with and without mainline/conscrypt updates
1010

11-
## Conscrypt certs or not
11+
Depending on your Android version and Google Play Security Update version, your certificates will be either stored in `/system/etc/security/cacerts` or in `/apex/com.android.conscrypt/cacerts/`. This module handles all scenarios and works on any device from Android 7 until Android 16.
1212

13-
Depending on your Android version and Google Play Security Update version, your certificates will be either stored in `/system/etc/security/cacerts` or in `/apex/com.android.conscrypt/cacerts/`. This module handles all scenarios and should work on any device from Android 7 until Android 16.
13+
## Usage
1414

1515
### Installing certificates
1616

@@ -22,6 +22,10 @@ Remove the certificate from the user store through the settings and restart the
2222

2323
## Changelog
2424

25+
### v1.3
26+
27+
* Fixed bug on A14+
28+
2529
### v1.2
2630

2731
* Added automatic update support

module.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id=trustusercerts
22
name=Always Trust User Certificates
3-
version=v1.2
4-
versionCode=44
3+
version=v1.3
4+
versionCode=45
55
author=Jeroen Beckers (NVISO.eu)
66
description=Copy user certs to the system trust store
77
updateJson=https://raw.githubusercontent.com/NVISOsecurity/AlwaysTrustUserCerts/master/update.json

service.sh

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,59 @@ log() {
77
echo "$(date '+%m-%d %H:%M:%S ')" "$@" >> $MODDIR/log.txt
88
}
99

10-
inject_into_zygote(){
10+
has_mount() {
11+
local pid="$1"
12+
grep -q " $APEX_CERT_DIR " "/proc/$pid/mountinfo"
13+
}
14+
15+
monitor_zygote(){
1116

12-
log "Injecting into Zygote"
17+
(
18+
while true; do
1319

14-
# Collect all zygote PIDs (both 32‑ and 64‑bit)
15-
zygote_pids=""
16-
for name in zygote zygote64; do
17-
for p in $(pidof $name 2>/dev/null); do
18-
zygote_pids="$zygote_pids $p"
20+
# Collect all zygote PIDs (both 32‑ and 64‑bit)
21+
zygote_pids=""
22+
for name in zygote zygote64; do
23+
for p in $(pidof $name 2>/dev/null); do
24+
zygote_pids="$zygote_pids $p"
25+
done
1926
done
20-
done
2127

22-
log "Zygote PIDs: $zygote_pids"
28+
for zp in $zygote_pids; do
29+
30+
# if our bind isn’t present, re-apply it
31+
if ! has_mount "$pid"; then
2332

24-
for zp in $zygote_pids; do
25-
log "zygote PID: $zp"
33+
# Get active children
34+
children=$(echo "$zp" | xargs -n1 ps -o pid -P | grep -v PID)
2635

27-
log " Injecting into $zp"
28-
/system/bin/nsenter --mount=/proc/$zp/ns/mnt -- /bin/mount --bind $APEX_CERT_DIR $APEX_CERT_DIR
36+
# Fallback for old Android ps (columns: USER PID PPID ...):
37+
if [ -z "$children" ]; then
38+
children=$(ps \
39+
| awk -v PPID=$zp '$3==PPID { print $2 }')
40+
fi
2941

30-
# Get active children
31-
children=$(echo "$zp" | xargs -n1 ps -o pid -P | grep -v PID)
42+
# After a crash, zygote is a bit unstable, so waiting to settle.
43+
if [ "$(echo "$children" | wc -l)" -lt 5 ]; then
44+
/system/bin/sleep 1s
45+
continue
46+
fi
3247

33-
# Fallback for old Android ps (columns: USER PID PPID ...):
34-
if [ -z "$children" ]; then
35-
children=$(ps \
36-
| awk -v PPID=$zp '$3==PPID { print $2 }')
37-
fi
48+
log "Injecting into zygote ($zp)"
49+
/system/bin/nsenter --mount=/proc/$zp/ns/mnt -- /bin/mount --rbind $SYS_CERT_DIR $APEX_CERT_DIR
3850

39-
for pid in $children; do
40-
log " Injecting into child: $pid"
41-
/system/bin/nsenter --mount=/proc/$pid/ns/mnt -- /bin/mount --bind $APEX_CERT_DIR $APEX_CERT_DIR
4251

52+
for pid in $children; do
53+
if ! has_mount "$pid"; then
54+
log " Injecting into child $pid"
55+
/system/bin/nsenter --mount=/proc/$pid/ns/mnt -- /bin/mount --rbind $SYS_CERT_DIR $APEX_CERT_DIR
56+
fi
57+
done
58+
fi
4359
done
60+
sleep 5
4461
done
62+
)&
4563
}
4664

4765
main(){
@@ -65,7 +83,7 @@ main(){
6583
chmod 644 $SYS_CERT_DIR/*
6684
chcon u:object_r:system_security_cacerts_file:s0 $SYS_CERT_DIR/*
6785

68-
inject_into_zygote
86+
monitor_zygote
6987
else
7088
# /system certs are automatically mounted by Magisk due to collection in post-fs-data
7189
log "No conscrypt"

0 commit comments

Comments
 (0)