improve linux root request process

This commit is contained in:
Nova 2025-03-26 22:56:19 +03:30
parent e55e5bd81c
commit aec4968f44

View File

@ -803,21 +803,22 @@ bool MainWindow::get_elevated_permissions(int reason) {
}
auto n = QMessageBox::warning(GetMessageBoxParent(), software_name, tr("Please give the core root privileges"), QMessageBox::Yes | QMessageBox::No);
if (n == QMessageBox::Yes) {
auto chownArgs = QString("root:root " + NekoGui::FindNekoBoxCoreRealPath());
auto ret = Linux_Run_Command("chown", chownArgs);
if (ret != 0) {
MW_show_log(QString("Failed to run chown %1 code is %2").arg(chownArgs).arg(ret));
return false;
}
auto chmodArgs = QString("u+s " + NekoGui::FindNekoBoxCoreRealPath());
ret = Linux_Run_Command("chmod", chmodArgs);
if (ret == 0) {
StopVPNProcess();
return true;
} else {
MW_show_log(QString("Failed to run chmod %1").arg(chmodArgs));
return false;
}
runOnNewThread([=]
{
auto chownArgs = QString("root:root " + NekoGui::FindNekoBoxCoreRealPath());
auto ret = Linux_Run_Command("chown", chownArgs);
if (ret != 0) {
MW_show_log(QString("Failed to run chown %1 code is %2").arg(chownArgs).arg(ret));
}
auto chmodArgs = QString("u+s " + NekoGui::FindNekoBoxCoreRealPath());
ret = Linux_Run_Command("chmod", chmodArgs);
if (ret == 0) {
StopVPNProcess();
} else {
MW_show_log(QString("Failed to run chmod %1").arg(chmodArgs));
}
});
return false;
}
#endif
#ifdef Q_OS_WIN