mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Add KernelSU root permission detection for auto-redirect
This commit is contained in:
parent
a2575526b6
commit
888487021d
@ -61,17 +61,20 @@ func newAutoRedirect(t *Tun) (*tunAutoRedirect, error) {
|
|||||||
suPath string
|
suPath string
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if t.platformInterface != nil {
|
for _, suPath = range []string{
|
||||||
suPath, err = exec.LookPath("/bin/su")
|
"su",
|
||||||
} else {
|
"/system/bin/su",
|
||||||
suPath, err = exec.LookPath("su")
|
} {
|
||||||
|
suPath, err = exec.LookPath(suPath)
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err != nil {
|
||||||
s.androidSu = true
|
|
||||||
s.suPath = suPath
|
|
||||||
} else {
|
|
||||||
return nil, E.Extend(E.Cause(err, "root permission is required for auto redirect"), os.Getenv("PATH"))
|
return nil, E.Extend(E.Cause(err, "root permission is required for auto redirect"), os.Getenv("PATH"))
|
||||||
}
|
}
|
||||||
|
s.androidSu = true
|
||||||
|
s.suPath = suPath
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err := s.initializeNfTables()
|
err := s.initializeNfTables()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user