Commit 5e268181 authored by Lefebvre, Jordan's avatar Lefebvre, Jordan

#2. Windows compliance issues. Still need to resolve POSIX permissions in open...

#2. Windows compliance issues. Still need to resolve POSIX permissions in open file/directory in SFTP.
parent 90e04377
Pipeline #100436 failed with stages
in 4 minutes and 25 seconds
......@@ -5,7 +5,7 @@
#include <libssh/libssh.h>
#include <libssh/sftp.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <cassert>
#include <sstream>
......@@ -233,12 +233,11 @@ SFTPFile::~SFTPFile()
bool SFTPFile::isOpen() { return (p->file != nullptr); }
// returns number of bytes written on success
// on error, returns < 0 and ssh and sftp session errors are set
ssize_t SFTPFile::write(QString str)
size_t SFTPFile::write(QString str)
{
const char* buf = str.toStdString().c_str();
size_t count = strlen(buf);
ssize_t nwritten = sftp_write(p->file, buf, count);
const char* buf = str.toStdString().c_str();
size_t count = strlen(buf);
size_t nwritten = sftp_write(p->file, buf, count);
return nwritten;
}
......@@ -280,10 +279,9 @@ bool SFTPFile::seek(size_t offset)
return true;
}
// returns < 0 on error
ssize_t SFTPFile::tell()
size_t SFTPFile::tell()
{
ssize_t result = static_cast<ssize_t>(sftp_tell64(p->file));
size_t result = static_cast<size_t>(sftp_tell64(p->file));
return result;
}
......@@ -556,7 +554,7 @@ SessionHostState Session::verifyKnownHost() const
int rc = ssh_get_server_publickey(p->session, &server_public_key);
if (rc < 0)
{
return SessionHostState::ERROR;
return SessionHostState::ERROR_STATE;
}
rc = ssh_get_publickey_hash(server_public_key, SSH_PUBLICKEY_HASH_SHA1, &hash,
......@@ -565,7 +563,7 @@ SessionHostState Session::verifyKnownHost() const
ssh_key_free(server_public_key);
if (rc < 0)
{
return SessionHostState::ERROR;
return SessionHostState::ERROR_STATE;
}
state = ssh_session_is_known_server(p->session);
......@@ -682,7 +680,7 @@ SessionAuthState Session::authenticatePrompts(QStringList responses)
if (err < 0)
{
ssh_disconnect(p->session);
return SessionAuthState::ERROR;
return SessionAuthState::ERROR_STATE;
}
}
// check status
......
......@@ -15,7 +15,7 @@ enum class SessionAuthState
PARTIAL,
INFO,
AGAIN,
ERROR = -1
ERROR_STATE = -1
};
#define SessionAuthMethodUNKNOWN 0x0000u
......@@ -33,7 +33,7 @@ enum class SessionHostState
{ /**
* There had been an error checking the host.
*/
ERROR = -2,
ERROR_STATE = -2,
/**
* The known host file does not exist. The host is thus unknown. File will
......@@ -350,11 +350,11 @@ class RSM_PUBLIC SFTPFile
SFTPFile(SFTPSession* sftpSession, QString filename, int accessType);
~SFTPFile();
bool isOpen();
ssize_t write(QString str);
size_t write(QString str);
QString read(size_t nBytes);
bool close();
bool seek(size_t offset);
ssize_t tell();
size_t tell();
}; // class SFTPFile
// ----------------------------------------------------------------------------
......
......@@ -132,7 +132,7 @@ void SessionWorker::verifyKnownHost()
radix_tagged_line("SSH_KNOWN_HOSTS_UNKNOWN: " << qhexa.toStdString());
emit hostUnknown(qhexa);
break;
case SessionHostState::ERROR:
case SessionHostState::ERROR_STATE:
QString message = p->session->getError();
radix_tagged_line("SSH_KNOWN_HOSTS_ERROR: " << message.toStdString());
emit knownHostError(message);
......@@ -163,7 +163,7 @@ void SessionWorker::authenticate()
if (method & SessionAuthMethodPUBLICKEY)
{
SessionAuthState state = p->session->authenticateWithPublicKey();
if (state == SessionAuthState::ERROR)
if (state == SessionAuthState::ERROR_STATE)
{
QString message = p->session->getError();
emit authenticationError(message);
......@@ -207,7 +207,8 @@ void SessionWorker::authenticateWithPassword(QString pswd)
{
radix_tagged_line("Authenticate with password.");
SessionAuthState state = p->session->authenticateWithPassword(pswd);
if (state == SessionAuthState::ERROR || state == SessionAuthState::DENIED)
if (state == SessionAuthState::ERROR_STATE ||
state == SessionAuthState::DENIED)
{
QString message = p->session->getError();
emit authenticationError(message);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment