Skip to content

Commit

Permalink
Merge branch 'sudo_permissions' of https://github.com/amnezia-vpn/amn…
Browse files Browse the repository at this point in the history
…ezia-client into sudo_permissions
  • Loading branch information
lunardunno committed Mar 1, 2025
2 parents fd06f8a + 90e25e9 commit a97535a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions client/core/controllers/serverController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,10 +757,6 @@ ErrorCode ServerController::isServerPortBusy(const ServerCredentials &credential

ErrorCode ServerController::isUserInSudo(const ServerCredentials &credentials, DockerContainer container)
{
if (credentials.userName == "root") {
return ErrorCode::NoError;
}

QString stdOut;
auto cbReadStdOut = [&](const QString &data, libssh::Client &) {
stdOut += data + "\n";
Expand All @@ -774,8 +770,14 @@ ErrorCode ServerController::isUserInSudo(const ServerCredentials &credentials, D
const QString scriptData = amnezia::scriptData(SharedScriptType::check_user_in_sudo);
ErrorCode error = runScript(credentials, replaceVars(scriptData, genVarsForScript(credentials)), cbReadStdOut, cbReadStdErr);

if (!stdOut.contains("sudo"))
if (credentials.userName != "root" && !stdOut.contains("sudo") && !stdOut.contains("wheel"))
return ErrorCode::ServerUserNotInSudo;
if (credentials.userName != "root" && stdOut.contains("sudo:") && !stdOut.contains("uname:") && stdOut.contains("not found"))
return ErrorCode::SudoPackageIsNotPreinstalled;
if (stdOut.contains("sudoers"))
return ErrorCode::ServerUserNotAllowedInSudoers;
if (stdOut.contains("password is required"))
return ErrorCode::ServerUserPasswordRequired;

return error;
}
Expand Down

0 comments on commit a97535a

Please sign in to comment.