Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit 1fd9bc8

Browse files
committed
Updated message handling of sudo-related issues.
1 parent 0e48a71 commit 1fd9bc8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

include/OscapScannerRemoteSsh.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class OscapScannerRemoteSsh : public OscapScannerBase
4343
virtual QStringList getCommandLineArgs() const;
4444
virtual void evaluate();
4545

46+
protected:
47+
48+
virtual void selectError(MessageType& kind, const QString& message);
49+
virtual void processError(QString& message);
50+
4651
private:
4752
void ensureConnected();
4853

src/OscapScannerRemoteSsh.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,29 @@ void OscapScannerRemoteSsh::evaluate()
344344
signalCompletion(mCancelRequested);
345345
}
346346

347+
void OscapScannerRemoteSsh::selectError(MessageType& kind, const QString& message)
348+
{
349+
OscapScannerBase::selectError(kind, message);
350+
if (mUserIsSudoer)
351+
{
352+
if (message.contains(QRegExp("^sudo:")))
353+
{
354+
kind = MSG_ERROR;
355+
}
356+
}
357+
358+
}
359+
360+
void OscapScannerRemoteSsh::processError(QString& message)
361+
{
362+
OscapScannerBase::processError(message);
363+
if (mUserIsSudoer && message.contains(QRegExp("^sudo:")))
364+
{
365+
message.replace(QRegExp("^sudo:"), "Error invoking sudo on the host:");
366+
message += ".\nOnly passwordless sudo setup on the remote host is supported by scap-workbench.";
367+
}
368+
}
369+
347370
void OscapScannerRemoteSsh::ensureConnected()
348371
{
349372
if (mSshConnection.isConnected())

0 commit comments

Comments
 (0)