diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index 15f111d4..42cd6a3b 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -857,7 +857,7 @@ namespace ServiceLib.Common private static async Task GetLinuxUserId() { var arg = new List() { "-c", "id -u" }; - return await GetCliWrapOutput("/bin/bash", arg); + return await GetCliWrapOutput(Global.LinuxBash, arg); } public static async Task SetLinuxChmod(string? fileName) @@ -868,14 +868,14 @@ namespace ServiceLib.Common fileName = fileName.AppendQuotes(); //File.SetUnixFileMode(fileName, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); var arg = new List() { "-c", $"chmod +x {fileName}" }; - return await GetCliWrapOutput("/bin/bash", arg); + return await GetCliWrapOutput(Global.LinuxBash, arg); } public static async Task GetLinuxFontFamily(string lang) { // var arg = new List() { "-c", $"fc-list :lang={lang} family" }; var arg = new List() { "-c", $"fc-list : family" }; - return await GetCliWrapOutput("/bin/bash", arg); + return await GetCliWrapOutput(Global.LinuxBash, arg); } public static string? GetHomePath() @@ -888,7 +888,7 @@ namespace ServiceLib.Common public static async Task GetListNetworkServices() { var arg = new List() { "-c", $"networksetup -listallnetworkservices" }; - return await GetCliWrapOutput("/bin/bash", arg); + return await GetCliWrapOutput(Global.LinuxBash, arg); } #endregion Platform diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index eb972879..fbda8abf 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -71,6 +71,7 @@ namespace ServiceLib public const string V2RayLocalAsset = "V2RAY_LOCATION_ASSET"; public const string XrayLocalAsset = "XRAY_LOCATION_ASSET"; public const int SpeedTestPageSize = 1000; + public const string LinuxBash = "/bin/bash"; public static readonly List IEProxyProtocols = [ diff --git a/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs b/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs index 79ade84b..0d85acfb 100644 --- a/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs +++ b/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs @@ -177,7 +177,7 @@ namespace ServiceLib.Handler if (File.Exists(launchAgentPath)) { var args = new[] { "-c", $"launchctl unload -w \"{launchAgentPath}\"" }; - await Utils.GetCliWrapOutput("/bin/bash", args); + await Utils.GetCliWrapOutput(Global.LinuxBash, args); File.Delete(launchAgentPath); } @@ -197,7 +197,7 @@ namespace ServiceLib.Handler await File.WriteAllTextAsync(launchAgentPath, plistContent); var args = new[] { "-c", $"launchctl load -w \"{launchAgentPath}\"" }; - await Utils.GetCliWrapOutput("/bin/bash", args); + await Utils.GetCliWrapOutput(Global.LinuxBash, args); } catch (Exception ex) { diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs index 386e28fa..d64d22b7 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs @@ -116,7 +116,7 @@ namespace ServiceLib.Services.CoreConfig //enable tun mode if (_config.TunModeItem.EnableTun) { - string tun = EmbedUtils.GetEmbedText(Global.ClashTunYaml); + var tun = EmbedUtils.GetEmbedText(Global.ClashTunYaml); if (Utils.IsNotEmpty(tun)) { var tunContent = YamlUtils.FromYaml>(tun);