mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-12-02 06:38:36 +00:00
merge: Merge upstream v1.14.6
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"unicode"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-tun"
|
||||
"github.com/sagernet/sing/common"
|
||||
@@ -87,7 +88,7 @@ func (s *linuxSearcher) FindProcessInfo(ctx context.Context, network string, sou
|
||||
processPath, err := s.findProcessPath(inode, uid)
|
||||
if err != nil {
|
||||
s.logger.DebugContext(ctx, "find process path: ", err)
|
||||
} else {
|
||||
} else if !C.IsAndroid || !strings.HasPrefix(processPath, "/system/bin/app_process") {
|
||||
processInfo.ProcessPath = processPath
|
||||
}
|
||||
if s.packageManager != nil {
|
||||
@@ -129,9 +130,14 @@ func (s *linuxSearcher) resolveSocketByNetlink(network string, source netip.Addr
|
||||
|
||||
// The socket keeps the uid it was created with, while /proc reflects the
|
||||
// current uid of the process, so a socket created before a privilege drop
|
||||
// only appears under a scan of all users.
|
||||
// only appears under a scan of all users. On Android, netd chowns the DNS
|
||||
// sockets it opens on behalf of an app to the app's uid.
|
||||
func (s *linuxSearcher) findProcessPath(targetInode, uid uint32) (string, error) {
|
||||
for _, scanUID := range []uint32{uid, processPathsAllUsers} {
|
||||
scanUIDs := []uint32{uid}
|
||||
if !C.IsAndroid {
|
||||
scanUIDs = append(scanUIDs, processPathsAllUsers)
|
||||
}
|
||||
for _, scanUID := range scanUIDs {
|
||||
if cached, ok := s.processPathCache.Get(scanUID); ok {
|
||||
if processPath, found := cached.entries[targetInode]; found {
|
||||
return processPath, nil
|
||||
@@ -180,6 +186,7 @@ func buildProcessPaths(uid uint32) (map[uint32]string, error) {
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
exePath = strings.TrimSuffix(exePath, " (deleted)")
|
||||
fds, err := os.ReadDir(fdPath)
|
||||
if err != nil {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user