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

#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 @@ ...@@ -5,7 +5,7 @@
#include <libssh/libssh.h> #include <libssh/libssh.h>
#include <libssh/sftp.h> #include <libssh/sftp.h>
#include <fcntl.h> #include <sys/stat.h>
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
...@@ -233,12 +233,11 @@ SFTPFile::~SFTPFile() ...@@ -233,12 +233,11 @@ SFTPFile::~SFTPFile()
bool SFTPFile::isOpen() { return (p->file != nullptr); } bool SFTPFile::isOpen() { return (p->file != nullptr); }
// returns number of bytes written on success // returns number of bytes written on success
// on error, returns < 0 and ssh and sftp session errors are set size_t SFTPFile::write(QString str)
ssize_t SFTPFile::write(QString str)
{ {
const char* buf = str.toStdString().c_str(); const char* buf = str.toStdString().c_str();
size_t count = strlen(buf); size_t count = strlen(buf);
ssize_t nwritten = sftp_write(p->file, buf, count); size_t nwritten = sftp_write(p->file, buf, count);
return nwritten; return nwritten;
} }
...@@ -280,10 +279,9 @@ bool SFTPFile::seek(size_t offset) ...@@ -280,10 +279,9 @@ bool SFTPFile::seek(size_t offset)
return true; return true;
} }
// returns < 0 on error size_t SFTPFile::tell()
ssize_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; return result;
} }
...@@ -556,7 +554,7 @@ SessionHostState Session::verifyKnownHost() const ...@@ -556,7 +554,7 @@ SessionHostState Session::verifyKnownHost() const
int rc = ssh_get_server_publickey(p->session, &server_public_key); int rc = ssh_get_server_publickey(p->session, &server_public_key);
if (rc < 0) if (rc < 0)
{ {
return SessionHostState::ERROR; return SessionHostState::ERROR_STATE;
} }
rc = ssh_get_publickey_hash(server_public_key, SSH_PUBLICKEY_HASH_SHA1, &hash, rc = ssh_get_publickey_hash(server_public_key, SSH_PUBLICKEY_HASH_SHA1, &hash,
...@@ -565,7 +563,7 @@ SessionHostState Session::verifyKnownHost() const ...@@ -565,7 +563,7 @@ SessionHostState Session::verifyKnownHost() const
ssh_key_free(server_public_key); ssh_key_free(server_public_key);
if (rc < 0) if (rc < 0)
{ {
return SessionHostState::ERROR; return SessionHostState::ERROR_STATE;
} }
state = ssh_session_is_known_server(p->session); state = ssh_session_is_known_server(p->session);
...@@ -682,7 +680,7 @@ SessionAuthState Session::authenticatePrompts(QStringList responses) ...@@ -682,7 +680,7 @@ SessionAuthState Session::authenticatePrompts(QStringList responses)
if (err < 0) if (err < 0)
{ {
ssh_disconnect(p->session); ssh_disconnect(p->session);
return SessionAuthState::ERROR; return SessionAuthState::ERROR_STATE;
} }
} }
// check status // check status
......
...@@ -15,7 +15,7 @@ enum class SessionAuthState ...@@ -15,7 +15,7 @@ enum class SessionAuthState
PARTIAL, PARTIAL,
INFO, INFO,
AGAIN, AGAIN,
ERROR = -1 ERROR_STATE = -1
}; };
#define SessionAuthMethodUNKNOWN 0x0000u #define SessionAuthMethodUNKNOWN 0x0000u
...@@ -33,7 +33,7 @@ enum class SessionHostState ...@@ -33,7 +33,7 @@ enum class SessionHostState
{ /** { /**
* There had been an error checking the host. * 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 * The known host file does not exist. The host is thus unknown. File will
...@@ -350,11 +350,11 @@ class RSM_PUBLIC SFTPFile ...@@ -350,11 +350,11 @@ class RSM_PUBLIC SFTPFile
SFTPFile(SFTPSession* sftpSession, QString filename, int accessType); SFTPFile(SFTPSession* sftpSession, QString filename, int accessType);
~SFTPFile(); ~SFTPFile();
bool isOpen(); bool isOpen();
ssize_t write(QString str); size_t write(QString str);
QString read(size_t nBytes); QString read(size_t nBytes);
bool close(); bool close();
bool seek(size_t offset); bool seek(size_t offset);
ssize_t tell(); size_t tell();
}; // class SFTPFile }; // class SFTPFile
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
...@@ -132,7 +132,7 @@ void SessionWorker::verifyKnownHost() ...@@ -132,7 +132,7 @@ void SessionWorker::verifyKnownHost()
radix_tagged_line("SSH_KNOWN_HOSTS_UNKNOWN: " << qhexa.toStdString()); radix_tagged_line("SSH_KNOWN_HOSTS_UNKNOWN: " << qhexa.toStdString());
emit hostUnknown(qhexa); emit hostUnknown(qhexa);
break; break;
case SessionHostState::ERROR: case SessionHostState::ERROR_STATE:
QString message = p->session->getError(); QString message = p->session->getError();
radix_tagged_line("SSH_KNOWN_HOSTS_ERROR: " << message.toStdString()); radix_tagged_line("SSH_KNOWN_HOSTS_ERROR: " << message.toStdString());
emit knownHostError(message); emit knownHostError(message);
...@@ -163,7 +163,7 @@ void SessionWorker::authenticate() ...@@ -163,7 +163,7 @@ void SessionWorker::authenticate()
if (method & SessionAuthMethodPUBLICKEY) if (method & SessionAuthMethodPUBLICKEY)
{ {
SessionAuthState state = p->session->authenticateWithPublicKey(); SessionAuthState state = p->session->authenticateWithPublicKey();
if (state == SessionAuthState::ERROR) if (state == SessionAuthState::ERROR_STATE)
{ {
QString message = p->session->getError(); QString message = p->session->getError();
emit authenticationError(message); emit authenticationError(message);
...@@ -207,7 +207,8 @@ void SessionWorker::authenticateWithPassword(QString pswd) ...@@ -207,7 +207,8 @@ void SessionWorker::authenticateWithPassword(QString pswd)
{ {
radix_tagged_line("Authenticate with password."); radix_tagged_line("Authenticate with password.");
SessionAuthState state = p->session->authenticateWithPassword(pswd); 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(); QString message = p->session->getError();
emit authenticationError(message); 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