From 9c24112d12d5cff648f7261ff83ae4c5f3bd0d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 22 Oct 2026 00:07:00 +0800 Subject: [PATCH] Fix unshare network namespace with capabilities --- cmd/sing-box/cmd_run_userns_linux.go | 8 +++++++- common/netns/manager_linux.go | 24 +++++++++++++++++++++--- common/netns/netns.go | 3 +++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/cmd/sing-box/cmd_run_userns_linux.go b/cmd/sing-box/cmd_run_userns_linux.go index aacd39cd..fc7bbd26 100644 --- a/cmd/sing-box/cmd_run_userns_linux.go +++ b/cmd/sing-box/cmd_run_userns_linux.go @@ -15,6 +15,8 @@ import ( "golang.org/x/sys/unix" ) +var initialDir, _ = os.Getwd() + func runInUserNamespaceIfNeeded(options option.Options, optionsList []*OptionsEntry) error { if !common.Any(options.NetworkNamespaces, func(namespace option.NetworkNamespace) bool { return namespace.Type == C.NetNsTypeUnshare @@ -31,8 +33,12 @@ func runInUserNamespaceIfNeeded(options option.Options, optionsList []*OptionsEn if data[0].Effective&(1<