forked from qt-creator/qt-creator
SSH: Use categorized logging.
Change-Id: I9890c7d4a86320c835e70e66c523c5a2f7b41421 Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include "sshexception_p.h"
|
#include "sshexception_p.h"
|
||||||
#include "sshincomingpacket_p.h"
|
#include "sshincomingpacket_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshsendfacility_p.h"
|
#include "sshsendfacility_p.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -256,9 +257,7 @@ void SftpChannelPrivate::handleChannelSuccess()
|
|||||||
{
|
{
|
||||||
if (channelState() == CloseRequested)
|
if (channelState() == CloseRequested)
|
||||||
return;
|
return;
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "sftp subsystem initialized");
|
||||||
qDebug("sftp subsystem initialized");
|
|
||||||
#endif
|
|
||||||
sendData(m_outgoingPacket.generateInit(ProtocolVersion).rawData());
|
sendData(m_outgoingPacket.generateInit(ProtocolVersion).rawData());
|
||||||
m_sftpState = InitSent;
|
m_sftpState = InitSent;
|
||||||
}
|
}
|
||||||
@@ -293,15 +292,13 @@ void SftpChannelPrivate::handleChannelDataInternal(const QByteArray &data)
|
|||||||
void SftpChannelPrivate::handleChannelExtendedDataInternal(quint32 type,
|
void SftpChannelPrivate::handleChannelExtendedDataInternal(quint32 type,
|
||||||
const QByteArray &data)
|
const QByteArray &data)
|
||||||
{
|
{
|
||||||
qWarning("Unexpected extended data '%s' of type %d on SFTP channel.",
|
qCWarning(sshLog, "Unexpected extended data '%s' of type %d on SFTP channel.",
|
||||||
data.data(), type);
|
data.data(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SftpChannelPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
|
void SftpChannelPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Remote SFTP service exited with exit code %d", exitStatus.exitStatus);
|
||||||
qDebug("Remote SFTP service exited with exit code %d", exitStatus.exitStatus);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (channelState() == CloseRequested || channelState() == Closed)
|
if (channelState() == CloseRequested || channelState() == Closed)
|
||||||
return;
|
return;
|
||||||
@@ -322,9 +319,7 @@ void SftpChannelPrivate::handleExitSignal(const SshChannelExitSignal &signal)
|
|||||||
|
|
||||||
void SftpChannelPrivate::handleCurrentPacket()
|
void SftpChannelPrivate::handleCurrentPacket()
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Handling SFTP packet of type %d", m_incomingPacket.type());
|
||||||
qDebug("Handling SFTP packet of type %d", m_incomingPacket.type());
|
|
||||||
#endif
|
|
||||||
switch (m_incomingPacket.type()) {
|
switch (m_incomingPacket.type()) {
|
||||||
case SSH_FXP_VERSION:
|
case SSH_FXP_VERSION:
|
||||||
handleServerVersion();
|
handleServerVersion();
|
||||||
@@ -359,9 +354,7 @@ void SftpChannelPrivate::handleServerVersion()
|
|||||||
"Unexpected SSH_FXP_VERSION packet.");
|
"Unexpected SSH_FXP_VERSION packet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "sftp init received");
|
||||||
qDebug("sftp init received");
|
|
||||||
#endif
|
|
||||||
const quint32 serverVersion = m_incomingPacket.extractServerVersion();
|
const quint32 serverVersion = m_incomingPacket.extractServerVersion();
|
||||||
if (serverVersion != ProtocolVersion) {
|
if (serverVersion != ProtocolVersion) {
|
||||||
emit channelError(tr("Protocol version mismatch: Expected %1, got %2")
|
emit channelError(tr("Protocol version mismatch: Expected %1, got %2")
|
||||||
@@ -450,9 +443,7 @@ void SftpChannelPrivate::handlePutHandle(const JobMap::Iterator &it)
|
|||||||
void SftpChannelPrivate::handleStatus()
|
void SftpChannelPrivate::handleStatus()
|
||||||
{
|
{
|
||||||
const SftpStatusResponse &response = m_incomingPacket.asStatusResponse();
|
const SftpStatusResponse &response = m_incomingPacket.asStatusResponse();
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "%s: status = %d", Q_FUNC_INFO, response.status);
|
||||||
qDebug("%s: status = %d", Q_FUNC_INFO, response.status);
|
|
||||||
#endif
|
|
||||||
JobMap::Iterator it = lookupJob(response.requestId);
|
JobMap::Iterator it = lookupJob(response.requestId);
|
||||||
switch (it.value()->type()) {
|
switch (it.value()->type()) {
|
||||||
case AbstractSftpOperation::ListDir:
|
case AbstractSftpOperation::ListDir:
|
||||||
@@ -850,9 +841,7 @@ void SftpChannelPrivate::closeHook()
|
|||||||
|
|
||||||
void SftpChannelPrivate::handleOpenSuccessInternal()
|
void SftpChannelPrivate::handleOpenSuccessInternal()
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "SFTP session started");
|
||||||
qDebug("SFTP session started");
|
|
||||||
#endif
|
|
||||||
m_sendFacility.sendSftpPacket(remoteChannel());
|
m_sendFacility.sendSftpPacket(remoteChannel());
|
||||||
m_sftpState = SubsystemRequested;
|
m_sftpState = SubsystemRequested;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "sftpincomingpacket_p.h"
|
#include "sftpincomingpacket_p.h"
|
||||||
|
|
||||||
#include "sshexception_p.h"
|
#include "sshexception_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshpacketparser_p.h"
|
#include "sshpacketparser_p.h"
|
||||||
|
|
||||||
namespace QSsh {
|
namespace QSsh {
|
||||||
@@ -42,10 +43,8 @@ SftpIncomingPacket::SftpIncomingPacket() : m_length(0)
|
|||||||
|
|
||||||
void SftpIncomingPacket::consumeData(QByteArray &newData)
|
void SftpIncomingPacket::consumeData(QByteArray &newData)
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "%s: current data size = %d, new data size = %d", Q_FUNC_INFO,
|
||||||
qDebug("%s: current data size = %d, new data size = %d", Q_FUNC_INFO,
|
|
||||||
m_data.size(), newData.size());
|
m_data.size(), newData.size());
|
||||||
#endif
|
|
||||||
|
|
||||||
if (isComplete() || dataSize() + newData.size() < sizeof m_length)
|
if (isComplete() || dataSize() + newData.size() < sizeof m_length)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "sftpoutgoingpacket_p.h"
|
#include "sftpoutgoingpacket_p.h"
|
||||||
|
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshpacket_p.h"
|
#include "sshpacket_p.h"
|
||||||
|
|
||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
@@ -183,10 +184,7 @@ SftpOutgoingPacket &SftpOutgoingPacket::init(SftpPacketType type,
|
|||||||
m_data[TypeOffset] = type;
|
m_data[TypeOffset] = type;
|
||||||
if (type != SSH_FXP_INIT) {
|
if (type != SSH_FXP_INIT) {
|
||||||
appendInt(requestId);
|
appendInt(requestId);
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Generating SFTP packet of type %d with request id %u", type, requestId);
|
||||||
qDebug("Generating SFTP packet of type %d with request id %u", type,
|
|
||||||
requestId);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ SOURCES = $$PWD/sshsendfacility.cpp \
|
|||||||
$$PWD/sshkeycreationdialog.cpp \
|
$$PWD/sshkeycreationdialog.cpp \
|
||||||
$$PWD/sshinit.cpp \
|
$$PWD/sshinit.cpp \
|
||||||
$$PWD/sshdirecttcpiptunnel.cpp \
|
$$PWD/sshdirecttcpiptunnel.cpp \
|
||||||
|
$$PWD/sshlogging.cpp \
|
||||||
$$PWD/sshhostkeydatabase.cpp
|
$$PWD/sshhostkeydatabase.cpp
|
||||||
|
|
||||||
HEADERS = $$PWD/sshsendfacility_p.h \
|
HEADERS = $$PWD/sshsendfacility_p.h \
|
||||||
@@ -66,6 +67,7 @@ HEADERS = $$PWD/sshsendfacility_p.h \
|
|||||||
$$PWD/sshdirecttcpiptunnel_p.h \
|
$$PWD/sshdirecttcpiptunnel_p.h \
|
||||||
$$PWD/sshinit_p.h \
|
$$PWD/sshinit_p.h \
|
||||||
$$PWD/sshdirecttcpiptunnel.h \
|
$$PWD/sshdirecttcpiptunnel.h \
|
||||||
|
$$PWD/sshlogging_p.h \
|
||||||
$$PWD/sshhostkeydatabase.h
|
$$PWD/sshhostkeydatabase.h
|
||||||
|
|
||||||
FORMS = $$PWD/sshkeycreationdialog.ui
|
FORMS = $$PWD/sshkeycreationdialog.ui
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ QtcLibrary {
|
|||||||
"sshkeygenerator.cpp", "sshkeygenerator.h",
|
"sshkeygenerator.cpp", "sshkeygenerator.h",
|
||||||
"sshkeypasswordretriever.cpp",
|
"sshkeypasswordretriever.cpp",
|
||||||
"sshkeypasswordretriever_p.h",
|
"sshkeypasswordretriever_p.h",
|
||||||
|
"sshlogging.cpp", "sshlogging_p.h",
|
||||||
"sshoutgoingpacket.cpp", "sshoutgoingpacket_p.h",
|
"sshoutgoingpacket.cpp", "sshoutgoingpacket_p.h",
|
||||||
"sshpacket.cpp", "sshpacket_p.h",
|
"sshpacket.cpp", "sshpacket_p.h",
|
||||||
"sshpacketparser.cpp", "sshpacketparser_p.h",
|
"sshpacketparser.cpp", "sshpacketparser_p.h",
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "sshchannel_p.h"
|
#include "sshchannel_p.h"
|
||||||
|
|
||||||
#include "sshincomingpacket_p.h"
|
#include "sshincomingpacket_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshsendfacility_p.h"
|
#include "sshsendfacility_p.h"
|
||||||
|
|
||||||
#include <botan/botan.h>
|
#include <botan/botan.h>
|
||||||
@@ -80,7 +81,7 @@ void AbstractSshChannel::requestSessionStart()
|
|||||||
setChannelState(SessionRequested);
|
setChannelState(SessionRequested);
|
||||||
m_timeoutTimer.start(ReplyTimeout);
|
m_timeoutTimer.start(ReplyTimeout);
|
||||||
} catch (const Botan::Exception &e) {
|
} catch (const Botan::Exception &e) {
|
||||||
qDebug("Botan error: %s", e.what());
|
qCWarning(sshLog, "Botan error: %s", e.what());
|
||||||
closeChannel();
|
closeChannel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,7 @@ void AbstractSshChannel::sendData(const QByteArray &data)
|
|||||||
m_sendBuffer += data;
|
m_sendBuffer += data;
|
||||||
flushSendBuffer();
|
flushSendBuffer();
|
||||||
} catch (const Botan::Exception &e) {
|
} catch (const Botan::Exception &e) {
|
||||||
qDebug("Botan error: %s", e.what());
|
qCWarning(sshLog, "Botan error: %s", e.what());
|
||||||
closeChannel();
|
closeChannel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,11 +155,9 @@ void AbstractSshChannel::handleOpenSuccess(quint32 remoteChannelId,
|
|||||||
"Maximum packet size too low.");
|
"Maximum packet size too low.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Channel opened. remote channel id: %u, remote window size: %u, "
|
||||||
qDebug("Channel opened. remote channel id: %u, remote window size: %u, "
|
|
||||||
"remote max packet size: %u",
|
"remote max packet size: %u",
|
||||||
remoteChannelId, remoteWindowSize, remoteMaxPacketSize);
|
remoteChannelId, remoteWindowSize, remoteMaxPacketSize);
|
||||||
#endif
|
|
||||||
m_remoteChannel = remoteChannelId;
|
m_remoteChannel = remoteChannelId;
|
||||||
m_remoteWindowSize = remoteWindowSize;
|
m_remoteWindowSize = remoteWindowSize;
|
||||||
m_remoteMaxPacketSize = remoteMaxPacketSize;
|
m_remoteMaxPacketSize = remoteMaxPacketSize;
|
||||||
@@ -183,9 +182,7 @@ void AbstractSshChannel::handleOpenFailure(const QString &reason)
|
|||||||
|
|
||||||
m_timeoutTimer.stop();
|
m_timeoutTimer.stop();
|
||||||
|
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Channel open request failed for channel %u", m_localChannel);
|
||||||
qDebug("Channel open request failed for channel %u", m_localChannel);
|
|
||||||
#endif
|
|
||||||
handleOpenFailureInternal(reason);
|
handleOpenFailureInternal(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,9 +198,7 @@ void AbstractSshChannel::handleChannelEof()
|
|||||||
|
|
||||||
void AbstractSshChannel::handleChannelClose()
|
void AbstractSshChannel::handleChannelClose()
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Receiving CLOSE for channel %u", m_localChannel);
|
||||||
qDebug("Receiving CLOSE for channel %u", m_localChannel);
|
|
||||||
#endif
|
|
||||||
if (channelState() == Inactive || channelState() == Closed) {
|
if (channelState() == Inactive || channelState() == Closed) {
|
||||||
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR,
|
||||||
"Unexpected SSH_MSG_CHANNEL_CLOSE message.");
|
"Unexpected SSH_MSG_CHANNEL_CLOSE message.");
|
||||||
@@ -235,7 +230,7 @@ void AbstractSshChannel::handleChannelRequest(const SshIncomingPacket &packet)
|
|||||||
else if (requestType == SshIncomingPacket::ExitSignalType)
|
else if (requestType == SshIncomingPacket::ExitSignalType)
|
||||||
handleExitSignal(packet.extractChannelExitSignal());
|
handleExitSignal(packet.extractChannelExitSignal());
|
||||||
else if (requestType != "eow@openssh.com") // Suppress warning for this one, as it's sent all the time.
|
else if (requestType != "eow@openssh.com") // Suppress warning for this one, as it's sent all the time.
|
||||||
qWarning("Ignoring unknown request type '%s'", requestType.data());
|
qCWarning(sshLog, "Ignoring unknown request type '%s'", requestType.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
int AbstractSshChannel::handleChannelOrExtendedChannelData(const QByteArray &data)
|
int AbstractSshChannel::handleChannelOrExtendedChannelData(const QByteArray &data)
|
||||||
@@ -244,7 +239,7 @@ int AbstractSshChannel::handleChannelOrExtendedChannelData(const QByteArray &dat
|
|||||||
|
|
||||||
const int bytesToDeliver = qMin<quint32>(data.size(), maxDataSize());
|
const int bytesToDeliver = qMin<quint32>(data.size(), maxDataSize());
|
||||||
if (bytesToDeliver != data.size())
|
if (bytesToDeliver != data.size())
|
||||||
qWarning("Misbehaving server does not respect local window, clipping.");
|
qCWarning(sshLog, "Misbehaving server does not respect local window, clipping.");
|
||||||
|
|
||||||
m_localWindowSize -= bytesToDeliver;
|
m_localWindowSize -= bytesToDeliver;
|
||||||
if (m_localWindowSize < maxPacketSize()) {
|
if (m_localWindowSize < maxPacketSize()) {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "sshexception_p.h"
|
#include "sshexception_p.h"
|
||||||
#include "sshinit_p.h"
|
#include "sshinit_p.h"
|
||||||
#include "sshkeyexchange_p.h"
|
#include "sshkeyexchange_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshremoteprocess.h"
|
#include "sshremoteprocess.h"
|
||||||
|
|
||||||
#include <botan/botan.h>
|
#include <botan/botan.h>
|
||||||
@@ -196,7 +197,7 @@ int SshConnection::closeAllChannels()
|
|||||||
try {
|
try {
|
||||||
return d->m_channelManager->closeAllChannels(Internal::SshChannelManager::CloseAllRegular);
|
return d->m_channelManager->closeAllChannels(Internal::SshChannelManager::CloseAllRegular);
|
||||||
} catch (const Botan::Exception &e) {
|
} catch (const Botan::Exception &e) {
|
||||||
qDebug("%s: %s", Q_FUNC_INFO, e.what());
|
qCWarning(Internal::sshLog, "%s: %s", Q_FUNC_INFO, e.what());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,10 +325,7 @@ void SshConnectionPrivate::handleIncomingData()
|
|||||||
if (!canUseSocket())
|
if (!canUseSocket())
|
||||||
return;
|
return;
|
||||||
m_incomingData += m_socket->readAll();
|
m_incomingData += m_socket->readAll();
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "state = %d, remote data size = %d", m_state, m_incomingData.count());
|
||||||
qDebug("state = %d, remote data size = %d", m_state,
|
|
||||||
m_incomingData.count());
|
|
||||||
#endif
|
|
||||||
if (m_serverId.isEmpty())
|
if (m_serverId.isEmpty())
|
||||||
handleServerId();
|
handleServerId();
|
||||||
handlePackets();
|
handlePackets();
|
||||||
@@ -346,10 +344,8 @@ void SshConnectionPrivate::handleIncomingData()
|
|||||||
// RFC 4253, 4.2.
|
// RFC 4253, 4.2.
|
||||||
void SshConnectionPrivate::handleServerId()
|
void SshConnectionPrivate::handleServerId()
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "%s: incoming data size = %d, incoming data = '%s'",
|
||||||
qDebug("%s: incoming data size = %d, incoming data = '%s'",
|
|
||||||
Q_FUNC_INFO, m_incomingData.count(), m_incomingData.data());
|
Q_FUNC_INFO, m_incomingData.count(), m_incomingData.data());
|
||||||
#endif
|
|
||||||
const int newLinePos = m_incomingData.indexOf('\n');
|
const int newLinePos = m_incomingData.indexOf('\n');
|
||||||
if (newLinePos == -1)
|
if (newLinePos == -1)
|
||||||
return; // Not enough data yet.
|
return; // Not enough data yet.
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "sshexception_p.h"
|
#include "sshexception_p.h"
|
||||||
#include "sshkeyexchange_p.h"
|
#include "sshkeyexchange_p.h"
|
||||||
#include "sshkeypasswordretriever_p.h"
|
#include "sshkeypasswordretriever_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshpacket_p.h"
|
#include "sshpacket_p.h"
|
||||||
|
|
||||||
#include <botan/botan.h>
|
#include <botan/botan.h>
|
||||||
@@ -213,9 +214,7 @@ void SshEncryptionFacility::createAuthenticationKey(const QByteArray &privKeyFil
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_authKeyAlgoName.clear();
|
m_authKeyAlgoName.clear();
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "%s: Key not cached, reading", Q_FUNC_INFO);
|
||||||
qDebug("%s: Key not cached, reading", Q_FUNC_INFO);
|
|
||||||
#endif
|
|
||||||
QList<BigInt> pubKeyParams;
|
QList<BigInt> pubKeyParams;
|
||||||
QList<BigInt> allKeyParams;
|
QList<BigInt> allKeyParams;
|
||||||
QString error1;
|
QString error1;
|
||||||
@@ -223,9 +222,7 @@ void SshEncryptionFacility::createAuthenticationKey(const QByteArray &privKeyFil
|
|||||||
if (!createAuthenticationKeyFromPKCS8(privKeyFileContents, pubKeyParams, allKeyParams, error1)
|
if (!createAuthenticationKeyFromPKCS8(privKeyFileContents, pubKeyParams, allKeyParams, error1)
|
||||||
&& !createAuthenticationKeyFromOpenSSL(privKeyFileContents, pubKeyParams, allKeyParams,
|
&& !createAuthenticationKeyFromOpenSSL(privKeyFileContents, pubKeyParams, allKeyParams,
|
||||||
error2)) {
|
error2)) {
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "%s: %s\n\t%s\n", Q_FUNC_INFO, qPrintable(error1), qPrintable(error2));
|
||||||
qDebug("%s: %s\n\t%s\n", Q_FUNC_INFO, qPrintable(error1), qPrintable(error2));
|
|
||||||
#endif
|
|
||||||
throw SshClientException(SshKeyFileError, SSH_TR("Decoding of private key file failed: "
|
throw SshClientException(SshKeyFileError, SSH_TR("Decoding of private key file failed: "
|
||||||
"Format not understood."));
|
"Format not understood."));
|
||||||
}
|
}
|
||||||
@@ -274,7 +271,8 @@ bool SshEncryptionFacility::createAuthenticationKeyFromPKCS8(const QByteArray &p
|
|||||||
<< ecdsaKey->public_point().get_affine_y();
|
<< ecdsaKey->public_point().get_affine_y();
|
||||||
allKeyParams << pubKeyParams << value;
|
allKeyParams << pubKeyParams << value;
|
||||||
} else {
|
} else {
|
||||||
qWarning("%s: Unexpected code flow, expected success or exception.", Q_FUNC_INFO);
|
qCWarning(sshLog, "%s: Unexpected code flow, expected success or exception.",
|
||||||
|
Q_FUNC_INFO);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (const Exception &ex) {
|
} catch (const Exception &ex) {
|
||||||
@@ -438,13 +436,11 @@ void SshDecryptionFacility::decrypt(QByteArray &data, quint32 offset,
|
|||||||
quint32 dataSize) const
|
quint32 dataSize) const
|
||||||
{
|
{
|
||||||
convert(data, offset, dataSize);
|
convert(data, offset, dataSize);
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Decrypted data:");
|
||||||
qDebug("Decrypted data:");
|
|
||||||
const char * const start = data.constData() + offset;
|
const char * const start = data.constData() + offset;
|
||||||
const char * const end = start + dataSize;
|
const char * const end = start + dataSize;
|
||||||
for (const char *c = start; c < end; ++c)
|
for (const char *c = start; c < end; ++c)
|
||||||
qDebug() << "'" << *c << "' (0x" << (static_cast<int>(*c) & 0xff) << ")";
|
qCDebug(sshLog, ) << "'" << *c << "' (0x" << (static_cast<int>(*c) & 0xff) << ")";
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "sshdirecttcpiptunnel_p.h"
|
#include "sshdirecttcpiptunnel_p.h"
|
||||||
|
|
||||||
#include "sshincomingpacket_p.h"
|
#include "sshincomingpacket_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshsendfacility_p.h"
|
#include "sshsendfacility_p.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@@ -82,18 +83,18 @@ void SshDirectTcpIpTunnelPrivate::handleChannelDataInternal(const QByteArray &da
|
|||||||
void SshDirectTcpIpTunnelPrivate::handleChannelExtendedDataInternal(quint32 type,
|
void SshDirectTcpIpTunnelPrivate::handleChannelExtendedDataInternal(quint32 type,
|
||||||
const QByteArray &data)
|
const QByteArray &data)
|
||||||
{
|
{
|
||||||
qDebug("%s: Unexpected extended channel data. Type is %u, content is '%s'.", Q_FUNC_INFO, type,
|
qCWarning(sshLog, "%s: Unexpected extended channel data. Type is %u, content is '%s'.",
|
||||||
data.constData());
|
Q_FUNC_INFO, type, data.constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshDirectTcpIpTunnelPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
|
void SshDirectTcpIpTunnelPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
|
||||||
{
|
{
|
||||||
qDebug("%s: Unexpected exit status %d.", Q_FUNC_INFO, exitStatus.exitStatus);
|
qCWarning(sshLog, "%s: Unexpected exit status %d.", Q_FUNC_INFO, exitStatus.exitStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshDirectTcpIpTunnelPrivate::handleExitSignal(const SshChannelExitSignal &signal)
|
void SshDirectTcpIpTunnelPrivate::handleExitSignal(const SshChannelExitSignal &signal)
|
||||||
{
|
{
|
||||||
qDebug("%s: Unexpected exit signal %s.", Q_FUNC_INFO, signal.signal.constData());
|
qCWarning(sshLog, "%s: Unexpected exit signal %s.", Q_FUNC_INFO, signal.signal.constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshDirectTcpIpTunnelPrivate::closeHook()
|
void SshDirectTcpIpTunnelPrivate::closeHook()
|
||||||
@@ -166,7 +167,7 @@ void SshDirectTcpIpTunnel::initialize()
|
|||||||
d->setChannelState(AbstractSshChannel::SessionRequested);
|
d->setChannelState(AbstractSshChannel::SessionRequested);
|
||||||
d->m_timeoutTimer.start(d->ReplyTimeout);
|
d->m_timeoutTimer.start(d->ReplyTimeout);
|
||||||
} catch (const Botan::Exception &e) { // Won't happen, but let's play it safe.
|
} catch (const Botan::Exception &e) { // Won't happen, but let's play it safe.
|
||||||
qDebug("Botan error: %s", e.what());
|
qCWarning(sshLog, "Botan error: %s", e.what());
|
||||||
d->closeChannel();
|
d->closeChannel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "sshhostkeydatabase.h"
|
#include "sshhostkeydatabase.h"
|
||||||
|
|
||||||
|
#include "sshlogging_p.h"
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -72,7 +74,7 @@ bool SshHostKeyDatabase::load(const QString &filePath, QString *error)
|
|||||||
foreach (const QByteArray &line, content.split('\n')) {
|
foreach (const QByteArray &line, content.split('\n')) {
|
||||||
const QList<QByteArray> &lineData = line.trimmed().split(' ');
|
const QList<QByteArray> &lineData = line.trimmed().split(' ');
|
||||||
if (lineData.count() != 2) {
|
if (lineData.count() != 2) {
|
||||||
qDebug("Unexpected line \"%s\" in file \"%s\".", line.constData(),
|
qCDebug(Internal::sshLog, "Unexpected line \"%s\" in file \"%s\".", line.constData(),
|
||||||
qPrintable(filePath));
|
qPrintable(filePath));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "ssh_global.h"
|
#include "ssh_global.h"
|
||||||
#include "sshbotanconversions_p.h"
|
#include "sshbotanconversions_p.h"
|
||||||
#include "sshcapabilities_p.h"
|
#include "sshcapabilities_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
|
|
||||||
namespace QSsh {
|
namespace QSsh {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -66,10 +67,8 @@ void SshIncomingPacket::reset()
|
|||||||
|
|
||||||
void SshIncomingPacket::consumeData(QByteArray &newData)
|
void SshIncomingPacket::consumeData(QByteArray &newData)
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "%s: current data size = %d, new data size = %d",
|
||||||
qDebug("%s: current data size = %d, new data size = %d",
|
|
||||||
Q_FUNC_INFO, m_data.size(), newData.size());
|
Q_FUNC_INFO, m_data.size(), newData.size());
|
||||||
#endif
|
|
||||||
|
|
||||||
if (isComplete() || newData.isEmpty())
|
if (isComplete() || newData.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -83,9 +82,7 @@ void SshIncomingPacket::consumeData(QByteArray &newData)
|
|||||||
const int bytesToTake
|
const int bytesToTake
|
||||||
= qMin<quint32>(minSize - currentDataSize(), newData.size());
|
= qMin<quint32>(minSize - currentDataSize(), newData.size());
|
||||||
moveFirstBytes(m_data, newData, bytesToTake);
|
moveFirstBytes(m_data, newData, bytesToTake);
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Took %d bytes from new data", bytesToTake);
|
||||||
qDebug("Took %d bytes from new data", bytesToTake);
|
|
||||||
#endif
|
|
||||||
if (currentDataSize() < minSize)
|
if (currentDataSize() < minSize)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -97,14 +94,10 @@ void SshIncomingPacket::consumeData(QByteArray &newData)
|
|||||||
= qMin<quint32>(length() + 4 + macLength() - currentDataSize(),
|
= qMin<quint32>(length() + 4 + macLength() - currentDataSize(),
|
||||||
newData.size());
|
newData.size());
|
||||||
moveFirstBytes(m_data, newData, bytesToTake);
|
moveFirstBytes(m_data, newData, bytesToTake);
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Took %d bytes from new data", bytesToTake);
|
||||||
qDebug("Took %d bytes from new data", bytesToTake);
|
|
||||||
#endif
|
|
||||||
if (isComplete()) {
|
if (isComplete()) {
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Message complete. Overall size: %u, payload size: %u",
|
||||||
qDebug("Message complete. Overall size: %u, payload size: %u",
|
|
||||||
m_data.size(), m_length - paddingLength() - 1);
|
m_data.size(), m_length - paddingLength() - 1);
|
||||||
#endif
|
|
||||||
decrypt();
|
decrypt();
|
||||||
++m_serverSeqNr;
|
++m_serverSeqNr;
|
||||||
}
|
}
|
||||||
@@ -509,19 +502,13 @@ QByteArray SshIncomingPacket::extractChannelRequestType() const
|
|||||||
void SshIncomingPacket::calculateLength() const
|
void SshIncomingPacket::calculateLength() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(currentDataSize() >= minPacketSize());
|
Q_ASSERT(currentDataSize() >= minPacketSize());
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Length field before decryption: %d-%d-%d-%d", m_data.at(0) & 0xff,
|
||||||
qDebug("Length field before decryption: %d-%d-%d-%d", m_data.at(0) & 0xff,
|
|
||||||
m_data.at(1) & 0xff, m_data.at(2) & 0xff, m_data.at(3) & 0xff);
|
m_data.at(1) & 0xff, m_data.at(2) & 0xff, m_data.at(3) & 0xff);
|
||||||
#endif
|
|
||||||
m_decrypter.decrypt(m_data, 0, cipherBlockSize());
|
m_decrypter.decrypt(m_data, 0, cipherBlockSize());
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Length field after decryption: %d-%d-%d-%d", m_data.at(0) & 0xff, m_data.at(1) & 0xff, m_data.at(2) & 0xff, m_data.at(3) & 0xff);
|
||||||
qDebug("Length field after decryption: %d-%d-%d-%d", m_data.at(0) & 0xff, m_data.at(1) & 0xff, m_data.at(2) & 0xff, m_data.at(3) & 0xff);
|
qCDebug(sshLog, "message type = %d", m_data.at(TypeOffset));
|
||||||
qDebug("message type = %d", m_data.at(TypeOffset));
|
|
||||||
#endif
|
|
||||||
m_length = SshPacketParser::asUint32(m_data, static_cast<quint32>(0));
|
m_length = SshPacketParser::asUint32(m_data, static_cast<quint32>(0));
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "decrypted length is %u", m_length);
|
||||||
qDebug("decrypted length is %u", m_length);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -33,15 +33,13 @@
|
|||||||
#include "ssh_global.h"
|
#include "ssh_global.h"
|
||||||
#include "sshbotanconversions_p.h"
|
#include "sshbotanconversions_p.h"
|
||||||
#include "sshcapabilities_p.h"
|
#include "sshcapabilities_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshsendfacility_p.h"
|
#include "sshsendfacility_p.h"
|
||||||
#include "sshexception_p.h"
|
#include "sshexception_p.h"
|
||||||
#include "sshincomingpacket_p.h"
|
#include "sshincomingpacket_p.h"
|
||||||
|
|
||||||
#include <botan/botan.h>
|
#include <botan/botan.h>
|
||||||
|
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
|
||||||
#include <iostream>
|
|
||||||
#endif
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace Botan;
|
using namespace Botan;
|
||||||
@@ -54,26 +52,16 @@ namespace {
|
|||||||
// For debugging
|
// For debugging
|
||||||
void printNameList(const char *listName, const SshNameList &list)
|
void printNameList(const char *listName, const SshNameList &list)
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "%s:", listName);
|
||||||
qDebug("%s:", listName);
|
|
||||||
foreach (const QByteArray &name, list.names)
|
foreach (const QByteArray &name, list.names)
|
||||||
qDebug("%s", name.constData());
|
qCDebug(sshLog, "%s", name.constData());
|
||||||
#else
|
|
||||||
Q_UNUSED(listName);
|
|
||||||
Q_UNUSED(list);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
|
||||||
void printData(const char *name, const QByteArray &data)
|
void printData(const char *name, const QByteArray &data)
|
||||||
{
|
{
|
||||||
std::cerr << std::hex;
|
qCDebug(sshLog, "The client thinks the %s has length %d and is: %s", name, data.count(),
|
||||||
qDebug("The client thinks the %s has length %d and is:", name, data.count());
|
data.toHex().constData());
|
||||||
for (int i = 0; i < data.count(); ++i)
|
|
||||||
std::cerr << (static_cast<unsigned int>(data.at(i)) & 0xff) << ' ';
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
@@ -93,9 +81,7 @@ void SshKeyExchange::sendKexInitPacket(const QByteArray &serverId)
|
|||||||
|
|
||||||
bool SshKeyExchange::sendDhInitPacket(const SshIncomingPacket &serverKexInit)
|
bool SshKeyExchange::sendDhInitPacket(const SshIncomingPacket &serverKexInit)
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "server requests key exchange");
|
||||||
qDebug("server requests key exchange");
|
|
||||||
#endif
|
|
||||||
serverKexInit.printRawBytes();
|
serverKexInit.printRawBytes();
|
||||||
SshKeyExchangeInit kexInitParams
|
SshKeyExchangeInit kexInitParams
|
||||||
= serverKexInit.extractKeyExchangeInitData();
|
= serverKexInit.extractKeyExchangeInitData();
|
||||||
@@ -110,9 +96,7 @@ bool SshKeyExchange::sendDhInitPacket(const SshIncomingPacket &serverKexInit)
|
|||||||
printNameList("Compression algorithms client to server", kexInitParams.compressionAlgorithmsClientToServer);
|
printNameList("Compression algorithms client to server", kexInitParams.compressionAlgorithmsClientToServer);
|
||||||
printNameList("Languages client to server", kexInitParams.languagesClientToServer);
|
printNameList("Languages client to server", kexInitParams.languagesClientToServer);
|
||||||
printNameList("Languages server to client", kexInitParams.languagesServerToClient);
|
printNameList("Languages server to client", kexInitParams.languagesServerToClient);
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "First packet follows: %d", kexInitParams.firstKexPacketFollows);
|
||||||
qDebug("First packet follows: %d", kexInitParams.firstKexPacketFollows);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_kexAlgoName = SshCapabilities::findBestMatch(SshCapabilities::KeyExchangeMethods,
|
m_kexAlgoName = SshCapabilities::findBestMatch(SshCapabilities::KeyExchangeMethods,
|
||||||
kexInitParams.keyAlgorithms.names);
|
kexInitParams.keyAlgorithms.names);
|
||||||
@@ -161,6 +145,13 @@ void SshKeyExchange::sendNewKeysPacket(const SshIncomingPacket &dhReply,
|
|||||||
concatenatedData += AbstractSshPacket::encodeString(m_clientKexInitPayload);
|
concatenatedData += AbstractSshPacket::encodeString(m_clientKexInitPayload);
|
||||||
concatenatedData += AbstractSshPacket::encodeString(m_serverKexInitPayload);
|
concatenatedData += AbstractSshPacket::encodeString(m_serverKexInitPayload);
|
||||||
concatenatedData += reply.k_s;
|
concatenatedData += reply.k_s;
|
||||||
|
|
||||||
|
printData("Client Id", AbstractSshPacket::encodeString(clientId));
|
||||||
|
printData("Server Id", AbstractSshPacket::encodeString(m_serverId));
|
||||||
|
printData("Client Payload", AbstractSshPacket::encodeString(m_clientKexInitPayload));
|
||||||
|
printData("Server payload", AbstractSshPacket::encodeString(m_serverKexInitPayload));
|
||||||
|
printData("K_S", reply.k_s);
|
||||||
|
|
||||||
SecureVector<byte> encodedK;
|
SecureVector<byte> encodedK;
|
||||||
if (m_dhKey) {
|
if (m_dhKey) {
|
||||||
concatenatedData += AbstractSshPacket::encodeMpInt(m_dhKey->get_y());
|
concatenatedData += AbstractSshPacket::encodeMpInt(m_dhKey->get_y());
|
||||||
@@ -169,6 +160,8 @@ void SshKeyExchange::sendNewKeysPacket(const SshIncomingPacket &dhReply,
|
|||||||
SecureVector<byte> encodedF = BigInt::encode(reply.f);
|
SecureVector<byte> encodedF = BigInt::encode(reply.f);
|
||||||
encodedK = dhOp.agree(encodedF, encodedF.size());
|
encodedK = dhOp.agree(encodedF, encodedF.size());
|
||||||
m_dhKey.reset(nullptr);
|
m_dhKey.reset(nullptr);
|
||||||
|
printData("y", AbstractSshPacket::encodeMpInt(m_dhKey->get_y()));
|
||||||
|
printData("f", AbstractSshPacket::encodeMpInt(reply.f));
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT(m_ecdhKey);
|
Q_ASSERT(m_ecdhKey);
|
||||||
concatenatedData // Q_C.
|
concatenatedData // Q_C.
|
||||||
@@ -181,25 +174,15 @@ void SshKeyExchange::sendNewKeysPacket(const SshIncomingPacket &dhReply,
|
|||||||
|
|
||||||
const BigInt k = BigInt::decode(encodedK);
|
const BigInt k = BigInt::decode(encodedK);
|
||||||
m_k = AbstractSshPacket::encodeMpInt(k); // Roundtrip, as Botan encodes BigInts somewhat differently.
|
m_k = AbstractSshPacket::encodeMpInt(k); // Roundtrip, as Botan encodes BigInts somewhat differently.
|
||||||
|
printData("K", m_k);
|
||||||
concatenatedData += m_k;
|
concatenatedData += m_k;
|
||||||
|
printData("Concatenated data", concatenatedData);
|
||||||
|
|
||||||
m_hash.reset(get_hash(botanHMacAlgoName(hashAlgoForKexAlgo())));
|
m_hash.reset(get_hash(botanHMacAlgoName(hashAlgoForKexAlgo())));
|
||||||
const SecureVector<byte> &hashResult = m_hash->process(convertByteArray(concatenatedData),
|
const SecureVector<byte> &hashResult = m_hash->process(convertByteArray(concatenatedData),
|
||||||
concatenatedData.size());
|
concatenatedData.size());
|
||||||
m_h = convertByteArray(hashResult);
|
m_h = convertByteArray(hashResult);
|
||||||
|
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
|
||||||
printData("Client Id", AbstractSshPacket::encodeString(clientId));
|
|
||||||
printData("Server Id", AbstractSshPacket::encodeString(m_serverId));
|
|
||||||
printData("Client Payload", AbstractSshPacket::encodeString(m_clientKexInitPayload));
|
|
||||||
printData("Server payload", AbstractSshPacket::encodeString(m_serverKexInitPayload));
|
|
||||||
printData("K_S", reply.k_s);
|
|
||||||
printData("y", AbstractSshPacket::encodeMpInt(m_dhKey->get_y()));
|
|
||||||
printData("f", AbstractSshPacket::encodeMpInt(reply.f));
|
|
||||||
printData("K", m_k);
|
|
||||||
printData("Concatenated data", concatenatedData);
|
|
||||||
printData("H", m_h);
|
printData("H", m_h);
|
||||||
#endif // CREATOR_SSH_DEBUG
|
|
||||||
|
|
||||||
QScopedPointer<Public_Key> sigKey;
|
QScopedPointer<Public_Key> sigKey;
|
||||||
if (m_serverHostKeyAlgo == SshCapabilities::PubKeyDss) {
|
if (m_serverHostKeyAlgo == SshCapabilities::PubKeyDss) {
|
||||||
|
|||||||
37
src/libs/ssh/sshlogging.cpp
Normal file
37
src/libs/ssh/sshlogging.cpp
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sshlogging_p.h"
|
||||||
|
|
||||||
|
namespace QSsh {
|
||||||
|
namespace Internal {
|
||||||
|
Q_LOGGING_CATEGORY(sshLog, "qtc.ssh")
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace QSsh
|
||||||
42
src/libs/ssh/sshlogging_p.h
Normal file
42
src/libs/ssh/sshlogging_p.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SSHLOGGING_P_H
|
||||||
|
#define SSHLOGGING_P_H
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
namespace QSsh {
|
||||||
|
namespace Internal {
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(sshLog)
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace QSsh
|
||||||
|
|
||||||
|
#endif // Include guard
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "sshcapabilities_p.h"
|
#include "sshcapabilities_p.h"
|
||||||
#include "sshcryptofacility_p.h"
|
#include "sshcryptofacility_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
|
|
||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
|
|
||||||
@@ -328,13 +329,9 @@ void SshOutgoingPacket::finalize()
|
|||||||
setPadding();
|
setPadding();
|
||||||
setLengthField(m_data);
|
setLengthField(m_data);
|
||||||
m_length = m_data.size() - 4;
|
m_length = m_data.size() - 4;
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Encrypting packet of type %u", m_data.at(TypeOffset));
|
||||||
qDebug("Encrypting packet of type %u", m_data.at(TypeOffset));
|
|
||||||
#endif
|
|
||||||
encrypt();
|
encrypt();
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Sending packet of size %d", rawData().count());
|
||||||
qDebug("Sending packet of size %d", rawData().count());
|
|
||||||
#endif
|
|
||||||
Q_ASSERT(isComplete());
|
Q_ASSERT(isComplete());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "sshcapabilities_p.h"
|
#include "sshcapabilities_p.h"
|
||||||
#include "sshcryptofacility_p.h"
|
#include "sshcryptofacility_p.h"
|
||||||
#include "sshexception_p.h"
|
#include "sshexception_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshpacketparser_p.h"
|
#include "sshpacketparser_p.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -47,18 +48,10 @@ const quint32 AbstractSshPacket::PayloadOffset = PaddingLengthOffset + 1;
|
|||||||
const quint32 AbstractSshPacket::TypeOffset = PayloadOffset;
|
const quint32 AbstractSshPacket::TypeOffset = PayloadOffset;
|
||||||
const quint32 AbstractSshPacket::MinPaddingLength = 4;
|
const quint32 AbstractSshPacket::MinPaddingLength = 4;
|
||||||
|
|
||||||
namespace {
|
static void printByteArray(const QByteArray &data)
|
||||||
|
{
|
||||||
void printByteArray(const QByteArray &data)
|
qCDebug(sshLog, "%s", data.toHex().constData());
|
||||||
{
|
}
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
|
||||||
for (int i = 0; i < data.count(); ++i)
|
|
||||||
qDebug() << std::hex << (static_cast<unsigned int>(data[i]) & 0xff) << " ";
|
|
||||||
#else
|
|
||||||
Q_UNUSED(data);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
|
|
||||||
AbstractSshPacket::AbstractSshPacket() : m_length(0) { }
|
AbstractSshPacket::AbstractSshPacket() : m_length(0) { }
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include "ssh_global.h"
|
#include "ssh_global.h"
|
||||||
#include "sshincomingpacket_p.h"
|
#include "sshincomingpacket_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshsendfacility_p.h"
|
#include "sshsendfacility_p.h"
|
||||||
|
|
||||||
#include <botan/botan.h>
|
#include <botan/botan.h>
|
||||||
@@ -195,9 +196,7 @@ void SshRemoteProcess::requestTerminal(const SshPseudoTerminal &terminal)
|
|||||||
void SshRemoteProcess::start()
|
void SshRemoteProcess::start()
|
||||||
{
|
{
|
||||||
if (d->channelState() == Internal::SshRemoteProcessPrivate::Inactive) {
|
if (d->channelState() == Internal::SshRemoteProcessPrivate::Inactive) {
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(Internal::sshLog, "process start requested, channel id = %u", d->localChannelId());
|
||||||
qDebug("process start requested, channel id = %u", d->localChannelId());
|
|
||||||
#endif
|
|
||||||
QIODevice::open(QIODevice::ReadWrite);
|
QIODevice::open(QIODevice::ReadWrite);
|
||||||
d->requestSessionStart();
|
d->requestSessionStart();
|
||||||
}
|
}
|
||||||
@@ -267,9 +266,7 @@ void SshRemoteProcessPrivate::init()
|
|||||||
|
|
||||||
void SshRemoteProcessPrivate::setProcState(ProcessState newState)
|
void SshRemoteProcessPrivate::setProcState(ProcessState newState)
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "channel: old state = %d,new state = %d", m_procState, newState);
|
||||||
qDebug("channel: old state = %d,new state = %d", m_procState, newState);
|
|
||||||
#endif
|
|
||||||
m_procState = newState;
|
m_procState = newState;
|
||||||
if (newState == StartFailed) {
|
if (newState == StartFailed) {
|
||||||
emit closed(SshRemoteProcess::FailedToStart);
|
emit closed(SshRemoteProcess::FailedToStart);
|
||||||
@@ -351,7 +348,7 @@ void SshRemoteProcessPrivate::handleChannelExtendedDataInternal(quint32 type,
|
|||||||
const QByteArray &data)
|
const QByteArray &data)
|
||||||
{
|
{
|
||||||
if (type != SSH_EXTENDED_DATA_STDERR) {
|
if (type != SSH_EXTENDED_DATA_STDERR) {
|
||||||
qWarning("Unknown extended data type %u", type);
|
qCWarning(sshLog, "Unknown extended data type %u", type);
|
||||||
} else {
|
} else {
|
||||||
m_stderr += data;
|
m_stderr += data;
|
||||||
emit readyReadStandardError();
|
emit readyReadStandardError();
|
||||||
@@ -362,18 +359,14 @@ void SshRemoteProcessPrivate::handleChannelExtendedDataInternal(quint32 type,
|
|||||||
|
|
||||||
void SshRemoteProcessPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
|
void SshRemoteProcessPrivate::handleExitStatus(const SshChannelExitStatus &exitStatus)
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Process exiting with exit code %d", exitStatus.exitStatus);
|
||||||
qDebug("Process exiting with exit code %d", exitStatus.exitStatus);
|
|
||||||
#endif
|
|
||||||
m_exitCode = exitStatus.exitStatus;
|
m_exitCode = exitStatus.exitStatus;
|
||||||
m_procState = Exited;
|
m_procState = Exited;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SshRemoteProcessPrivate::handleExitSignal(const SshChannelExitSignal &signal)
|
void SshRemoteProcessPrivate::handleExitSignal(const SshChannelExitSignal &signal)
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Exit due to signal %s", signal.signal.data());
|
||||||
qDebug("Exit due to signal %s", signal.signal.data());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof signalMap/sizeof *signalMap; ++i) {
|
for (size_t i = 0; i < sizeof signalMap/sizeof *signalMap; ++i) {
|
||||||
if (signalMap[i].signalString == signal.signal) {
|
if (signalMap[i].signalString == signal.signal) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "sshsendfacility_p.h"
|
#include "sshsendfacility_p.h"
|
||||||
|
|
||||||
#include "sshkeyexchange_p.h"
|
#include "sshkeyexchange_p.h"
|
||||||
|
#include "sshlogging_p.h"
|
||||||
#include "sshoutgoingpacket_p.h"
|
#include "sshoutgoingpacket_p.h"
|
||||||
|
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
@@ -46,9 +47,7 @@ SshSendFacility::SshSendFacility(QTcpSocket *socket)
|
|||||||
|
|
||||||
void SshSendFacility::sendPacket()
|
void SshSendFacility::sendPacket()
|
||||||
{
|
{
|
||||||
#ifdef CREATOR_SSH_DEBUG
|
qCDebug(sshLog, "Sending packet, client seq nr is %u", m_clientSeqNr);
|
||||||
qDebug("Sending packet, client seq nr is %u", m_clientSeqNr);
|
|
||||||
#endif
|
|
||||||
if (m_socket->isValid()
|
if (m_socket->isValid()
|
||||||
&& m_socket->state() == QAbstractSocket::ConnectedState) {
|
&& m_socket->state() == QAbstractSocket::ConnectedState) {
|
||||||
m_socket->write(m_outgoingPacket.rawData());
|
m_socket->write(m_outgoingPacket.rawData());
|
||||||
|
|||||||
Reference in New Issue
Block a user