From 8ccc8bb1d7fc9216657bca8b974801eed9ed9536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 1 Jun 2024 11:05:57 +0800 Subject: [PATCH] fix --- inbound/tun_auto_redirect.go | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/inbound/tun_auto_redirect.go b/inbound/tun_auto_redirect.go index a7a97ce1..c79232f7 100644 --- a/inbound/tun_auto_redirect.go +++ b/inbound/tun_auto_redirect.go @@ -61,26 +61,20 @@ func newAutoRedirect(t *Tun) (*tunAutoRedirect, error) { suPath string err error ) - if t.platformInterface != nil { - suPaths := []string{ - "/bin/su", - "/system/bin/su", + for _, suPath = range []string{ + "su", + "/system/bin/su", + } { + suPath, err = exec.LookPath(suPath) + if err == nil { + break } - for _, path := range suPaths { - suPath, err = exec.LookPath(path) - if err == nil { - break - } - } - } else { - suPath, err = exec.LookPath("su") } - if err == nil { - s.androidSu = true - s.suPath = suPath - } else { + if err != nil { return nil, E.Extend(E.Cause(err, "root permission is required for auto redirect"), os.Getenv("PATH")) } + s.androidSu = true + s.suPath = suPath } } else { err := s.initializeNfTables()