-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdaemon.sh
More file actions
executable file
·47 lines (35 loc) · 844 Bytes
/
Copy pathdaemon.sh
File metadata and controls
executable file
·47 lines (35 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/system/bin/sh
MODDIR=${0%/*}
SOCAT="$MODDIR/bin/socat"
USER_SOCK="/data/local/host.user.sock"
ROOT_SOCK="/data/local/host.root.sock"
LOG="/data/local/hostsocket.log"
log() {
echo "[$(date)] $*" >> "$LOG"
}
cleanup() {
log "Exiting..."
rm -f "$USER_SOCK" "$ROOT_SOCK"
}
trap cleanup EXIT
cleanup
start_user() {
log "Starting USER socket"
$SOCAT UNIX-LISTEN:$USER_SOCK,mode=660,fork EXEC:"su shell -c /system/bin/sh",pty,stderr,setsid,sigint,sane
}
start_root() {
log "Starting ROOT socket"
$SOCAT UNIX-LISTEN:$ROOT_SOCK,mode=660,fork EXEC:"su -c /system/bin/sh",pty,stderr,setsid,sigint,sane
}
while true; do
start_user &
U_PID=$!
start_root &
R_PID=$!
wait $U_PID
log "User socket died"
wait $R_PID
log "Root socket died"
log "Restarting in 1s..."
sleep 1
done