bug in asking password resolved.

This commit is contained in:
2023-04-26 17:30:38 +02:00
parent 659498c826
commit 975361c8c9
3 changed files with 127 additions and 91 deletions
+31 -10
View File
@@ -383,7 +383,8 @@ bool MainWindow::testServicePresence(QString service, bool askPassword)
QStringList v;
QProcess *myProcess;
bool returnValue = false;
QEventLoop loop;
int loop =0;
bool r = false;
cmd = "/usr/bin/rsync";
param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << this->connexion.server + "::" + service;
@@ -405,9 +406,10 @@ bool MainWindow::testServicePresence(QString service, bool askPassword)
}
if (line.contains("auth failed"))
{
if (askPassword)
if (askPassword == true and loop >=2 and r == true)
{
getUserPassword(&this->connexion);
r = getUserPassword(&this->connexion);
loop++;
}
returnValue = true;
}
@@ -487,6 +489,8 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
bool readOk = false;
bool passwdOk = false;
int nChild = 0;
bool r;
static uint looping;
myProcess = new QProcess(this);
myProcess->setProcessChannelMode(QProcess::MergedChannels);
@@ -531,9 +535,23 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
}
if (line.contains("auth failed"))
{
myProcess->readAllStandardOutput();
getUserPassword(&this->connexion);
return 0;
myProcess->readAllStandardOutput();
r = getUserPassword(&this->connexion);
if (looping <= 1)
{
this->rescan = true;
looping++;
}else
{
this->rescan = false;
looping = 0;
QMessageBox::warning(
this,
a.applicationName(),
tr("Authentication failed" )
);
}
return false;
}
// extracting name, size and if is dir/file
@@ -593,7 +611,7 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
testRsyncReturn(this, myProcess);
myProcess->close();
}
return 0;
return false;
}
// Verify if server address is IP address
@@ -609,7 +627,7 @@ bool MainWindow::isIpAddress(QString server)
for (auto element : r)
{
elementN = element.toInt(&ok);
if (elementN < 0 or elementN > 255 or ok == false)
if ((elementN < 0) or (elementN > 255) or ok == false)
{
return false;
}
@@ -777,8 +795,8 @@ void MainWindow::preparePopulateTree()
bool MainWindow::getUserPassword(Connexion * object)
{
QStringList logins;
QString login;
QString password;
QString login = "";
QString password = "";
QString server;
QString service;
int c;
@@ -820,10 +838,12 @@ bool MainWindow::getUserPassword(Connexion * object)
if (!ok or password.isEmpty())
{
password = "";
returnValue = false;
}
}else
{
password = getPassword(login);
returnValue = true;
}
object->user = login;
object->password = password;
@@ -955,6 +975,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
{
scanDir(this->connexion.server, this->connexion.port, item, this->connexion.service + "/" + path +"/");
item->setExpanded(true);
}
}