Commit 72c724a8 authored by Huff, Israel's avatar Huff, Israel
Browse files

Merge branch 'rsmpbs' of code.ornl.gov:jap/rsm into rsmpbs

parents 35972ea6 5e268181
Pipeline #100473 failed with stages
in 4 minutes and 26 seconds
...@@ -22,7 +22,10 @@ mac_llvm_testing: ...@@ -22,7 +22,10 @@ mac_llvm_testing:
-Drsm_ENABLE_TESTS=ON -Drsm_ENABLE_TESTS=ON
-Drsm_ENABLE_rsmcore=ON -Drsm_ENABLE_rsmcore=ON
-Drsm_ENABLE_rsmwidgets=OFF .. -Drsm_ENABLE_rsmwidgets=OFF ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit - ctest --verbose --output-on-failure
-D ExperimentalStart
-D ExperimentalBuild
-D ExperimentalTest
linux_gcc_testing: linux_gcc_testing:
tags: tags:
...@@ -42,7 +45,10 @@ linux_gcc_testing: ...@@ -42,7 +45,10 @@ linux_gcc_testing:
-Drsm_ENABLE_TESTS=ON -Drsm_ENABLE_TESTS=ON
-Drsm_ENABLE_rsmcore=ON -Drsm_ENABLE_rsmcore=ON
-Drsm_ENABLE_rsmwidgets=OFF .. -Drsm_ENABLE_rsmwidgets=OFF ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit - ctest --verbose --output-on-failure
-D ExperimentalStart
-D ExperimentalBuild
-D ExperimentalTest
linux_analysis: linux_analysis:
stage: analysis stage: analysis
...@@ -66,7 +72,12 @@ linux_analysis: ...@@ -66,7 +72,12 @@ linux_analysis:
-Drsm_ENABLE_TESTS=ON -Drsm_ENABLE_TESTS=ON
-Drsm_ENABLE_rsmcore=ON -Drsm_ENABLE_rsmcore=ON
-Drsm_ENABLE_rsmwidgets=OFF .. -Drsm_ENABLE_rsmwidgets=OFF ..
- ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalMemCheck -D ExperimentalCoverage -D ExperimentalSubmit - ctest --verbose --output-on-failure
-D ExperimentalStart
-D ExperimentalBuild
-D ExperimentalTest
-D ExperimentalMemCheck
-D ExperimentalCoverage
allow_failure: true allow_failure: true
windows_msvc_testing: windows_msvc_testing:
......
...@@ -15,4 +15,7 @@ cmake -DBUILD_SHARED_LIBS=OFF ^ ...@@ -15,4 +15,7 @@ cmake -DBUILD_SHARED_LIBS=OFF ^
-Drsm_ENABLE_rsmcore=ON ^ -Drsm_ENABLE_rsmcore=ON ^
-Drsm_ENABLE_rsmwidgets=OFF ^ -Drsm_ENABLE_rsmwidgets=OFF ^
-G "NMake Makefiles" .. -G "NMake Makefiles" ..
ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit ctest --verbose --output-on-failure ^
-D ExperimentalStart ^
-D ExperimentalBuild ^
-D ExperimentalTest
...@@ -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>
...@@ -247,7 +247,10 @@ ssize_t SFTPFile::write(QString str) ...@@ -247,7 +247,10 @@ ssize_t SFTPFile::write(QString str)
// success // success
QString SFTPFile::read(size_t nBytes) QString SFTPFile::read(size_t nBytes)
{ {
char* buf = new char[nBytes + 1]; if (nBytes == 0) return QString();
char* buf = new char[nBytes + 1];
// initialize buff
memset(&buf[0], 0, nBytes);
buf[nBytes] = '\0'; buf[nBytes] = '\0';
ssize_t nBytesRead = sftp_read(p->file, buf, nBytes); ssize_t nBytesRead = sftp_read(p->file, buf, nBytes);
if (nBytesRead < 0) if (nBytesRead < 0)
...@@ -278,10 +281,9 @@ bool SFTPFile::seek(size_t offset) ...@@ -278,10 +281,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;
} }
...@@ -353,6 +355,9 @@ SFTPAttributes* SFTPDir::next() ...@@ -353,6 +355,9 @@ SFTPAttributes* SFTPDir::next()
retVal->extended_data = retVal->extended_data =
QString(ssh_string_get_char(sftpResult->extended_data)); QString(ssh_string_get_char(sftpResult->extended_data));
// release memory
sftp_attributes_free(sftpResult);
return retVal; return retVal;
} }
...@@ -383,7 +388,6 @@ class SessionImpl ...@@ -383,7 +388,6 @@ class SessionImpl
if (session != nullptr) if (session != nullptr)
{ {
ssh_free(session); ssh_free(session);
ssh_finalize();
} }
} }
}; // class SessionImpl }; // class SessionImpl
...@@ -411,18 +415,16 @@ QString Session::host() const ...@@ -411,18 +415,16 @@ QString Session::host() const
{ {
// This may not be necessary // This may not be necessary
assert_ssh_session(p->session, "host() -- Session is not allocated."); assert_ssh_session(p->session, "host() -- Session is not allocated.");
char* host_name; char* host_name = nullptr;
QString host;
int rv = ssh_options_get(p->session, SSH_OPTIONS_HOST, &host_name); int rv = ssh_options_get(p->session, SSH_OPTIONS_HOST, &host_name);
if (rv == SSH_OK) if (rv == SSH_OK)
{ {
QString host = host_name; host = host_name;
delete host_name;
return host;
}
else
{
return QString("");
} }
if (host_name != nullptr) ssh_string_free_char(host_name);
return host;
} }
void Session::setLogVerbosity(SessionVerbosity level) void Session::setLogVerbosity(SessionVerbosity level)
{ {
...@@ -446,18 +448,15 @@ QString Session::user() const ...@@ -446,18 +448,15 @@ QString Session::user() const
{ {
// This may not be necessary // This may not be necessary
assert_ssh_session(p->session, "user() -- Session is not allocated."); assert_ssh_session(p->session, "user() -- Session is not allocated.");
char* user_name; char* user_name = nullptr;
QString user;
int rv = ssh_options_get(p->session, SSH_OPTIONS_USER, &user_name); int rv = ssh_options_get(p->session, SSH_OPTIONS_USER, &user_name);
if (rv == SSH_OK) if (rv == SSH_OK)
{ {
QString user = user_name; user = user_name;
delete user_name;
return user;
}
else
{
return QString("");
} }
if (user_name != nullptr) ssh_string_free_char(user_name);
return user;
} }
void Session::setProxyCommand(QString command) void Session::setProxyCommand(QString command)
...@@ -480,6 +479,7 @@ bool Session::connect() ...@@ -480,6 +479,7 @@ bool Session::connect()
radix_tagged_line("Attempting connection."); radix_tagged_line("Attempting connection.");
// attempt a connection // attempt a connection
int rc = ssh_connect(p->session); int rc = ssh_connect(p->session);
radix_tagged_line("\tConnect return: " << rc);
return (rc == SSH_OK); return (rc == SSH_OK);
} }
} }
...@@ -499,7 +499,7 @@ bool Session::disconnect() ...@@ -499,7 +499,7 @@ bool Session::disconnect()
{ {
assert_ssh_session(p->session, "disconnect() -- Session is not allocated."); assert_ssh_session(p->session, "disconnect() -- Session is not allocated.");
radix_tagged_line("disconnect()"); radix_tagged_line("disconnect()");
if (ssh_is_connected(p->session) != 0) if (isConnected())
{ {
radix_tagged_line("Disconnecting session."); radix_tagged_line("Disconnecting session.");
ssh_disconnect(p->session); ssh_disconnect(p->session);
...@@ -556,7 +556,7 @@ SessionHostState Session::verifyKnownHost() const ...@@ -556,7 +556,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 +565,7 @@ SessionHostState Session::verifyKnownHost() const ...@@ -565,7 +565,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 +682,7 @@ SessionAuthState Session::authenticatePrompts(QStringList responses) ...@@ -682,7 +682,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
...@@ -354,7 +354,7 @@ class RSM_PUBLIC SFTPFile ...@@ -354,7 +354,7 @@ class RSM_PUBLIC SFTPFile
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) 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