@@ -30,7 +30,7 @@ RemoteMachineComboBox::RemoteMachineComboBox(QWidget* parent):
3030
3131#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0))
3232 // placeholder text is only supported in Qt 4.7 onwards
33- mUI .host ->setPlaceholderText (QObject::tr (" username@hostname" ));
33+ mUI .host ->setPlaceholderText (QObject::tr (" username@hostname [sudo] " ));
3434#endif
3535
3636 mQSettings = new QSettings (this );
@@ -77,11 +77,12 @@ unsigned int RemoteMachineComboBox::getRecentMachineCount() const
7777 return mRecentTargets .size ();
7878}
7979
80- void RemoteMachineComboBox::notifyTargetUsed (const QString& target)
80+ void RemoteMachineComboBox::notifyTargetUsed (const QString& target, bool userIsSudoer )
8181{
8282 QString host;
8383 unsigned short port;
84- OscapScannerRemoteSsh::splitTarget (target, host, port);
84+ bool placeholder;
85+ OscapScannerRemoteSsh::splitTarget (target, host, port, placeholder);
8586
8687 // skip invalid suggestions
8788 if (host.isEmpty () || port == 0 )
@@ -90,7 +91,8 @@ void RemoteMachineComboBox::notifyTargetUsed(const QString& target)
9091 const unsigned int machineCount = getRecentMachineCount ();
9192
9293 // this moves target to the beginning of the list if it was in the list already
93- mRecentTargets .prepend (target);
94+ QString targetWithSudo = target + (userIsSudoer ? " sudo" : " " );
95+ mRecentTargets .prepend (targetWithSudo);
9496 mRecentTargets .removeDuplicates ();
9597
9698 setRecentMachineCount (machineCount);
@@ -106,6 +108,7 @@ void RemoteMachineComboBox::clearHistory()
106108{
107109 mUI .host ->setText (" " );
108110 mUI .port ->setValue (22 );
111+ mUI .userIsSudoer ->setChecked (false );
109112
110113 const unsigned int machineCount = getRecentMachineCount ();
111114 mRecentTargets .clear ();
@@ -167,6 +170,7 @@ void RemoteMachineComboBox::updateHostPort(int index)
167170 {
168171 mUI .host ->setText (" " );
169172 mUI .port ->setValue (22 );
173+ mUI .userIsSudoer ->setChecked (false );
170174 return ;
171175 }
172176
@@ -179,10 +183,11 @@ void RemoteMachineComboBox::updateHostPort(int index)
179183
180184 QString host;
181185 unsigned short port;
186+ bool userIsSudoer;
182187
183- OscapScannerRemoteSsh::splitTarget (target, host, port);
188+ OscapScannerRemoteSsh::splitTarget (target, host, port, userIsSudoer );
184189
185190 mUI .host ->setText (host);
186191 mUI .port ->setValue (port);
187-
192+ mUI . userIsSudoer -> setChecked (userIsSudoer);
188193}
0 commit comments