From 0efb0b5e3eb97c143fcc1b32cb59a7973db53f78 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 25 Oct 2024 10:10:55 +0800 Subject: [PATCH] Give core execute permission at runtime --- v2rayN/ServiceLib/Handler/CoreHandler.cs | 23 ++++++++++++++++++- .../ViewModels/MainWindowViewModel.cs | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index 001170cc..33d78f74 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -15,13 +15,34 @@ namespace ServiceLib.Handler private Process? _processPre; private Action? _updateFunc; - public void Init(Config config, Action updateFunc) + public async Task Init(Config config, Action updateFunc) { _config = config; _updateFunc = updateFunc; Environment.SetEnvironmentVariable("V2RAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("XRAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process); + + if (Utils.IsLinux()) + { + var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); + foreach (var it in coreInfo) + { + if (it.CoreType == ECoreType.v2rayN) + { + continue; + } + + foreach (var vName in it.CoreExes) + { + var exe = Utils.GetExeName(Utils.GetBinPath(vName, it.CoreType.ToString())); + if (File.Exists(exe)) + { + await Utils.SetLinuxChmod(exe); + } + } + } + } } public async Task LoadCore(ProfileItem? node) diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index efedf556..e1961b2a 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -208,7 +208,7 @@ namespace ServiceLib.ViewModels await ConfigHandler.InitBuiltinRouting(_config); await ConfigHandler.InitBuiltinDNS(_config); - CoreHandler.Instance.Init(_config, UpdateHandler); + await CoreHandler.Instance.Init(_config, UpdateHandler); TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler); if (_config.GuiItem.EnableStatistics)