Enhance logging for Unix elevation failure

This commit is contained in:
maximilionus 2025-07-23 17:23:39 +03:00
parent bf1c601cb5
commit 69c1f4713e

View file

@ -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;