Improve CoreAdminHandler null obj init

pull/7639/head
maximilionus 2025-07-24 17:12:27 +03:00
parent 7620dac3a0
commit 0b7d728b04
1 changed files with 2 additions and 3 deletions

View File

@ -29,9 +29,9 @@ public class CoreAdminHandler
public async Task<Process?> RunProcessAsLinuxSudo(string fileName, CoreInfo coreInfo, string configPath)
{
Process process = null;
var cmdLine = $"{fileName.AppendQuotes()} {string.Format(coreInfo.Arguments, Utils.GetBinConfigPath(configPath).AppendQuotes())}";
var shFilePath = await CreateLinuxShellFile(cmdLine, "run_as_sudo.sh");
Process? process = null;
var cmdTask = Cli.Wrap(shFilePath)
.WithWorkingDirectory(Utils.GetBinConfigPath())
@ -51,13 +51,12 @@ public class CoreAdminHandler
.WithValidation(CommandResultValidation.None)
.ExecuteAsync();
_linuxSudoPid = cmdTask.ProcessId;
try
{
process = Process.GetProcessById(_linuxSudoPid);
await Task.Delay(5000); // Sudo exit on wrong password takes 2-4 sec.
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.");
}