From 69c1f4713e6a91012f213012c0eee0fdeb6e273c Mon Sep 17 00:00:00 2001 From: maximilionus Date: Wed, 23 Jul 2025 17:23:39 +0300 Subject: [PATCH] Enhance logging for Unix elevation failure --- v2rayN/ServiceLib/Handler/CoreAdminHandler.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/CoreAdminHandler.cs b/v2rayN/ServiceLib/Handler/CoreAdminHandler.cs index ee197b64..45fedf8e 100644 --- a/v2rayN/ServiceLib/Handler/CoreAdminHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreAdminHandler.cs @@ -53,13 +53,18 @@ public class CoreAdminHandler _linuxSudoPid = cmdTask.ProcessId; - process = Process.GetProcessById(_linuxSudoPid); - await Task.Delay(5000); // Sudo exit on wrong password takes 2-4 sec. - if (process.HasExited || process is null) + try + { + process = Process.GetProcessById(_linuxSudoPid); + await Task.Delay(5000); // Sudo exit on wrong password takes 2-4 sec. + if (process.HasExited) + throw new InvalidOperationException("Process exited too soon, likely improper sudo password."); + } + catch (Exception ex) { _linuxSudoPid = -1; - throw new Exception(ResUI.FailedToRunCore); + throw new Exception(ResUI.FailedToRunCore, ex); } return process;