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());
|
private static readonly Lazy<CoreAdminHandler> _instance = new(() => new());
|
||||||
public static CoreAdminHandler Instance => _instance.Value;
|
public static CoreAdminHandler Instance => _instance.Value;
|
||||||
private Config _config;
|
private Config _config;
|
||||||
private readonly string _sudoAccessText = "SUDO_ACCESS_VERIFIED";
|
|
||||||
private Action<bool, string>? _updateFunc;
|
private Action<bool, string>? _updateFunc;
|
||||||
private int _linuxSudoPid = -1;
|
private int _linuxSudoPid = -1;
|
||||||
|
|
||||||
|
@ -50,17 +49,10 @@ public class CoreAdminHandler
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var sudoVerified = false;
|
|
||||||
DataReceivedEventHandler dataHandler = (sender, e) =>
|
DataReceivedEventHandler dataHandler = (sender, e) =>
|
||||||
{
|
{
|
||||||
if (e.Data.IsNotEmpty())
|
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);
|
UpdateFunc(false, e.Data + Environment.NewLine);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -72,8 +64,6 @@ public class CoreAdminHandler
|
||||||
proc.BeginOutputReadLine();
|
proc.BeginOutputReadLine();
|
||||||
proc.BeginErrorReadLine();
|
proc.BeginErrorReadLine();
|
||||||
|
|
||||||
await Task.Delay(10);
|
|
||||||
await proc.StandardInput.WriteLineAsync(AppHandler.Instance.LinuxSudoPwd);
|
|
||||||
await Task.Delay(10);
|
await Task.Delay(10);
|
||||||
await proc.StandardInput.WriteLineAsync(AppHandler.Instance.LinuxSudoPwd);
|
await proc.StandardInput.WriteLineAsync(AppHandler.Instance.LinuxSudoPwd);
|
||||||
|
|
||||||
|
@ -118,7 +108,7 @@ public class CoreAdminHandler
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.AppendLine($"sudo -S echo \"{_sudoAccessText}\" && sudo -S {cmdLine}");
|
sb.AppendLine($"sudo -S -k -p '' {cmdLine}");
|
||||||
}
|
}
|
||||||
|
|
||||||
await File.WriteAllTextAsync(shFilePath, sb.ToString());
|
await File.WriteAllTextAsync(shFilePath, sb.ToString());
|
||||||
|
|
|
@ -64,8 +64,8 @@ public partial class SudoPasswordInputView : UserControl
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Use sudo -S echo command to verify password
|
// Use sudo echo command to verify password
|
||||||
var arg = new List<string>() { "-c", "sudo -S echo SUDO_CHECK" };
|
var arg = new List<string>() { "-c", "sudo -S -k -p '' echo SUDO_CHECK" };
|
||||||
var result = await CliWrap.Cli
|
var result = await CliWrap.Cli
|
||||||
.Wrap(Global.LinuxBash)
|
.Wrap(Global.LinuxBash)
|
||||||
.WithArguments(arg)
|
.WithArguments(arg)
|
||||||
|
|
Loading…
Reference in New Issue