mirror of https://github.com/2dust/v2rayN
Unix platform elevation enhancements v2 (#7658)
* Remove multiple send password actions on Unix elev * Remove CoreAdminHandler password verification This is useless since already handled in v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs with CheckSudoPasswordAsync(). * Disable caching and prompt for sudo call * Cleanup CoreAdminHandler pwd verify remains * Migrate sudo opts to initial pwd verificationpull/7673/head
parent
74bb01d044
commit
ce7c41e3ff
|
@ -9,7 +9,6 @@ public class CoreAdminHandler
|
|||
private static readonly Lazy<CoreAdminHandler> _instance = new(() => new());
|
||||
public static CoreAdminHandler Instance => _instance.Value;
|
||||
private Config _config;
|
||||
private readonly string _sudoAccessText = "SUDO_ACCESS_VERIFIED";
|
||||
private Action<bool, string>? _updateFunc;
|
||||
private int _linuxSudoPid = -1;
|
||||
|
||||
|
@ -50,17 +49,10 @@ public class CoreAdminHandler
|
|||
}
|
||||
};
|
||||
|
||||
var sudoVerified = false;
|
||||
DataReceivedEventHandler dataHandler = (sender, e) =>
|
||||
{
|
||||
if (e.Data.IsNotEmpty())
|
||||
{
|
||||
if (!sudoVerified && e.Data.Contains(_sudoAccessText))
|
||||
{
|
||||
sudoVerified = true;
|
||||
UpdateFunc(false, ResUI.SudoPwdVerfiedSuccessTip + Environment.NewLine);
|
||||
return;
|
||||
}
|
||||
UpdateFunc(false, e.Data + Environment.NewLine);
|
||||
}
|
||||
};
|
||||
|
@ -72,8 +64,6 @@ public class CoreAdminHandler
|
|||
proc.BeginOutputReadLine();
|
||||
proc.BeginErrorReadLine();
|
||||
|
||||
await Task.Delay(10);
|
||||
await proc.StandardInput.WriteLineAsync(AppHandler.Instance.LinuxSudoPwd);
|
||||
await Task.Delay(10);
|
||||
await proc.StandardInput.WriteLineAsync(AppHandler.Instance.LinuxSudoPwd);
|
||||
|
||||
|
@ -118,7 +108,7 @@ public class CoreAdminHandler
|
|||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine($"sudo -S echo \"{_sudoAccessText}\" && sudo -S {cmdLine}");
|
||||
sb.AppendLine($"sudo -S -k -p '' {cmdLine}");
|
||||
}
|
||||
|
||||
await File.WriteAllTextAsync(shFilePath, sb.ToString());
|
||||
|
|
|
@ -64,8 +64,8 @@ public partial class SudoPasswordInputView : UserControl
|
|||
{
|
||||
try
|
||||
{
|
||||
// Use sudo -S echo command to verify password
|
||||
var arg = new List<string>() { "-c", "sudo -S echo SUDO_CHECK" };
|
||||
// Use sudo echo command to verify password
|
||||
var arg = new List<string>() { "-c", "sudo -S -k -p '' echo SUDO_CHECK" };
|
||||
var result = await CliWrap.Cli
|
||||
.Wrap(Global.LinuxBash)
|
||||
.WithArguments(arg)
|
||||
|
|
Loading…
Reference in New Issue