diff --git a/src/libs/3rdparty/3rdparty.pro b/src/libs/3rdparty/3rdparty.pro index 5c2dec27d03..c7babdde2c0 100644 --- a/src/libs/3rdparty/3rdparty.pro +++ b/src/libs/3rdparty/3rdparty.pro @@ -1,5 +1,4 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += botan \ - net7ssh +SUBDIRS += botan diff --git a/src/libs/3rdparty/net7ssh/AUTHORS b/src/libs/3rdparty/net7ssh/AUTHORS deleted file mode 100644 index 18d0a6839d5..00000000000 --- a/src/libs/3rdparty/net7ssh/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Andrew Useckas -Keef Aragon \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/CHANGELOG b/src/libs/3rdparty/net7ssh/CHANGELOG deleted file mode 100644 index 2ae5ca241a9..00000000000 --- a/src/libs/3rdparty/net7ssh/CHANGELOG +++ /dev/null @@ -1,126 +0,0 @@ -1.3.2 -Random Number Generator is now thread safe. Thanks to Jack Llloyd of Radnombit. -Timeouts in waitFor() and sendCmd() now work as they are supposed to. -Fixed include issues. -Fixed handling of NULL packet. - - -1.3.1 -Channel ID managment rewriten and ID clashes that caused multiple issues are now fixed. -Fixed cleanup procedures after timed out login. -Fixed cleanup procedures after remote end goes away. -Fixed variable types for MSVS compatbility. -Fixed thred sleep issues under Windows. -Fixed couple of small memory leaks. - - -1.3.0 -Changes made to support new stable Botan 1.8.x crypto library. -Added macros for backward compatibility with Botan 1.6.x. -All strings returned by read() method are now NULL terminated. -All error message strings are now NULL terminated. -Fixed multiple race conditions related to late mutex locking. -Fixed multiple race conditions related to premature mutex unlocking. -Fixed segfault when using cryptographic algorithms with block size > 64bit. -Added aes192-cbc algorithm support. -Fixed cleanup of connections after authentication failure. -Fixed SFTP crash after changing to non existent remote directory. -Updated examples. -Updated api docs. - - -1.2.7 -Converted to cmake from auto* tools. -Moved thread functions into macros to avoid conflicts when linking to POSIX libraries in Windows. -Fixed a race condition in ne7ssh.cpp. -Fixed multiple memory leaks. - - -1.2.6 -Fixed includes to compile with GCC 4.3.0. -Fixed the cleanup of timed out connections. -Fixed a race condition within ne7ssh.cpp. -Fixes for mingw32 compiler. - - -1.2.5 -Fixed a typo preventing use of 3des-cbc (thanks to Henry Fann for the patch). -Fixed includes preventing compile in older versions of Linux. -Fixed memory relocation issue in ne7ssh destructor. - - -1.2.4 -Added support for SSH2_MSG_USERAUTH_BANNER. -Fixed infinate loop in select_thread(). -Other bug fixes. - - -1.2.3 -Fixed error logging issue seen during authentication. -Added more detailed authentication error messages. -Adjusted the error reporting interface for easier porting. -Addressed debugging issues in the Windows port. -Included new code examples reflecting the changes to the error reporting interface. - - -1.2.2 -Fixed premature communication thread termination. -Adjustments for MINGW compiler. -Other bugfixes. - - -1.2.1 -Fixed buffer overflow in SFTP put() and get(). -Mutex put in it's own class. -Code formatting fixed. -Other bugfixes. - - -1.2.0 -Implemented Secure FTP client functionality. -Fixed mutex locking issues. -Fixed race conditions when running with multiple threads. -Added support for RSA host keys. -Added diffie-hellman-group14-sha1 key exchange algorithm support. -Added timeout variable to connect methods. -Other bugfixes. - - -1.1.6 -Added support for Botan 1.5. Thanks to Jack Lloyd for the patch. -WIN32 related bugfixes. -Improved PEM file checking. -Other minor bugfixes. - - -1.1.5 - -Fixed DSA key generation. -Implemented single command execution. -Added Support for reading binary data. -Fixed getReceivedSize() method. -Error handling rewritten. -Fixed a few memory leaks. -Other bugfixes. - - -1.1 - -RSA and DSA public key authentication support added. -RSA and DSA key generation methods added. -All errors are handled through throwError() function. -Syslog functions removed. -Implemented getReceivedSize() method to support reading past /0 character in received stream. -Botan types changed to full types to avoid compatibility issues with WIN32. -WIN32 specific thread functions added. -Premature mutex unlocking in connection routines fixed. -Fixed prevLen variable initialization in waitFor method. -In Net7Sock class write() method, write() replaced with send(). -In Net7Sock class read() method, read() replaced with recv(). -Type definitions adjusted for WIN32 compatibility. -WIN32 socket functions implemented. - - -1.03 - -Initial stand alone release. diff --git a/src/libs/3rdparty/net7ssh/CMakeLists.txt b/src/libs/3rdparty/net7ssh/CMakeLists.txt deleted file mode 100644 index 9bd25d2d557..00000000000 --- a/src/libs/3rdparty/net7ssh/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -cmake_minimum_required(VERSION 2.0) -project(net7ssh CXX) -INCLUDE(CheckIncludeFileCXX) -check_include_file_cxx("botan/botan.h" HAVE_BOTAN) -if (NOT ${HAVE_BOTAN}) -MESSAGE(FATAL_ERROR "Could not find Botan library.") -endif() -set(CMAKE_INSTALL_PREFIX "/usr") -add_subdirectory ( src ) -include_directories ( src ) -if ( UNIX ) - SET(UNIX_STYLE_FLAGS 1) - SET(WIN32_STYLE_FLAGS 0) - EXECUTE_PROCESS( - COMMAND uname -a - OUTPUT_VARIABLE OS_ARCH - ) - - IF ( OS_ARCH MATCHES ".*SunOS.*" ) - MESSAGE ("Making Changes for SunOS!") - SET(CMAKE_C_COMPILER "cc") - SET(CMAKE_CXX_COMPILER "CC") - SET(CMAKE_LINKER "cc") - SET(CMAKE_AR "/usr/ccs/bin/ar") - SET(CMAKE_CXX_FLAGS "-I/usr/local/include") - SET(CMAKE_SHARED_LINKER_FLAGS "-L/usr/local/lib") - SET(CMAKE_MODULE_LINKER_FLAGS "-L/usr/local/lib") - ENDIF ( OS_ARCH MATCHES ".*SunOS.*" ) - -ENDIF ( UNIX ) -set(net7ssh_LIB_SRCS - src/crypt.cpp - src/crypt.h - src/ne7ssh.cpp - src/ne7ssh.h - src/ne7ssh_channel.cpp - src/ne7ssh_channel.h - src/ne7ssh_connection.cpp - src/ne7ssh_connection.h - src/ne7ssh_kex.cpp - src/ne7ssh_kex.h - src/ne7ssh_session.cpp - src/ne7ssh_session.h - src/ne7ssh_string.cpp - src/ne7ssh_string.h - src/ne7ssh_transport.cpp - src/ne7ssh_transport.h - src/ne7ssh_types.h - src/ne7ssh_keys.cpp - src/ne7ssh_keys.h - src/ne7ssh_error.cpp - src/ne7ssh_error.h - src/ne7ssh_sftp.cpp - src/ne7ssh_sftp.h - src/ne7ssh_sftp_packet.cpp - src/ne7ssh_sftp_packet.h - src/ne7ssh_mutex.cpp - src/ne7ssh_mutex.h) - -add_library(ne7ssh STATIC ${net7ssh_LIB_SRCS}) - -add_library(net7ssh SHARED ${net7ssh_LIB_SRCS}) -target_link_libraries(net7ssh botan) -set_target_properties(net7ssh PROPERTIES VERSION 0.3.1 SOVERSION 0) - - -########### install files ############### - -install(TARGETS net7ssh LIBRARY DESTINATION lib) -install(FILES src/ne7ssh.h src/ne7ssh_types.h src/ne7ssh_error.h src/ne7ssh_mutex.h DESTINATION include) -install(FILES LICENSE.QPL AUTHORS INSTALL COPYING CHANGELOG DESTINATION share/doc/ne7ssh) -install(DIRECTORY doc DESTINATION share/doc/ne7ssh) -install(DIRECTORY doc/html DESTINATION share/doc/ne7ssh) -install(DIRECTORY examples DESTINATION share/doc/ne7ssh) diff --git a/src/libs/3rdparty/net7ssh/COPYING b/src/libs/3rdparty/net7ssh/COPYING deleted file mode 100644 index 85bc6356f50..00000000000 --- a/src/libs/3rdparty/net7ssh/COPYING +++ /dev/null @@ -1,103 +0,0 @@ - THE Q PUBLIC LICENSE - version 1.0 - - Copyright (C) 1999-2000 Troll Tech AS, Norway. - Everyone is permitted to copy and - distribute this license document. - -The intent of this license is to establish freedom to share and change the -software regulated by this license under the open source model. - -This license applies to any software containing a notice placed by the -copyright holder saying that it may be distributed under the terms of -the Q Public License version 1.0. Such software is herein referred to as -the Software. This license covers modification and distribution of the -Software, use of third-party application programs based on the Software, -and development of free software which uses the Software. - - Granted Rights - -1. You are granted the non-exclusive rights set forth in this license - provided you agree to and comply with any and all conditions in this - license. Whole or partial distribution of the Software, or software - items that link with the Software, in any form signifies acceptance of - this license. - -2. You may copy and distribute the Software in unmodified form provided - that the entire package, including - but not restricted to - copyright, - trademark notices and disclaimers, as released by the initial developer - of the Software, is distributed. - -3. You may make modifications to the Software and distribute your - modifications, in a form that is separate from the Software, such as - patches. The following restrictions apply to modifications: - - a. Modifications must not alter or remove any copyright notices in - the Software. - - b. When modifications to the Software are released under this - license, a non-exclusive royalty-free right is granted to the - initial developer of the Software to distribute your modification - in future versions of the Software provided such versions remain - available under these terms in addition to any other license(s) of - the initial developer. - -4. You may distribute machine-executable forms of the Software or - machine-executable forms of modified versions of the Software, provided - that you meet these restrictions: - - a. You must include this license document in the distribution. - - b. You must ensure that all recipients of the machine-executable forms - are also able to receive the complete machine-readable source code - to the distributed Software, including all modifications, without - any charge beyond the costs of data transfer, and place prominent - notices in the distribution explaining this. - - c. You must ensure that all modifications included in the - machine-executable forms are available under the terms of this - license. - -5. You may use the original or modified versions of the Software to - compile, link and run application programs legally developed by you - or by others. - -6. You may develop application programs, reusable components and other - software items that link with the original or modified versions of the - Software. These items, when distributed, are subject to the following - requirements: - - a. You must ensure that all recipients of machine-executable forms of - these items are also able to receive and use the complete - machine-readable source code to the items without any charge - beyond the costs of data transfer. - - b. You must explicitly license all recipients of your items to use - and re-distribute original and modified versions of the items in - both machine-executable and source code forms. The recipients must - be able to do so without any charges whatsoever, and they must be - able to re-distribute to anyone they choose. - - - c. If the items are not available to the general public, and the - initial developer of the Software requests a copy of the items, - then you must supply one. - - Limitations of Liability - -In no event shall the initial developers or copyright holders be liable -for any damages whatsoever, including - but not restricted to - lost -revenue or profits or other direct, indirect, special, incidental or -consequential damages, even if they have been advised of the possibility -of such damages, except to the extent invariable law, if any, provides -otherwise. - - No Warranty - -The Software and this license document are provided AS IS with NO WARRANTY -OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE. - Choice of Law - -This license is governed by the Laws of Norway. Disputes shall be settled -by Oslo City Court. diff --git a/src/libs/3rdparty/net7ssh/INSTALL b/src/libs/3rdparty/net7ssh/INSTALL deleted file mode 100644 index fde2e814599..00000000000 --- a/src/libs/3rdparty/net7ssh/INSTALL +++ /dev/null @@ -1,26 +0,0 @@ -Basic Installation Instructions -=============================== - - These are generic installation instructions. - - NetSieben SSH Library requires Botan crypto library 1.4.9 or higher. - It can be found here: - - http://botan.randombit.net - - NetSieben SSH Library requires Cmake. Cmake software can be found here: - http://www.cmake.org - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `cmake .' to configure the package for your system. - - 2. Type `make all' to compile the package. - - 3. Type `make install' to install the programs and any data files and - documentation. - - 4. You can remove the program binaries and object files from the - source code directory by typing `make clean'. - diff --git a/src/libs/3rdparty/net7ssh/LICENSE.QPL b/src/libs/3rdparty/net7ssh/LICENSE.QPL deleted file mode 100644 index 85bc6356f50..00000000000 --- a/src/libs/3rdparty/net7ssh/LICENSE.QPL +++ /dev/null @@ -1,103 +0,0 @@ - THE Q PUBLIC LICENSE - version 1.0 - - Copyright (C) 1999-2000 Troll Tech AS, Norway. - Everyone is permitted to copy and - distribute this license document. - -The intent of this license is to establish freedom to share and change the -software regulated by this license under the open source model. - -This license applies to any software containing a notice placed by the -copyright holder saying that it may be distributed under the terms of -the Q Public License version 1.0. Such software is herein referred to as -the Software. This license covers modification and distribution of the -Software, use of third-party application programs based on the Software, -and development of free software which uses the Software. - - Granted Rights - -1. You are granted the non-exclusive rights set forth in this license - provided you agree to and comply with any and all conditions in this - license. Whole or partial distribution of the Software, or software - items that link with the Software, in any form signifies acceptance of - this license. - -2. You may copy and distribute the Software in unmodified form provided - that the entire package, including - but not restricted to - copyright, - trademark notices and disclaimers, as released by the initial developer - of the Software, is distributed. - -3. You may make modifications to the Software and distribute your - modifications, in a form that is separate from the Software, such as - patches. The following restrictions apply to modifications: - - a. Modifications must not alter or remove any copyright notices in - the Software. - - b. When modifications to the Software are released under this - license, a non-exclusive royalty-free right is granted to the - initial developer of the Software to distribute your modification - in future versions of the Software provided such versions remain - available under these terms in addition to any other license(s) of - the initial developer. - -4. You may distribute machine-executable forms of the Software or - machine-executable forms of modified versions of the Software, provided - that you meet these restrictions: - - a. You must include this license document in the distribution. - - b. You must ensure that all recipients of the machine-executable forms - are also able to receive the complete machine-readable source code - to the distributed Software, including all modifications, without - any charge beyond the costs of data transfer, and place prominent - notices in the distribution explaining this. - - c. You must ensure that all modifications included in the - machine-executable forms are available under the terms of this - license. - -5. You may use the original or modified versions of the Software to - compile, link and run application programs legally developed by you - or by others. - -6. You may develop application programs, reusable components and other - software items that link with the original or modified versions of the - Software. These items, when distributed, are subject to the following - requirements: - - a. You must ensure that all recipients of machine-executable forms of - these items are also able to receive and use the complete - machine-readable source code to the items without any charge - beyond the costs of data transfer. - - b. You must explicitly license all recipients of your items to use - and re-distribute original and modified versions of the items in - both machine-executable and source code forms. The recipients must - be able to do so without any charges whatsoever, and they must be - able to re-distribute to anyone they choose. - - - c. If the items are not available to the general public, and the - initial developer of the Software requests a copy of the items, - then you must supply one. - - Limitations of Liability - -In no event shall the initial developers or copyright holders be liable -for any damages whatsoever, including - but not restricted to - lost -revenue or profits or other direct, indirect, special, incidental or -consequential damages, even if they have been advised of the possibility -of such damages, except to the extent invariable law, if any, provides -otherwise. - - No Warranty - -The Software and this license document are provided AS IS with NO WARRANTY -OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE. - Choice of Law - -This license is governed by the Laws of Norway. Disputes shall be settled -by Oslo City Court. diff --git a/src/libs/3rdparty/net7ssh/README b/src/libs/3rdparty/net7ssh/README deleted file mode 100644 index d81761df4fa..00000000000 --- a/src/libs/3rdparty/net7ssh/README +++ /dev/null @@ -1,614 +0,0 @@ -NetSieben SSH Library (ne7ssh) v1.3.2 README - -LEGALESE - -NetSieben Technologies Pty Limited -http://www.netsieben.com - -Copyright (C) 2005-2009 NetSieben Technologies INC -ALL RIGHTS RESERVED - -This program may be distributed under the terms of the Q Public -License as defined by Trolltech AS of Norway and appearing in the -file LICENSE.QPL included in the packaging of this file. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - ----------------------------------------- - -Table of Contents - -1. Overview -1.1 Features -1.2 Dependencies -1.3 Installation - -2. Usage -2.1 Initializing the class -2.2 Setting the options -2.3 Connecting to a remote server -2.3.1 Key based authentication -2.3.1.1 Generating a key pair -2.3.2 Password based authentication - -2.4 Communications -2.4.1 Interactive mode -2.4.2 Single command - -2.5 Closing the connection -2.6 Error handling -2.6.1 Core context -2.6.2 Channel context -2.7 Secure FTP support -2.7.1 Initializing the subsystem -2.7.2 Setting a timeout for SFTP communications -2.7.3 Downloading a file -2.7.4 Uploading a file -2.7.5 Removing a file -2.7.6 Renaming or moving a file -2.7.7 Changing the current context -2.7.8 Creating a new directory -2.7.9 Removing a directory -2.7.10 Getting a directory listing -2.7.11 Changing permissions -2.7.12 Changing ownership - -3. Commercial License - ----------------------------------------- -1. Overview - -The Secure Shell (SSH) protocol is used by many, as a secure way of managing -servers, firewalls and other network appliances. Nowadays many custom built -applications require Secure Shell client functionality. Instead of spending -countless hours building SSH functionality into an application one can now use -NetSieben Technologies Inc. (NetSieben) SSH library to securely communicate -with a variety of SSH server implementations. - -The library was developed by NetSieben after researching the limited number of -options available. A lot of available solutions were either wrappers to openssh -application or libraries with very limited functionality, and at best, still in -alpha or beta stages of development. At this time version 1 of the SSH -protocol is outdated with well known security flaws inherently in its design. -Therefore NetSieben SSH library supports only with version 2 of the SSH -protocol. Currently NetSieben's library supports only the SSH client. - - -1.1 Features Feature Supported Algorithms - -Key exchange Diffie Hellman Group 1, SHA1 Signatures ssh-dss (1024) User -authentication public key, password Authentication keys DSA (512bit to -1024bit), RSA Encryption aes256-cbc, twofish-cbc, twofish256-cbc, blowfish-cbc, -3des-cbc, aes128-cbc, cast128-cbc HMAC hmac-md5, hmac-sha1, none Compression -not supported Interoperability SSH Library should work with most SSH2 server -implementations. Tested with openssh on Linux. Solaris, FreeBSD and NetBSD. -Also tested with Juniper Netscreen ssh server implementation. - -Portability: The NetSieben SSH Library is based on the Botan crypto library, -making it highly portable. It has been tested on Linux x86, Linux x86_64Linux -PPC, Linux SPARC, Solaris, Windows 2000 and XP. - -1.2 Dependencies - -NetSiben SSH Library requires Botan crypto library 1.4.9 or higher. -Recommended version is 1.4.12. 1.5.x development versions are not supported at -this time. - -The Botan library can be found here: http://botan.randombit.net - -NetSieben SSH Library requires Cmake version 2.0 or higher. Cmake software can -be found here: http://www.cmake.org - - -1.3 Installation - -Public version of NetSieben SSH library is distributed in source code form. -The current version uses autoconf to handle generating of Makefile(s) for your -system. Generally you should be able to install NetSieben SSH Library by -executing the following commands after decompressing the tarball: - -cmake . -make -make install - -For more information please refer to INSTALL file included in the software -package. - - -2. Usage - -2.1 Initializing the class - -Before using library's functionality it needs to be initialized. The -initialization process will allocate the required memory resources and prepare -cryptographic methods for usage. It is recommended to do this first, when -starting the application. Only one instance of ne7ssh class can be used at a -time. Single instance of ne7ssh class is able to handle multiple connections -to multiple servers. It is recommended to initialize the class when starting, -use the same class for all of your SSH connections, and destroy it on the exit. -The class should be initialized with the following command: - -ne7ssh *ssh = new ne7ssh (); - -The constructor of the class requires no arguments. The applications will exit -when trying to initialize the class more than once within the same application. - - -2.2 Setting the options - -Before opening Secure connections, custom options can be configured for the use -in all future connections. Currently only desired cipher and integrity -checking algorithms can be configured. The following method can be used to -configure the options: - -setOptions (const char *prefCipher, const char *prefHmac) - -prefCipher your preferred cipher algorithm string representation. - Supported options are: aes256-cbc, twofish-cbc, twofish256-cbc, - blowfish-cbc, 3des-cbc, aes128-cbc, cast128-cbc. - -prefHmac the preferred integrity checking algorithm string. - Supported optionss are: hmac-md5, hmac-sha1 and none. - - -This step is optional and if skipped the SSH library will use the default -settings. If desired algorithms are not supported by the server, the next one -from the list of supported algorithms will be used. - - -2.3 Connecting to a remote server - -After the options are set, connections to remote servers can be initiated. -NetSieben library supports Password and Public Key authentication methods. - - -2.3.1 Key based authentication - -NetSieben SSH library supports key based authentication. For this to work one -needs to generate a key pair either by using generateKeyPair method from ne7ssh -class or by using ssh-keygen program included in openssh distributions. Server -has to support key based authentication and newly generated public key needs to -be added to servers authorized keys. The process may differ depending on SSH -server vendor. Currently RSA and DSA keys are supported. The NetSieben -library keys are compatible with unencrypted OpenSSH keys. - -No password should be specified when creating a key pair with ssh-keygen. To -establish connection to a remote server using a private key use the following -method: - -int ssh->connectWithKey (const char* host, uint32 port, const char* username, -const char* privKeyFile); - -host Hostname or IP of the server. -port Port the SSH server binds to. - usually be 22 (standard SSH port). -username Username to be used in authentication. -PrivKeyFile Full path to a PEM encoded private key file. - -If the connection succeeds, the method will return the newly created channel -ID. This ID should be used in all further communications via newly created -connection. If the connection failed for any reason, "-1" will be returned by -the method. - -Generating a key pair - -NetSieben SSH library can be used to generate key pairs. Currently RSA and DSA -key algorithms are supported. DSA keys can only be between 512bits and -1024bits (restriction inherited from Botan library). The newly generate keys -are OpenSSH compatible and public keys can be pasted straight into -authorized_keys file. The following method generates a key pair: - -bool generateKeyPair (const char* type, const char* fqdn, const char* -privKeyFileName, const char* pubKeyFileName, uint16 keySize); - -type String specifying key type. Currently "dsa" and "rsa" are supported. -fqdn User id. Such as an Email address. -privKeyFileName Full path to a file where generated private key will be written. -pubKeyFileName Full path to a file where generated public key will be written. -keySize Desired key size in bits. If not specified will default to 2048. - The value has to be changed if generating a dsa keypair. -shell Should the shell be spawned on the remote end. True by defaut. - Should be set to false if using sendCmd method after authentication. - - -2.3.2 Password based authentication - -NetSieben SSH library supports password based authentication. The password -authentication should be enabled in the server configuration. If using this -method make sure its enabled as many distributions of OpenSSH disable this -method by default. The following method allows to establish a connection using -the password authentication: - -int connectWithPassword (const char *host, uint32 port, const char *username, -const char *password ) - -host Hostname or IP of the server. -port Port SSH server binds to, usually 22 (the standard SSH port). -username Username used in authentication. -password Password used in authentication. - -If the connection succeeds, the method will return the newly created channel -ID. This ID should be used in all further communications via newly established -connection. If the connection fails for any reason, "-1" will be returned by -the method. - - -2.4 Communications - -NetSieben SSH library supports two command modes. The first is interactive -mode used for sending text commands and waiting for text results. This works -much like perl "Expect" module. The second mode is a single command mode, -where library sends a single command to the remote end, waits for results and -disconnects. This method can be used to handle binary results. - - -2.4.1 Interactive mode - -Send command - -Before sending a command the waitFor method should be used to wait for shell -prompt, ensuing the remote end is ready for interactive commands. Sending a -command to the remote end can be accomplished using this method: - -bool send (const char *data, int channel ) - -data Command to send. This should be a string terminated with an EOL. - Most terminals will not process a command without end-line. - (character(s) (\n in Unix) to it). -channel Channel ID. - -The method will return "true" if the write to send buffer succeeded. Otherwise -false will be returned. Note: Keep in mind that each usage of send() method -will flush the receive buffer. - -Wait for results - -If the connection is established and a shell launched at the remote end one -needs to pause until a specific string is received. This could be used to wait -for shell prompt after connecting or after a command execution. The SSH -protocol is designed to send data in packets. If results are read from the -buffer right after sending a command, there is no guarantee that the entire -result has been received by the library. Thus it is necessary to wait for a -particular string to appear in the receive buffer. This ensures that all the -data has been received. - -If the specified string is not received, to avoid blocking condition, a timeout -value should be specified. If the desired result is not received in specified -timeframe, the function will return false. The following method is used for -interactive communications: - -bool waitFor (int channel, const char *str, uint32 timeout = 0) - -channel Channel ID received from the connection methods, specifying - the interactive channel. -str String containing text to wait for. -timeout Timeout in seconds. Timeout depends on the speed of your - connection to the remote side. 2 seconds should be enough for - most connections. If 0 is specified, the method will block - until the requested string arrives in the receive buffer. - -If an expected string is received the method will return "true". If the -timeout has been reached, the method will return "false". - - -Fetching the result - -After receiving the expected string or reaching the timeout threshold, the -received results can be accessed by using the following method: - -const char *read (int channel) - -channel Channel ID received from the connection methods, specifying - the interactive channel. - -The method will return pointer to the receive buffer. The memory for the -buffer doesn't need to be allocated nor freed by a programmer, its storage is -handled entirely by the ne7ssh class. This method should always be executed -after waitFor() method. - - -2.4.2 Single command - -Single command can be used when only one command needs to be executed before -disconnecting. Or when expected result is binary. - -Sending command - -This method will not work if the shell has been spawned at the remote end. One -needs to make sure that "shell" parameter of authentication method is set to -"false" before using this method: - -bool sendCmd (const char* cmd, int channel, int timeout); - -cmd Command to send. This should be a string terminated with an EOL. - Most terminals will not process a command without end-line. - (character(s) (\n in Unix) to it). -channel Channel ID. -timeout How long to wait for completion. This value will depend on the - speed of connection and size of results. Recommended value is 30 - seconds. - -The method will "true" if command executed successfully. If an error occurred -during execution "false" is returned. The last error can be obtained by using -errors()->pop() method. - -Result buffer size - -After sending a command followed by a successful execution, the result is -received by the SSH library and placed into the receive buffer. If the data -received is binary one needs to know the size of the buffer before reading it. -This can be obtain by the following method: - -int getReceivedSize (int channel) - -channel Channel ID. - -The method will return the size of the receive buffer, or zero if the buffer is -empty. - -Fetching the result - -If the expected result is a string one can use the above mentioned read() -method to fetch the data. However if the result is binary the following method -should be used: - -void *readBinary (int channel) - -channel Channel ID received from the connection methods. - -The method will return a pointer to the receive buffer. The memory for the -buffer doesn't need to be allocated nor freed by a programmer, its storage is -handled entirely by the ne7ssh class. Having a pointer to the receive buffer -and the size of the buffer, one can easily fetch the binary data stored. - - -2.5 Closing the connection - -When the desired communications are completed the connection needs to be close -using this method: - -bool close (int channel) - -channel Channel ID received from the connection methods. - -The method returns "true" if the sending of "close" command succeeds. "False" -is returned if the channel has already been closed. It is highly recommended -to use a shell command to close the interactive connection instead of this -method. - - -2.6 Error handling - -Starting with version 1.1.5 the SSH library integrates contextual error -reporting. Errors are bound to the channel they occur in. The core messages -are bound to the Core context. All errors are stored in a static instance of -Ne7sshError class and can be access via ne7ssh::errors() method. - - -2.6.1 Core context - -The errors that are not bound to a channel context are considered to be core -errors and can be retrieved using the following command: - -const char* Ne7sshError::pop() - -The command returns a pointer to the last error message within Core context, -removing it from the stack. Continued execution of this command will result in -returning of all Core error messages and at the same time removing them from -the stack. If there are no error message in the Core context zero is returned. - - -2.6.2 Channel context - -The errors that are bound to a channel context can be retrieved using the -following command: - -const char* Ne7sshError::pop(in channel) - -channel Channel ID. - -The command returns a pointer to the last error message within particular -channel context, also removing it from the stack. Continued execution of this -command will result in returning of all particular channel error messages at -the same time removing them from the stack. If there are no error message in a -channel context zero is returned. - - -2.7 Secure FTP support - -Secure FTP (SFTP) client is supported by the NetSieben library starting with -version 1.2.0. - -2.7.1 Initializing the subsystem - -In order to utilize the Secure FTP functionality sftp specific class instances -need to be icreated and sftp subsystem started on the server side. In order to -accomplish this task the following variable needs to be defined: - -Ne7SftpSubsystem _sftp - -The following method is used to initialize the subsystem. The method needs -channel ID, so has to be executed after one of the connect methods. Make sure -remote shell is not spawned. - -bool initSftp (class Ne7SftpSubsystem& _sftp, int channel) - -_sftp Reference to SFTP subsystem to be initialized. -channel Channel ID returned by one of the connect methods. - - -This command returns "true" if the new subsystem was successfully initialized. -And "false" is returned if any error occurs. - - -2.7.2 Setting a timeout for SFTP communications. - -The SFTP subsystem has a default timeout for all of the communications, set to -30 seconds. This should work well under most circumstances, however sometimes -it maybe desirable to modify this value. The following method accomplishes the -task: - -bool setTimeout (uint32 _timeout) - -timeout Timeout in seconds. - - -This command returns "true" upon successful setting of the timeout. Returns -"false" on any error. - - -2.7.3 Downloading a file - -The following method is used to download a file from a remote server. It -functions like sftp "get" command: - -bool get (const char* remoteFile, FILE* localFile) - -remoteFile Full or relative path to the file on the remote side. -LocalFile Pointer to FILE structure. If the file being retrieved - is binary, use "w+" attributes in fopen function. - -This command returns "true" if the file was successfully downloaded. Returns -"false" on any error. - - -2.7.4 Uploading a file - -The following method is used for uploading a file to a remote server. It -functions like SFTP "put" command: - -bool put (FILE* localFile, const char* remoteFile) - -localFile Pointer to FILE structure. If the file being retrieved - is binary, use "r+" attributes in fopen function. -remoteFile Full or relative path to the file on the remote side. - - -This command returns "true" if the file was successfully uploaded. Returns -"false" if any error is encountered. - - -2.7.5 Removing a file - -The following method is used to remove a file. It functions like sftp "rm" -command: - -bool rm (const char* remoteFile) - -remoteFile Full or relative path to the file on the remote side. - - -This command returns "true" if the file was successfully removed. Returns -"false" if any error is encountered. - - -2.7.6 Renaming or moving a file - -The following method is used to rename or move a file. It functions like sftp -"rename" command: - -bool mv (const char* oldFile, const char* newFile) - -oldFile Full or relative path to the file being moved or renamed. -newFIle Full or relative path to the new location/name of the file. - - -This command returns "true" if the file was successfully renamed or moved. -Returns "false" if any error is encountered. - - -2.7.7 Changing the current context - -The following method is used to change the current context. It functions like -sftp "cd" command: - -bool cd (const char* remoteDir) - -remoteDir Full or relative path to a new work path. - - -This command returns "true" if the context was successfully changed. Returns -"false" if any error is encountered. - - -2.7.8 Creating a new directory - -The following method is used to create a new directory. It functions like sftp -"mkdir" command: - -bool mkdir (const char* remoteDir) - -remoteDir Full or relative path to a new directory. - - -This command returns "true" if the new directory was successfully created. -Returns "false" if any error is encountered. - - -2.7.9 Removing a directory - -The following method if used to remove a directory. It functions like sftp -"rmdir" command: - -bool rmdir (const char* remoteDir) - -remoteDir Full or relative path to a directory. - -This command returns "true" if the directory was successfully removed. Returns -"false" if any error is encountered. - - -2.7.10 Getting a directory listing - -The following method is used to get a directory listing. It functions like -sftp "ls" command: - -const char* ls (const char* remoteDir, bool longNames=false) - -remoteDir Full or relative path to a directory. -LongNames If set to "true" the returned string in addition to - file strings will contain attributes for each file. - - -This command returns pointer to a buffer containing directory listing. Returns -NULL if any error is encountered. - - -2.7.11 Changing permissions - -The following method is used to change the permissions of a file or directory. -It functions like sftp "chmod" command: - -bool chmod (const char* remoteFile, const char* mode) - -remotFile Full or relative path to a file. -mode Mode string. It can be either a numerical mode - expression such as "755" or an expression showing the - modifications to be made, such as "ug+w". Mode string - is the same as used by *nix chmod command. - -This command returns "true" if the new permissions are successfully applied. -Returns "false" if any error is encountered. - - -2.7.12 Changing ownership - -The following method is used to change the ownership of a file or directory. -It functions like sftp "chown" command: - -bool chown (const char* remoteFile, uint32_t uid, uint32_t gid) - -remoteFile Full or relative path to a file. -uid Numerical user ID of the new owner. -gid Numerical group ID of the new owner. - -This command returns "true" if the new ownership is successfully applied. -Returns "false" if any error is encountered. - - -3. Commercial License - -For details about commercial license please fill out the form located at: -https://netsieben.com/sshlib_info.phtml diff --git a/src/libs/3rdparty/net7ssh/doc/html/annotated.html b/src/libs/3rdparty/net7ssh/doc/html/annotated.html deleted file mode 100644 index 6a2145ac6c5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/annotated.html +++ /dev/null @@ -1,52 +0,0 @@ - - -ne7ssh.kdevelop: Class List - - - - - - -
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem-members.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem-members.html deleted file mode 100644 index 73bb9a14d95..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem-members.html +++ /dev/null @@ -1,62 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7SftpSubsystem Member List

This is the complete list of members for Ne7SftpSubsystem, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APPEND enum value (defined in Ne7SftpSubsystem)Ne7SftpSubsystem
cd(const char *remoteDir)Ne7SftpSubsystem
chmod(const char *remoteFile, const char *mode)Ne7SftpSubsystem
chown(const char *remoteFile, uint32_t uid, uint32_t gid=0)Ne7SftpSubsystem
closeFile(uint32 fileID)Ne7SftpSubsystem
errorNotInited()Ne7SftpSubsystem [private]
get(const char *remoteFile, FILE *localFile)Ne7SftpSubsystem
getFileAttrs(fileAttrs &attrs, const char *filename, bool followSymLinks=true)Ne7SftpSubsystem
inited (defined in Ne7SftpSubsystem)Ne7SftpSubsystem [private]
isDir(const char *remoteFile)Ne7SftpSubsystem
isFile(const char *remoteFile)Ne7SftpSubsystem
ls(const char *remoteDir, bool longNames=false)Ne7SftpSubsystem
mkdir(const char *remoteDir)Ne7SftpSubsystem
mv(const char *oldFile, const char *newFile)Ne7SftpSubsystem
Ne7SftpSubsystem()Ne7SftpSubsystem
Ne7SftpSubsystem(class Ne7sshSftp *_sftp)Ne7SftpSubsystem
openDir(const char *dirname)Ne7SftpSubsystem
openFile(const char *filename, uint8 mode)Ne7SftpSubsystem
OVERWRITE enum value (defined in Ne7SftpSubsystem)Ne7SftpSubsystem
put(FILE *localFile, const char *remoteFile)Ne7SftpSubsystem
READ enum value (defined in Ne7SftpSubsystem)Ne7SftpSubsystem
readFile(uint32 fileID, uint64 offset=0)Ne7SftpSubsystem
rm(const char *remoteFile)Ne7SftpSubsystem
rmdir(const char *remoteDir)Ne7SftpSubsystem
setTimeout(uint32 _timeout)Ne7SftpSubsystem
sftp (defined in Ne7SftpSubsystem)Ne7SftpSubsystem [private]
writeFile(uint32 fileID, const uint8 *data, uint32 len, uint64 offset=0)Ne7SftpSubsystem
writeMode enum nameNe7SftpSubsystem
~Ne7SftpSubsystem()Ne7SftpSubsystem

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem.html deleted file mode 100644 index 09b06ed273b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem.html +++ /dev/null @@ -1,879 +0,0 @@ - - -ne7ssh.kdevelop: Ne7SftpSubsystem Class Reference - - - - - -
-

Ne7SftpSubsystem Class Reference

#include <ne7ssh.h> -

-

-Collaboration diagram for Ne7SftpSubsystem:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Classes

struct  fileAttrs

Public Types

enum  writeMode { READ, -OVERWRITE, -APPEND - }

Public Member Functions

 Ne7SftpSubsystem ()
 Ne7SftpSubsystem (class Ne7sshSftp *_sftp)
 ~Ne7SftpSubsystem ()
bool setTimeout (uint32 _timeout)
uint32 openFile (const char *filename, uint8 mode)
uint32 openDir (const char *dirname)
bool readFile (uint32 fileID, uint64 offset=0)
bool writeFile (uint32 fileID, const uint8 *data, uint32 len, uint64 offset=0)
bool closeFile (uint32 fileID)
bool getFileAttrs (fileAttrs &attrs, const char *filename, bool followSymLinks=true)
bool get (const char *remoteFile, FILE *localFile)
bool put (FILE *localFile, const char *remoteFile)
bool rm (const char *remoteFile)
bool mv (const char *oldFile, const char *newFile)
bool mkdir (const char *remoteDir)
bool rmdir (const char *remoteDir)
const char * ls (const char *remoteDir, bool longNames=false)
bool cd (const char *remoteDir)
bool chmod (const char *remoteFile, const char *mode)
bool chown (const char *remoteFile, uint32_t uid, uint32_t gid=0)
bool isFile (const char *remoteFile)
bool isDir (const char *remoteFile)

Private Member Functions

bool errorNotInited ()

Private Attributes

-bool inited
-Ne7sshSftpsftp
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Member Enumeration Documentation

- -
-
- - - - -
enum Ne7SftpSubsystem::writeMode
-
-
- -

-Modes used when opening a remote file. -

-

-


Constructor & Destructor Documentation

- -
-
- - - - - - - - -
Ne7SftpSubsystem::Ne7SftpSubsystem (  ) 
-
-
- -

-Default constructor. -

-

- -

-
- - - - - - - - - -
Ne7SftpSubsystem::Ne7SftpSubsystem (class Ne7sshSftp _sftp  ) 
-
-
- -

-Constructor used to initialize the subsystem with a new Ne7sshSftp class instance.

Parameters:
- - -
_sftp Ne7sshSftp class instance.
-
- -
-

- -

-
- - - - - - - - -
Ne7SftpSubsystem::~Ne7SftpSubsystem (  ) 
-
-
- -

-Default destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool Ne7SftpSubsystem::cd (const char *  remoteDir  ) 
-
-
- -

-This method is used to change the current working directory.

Parameters:
- - -
remoteDir Full or relative path to the new working directory on the remote server.
-
-
Returns:
True if change of directory succedded. False on any error.
- -

References Ne7sshSftp::cd(), and errorNotInited().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::chmod (const char *  remoteFile,
const char *  mode 
)
-
-
- -

-This method is used for changing the permissions associated with a remote file.

Parameters:
- - - -
remoteFile Full or relative path to the remote file.
mode Mode string. It can be either a numerical mode expression such as "755" or an expression showing the modifications to be made, such as "ug+w". Mode string is the same as used by *nix chmod command.
-
-
Returns:
True if the new permissions are succesfully applied to the remote file. False on any error.
- -

References Ne7sshSftp::chmod(), and errorNotInited().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::chown (const char *  remoteFile,
uint32_t  uid,
uint32_t  gid = 0 
)
-
-
- -

-This method is used to change the owner of a remote file.

Parameters:
- - - - -
remoteFile Full or relative path to the remote file.
uid Numerical new owner user ID.
gid Numerical new owner group ID.
-
-
Returns:
True if the change of ownership succeeds. False on any error.
- -

References Ne7sshSftp::chown(), and errorNotInited().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::closeFile (uint32  fileID  ) 
-
-
- -

-Low level method used to close a file opened by using openFile() method.

Parameters:
- - -
fileID File ID returned by openFile() method.
-
-
Returns:
True on success. False on any error.
- -

References Ne7sshSftp::closeFile(), and errorNotInited().

- -
-

- -

-
- - - - - - - - -
bool Ne7SftpSubsystem::errorNotInited (  )  [private]
-
-
- -

-Pushes and error to the error buffer, if this subsystem has not been initialized before usage.

Returns:
True if the push succeeds. Otherwise false.
- -

References ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by cd(), chmod(), chown(), closeFile(), get(), getFileAttrs(), isDir(), isFile(), ls(), mkdir(), mv(), openDir(), openFile(), put(), readFile(), rm(), rmdir(), setTimeout(), and writeFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::get (const char *  remoteFile,
FILE *  localFile 
)
-
-
- -

-This method is used to retrieve a remote file and dump it into local file.

Parameters:
- - - -
remoteFile Full or relative path to the file on the remote side.
localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function.
-
-
Returns:
True if getting the file is succeeds. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::get().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::getFileAttrs (fileAttrs attrs,
const char *  filename,
bool  followSymLinks = true 
)
-
-
- -

-This method is used to retrieve remote file attributes and place them into fileAttrs structure.

Parameters:
- - - - -
attrs Reference to fileAttrs structure where retrieved attributes should be placed.
filename Name of the remote file.
followSymLinks If this variable is set to true, symbolic links will be followed. That is the default befavour. If this behavour is undesired, pass "false".
-
-
Returns:
True if the attributes successfully retrieved. Otherwise false is returned.
- -

References errorNotInited(), and Ne7sshSftp::getFileAttrs().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::isDir (const char *  remoteFile  ) 
-
-
- -

-This method is used to determine if a remote inode is a directory.

Parameters:
- - -
remoteFile Full or relative path to the remote file.
-
-
Returns:
True if the remote inode is a directory. Otherwise false.
- -

References errorNotInited(), and Ne7sshSftp::isDir().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::isFile (const char *  remoteFile  ) 
-
-
- -

-This method is used to determine if a remote inode is a regular file.

Parameters:
- - -
remoteFile Full or relative path to the remote inode.
-
-
Returns:
True if the remote inode is a regular file. Otherwise false.
- -

References errorNotInited(), and Ne7sshSftp::isFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
const char * Ne7SftpSubsystem::ls (const char *  remoteDir,
bool  longNames = false 
)
-
-
- -

-This methods is used retrieve a listing of a remote directory.

Parameters:
- - - -
remoteDir Full or relative path to a directory.
longNames If set to "true" the returned string in addition to file strings will contain attributes for each file.
-
-
Returns:
A pointer to a string containing the directory listing.
- -

References errorNotInited(), and Ne7sshSftp::ls().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::mkdir (const char *  remoteDir  ) 
-
-
- -

-This method is used to create a new directory.

Parameters:
- - -
remoteDir Full or relative path to a new directory on the remote server.
-
-
Returns:
True if the directory successfully created. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::mkdir().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::mv (const char *  oldFile,
const char *  newFile 
)
-
-
- -

-This method is used to rename/move files.

Parameters:
- - - -
oldFile Full or relative path to an old file on the remote server.
newFile Full or relative path to a new file on the remote side.
-
-
Returns:
True if renaming successfull. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::mv().

- -
-

- -

-
- - - - - - - - - -
uint32 Ne7SftpSubsystem::openDir (const char *  dirname  ) 
-
-
- -

-Low level method used to open an inode containing file entries a.k.a directory.

Parameters:
- - -
dirname Relative or full path to the inode.
-
-
Returns:
Newly opened file ID or 0 if the inode could not be opened.
- -

References errorNotInited(), and Ne7sshSftp::openDir().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
uint32 Ne7SftpSubsystem::openFile (const char *  filename,
uint8  mode 
)
-
-
- -

-Low level method used to open a remote file.

Parameters:
- - - -
filename Relative or full path to the file.
mode Mode to be used when opening the file. Can be one of the modes defined by writeMode class variable.
-
-
Returns:
Newly opened file ID or 0 if file could not be opened.
- -

References errorNotInited(), and Ne7sshSftp::openFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::put (FILE *  localFile,
const char *  remoteFile 
)
-
-
- -

-This method is used to upload a file to a remote server.

Parameters:
- - - -
localFile Pointer to the FILE structure. If the file being retrieved is binary, use "r+" attributes in fopen function.
remoteFile Full or relative path to the file on the remote side.
-
-
Returns:
True if putting the file succeeds. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::put().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::readFile (uint32  fileID,
uint64  offset = 0 
)
-
-
- -

-Low level method used to read datablock up to the size of SFTP_MAX_MSG_SIZE from a file.

Parameters:
- - - -
fileID File ID retruned by openFile() method.
offset Offset.
-
-
Returns:
True if file content successfully read and placed in the buffer. Otherwise false.
- -

References errorNotInited(), and Ne7sshSftp::readFile().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::rm (const char *  remoteFile  ) 
-
-
- -

-This method is used to remove a file on a remote server.

Parameters:
- - -
remoteFile Full or relative path to the file on the remote side.
-
-
Returns:
True if remove succeeds. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::rm().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::rmdir (const char *  remoteDir  ) 
-
-
- -

-This method is used to remove a remote directory.

Parameters:
- - -
remoteDir Full or relative path to a directory to be removed.
-
-
Returns:
True if the directory successfully removed. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::rmdir().

- -
-

- -

-
- - - - - - - - - -
bool Ne7SftpSubsystem::setTimeout (uint32  _timeout  ) 
-
-
- -

-This method is used to set a timeout for all SFTP subsystem communications.

Parameters:
- - -
_timeout Timeout in seconds.
-
-
Returns:
True if timeout set, otherwise false.
- -

References errorNotInited(), and Ne7sshSftp::setTimeout().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7SftpSubsystem::writeFile (uint32  fileID,
const uint8 *  data,
uint32  len,
uint64  offset = 0 
)
-
-
- -

-Low level method used to write data-block up to the size of SFTP_MAX_MSG_SIZE to a remote file.

Parameters:
- - - - - -
fileID File ID returned by openFile() method.
data Pointer to a buffer containing the data.
len Length of the block.
offset Offset in the remote file. If offset is passed EOF the space between EOF and offset will be filled by 0x0.
-
-
Returns:
True if file contect successfully written. False on any error.
- -

References errorNotInited(), and Ne7sshSftp::writeFile().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.map deleted file mode 100644 index 7abd9ada75c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.map +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.md5 deleted file mode 100644 index b417fbad956..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7SftpSubsystem__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -a3599377bc7d09bac1983e35132d609e \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError-members.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError-members.html deleted file mode 100644 index f7cafb0c76d..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError-members.html +++ /dev/null @@ -1,47 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshError Member List

This is the complete list of members for Ne7sshError, including all inherited members.

- - - - - - - - - - - - - - -
deleteChannel(int32 channel)Ne7sshError
deleteCoreMsgs()Ne7sshError
deleteRecord(uint16 recID)Ne7sshError [private]
ErrorBufferNe7sshError [private]
lock()Ne7sshError [private, static]
memberCount (defined in Ne7sshError)Ne7sshError [private]
mut (defined in Ne7sshError)Ne7sshError [private, static]
Ne7sshError()Ne7sshError
pop()Ne7sshError
pop(int32 channel)Ne7sshError
popedErr (defined in Ne7sshError)Ne7sshError [private]
push(int32 channel, const char *format,...)Ne7sshError
unlock()Ne7sshError [private, static]
~Ne7sshError()Ne7sshError

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError.html deleted file mode 100644 index e8dcc654b44..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError.html +++ /dev/null @@ -1,375 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshError Class Reference - - - - - -
-

Ne7sshError Class Reference

#include <ne7ssh_error.h> -

-

-Collaboration diagram for Ne7sshError:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Classes

struct  Error

Public Member Functions

 Ne7sshError ()
 ~Ne7sshError ()
bool push (int32 channel, const char *format,...)
const char * pop ()
const char * pop (int32 channel)
bool deleteCoreMsgs ()
bool deleteChannel (int32 channel)

Private Member Functions

bool deleteRecord (uint16 recID)

Static Private Member Functions

static bool lock ()
static bool unlock ()

Private Attributes

-uint16 memberCount
-char popedErr [MAX_ERROR_LEN+1]
struct Ne7sshError::Error ** ErrorBuffer

Static Private Attributes

-static Ne7ssh_Mutex mut
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
Ne7sshError::Ne7sshError (  ) 
-
-
- -

-Ne7sshError constructor. -

-

- -

-
- - - - - - - - -
Ne7sshError::~Ne7sshError (  ) 
-
-
- -

-Ne7sshError destructor. -

References ErrorBuffer.

- -
-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool Ne7sshError::deleteChannel (int32  channel  ) 
-
-
- -

-Removes all error messages within Channel context from the stack.

Parameters:
- - -
channel Specifies the channel error message was bound to. This is ne7ssh library channel, not the receive or send channels used by the transport layer.
-
-
Returns:
True on succes, false on failure.
- -

References ErrorBuffer, lock(), and unlock().

- -

Referenced by ne7ssh::close(), and deleteCoreMsgs().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshError::deleteCoreMsgs (  ) 
-
-
- -

-Removes all error messages within Core context from the stack.

Returns:
True on success, false on failure.
- -

References deleteChannel().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshError::deleteRecord (uint16  recID  )  [private]
-
-
- -

-Delete a single error message.

Parameters:
- - -
recID Position within the array.
-
-
Returns:
True on success, false on failure.
- -

References ErrorBuffer.

- -

Referenced by pop().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshError::lock (  )  [static, private]
-
-
- -

-Lock the mutex.

Returns:
True if lock aquired. Oterwise false.
- -

-FIXME possible infinite loop -

References ne7ssh::errors(), and push().

- -

Referenced by deleteChannel(), pop(), and push().

- -
-

- -

-
- - - - - - - - - -
const char * Ne7sshError::pop (int32  channel  ) 
-
-
- -

-Pops an error message from the Channel context.

Parameters:
- - -
channel Specifies the channel error message was bound to. This is ne7ssh library channel, not the receive or send channels used by the transport layer.
-
-
Returns:
The last error message in the Channel context. The message is removed from the stack. Returns null if no there are no erros in the Channel context.
- -

References deleteRecord(), ErrorBuffer, lock(), and unlock().

- -
-

- -

-
- - - - - - - - -
const char * Ne7sshError::pop (  ) 
-
-
- -

-Pops an error message from the Core context.

Returns:
The last error message in the Core context. The message is removed from the stack.
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshError::push (int32  channel,
const char *  format,
  ... 
)
-
-
- -

-Pushes a new error message into the stack.

Parameters:
- - - -
channel Specifies the channel to bind the error message to. This is ne7ssh library channel, not the receive or send channels used by the transport layer.
format Specifies the error message followed by argument in printf format. The following formatting characters are supported: s,d,i,l,x. Modifier u can be used together with decimal to specify an unsigned variable. Returns null if no there are no erros in the Core context.
-
-
Returns:
True on success, false on failure.
- -

References ErrorBuffer, lock(), and unlock().

- -

Referenced by ne7ssh_string::addFile(), ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), Ne7sshSftp::cd(), ne7ssh_connection::checkRemoteVersion(), Ne7sshSftp::chmod(), Ne7sshSftp::chown(), ne7ssh::close(), Ne7sshSftp::closeFile(), ne7ssh_crypt::compute_key(), ne7ssh_crypt::computeH(), ne7ssh::connectWithKey(), ne7ssh::connectWithPassword(), Ne7SftpSubsystem::errorNotInited(), ne7ssh_transport::establish(), ne7ssh_channel::execCmd(), ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateDSASignature(), ne7ssh::generateKeyPair(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::generateRSASignature(), Ne7sshSftp::get(), ne7ssh::getChannelNo(), ne7ssh_crypt::getCryptAlgo(), ne7ssh_keys::getDSAKeys(), Ne7sshSftp::getFileAttrs(), Ne7sshSftp::getFileHandle(), Ne7sshSftp::getFileSize(), Ne7sshSftp::getFileStats(), Ne7sshSftp::getFStat(), ne7ssh_crypt::getHashAlgo(), ne7ssh_crypt::getHmacAlgo(), ne7ssh_crypt::getKexPublic(), ne7ssh_keys::getKeyPairFromFile(), ne7ssh_crypt::getMacKeyLen(), ne7ssh_keys::getRSAKeys(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), ne7ssh_channel::handleDisconnect(), ne7ssh_channel::handleEof(), ne7ssh_channel::handleExtendedData(), ne7ssh_kex::handleInit(), ne7ssh_channel::handleReceived(), ne7ssh_channel::handleRequest(), Ne7sshSftp::handleSftpData(), Ne7sshSftp::handleStatus(), Ne7sshSftp::handleVersion(), ne7ssh::initSftp(), Ne7sshSftp::isType(), lock(), ne7ssh::lock(), Ne7sshSftp::ls(), Ne7sshSftp::mkdir(), Ne7sshSftp::mv(), ne7ssh::ne7ssh(), ne7ssh_crypt::negotiatedCmprsC2s(), ne7ssh_crypt::negotiatedCmprsS2c(), ne7ssh_crypt::negotiatedCryptoC2s(), ne7ssh_crypt::negotiatedCryptoS2c(), ne7ssh_crypt::negotiatedHostkey(), ne7ssh_crypt::negotiatedKex(), ne7ssh_crypt::negotiatedMacC2s(), ne7ssh_crypt::negotiatedMacS2c(), ne7ssh_transport::NoBlock(), ne7ssh_channel::open(), Ne7sshSftp::openDir(), Ne7sshSftp::openFile(), Ne7sshSftp::put(), ne7ssh::read(), ne7ssh::readBinary(), Ne7sshSftp::readFile(), ne7ssh_transport::receive(), Ne7sshSftp::receiveWindowAdjust(), ne7ssh_connection::requestService(), Ne7sshSftp::rm(), Ne7sshSftp::rmdir(), ne7ssh::selectThread(), ne7ssh_transport::send(), ne7ssh::send(), ne7ssh::sendCmd(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), ne7ssh_transport::sendPacket(), ne7ssh_connection::startSftp(), unlock(), ne7ssh::unlock(), ne7ssh_crypt::verifySig(), ne7ssh::waitFor(), ne7ssh_transport::waitForPacket(), and Ne7sshSftp::writeFile().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshError::unlock (  )  [static, private]
-
-
- -

-Unlock the mutext.

Returns:
True if the mutext successfully unlocked. Otherwise false.
- -

References ne7ssh::errors(), and push().

- -

Referenced by deleteChannel(), pop(), and push().

- -
-

-


Member Data Documentation

- -
-
- - - - -
struct Ne7sshError::Error ** Ne7sshError::ErrorBuffer [private]
-
-
- -

-Structure for storing error messages. -

Referenced by deleteChannel(), deleteRecord(), pop(), push(), and ~Ne7sshError().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.map deleted file mode 100644 index f46ec445b1f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.md5 deleted file mode 100644 index 1b4476ec8bf..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshError__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -59fecf6fac000bbe159906d2497191a5 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp-members.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp-members.html deleted file mode 100644 index a5b7df92978..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp-members.html +++ /dev/null @@ -1,110 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshSftp Member List

This is the complete list of members for Ne7sshSftp, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
addOpenHandle(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
adjustRecvWindow(int bufferSize)ne7ssh_channel
APPEND enum value (defined in Ne7sshSftp)Ne7sshSftp [private]
attrs (defined in Ne7sshSftp)Ne7sshSftp [private]
cd(const char *remoteDir)Ne7sshSftp
channelOpened (defined in ne7ssh_channel)ne7ssh_channel [protected]
chmod(const char *remoteFile, const char *mode)Ne7sshSftp
chown(const char *remoteFile, uint32 uid, uint32 gid=0)Ne7sshSftp
closeFile(uint32 fileID)Ne7sshSftp
commBuffer (defined in Ne7sshSftp)Ne7sshSftp [private]
currentPath (defined in Ne7sshSftp)Ne7sshSftp [private]
data2Send()ne7ssh_channel [inline]
execCmd(const char *cmd)ne7ssh_channel
fileBuffer (defined in Ne7sshSftp)Ne7sshSftp [private]
get(const char *remoteFile, FILE *localFile)Ne7sshSftp
getCmdComplete()ne7ssh_channel [inline]
getFileAttrs(sftpFileAttrs &attributes, Botan::SecureVector< Botan::byte > &remoteFile, bool followSymLinks=true)Ne7sshSftp [private]
getFileAttrs(Ne7SftpSubsystem::fileAttrs &attributes, const char *remoteFile, bool followSymLinks=true)Ne7sshSftp
getFileHandle(uint32 fileID)Ne7sshSftp [private]
getFileSize(uint32 fileID)Ne7sshSftp [private]
getFileStats(const char *remoteFile, bool followSymLinks=true)Ne7sshSftp [private]
getFStat(uint32 fileID)Ne7sshSftp [private]
getFullPath(const char *filename)Ne7sshSftp [private]
getReceived()ne7ssh_channel [inline]
getRecvWindow()ne7ssh_channel [inline]
getSendWindow()ne7ssh_channel [inline]
getShell()ne7ssh_channel
handleData(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private, virtual]
handleNames(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
handleReceived(Botan::SecureVector< Botan::byte > &_packet)ne7ssh_channel
handleSftpData(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
handleStatus(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
handleVersion(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
init()Ne7sshSftp
isDir(const char *remoteFile)Ne7sshSftp
isFile(const char *remoteFile)Ne7sshSftp
isOpen()ne7ssh_channel [inline]
isRemoteShell()ne7ssh_channel [inline]
isType(const char *remoteFile, uint32 type)Ne7sshSftp [private]
lastError (defined in Ne7sshSftp)Ne7sshSftp [private]
ls(const char *remoteDir, bool longNames=false)Ne7sshSftp
mkdir(const char *remoteDir)Ne7sshSftp
mv(const char *oldFile, const char *newFile)Ne7sshSftp
ne7ssh_channel(ne7ssh_session *_session)ne7ssh_channel
Ne7sshSftp(ne7ssh_session *_session, ne7ssh_channel *_channel)Ne7sshSftp
open(uint32 channelID)ne7ssh_channel
openDir(const char *dirname)Ne7sshSftp
openFile(const char *filename, uint8 shortMode)Ne7sshSftp
OVERWRITE enum value (defined in Ne7sshSftp)Ne7sshSftp [private]
processAttrs(Botan::SecureVector< Botan::byte > &packet)Ne7sshSftp [private]
put(FILE *localFile, const char *remoteFile)Ne7sshSftp
READ enum value (defined in Ne7sshSftp)Ne7sshSftp [private]
readFile(uint32 fileID, uint64 offset=0)Ne7sshSftp
receive()ne7ssh_channel
receiveUntil(short _cmd, uint32 timeSec=0)Ne7sshSftp [private]
receiveWhile(short _cmd, uint32 timeSec=0)Ne7sshSftp [private]
receiveWindowAdjust()Ne7sshSftp [private]
rm(const char *remoteFile)Ne7sshSftp
rmdir(const char *remoteDir)Ne7sshSftp
sendAdjustWindow()ne7ssh_channel [protected]
sendAll()ne7ssh_channel
sendClose()ne7ssh_channel
sendEof()ne7ssh_channel
seq (defined in Ne7sshSftp)Ne7sshSftp [private]
session (defined in Ne7sshSftp)Ne7sshSftp [private]
setTimeout(uint32 _timeout)Ne7sshSftp [inline]
sftpCmd (defined in Ne7sshSftp)Ne7sshSftp [private]
sftpFiles (defined in Ne7sshSftp)Ne7sshSftp [private]
sftpFilesCount (defined in Ne7sshSftp)Ne7sshSftp [private]
timeout (defined in Ne7sshSftp)Ne7sshSftp [private]
windowRecv (defined in ne7ssh_channel)ne7ssh_channel [protected]
windowSend (defined in ne7ssh_channel)ne7ssh_channel [protected]
write(Botan::SecureVector< Botan::byte > &data)ne7ssh_channel
writeFile(uint32 fileID, const uint8 *data, uint32 len, uint64 offset=0)Ne7sshSftp
writeMode enum name (defined in Ne7sshSftp)Ne7sshSftp [private]
~ne7ssh_channel()ne7ssh_channel [virtual]
~Ne7sshSftp()Ne7sshSftp

-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp.html deleted file mode 100644 index dcb580358da..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp.html +++ /dev/null @@ -1,1516 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshSftp Class Reference - - - - - -
-

Ne7sshSftp Class Reference

#include <ne7ssh_sftp.h> -

-

-Inheritance diagram for Ne7sshSftp:
-
-

Inheritance graph
- - -
[legend]
-
-Collaboration diagram for Ne7sshSftp:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Classes

struct  sftpFile
struct  sftpFileAttrs

Public Member Functions

 Ne7sshSftp (ne7ssh_session *_session, ne7ssh_channel *_channel)
 ~Ne7sshSftp ()
bool init ()
void setTimeout (uint32 _timeout)
uint32 openFile (const char *filename, uint8 shortMode)
uint32 openDir (const char *dirname)
bool readFile (uint32 fileID, uint64 offset=0)
bool writeFile (uint32 fileID, const uint8 *data, uint32 len, uint64 offset=0)
bool closeFile (uint32 fileID)
bool getFileAttrs (Ne7SftpSubsystem::fileAttrs &attributes, const char *remoteFile, bool followSymLinks=true)
bool isFile (const char *remoteFile)
bool isDir (const char *remoteFile)
bool get (const char *remoteFile, FILE *localFile)
bool put (FILE *localFile, const char *remoteFile)
bool rm (const char *remoteFile)
bool mv (const char *oldFile, const char *newFile)
bool mkdir (const char *remoteDir)
bool rmdir (const char *remoteDir)
const char * ls (const char *remoteDir, bool longNames=false)
bool cd (const char *remoteDir)
bool chmod (const char *remoteFile, const char *mode)
bool chown (const char *remoteFile, uint32 uid, uint32 gid=0)

Private Types

enum  writeMode { READ, -OVERWRITE, -APPEND - }

Private Member Functions

bool handleData (Botan::SecureVector< Botan::byte > &packet)
bool handleVersion (Botan::SecureVector< Botan::byte > &packet)
bool handleStatus (Botan::SecureVector< Botan::byte > &packet)
bool addOpenHandle (Botan::SecureVector< Botan::byte > &packet)
bool handleSftpData (Botan::SecureVector< Botan::byte > &packet)
bool handleNames (Botan::SecureVector< Botan::byte > &packet)
sftpFilegetFileHandle (uint32 fileID)
bool receiveUntil (short _cmd, uint32 timeSec=0)
bool receiveWhile (short _cmd, uint32 timeSec=0)
bool processAttrs (Botan::SecureVector< Botan::byte > &packet)
bool getFileStats (const char *remoteFile, bool followSymLinks=true)
bool getFileAttrs (sftpFileAttrs &attributes, Botan::SecureVector< Botan::byte > &remoteFile, bool followSymLinks=true)
bool getFStat (uint32 fileID)
uint64 getFileSize (uint32 fileID)
bool receiveWindowAdjust ()
ne7ssh_string getFullPath (const char *filename)
bool isType (const char *remoteFile, uint32 type)

Private Attributes

-ne7ssh_sessionsession
-uint32 timeout
-uint32 seq
-uint8 sftpCmd
-ne7ssh_string commBuffer
-Botan::SecureVector< Botan::byte > fileBuffer
-uint8 lastError
-char * currentPath
-sftpFileAttrs attrs
-sftpFile ** sftpFiles
-uint16 sftpFilesCount
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - - - - - - - - - - -
Ne7sshSftp::Ne7sshSftp (ne7ssh_session _session,
ne7ssh_channel _channel 
)
-
-
- -

-Constructor.

Parameters:
- - - -
_session Pointer to connections session data.
_channel Pointer to the ne7ssh_channel instance, taken from the new ne7ssh_connection instance.
-
- -

References ne7ssh_channel::getRecvWindow(), and ne7ssh_channel::getSendWindow().

- -
-

- -

-
- - - - - - - - -
Ne7sshSftp::~Ne7sshSftp (  ) 
-
-
- -

-Default destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool Ne7sshSftp::addOpenHandle (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Method to add a new file to sftpFiles variable from the HANDLE packet.

Parameters:
- - -
packet HANDLE packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh_string::getInt(), and ne7ssh_string::getString().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::cd (const char *  remoteDir  ) 
-
-
- -

-This method is used to change the current working directory.

Parameters:
- - -
remoteDir Full or relative path to the new working directory on the remote server.
-
-
Returns:
True if change of directory succedded. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::cd().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::chmod (const char *  remoteFile,
const char *  mode 
)
-
-
- -

-This method is used for changing the permissions associated with a remote file.

Parameters:
- - - -
remoteFile Full or relative path to the remote file.
mode Mode string. It can be wither a numerical mode expression such as "755" or an expression showing the modifications to be made, such as "ug+w". Mode string is the same as used by *nix chmod command.
-
-
Returns:
True if the new permissions are succesfully applied to the remote file. False on any error.
- -

References ne7ssh::errors(), getFileAttrs(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::chmod().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::chown (const char *  remoteFile,
uint32  uid,
uint32  gid = 0 
)
-
-
- -

-This method is used to change the owner of a remote file.

Parameters:
- - - - -
remoteFile Full or relative path to the remote file.
uid Numerical new owner user ID.
gid Numerical new owner group ID.
-
-
Returns:
True if the change of ownership succeeds. False on any error.
- -

References ne7ssh::errors(), getFileAttrs(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::chown().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::closeFile (uint32  fileID  ) 
-
-
- -

-Low level method used to close a file opened using openFile() method.

Parameters:
- - -
fileID File ID returned by openFile() method.
-
-
Returns:
True on success. False on any error.
- -

References ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and receiveUntil().

- -

Referenced by Ne7SftpSubsystem::closeFile(), get(), ls(), and put().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::get (const char *  remoteFile,
FILE *  localFile 
)
-
-
- -

-This method is used to retrieve a remote file and dump it into local file.

Parameters:
- - - -
remoteFile Full or relative path to the file on the remote side.
localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function.
-
-
Returns:
True if getting the file is succeeds. False on any error.
- -

References closeFile(), ne7ssh::errors(), getFileSize(), ne7ssh_session::getSshChannel(), openFile(), Ne7sshError::push(), and readFile().

- -

Referenced by Ne7SftpSubsystem::get().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::getFileAttrs (Ne7SftpSubsystem::fileAttrs attributes,
const char *  remoteFile,
bool  followSymLinks = true 
)
-
-
- -

-This method is used to retrieve remote file attributes and place them into fileAttrs structure.

Parameters:
- - - - -
attributes Reference to fileAttrs structure where retrieved attributes should be placed.
remoteFile Name of the remote file.
followSymLinks If this variable is set to true, symbolic links will be followed. That is the default befavour. If this behavour is undesired, pass "false".
-
-
Returns:
True if the attributes successfully retrieved. Otherwise false is returned.
- -

References ne7ssh::errors(), getFileStats(), getFullPath(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), and ne7ssh_string::value().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::getFileAttrs (sftpFileAttrs attributes,
Botan::SecureVector< Botan::byte > &  remoteFile,
bool  followSymLinks = true 
) [private]
-
-
- -

-Gets attributes of a remote file and dumps them into sfptFileAtts structure.

Parameters:
- - - - -
attributes reference to sftpFileAttrs structure where the result will be stored.
remoteFile Full or relative path to a remote file.
followSymLinks If set to true symbolic links will be followed. That is the default behavior. If following symbolic links is undesired set to "false".
-
-
Returns:
True if the attributes successfully received. False on any error.
- -

References ne7ssh::errors(), getFileStats(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by chmod(), chown(), and Ne7SftpSubsystem::getFileAttrs().

- -
-

- -

-
- - - - - - - - - -
Ne7sshSftp::sftpFile * Ne7sshSftp::getFileHandle (uint32  fileID  )  [private]
-
-
- -

-This method is used to get a pointer to currently open file stored in sftpFile structure.

Parameters:
- - -
fileID File ID, received from fileOpen() method.
-
-
Returns:
Returns a pointer to sftpFile structyure containing opened file or directory. If file specified by fileID has not been opened, NULL is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by closeFile(), getFStat(), ls(), readFile(), and writeFile().

- -
-

- -

-
- - - - - - - - - -
uint64 Ne7sshSftp::getFileSize (uint32  fileID  )  [private]
-
-
- -

-This methods returnes the size of an open file.

Parameters:
- - -
fileID File ID, returned by the openFile() method.
-
-
Returns:
The size of the remote file. False on any error.
- -

References ne7ssh::errors(), getFStat(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by get().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::getFileStats (const char *  remoteFile,
bool  followSymLinks = true 
) [private]
-
-
- -

-Low level method to request file attributes.

Parameters:
- - - -
remoteFile Full or relative path to a remote file.
followSymLinks If set to true symbolic links will be followed. That is the default behavior. If following symbolic links is undesired set to "false".
-
-
Returns:
True if the request succeeds. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by getFileAttrs(), and isType().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::getFStat (uint32  fileID  )  [private]
-
-
- -

-Works like getFileStats() method, except that it operates on a handle of already opened file instead of path.

Parameters:
- - -
fileID File ID, returned by the openFile() method.
-
-
Returns:
True if the request succeeds. False on any error.
- -

References ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and receiveWhile().

- -

Referenced by getFileSize().

- -
-

- -

-
- - - - - - - - - -
ne7ssh_string Ne7sshSftp::getFullPath (const char *  filename  )  [private]
-
-
- -

-Returns full path to a file or directory.

Parameters:
- - -
filename Relative path to a remote file or directory.
-
-
Returns:
ne7ssh_string class containing full path to the remote file or directory. The class will contain an empty string on error.
- -

Referenced by cd(), chmod(), chown(), getFileAttrs(), getFileStats(), isType(), mkdir(), mv(), openDir(), openFile(), rm(), and rmdir().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleData (Botan::SecureVector< Botan::byte > &  packet  )  [private, virtual]
-
-
- -

-Replacement for ne7ssh_channel handleData method. Processes SFTP specific packets.

Parameters:
- - -
packet Reference to the newly received packet.
-
-
Returns:
True if data successfully processed. False on any error.
- -

Reimplemented from ne7ssh_channel.

- -

References addOpenHandle(), ne7ssh_string::addVector(), ne7ssh_channel::adjustRecvWindow(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_string::getByte(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), handleNames(), handleSftpData(), handleStatus(), handleVersion(), ne7ssh_string::length(), processAttrs(), Ne7sshError::push(), and ne7ssh_string::value().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleNames (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Method to process NAME packets.

Parameters:
- - -
packet NAME packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh_string::addInt(), ne7ssh_string::addVectorField(), ne7ssh_string::getInt(), Ne7sshSftpPacket::getInt64(), ne7ssh_string::getString(), and ne7ssh_string::value().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleSftpData (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Method to process DATA packets.

Parameters:
- - -
packet DATA packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleStatus (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Processes the STATUS packet received from the server.

Parameters:
- - -
packet STATUS packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::handleVersion (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Processes the VERSION packet received from the server.

Parameters:
- - -
packet VERSION packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshSftp::init (  ) 
-
-
- -

-Initializes SFTP subsystem.

Returns:
True if the subsystem successfully initialized. False on any error.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh_session::getSendChannel(), receiveUntil(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::startSftp().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::isDir (const char *  remoteFile  ) 
-
-
- -

-This method is used to determine if a remote inode is a directory.

Parameters:
- - -
remoteFile Full or relative path to the remote file.
-
-
Returns:
True if the remote inode is a directory. Otherwise false.
- -

References isType().

- -

Referenced by Ne7SftpSubsystem::isDir().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::isFile (const char *  remoteFile  ) 
-
-
- -

-This method is used to determine if a remote inode is a regular file.

Parameters:
- - -
remoteFile Full or relative path to the remote inode.
-
-
Returns:
True if the remote inode is a regular file. Otherwise false.
- -

References isType().

- -

Referenced by Ne7SftpSubsystem::isFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::isType (const char *  remoteFile,
uint32  type 
) [private]
-
-
- -

-Determines the type of a remote file.

Parameters:
- - - -
remoteFile Relative or full path to the remote file.
type Type, taken from sys/stat.h.
-
-
Returns:
True if file is of specified type. Otherwise false.
- -

References ne7ssh::errors(), getFileStats(), getFullPath(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by isDir(), and isFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
const char * Ne7sshSftp::ls (const char *  remoteDir,
bool  longNames = false 
)
-
-
- -

-This methods is used retrieve a listing of a remote directory.

Parameters:
- - - -
remoteDir Full or relative path to a directory.
longNames If set to "true" the returned string in addition to file strings will contain attributes for each file.
-
-
Returns:
A pointer to a string containing the directory listing.
- -

References ne7ssh_string::addVector(), ne7ssh_string::clear(), closeFile(), ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), openDir(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::ls().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::mkdir (const char *  remoteDir  ) 
-
-
- -

-This method is used to create a new directory.

Parameters:
- - -
remoteDir Full or relative path to a new directory on the remote server.
-
-
Returns:
True if the directory successfully created. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::mkdir().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::mv (const char *  oldFile,
const char *  newFile 
)
-
-
- -

-This method is used to rename/move files.

Parameters:
- - - -
oldFile Full or relative path to an old file on the remote server.
newFile Full or relative path to a new file on the remote side.
-
-
Returns:
True if renaming successfull. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::mv().

- -
-

- -

-
- - - - - - - - - -
uint32 Ne7sshSftp::openDir (const char *  dirname  ) 
-
-
- -

-Low level method used to open an inode containing file entries a.k.a directory.

Parameters:
- - -
dirname Relative or full path to the inode.
-
-
Returns:
Newly opened file ID or 0 if the inode could not be opened.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveUntil(), and ne7ssh_string::value().

- -

Referenced by ls(), and Ne7SftpSubsystem::openDir().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
uint32 Ne7sshSftp::openFile (const char *  filename,
uint8  shortMode 
)
-
-
- -

-Low level method used to open a remote file.

Parameters:
- - - -
filename Relative or full path to the file.
shortMode Mode to be used when opening the file. Can be one of the modes defined by writeMode class variable.
-
-
Returns:
Newly opened file ID or 0 if file could not be opened.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveUntil(), and ne7ssh_string::value().

- -

Referenced by get(), Ne7SftpSubsystem::openFile(), and put().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::processAttrs (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-Method to process ATTRS packet.

Parameters:
- - -
packet ATTRS packet.
-
-
Returns:
True if processing successful, otherwise false.
- -

References ne7ssh_string::getInt(), and Ne7sshSftpPacket::getInt64().

- -

Referenced by handleData().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::put (FILE *  localFile,
const char *  remoteFile 
)
-
-
- -

-This method is used to upload a file to a remote server.

Parameters:
- - - -
localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function.
remoteFile Full or relative path to the file on the remote side.
-
-
Returns:
True if putting the file succeeds. False on any error.
- -

References closeFile(), ne7ssh::errors(), ne7ssh_session::getSshChannel(), openFile(), Ne7sshError::push(), and writeFile().

- -

Referenced by Ne7SftpSubsystem::put().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::readFile (uint32  fileID,
uint64  offset = 0 
)
-
-
- -

-Low level method used to read datablock up to the size of SFTP_MAX_MSG_SIZE from a file.

Parameters:
- - - -
fileID File ID retruned by openFile() method.
offset Offset. 0 by default.
-
-
Returns:
True if file content successfully read and placed in the buffer. Otherwise false.
- -

References ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and receiveWhile().

- -

Referenced by get(), and Ne7SftpSubsystem::readFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::receiveUntil (short  _cmd,
uint32  timeSec = 0 
) [private]
-
-
- -

-Receive packets until specific SFTP subsystem command is received.

Parameters:
- - - -
_cmd SFTP command to wait for.
timeSec Timeout in seconds.
-
-
Returns:
True if the command specified has been received. Otherwise false.
- -

References ne7ssh_string::clear(), ne7ssh_transport::getPacket(), ne7ssh_channel::handleReceived(), ne7ssh_string::length(), and ne7ssh_transport::waitForPacket().

- -

Referenced by closeFile(), init(), openDir(), openFile(), and writeFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::receiveWhile (short  _cmd,
uint32  timeSec = 0 
) [private]
-
-
- -

-Receive packets while SFTP subsystem commands received matches specified command.

Parameters:
- - - -
_cmd Command to receive.
timeSec Timeout in seconds.
-
-
Returns:
True if all expected data received. Otherwise false.
- -

References ne7ssh_string::clear(), ne7ssh_transport::getPacket(), ne7ssh_channel::handleReceived(), ne7ssh_string::length(), and ne7ssh_transport::waitForPacket().

- -

Referenced by cd(), chmod(), chown(), getFileStats(), getFStat(), ls(), mkdir(), mv(), readFile(), rm(), and rmdir().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshSftp::receiveWindowAdjust (  )  [private]
-
-
- -

-This method is used to wait for an ADJUST_WINDOW packet, when the send window size is zero.

Returns:
True if the ADJUST_WINDOW packet has been received, otherwise false.
- -

References ne7ssh::errors(), ne7ssh_transport::getPacket(), ne7ssh_session::getSshChannel(), ne7ssh_channel::handleReceived(), Ne7sshError::push(), and ne7ssh_transport::waitForPacket().

- -

Referenced by writeFile().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::rm (const char *  remoteFile  ) 
-
-
- -

-This method is used to remove a file on a remote server.

Parameters:
- - -
remoteFile Full or relative path to the file on the remote side.
-
-
Returns:
True if remove succeeds. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::rm().

- -
-

- -

-
- - - - - - - - - -
bool Ne7sshSftp::rmdir (const char *  remoteDir  ) 
-
-
- -

-This method is used to remove a remote directory.

Parameters:
- - -
remoteDir Full or relative path to a directory to be removed.
-
-
Returns:
True if the directory successfully removed. False on any error.
- -

References ne7ssh::errors(), getFullPath(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), ne7ssh_string::length(), Ne7sshError::push(), receiveWhile(), and ne7ssh_string::value().

- -

Referenced by Ne7SftpSubsystem::rmdir().

- -
-

- -

-
- - - - - - - - - -
void Ne7sshSftp::setTimeout (uint32  _timeout  )  [inline]
-
-
- -

-This method is used to set a timeout for all SFTP subsystem communications.

Parameters:
- - -
_timeout Timeout in seconds.
-
- -

Referenced by Ne7SftpSubsystem::setTimeout().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Ne7sshSftp::writeFile (uint32  fileID,
const uint8 *  data,
uint32  len,
uint64  offset = 0 
)
-
-
- -

-Low level method used to write data-block up to the size of SFTP_MAX_MSG_SIZE to a remote file.

Parameters:
- - - - - -
fileID File ID returned by openFile() method.
data Pointer to a buffer containing the data.
len Length of the block.
offset Offset in the remote file. If offset is passed EOF the space between EOF and offset will be filled by 0x0. Variable is set to 0 by default.
-
-
Returns:
True if file contect successfully written. False on any error.
- -

References ne7ssh::errors(), getFileHandle(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), receiveUntil(), and receiveWindowAdjust().

- -

Referenced by put(), and Ne7SftpSubsystem::writeFile().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket-members.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket-members.html deleted file mode 100644 index d17712480ac..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket-members.html +++ /dev/null @@ -1,67 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshSftpPacket Member List

This is the complete list of members for Ne7sshSftpPacket, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
addBigInt(const Botan::BigInt &bn)ne7ssh_string
addBytes(const Botan::byte *buff, uint32 len)ne7ssh_string
addChar(const char ch)ne7ssh_string
addFile(const char *filename)ne7ssh_string
addInt(const uint32 var)ne7ssh_string
addInt64(const uint64 var)Ne7sshSftpPacket
addString(const char *str)ne7ssh_string
addVector(Botan::SecureVector< Botan::byte > &secvec)ne7ssh_string
addVectorField(const Botan::SecureVector< Botan::byte > &vector)ne7ssh_string
bn2vector(Botan::SecureVector< Botan::byte > &result, const Botan::BigInt &bi)ne7ssh_string [static]
buffer (defined in ne7ssh_string)ne7ssh_string [protected]
channel (defined in Ne7sshSftpPacket)Ne7sshSftpPacket [private]
chop(uint32 nBytes)ne7ssh_string
clear()ne7ssh_string [inline]
getBigInt(Botan::BigInt &result)ne7ssh_string
getByte()ne7ssh_string
getInt()ne7ssh_string
getInt64()Ne7sshSftpPacket
getString(Botan::SecureVector< Botan::byte > &result)ne7ssh_string
isChannelSet()Ne7sshSftpPacket
length()ne7ssh_string [inline]
ne7ssh_string()ne7ssh_string
ne7ssh_string(Botan::SecureVector< Botan::byte > &var, uint32 position)ne7ssh_string
ne7ssh_string(const char *var, uint32 position)ne7ssh_string
Ne7sshSftpPacket()Ne7sshSftpPacket
Ne7sshSftpPacket(int channel)Ne7sshSftpPacket
Ne7sshSftpPacket(Botan::SecureVector< Botan::byte > &var, uint32 position)Ne7sshSftpPacket
nextPart()ne7ssh_string
resetParts()ne7ssh_string [inline]
split(const char token)ne7ssh_string
value()Ne7sshSftpPacket [virtual]
valueFragment(uint32 len=0)Ne7sshSftpPacket
~ne7ssh_string()ne7ssh_string [virtual]
~Ne7sshSftpPacket()Ne7sshSftpPacket

-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket.html b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket.html deleted file mode 100644 index 6d3f0e2e6a9..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket.html +++ /dev/null @@ -1,302 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshSftpPacket Class Reference - - - - - -
-

Ne7sshSftpPacket Class Reference

#include <ne7ssh_sftp_packet.h> -

-

-Inheritance diagram for Ne7sshSftpPacket:
-
-

Inheritance graph
- - -
[legend]
-
-Collaboration diagram for Ne7sshSftpPacket:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 Ne7sshSftpPacket ()
 Ne7sshSftpPacket (int channel)
 Ne7sshSftpPacket (Botan::SecureVector< Botan::byte > &var, uint32 position)
 ~Ne7sshSftpPacket ()
Botan::SecureVector
-< Botan::byte > & 
value ()
Botan::SecureVector< Botan::byte > valueFragment (uint32 len=0)
void addInt64 (const uint64 var)
uint64 getInt64 ()
bool isChannelSet ()

Private Attributes

-int channel
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
Ne7sshSftpPacket::Ne7sshSftpPacket (  ) 
-
-
- -

-Default constructor. -

-

- -

-
- - - - - - - - - -
Ne7sshSftpPacket::Ne7sshSftpPacket (int  channel  ) 
-
-
- -

-Constructor.

Parameters:
- - -
channel Channel ID, returned by connect methods.
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
Ne7sshSftpPacket::Ne7sshSftpPacket (Botan::SecureVector< Botan::byte > &  var,
uint32  position 
)
-
-
- -

-Constructor. Intializes the class with packet data.

Parameters:
- - - -
var Reference to packet data.
position Offset.
-
- -
-

- -

-
- - - - - - - - -
Ne7sshSftpPacket::~Ne7sshSftpPacket (  ) 
-
-
- -

-Default destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
void Ne7sshSftpPacket::addInt64 (const uint64  var  ) 
-
-
- -

-Appends 64 bit integer to the packet buffer.

Parameters:
- - -
var 64 bit integer.
-
- -

References ne7ssh_string::addBytes().

- -
-

- -

-
- - - - - - - - -
uint64 Ne7sshSftpPacket::getInt64 (  ) 
-
-
- -

-Retrieves a 64 bit integer from a packet buffer.

Returns:
Unsigned 64 bit integer.
- -

Referenced by Ne7sshSftp::handleNames(), and Ne7sshSftp::processAttrs().

- -
-

- -

-
- - - - - - - - -
bool Ne7sshSftpPacket::isChannelSet (  ) 
-
-
- -

-Checks if the channel ID is set in the instance. Channel ID is needed to construct a SFTP packet.

Returns:
True if the channel ID is set. Otherwise false.
- -
-

- -

-
- - - - - - - - -
Botan::SecureVector< Botan::byte > & Ne7sshSftpPacket::value (  )  [virtual]
-
-
- -

-Returns buffer as a vector appending the SFTP subsystem specific packet headers.

Returns:
Reference to the buffer.
- -

Reimplemented from ne7ssh_string.

- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addVectorField(), and ne7ssh_string::value().

- -
-

- -

-
- - - - - - - - - -
Botan::SecureVector< Botan::byte > Ne7sshSftpPacket::valueFragment (uint32  len = 0  ) 
-
-
- -

-Returns buffer as a vector appending the SFTP subsystem specific packet headers, including the length in the first packet transmitted. Used in transmissions when it's necessary to split the message into multiple packets.

Parameters:
- - -
len Length to append to the first packet in the message.
-
-
Returns:
Reference to SFTP packet or empty vector on error.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), and ne7ssh_string::value().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.map deleted file mode 100644 index bd23dfcbe72..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.md5 deleted file mode 100644 index c5be6ab9d57..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -c1347fb4ae29dfc3c6f77685b09bf3ae \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.map deleted file mode 100644 index bd23dfcbe72..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.md5 deleted file mode 100644 index c5be6ab9d57..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftpPacket__inherit__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -c1347fb4ae29dfc3c6f77685b09bf3ae \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.map deleted file mode 100644 index f6c6d47b42b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.map +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.md5 deleted file mode 100644 index 0daef81959c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -a33cd3840dcce8913b78a463d6b5024b \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.map deleted file mode 100644 index 0988ea6f45c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.md5 deleted file mode 100644 index 68a0a1079f7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classNe7sshSftp__inherit__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -ead7f3358bb2dde804b9829bd96bab56 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classes.html b/src/libs/3rdparty/net7ssh/doc/html/classes.html deleted file mode 100644 index 94fc911372f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classes.html +++ /dev/null @@ -1,40 +0,0 @@ - - -ne7ssh.kdevelop: Alphabetical List - - - - - -
-

Class Index

C | E | F | N | S

- -
  C  
-
Ne7SftpSubsystem::fileAttrs   ne7ssh_connection   ne7ssh_string   Ne7sshSftpPacket   
connStruct   
  N  
-
ne7ssh_crypt   ne7ssh_transport   
  S  
-
  E  
-
Ne7SftpSubsystem   ne7ssh_kex   Ne7sshError   Ne7sshSftp::sftpFile   
Ne7sshError::Error   ne7ssh   ne7ssh_keys   Ne7sshSftp   Ne7sshSftp::sftpFileAttrs   
  F  
-
ne7ssh_channel   ne7ssh_session   

C | E | F | N | S

-

-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh-members.html deleted file mode 100644 index b3de987c6f5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh-members.html +++ /dev/null @@ -1,74 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh Member List

This is the complete list of members for ne7ssh, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
allConns (defined in ne7ssh)ne7ssh [private]
CIPHER_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
close(int channel)ne7ssh
COMPRESSION_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
conCount (defined in ne7ssh)ne7ssh [private]
connected (defined in ne7ssh)ne7ssh [private]
connections (defined in ne7ssh)ne7ssh [private]
connectWithKey(const char *host, const int port, const char *username, const char *privKeyFileName, bool shell=true, const int timeout=0)ne7ssh
connectWithPassword(const char *host, const int port, const char *username, const char *password, bool shell=true, const int timeout=0)ne7ssh
errors()ne7ssh [static]
errs (defined in ne7ssh)ne7ssh [private, static]
generateKeyPair(const char *type, const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=0)ne7ssh
getChannelNo()ne7ssh [private]
getConnetions()ne7ssh [inline]
getReceivedSize(int channel, bool do_lock=true)ne7ssh
HOSTKEY_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
init (defined in ne7ssh)ne7ssh [private]
initSftp(Ne7SftpSubsystem &_sftp, int channel)ne7ssh
isSelectActive() (defined in ne7ssh)ne7ssh [inline, static]
KEX_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
lock()ne7ssh [private, static]
MAC_ALGORITHMS (defined in ne7ssh)ne7ssh [static]
mut (defined in ne7ssh)ne7ssh [private, static]
ne7ssh()ne7ssh
PREFERED_CIPHER (defined in ne7ssh)ne7ssh [static]
PREFERED_MAC (defined in ne7ssh)ne7ssh [static]
read(int channel, bool do_lock=true)ne7ssh
readBinary(int channel)ne7ssh
running (defined in ne7ssh)ne7ssh [private, static]
select_thread (defined in ne7ssh)ne7ssh [private]
selectActive (defined in ne7ssh)ne7ssh [private, static]
selectDead() (defined in ne7ssh)ne7ssh [inline, static]
selectThread(void *)ne7ssh [private, static]
send(const char *data, int channel)ne7ssh
sendCmd(const char *cmd, int channel, int timeout)ne7ssh
setCount(uint32 count)ne7ssh [inline]
setOptions(const char *prefCipher, const char *prefHmac)ne7ssh
SSH_VERSION (defined in ne7ssh)ne7ssh [static]
unlock()ne7ssh [private, static]
waitFor(int channel, const char *str, uint32 timeout=0)ne7ssh
~ne7ssh()ne7ssh

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh.html deleted file mode 100644 index d4b28937445..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh.html +++ /dev/null @@ -1,906 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh Class Reference - - - - - -
-

ne7ssh Class Reference

#include <ne7ssh.h> -

-

-Collaboration diagram for ne7ssh:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh ()
 ~ne7ssh ()
int connectWithPassword (const char *host, const int port, const char *username, const char *password, bool shell=true, const int timeout=0)
int connectWithKey (const char *host, const int port, const char *username, const char *privKeyFileName, bool shell=true, const int timeout=0)
connStructgetConnetions ()
bool send (const char *data, int channel)
bool sendCmd (const char *cmd, int channel, int timeout)
bool close (int channel)
void setCount (uint32 count)
const char * read (int channel, bool do_lock=true)
void * readBinary (int channel)
int getReceivedSize (int channel, bool do_lock=true)
bool waitFor (int channel, const char *str, uint32 timeout=0)
void setOptions (const char *prefCipher, const char *prefHmac)
bool generateKeyPair (const char *type, const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=0)
bool initSftp (Ne7SftpSubsystem &_sftp, int channel)

Static Public Member Functions

static Ne7sshErrorerrors ()
-static bool isSelectActive ()
-static void selectDead ()

Static Public Attributes

-static const char * SSH_VERSION = "SSH-2.0-NetSieben_1.3.1"
-static const char * KEX_ALGORITHMS = "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1"
-static const char * HOSTKEY_ALGORITHMS = "ssh-dss,ssh-rsa"
-static const char * MAC_ALGORITHMS = "hmac-md5,hmac-sha1,none"
-static const char * CIPHER_ALGORITHMS = "aes256-cbc,aes192-cbc,twofish-cbc,twofish256-cbc,blowfish-cbc,3des-cbc,aes128-cbc,cast128-cbc"
-static const char * COMPRESSION_ALGORITHMS = "none"
-static char * PREFERED_CIPHER = 0
-static char * PREFERED_MAC = 0

Private Member Functions

uint32 getChannelNo ()

Static Private Member Functions

static void * selectThread (void *)
static bool lock ()
static bool unlock ()

Private Attributes

-Botan::LibraryInitializer * init
-ne7ssh_connection ** connections
-uint32 conCount
-connStruct allConns
-ne7ssh_thread_t select_thread
-bool connected

Static Private Attributes

-static Ne7ssh_Mutex mut
-static bool running = false
-static bool selectActive = true
-static Ne7sshErrorerrs = NULL
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh::ne7ssh (  ) 
-
-
- -

-Default constructor. Used to allocate required memory, as well as initializing cryptographic routines. -

References connStruct::conns, connStruct::count, Ne7sshError::push(), and selectThread().

- -
-

- -

-
- - - - - - - - -
ne7ssh::~ne7ssh (  ) 
-
-
- -

-Destructor. -

References close(), lock(), and unlock().

- -
-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool ne7ssh::close (int  channel  ) 
-
-
- -

-Closes specified channel.

Parameters:
- - -
channel Channel to close.
-
-
Returns:
Returns true if closing was successful, otherwise false is returned.
- -

References Ne7sshError::deleteChannel(), getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::sendClose(), and unlock().

- -

Referenced by ~ne7ssh().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ne7ssh::connectWithKey (const char *  host,
const int  port,
const char *  username,
const char *  privKeyFileName,
bool  shell = true,
const int  timeout = 0 
)
-
-
- -

-Connect to remote host using SSH2 protocol, with publickey authentication.

-Reads private key from a file specified, and uses it to authenticate to remote host. Remote side must have public key from the key pair for authentication to succeed.

Parameters:
- - - - - - - -
host Hostname or IP to connect to.
port Port to connect to.
username Username to use in authentication.
privKeyFileName Full path to file containing private key used in authentication.
shell Set this to true if you wish to launch the shell on the remote end. By default set to true.
timeout Timeout for the connection procedure, in seconds.
-
-
Returns:
Returns newly assigned channel ID, or -1 if connection failed.
- -

References ne7ssh_connection::connectWithKey(), connStruct::conns, connStruct::count, errors(), getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::setChannelNo(), and unlock().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ne7ssh::connectWithPassword (const char *  host,
const int  port,
const char *  username,
const char *  password,
bool  shell = true,
const int  timeout = 0 
)
-
-
- -

-Connect to remote host using SSH2 protocol, with password authentication.

Parameters:
- - - - - - - -
host Hostname or IP to connect to.
port Port to connect to.
username Username to use in authentication.
password Password to use in authentication.
shell Set this to true if you wish to launch the shell on the remote end. By default set to true.
timeout Timeout for the connection procedure, in seconds.
-
-
Returns:
Returns newly assigned channel ID, or -1 if connection failed.
- -

References ne7ssh_connection::connectWithPassword(), connStruct::conns, connStruct::count, errors(), getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::setChannelNo(), and unlock().

- -
-

- -

-
- - - - - - - - -
SSH_EXPORT Ne7sshError * ne7ssh::errors (  )  [static]
-
-
- -

-This method returns a pointer to the current Error collection.

Returns:
the Error collection
- -

Referenced by ne7ssh_string::addFile(), ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), Ne7sshSftp::cd(), ne7ssh_connection::checkRemoteVersion(), Ne7sshSftp::chmod(), Ne7sshSftp::chown(), Ne7sshSftp::closeFile(), ne7ssh_crypt::compute_key(), ne7ssh_crypt::computeH(), connectWithKey(), connectWithPassword(), Ne7SftpSubsystem::errorNotInited(), ne7ssh_transport::establish(), ne7ssh_channel::execCmd(), ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::generateRSASignature(), Ne7sshSftp::get(), ne7ssh_crypt::getCryptAlgo(), ne7ssh_keys::getDSAKeys(), Ne7sshSftp::getFileAttrs(), Ne7sshSftp::getFileHandle(), Ne7sshSftp::getFileSize(), Ne7sshSftp::getFileStats(), Ne7sshSftp::getFStat(), ne7ssh_crypt::getHashAlgo(), ne7ssh_crypt::getHmacAlgo(), ne7ssh_crypt::getKexPublic(), ne7ssh_keys::getKeyPairFromFile(), ne7ssh_crypt::getMacKeyLen(), ne7ssh_keys::getRSAKeys(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), ne7ssh_channel::handleDisconnect(), ne7ssh_channel::handleEof(), ne7ssh_channel::handleExtendedData(), ne7ssh_kex::handleInit(), ne7ssh_channel::handleReceived(), ne7ssh_channel::handleRequest(), Ne7sshSftp::handleSftpData(), Ne7sshSftp::handleStatus(), Ne7sshSftp::handleVersion(), Ne7sshSftp::isType(), Ne7sshError::lock(), Ne7sshSftp::ls(), Ne7sshSftp::mkdir(), Ne7sshSftp::mv(), ne7ssh_crypt::negotiatedCmprsC2s(), ne7ssh_crypt::negotiatedCmprsS2c(), ne7ssh_crypt::negotiatedCryptoC2s(), ne7ssh_crypt::negotiatedCryptoS2c(), ne7ssh_crypt::negotiatedHostkey(), ne7ssh_crypt::negotiatedKex(), ne7ssh_crypt::negotiatedMacC2s(), ne7ssh_crypt::negotiatedMacS2c(), ne7ssh_transport::NoBlock(), ne7ssh_channel::open(), Ne7sshSftp::openDir(), Ne7sshSftp::openFile(), Ne7sshSftp::put(), Ne7sshSftp::readFile(), ne7ssh_transport::receive(), Ne7sshSftp::receiveWindowAdjust(), ne7ssh_connection::requestService(), Ne7sshSftp::rm(), Ne7sshSftp::rmdir(), ne7ssh_transport::send(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), ne7ssh_transport::sendPacket(), ne7ssh_connection::startSftp(), Ne7sshError::unlock(), ne7ssh_crypt::verifySig(), ne7ssh_transport::waitForPacket(), and Ne7sshSftp::writeFile().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh::generateKeyPair (const char *  type,
const char *  fqdn,
const char *  privKeyFileName,
const char *  pubKeyFileName,
uint16  keySize = 0 
)
-
-
- -

-Generate key pair.

Parameters:
- - - - - - -
type String specifying key type. Currently "dsa" and "rsa" are supported.
fqdn User id. Usually an Email. For example "test@netsieben.com"
privKeyFileName Full path to a file where generated private key should be written.
pubKeyFileName Full path to a file where generated public key should be written.
keySize Desired key size in bits. If not specified will default to 2048.
-
-
Returns:
Return true if keys generated and written to the files. Otherwise false is returned.
- -

References ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateRSAKeys(), and Ne7sshError::push().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh::getChannelNo (  )  [private]
-
-
- -

-Returns the number of active channel.

Returns:
Active channel.
- -

References Ne7sshError::push().

- -

Referenced by close(), connectWithKey(), connectWithPassword(), getReceivedSize(), initSftp(), read(), readBinary(), send(), and sendCmd().

- -
-

- -

-
- - - - - - - - -
connStruct* ne7ssh::getConnetions (  )  [inline]
-
-
- -

-Retrieves a pointer to all current connections.

-For internal use only.

Returns:
Returns pointer to pointers to ne7ssh_connection class, or 0 if no connection exist.
- -

Referenced by selectThread().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
int ne7ssh::getReceivedSize (int  channel,
bool  do_lock = true 
)
-
-
- -

-Returns the size of all data read. Used to read buffer passed 0x0.

Parameters:
- - -
channel Channel number which buffer size to check.
-
-
Returns:
Return size of the buffer, or 0x0 if receive buffer empty.
- -

References getChannelNo(), ne7ssh_connection::getReceived(), lock(), and unlock().

- -

Referenced by waitFor().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh::initSftp (Ne7SftpSubsystem _sftp,
int  channel 
)
-
-
- -

-This method is used to initialize a new SFTP subsystem.

Parameters:
- - - -
_sftp Reference to SFTP subsystem to be initialized.
channel Channel ID returned by one of the connect methods.
-
-
Returns:
True if the new subsystem successfully initialized. False on any error.
- -

References getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::startSftp(), and unlock().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh::lock (  )  [static, private]
-
-
- -

-Lock the mutex.

Returns:
True if lock aquired. Oterwise false.
- -

References Ne7sshError::push().

- -

Referenced by close(), connectWithKey(), connectWithPassword(), getReceivedSize(), initSftp(), read(), readBinary(), selectThread(), send(), sendCmd(), waitFor(), and ~ne7ssh().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
const char * ne7ssh::read (int  channel,
bool  do_lock = true 
)
-
-
- -

-Reads all data from receiving buffer on specified channel.

Parameters:
- - -
channel Channel to read data on.
-
-
Returns:
Returns string read from receiver buffer or 0 if buffer is empty.
- -

References getChannelNo(), ne7ssh_connection::getReceived(), lock(), Ne7sshError::push(), and unlock().

- -

Referenced by waitFor().

- -
-

- -

-
- - - - - - - - - -
void * ne7ssh::readBinary (int  channel  ) 
-
-
- -

-Reads all data from receiving buffer on specified channel. Returns pointer to void. Together with getReceivedSize and sendCmd can be used to read remote files.

Parameters:
- - -
channel Channel to read data on.
-
-
Returns:
Returns pointer to the start of binary data or 0 if nothing received.
- -

References getChannelNo(), ne7ssh_connection::getReceived(), lock(), Ne7sshError::push(), and unlock().

- -
-

- -

-
- - - - - - - - - -
void * ne7ssh::selectThread (void *  initData  )  [static, private]
-
-
- -

-Send / Receive thread.

-For Internal use only

Returns:
Usually 0 when thread terminates
- -

References connStruct::conns, getConnetions(), ne7ssh_connection::handleData(), lock(), Ne7sshError::push(), ne7ssh_connection::sendData(), setCount(), and unlock().

- -

Referenced by ne7ssh().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh::send (const char *  data,
int  channel 
)
-
-
- -

-Retreives count of current connections

-For internal use only.

Returns:
Returns current count of connections. Sends a command string on specified channel, provided the specified channel has been previously opened through connectWithPassword() function.
-
Parameters:
- - - -
data Pointer to the command string to send to a channel.
channel Channel to send data on.
-
-
Returns:
Returns true if the send was successful, otherwise false returned.
- -

References getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::sendData(), and unlock().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh::sendCmd (const char *  cmd,
int  channel,
int  timeout 
)
-
-
- -

-Can be used to send a single command and disconnect, similiar behavior to openssh when one appends a command to the end of ssh command.

Parameters:
- - - - -
cmd Remote command to execute. Can be used to read files on unix with 'cat [filename]'.
channel Channel to send the command.
timeout How long to wait before giving up.
-
-
Returns:
Returns true if the send was successful, otherwise false returned.
- -

References getChannelNo(), lock(), Ne7sshError::push(), ne7ssh_connection::sendCmd(), and unlock().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh::setCount (uint32  count  )  [inline]
-
-
- -

-Sets connection count.

-For internal use only.

Parameters:
- - -
count Integer to set connection count.
-
- -

Referenced by selectThread().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void ne7ssh::setOptions (const char *  prefCipher,
const char *  prefHmac 
)
-
-
- -

-Sets prefered cipher and hmac algorithms.

-This function as to be executed before connection functions, just after initialization of ne7ssh class.

Parameters:
- - - -
prefCipher prefered cipher algorithm string representation. Possible cipher algorithms are aes256-cbc, twofish-cbc, twofish256-cbc, blowfish-cbc, 3des-cbc, aes128-cbc, cast128-cbc.
prefHmac preferede hmac algorithm string representation. Possible hmac algorithms are hmac-md5, hmac-sha1, none.
-
- -
-

- -

-
- - - - - - - - -
bool ne7ssh::unlock (  )  [static, private]
-
-
- -

-Unlock the mutext.

Returns:
True if the mutext successfully unlocked. Otherwise false.
- -

References Ne7sshError::push().

- -

Referenced by close(), connectWithKey(), connectWithPassword(), getReceivedSize(), initSftp(), read(), readBinary(), selectThread(), send(), sendCmd(), waitFor(), and ~ne7ssh().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh::waitFor (int  channel,
const char *  str,
uint32  timeout = 0 
)
-
-
- -

-Wait until receiving buffer contains a string passed in str, or until the function timeouts as specified in timeout.

Parameters:
- - - - -
channel Channel to wait on.
str String to wait for.
timeout Timeout in seconds.
-
-
Returns:
Returns true if string specified in str variable has been received, otherwise false returned.
- -

References getReceivedSize(), lock(), Ne7sshError::push(), read(), and unlock().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel-members.html deleted file mode 100644 index e6ea00c3865..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel-members.html +++ /dev/null @@ -1,72 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_channel Member List

This is the complete list of members for ne7ssh_channel, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
adjustRecvWindow(int bufferSize)ne7ssh_channel
adjustWindow(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
channelOpened (defined in ne7ssh_channel)ne7ssh_channel [protected]
closed (defined in ne7ssh_channel)ne7ssh_channel [private]
cmdComplete (defined in ne7ssh_channel)ne7ssh_channel [private]
data2Send()ne7ssh_channel [inline]
delayedBuffer (defined in ne7ssh_channel)ne7ssh_channel [private]
eof (defined in ne7ssh_channel)ne7ssh_channel [private]
execCmd(const char *cmd)ne7ssh_channel
getCmdComplete()ne7ssh_channel [inline]
getReceived()ne7ssh_channel [inline]
getRecvWindow()ne7ssh_channel [inline]
getSendWindow()ne7ssh_channel [inline]
getShell()ne7ssh_channel
handleChannelConfirm()ne7ssh_channel [private]
handleClose(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
handleData(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private, virtual]
handleDisconnect(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
handleEof(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
handleExtendedData(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
handleReceived(Botan::SecureVector< Botan::byte > &_packet)ne7ssh_channel
handleRequest(Botan::SecureVector< Botan::byte > &packet)ne7ssh_channel [private]
inBuffer (defined in ne7ssh_channel)ne7ssh_channel [private]
isOpen()ne7ssh_channel [inline]
isRemoteShell()ne7ssh_channel [inline]
ne7ssh_channel(ne7ssh_session *_session)ne7ssh_channel
open(uint32 channelID)ne7ssh_channel
outBuffer (defined in ne7ssh_channel)ne7ssh_channel [private]
receive()ne7ssh_channel
sendAdjustWindow()ne7ssh_channel [protected]
sendAll()ne7ssh_channel
sendClose()ne7ssh_channel
sendEof()ne7ssh_channel
session (defined in ne7ssh_channel)ne7ssh_channel [private]
shellSpawned (defined in ne7ssh_channel)ne7ssh_channel [private]
windowRecv (defined in ne7ssh_channel)ne7ssh_channel [protected]
windowSend (defined in ne7ssh_channel)ne7ssh_channel [protected]
write(Botan::SecureVector< Botan::byte > &data)ne7ssh_channel
~ne7ssh_channel()ne7ssh_channel [virtual]

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel.html deleted file mode 100644 index e96742383ca..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel.html +++ /dev/null @@ -1,882 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_channel Class Reference - - - - - -
-

ne7ssh_channel Class Reference

#include <ne7ssh_channel.h> -

-

-Inheritance diagram for ne7ssh_channel:
-
-

Inheritance graph
- - -
[legend]
-
-Collaboration diagram for ne7ssh_channel:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_channel (ne7ssh_session *_session)
virtual ~ne7ssh_channel ()
uint32 open (uint32 channelID)
void getShell ()
bool execCmd (const char *cmd)
void receive ()
bool handleReceived (Botan::SecureVector< Botan::byte > &_packet)
void write (Botan::SecureVector< Botan::byte > &data)
void sendAll ()
bool data2Send ()
bool isOpen ()
bool sendClose ()
bool sendEof ()
Botan::SecureVector
-< Botan::byte > & 
getReceived ()
bool getCmdComplete ()
bool isRemoteShell ()
bool adjustRecvWindow (int bufferSize)
uint32 getRecvWindow ()
uint32 getSendWindow ()

Protected Member Functions

void sendAdjustWindow ()

Protected Attributes

-uint32 windowRecv
-uint32 windowSend
-bool channelOpened

Private Member Functions

bool handleChannelConfirm ()
bool adjustWindow (Botan::SecureVector< Botan::byte > &packet)
virtual bool handleData (Botan::SecureVector< Botan::byte > &packet)
bool handleExtendedData (Botan::SecureVector< Botan::byte > &packet)
bool handleEof (Botan::SecureVector< Botan::byte > &packet)
void handleClose (Botan::SecureVector< Botan::byte > &packet)
void handleRequest (Botan::SecureVector< Botan::byte > &packet)
bool handleDisconnect (Botan::SecureVector< Botan::byte > &packet)

Private Attributes

-bool eof
-bool closed
-bool cmdComplete
-bool shellSpawned
-ne7ssh_sessionsession
-ne7ssh_string inBuffer
-ne7ssh_string outBuffer
-ne7ssh_string delayedBuffer
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
ne7ssh_channel::ne7ssh_channel (ne7ssh_session _session  ) 
-
-
- -

-ne7ssh_channel class consturctor.

Parameters:
- - -
_session Pointer to ne7ssh_session.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_channel::~ne7ssh_channel (  )  [virtual]
-
-
- -

-ne7ssh_channel class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
bool ne7ssh_channel::adjustRecvWindow (int  bufferSize  ) 
-
-
- -

-Checks if receive window needs adjusting, if so send a window adjust request.

Parameters:
- - -
bufferSize Current buffer size.
-
-
Returns:
False on any error, otherwise true.
- -

References sendAdjustWindow().

- -

Referenced by Ne7sshSftp::handleData().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::adjustWindow (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'WINDOWS_ADJUST' packet.

-It's used to increase our sending window size.

Parameters:
- - -
packet Reference to vector containing WINDOW_ADJUST packet.
-
-
Returns:
If parsing of payload is successful, returns true, otherwise false is returned.
- -

References ne7ssh_string::getInt().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::data2Send (  )  [inline]
-
-
- -

-Checks if there is any data waiting to be sent. Most often called from selectThread via ne7ssh_connection class.

Returns:
True if there is data to send, otherwise false is returned.
- -

References ne7ssh_string::length().

- -

Referenced by ne7ssh_connection::data2Send().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::execCmd (const char *  cmd  ) 
-
-
- -

-Executes a single command on the remote end and terminates the connection.

Parameters:
- - -
cmd Remote command to execute.
-
-
Returns:
True if command if sening of a command succeded. False returned on failure.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_session::getSendChannel(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::sendCmd().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::getCmdComplete (  )  [inline]
-
-
- -

-When executing a single command with ne7ssh::sendCmd this command is used to determine when remote side finishes the execution.

Returns:
True if execution of the command is complete. Otherwise false.
- -

Referenced by ne7ssh_connection::getCmdComplete().

- -
-

- -

-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_channel::getReceived (  )  [inline]
-
-
- -

-Gets last received packet.

Returns:
Reference to a vector containing the last received packet.
- -

References ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::getReceived().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_channel::getRecvWindow (  )  [inline]
-
-
- -

-Gets the current size of the receive window.

Returns:
Size of the revceive window.
- -

Referenced by Ne7sshSftp::Ne7sshSftp().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_channel::getSendWindow (  )  [inline]
-
-
- -

-Gets the current size of the send window.

Returns:
Size of the send window.
- -

Referenced by Ne7sshSftp::Ne7sshSftp().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_channel::getShell (  ) 
-
-
- -

-Requests shell from remote side. Does not wait for or expect a reply. According to SSH specs that's an acceptable behavior. -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh_session::getSendChannel(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::handleChannelConfirm (  )  [private]
-
-
- -

-This function is used to handle the 'CHANNEL_OPEN_CONFIRMATION' packet.

-After parsing the payload, send channel ID is assigned, along with send windows size and maximum packer size.

Returns:
Always returns true.
- -

References ne7ssh_string::getInt(), ne7ssh_transport::getPacket(), ne7ssh_session::setMaxPacket(), and ne7ssh_session::setSendChannel().

- -

Referenced by open().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_channel::handleClose (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'CLOSE' packet.

-If the close action wasn't initiated on this end, we also send a 'CLOSE' packet to the remote side, prompting the closing of remote side's receiving channel.

Parameters:
- - -
packet Reference to vector containing the 'CLOSE' packet.
-
- -

References sendClose().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleData (Botan::SecureVector< Botan::byte > &  packet  )  [private, virtual]
-
-
- -

-This function is used to handle the 'DATA' packet.

-It's used to parse the payload, and add received data to the buffer.

Parameters:
- - -
packet Reference to vector containing 'DATA' packet.
-
-
Returns:
If parsing of payload is successful, returns true, otherwise false is returned.
- -

Reimplemented in Ne7sshSftp.

- -

References ne7ssh_string::addChar(), ne7ssh_string::addVector(), ne7ssh_string::chop(), ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), ne7ssh_string::length(), Ne7sshError::push(), and sendAdjustWindow().

- -

Referenced by handleExtendedData(), and handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleDisconnect (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'DISCONNECT' packet.

-In normal operation we should not get this packet. Only if some serious error occurs, and makes remote side drop the connection, will this packet be received. And at that point we disconnect right away, and throw an error.

Parameters:
- - -
packet Reference to vector containing the 'DISCONNECT' packet.
-
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleEof (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'EOF' packet.

-It's used to close the receiving window and channel.

Parameters:
- - -
packet Reference to vector containing EOF packet.
-
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and sendClose().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleExtendedData (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle 'EXTENDED_DATA' packet. This packet is mostly used to transmit remote side errors.

Parameters:
- - -
packet Reference to vector containing 'EXTENDED_DATA' packet.
-
-
Returns:
If parsing of payload is successful, returns true, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), handleData(), Ne7sshError::push(), and sendAdjustWindow().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_channel::handleReceived (Botan::SecureVector< Botan::byte > &  _packet  ) 
-
-
- -

-Handle a packet received from remote side.

Parameters:
- - -
_packet Reference to a newly received packet.
-
-
Returns:
True if the packet successfully processed. False on any error.
- -

References ne7ssh_string::addVector(), adjustWindow(), ne7ssh::errors(), ne7ssh_string::getByte(), ne7ssh_session::getSshChannel(), handleClose(), handleData(), handleDisconnect(), handleEof(), handleExtendedData(), handleRequest(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by receive(), Ne7sshSftp::receiveUntil(), Ne7sshSftp::receiveWhile(), and Ne7sshSftp::receiveWindowAdjust().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_channel::handleRequest (Botan::SecureVector< Botan::byte > &  packet  )  [private]
-
-
- -

-This function is used to handle the 'REQUEST' packet.

-At this point only two requests are supported, namely "exit-signal" and "exit-status". For the most part we ignore this packet, which is safe to do according to SSH specs.

Parameters:
- - -
packet Reference to vector containing the 'REQUEST' packet.
-
- -

References ne7ssh::errors(), ne7ssh_string::getByte(), ne7ssh_string::getInt(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by handleReceived().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::isOpen (  )  [inline]
-
-
- -

-Checks if current channel is in an open state.

Returns:
True if channel is open, otherwise false is returned.
- -

Referenced by ne7ssh_connection::isOpen(), and ne7ssh_connection::sendClose().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::isRemoteShell (  )  [inline]
-
-
- -

-Determines if the shell has been spawned on the remote side.

Returns:
True if the shell has been spawned. Otherwise false.
- -

Referenced by ne7ssh_connection::isRemoteShell(), and ne7ssh_connection::startSftp().

- -
-

- -

-
- - - - - - - - - -
uint32 ne7ssh_channel::open (uint32  channelID  ) 
-
-
- -

-Requests 'CHANNEL_OPEN' from the remote side.

Parameters:
- - -
channelID New receiving channel ID.
-
-
Returns:
Returns new channel ID, or 0 if open fails.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_string::addString(), ne7ssh::errors(), handleChannelConfirm(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_channel::receive (  ) 
-
-
- -

-Receives new packet from remote side. This function is mostly used from selectThread. -

References ne7ssh_transport::getPacket(), handleReceived(), and ne7ssh_transport::waitForPacket().

- -

Referenced by ne7ssh_connection::handleData().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_channel::sendAdjustWindow (  )  [protected]
-
-
- -

-Request adjustment of the send window size on the remote end, so we can receive more data. -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_session::getMaxPacket(), ne7ssh_session::getSendChannel(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by adjustRecvWindow(), handleData(), and handleExtendedData().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_channel::sendAll (  ) 
-
- -

- -

-
- - - - - - - - -
bool ne7ssh_channel::sendClose (  ) 
-
-
- -

-When closing a channel, initiates the closing procedure.

Returns:
False if sending fails. Otherwise true is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_session::getSendChannel(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -

Referenced by handleClose(), handleEof(), and ne7ssh_connection::sendClose().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_channel::sendEof (  ) 
-
-
- -

-Send EOF to the remote side.

Returns:
True if sending succeeds, otherwise false.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addInt(), ne7ssh_session::getSendChannel(), ne7ssh_transport::sendPacket(), and ne7ssh_string::value().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_channel::write (Botan::SecureVector< Botan::byte > &  data  ) 
-
-
- -

-Pushes a new command to the buffer where the selectThread will catch and send it.

Parameters:
- - -
data Reference to vector containing a command to be added to the buffer.
-
- -

References ne7ssh_string::addVector(), ne7ssh_string::clear(), ne7ssh_session::getMaxPacket(), ne7ssh_string::length(), and ne7ssh_string::value().

- -

Referenced by sendAll(), and ne7ssh_connection::sendData().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.map deleted file mode 100644 index 02c4c4d8a55..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.map +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.md5 deleted file mode 100644 index d5ff61a0e44..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -ec1101fe9893f883eb4ebdb2f49a2dc0 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.map deleted file mode 100644 index 063936f72f4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.md5 deleted file mode 100644 index 1feddb9d560..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__channel__inherit__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -386e64f96857962ac64bfcfcd2ee191e \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.map deleted file mode 100644 index 98f2305886d..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.map +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.md5 deleted file mode 100644 index 27dbb60a0a5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -93c2b10c3b049ce2f2c5694a6507d90e \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection-members.html deleted file mode 100644 index 42ca0ddd8e3..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection-members.html +++ /dev/null @@ -1,71 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_connection Member List

This is the complete list of members for ne7ssh_connection, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
authWithKey(const char *username, const char *privKeyFileName)ne7ssh_connection [private]
authWithPassword(const char *username, const char *password)ne7ssh_connection [private]
channel (defined in ne7ssh_connection)ne7ssh_connection [private]
checkRemoteVersion()ne7ssh_connection [private]
cmdClosed (defined in ne7ssh_connection)ne7ssh_connection [private]
cmdRunning (defined in ne7ssh_connection)ne7ssh_connection [private]
connected (defined in ne7ssh_connection)ne7ssh_connection [private]
connectWithKey(uint32 channelID, const char *host, uint32 port, const char *username, const char *privKeyFileName, bool shell=true, int timeout=0)ne7ssh_connection
connectWithPassword(uint32 channelID, const char *host, uint32 port, const char *username, const char *password, bool shell=true, int timeout=0)ne7ssh_connection
crypto (defined in ne7ssh_connection)ne7ssh_connection [private]
data2Send()ne7ssh_connection [inline]
getChannelNo()ne7ssh_connection [inline]
getCmdComplete()ne7ssh_connection [inline]
getReceived()ne7ssh_connection [inline]
getSocket()ne7ssh_connection [inline]
handleData()ne7ssh_connection
isCmdClosed()ne7ssh_connection [inline]
isCmdRunning()ne7ssh_connection [inline]
isConnected()ne7ssh_connection [inline]
isOpen()ne7ssh_connection [inline]
isRemoteShell()ne7ssh_connection [inline]
isSftpActive()ne7ssh_connection
mut (defined in ne7ssh_connection)ne7ssh_connection [private]
ne7ssh_connection()ne7ssh_connection
requestService(const char *service)ne7ssh_connection [private]
sendClose()ne7ssh_connection
sendCmd(const char *cmd)ne7ssh_connection
sendData(const char *data)ne7ssh_connection
sendData()ne7ssh_connection [inline]
sendLocalVersion()ne7ssh_connection [private]
session (defined in ne7ssh_connection)ne7ssh_connection [private]
setChannelNo(int channelID)ne7ssh_connection [inline]
sftp (defined in ne7ssh_connection)ne7ssh_connection [private]
sock (defined in ne7ssh_connection)ne7ssh_connection [private]
startSftp()ne7ssh_connection
thisChannel (defined in ne7ssh_connection)ne7ssh_connection [private]
transport (defined in ne7ssh_connection)ne7ssh_connection [private]
~ne7ssh_connection()ne7ssh_connection

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection.html deleted file mode 100644 index 6f252c42d8b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection.html +++ /dev/null @@ -1,900 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_connection Class Reference - - - - - -
-

ne7ssh_connection Class Reference

#include <ne7ssh_connection.h> -

-

-Collaboration diagram for ne7ssh_connection:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_connection ()
 ~ne7ssh_connection ()
int connectWithPassword (uint32 channelID, const char *host, uint32 port, const char *username, const char *password, bool shell=true, int timeout=0)
int connectWithKey (uint32 channelID, const char *host, uint32 port, const char *username, const char *privKeyFileName, bool shell=true, int timeout=0)
SOCKET getSocket ()
void handleData ()
void sendData (const char *data)
void setChannelNo (int channelID)
int getChannelNo ()
bool data2Send ()
void sendData ()
bool sendCmd (const char *cmd)
bool sendClose ()
bool isOpen ()
bool isConnected ()
Botan::SecureVector
-< Botan::byte > & 
getReceived ()
bool getCmdComplete ()
bool isCmdClosed ()
bool isRemoteShell ()
bool isCmdRunning ()
Ne7sshSftpstartSftp ()
bool isSftpActive ()

Private Member Functions

bool checkRemoteVersion ()
bool sendLocalVersion ()
bool requestService (const char *service)
bool authWithPassword (const char *username, const char *password)
bool authWithKey (const char *username, const char *privKeyFileName)

Private Attributes

-SOCKET sock
-int thisChannel
-ne7ssh_cryptcrypto
-ne7ssh_transporttransport
-ne7ssh_sessionsession
-ne7ssh_channelchannel
-Ne7sshSftpsftp
-Ne7ssh_Mutex mut
-bool connected
-bool cmdRunning
-bool cmdClosed
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh_connection::ne7ssh_connection (  ) 
-
-
- -

-ne7ssh_connection class constructor. -

-

- -

-
- - - - - - - - -
ne7ssh_connection::~ne7ssh_connection (  ) 
-
-
- -

-ne7ssh_connection class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_connection::authWithKey (const char *  username,
const char *  privKeyFileName 
) [private]
-
-
- -

-Sends a test message to check if "publickey" authentication is allowed fo specified user. If succesfull proceeds wtih generating a signature and sending real authentication packet of "publickey" type.

Parameters:
- - - -
username Username used for authentication.
privKeyFileName Full path to file containing private key to be used in authentication.
-
-
Returns:
True if authentication was successful, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addString(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_keys::generateSignature(), ne7ssh_string::getByte(), ne7ssh_keys::getKeyAlgo(), ne7ssh_keys::getKeyPairFromFile(), ne7ssh_transport::getPacket(), ne7ssh_keys::getPublicKeyBlob(), ne7ssh_session::getSessionID(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by connectWithKey().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_connection::authWithPassword (const char *  username,
const char *  password 
) [private]
-
-
- -

-Sends an authentication request of "password" type. Waits for packet 'USERAUTH_SUCESS'.

Parameters:
- - - -
username Username used for authentication.
password Password used for authentication.
-
-
Returns:
True if authentication was successful, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_string::getByte(), ne7ssh_transport::getPacket(), ne7ssh_string::getString(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::checkRemoteVersion (  )  [private]
-
-
- -

-Checks if remote side is returning a correctly formated SSH version string, and makes sure that version 2 of SSH protocol is supported by the remote side.

Returns:
False if version string is malformed, or version 2 is not supported, otherwise true is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::receive(), and ne7ssh_session::setRemoteVersion().

- -

Referenced by connectWithKey(), and connectWithPassword().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ne7ssh_connection::connectWithKey (uint32  channelID,
const char *  host,
uint32  port,
const char *  username,
const char *  privKeyFileName,
bool  shell = true,
int  timeout = 0 
)
-
-
- -

-Connects to a remote host using SSH protocol version 2, with publickey based authentication.

Parameters:
- - - - - - - - -
channelID ID assigned to the new channel.
host Hostname / IP of the remote host.
port Connection port.
username Username to use in the authentication.
privKeyFileName Full path to file containing private key to be used in authentication.
shell Set this to true if you wish to launch the shell on the remote end. By default set to true.
timeout Timeout for the connection procedure, in seconds.
-
-
Returns:
A newly assigned channel ID, or -1 if connection failed.
- -

References authWithKey(), checkRemoteVersion(), ne7ssh_transport::establish(), ne7ssh_channel::getShell(), ne7ssh_kex::handleInit(), ne7ssh_kex::handleKexDHReply(), ne7ssh_channel::open(), requestService(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), sendLocalVersion(), and ne7ssh_session::setSshChannel().

- -

Referenced by ne7ssh::connectWithKey().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ne7ssh_connection::connectWithPassword (uint32  channelID,
const char *  host,
uint32  port,
const char *  username,
const char *  password,
bool  shell = true,
int  timeout = 0 
)
-
-
- -

-Connects to a remote host using SSH protocol version 2, with password based authentication.

Parameters:
- - - - - - - - -
channelID ID of the new channel.
host Hostname / IP of the remote host.
port Connection port.
username Username to use in the authentication.
password Password to use in the authentication.
shell Set this to true if you wish to launch the shell on the remote end. By default set to true.
timeout Timeout for the connection procedure, in seconds.
-
-
Returns:
A newly assigned channel ID, or -1 if connection failed.
- -

References authWithPassword(), checkRemoteVersion(), ne7ssh_transport::establish(), ne7ssh_channel::getShell(), ne7ssh_kex::handleInit(), ne7ssh_kex::handleKexDHReply(), ne7ssh_channel::open(), requestService(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), sendLocalVersion(), and ne7ssh_session::setSshChannel().

- -

Referenced by ne7ssh::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::data2Send (  )  [inline]
-
-
- -

-Checks for the data in the send buffer.

Returns:
True is there is data to send, otherwise false.
- -

References ne7ssh_channel::data2Send().

- -
-

- -

-
- - - - - - - - -
int ne7ssh_connection::getChannelNo (  )  [inline]
-
-
- -

-Retrieves the current SSH channel.

Returns:
Returns SSH channel or -1 if not connected.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::getCmdComplete (  )  [inline]
-
-
- -

-When executing a single command with ne7ssh::sendCmd this command is used to determine when remote side finishes the xecution.

Returns:
True if execution of the command is complete. Otherwise false.
- -

References ne7ssh_channel::getCmdComplete().

- -

Referenced by sendClose().

- -
-

- -

-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_connection::getReceived (  )  [inline]
-
-
- -

-Retrieves the last received packet.

Returns:
A reference to a buffer containing the last received packet.
- -

References ne7ssh_channel::getReceived().

- -

Referenced by ne7ssh::getReceivedSize(), ne7ssh::read(), and ne7ssh::readBinary().

- -
-

- -

-
- - - - - - - - -
SOCKET ne7ssh_connection::getSocket (  )  [inline]
-
-
- -

-Retrieves the tcp socket number.

Returns:
Socket, or -1 if not connected.
- -
-

- -

-
- - - - - - - - -
void ne7ssh_connection::handleData (  ) 
-
-
- -

-When new data arrives, and is available for reading, this function is called from selectThread to handle it. -

References ne7ssh_channel::receive().

- -

Referenced by ne7ssh::selectThread().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isCmdClosed (  )  [inline]
-
-
- -

-When executing a single command with ne7ssh::sendCmd this command is used to determine when the user requested a close() on the channel.

Returns:
True if the user requested to close the channel. Otherwise false.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isCmdRunning (  )  [inline]
-
-
- -

-Checks if current connection is executing a single command, without a shell.

Returns:
True if a single command is running. Otherwise false.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isConnected (  )  [inline]
-
-
- -

-Checks if process is connected and authenticated to the remote side.

Returns:
True if connected, otherwise false is returned.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isOpen (  )  [inline]
-
-
- -

-Checks if channel is open.

Returns:
True if channel is open, otherwise false is returned.
- -

References ne7ssh_channel::isOpen().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isRemoteShell (  )  [inline]
-
-
- -

-Determines if the shell has been spawned on the remote side.

Returns:
True if the shell has been spawned. Otherwise false.
- -

References ne7ssh_channel::isRemoteShell().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::isSftpActive (  ) 
-
-
- -

-Checks if SFTP subsystem is active on the current connection.

Returns:
True if SFTP subsystem is active, otherwise false.
- -

Referenced by sendClose().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_connection::requestService (const char *  service  )  [private]
-
-
- -

-Sends an SSH service request, waits for 'SERVICE_ACCEPT' packet.

Parameters:
- - -
service pointer to a string containing the requested SSH service. For example "ssh-userauth".
-
-
Returns:
True If SERVICE_ACCEPT packet was received, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addString(), ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by connectWithKey(), and connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::sendClose (  ) 
-
-
- -

-This function is used to close the current connection.

-First closes the channel, and then the connection itself.

Returns:
True, if packet sent successfully, otherwise false is returned.
- -

References getCmdComplete(), ne7ssh_channel::isOpen(), isSftpActive(), and ne7ssh_channel::sendClose().

- -

Referenced by ne7ssh::close().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_connection::sendCmd (const char *  cmd  ) 
-
-
- -

-

Parameters:
- - -
cmd 
-
-
Returns:
- -

References ne7ssh_channel::execCmd().

- -

Referenced by ne7ssh::sendCmd().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_connection::sendData (  )  [inline]
-
-
- -

-Sends the content of the buffer.,

-Usually used after data2Send returns true, executed by selectThread. -

References ne7ssh_channel::sendAll().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_connection::sendData (const char *  data  ) 
-
-
- -

-This function is used to write commands to the buffer, later to be sent to the remote site for execution.

Parameters:
- - -
data Pointer to a string, containing command to be written to the buffer.
-
- -

References ne7ssh_channel::write().

- -

Referenced by ne7ssh::selectThread(), and ne7ssh::send().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_connection::sendLocalVersion (  )  [private]
-
-
- -

-Sends local version string.

Returns:
Returns false is there any communication errors occur, otherwise true is returned.
- -

References ne7ssh_transport::send(), and ne7ssh_session::setLocalVersion().

- -

Referenced by connectWithKey(), and connectWithPassword().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_connection::setChannelNo (int  channelID  )  [inline]
-
-
- -

-Sets the current SSH channel number. -

Referenced by ne7ssh::connectWithKey(), and ne7ssh::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
Ne7sshSftp * ne7ssh_connection::startSftp (  ) 
-
-
- -

-Starts a new sftp subsystem.

Returns:
Returns a pointer to the newly started Ne7sshSftp instance.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshSftp::init(), ne7ssh_channel::isRemoteShell(), and Ne7sshError::push().

- -

Referenced by ne7ssh::initSftp().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.map deleted file mode 100644 index 1f53e7b28cd..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.map +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.md5 deleted file mode 100644 index b74f4f60914..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__connection__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -ce68b6591bcf910222da91a135d39054 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt-members.html deleted file mode 100644 index 581c5799723..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt-members.html +++ /dev/null @@ -1,112 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_crypt Member List

This is the complete list of members for ne7ssh_crypt, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AES128_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
AES192_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
AES256_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
agree(Botan::SecureVector< Botan::byte > &result, const char *local, Botan::SecureVector< Botan::byte > &remote)ne7ssh_crypt
BLOWFISH_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
c2sCmprsMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
c2sCryptoMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
c2sMacMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
CAST128_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
cmprsMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
compress (defined in ne7ssh_crypt)ne7ssh_crypt [private]
compressData(Botan::SecureVector< Botan::byte > &buffer)ne7ssh_crypt
compute_key(Botan::SecureVector< Botan::byte > &key, Botan::byte ID, uint32 nBytes)ne7ssh_crypt [private]
computeH(Botan::SecureVector< Botan::byte > &result, Botan::SecureVector< Botan::byte > &val)ne7ssh_crypt
computeMac(Botan::SecureVector< Botan::byte > &hmac, Botan::SecureVector< Botan::byte > &packet, uint32 seq)ne7ssh_crypt
cryptoMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
decompress (defined in ne7ssh_crypt)ne7ssh_crypt [private]
decompressData(Botan::SecureVector< Botan::byte > &buffer)ne7ssh_crypt
decrypt (defined in ne7ssh_crypt)ne7ssh_crypt [private]
decryptBlock (defined in ne7ssh_crypt)ne7ssh_crypt [private]
decryptPacket(Botan::SecureVector< Botan::byte > &decrypted, Botan::SecureVector< Botan::byte > &packet, uint32 len)ne7ssh_crypt
DH_GROUP14_SHA1 enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
DH_GROUP1_SHA1 enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
encrypt (defined in ne7ssh_crypt)ne7ssh_crypt [private]
encryptBlock (defined in ne7ssh_crypt)ne7ssh_crypt [private]
encryptPacket(Botan::SecureVector< Botan::byte > &crypted, Botan::SecureVector< Botan::byte > &hmac, Botan::SecureVector< Botan::byte > &packet, uint32 seq)ne7ssh_crypt
getCryptAlgo(uint32 crypto)ne7ssh_crypt [private]
getDecryptBlock()ne7ssh_crypt [inline]
getDHGroup14Sha1Public(Botan::BigInt &publicKey)ne7ssh_crypt [private]
getDHGroup1Sha1Public(Botan::BigInt &publicKey)ne7ssh_crypt [private]
getDSAKey(Botan::SecureVector< Botan::byte > &hostKey)ne7ssh_crypt [private]
getEncryptBlock()ne7ssh_crypt [inline]
getHashAlgo()ne7ssh_crypt [private]
getHmacAlgo(uint32 method)ne7ssh_crypt [private]
getKexPublic(Botan::BigInt &publicKey)ne7ssh_crypt
getMacDigestLen(uint32 method)ne7ssh_crypt [private]
getMacInLen()ne7ssh_crypt [inline]
getMacKeyLen(uint32 method)ne7ssh_crypt [private]
getMacOutLen()ne7ssh_crypt [inline]
getRSAKey(Botan::SecureVector< Botan::byte > &hostKey)ne7ssh_crypt [private]
H (defined in ne7ssh_crypt)ne7ssh_crypt [private]
HMAC_MD5 enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
HMAC_NONE enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
HMAC_SHA1 enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
hmacIn (defined in ne7ssh_crypt)ne7ssh_crypt [private]
hmacOut (defined in ne7ssh_crypt)ne7ssh_crypt [private]
hostkeyMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
hostkeyMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
inited (defined in ne7ssh_crypt)ne7ssh_crypt [private]
isCompressed()ne7ssh_crypt [inline]
isInited()ne7ssh_crypt [inline]
K (defined in ne7ssh_crypt)ne7ssh_crypt [private]
kexMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
kexMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
macMethods enum name (defined in ne7ssh_crypt)ne7ssh_crypt [private]
makeKexSecret(Botan::SecureVector< Botan::byte > &result, Botan::BigInt &f)ne7ssh_crypt
makeNewKeys()ne7ssh_crypt
ne7ssh_crypt(ne7ssh_session *_session)ne7ssh_crypt
negotiatedCmprsC2s(Botan::SecureVector< Botan::byte > &cmprsAlgo)ne7ssh_crypt
negotiatedCmprsS2c(Botan::SecureVector< Botan::byte > &cmprsAlgo)ne7ssh_crypt
negotiatedCryptoC2s(Botan::SecureVector< Botan::byte > &cryptoAlgo)ne7ssh_crypt
negotiatedCryptoS2c(Botan::SecureVector< Botan::byte > &cryptoAlgo)ne7ssh_crypt
negotiatedHostkey(Botan::SecureVector< Botan::byte > &hostKeyAlgo)ne7ssh_crypt
negotiatedKex(Botan::SecureVector< Botan::byte > &kexAlgo)ne7ssh_crypt
negotiatedMacC2s(Botan::SecureVector< Botan::byte > &macAlgo)ne7ssh_crypt
negotiatedMacS2c(Botan::SecureVector< Botan::byte > &macAlgo)ne7ssh_crypt
NONE enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
privKexKey (defined in ne7ssh_crypt)ne7ssh_crypt [private]
s2cCmprsMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
s2cCryptoMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
s2cMacMethod (defined in ne7ssh_crypt)ne7ssh_crypt [private]
session (defined in ne7ssh_crypt)ne7ssh_crypt [private]
SSH_DSS enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
SSH_RSA enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
TDES_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
TWOFISH_CBC enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
verifySig(Botan::SecureVector< Botan::byte > &hostKey, Botan::SecureVector< Botan::byte > &sig)ne7ssh_crypt
ZLIB enum value (defined in ne7ssh_crypt)ne7ssh_crypt [private]
~ne7ssh_crypt()ne7ssh_crypt

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt.html deleted file mode 100644 index 7202d2d2192..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt.html +++ /dev/null @@ -1,1362 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_crypt Class Reference - - - - - -
-

ne7ssh_crypt Class Reference

#include <crypt.h> -

-

-Collaboration diagram for ne7ssh_crypt:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_crypt (ne7ssh_session *_session)
 ~ne7ssh_crypt ()
bool isInited ()
uint32 getEncryptBlock ()
uint32 getDecryptBlock ()
uint32 getMacOutLen ()
uint32 getMacInLen ()
bool agree (Botan::SecureVector< Botan::byte > &result, const char *local, Botan::SecureVector< Botan::byte > &remote)
bool negotiatedKex (Botan::SecureVector< Botan::byte > &kexAlgo)
bool negotiatedHostkey (Botan::SecureVector< Botan::byte > &hostKeyAlgo)
bool negotiatedCryptoC2s (Botan::SecureVector< Botan::byte > &cryptoAlgo)
bool negotiatedCryptoS2c (Botan::SecureVector< Botan::byte > &cryptoAlgo)
bool negotiatedMacC2s (Botan::SecureVector< Botan::byte > &macAlgo)
bool negotiatedMacS2c (Botan::SecureVector< Botan::byte > &macAlgo)
bool negotiatedCmprsC2s (Botan::SecureVector< Botan::byte > &cmprsAlgo)
bool negotiatedCmprsS2c (Botan::SecureVector< Botan::byte > &cmprsAlgo)
bool getKexPublic (Botan::BigInt &publicKey)
bool makeKexSecret (Botan::SecureVector< Botan::byte > &result, Botan::BigInt &f)
bool computeH (Botan::SecureVector< Botan::byte > &result, Botan::SecureVector< Botan::byte > &val)
bool verifySig (Botan::SecureVector< Botan::byte > &hostKey, Botan::SecureVector< Botan::byte > &sig)
bool makeNewKeys ()
bool encryptPacket (Botan::SecureVector< Botan::byte > &crypted, Botan::SecureVector< Botan::byte > &hmac, Botan::SecureVector< Botan::byte > &packet, uint32 seq)
bool decryptPacket (Botan::SecureVector< Botan::byte > &decrypted, Botan::SecureVector< Botan::byte > &packet, uint32 len)
void computeMac (Botan::SecureVector< Botan::byte > &hmac, Botan::SecureVector< Botan::byte > &packet, uint32 seq)
void compressData (Botan::SecureVector< Botan::byte > &buffer)
void decompressData (Botan::SecureVector< Botan::byte > &buffer)
bool isCompressed ()

Private Types

enum  kexMethods { DH_GROUP1_SHA1, -DH_GROUP14_SHA1 - }
enum  hostkeyMethods { SSH_DSS, -SSH_RSA - }
enum  cryptoMethods {
-  TDES_CBC, -AES128_CBC, -AES192_CBC, -AES256_CBC, -
-  BLOWFISH_CBC, -CAST128_CBC, -TWOFISH_CBC -
- }
enum  macMethods { HMAC_SHA1, -HMAC_MD5, -HMAC_NONE - }
enum  cmprsMethods { NONE, -ZLIB - }

Private Member Functions

bool getDHGroup1Sha1Public (Botan::BigInt &publicKey)
bool getDHGroup14Sha1Public (Botan::BigInt &publicKey)
Botan::DSA_PublicKey * getDSAKey (Botan::SecureVector< Botan::byte > &hostKey)
Botan::RSA_PublicKey * getRSAKey (Botan::SecureVector< Botan::byte > &hostKey)
const char * getHashAlgo ()
const char * getCryptAlgo (uint32 crypto)
const char * getHmacAlgo (uint32 method)
uint32 getMacKeyLen (uint32 method)
uint32 getMacDigestLen (uint32 method)
bool compute_key (Botan::SecureVector< Botan::byte > &key, Botan::byte ID, uint32 nBytes)

Private Attributes

-ne7ssh_sessionsession
-uint32 kexMethod
-uint32 hostkeyMethod
-uint32 c2sCryptoMethod
-uint32 s2cCryptoMethod
-uint32 c2sMacMethod
-uint32 s2cMacMethod
-uint32 c2sCmprsMethod
-uint32 s2cCmprsMethod
-bool inited
-Botan::SecureVector< Botan::byte > H
-Botan::SecureVector< Botan::byte > K
-Botan::Pipe * encrypt
-Botan::Pipe * decrypt
-Botan::Pipe * compress
-Botan::Pipe * decompress
-Botan::HMAC * hmacOut
-Botan::HMAC * hmacIn
-Botan::DH_PrivateKey * privKexKey
-uint32 encryptBlock
-uint32 decryptBlock
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
ne7ssh_crypt::ne7ssh_crypt (ne7ssh_session _session  ) 
-
-
- -

-ne7ssh_crypt class constructor.

Parameters:
- - -
_session Pointer to ne7ssh_session class.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_crypt::~ne7ssh_crypt (  ) 
-
-
- -

-ne7ssh_crypt class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::agree (Botan::SecureVector< Botan::byte > &  result,
const char *  local,
Botan::SecureVector< Botan::byte > &  remote 
)
-
-
- -

-This function is used in negotiations of crypto, signing and HMAC algorithms.

Parameters:
- - - - -
result Reference to a vector where negotiated algorithm name will be dumped.
local String containing a list of localy supported algorithms, separated by commas.
remote Reference to vector containing a list of algorithms supported by remote side, separated by commas.
-
-
Returns:
True, if common algorithm was found, otherwise false is returned.
- -

References ne7ssh_string::nextPart(), ne7ssh_string::resetParts(), and ne7ssh_string::split().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_crypt::compressData (Botan::SecureVector< Botan::byte > &  buffer  ) 
-
-
- -

-Compresses the data.

Parameters:
- - -
buffer Reference to vector containing payload to be compress. Results will also be dumped into this var.
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::compute_key (Botan::SecureVector< Botan::byte > &  key,
Botan::byte  ID,
uint32  nBytes 
) [private]
-
-
- -

-Function used to compute crypto and HMAC keys.

-Keys are computed using K, H, ID and sessionID values. All these are concated and hashed. If hash is not long enough K, H, and newly generated key is used over and over again, till keys are long enough.

Parameters:
- - - - -
key Resulting key will be dumped into this var.
ID Single character ID, as specified in SSH protocol specs.
nBytes Key length in bytes.
-
-
Returns:
True if key generation was successful, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh_string::clear(), ne7ssh::errors(), getHashAlgo(), ne7ssh_session::getSessionID(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by makeNewKeys().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::computeH (Botan::SecureVector< Botan::byte > &  result,
Botan::SecureVector< Botan::byte > &  val 
)
-
-
- -

-Computes H value by checking what hash algorithm is used and hashing "val".

Parameters:
- - - -
result H value will be dumped into this var.
val Reference to vector containing material for H variable generation.
-
-
Returns:
True if key generation was successful, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::makeH().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
void ne7ssh_crypt::computeMac (Botan::SecureVector< Botan::byte > &  hmac,
Botan::SecureVector< Botan::byte > &  packet,
uint32  seq 
)
-
-
- -

-Computes HMAC from specific packet.

Parameters:
- - - - -
hmac Generated HMAC value will be dumped into this var.
packet Reference to vector containing packet for HMAC generation.
seq receive sequence.
-
- -

Referenced by ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_crypt::decompressData (Botan::SecureVector< Botan::byte > &  buffer  ) 
-
-
- -

-Decompresses the data.

Parameters:
- - -
buffer Reference to vector containing packet payload to decompress. Result will also be dumped into this var.
-
- -

Referenced by ne7ssh_transport::getPacket().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::decryptPacket (Botan::SecureVector< Botan::byte > &  decrypted,
Botan::SecureVector< Botan::byte > &  packet,
uint32  len 
)
-
-
- -

-Decrypts a packet.

Parameters:
- - - - -
decrypted Decrypted payload will be dumped into this var.
packet Reference to vector containing encrypted packet.
len Specifies the length of chunk to be decrypted.
-
-
Returns:
True if decryption is successful, otherwise false returned.
- -

Referenced by ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::encryptPacket (Botan::SecureVector< Botan::byte > &  crypted,
Botan::SecureVector< Botan::byte > &  hmac,
Botan::SecureVector< Botan::byte > &  packet,
uint32  seq 
)
-
-
- -

-Encrypts a packet and generates HMAC, if enabled during negotiation.

-The entire packet is encrypted, only HMAC stays in raw format.

Parameters:
- - - - - -
crypted Encrypted packet will be dumped into this var.
hmac HMAC will be dumped into this var.
packet Reference to vector containing unencrypted packet.
seq Transmited packet sequence.
-
-
Returns:
True if encryption successful, otherwise false is returned.
- -

Referenced by ne7ssh_transport::sendPacket().

- -
-

- -

-
- - - - - - - - - -
const char * ne7ssh_crypt::getCryptAlgo (uint32  crypto  )  [private]
-
-
- -

-Returns a string represenation of negotiated cipher algorithm.

Parameters:
- - -
crypto Integer represenating a cipher algorithm.
-
-
Returns:
A string containing algorithm name.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by makeNewKeys().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_crypt::getDecryptBlock (  )  [inline]
-
-
- -

-Returns the size of decryption block

Returns:
Size of the block
- -

Referenced by ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::getDHGroup14Sha1Public (Botan::BigInt &  publicKey  )  [private]
-
-
- -

-Generates a new Public Key, based on Diffie Helman Group14, SHA1 standard.

Parameters:
- - -
publicKey Reference to publick Key. The result will be dumped into this var.
-
-
Returns:
If generation successful returns true, otherwise false is returned.
- -

Referenced by getKexPublic().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::getDHGroup1Sha1Public (Botan::BigInt &  publicKey  )  [private]
-
-
- -

-Generates a new Public Key, based on Diffie Helman Group1, SHA1 standard.

Parameters:
- - -
publicKey Reference to publick Key. The result will be dumped into this var.
-
-
Returns:
If generation successful returns true, otherwise false is returned.
- -

Referenced by getKexPublic().

- -
-

- -

-
- - - - - - - - - -
DSA_PublicKey * ne7ssh_crypt::getDSAKey (Botan::SecureVector< Botan::byte > &  hostKey  )  [private]
-
-
- -

-Generates a new DSA public Key from p,q,g,y values extracted from the host key received from the server.

Parameters:
- - -
hostKey Reference to vector containing host key received from a server.
-
-
Returns:
Returns newly generated DSA public Key. If host key vector is trash, more likely application will be aborted within Botan library.
- -

References ne7ssh_string::addVector(), ne7ssh_string::getBigInt(), ne7ssh_string::getString(), and negotiatedHostkey().

- -

Referenced by verifySig().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_crypt::getEncryptBlock (  )  [inline]
-
-
- -

-Returns the size of encryption block.

Returns:
Size of the block.
- -

Referenced by ne7ssh_transport::sendPacket().

- -
-

- -

-
- - - - - - - - -
const char * ne7ssh_crypt::getHashAlgo (  )  [private]
-
-
- -

-Returns a string represenation of negotiated one way hash algorithm. For DH1_GROUP1_SHA1, "SHA-1" will be returned.

Returns:
A string containing algorithm name.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by compute_key().

- -
-

- -

-
- - - - - - - - - -
const char * ne7ssh_crypt::getHmacAlgo (uint32  method  )  [private]
-
-
- -

-Returns a string represenation of negotiated HMAC algorithm.

Parameters:
- - -
method Integer represenating HMAC algorithm.
-
-
Returns:
A string containing algorithm name.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by makeNewKeys().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::getKexPublic (Botan::BigInt &  publicKey  ) 
-
-
- -

-Generates KEX public key.

Parameters:
- - -
publicKey Public key will be dumped into this var.
-
-
Returns:
True if key generation was successful, otherwise false is returned.
- -

References ne7ssh::errors(), getDHGroup14Sha1Public(), getDHGroup1Sha1Public(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::sendKexDHInit().

- -
-

- -

-
- - - - - - - - - -
uint32 ne7ssh_crypt::getMacDigestLen (uint32  method  )  [private]
-
-
- -

-Returns digest length of negotiated HMAC algorithm.

-If HMAC integrity checking is enabled, this value is used in the verification process. Digest length coded in accordance with SSH protocol specs.

Parameters:
- - -
method Integer represenation of HMAC algorithm.
-
-
Returns:
Key length.
- -

Referenced by getMacInLen(), and getMacOutLen().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_crypt::getMacInLen (  )  [inline]
-
-
- -

-Returns digest length of HMAC algorithm used to verify integrity of data received.

Returns:
Digest length.
- -

References getMacDigestLen().

- -

Referenced by ne7ssh_transport::getPacket(), and ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - -
uint32 ne7ssh_crypt::getMacKeyLen (uint32  method  )  [private]
-
-
- -

-Returns key length of the negotiated HMAC algorithm.

-Used in HMAC key generation. Key length coded in accordance with SSH protocol specs.

Parameters:
- - -
method Integer represenating HMAC algorithm.
-
-
Returns:
Key length.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by makeNewKeys().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_crypt::getMacOutLen (  )  [inline]
-
-
- -

-Returns digest length of HMAC algorithm used to verify integrity of transmited data.

Returns:
Digest length.
- -

References getMacDigestLen().

- -
-

- -

-
- - - - - - - - - -
RSA_PublicKey * ne7ssh_crypt::getRSAKey (Botan::SecureVector< Botan::byte > &  hostKey  )  [private]
-
-
- -

-Generates a new RSA public Key from n and e values extracted from the host key received from the server.

Parameters:
- - -
hostKey Reference to a vector containing host key.
-
-
Returns:
Returns newly generated ESA public Key. If the hostkey is trash, more likely application will abort within Botan library.
- -

References ne7ssh_string::addVector(), ne7ssh_string::getBigInt(), ne7ssh_string::getString(), and negotiatedHostkey().

- -

Referenced by verifySig().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_crypt::isCompressed (  )  [inline]
-
-
- -

-Checks if compression is enabled.

Returns:
If compression is enabled returns true, otherwise false is returned.
- -
-

- -

-
- - - - - - - - -
bool ne7ssh_crypt::isInited (  )  [inline]
-
-
- -

-Checks if cryptographic engine has been initialized.

-The engine is initialized when all crypto and hmac keys are generated and the cryptographic Pipes are created.

Returns:
True if cryptographic engine is initialized, otherwise false is returned.
- -

Referenced by ne7ssh_transport::getPacket(), ne7ssh_kex::handleKexDHReply(), ne7ssh_transport::sendPacket(), and ne7ssh_transport::waitForPacket().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::makeKexSecret (Botan::SecureVector< Botan::byte > &  result,
Botan::BigInt &  f 
)
-
-
- -

-At the end of key exchange this function is used to generate a shared secret key from private KEX key, that one gets from getKexPublic() function and F value received from a server.

Parameters:
- - - -
result Secret key will be dumped into this var.
f Reference to F value.
-
-
Returns:
True if key generation was successful, otherwise false is returned.
- -

References ne7ssh_string::bn2vector().

- -

Referenced by ne7ssh_kex::handleKexDHReply().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_crypt::makeNewKeys (  ) 
-
-
- -

-Generates new cipher and HMAC keys.

Returns:
True if key generation was successful, otherwise false is returned.
- -

References compute_key(), getCryptAlgo(), getHmacAlgo(), and getMacKeyLen().

- -

Referenced by ne7ssh_kex::sendKexNewKeys().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedCmprsC2s (Botan::SecureVector< Botan::byte > &  cmprsAlgo  ) 
-
-
- -

-Parses negotiated client to server compression algorithm and registers it's integer representation with the class.

Parameters:
- - -
cmprsAlgo Reference to a vector containing the negotiated compression algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedCmprsS2c (Botan::SecureVector< Botan::byte > &  cmprsAlgo  ) 
-
-
- -

-Parses negotiated server to client compression algorithm and registers it's integer representation with the class.

Parameters:
- - -
cmprsAlgo Reference to a vector containing the negotiated compression algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedCryptoC2s (Botan::SecureVector< Botan::byte > &  cryptoAlgo  ) 
-
-
- -

-Parse negotiated client to server cipher algorithm and registers it's integer representation with the class.

Parameters:
- - -
cryptoAlgo Reference to a vector containing the negotiated cipher algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedCryptoS2c (Botan::SecureVector< Botan::byte > &  cryptoAlgo  ) 
-
-
- -

-Parses negotiated server to client cipher algorithm and registers it's integer representation with the class.

Parameters:
- - -
cryptoAlgo Reference to a vector containing the negotiated cipher algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedHostkey (Botan::SecureVector< Botan::byte > &  hostKeyAlgo  ) 
-
-
- -

-Parses negotiated host key algorithm and registers it's integer representation with the class.

Parameters:
- - -
hostKeyAlgo Reference to a vector containing the negotiated host key algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by getDSAKey(), getRSAKey(), and ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedKex (Botan::SecureVector< Botan::byte > &  kexAlgo  ) 
-
-
- -

-Parses negotiated key exchange algorithm vector, and registers it's integer representation with the class.

Parameters:
- - -
kexAlgo Reference to a vector containing the negotiated KEX algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedMacC2s (Botan::SecureVector< Botan::byte > &  macAlgo  ) 
-
-
- -

-Parses negotiated client to server HMAC algorithm and registers it's integer representation with the class.

Parameters:
- - -
macAlgo Reference to a vector containing the negotiated HMAC algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_crypt::negotiatedMacS2c (Botan::SecureVector< Botan::byte > &  macAlgo  ) 
-
-
- -

-Parses negotiated server to client HMAC algorithm vector and registers it's integer representation with the class.

Parameters:
- - -
macAlgo Reference to a vector containing the negotiated HMAC algorithm.
-
-
Returns:
True if negotiated algorithm is recognized, otherwise false is returned.
- -

References ne7ssh::errors(), ne7ssh_session::getSshChannel(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleInit().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_crypt::verifySig (Botan::SecureVector< Botan::byte > &  hostKey,
Botan::SecureVector< Botan::byte > &  sig 
)
-
-
- -

-Verifies host signature.

Parameters:
- - - -
hostKey Reference to vector containing hostKey.
sig Regerence to vector containing the signature.
-
-
Returns:
True if signature verification was successful, otherwise false is returned.
- -

References ne7ssh::errors(), getDSAKey(), getRSAKey(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), and Ne7sshError::push().

- -

Referenced by ne7ssh_kex::handleKexDHReply().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.map deleted file mode 100644 index acb09cde818..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.md5 deleted file mode 100644 index a0191a6c0a9..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__crypt__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -72e4da21efe57283ea6ef8f98feb75eb \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex-members.html deleted file mode 100644 index b87d6c42236..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex-members.html +++ /dev/null @@ -1,51 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_kex Member List

This is the complete list of members for ne7ssh_kex, including all inherited members.

- - - - - - - - - - - - - - - - - - -
Ciphers (defined in ne7ssh_kex)ne7ssh_kex [private]
constructLocalKex()ne7ssh_kex [private]
e (defined in ne7ssh_kex)ne7ssh_kex [private]
f (defined in ne7ssh_kex)ne7ssh_kex [private]
handleInit()ne7ssh_kex
handleKexDHReply()ne7ssh_kex
Hmacs (defined in ne7ssh_kex)ne7ssh_kex [private]
hostKey (defined in ne7ssh_kex)ne7ssh_kex [private]
k (defined in ne7ssh_kex)ne7ssh_kex [private]
localKex (defined in ne7ssh_kex)ne7ssh_kex [private]
makeH(Botan::SecureVector< Botan::byte > &hVector)ne7ssh_kex [private]
ne7ssh_kex(ne7ssh_session *_session)ne7ssh_kex
remotKex (defined in ne7ssh_kex)ne7ssh_kex [private]
sendInit()ne7ssh_kex
sendKexDHInit()ne7ssh_kex
sendKexNewKeys()ne7ssh_kex
session (defined in ne7ssh_kex)ne7ssh_kex [private]
~ne7ssh_kex()ne7ssh_kex

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex.html deleted file mode 100644 index 64d7ba28820..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex.html +++ /dev/null @@ -1,319 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_kex Class Reference - - - - - -
-

ne7ssh_kex Class Reference

#include <ne7ssh_kex.h> -

-

-Collaboration diagram for ne7ssh_kex:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_kex (ne7ssh_session *_session)
 ~ne7ssh_kex ()
bool sendInit ()
bool handleInit ()
bool sendKexDHInit ()
bool handleKexDHReply ()
bool sendKexNewKeys ()

Private Member Functions

void constructLocalKex ()
void makeH (Botan::SecureVector< Botan::byte > &hVector)

Private Attributes

-ne7ssh_sessionsession
-ne7ssh_string localKex
-ne7ssh_string remotKex
-ne7ssh_string hostKey
-ne7ssh_string e
-ne7ssh_string f
-ne7ssh_string k
-Botan::SecureVector< Botan::byte > Ciphers
-Botan::SecureVector< Botan::byte > Hmacs
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
ne7ssh_kex::ne7ssh_kex (ne7ssh_session _session  ) 
-
-
- -

-ne7ssh_kex class constructor.

Parameters:
- - -
_session Pointer to ne7ssh_session variable.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_kex::~ne7ssh_kex (  ) 
-
-
- -

-ne7ssh_kex class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - -
void ne7ssh_kex::constructLocalKex (  )  [private]
-
- -

- -

-
- - - - - - - - -
bool ne7ssh_kex::handleInit (  ) 
-
-
- -

-After sendInit() function returnes true, this functions is used to parse the received 'KEX_INIT' packet.

-Used to agree on cipher, hmac, etc. algorithms used in communication between client and server.

Returns:
True if parsing was succesful and all algorithms agreed upon, otherwise false is returned.
- -

References ne7ssh_string::addBytes(), ne7ssh_crypt::agree(), ne7ssh_string::clear(), ne7ssh::errors(), ne7ssh_transport::getPacket(), ne7ssh_session::getSshChannel(), ne7ssh_string::getString(), ne7ssh_crypt::negotiatedCmprsC2s(), ne7ssh_crypt::negotiatedCmprsS2c(), ne7ssh_crypt::negotiatedCryptoC2s(), ne7ssh_crypt::negotiatedCryptoS2c(), ne7ssh_crypt::negotiatedHostkey(), ne7ssh_crypt::negotiatedKex(), ne7ssh_crypt::negotiatedMacC2s(), ne7ssh_crypt::negotiatedMacS2c(), and Ne7sshError::push().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_kex::handleKexDHReply (  ) 
-
-
- -

-After sendKexDHInit() returns true, this function is used to handle the received 'KEXDH_REPLY'.

-This is the function to create the shared secret K. It also extracts the host key and signature fields from the payload, generates DSA/RSA keys, and verifies the signature.

Returns:
True if all operations are completed successfully, otherwise false is returned.
- -

References ne7ssh_string::addVector(), ne7ssh_string::bn2vector(), ne7ssh_string::clear(), ne7ssh_string::getBigInt(), ne7ssh_transport::getPacket(), ne7ssh_string::getString(), ne7ssh_crypt::isInited(), makeH(), ne7ssh_crypt::makeKexSecret(), ne7ssh_session::setSessionID(), ne7ssh_string::value(), and ne7ssh_crypt::verifySig().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_kex::makeH (Botan::SecureVector< Botan::byte > &  hVector  )  [private]
-
-
- -

-Computes H hash, from concated values of the local SSH version string, remote SSH version string, local KEX_INIT payload, remote KEX_INIT payload, host key, e, f and k BigInt values.

Parameters:
- - -
hVector Reference to a vecor where H value will be stored.
-
- -

References ne7ssh_string::addVectorField(), ne7ssh_crypt::computeH(), ne7ssh_session::getLocalVersion(), ne7ssh_session::getRemoteVersion(), and ne7ssh_string::value().

- -

Referenced by handleKexDHReply().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_kex::sendInit (  ) 
-
-
- -

-Sends 'KEX_INIT' packet and waits for 'KEX_INIT' reply.

Returns:
True if successful, otherwise false is returned.
- -

References constructLocalKex(), ne7ssh::errors(), ne7ssh_session::getSshChannel(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - -
bool ne7ssh_kex::sendKexDHInit (  ) 
-
- -

- -

-
- - - - - - - - -
bool ne7ssh_kex::sendKexNewKeys (  ) 
-
-
- -

-This function waits for 'NEWKEYS' packet from the remote host.

-Once the packet is received, local 'NEWKEYS' packet is sent, all encryption and hmac keys are generated and encrypted communication is established.

Returns:
True if all operations are successful, otherwise false is returned.
- -

References ne7ssh_string::addChar(), ne7ssh::errors(), ne7ssh_session::getSshChannel(), ne7ssh_crypt::makeNewKeys(), Ne7sshError::push(), ne7ssh_transport::sendPacket(), ne7ssh_string::value(), and ne7ssh_transport::waitForPacket().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.map deleted file mode 100644 index 892978342e2..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.map +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.md5 deleted file mode 100644 index 4685c290b84..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__kex__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -c6c626f9886b1a9d69d7e1660e94daa0 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys-members.html deleted file mode 100644 index a9fbbbdc0b3..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys-members.html +++ /dev/null @@ -1,53 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_keys Member List

This is the complete list of members for ne7ssh_keys, including all inherited members.

- - - - - - - - - - - - - - - - - - - - -
DSA enum value (defined in ne7ssh_keys)ne7ssh_keys
dsaPrivateKey (defined in ne7ssh_keys)ne7ssh_keys [private]
generateDSAKeys(const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048)ne7ssh_keys
generateDSASignature(Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)ne7ssh_keys
generateRSAKeys(const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048)ne7ssh_keys
generateRSASignature(Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)ne7ssh_keys
generateSignature(Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)ne7ssh_keys
getDSAKeys(char *buffer, uint32 size)ne7ssh_keys [private]
getKeyAlgo()ne7ssh_keys [inline]
getKeyPairFromFile(const char *privKeyFileName)ne7ssh_keys
getPublicKeyBlob()ne7ssh_keys
getRSAKeys(char *buffer, uint32 size)ne7ssh_keys [private]
keyAlgo (defined in ne7ssh_keys)ne7ssh_keys [private]
keyAlgos enum name (defined in ne7ssh_keys)ne7ssh_keys
ne7ssh_keys()ne7ssh_keys
publicKeyBlob (defined in ne7ssh_keys)ne7ssh_keys [private]
RSA enum value (defined in ne7ssh_keys)ne7ssh_keys
rsaPrivateKey (defined in ne7ssh_keys)ne7ssh_keys [private]
signature (defined in ne7ssh_keys)ne7ssh_keys [private]
~ne7ssh_keys()ne7ssh_keys

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys.html deleted file mode 100644 index fe199c04891..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys.html +++ /dev/null @@ -1,526 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_keys Class Reference - - - - - -
-

ne7ssh_keys Class Reference

#include <ne7ssh_keys.h> -

-

-Collaboration diagram for ne7ssh_keys:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Types

enum  keyAlgos { DSA, -RSA - }

Public Member Functions

 ne7ssh_keys ()
 ~ne7ssh_keys ()
bool generateDSAKeys (const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048)
bool generateRSAKeys (const char *fqdn, const char *privKeyFileName, const char *pubKeyFileName, uint16 keySize=2048)
bool getKeyPairFromFile (const char *privKeyFileName)
Botan::SecureVector
-< Botan::byte > & 
generateSignature (Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)
Botan::SecureVector< Botan::byte > generateDSASignature (Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)
Botan::SecureVector< Botan::byte > generateRSASignature (Botan::SecureVector< Botan::byte > &sessionID, Botan::SecureVector< Botan::byte > &signingData)
Botan::SecureVector
-< Botan::byte > & 
getPublicKeyBlob ()
uint8 getKeyAlgo ()

Private Member Functions

bool getDSAKeys (char *buffer, uint32 size)
bool getRSAKeys (char *buffer, uint32 size)

Private Attributes

-Botan::DSA_PrivateKey * dsaPrivateKey
-Botan::RSA_PrivateKey * rsaPrivateKey
-ne7ssh_string publicKeyBlob
-Botan::SecureVector< Botan::byte > signature
-uint8 keyAlgo
-


Detailed Description

-
Author:
Andrew Useckas <andrew@netsieben.com>
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh_keys::ne7ssh_keys (  ) 
-
-
- -

-ne7ssh_keys constructor. -

-

- -

-
- - - - - - - - -
ne7ssh_keys::~ne7ssh_keys (  ) 
-
-
- -

-ne7ssh_keys destructor.

Returns:
- -
-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_keys::generateDSAKeys (const char *  fqdn,
const char *  privKeyFileName,
const char *  pubKeyFileName,
uint16  keySize = 2048 
)
-
-
- -

-Generates DSA Key pair and saves keys in specified files.

Parameters:
- - - - - -
fqdn User id. Usually an Email. For example "test@netsieben.com"
privKeyFileName Full path to a file where generated private key should be written.
pubKeyFileName Full path to a file where generated public key should be written.
keySize Desired key size in bits. If not specified will default to 2048.
-
-
Returns:
True if keys generated and written to the files. Otherwise false is returned.
- -

References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by ne7ssh::generateKeyPair().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
SecureVector< Botan::byte > ne7ssh_keys::generateDSASignature (Botan::SecureVector< Botan::byte > &  sessionID,
Botan::SecureVector< Botan::byte > &  signingData 
)
-
-
- -

-Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before.

Parameters:
- - - -
sessionID SSH2 SessionID.
signingData Packet data to sign.
-
-
Returns:
Returns signature, or 0 length vector if operation failed.
- -

References ne7ssh_string::addString(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh_string::clear(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by generateSignature().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_keys::generateRSAKeys (const char *  fqdn,
const char *  privKeyFileName,
const char *  pubKeyFileName,
uint16  keySize = 2048 
)
-
-
- -

-Generates RSA Key pair and saves keys in specified files.

Parameters:
- - - - - -
fqdn User id. Usually an Email. For example "test@netsieben.com"
privKeyFileName Full path to a file where generated private key should be written.
pubKeyFileName Full path to a file where generated public key should be written.
keySize Desired key size in bits. If not specified will default to 2048.
-
-
Returns:
True if keys generated and written to the files. Otherwise false is returned.
- -

References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by ne7ssh::generateKeyPair().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
SecureVector< Botan::byte > ne7ssh_keys::generateRSASignature (Botan::SecureVector< Botan::byte > &  sessionID,
Botan::SecureVector< Botan::byte > &  signingData 
)
-
-
- -

-Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before.

Parameters:
- - - -
sessionID SSH2 SessionID.
signingData Packet data to sign.
-
-
Returns:
Returns signature, or 0 length vector if operation failed.
- -

References ne7ssh_string::addString(), ne7ssh_string::addVector(), ne7ssh_string::addVectorField(), ne7ssh::errors(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by generateSignature().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
SecureVector< Botan::byte > & ne7ssh_keys::generateSignature (Botan::SecureVector< Botan::byte > &  sessionID,
Botan::SecureVector< Botan::byte > &  signingData 
)
-
-
- -

-Generates a SHA-1 signature from sessionID and packet data provided.

-Determines key type and passed the processing either to generateDSASignature() or generateRSAKeys() functions.

Parameters:
- - - -
sessionID SSH2 SessionID.
signingData Packet data to sign.
-
-
Returns:
Returns signature, or 0 length vector if operation failed.
- -

References generateDSASignature(), and generateRSASignature().

- -

Referenced by ne7ssh_connection::authWithKey().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_keys::getDSAKeys (char *  buffer,
uint32  size 
) [private]
-
-
- -

-Extracts DSA key pair from a PEM encoded stream.

Parameters:
- - - -
buffer PEM encoded string.
size Length of the stream.
-
-
Returns:
True if keys succesfully extracted. Otherwise False is returned.
- -

References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by getKeyPairFromFile().

- -
-

- -

-
- - - - - - - - -
uint8 ne7ssh_keys::getKeyAlgo (  )  [inline]
-
-
- -

-Returns type of initialized keys.

Returns:
Type of keys.
- -

Referenced by ne7ssh_connection::authWithKey().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_keys::getKeyPairFromFile (const char *  privKeyFileName  ) 
-
-
- -

-Extracts key pair from a PEM encoded file.

-Reads the file and determines the type of key, then passes processing to either getDsaKeys() or getRSAKeys(*) functions.

Parameters:
- - -
privKeyFileName Full path to PEM encoded file.
-
-
Returns:
True if key succesfully extracted, otherwise False is returned.
- -

References ne7ssh_string::addFile(), ne7ssh::errors(), getDSAKeys(), getRSAKeys(), ne7ssh_string::length(), Ne7sshError::push(), and ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::authWithKey().

- -
-

- -

-
- - - - - - - - -
SecureVector< Botan::byte > & ne7ssh_keys::getPublicKeyBlob (  ) 
-
-
- -

-After key pair has been initialized, this function returns public key blob, as specified by SSH2 specs.

Returns:
Public key blob or zero length vector, if there are initialized keys.
- -

References ne7ssh_string::value().

- -

Referenced by ne7ssh_connection::authWithKey().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_keys::getRSAKeys (char *  buffer,
uint32  size 
) [private]
-
-
- -

-Extracts RSA key pair from a PEM encoded stream.

Parameters:
- - - -
buffer PEM encoded string.
size Length of the stream.
-
-
Returns:
True if keys succesfully extracted. Otherwise False is returned.
- -

References ne7ssh_string::addBigInt(), ne7ssh_string::addString(), ne7ssh_string::clear(), ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by getKeyPairFromFile().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.map deleted file mode 100644 index 28bba305867..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.md5 deleted file mode 100644 index 96a712790ec..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__keys__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -b0e2e8f8f6e9dbf06d7b20a0e23b73c3 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session-members.html deleted file mode 100644 index 1c71879f867..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session-members.html +++ /dev/null @@ -1,58 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_session Member List

This is the complete list of members for ne7ssh_session, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - -
channelID (defined in ne7ssh_session)ne7ssh_session [private]
crypto (defined in ne7ssh_session)ne7ssh_session
getLocalVersion()ne7ssh_session [inline]
getMaxPacket()ne7ssh_session [inline]
getReceiveChannel()ne7ssh_session [inline]
getRemoteVersion()ne7ssh_session [inline]
getSendChannel() const ne7ssh_session [inline]
getSessionID()ne7ssh_session [inline]
getSshChannel()ne7ssh_session [inline]
localVersion (defined in ne7ssh_session)ne7ssh_session [private]
maxPacket (defined in ne7ssh_session)ne7ssh_session [private]
ne7ssh_session()ne7ssh_session
receiveChannel (defined in ne7ssh_session)ne7ssh_session [private]
remoteVersion (defined in ne7ssh_session)ne7ssh_session [private]
sendChannel (defined in ne7ssh_session)ne7ssh_session [private]
sessionID (defined in ne7ssh_session)ne7ssh_session [private]
setLocalVersion(Botan::SecureVector< Botan::byte > &version)ne7ssh_session [inline]
setMaxPacket(uint32 size)ne7ssh_session [inline]
setReceiveChannel(uint32 channel)ne7ssh_session [inline]
setRemoteVersion(Botan::SecureVector< Botan::byte > &version)ne7ssh_session [inline]
setSendChannel(uint32 channel)ne7ssh_session [inline]
setSessionID(Botan::SecureVector< Botan::byte > &session)ne7ssh_session [inline]
setSshChannel(int32 channel)ne7ssh_session [inline]
transport (defined in ne7ssh_session)ne7ssh_session
~ne7ssh_session()ne7ssh_session

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session.html deleted file mode 100644 index fec4e08805f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session.html +++ /dev/null @@ -1,494 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_session Class Reference - - - - - -
-

ne7ssh_session Class Reference

#include <ne7ssh_session.h> -

-

-Collaboration diagram for ne7ssh_session:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_session ()
 ~ne7ssh_session ()
void setLocalVersion (Botan::SecureVector< Botan::byte > &version)
Botan::SecureVector
-< Botan::byte > & 
getLocalVersion ()
void setRemoteVersion (Botan::SecureVector< Botan::byte > &version)
Botan::SecureVector
-< Botan::byte > & 
getRemoteVersion ()
void setSessionID (Botan::SecureVector< Botan::byte > &session)
Botan::SecureVector
-< Botan::byte > & 
getSessionID ()
void setSendChannel (uint32 channel)
uint32 getSendChannel () const
void setReceiveChannel (uint32 channel)
uint32 getReceiveChannel ()
void setMaxPacket (uint32 size)
uint32 getMaxPacket ()
void setSshChannel (int32 channel)
int32 getSshChannel ()

Public Attributes

-ne7ssh_transporttransport
-ne7ssh_cryptcrypto

Private Attributes

-Botan::SecureVector< Botan::byte > localVersion
-Botan::SecureVector< Botan::byte > remoteVersion
-Botan::SecureVector< Botan::byte > sessionID
-uint32 sendChannel
-uint32 receiveChannel
-uint32 maxPacket
-int32 channelID
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh_session::ne7ssh_session (  ) 
-
-
- -

-ne7ssh_session class constructor. -

-

- -

-
- - - - - - - - -
ne7ssh_session::~ne7ssh_session (  ) 
-
-
- -

-ne7ssh_session class desctructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_session::getLocalVersion (  )  [inline]
-
-
- -

-Returns local SSH version.

Returns:
Reference to a vector containing the version string.
- -

Referenced by ne7ssh_kex::makeH().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_session::getMaxPacket (  )  [inline]
-
-
- -

-Returns maximum send packet size.

Returns:
Maximum packet size.
- -

Referenced by ne7ssh_channel::sendAdjustWindow(), and ne7ssh_channel::write().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_session::getReceiveChannel (  )  [inline]
-
-
- -

-Returns the receive channel ID.

Returns:
Channel ID.
- -
-

- -

-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_session::getRemoteVersion (  )  [inline]
-
-
- -

-Returns remote SSH version.

Returns:
Reference to a vector containing the version string.
- -

Referenced by ne7ssh_kex::makeH().

- -
-

- -

- -

-
- - - - - - - - -
Botan::SecureVector<Botan::byte>& ne7ssh_session::getSessionID (  )  [inline]
-
-
- -

-Returns the current SSH session ID.

Returns:
Reference to a vector containing the session ID.
- -

Referenced by ne7ssh_connection::authWithKey(), and ne7ssh_crypt::compute_key().

- -
-

- -

-
- - - - - - - - -
int32 ne7ssh_session::getSshChannel (  )  [inline]
-
-
- -

-REtrieves current ne7ssh channel.

Returns:
ne7ssh channel or -1 if the session hasn't succesfully opened the channel yet.
- -

Referenced by ne7ssh_connection::authWithKey(), Ne7sshSftp::cd(), ne7ssh_connection::checkRemoteVersion(), Ne7sshSftp::chmod(), Ne7sshSftp::chown(), Ne7sshSftp::closeFile(), ne7ssh_crypt::compute_key(), ne7ssh_crypt::computeH(), ne7ssh_channel::execCmd(), Ne7sshSftp::get(), ne7ssh_crypt::getCryptAlgo(), Ne7sshSftp::getFileAttrs(), Ne7sshSftp::getFileHandle(), Ne7sshSftp::getFileSize(), Ne7sshSftp::getFileStats(), Ne7sshSftp::getFStat(), ne7ssh_crypt::getHashAlgo(), ne7ssh_crypt::getHmacAlgo(), ne7ssh_crypt::getKexPublic(), ne7ssh_crypt::getMacKeyLen(), Ne7sshSftp::handleData(), ne7ssh_channel::handleData(), ne7ssh_channel::handleDisconnect(), ne7ssh_channel::handleEof(), ne7ssh_channel::handleExtendedData(), ne7ssh_kex::handleInit(), ne7ssh_channel::handleReceived(), ne7ssh_channel::handleRequest(), Ne7sshSftp::handleSftpData(), Ne7sshSftp::handleStatus(), Ne7sshSftp::handleVersion(), Ne7sshSftp::isType(), Ne7sshSftp::ls(), Ne7sshSftp::mkdir(), Ne7sshSftp::mv(), ne7ssh_crypt::negotiatedCmprsC2s(), ne7ssh_crypt::negotiatedCmprsS2c(), ne7ssh_crypt::negotiatedCryptoC2s(), ne7ssh_crypt::negotiatedCryptoS2c(), ne7ssh_crypt::negotiatedHostkey(), ne7ssh_crypt::negotiatedKex(), ne7ssh_crypt::negotiatedMacC2s(), ne7ssh_crypt::negotiatedMacS2c(), Ne7sshSftp::openDir(), Ne7sshSftp::openFile(), Ne7sshSftp::put(), Ne7sshSftp::readFile(), Ne7sshSftp::receiveWindowAdjust(), ne7ssh_connection::requestService(), Ne7sshSftp::rm(), Ne7sshSftp::rmdir(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), ne7ssh_kex::sendKexNewKeys(), ne7ssh_connection::startSftp(), ne7ssh_crypt::verifySig(), and Ne7sshSftp::writeFile().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setLocalVersion (Botan::SecureVector< Botan::byte > &  version  )  [inline]
-
-
- -

-Sets the local SSH version string.

Parameters:
- - -
version Reference to a vector containing the version string.
-
- -

Referenced by ne7ssh_connection::sendLocalVersion().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setMaxPacket (uint32  size  )  [inline]
-
-
- -

-Sets maximum send packet size.

Parameters:
- - -
size Maximum packet size.
-
- -

Referenced by ne7ssh_channel::handleChannelConfirm().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setReceiveChannel (uint32  channel  )  [inline]
-
-
- -

-After the channel is open this function sets the receive channel ID.

Parameters:
- - -
channel Channel ID.
-
- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setRemoteVersion (Botan::SecureVector< Botan::byte > &  version  )  [inline]
-
-
- -

-Sets the remote SSH version string.

Parameters:
- - -
version Reference to a vector containing the version string.
-
- -

Referenced by ne7ssh_connection::checkRemoteVersion().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setSendChannel (uint32  channel  )  [inline]
-
-
- -

-After the channel is open this function sets the send channel ID.

Parameters:
- - -
channel Channel ID.
-
- -

Referenced by ne7ssh_channel::handleChannelConfirm().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setSessionID (Botan::SecureVector< Botan::byte > &  session  )  [inline]
-
-
- -

-Sets SSH session ID, a.k.a. H from the first KEX.

Parameters:
- - -
session Reference to a vector containing the session ID.
-
- -

Referenced by ne7ssh_kex::handleKexDHReply().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_session::setSshChannel (int32  channel  )  [inline]
-
-
- -

-Stores newly created ne7ssh channel.

Parameters:
- - -
channel ne7ssh channel.
-
- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.map deleted file mode 100644 index 1d4d8540da5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.md5 deleted file mode 100644 index eb206efc763..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__session__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -5a1d3b6712725f15bca94f2095e25ebe \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string-members.html deleted file mode 100644 index 33c19412b92..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string-members.html +++ /dev/null @@ -1,61 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_string Member List

This is the complete list of members for ne7ssh_string, including all inherited members.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
addBigInt(const Botan::BigInt &bn)ne7ssh_string
addBytes(const Botan::byte *buff, uint32 len)ne7ssh_string
addChar(const char ch)ne7ssh_string
addFile(const char *filename)ne7ssh_string
addInt(const uint32 var)ne7ssh_string
addString(const char *str)ne7ssh_string
addVector(Botan::SecureVector< Botan::byte > &secvec)ne7ssh_string
addVectorField(const Botan::SecureVector< Botan::byte > &vector)ne7ssh_string
bn2vector(Botan::SecureVector< Botan::byte > &result, const Botan::BigInt &bi)ne7ssh_string [static]
buffer (defined in ne7ssh_string)ne7ssh_string [protected]
chop(uint32 nBytes)ne7ssh_string
clear()ne7ssh_string [inline]
currentPart (defined in ne7ssh_string)ne7ssh_string [private]
getBigInt(Botan::BigInt &result)ne7ssh_string
getByte()ne7ssh_string
getInt()ne7ssh_string
getString(Botan::SecureVector< Botan::byte > &result)ne7ssh_string
length()ne7ssh_string [inline]
ne7ssh_string()ne7ssh_string
ne7ssh_string(Botan::SecureVector< Botan::byte > &var, uint32 position)ne7ssh_string
ne7ssh_string(const char *var, uint32 position)ne7ssh_string
nextPart()ne7ssh_string
parts (defined in ne7ssh_string)ne7ssh_string [private]
positions (defined in ne7ssh_string)ne7ssh_string [private]
resetParts()ne7ssh_string [inline]
split(const char token)ne7ssh_string
value()ne7ssh_string [inline, virtual]
~ne7ssh_string()ne7ssh_string [virtual]

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string.html deleted file mode 100644 index 01a716a2628..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string.html +++ /dev/null @@ -1,766 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_string Class Reference - - - - - -
-

ne7ssh_string Class Reference

#include <ne7ssh_string.h> -

-

-Inheritance diagram for ne7ssh_string:
-
-

Inheritance graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_string ()
 ne7ssh_string (Botan::SecureVector< Botan::byte > &var, uint32 position)
 ne7ssh_string (const char *var, uint32 position)
virtual ~ne7ssh_string ()
void clear ()
void addString (const char *str)
bool addFile (const char *filename)
void addBytes (const Botan::byte *buff, uint32 len)
void addVector (Botan::SecureVector< Botan::byte > &secvec)
void addVectorField (const Botan::SecureVector< Botan::byte > &vector)
void addChar (const char ch)
void addInt (const uint32 var)
void addBigInt (const Botan::BigInt &bn)
virtual Botan::SecureVector
-< Botan::byte > & 
value ()
uint32 length ()
bool getString (Botan::SecureVector< Botan::byte > &result)
bool getBigInt (Botan::BigInt &result)
uint32 getInt ()
Botan::byte getByte ()
void split (const char token)
void resetParts ()
char * nextPart ()
void chop (uint32 nBytes)

Static Public Member Functions

static void bn2vector (Botan::SecureVector< Botan::byte > &result, const Botan::BigInt &bi)

Protected Attributes

-Botan::SecureVector< Botan::byte > buffer

Private Attributes

-Botan::byte ** positions
-uint32 parts
-uint32 currentPart
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - -
ne7ssh_string::ne7ssh_string (  ) 
-
-
- -

-ne7ssh_string class default consturctor.

-Zeros out 'positions' and 'parts'. -

-

- -

-
- - - - - - - - - - - - - - - - - - -
ne7ssh_string::ne7ssh_string (Botan::SecureVector< Botan::byte > &  var,
uint32  position 
)
-
-
- -

-ne7ssh_string class consturctor.

-Takes a vector as an argument and places the data into 'buffer'.

Parameters:
- - - -
var Reference to a vector containing a string.
position Position in the vector to start reading from. If '0', the entire vector is dumped into 'buffer'.
-
- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
ne7ssh_string::ne7ssh_string (const char *  var,
uint32  position 
)
-
-
- -

-Same as above costructor, but instead of vector it works with a string (const char*).

Parameters:
- - - -
var Pointer to a string terminated by '/0'.
position Read from this position onwards.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_string::~ne7ssh_string (  )  [virtual]
-
-
- -

-ne7ssh_string class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - -
void ne7ssh_string::addBigInt (const Botan::BigInt &  bn  ) 
-
-
- -

-Adds a BigInt variable to the buffer.

-BigInt is first converted to a vector, then the integer, representing length of the vector is converted to the network format. Converted ingeger is added to the buffer, followed by the vector.

Parameters:
- - -
bn Reference to BigInt variable.
-
- -

References bn2vector().

- -

Referenced by ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::getDSAKeys(), ne7ssh_keys::getRSAKeys(), and ne7ssh_kex::sendKexDHInit().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void ne7ssh_string::addBytes (const Botan::byte *  buff,
uint32  len 
)
-
-
- -

-Adds a byte stream to the buffer.

Parameters:
- - - -
buff Pointer to the byte stream.
len Length of the byte stream.
-
- -

Referenced by Ne7sshSftpPacket::addInt64(), ne7ssh_kex::constructLocalKex(), ne7ssh_kex::handleInit(), and ne7ssh_transport::sendPacket().

- -
-

- -

- -

-
- - - - - - - - - -
bool ne7ssh_string::addFile (const char *  filename  ) 
-
-
- -

-Reads content of an ASCII file and appends it to the buffer.

Parameters:
- - -
filename Full path to ASCII file.
-
-
Returns:
True is file is successfully read. Otherwise False is returned.
- -

References ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by ne7ssh_keys::getKeyPairFromFile().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_string::addInt (const uint32  var  ) 
-
- -

- -

-
- - - - - - - - - -
void ne7ssh_string::addString (const char *  str  ) 
-
-
- -

-Adds a string to the buffer.

-Adds an integer representing the length of the string, converted to the network format, before the actual string data. Required by SSH protocol specifications.

Parameters:
- - -
str pointer to a string.
-
- -

References value().

- -

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), ne7ssh_kex::constructLocalKex(), ne7ssh_channel::execCmd(), ne7ssh_keys::generateDSAKeys(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSAKeys(), ne7ssh_keys::generateRSASignature(), ne7ssh_keys::getDSAKeys(), ne7ssh_keys::getRSAKeys(), ne7ssh_channel::getShell(), Ne7sshSftp::init(), ne7ssh_channel::open(), and ne7ssh_connection::requestService().

- -
-

- -

- -

-
- - - - - - - - - -
void ne7ssh_string::addVectorField (const Botan::SecureVector< Botan::byte > &  vector  ) 
-
-
- -

-Adds a vector to the buffer.

-Adds an integer representing the length of the vector, converted to the network format, before the actual data. Required by SSH protocol specifications.

Parameters:
- - -
vector Reference to a vector.
-
- -

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_crypt::compute_key(), ne7ssh_kex::constructLocalKex(), ne7ssh_keys::generateDSASignature(), ne7ssh_keys::generateRSASignature(), Ne7sshSftp::handleNames(), ne7ssh_kex::makeH(), ne7ssh_channel::sendAll(), Ne7sshSftpPacket::value(), and Ne7sshSftpPacket::valueFragment().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
void ne7ssh_string::bn2vector (Botan::SecureVector< Botan::byte > &  result,
const Botan::BigInt &  bi 
) [static]
-
-
- -

-Converts BigInt into vector

-For internal use only

Parameters:
- - - -
result Reference to vector where the converted result will be dumped.
bi Reference to BigInt to convert.
-
- -

Referenced by addBigInt(), ne7ssh_kex::handleKexDHReply(), ne7ssh_crypt::makeKexSecret(), and ne7ssh_kex::sendKexDHInit().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_string::chop (uint32  nBytes  ) 
-
-
- -

-Chops bytes off of the end of the buffer.

Parameters:
- - -
nBytes How many bytes to chop off the end of the buffer.
-
- -

Referenced by ne7ssh_channel::handleData().

- -
-

- -

- -

-
- - - - - - - - - -
bool ne7ssh_string::getBigInt (Botan::BigInt &  result  ) 
-
-
- -

-Extracts a single BigInt variable from the payload field of SSH packet.

Parameters:
- - -
result Reference to a BigInt variable where the result will be stored.
-
-
Returns:
True if BigInt field was found and successfully parsed, otherwise false is returned.
- -

Referenced by ne7ssh_crypt::getDSAKey(), ne7ssh_crypt::getRSAKey(), and ne7ssh_kex::handleKexDHReply().

- -
-

- -

-
- - - - - - - - -
Botan::byte ne7ssh_string::getByte (  ) 
-
-
- -

-Extracts a single byte from tje payload field of SSH packet.

Returns:
A byte extracted from thenext byte of the payload.
- -

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), Ne7sshSftp::handleData(), ne7ssh_channel::handleReceived(), and ne7ssh_channel::handleRequest().

- -
-

- -

-
- - - - - - - - -
uint32 ne7ssh_string::getInt (  ) 
-
- -

- -

-
- - - - - - - - - -
bool ne7ssh_string::getString (Botan::SecureVector< Botan::byte > &  result  ) 
-
- -

- -

- -

-
- - - - - - - - -
char * ne7ssh_string::nextPart (  ) 
-
-
- -

-Returns the next part.

Returns:
NULL terminated string, or 0 if this is the last part.
- -

Referenced by ne7ssh_crypt::agree(), and ne7ssh_kex::constructLocalKex().

- -
-

- -

-
- - - - - - - - -
void ne7ssh_string::resetParts (  )  [inline]
-
-
- -

-Returns to the first part. -

Referenced by ne7ssh_crypt::agree(), and ne7ssh_kex::constructLocalKex().

- -
-

- -

-
- - - - - - - - - -
void ne7ssh_string::split (const char  token  ) 
-
-
- -

-Splits the buffer into strings separated by null character.

Parameters:
- - -
token Searches for this character in the buffer, replaces it with null and creates a part index.
-
- -

Referenced by ne7ssh_crypt::agree(), and ne7ssh_kex::constructLocalKex().

- -
-

- -

-
- - - - - - - - -
virtual Botan::SecureVector<Botan::byte>& ne7ssh_string::value (  )  [inline, virtual]
-
- -

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.map deleted file mode 100644 index b662f1b05f1..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.md5 deleted file mode 100644 index 208ee6645fa..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__string__inherit__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -3edbca75c8429aa19fa0d66169573383 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport-members.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport-members.html deleted file mode 100644 index 3f6e454a251..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport-members.html +++ /dev/null @@ -1,50 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

ne7ssh_transport Member List

This is the complete list of members for ne7ssh_transport, including all inherited members.

- - - - - - - - - - - - - - - - - -
establish(const char *host, uint32 port, int timeout=0)ne7ssh_transport
getPacket(Botan::SecureVector< Botan::byte > &result)ne7ssh_transport
haveData()ne7ssh_transport
in (defined in ne7ssh_transport)ne7ssh_transport [private]
inBuffer (defined in ne7ssh_transport)ne7ssh_transport [private]
ne7ssh_transport(ne7ssh_session *_session)ne7ssh_transport
NoBlock(SOCKET socket, bool on)ne7ssh_transport [private]
receive(Botan::SecureVector< Botan::byte > &buffer, bool append=false)ne7ssh_transport
rSeq (defined in ne7ssh_transport)ne7ssh_transport [private]
send(Botan::SecureVector< Botan::byte > &buffer)ne7ssh_transport
sendPacket(Botan::SecureVector< Botan::byte > &buffer)ne7ssh_transport
seq (defined in ne7ssh_transport)ne7ssh_transport [private]
session (defined in ne7ssh_transport)ne7ssh_transport [private]
sock (defined in ne7ssh_transport)ne7ssh_transport [private]
wait(SOCKET socket, int rw, int timeout=-1)ne7ssh_transport [private]
waitForPacket(Botan::byte cmd, bool bufferOnly=false)ne7ssh_transport
~ne7ssh_transport()ne7ssh_transport

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport.html b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport.html deleted file mode 100644 index a33eb0c00c4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport.html +++ /dev/null @@ -1,466 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_transport Class Reference - - - - - -
-

ne7ssh_transport Class Reference

#include <ne7ssh_transport.h> -

-

-Collaboration diagram for ne7ssh_transport:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Public Member Functions

 ne7ssh_transport (ne7ssh_session *_session)
 ~ne7ssh_transport ()
SOCKET establish (const char *host, uint32 port, int timeout=0)
bool receive (Botan::SecureVector< Botan::byte > &buffer, bool append=false)
bool send (Botan::SecureVector< Botan::byte > &buffer)
bool sendPacket (Botan::SecureVector< Botan::byte > &buffer)
short waitForPacket (Botan::byte cmd, bool bufferOnly=false)
uint32 getPacket (Botan::SecureVector< Botan::byte > &result)
bool haveData ()

Private Member Functions

bool NoBlock (SOCKET socket, bool on)
bool wait (SOCKET socket, int rw, int timeout=-1)

Private Attributes

-uint32 seq
-uint32 rSeq
-const ne7ssh_sessionsession
-SOCKET sock
-Botan::SecureVector< Botan::byte > in
-Botan::SecureVector< Botan::byte > inBuffer
-


Detailed Description

-
Author:
Andrew Useckas
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
ne7ssh_transport::ne7ssh_transport (ne7ssh_session _session  ) 
-
-
- -

-ne7ssh_transport class constructor.

-Transport class handles all socket communications for the ne7ssh library.

Parameters:
- - -
_session Pointer to ne7ssh_session instance.
-
- -
-

- -

-
- - - - - - - - -
ne7ssh_transport::~ne7ssh_transport (  ) 
-
-
- -

-ne7ssh_transport class destructor. -

-

-


Member Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
SOCKET ne7ssh_transport::establish (const char *  host,
uint32  port,
int  timeout = 0 
)
-
-
- -

-Establishes connection to a remote host.

Parameters:
- - - - -
host Host name or IP.
port Port.
timeout Timeout for the establish procedure, in seconds.
-
-
Returns:
Socket number or -1 on failure.
- -

References ne7ssh::errors(), NoBlock(), and Ne7sshError::push().

- -

Referenced by ne7ssh_connection::connectWithKey(), and ne7ssh_connection::connectWithPassword().

- -
-

- -

-
- - - - - - - - - -
uint32 ne7ssh_transport::getPacket (Botan::SecureVector< Botan::byte > &  result  ) 
-
- -

- -

-
- - - - - - - - -
bool ne7ssh_transport::haveData (  ) 
-
-
- -

-Checks to see if there is more data to be read from the socket.

Returns:
True if there is data to be read, otherwise false is returned.
- -

References wait().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_transport::NoBlock (SOCKET  socket,
bool  on 
) [private]
-
-
- -

-Switches socket's NonBlocking option on or off.

Parameters:
- - - -
socket Socket number.
on If set to true, NonBlocking option will be turned on, and vice versa.
-
-
Returns:
True if options have been successfuly set, otherwise false is returned.
- -

References ne7ssh::errors(), and Ne7sshError::push().

- -

Referenced by establish().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
bool ne7ssh_transport::receive (Botan::SecureVector< Botan::byte > &  buffer,
bool  append = false 
)
-
-
- -

-Reads data from the socket.

Parameters:
- - - -
buffer The data will be placed here.
append If set to true, received data will be appended to the buffer, instead of overwriting it.
-
-
Returns:
True if data successfuly read, otherwise false is returned.
- -

References ne7ssh::errors(), Ne7sshError::push(), and wait().

- -

Referenced by ne7ssh_connection::checkRemoteVersion(), and waitForPacket().

- -
-

- -

-
- - - - - - - - - -
bool ne7ssh_transport::send (Botan::SecureVector< Botan::byte > &  buffer  ) 
-
-
- -

-Writes a buffer to the socket.

Parameters:
- - -
buffer Data to be written to the socket.
-
-
Returns:
True if data successful sent, otherwise false is returned.
- -

References ne7ssh::errors(), Ne7sshError::push(), and wait().

- -

Referenced by ne7ssh_connection::sendLocalVersion(), and sendPacket().

- -
-

- -

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - -
bool ne7ssh_transport::wait (SOCKET  socket,
int  rw,
int  timeout = -1 
) [private]
-
-
- -

-Waits for activity on a socket.

Parameters:
- - - - -
socket Socket number.
rw If set to true, checks if process can write to the socket, otherwise checks if there is data to be read from the socket.
timeout Desired timeout. By default the function will block until socket is ready for reading/writting. If set to '0', the function will return right away.
-
-
Returns:
True if socket is ready for reading/writting, otherwise false is returned.
- -

Referenced by haveData(), receive(), and send().

- -
-

- -

-
- - - - - - - - - - - - - - - - - - -
short ne7ssh_transport::waitForPacket (Botan::byte  cmd,
bool  bufferOnly = false 
)
-
-
- -

-Waits until specified type of packet is received.

-If cmd is 0, waits for the first available packet of any kind.

-Once the desired packet is received, it is decrypted / decommpressed, the hMac is checked, and dropped into inBuffer class variable.

Parameters:
- - - -
cmd SSH2 packet to wait for. If 0, first available packet will be read into inBuffer class variable.
bufferOnly Does not wait to receive a new packet, only checks existing receive buffer for unprocessed packets.
-
-
Returns:
1 if desired packet is received, 0 if there another packet is received, or -1 if HMAC checking is enabled, and remote and local HMACs do not match.
- -

References ne7ssh_crypt::computeMac(), ne7ssh_crypt::decryptPacket(), ne7ssh::errors(), ne7ssh_crypt::getDecryptBlock(), ne7ssh_crypt::getMacInLen(), ne7ssh_crypt::isInited(), Ne7sshError::push(), and receive().

- -

Referenced by ne7ssh_connection::authWithKey(), ne7ssh_connection::authWithPassword(), ne7ssh_channel::open(), ne7ssh_channel::receive(), Ne7sshSftp::receiveUntil(), Ne7sshSftp::receiveWhile(), Ne7sshSftp::receiveWindowAdjust(), ne7ssh_connection::requestService(), ne7ssh_kex::sendInit(), ne7ssh_kex::sendKexDHInit(), and ne7ssh_kex::sendKexNewKeys().

- -
-

-


The documentation for this class was generated from the following files: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.map deleted file mode 100644 index 0b572a73e88..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.md5 deleted file mode 100644 index aa00e5ff508..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/classne7ssh__transport__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -7e399d8b6e7aaebcf329bfb9bf88132f \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/crypt_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/crypt_8h_source.html deleted file mode 100644 index d49b70beaeb..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/crypt_8h_source.html +++ /dev/null @@ -1,192 +0,0 @@ - - -ne7ssh.kdevelop: crypt.h Source File - - - - - -
-

crypt.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef CRYPT_H
-00018 #define CRYPT_H
-00019 
-00020 #include <botan/dl_group.h>
-00021 #include <botan/dh.h>
-00022 #include <botan/pubkey.h>
-00023 #include <botan/lookup.h>
-00024 #include <botan/dsa.h>
-00025 #include <botan/rsa.h>
-00026 #include <botan/look_pk.h>
-00027 #include <botan/pubkey.h>
-00028 
-00029 
-00030 // #if defined(BOTAN_EXT_COMPRESSOR_ZLIB)
-00031 //   #include <botan/zlib.h>
-00032 // #else
-00033 //   #error "Zlib support is not compiled into Botan"
-00034 // #endif
-00035 
-00036 #include <botan/cbc.h>
-00037 #include <botan/hmac.h>
-00038 
-00039 #include "ne7ssh_types.h"
-00040 #include "ne7ssh_string.h"
-00041 
-00042 class ne7ssh_session;
-00043 
-00047 class ne7ssh_crypt
-00048 {
-00049   private:
-00050     ne7ssh_session* session;
-00051 
-00052     enum kexMethods { DH_GROUP1_SHA1, DH_GROUP14_SHA1 };
-00053     uint32 kexMethod;
-00054 
-00055     enum hostkeyMethods { SSH_DSS, SSH_RSA };
-00056     uint32 hostkeyMethod;
-00057 
-00058     enum cryptoMethods { TDES_CBC, AES128_CBC, AES192_CBC, AES256_CBC, BLOWFISH_CBC, CAST128_CBC, TWOFISH_CBC };
-00059     uint32 c2sCryptoMethod;
-00060     uint32 s2cCryptoMethod;
-00061 
-00062     enum macMethods { HMAC_SHA1, HMAC_MD5, HMAC_NONE };
-00063     uint32 c2sMacMethod;
-00064     uint32 s2cMacMethod; 
-00065 
-00066     enum cmprsMethods { NONE, ZLIB };
-00067     uint32 c2sCmprsMethod;
-00068     uint32 s2cCmprsMethod; 
-00069 
-00070     bool inited;
-00071     Botan::SecureVector<Botan::byte> H;
-00072     Botan::SecureVector<Botan::byte> K;
-00073 
-00074     Botan::Pipe *encrypt;
-00075     Botan::Pipe *decrypt;
-00076     Botan::Pipe *compress;
-00077     Botan::Pipe *decompress;
-00078     Botan::HMAC *hmacOut, *hmacIn;
-00079 
-00080     Botan::DH_PrivateKey *privKexKey;
-00081 
-00082     uint32 encryptBlock;
-00083     uint32 decryptBlock;
-00084 
-00090     bool getDHGroup1Sha1Public (Botan::BigInt& publicKey);
-00091 
-00097     bool getDHGroup14Sha1Public (Botan::BigInt &publicKey);
-00098 
-00104     Botan::DSA_PublicKey* getDSAKey (Botan::SecureVector<Botan::byte>& hostKey);
-00105 
-00111     Botan::RSA_PublicKey* getRSAKey (Botan::SecureVector<Botan::byte> &hostKey);
-00112 
-00117     const char* getHashAlgo();
-00118 
-00124     const char* getCryptAlgo (uint32 crypto);
-00125 
-00131     const char* getHmacAlgo (uint32 method);
-00132 
-00139     uint32 getMacKeyLen (uint32 method);
-00140 
-00147     uint32 getMacDigestLen (uint32 method);
-00148 
-00157     bool compute_key (Botan::SecureVector<Botan::byte>& key, Botan::byte ID, uint32 nBytes);
-00158 
-00159 
-00160   public:
-00165     ne7ssh_crypt(ne7ssh_session* _session);
-00166 
-00170     ~ne7ssh_crypt();
-00171 
-00177     bool isInited () { return inited; }
-00178 
-00183     uint32 getEncryptBlock () { return encryptBlock; }
-00184 
-00189     uint32 getDecryptBlock () { return decryptBlock; }
-00190 
-00195     uint32 getMacOutLen () { return getMacDigestLen (c2sMacMethod); }
-00196 
-00201     uint32 getMacInLen () { return getMacDigestLen (s2cMacMethod); }
-00202 
-00210     bool agree (Botan::SecureVector<Botan::byte>& result, const char* local, Botan::SecureVector<Botan::byte>& remote);
-00211 
-00217     bool negotiatedKex (Botan::SecureVector<Botan::byte>& kexAlgo);
-00218 
-00224     bool negotiatedHostkey (Botan::SecureVector<Botan::byte>& hostKeyAlgo);
-00225 
-00231     bool negotiatedCryptoC2s (Botan::SecureVector<Botan::byte>& cryptoAlgo);
-00232 
-00238     bool negotiatedCryptoS2c (Botan::SecureVector<Botan::byte>& cryptoAlgo);
-00239 
-00245     bool negotiatedMacC2s (Botan::SecureVector<Botan::byte>& macAlgo);
-00246 
-00252     bool negotiatedMacS2c (Botan::SecureVector<Botan::byte>& macAlgo);
-00253 
-00259     bool negotiatedCmprsC2s (Botan::SecureVector<Botan::byte>& cmprsAlgo);
-00260 
-00266     bool negotiatedCmprsS2c (Botan::SecureVector<Botan::byte>& cmprsAlgo);
-00267 
-00273     bool getKexPublic (Botan::BigInt& publicKey);
-00274 
-00281     bool makeKexSecret (Botan::SecureVector<Botan::byte>& result, Botan::BigInt& f);
-00282 
-00289     bool computeH (Botan::SecureVector<Botan::byte>& result, Botan::SecureVector<Botan::byte>& val);
-00290 
-00297     bool verifySig (Botan::SecureVector<Botan::byte>& hostKey, Botan::SecureVector<Botan::byte>& sig);
-00298 
-00303     bool makeNewKeys ();
-00304 
-00314     bool encryptPacket (Botan::SecureVector<Botan::byte>& crypted, Botan::SecureVector<Botan::byte>& hmac, Botan::SecureVector<Botan::byte>& packet, uint32 seq);
-00315 
-00323     bool decryptPacket (Botan::SecureVector<Botan::byte>& decrypted, Botan::SecureVector<Botan::byte>& packet, uint32 len);
-00324 
-00331     void computeMac (Botan::SecureVector<Botan::byte>& hmac, Botan::SecureVector<Botan::byte>& packet, uint32 seq);
-00332 
-00337     void compressData (Botan::SecureVector<Botan::byte>& buffer);
-00338 
-00343     void decompressData (Botan::SecureVector<Botan::byte>& buffer);
-00344 
-00349     bool isCompressed () { if (decompress) return true; else return false; }
-00350 
-00355 };
-00356 
-00357 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae.html b/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae.html deleted file mode 100644 index b58281d98aa..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae.html +++ /dev/null @@ -1,42 +0,0 @@ - - -ne7ssh.kdevelop: projects/ne7ssh/ Directory Reference - - - - - -
-

ne7ssh Directory Reference

-

-

-
-
-

projects/ne7ssh/
- - -
- - - - - -

Directories

directory  src
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae_dep.map b/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae_dep.map deleted file mode 100644 index ba754eabf37..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_0149abaf0c2b822b0c584e3b6dde2eae_dep.map +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5.html b/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5.html deleted file mode 100644 index a58bb3afbcf..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5.html +++ /dev/null @@ -1,42 +0,0 @@ - - -ne7ssh.kdevelop: projects/ Directory Reference - - - - - -
-

projects Directory Reference

-

-

-
-
-

projects/
- - -
- - - - - -

Directories

directory  ne7ssh
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5_dep.map b/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5_dep.map deleted file mode 100644 index c0ba7e87a72..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_dd1c5291a9065b7545d10d656e7badb5_dep.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5.html b/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5.html deleted file mode 100644 index 749b4ee316d..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5.html +++ /dev/null @@ -1,94 +0,0 @@ - - -ne7ssh.kdevelop: projects/ne7ssh/src/ Directory Reference - - - - - -
-

src Directory Reference

-

-

-
-
-

projects/ne7ssh/src/
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Files

file  crypt.cpp
file  crypt.h [code]
file  ne7ssh.cpp
file  ne7ssh.h [code]
file  ne7ssh_channel.cpp
file  ne7ssh_channel.h [code]
file  ne7ssh_connection.cpp
file  ne7ssh_connection.h [code]
file  ne7ssh_error.cpp
file  ne7ssh_error.h [code]
file  ne7ssh_kex.cpp
file  ne7ssh_kex.h [code]
file  ne7ssh_keys.cpp
file  ne7ssh_keys.h [code]
file  ne7ssh_mutex.cpp
file  ne7ssh_mutex.h [code]
file  ne7ssh_session.cpp
file  ne7ssh_session.h [code]
file  ne7ssh_sftp.cpp
file  ne7ssh_sftp.h [code]
file  ne7ssh_sftp_packet.cpp
file  ne7ssh_sftp_packet.h [code]
file  ne7ssh_string.cpp
file  ne7ssh_string.h [code]
file  ne7ssh_transport.cpp
file  ne7ssh_transport.h [code]
file  ne7ssh_types.h [code]
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5_dep.map b/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5_dep.map deleted file mode 100644 index ed6c1032bca..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dir_f38c3faaed4ee86c894d75645400fcb5_dep.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/dirs.html b/src/libs/3rdparty/net7ssh/doc/html/dirs.html deleted file mode 100644 index df0a6dc0f96..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/dirs.html +++ /dev/null @@ -1,34 +0,0 @@ - - -ne7ssh.kdevelop: Directory Hierarchy - - - - - -
-

Directories

This directory hierarchy is sorted roughly, but not completely, alphabetically: -
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/doxygen.css b/src/libs/3rdparty/net7ssh/doc/html/doxygen.css deleted file mode 100644 index 3767dc957b0..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/doxygen.css +++ /dev/null @@ -1,441 +0,0 @@ -body, table, div, p, dl { - font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; - font-size: 12px; -} - -/* @group Heading Levels */ - -h1 { - text-align: center; - font-size: 150%; -} - -h2 { - font-size: 120%; -} - -h3 { - font-size: 100%; -} - -/* @end */ - -caption { - font-weight: bold; -} - -div.qindex, div.navtab{ - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - padding: 2px; -} - -div.qindex, div.navpath { - width: 100%; - line-height: 140%; -} - -div.navtab { - margin-right: 15px; -} - -/* @group Link Styling */ - -a { - color: #153788; - font-weight: normal; - text-decoration: none; -} - -.contents a:visited { - color: #1b77c5; -} - -a:hover { - text-decoration: underline; -} - -a.qindex { - font-weight: bold; -} - -a.qindexHL { - font-weight: bold; - background-color: #6666cc; - color: #ffffff; - border: 1px double #9295C2; -} - -.contents a.qindexHL:visited { - color: #ffffff; -} - -a.el { - font-weight: bold; -} - -a.elRef { -} - -a.code { -} - -a.codeRef { -} - -/* @end */ - -dl.el { - margin-left: -1cm; -} - -.fragment { - font-family: monospace, fixed; - font-size: 105%; -} - -pre.fragment { - border: 1px solid #CCCCCC; - background-color: #f5f5f5; - padding: 4px 6px; - margin: 4px 8px 4px 2px; -} - -div.ah { - background-color: black; - font-weight: bold; - color: #ffffff; - margin-bottom: 3px; - margin-top: 3px -} - -div.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold; -} - -div.groupText { - margin-left: 16px; - font-style: italic; -} - -body { - background: white; - color: black; - margin-right: 20px; - margin-left: 20px; -} - -td.indexkey { - background-color: #e8eef2; - font-weight: bold; - border: 1px solid #CCCCCC; - margin: 2px 0px 2px 0; - padding: 2px 10px; -} - -td.indexvalue { - background-color: #e8eef2; - border: 1px solid #CCCCCC; - padding: 2px 10px; - margin: 2px 0px; -} - -tr.memlist { - background-color: #f0f0f0; -} - -p.formulaDsp { - text-align: center; -} - -img.formulaDsp { - -} - -img.formulaInl { - vertical-align: middle; -} - -/* @group Code Colorization */ - -span.keyword { - color: #008000 -} - -span.keywordtype { - color: #604020 -} - -span.keywordflow { - color: #e08000 -} - -span.comment { - color: #800000 -} - -span.preprocessor { - color: #806020 -} - -span.stringliteral { - color: #002080 -} - -span.charliteral { - color: #008080 -} - -span.vhdldigit { - color: #ff00ff -} - -span.vhdlchar { - color: #000000 -} - -span.vhdlkeyword { - color: #700070 -} - -span.vhdllogic { - color: #ff0000 -} - -/* @end */ - -.search { - color: #003399; - font-weight: bold; -} - -form.search { - margin-bottom: 0px; - margin-top: 0px; -} - -input.search { - font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; -} - -td.tiny { - font-size: 75%; -} - -.dirtab { - padding: 4px; - border-collapse: collapse; - border: 1px solid #84b0c7; -} - -th.dirtab { - background: #e8eef2; - font-weight: bold; -} - -hr { - height: 0; - border: none; - border-top: 1px solid #666; -} - -/* @group Member Descriptions */ - -.mdescLeft, .mdescRight, -.memItemLeft, .memItemRight, -.memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #FAFAFA; - border: none; - margin: 4px; - padding: 1px 0 0 8px; -} - -.mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; -} - -.memItemLeft, .memItemRight, .memTemplParams { - border-top: 1px solid #ccc; -} - -.memTemplParams { - color: #606060; -} - -/* @end */ - -/* @group Member Details */ - -/* Styles for detailed member documentation */ - -.memtemplate { - font-size: 80%; - color: #606060; - font-weight: normal; - margin-left: 3px; -} - -.memnav { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} - -.memitem { - padding: 0; -} - -.memname { - white-space: nowrap; - font-weight: bold; -} - -.memproto, .memdoc { - border: 1px solid #84b0c7; -} - -.memproto { - padding: 0; - background-color: #d5e1e8; - font-weight: bold; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - -moz-border-radius-topleft: 8px; - -moz-border-radius-topright: 8px; -} - -.memdoc { - padding: 2px 5px; - background-color: #eef3f5; - border-top-width: 0; - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - -moz-border-radius-bottomleft: 8px; - -moz-border-radius-bottomright: 8px; -} - -.paramkey { - text-align: right; -} - -.paramtype { - white-space: nowrap; -} - -.paramname { - color: #602020; - white-space: nowrap; -} -.paramname em { - font-style: normal; -} - -/* @end */ - -/* @group Directory (tree) */ - -/* for the tree view */ - -.ftvtree { - font-family: sans-serif; - margin: 0.5em; -} - -/* these are for tree view when used as main index */ - -.directory { - font-size: 9pt; - font-weight: bold; -} - -.directory h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -/* -The following two styles can be used to replace the root node title -with an image of your choice. Simply uncomment the next two styles, -specify the name of your image and be sure to set 'height' to the -proper pixel height of your image. -*/ - -/* -.directory h3.swap { - height: 61px; - background-repeat: no-repeat; - background-image: url("yourimage.gif"); -} -.directory h3.swap span { - display: none; -} -*/ - -.directory > h3 { - margin-top: 0; -} - -.directory p { - margin: 0px; - white-space: nowrap; -} - -.directory div { - display: none; - margin: 0px; -} - -.directory img { - vertical-align: -30%; -} - -/* these are for tree view when not used as main index */ - -.directory-alt { - font-size: 100%; - font-weight: bold; -} - -.directory-alt h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -.directory-alt > h3 { - margin-top: 0; -} - -.directory-alt p { - margin: 0px; - white-space: nowrap; -} - -.directory-alt div { - display: none; - margin: 0px; -} - -.directory-alt img { - vertical-align: -30%; -} - -/* @end */ - -address { - font-style: normal; - color: #333; -} diff --git a/src/libs/3rdparty/net7ssh/doc/html/files.html b/src/libs/3rdparty/net7ssh/doc/html/files.html deleted file mode 100644 index 338df597d24..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/files.html +++ /dev/null @@ -1,46 +0,0 @@ - - -ne7ssh.kdevelop: File Index - - - - - -
-

File List

Here is a list of all documented files with brief descriptions: - - - - - - - - - - - - - - -
crypt.h [code]
ne7ssh.h [code]
ne7ssh_channel.h [code]
ne7ssh_connection.h [code]
ne7ssh_error.h [code]
ne7ssh_kex.h [code]
ne7ssh_keys.h [code]
ne7ssh_mutex.h [code]
ne7ssh_session.h [code]
ne7ssh_sftp.h [code]
ne7ssh_sftp_packet.h [code]
ne7ssh_string.h [code]
ne7ssh_transport.h [code]
ne7ssh_types.h [code]
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions.html b/src/libs/3rdparty/net7ssh/doc/html/functions.html deleted file mode 100644 index 2c0e0ae69f4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions.html +++ /dev/null @@ -1,97 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- a -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x62.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x62.html deleted file mode 100644 index c49ba01c070..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x62.html +++ /dev/null @@ -1,69 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- b -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x63.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x63.html deleted file mode 100644 index b0beb9cf0d9..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x63.html +++ /dev/null @@ -1,107 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- c -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x64.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x64.html deleted file mode 100644 index 46bd7dfd63a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x64.html +++ /dev/null @@ -1,80 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- d -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x65.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x65.html deleted file mode 100644 index 95871ef4e30..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x65.html +++ /dev/null @@ -1,79 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- e -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x67.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x67.html deleted file mode 100644 index 3d4ca3d7cbc..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x67.html +++ /dev/null @@ -1,180 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- g -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x68.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x68.html deleted file mode 100644 index bd0e22a478e..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x68.html +++ /dev/null @@ -1,99 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- h -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x69.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x69.html deleted file mode 100644 index 3b1959e33ee..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x69.html +++ /dev/null @@ -1,99 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- i -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6c.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x6c.html deleted file mode 100644 index 0dc8af8a486..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6c.html +++ /dev/null @@ -1,75 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- l -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6d.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x6d.html deleted file mode 100644 index f29e031dc16..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6d.html +++ /dev/null @@ -1,79 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- m -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6e.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x6e.html deleted file mode 100644 index b6e426508c7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6e.html +++ /dev/null @@ -1,113 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- n -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6f.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x6f.html deleted file mode 100644 index 5381ac7afc7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x6f.html +++ /dev/null @@ -1,75 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- o -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x70.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x70.html deleted file mode 100644 index 17aa639c291..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x70.html +++ /dev/null @@ -1,76 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- p -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x72.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x72.html deleted file mode 100644 index 906a41136ef..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x72.html +++ /dev/null @@ -1,93 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- r -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x73.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x73.html deleted file mode 100644 index 402d9d48213..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x73.html +++ /dev/null @@ -1,123 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- s -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x75.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x75.html deleted file mode 100644 index 168a83a13c0..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x75.html +++ /dev/null @@ -1,70 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- u -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x76.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x76.html deleted file mode 100644 index fa0714a7e62..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x76.html +++ /dev/null @@ -1,74 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- v -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x77.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x77.html deleted file mode 100644 index 5db1eed7af5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x77.html +++ /dev/null @@ -1,80 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- w -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_0x7e.html b/src/libs/3rdparty/net7ssh/doc/html/functions_0x7e.html deleted file mode 100644 index 40cd4ce5fd5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_0x7e.html +++ /dev/null @@ -1,93 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -

-

- ~ -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_enum.html b/src/libs/3rdparty/net7ssh/doc/html/functions_enum.html deleted file mode 100644 index e8ea3b1da79..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_enum.html +++ /dev/null @@ -1,46 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Enumerations - - - - - -
-  -

-

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func.html deleted file mode 100644 index faa8c4818ff..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func.html +++ /dev/null @@ -1,97 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- a -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x62.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x62.html deleted file mode 100644 index 9151f353652..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x62.html +++ /dev/null @@ -1,69 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- b -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x63.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x63.html deleted file mode 100644 index 0746f081a7b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x63.html +++ /dev/null @@ -1,103 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- c -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x64.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x64.html deleted file mode 100644 index 68c5bf05516..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x64.html +++ /dev/null @@ -1,80 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- d -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x65.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x65.html deleted file mode 100644 index 889de4d8ed6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x65.html +++ /dev/null @@ -1,77 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- e -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x67.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x67.html deleted file mode 100644 index ed7e15ae460..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x67.html +++ /dev/null @@ -1,180 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- g -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x68.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x68.html deleted file mode 100644 index 5d4474d3fb5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x68.html +++ /dev/null @@ -1,99 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- h -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x69.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x69.html deleted file mode 100644 index abaa6f5d958..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x69.html +++ /dev/null @@ -1,99 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- i -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6c.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6c.html deleted file mode 100644 index ecd17a0022c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6c.html +++ /dev/null @@ -1,75 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- l -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6d.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6d.html deleted file mode 100644 index 00c5331565c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6d.html +++ /dev/null @@ -1,79 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- m -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6e.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6e.html deleted file mode 100644 index f48e7975b6a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6e.html +++ /dev/null @@ -1,113 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- n -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6f.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6f.html deleted file mode 100644 index c6d4da4eef4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x6f.html +++ /dev/null @@ -1,75 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- o -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x70.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x70.html deleted file mode 100644 index 5724154bc43..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x70.html +++ /dev/null @@ -1,76 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- p -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x72.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x72.html deleted file mode 100644 index 2cdf7c35fa0..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x72.html +++ /dev/null @@ -1,93 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- r -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x73.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x73.html deleted file mode 100644 index 8e8e3571c78..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x73.html +++ /dev/null @@ -1,123 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- s -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x75.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x75.html deleted file mode 100644 index 0548b8639ba..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x75.html +++ /dev/null @@ -1,70 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- u -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x76.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x76.html deleted file mode 100644 index 69c4883da15..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x76.html +++ /dev/null @@ -1,74 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- v -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x77.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x77.html deleted file mode 100644 index 4cd1330ec9a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x77.html +++ /dev/null @@ -1,78 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- w -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x7e.html b/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x7e.html deleted file mode 100644 index 6320d9440f7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_func_0x7e.html +++ /dev/null @@ -1,93 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Functions - - - - - -
-  -

-

- ~ -

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/functions_vars.html b/src/libs/3rdparty/net7ssh/doc/html/functions_vars.html deleted file mode 100644 index 6e33fd3f414..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/functions_vars.html +++ /dev/null @@ -1,50 +0,0 @@ - - -ne7ssh.kdevelop: Class Members - Variables - - - - - -
-  -

-

-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/graph_legend.dot b/src/libs/3rdparty/net7ssh/doc/html/graph_legend.dot deleted file mode 100644 index 9a09018a423..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/graph_legend.dot +++ /dev/null @@ -1,22 +0,0 @@ -digraph G -{ - edge [fontname="FreeSans",fontsize="10",labelfontname="FreeSans",labelfontsize="10"]; - node [fontname="FreeSans",fontsize="10",shape=record]; - Node9 [shape="box",label="Inherited",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",fillcolor="grey75",style="filled" fontcolor="black"]; - Node10 -> Node9 [dir=back,color="midnightblue",fontsize="10",style="solid",fontname="FreeSans"]; - Node10 [shape="box",label="PublicBase",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classPublicBase.html"]; - Node11 -> Node10 [dir=back,color="midnightblue",fontsize="10",style="solid",fontname="FreeSans"]; - Node11 [shape="box",label="Truncated",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="red",URL="$classTruncated.html"]; - Node13 -> Node9 [dir=back,color="darkgreen",fontsize="10",style="solid",fontname="FreeSans"]; - Node13 [shape="box",label="ProtectedBase",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classProtectedBase.html"]; - Node14 -> Node9 [dir=back,color="firebrick4",fontsize="10",style="solid",fontname="FreeSans"]; - Node14 [shape="box",label="PrivateBase",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classPrivateBase.html"]; - Node15 -> Node9 [dir=back,color="midnightblue",fontsize="10",style="solid",fontname="FreeSans"]; - Node15 [shape="box",label="Undocumented",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="grey75"]; - Node16 -> Node9 [dir=back,color="midnightblue",fontsize="10",style="solid",fontname="FreeSans"]; - Node16 [shape="box",label="Templ< int >",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classTempl.html"]; - Node17 -> Node16 [dir=back,color="orange",fontsize="10",style="dashed",label="< int >",fontname="FreeSans"]; - Node17 [shape="box",label="Templ< T >",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classTempl.html"]; - Node18 -> Node9 [dir=back,color="darkorchid3",fontsize="10",style="dashed",label="m_usedClass",fontname="FreeSans"]; - Node18 [shape="box",label="Used",fontsize="10",height=0.2,width=0.4,fontname="FreeSans",color="black",URL="$classUsed.html"]; -} diff --git a/src/libs/3rdparty/net7ssh/doc/html/graph_legend.html b/src/libs/3rdparty/net7ssh/doc/html/graph_legend.html deleted file mode 100644 index d64d84e84f7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/graph_legend.html +++ /dev/null @@ -1,87 +0,0 @@ - - -ne7ssh.kdevelop: Graph Legend - - - - - -
-

Graph Legend

This page explains how to interpret the graphs that are generated by doxygen.

-Consider the following example:

/*! Invisible class because of truncation */
-class Invisible { };
-
-/*! Truncated class, inheritance relation is hidden */
-class Truncated : public Invisible { };
-
-/* Class not documented with doxygen comments */
-class Undocumented { };
-
-/*! Class that is inherited using public inheritance */
-class PublicBase : public Truncated { };
-
-/*! A template class */
-template<class T> class Templ { };
-
-/*! Class that is inherited using protected inheritance */
-class ProtectedBase { };
-
-/*! Class that is inherited using private inheritance */
-class PrivateBase { };
-
-/*! Class that is used by the Inherited class */
-class Used { };
-
-/*! Super class that inherits a number of other classes */
-class Inherited : public PublicBase,
-                  protected ProtectedBase,
-                  private PrivateBase,
-                  public Undocumented,
-                  public Templ<int>
-{
-  private:
-    Used *m_usedClass;
-};
-
This will result in the following graph:

-

-graph_legend.png -
-

-The boxes in the above graph have the following meaning:

    -
  • -A filled gray box represents the struct or class for which the graph is generated.
  • -
  • -A box with a black border denotes a documented struct or class.
  • -
  • -A box with a grey border denotes an undocumented struct or class.
  • -
  • -A box with a red border denotes a documented struct or class forwhich not all inheritance/containment relations are shown. A graph is truncated if it does not fit within the specified boundaries.
  • -
-The arrows have the following meaning:
    -
  • -A dark blue arrow is used to visualize a public inheritance relation between two classes.
  • -
  • -A dark green arrow is used for protected inheritance.
  • -
  • -A dark red arrow is used for private inheritance.
  • -
  • -A purple dashed arrow is used if a class is contained or used by another class. The arrow is labeled with the variable(s) through which the pointed class or struct is accessible.
  • -
  • -A yellow dashed arrow denotes a relation between a template instance and the template class it was instantiated from. The arrow is labeled with the template parameters of the instance.
  • -
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/hierarchy.html b/src/libs/3rdparty/net7ssh/doc/html/hierarchy.html deleted file mode 100644 index 4ec6552d01b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/hierarchy.html +++ /dev/null @@ -1,58 +0,0 @@ - - -ne7ssh.kdevelop: Hierarchical Index - - - - - - -
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/index.html b/src/libs/3rdparty/net7ssh/doc/html/index.html deleted file mode 100644 index 82c22ca9f62..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - -ne7ssh.kdevelop: Main Page - - - - - -
-

ne7ssh.kdevelop Documentation

-

-

1.3.1

-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.map deleted file mode 100644 index 3009aad4f2f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.md5 deleted file mode 100644 index 13b09c8fef9..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__0.md5 +++ /dev/null @@ -1 +0,0 @@ -32272a437d808ca54d1aa16d1fdcf2eb \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.map deleted file mode 100644 index c42e0733bf4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.md5 deleted file mode 100644 index 5624ec9074f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__1.md5 +++ /dev/null @@ -1 +0,0 @@ -f86864cff4e18963b72fbace1c5228c2 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.map deleted file mode 100644 index 10a671a8c85..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.md5 deleted file mode 100644 index 069830d3364..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__10.md5 +++ /dev/null @@ -1 +0,0 @@ -08221d327d3eba0b917aace18b9b8cc1 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.map deleted file mode 100644 index 356017e409e..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.md5 deleted file mode 100644 index 461f240a934..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__11.md5 +++ /dev/null @@ -1 +0,0 @@ -198aa1e42d164855c29f7e3b8f0e32c8 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.map deleted file mode 100644 index b7f1bc27b3f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.md5 deleted file mode 100644 index 5630abcd40a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__12.md5 +++ /dev/null @@ -1 +0,0 @@ -ff94628ec786c1149c0474d9992fbafa \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.map deleted file mode 100644 index 9838396ca7a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.md5 deleted file mode 100644 index a7b91b54653..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__13.md5 +++ /dev/null @@ -1 +0,0 @@ -e205f807b675488e62401f919f733ac4 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.map deleted file mode 100644 index 40a31429987..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.md5 deleted file mode 100644 index 3be6621b6be..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__14.md5 +++ /dev/null @@ -1 +0,0 @@ -4bcff168797e6c21ba1eede52dba50b9 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.map deleted file mode 100644 index 6e989154fe4..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.md5 deleted file mode 100644 index 99eb483df07..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__15.md5 +++ /dev/null @@ -1 +0,0 @@ -46e6503b52f860bd459c69e721707e2e \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.map deleted file mode 100644 index b8206e21457..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.md5 deleted file mode 100644 index f3de628eb24..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__2.md5 +++ /dev/null @@ -1 +0,0 @@ -d5b5d6ab3ef640c569f85650ea9f8480 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.map deleted file mode 100644 index 3f55ba7def7..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.md5 deleted file mode 100644 index e8569efaf4f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__3.md5 +++ /dev/null @@ -1 +0,0 @@ -7ee0313d1503b3cf75d48b435961182d \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.map deleted file mode 100644 index 78fc1253bae..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.map +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.md5 deleted file mode 100644 index ddc4477d615..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__4.md5 +++ /dev/null @@ -1 +0,0 @@ -78da7c9248f34e1119fb20cd3e56033d \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.map deleted file mode 100644 index deb643e1bb6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.md5 deleted file mode 100644 index 92cc25bce0c..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__5.md5 +++ /dev/null @@ -1 +0,0 @@ -64416016196c678d33fadc16862bfd57 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.map deleted file mode 100644 index e87f24acb08..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.md5 deleted file mode 100644 index 4303f149612..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__6.md5 +++ /dev/null @@ -1 +0,0 @@ -a2a52726162489889e63cafffb233f06 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.map deleted file mode 100644 index 2dd4869225f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.md5 deleted file mode 100644 index ee9cae3c5c6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__7.md5 +++ /dev/null @@ -1 +0,0 @@ -4d1c9d846e00a922cc47fd379b350562 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.map deleted file mode 100644 index 26da6c643c8..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.md5 deleted file mode 100644 index dc4a68efc75..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__8.md5 +++ /dev/null @@ -1 +0,0 @@ -ed97562dd0a16449e3f78567ede9cb34 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.map b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.map deleted file mode 100644 index b93da65e751..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.map +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.md5 b/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.md5 deleted file mode 100644 index 4bb114bf879..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherit__graph__9.md5 +++ /dev/null @@ -1 +0,0 @@ -1a000d5ea63c4b0adb98721e2737f886 \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/inherits.html b/src/libs/3rdparty/net7ssh/doc/html/inherits.html deleted file mode 100644 index 25cacc052ef..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/inherits.html +++ /dev/null @@ -1,84 +0,0 @@ - - -ne7ssh.kdevelop: Graphical Class Hierarchy - - - - - -
-

Graphical Class Hierarchy

Go to the textual class hierarchy -

- - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
-

-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/namespaceBotan.html b/src/libs/3rdparty/net7ssh/doc/html/namespaceBotan.html deleted file mode 100644 index 06ed3780a90..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/namespaceBotan.html +++ /dev/null @@ -1,36 +0,0 @@ - - -ne7ssh.kdevelop: Botan Namespace Reference - - - - - -
-

Botan Namespace Reference

- -
-

Detailed Description

-definitions for Botan -

-

-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/namespaces.html b/src/libs/3rdparty/net7ssh/doc/html/namespaces.html deleted file mode 100644 index 38675124f64..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/namespaces.html +++ /dev/null @@ -1,33 +0,0 @@ - - -ne7ssh.kdevelop: Namespace Index - - - - - -
-

Namespace List

Here is a list of all documented namespaces with brief descriptions: - -
Botan
-
-
Generated on Tue May 5 14:10:46 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh_8h_source.html deleted file mode 100644 index c2d21f74683..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh_8h_source.html +++ /dev/null @@ -1,277 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh.h Source File - - - - - -
-

ne7ssh.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_H
-00018 #define NE7SSH_H
-00019 
-00020 #include <botan/build.h>
-00021 
-00022 //#include <botan/zlib.h>
-00023 //#include "error.h"
-00024 
-00025 #if BOTAN_VERSION_MAJOR > 1
-00026 #   error Unsupported Botan Version
-00027 #endif
-00028 
-00029 #define BOTAN_PRE_15 (BOTAN_VERSION_MINOR < 5)
-00030 #define BOTAN_PRE_18 (BOTAN_VERSION_MINOR < 8)
-00031 
-00032 #if !BOTAN_PRE_18 && !BOTAN_PRE_15
-00033 # include <botan/auto_rng.h>
-00034 #endif
-00035 
-00036 #include <stdlib.h>
-00037 #include <string>
-00038 #include <fcntl.h>
-00039 #if !defined(WIN32) && !defined(__MINGW32__)
-00040 #   include <pthread.h>
-00041 #   include <sys/select.h>
-00042 #   include <unistd.h>
-00043 typedef pthread_t ne7ssh_thread_t;
-00044 #else
-00045 #include <windows.h>
-00046 typedef HANDLE ne7ssh_thread_t;
-00047 #endif
-00048 
-00049 #include "ne7ssh_types.h"
-00050 #include "ne7ssh_error.h"
-00051 #include "ne7ssh_mutex.h"
-00052 
-00053 #define SSH2_MSG_DISCONNECT 1
-00054 #define SSH2_MSG_IGNORE 2
-00055 
-00056 #define SSH2_MSG_KEXINIT  20
-00057 #define SSH2_MSG_NEWKEYS  21
-00058 
-00059 #define SSH2_MSG_KEXDH_INIT 30
-00060 #define SSH2_MSG_KEXDH_REPLY  31
-00061 
-00062 #define SSH2_MSG_SERVICE_REQUEST 5
-00063 #define SSH2_MSG_SERVICE_ACCEPT 6
-00064 
-00065 #define SSH2_MSG_USERAUTH_REQUEST 50
-00066 #define SSH2_MSG_USERAUTH_FAILURE 51
-00067 #define SSH2_MSG_USERAUTH_SUCCESS 52
-00068 #define SSH2_MSG_USERAUTH_BANNER 53
-00069 #define SSH2_MSG_USERAUTH_PK_OK 60
-00070 
-00071 #define SSH2_MSG_CHANNEL_OPEN                           90
-00072 #define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION              91
-00073 #define SSH2_MSG_CHANNEL_OPEN_FAILURE                   92
-00074 #define SSH2_MSG_CHANNEL_WINDOW_ADJUST                  93
-00075 #define SSH2_MSG_CHANNEL_DATA                           94
-00076 #define SSH2_MSG_CHANNEL_EXTENDED_DATA                  95
-00077 #define SSH2_MSG_CHANNEL_EOF                            96
-00078 #define SSH2_MSG_CHANNEL_CLOSE                          97
-00079 #define SSH2_MSG_CHANNEL_REQUEST                        98
-00080 #define SSH2_MSG_CHANNEL_SUCCESS                        99
-00081 #define SSH2_MSG_CHANNEL_FAILURE                        100
-00082 
-00083 class ne7ssh_connection;
-00084 
-00086 typedef struct {
-00088   ne7ssh_connection **conns;
-00090   uint32 count;
-00091 } connStruct;
-00092 
-00094 namespace Botan
-00095 {
-00096     class LibraryInitializer;
-00097 }
-00098 
-00099 class Ne7SftpSubsystem;
-00100 
-00104 class SSH_EXPORT ne7ssh
-00105 {
-00106   private:
-00107 
-00108     static Ne7ssh_Mutex mut;
-00109     Botan::LibraryInitializer *init;
-00110     ne7ssh_connection **connections;
-00111     uint32 conCount;
-00112     static bool running;
-00113     static bool selectActive;
-00114     connStruct allConns;
-00115 
-00116 
-00122     static void *selectThread (void*);
-00123 
-00128     uint32 getChannelNo ();
-00129     ne7ssh_thread_t select_thread;
-00130     bool connected;
-00131 
-00136     static bool lock ();
-00137 
-00142     static bool unlock ();
-00143     static Ne7sshError* errs;
-00144 
-00145   public:
-00146 #if !BOTAN_PRE_18 && !BOTAN_PRE_15
-00147     static Botan::AutoSeeded_RNG *rng;
-00148 #endif
-00149     static const char* SSH_VERSION;
-00150     static const char* KEX_ALGORITHMS;
-00151     static const char* HOSTKEY_ALGORITHMS;
-00152     static const char* MAC_ALGORITHMS;
-00153     static const char* CIPHER_ALGORITHMS;
-00154     static const char* COMPRESSION_ALGORITHMS;
-00155     static char* PREFERED_CIPHER;
-00156     static char* PREFERED_MAC;
-00157 
-00161     ne7ssh();
-00165     ~ne7ssh();
-00166 
-00177     int connectWithPassword (const char* host, const int port, const char* username, const char* password, bool shell = true, const int timeout = 0);
-00178 
-00191     int connectWithKey (const char* host, const int port, const char* username, const char* privKeyFileName, bool shell = true, const int timeout = 0);
-00192 
-00198 //    ne7ssh_connection** getConnections () { return connections; }
-00199 
-00200     connStruct* getConnetions () { return &allConns; }
-00201 
-00207 //    uint32 getConCount () { return conCount; }
-00208 
-00215     bool send (const char* data, int channel);
-00216 
-00224     bool sendCmd (const char* cmd, int channel, int timeout);
-00225 
-00231     bool close (int channel);
-00232 
-00238     void setCount (uint32 count) { conCount = count; }
-00239 
-00245     const char* read (int channel, bool do_lock=true);
-00246 
-00252     void* readBinary (int channel);
-00253 
-00259     int getReceivedSize (int channel, bool do_lock=true);
-00260 
-00268     bool waitFor (int channel, const char* str, uint32 timeout=0);
-00269 
-00276     void setOptions (const char* prefCipher, const char* prefHmac);
-00277 
-00278 
-00288     bool generateKeyPair (const char* type, const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 0);
-00289 
-00296     bool initSftp (Ne7SftpSubsystem& _sftp, int channel);
-00297 
-00302     static Ne7sshError* errors();
-00303 
-00304     static bool isSelectActive() { return selectActive; }
-00305     static void selectDead() { selectActive = false; }
-00306 };
-00307 
-00308 class Ne7sshSftp;
-00309 
-00313 class SSH_EXPORT Ne7SftpSubsystem
-00314 {
-00315   private:
-00316     bool inited;
-00317     Ne7sshSftp* sftp;
-00318 
-00323 bool errorNotInited ();
-00324 
-00325   public:
-00327     typedef struct
-00328     {
-00329       uint64_t  size;
-00330       uint32_t  owner;
-00331       uint32_t  group;
-00332       uint32_t  permissions;
-00333       uint32_t  atime;
-00334       uint32_t  mtime;
-00335     } fileAttrs;
-00336 
-00338     enum writeMode { READ, OVERWRITE, APPEND };
-00339 
-00343     Ne7SftpSubsystem ();
-00344 
-00349     Ne7SftpSubsystem (class Ne7sshSftp* _sftp);
-00350 
-00354     ~Ne7SftpSubsystem();
-00355 
-00361     bool setTimeout (uint32 _timeout);
-00362 
-00369     uint32 openFile (const char* filename, uint8 mode);
-00370 
-00376     uint32 openDir (const char* dirname);
-00377 
-00384     bool readFile (uint32 fileID, uint64 offset = 0);
-00385 
-00394     bool writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset = 0);
-00395 
-00401     bool closeFile (uint32 fileID);
-00402 
-00410     bool getFileAttrs (fileAttrs& attrs, const char* filename, bool followSymLinks = true);
-00411 
-00412 
-00419     bool get (const char* remoteFile, FILE* localFile);
-00420 
-00427     bool put (FILE* localFile, const char* remoteFile);
-00428 
-00434     bool rm (const char* remoteFile);
-00435 
-00442     bool mv (const char* oldFile, const char* newFile);
-00443 
-00449     bool mkdir (const char* remoteDir);
-00450 
-00456     bool rmdir (const char* remoteDir);
-00457 
-00464     const char* ls (const char* remoteDir, bool longNames=false);
-00465 
-00471     bool cd (const char* remoteDir);
-00472 
-00479     bool chmod (const char* remoteFile, const char* mode);
-00480 
-00488     bool chown (const char* remoteFile, uint32_t uid, uint32_t gid = 0);
-00489 
-00495     bool isFile (const char* remoteFile);
-00496 
-00502     bool isDir (const char* remoteFile);
-00503 };
-00504 
-00505 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__channel_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__channel_8h_source.html deleted file mode 100644 index d10fd791297..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__channel_8h_source.html +++ /dev/null @@ -1,133 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_channel.h Source File - - - - - -
-

ne7ssh_channel.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_CHANNEL_H
-00018 #define NE7SSH_CHANNEL_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include "ne7ssh_string.h"
-00022 
-00023 class ne7ssh_session;
-00024 
-00028 class ne7ssh_channel
-00029 {
-00030   private:
-00031     bool eof, closed;
-00032     bool cmdComplete;
-00033     bool shellSpawned;
-00034 
-00035 //    static uint32 channelCount;
-00036     ne7ssh_session *session;
-00037     ne7ssh_string inBuffer;
-00038     ne7ssh_string outBuffer;
-00039     ne7ssh_string delayedBuffer;
-00040 
-00046     bool handleChannelConfirm ();
-00047 
-00054     bool adjustWindow (Botan::SecureVector<Botan::byte>& packet);
-00055 
-00062     virtual bool handleData (Botan::SecureVector<Botan::byte>& packet);
-00063 
-00069     bool handleExtendedData (Botan::SecureVector<Botan::byte>& packet);
-00070 
-00076     bool handleEof (Botan::SecureVector<Botan::byte>& packet);
-00077 
-00083     void handleClose (Botan::SecureVector<Botan::byte>& packet);
-00084 
-00090     void handleRequest (Botan::SecureVector<Botan::byte>& packet);
-00091 
-00097     bool handleDisconnect (Botan::SecureVector<Botan::byte>& packet);
-00098 
-00099   protected:
-00100     uint32 windowRecv, windowSend;
-00101 
-00102     bool channelOpened;
-00103 
-00107     void sendAdjustWindow ();
-00108 
-00109   public:
-00114     ne7ssh_channel(ne7ssh_session* _session);
-00115 
-00119     virtual ~ne7ssh_channel();
-00120 
-00126     uint32 open (uint32 channelID);
-00127 
-00131     void getShell ();
-00132 
-00138     bool execCmd (const char* cmd);
-00139 
-00143     void receive ();
-00144 
-00150     bool handleReceived (Botan::SecureVector<Botan::byte>& _packet);
-00151 
-00156     void write (Botan::SecureVector<Botan::byte>& data);
-00157 
-00161     void sendAll ();
-00162 
-00167     bool data2Send () { if (outBuffer.length() || delayedBuffer.length()) return true; else return false; }
-00168 
-00173     bool isOpen () { return channelOpened; } 
-00174 
-00179     bool sendClose ();
-00180 
-00185     bool sendEof ();
-00186 
-00191     Botan::SecureVector<Botan::byte>& getReceived () { return inBuffer.value(); }
-00192 
-00197     bool getCmdComplete () { return cmdComplete; }
-00198 
-00203     bool isRemoteShell () { return shellSpawned; }
-00204 
-00210     bool adjustRecvWindow (int bufferSize);
-00211 
-00216     uint32 getRecvWindow () { return windowRecv; }
-00217 
-00222     uint32 getSendWindow () { return windowSend; }
-00223 };
-00224 
-00225 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__connection_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__connection_8h_source.html deleted file mode 100644 index 09a66035769..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__connection_8h_source.html +++ /dev/null @@ -1,135 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_connection.h Source File - - - - - -
-

ne7ssh_connection.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_CONNECTION_H
-00018 #define NE7SSH_CONNECTION_H
-00019 
-00020 #include "ne7ssh_transport.h"
-00021 #include "ne7ssh_session.h"
-00022 #include "ne7ssh_channel.h"
-00023 #include "ne7ssh_keys.h"
-00024 #include "crypt.h"
-00025 #include "ne7ssh_types.h"
-00026 #include "ne7ssh_string.h"
-00027 #include "ne7ssh_sftp.h"
-00028 
-00029 
-00033 class ne7ssh_connection
-00034 {
-00035   private:
-00036     SOCKET sock;
-00037     int thisChannel;
-00038     ne7ssh_crypt *crypto;
-00039     ne7ssh_transport *transport;
-00040     ne7ssh_session *session;
-00041     ne7ssh_channel *channel;
-00042     Ne7sshSftp* sftp;
-00043 
-00044     Ne7ssh_Mutex mut;
-00045     bool connected;
-00046     bool cmdRunning;
-00047     bool cmdClosed;
-00048 
-00049 
-00054     bool checkRemoteVersion ();
-00055 
-00060     bool sendLocalVersion ();
-00061 
-00067     bool requestService (const char* service);
-00068 
-00075     bool authWithPassword (const char* username, const char* password);
-00076 
-00085     bool authWithKey (const char* username, const char* privKeyFileName);
-00086 
-00087   public:
-00091     ne7ssh_connection();
-00092 
-00096     ~ne7ssh_connection();
-00097 
-00109     int connectWithPassword (uint32 channelID, const char *host, uint32 port, const char* username, const char* password, bool shell = true, int timeout = 0);
-00110 
-00122     int connectWithKey (uint32 channelID, const char *host, uint32 port, const char* username, const char* privKeyFileName, bool shell = true, int timeout = 0);
-00123 
-00128     SOCKET getSocket () { return sock; }
-00129 
-00133     void handleData ();
-00134 
-00139     void sendData (const char* data);
-00140 
-00144     void setChannelNo (int channelID) { thisChannel = channelID; }
-00145 
-00150     int getChannelNo () { return thisChannel; }
-00151 
-00156     bool data2Send () { return channel->data2Send(); }
-00157 
-00162     void sendData () { channel->sendAll (); }
-00163 
-00169     bool sendCmd (const char* cmd);
-00170 
-00176     bool sendClose ();
-00177 
-00182     bool isOpen () { return channel->isOpen(); }
-00183 
-00188     bool isConnected () { return connected; }
-00189 
-00194     Botan::SecureVector<Botan::byte>& getReceived () { return channel->getReceived(); }
-00195                 
-00200     bool getCmdComplete() { return channel->getCmdComplete(); }
-00201 
-00206     bool isCmdClosed() { return cmdClosed; }
-00207 
-00212     bool isRemoteShell () { return channel->isRemoteShell(); }
-00213 
-00218     bool isCmdRunning () { return cmdRunning; }
-00219 
-00224     Ne7sshSftp* startSftp ();
-00225 
-00230     bool isSftpActive ();
-00231 };
-00232 
-00233 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__error_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__error_8h_source.html deleted file mode 100644 index bb8ab8f01dd..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__error_8h_source.html +++ /dev/null @@ -1,96 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_error.h Source File - - - - - -
-

ne7ssh_error.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                           *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   This program may be distributed under the terms of the Q Public       *
-00007  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00008  *   file LICENSE.QPL included in the packaging of this file.              *
-00009  *                                                                         *
-00010  *   This program is distributed in the hope that it will be useful,       *
-00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00013  ***************************************************************************/
-00014 
-00015 #ifndef NE7SSH_ERROR_H
-00016 #define NE7SSH_ERROR_H
-00017 
-00018 #include <stdlib.h>
-00019 #if !defined(WIN32) && !defined(__MINGW32__)
-00020 #   include <sys/select.h>
-00021 #endif
-00022 
-00023 #define MAX_ERROR_LEN 500
-00024 
-00025 #include "ne7ssh_types.h"
-00026 #include "ne7ssh_mutex.h"
-00027 
-00031 class SSH_EXPORT Ne7sshError
-00032 {
-00033   private:
-00034     uint16 memberCount;
-00035     char popedErr[MAX_ERROR_LEN + 1];
-00036     static Ne7ssh_Mutex mut;
-00037 
-00041     struct Error
-00042     {
-00043       int32 channel;
-00044       char* errorStr;
-00045     } **ErrorBuffer;
-00046 
-00052     bool deleteRecord (uint16 recID);
-00053 
-00058     static bool lock ();
-00059 
-00064     static bool unlock ();
-00065 
-00066   public:
-00070     Ne7sshError();
-00071 
-00075     ~Ne7sshError();
-00076 
-00083     bool push (int32 channel, const char* format, ...);
-00084 
-00089     const char* pop ();
-00090 
-00096     const char* pop (int32 channel);
-00097 
-00102     bool deleteCoreMsgs ();
-00103 
-00109     bool deleteChannel (int32 channel);
-00110 
-00111 };
-00112 
-00113 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__kex_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__kex_8h_source.html deleted file mode 100644 index 87e22f488a2..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__kex_8h_source.html +++ /dev/null @@ -1,91 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_kex.h Source File - - - - - -
-

ne7ssh_kex.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_KEX_H
-00018 #define NE7SSH_KEX_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include "ne7ssh_session.h"
-00022 #include "ne7ssh_string.h"
-00023 #include "ne7ssh_transport.h"
-00024 #include "crypt.h"
-00025 
-00029 class ne7ssh_kex
-00030 {
-00031   private:
-00032     ne7ssh_session* session;
-00033     ne7ssh_string localKex;
-00034     ne7ssh_string remotKex;
-00035     ne7ssh_string hostKey;
-00036     ne7ssh_string e;
-00037     ne7ssh_string f;
-00038     ne7ssh_string k;
-00039     Botan::SecureVector<Botan::byte> Ciphers, Hmacs;
-00040 
-00044     void constructLocalKex();
-00045 
-00050     void makeH (Botan::SecureVector<Botan::byte>& hVector);
-00051 
-00052   public:
-00057     ne7ssh_kex(ne7ssh_session* _session);
-00058 
-00062     ~ne7ssh_kex();
-00063 
-00068     bool sendInit();
-00069 
-00075     bool handleInit();
-00076 
-00081     bool sendKexDHInit();
-00082 
-00088     bool handleKexDHReply();
-00089 
-00095     bool sendKexNewKeys();
-00096 
-00097 };
-00098 
-00099 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__keys_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__keys_8h_source.html deleted file mode 100644 index 3f9460076fc..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__keys_8h_source.html +++ /dev/null @@ -1,104 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_keys.h Source File - - - - - -
-

ne7ssh_keys.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_KEYS_H
-00018 #define NE7SSH_KEYS_H
-00019 #include <botan/pubkey.h>
-00020 #include <botan/pem.h>
-00021 #include <botan/dsa.h>
-00022 #include <botan/rsa.h>
-00023 #include <botan/numthry.h>
-00024 #include <botan/der_enc.h>
-00025 #include <botan/ber_dec.h>
-00026 
-00027 #include "ne7ssh_types.h"
-00028 #include "ne7ssh_string.h"
-00029 
-00030 #define MAX_KEYSIZE 8192
-00031 
-00032 
-00036 class ne7ssh_keys
-00037 {
-00038   private:
-00039     Botan::DSA_PrivateKey *dsaPrivateKey;
-00040     Botan::RSA_PrivateKey *rsaPrivateKey;
-00041     ne7ssh_string publicKeyBlob;
-00042     Botan::SecureVector<Botan::byte> signature;
-00043 
-00044     uint8 keyAlgo;
-00045 
-00052     bool getDSAKeys (char* buffer, uint32 size);
-00053 
-00060     bool getRSAKeys (char* buffer, uint32 size);
-00061 
-00062   public:
-00063     enum keyAlgos { DSA, RSA };
-00064 
-00068     ne7ssh_keys();
-00069 
-00074     ~ne7ssh_keys();
-00075 
-00084     bool generateDSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 2048);
-00085 
-00094     bool generateRSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 2048);
-00095 
-00102     bool getKeyPairFromFile (const char* privKeyFileName);
-00103 
-00111     Botan::SecureVector<Botan::byte>& generateSignature (Botan::SecureVector<Botan::byte>& sessionID, Botan::SecureVector<Botan::byte>& signingData);
-00112 
-00119     Botan::SecureVector<Botan::byte> generateDSASignature (Botan::SecureVector<Botan::byte>& sessionID, Botan::SecureVector<Botan::byte>& signingData);
-00120 
-00127     Botan::SecureVector<Botan::byte> generateRSASignature (Botan::SecureVector<Botan::byte>& sessionID, Botan::SecureVector<Botan::byte>& signingData);
-00128 
-00133     Botan::SecureVector<Botan::byte>& getPublicKeyBlob ();
-00134 
-00139     uint8 getKeyAlgo () { return keyAlgo; }
-00140 
-00141 };
-00142 
-00143 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__mutex_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__mutex_8h_source.html deleted file mode 100644 index 4e079b7e3c6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__mutex_8h_source.html +++ /dev/null @@ -1,77 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_mutex.h Source File - - - - - -
-

ne7ssh_mutex.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2006 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 
-00018 #ifndef NE7SSH_MUTEX_H
-00019 #define NE7SSH_MUTEX_H
-00020 
-00021 #if defined(WIN32) || defined(__MINGW32__)
-00022 #   include <windows.h>
-00023 #else
-00024 #   include <pthread.h>
-00025 #endif
-00026 
-00027 class Ne7ssh_Mutex
-00028 {
-00029 public:
-00030     Ne7ssh_Mutex();
-00031 
-00032     int lock();
-00033 
-00034     int unlock();
-00035 
-00036     ~Ne7ssh_Mutex();
-00037 private:
-00038 #if defined(WIN32) || defined(__MINGW32__)
-00039     CRITICAL_SECTION mutint;
-00040 #else
-00041     pthread_mutex_t mutint;
-00042 #endif
-00043 };
-00044 
-00045 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__session_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__session_8h_source.html deleted file mode 100644 index a1472bd16c6..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__session_8h_source.html +++ /dev/null @@ -1,106 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_session.h Source File - - - - - -
-

ne7ssh_session.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_SESSION_H
-00018 #define NE7SSH_SESSION_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include "ne7ssh_transport.h"
-00022 #include "crypt.h"
-00023 
-00027 class ne7ssh_session
-00028 {
-00029   private:
-00030     Botan::SecureVector<Botan::byte> localVersion;
-00031     Botan::SecureVector<Botan::byte> remoteVersion;
-00032     Botan::SecureVector<Botan::byte> sessionID;
-00033     uint32 sendChannel;
-00034     uint32 receiveChannel;
-00035     uint32 maxPacket;
-00036     int32 channelID;
-00037 
-00038   public:
-00039     ne7ssh_transport *transport;
-00040     ne7ssh_crypt *crypto;
-00041 
-00045     ne7ssh_session();
-00046 
-00050     ~ne7ssh_session();
-00051 
-00056     void setLocalVersion (Botan::SecureVector<Botan::byte>& version) { localVersion = version; }
-00057 
-00062     Botan::SecureVector<Botan::byte> &getLocalVersion () { return localVersion; }
-00063 
-00068     void setRemoteVersion (Botan::SecureVector<Botan::byte>& version) { remoteVersion = version; }
-00069 
-00074     Botan::SecureVector<Botan::byte> &getRemoteVersion () { return remoteVersion; }    
-00075 
-00080     void setSessionID (Botan::SecureVector<Botan::byte>& session) { sessionID = session; }
-00081 
-00086     Botan::SecureVector<Botan::byte> &getSessionID () { return sessionID; }
-00087 
-00092     void setSendChannel (uint32 channel) { sendChannel = channel; }
-00093 
-00098     uint32 getSendChannel () const { return sendChannel; }
-00099 
-00104     void setReceiveChannel (uint32 channel) { receiveChannel = channel; }
-00105 
-00110     uint32 getReceiveChannel () { return receiveChannel; }
-00111 
-00116     void setMaxPacket (uint32 size) { maxPacket = size; }
-00117 
-00122     uint32 getMaxPacket () { return maxPacket; }
-00123 
-00128     void setSshChannel (int32 channel) { channelID = channel; }
-00129 
-00134     int32 getSshChannel () { return channelID; }
-00135 
-00136 
-00137 };
-00138 
-00139 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp_8h_source.html deleted file mode 100644 index b681100ecbe..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp_8h_source.html +++ /dev/null @@ -1,251 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_sftp.h Source File - - - - - -
-

ne7ssh_sftp.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 
-00018 #ifndef NE7SSHSFTP_H
-00019 #define NE7SSHSFTP_H
-00020 
-00021 #include "ne7ssh_channel.h"
-00022 #include "ne7ssh.h"
-00023 
-00024 #ifdef WIN32
-00025 // 777 = 0x1ff
-00026 #ifndef __MINGW32__
-00027 #define S_IRUSR 0x100
-00028 #endif
-00029 #define S_IRGRP 0x020
-00030 #define S_IROTH 0x004
-00031 #ifndef __MINGW32__
-00032 #define S_IWUSR 0x080
-00033 #endif
-00034 #define S_IWGRP 0x010
-00035 #define S_IWOTH 0x002
-00036 #ifndef __MINGW32__
-00037 #define S_IXUSR 0x040
-00038 #endif
-00039 #define S_IXGRP 0x008
-00040 #define S_IXOTH 0x001
-00041 #define S_ISUID 0x800
-00042 #define S_ISGID 0x400
-00043 #define S_ISVTX 0x200
-00044 #ifndef __MINGW32__
-00045 #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
-00046 #endif
-00047 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
-00048 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
-00049 #endif
-00050 
-00051 #define SSH2_FXP_INIT                1
-00052 #define SSH2_FXP_VERSION             2
-00053 #define SSH2_FXP_OPEN                3
-00054 #define SSH2_FXP_CLOSE               4
-00055 #define SSH2_FXP_READ                5
-00056 #define SSH2_FXP_WRITE               6
-00057 #define SSH2_FXP_LSTAT               7
-00058 #define SSH2_FXP_FSTAT               8
-00059 #define SSH2_FXP_SETSTAT             9
-00060 #define SSH2_FXP_FSETSTAT           10
-00061 #define SSH2_FXP_OPENDIR            11
-00062 #define SSH2_FXP_READDIR            12
-00063 #define SSH2_FXP_REMOVE             13
-00064 #define SSH2_FXP_MKDIR              14
-00065 #define SSH2_FXP_RMDIR              15
-00066 #define SSH2_FXP_REALPATH           16
-00067 #define SSH2_FXP_STAT               17
-00068 #define SSH2_FXP_RENAME             18
-00069 #define SSH2_FXP_READLINK           19
-00070 #define SSH2_FXP_LINK               21
-00071 #define SSH2_FXP_BLOCK              22
-00072 #define SSH2_FXP_UNBLOCK            23
-00073 
-00074 #define SSH2_FXP_STATUS            101
-00075 #define SSH2_FXP_HANDLE            102
-00076 #define SSH2_FXP_DATA              103
-00077 #define SSH2_FXP_NAME              104
-00078 #define SSH2_FXP_ATTRS             105
-00079 
-00080 #define SSH2_FXP_EXTENDED          200
-00081 #define SSH2_FXP_EXTENDED_REPLY    201
-00082 
-00083 #define SFTP_VERSION 3
-00084 #define SFTP_MAX_SEQUENCE 4294967295U
-00085 #define SFTP_MAX_PACKET_SIZE (32 * 1024)
-00086 #define SFTP_MAX_MSG_SIZE (256 * 1024)
-00087 
-00088 #define SSH2_FXF_READ           0x00000001
-00089 #define SSH2_FXF_WRITE          0x00000002
-00090 #define SSH2_FXF_APPEND         0x00000004
-00091 #define SSH2_FXF_CREAT          0x00000008
-00092 #define SSH2_FXF_TRUNC          0x00000010
-00093 #define SSH2_FXF_EXCL           0x00000020
-00094 
-00095 #define SSH2_FILEXFER_ATTR_SIZE         0x00000001
-00096 #define SSH2_FILEXFER_ATTR_UIDGID       0x00000002
-00097 #define SSH2_FILEXFER_ATTR_ACMODTIME    0x00000008
-00098 #define SSH2_FILEXFER_ATTR_PERMISSIONS  0x00000004
-00099 
-00100 class ne7ssh_session;
-00101 class ne7ssh_transport;
-00102 
-00106 class Ne7sshSftp : public ne7ssh_channel
-00107 {
-00108   private:
-00109     ne7ssh_session* session;
-00110     uint32 timeout;
-00111     uint32 seq;
-00112     uint8 sftpCmd;
-00113     ne7ssh_string commBuffer;
-00114     Botan::SecureVector<Botan::byte> fileBuffer;
-00115     enum writeMode { READ, OVERWRITE, APPEND };
-00116     uint8 lastError;
-00117     char* currentPath;
-00118 
-00122     typedef struct
-00123     {
-00124       uint32 flags;
-00125       uint64 size;
-00126       uint32 owner;
-00127       uint32 group;
-00128       uint32 permissions;
-00129       uint32 atime;
-00130       uint32 mtime;
-00131     } sftpFileAttrs;
-00132 
-00133     sftpFileAttrs attrs;
-00134 
-00138     typedef struct 
-00139     {
-00140       uint32 fileID;
-00141       uint16 handleLen;
-00142       char handle[256];
-00143     } sftpFile;
-00144     sftpFile **sftpFiles;
-00145     uint16 sftpFilesCount;
-00146 
-00152     bool handleData (Botan::SecureVector<Botan::byte>& packet);
-00153 
-00159     bool handleVersion (Botan::SecureVector<Botan::byte>& packet);
-00160 
-00166     bool handleStatus (Botan::SecureVector<Botan::byte>& packet);
-00167 
-00173     bool addOpenHandle (Botan::SecureVector<Botan::byte>& packet);
-00174 
-00180     bool handleSftpData (Botan::SecureVector<Botan::byte>& packet);
-00181 
-00187     bool handleNames (Botan::SecureVector<Botan::byte>& packet);
-00188 
-00194     sftpFile* getFileHandle (uint32 fileID);
-00195 
-00202     bool receiveUntil (short _cmd, uint32 timeSec = 0);
-00203 
-00210     bool receiveWhile (short _cmd, uint32 timeSec = 0);
-00211 
-00217     bool processAttrs (Botan::SecureVector<Botan::byte>& packet);
-00218 
-00225     bool getFileStats (const char* remoteFile, bool followSymLinks = true);
-00226 
-00234     bool getFileAttrs (sftpFileAttrs& attributes, Botan::SecureVector<Botan::byte>& remoteFile,  bool followSymLinks = true);
-00235 
-00241     bool getFStat (uint32 fileID);
-00242 
-00248     uint64 getFileSize (uint32 fileID);
-00249 
-00254     bool receiveWindowAdjust ();
-00255 
-00261     ne7ssh_string getFullPath (const char* filename);
-00262 
-00269     bool isType (const char* remoteFile, uint32 type);
-00270 
-00271   public:
-00277     Ne7sshSftp(ne7ssh_session* _session, ne7ssh_channel* _channel);
-00278 
-00282     ~Ne7sshSftp();
-00283 
-00288     bool init();
-00289 
-00294     void setTimeout (uint32 _timeout) { timeout = _timeout; }
-00295 
-00302     uint32 openFile (const char* filename, uint8 shortMode);
-00303 
-00309     uint32 openDir (const char* dirname);
-00310 
-00317     bool readFile (uint32 fileID, uint64 offset = 0);
-00318 
-00327     bool writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset = 0);
-00328 
-00334     bool closeFile (uint32 fileID);
-00335 
-00343     bool getFileAttrs (Ne7SftpSubsystem::fileAttrs& attributes, const char* remoteFile,  bool followSymLinks = true);
-00344 
-00350     bool isFile (const char* remoteFile);
-00351 
-00357     bool isDir (const char* remoteFile);
-00358 
-00359 
-00366     bool get (const char* remoteFile, FILE* localFile);
-00367 
-00374     bool put (FILE* localFile, const char* remoteFile);
-00375 
-00381     bool rm (const char* remoteFile);
-00382 
-00389     bool mv (const char* oldFile, const char* newFile);
-00390 
-00396     bool mkdir (const char* remoteDir);
-00397 
-00403     bool rmdir (const char* remoteDir);
-00404 
-00411     const char* ls (const char* remoteDir, bool longNames=false);
-00412 
-00418     bool cd (const char* remoteDir);
-00419 
-00426     bool chmod (const char* remoteFile, const char* mode);
-00427 
-00435     bool chown (const char* remoteFile, uint32 uid, uint32 gid = 0);
-00436 };
-00437 
-00438 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp__packet_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp__packet_8h_source.html deleted file mode 100644 index 179fd9bbcd1..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__sftp__packet_8h_source.html +++ /dev/null @@ -1,80 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_sftp_packet.h Source File - - - - - -
-

ne7ssh_sftp_packet.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSHSFTPPACKET_H
-00018 #define NE7SSHSFTPPACKET_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include "ne7ssh_string.h"
-00022 
-00026 class Ne7sshSftpPacket : public ne7ssh_string
-00027 {
-00028   private:
-00029     int channel;
-00030 
-00031   public:
-00036     Ne7sshSftpPacket();
-00041     Ne7sshSftpPacket(int channel);
-00042 
-00048     Ne7sshSftpPacket(Botan::SecureVector<Botan::byte>& var, uint32 position);
-00049     
-00053     ~Ne7sshSftpPacket();
-00054 
-00059     Botan::SecureVector<Botan::byte> &value ();
-00060 
-00066     Botan::SecureVector<Botan::byte> valueFragment (uint32 len = 0);
-00067 
-00072     void addInt64 (const uint64 var);
-00073 
-00078     uint64 getInt64 ();
-00079 
-00084     bool isChannelSet ();
-00085 
-00086 };
-00087 
-00088 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__string_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__string_8h_source.html deleted file mode 100644 index 8139ed96380..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__string_8h_source.html +++ /dev/null @@ -1,116 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_string.h Source File - - - - - -
-

ne7ssh_string.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_STRING_H
-00018 #define NE7SSH_STRING_H
-00019 
-00020 #include "ne7ssh_types.h"
-00021 #include <botan/bigint.h>
-00022  
-00026 class ne7ssh_string
-00027 {
-00028 private:
-00029   Botan::byte **positions;
-00030   uint32 parts;
-00031   uint32 currentPart;
-00032 
-00033 protected:
-00034   Botan::SecureVector<Botan::byte> buffer;
-00035 
-00036 public:
-00041     ne7ssh_string();
-00042 
-00049     ne7ssh_string(Botan::SecureVector<Botan::byte>& var, uint32 position);
-00050 
-00056     ne7ssh_string(const char* var, uint32 position);
-00057 
-00061     virtual ~ne7ssh_string();
-00062 
-00066     void clear() { buffer.destroy(); }
-00067 
-00074     void addString (const char* str);
-00075 
-00081     bool addFile (const char* filename);
-00082 
-00088     void addBytes (const Botan::byte* buff, uint32 len);
-00089 
-00094     void addVector (Botan::SecureVector<Botan::byte>& secvec);
-00095 
-00102     void addVectorField (const Botan::SecureVector<Botan::byte>& vector);
-00103 
-00108     void addChar (const char ch);
-00109 
-00115     void addInt (const uint32 var);
-00116 
-00123     void addBigInt (const Botan::BigInt& bn);
-00124 
-00129     virtual Botan::SecureVector<Botan::byte> &value () { return buffer; }
-00130 
-00135     uint32 length () { return buffer.size(); }
-00136 
-00142     bool getString (Botan::SecureVector<Botan::byte>& result);
-00143 
-00149     bool getBigInt (Botan::BigInt& result);
-00150 
-00155     uint32 getInt ();
-00156 
-00161     Botan::byte getByte ();
-00162 
-00167     void split (const char token);
-00168 
-00172     void resetParts () { currentPart = 0; }
-00173 
-00178     char* nextPart ();
-00179 
-00184     void chop (uint32 nBytes);
-00185 
-00192     static void bn2vector (Botan::SecureVector<Botan::byte>& result, const Botan::BigInt& bi);
-00193 
-00194 };
-00195 
-00196 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__transport_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__transport_8h_source.html deleted file mode 100644 index 130df3e5e84..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__transport_8h_source.html +++ /dev/null @@ -1,104 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_transport.h Source File - - - - - -
-

ne7ssh_transport.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_TRANSPORT_H
-00018 #define NE7SSH_TRANSPORT_H
-00019 
-00020 #include "crypt.h"
-00021 #include "ne7ssh_types.h"
-00022 #include "ne7ssh_string.h"
-00023 
-00024 #if defined(WIN32) || defined(__MINGW32__)
-00025 #   include <winsock.h>
-00026 #endif
-00027 #include <sys/types.h>
-00028 
-00029 //#define MAX_PACKET_LEN 35000
-00030 #define MAX_PACKET_LEN 34816
-00031 #define MAX_SEQUENCE 4294967295U
-00032 
-00033 #if !defined(WIN32) && !defined(__MINGW32__)
-00034 #  define SOCKET int
-00035 #endif
-00036 
-00037 class ne7ssh_session;
-00038 
-00042 class ne7ssh_transport
-00043 {
-00044   private:
-00045     uint32 seq, rSeq;
-00046     const ne7ssh_session* session;
-00047     SOCKET sock;
-00048     Botan::SecureVector<Botan::byte> in;
-00049     Botan::SecureVector<Botan::byte> inBuffer;
-00050 
-00057     bool NoBlock (SOCKET socket, bool on);
-00058 
-00066     bool wait (SOCKET socket, int rw, int timeout = -1);
-00067 
-00068   public:
-00074     ne7ssh_transport(ne7ssh_session* _session);
-00075 
-00079     ~ne7ssh_transport();
-00080 
-00088     SOCKET establish (const char *host, uint32 port, int timeout = 0);
-00089 
-00096     bool receive (Botan::SecureVector<Botan::byte>& buffer, bool append = false);
-00097 
-00103     bool send (Botan::SecureVector<Botan::byte>& buffer);
-00104 
-00110     bool sendPacket (Botan::SecureVector<Botan::byte>& buffer);
-00111 
-00120     short waitForPacket (Botan::byte cmd, bool bufferOnly = false);
-00121 
-00127     uint32 getPacket (Botan::SecureVector<Botan::byte>& result);
-00128 
-00133     bool haveData ();
-00134 };
-00135 
-00136 #endif
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__types_8h_source.html b/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__types_8h_source.html deleted file mode 100644 index 91c005d093a..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/ne7ssh__types_8h_source.html +++ /dev/null @@ -1,127 +0,0 @@ - - -ne7ssh.kdevelop: ne7ssh_types.h Source File - - - - - -
-

ne7ssh_types.h

00001 /***************************************************************************
-00002  *   Copyright (C) 2005-2007 by NetSieben Technologies INC                 *
-00003  *   Author: Andrew Useckas                                                *
-00004  *   Email: andrew@netsieben.com                                           *
-00005  *                                                                         *
-00006  *   Windows Port and bugfixes: Keef Aragon <keef@netsieben.com>           *
-00007  *                                                                         *
-00008  *   This program may be distributed under the terms of the Q Public       *
-00009  *   License as defined by Trolltech AS of Norway and appearing in the     *
-00010  *   file LICENSE.QPL included in the packaging of this file.              *
-00011  *                                                                         *
-00012  *   This program is distributed in the hope that it will be useful,       *
-00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
-00015  ***************************************************************************/
-00016 
-00017 #ifndef NE7SSH_TYPES_H
-00018 #define NE7SSH_TYPES_H
-00019 
-00020 #if defined(WIN32) || defined(__MINGW32)
-00021   typedef int int32_t;
-00022   typedef long long      int64_t;
-00023   typedef short        int16_t;
-00024   typedef signed char  int8_t;
-00025 
-00026   typedef unsigned int uint32_t;
-00027   typedef unsigned long long uint64_t;
-00028   typedef unsigned short uint16_t;
-00029   typedef unsigned char  uint8_t;
-00030 
-00031 #   if defined(_WINDLL) || defined(_USRDLL) || defined(_CONSOLE) || defined(_WINDOWS)
-00032 #       ifdef NE7SSH_EXPORTS
-00033 #        define SSH_EXPORT __declspec(dllexport)
-00034 #      else
-00035 #        define SSH_EXPORT __declspec(dllimport)
-00036 #      endif
-00037 #   else
-00038 #       define SSH_EXPORT
-00039 #   endif
-00040 #else
-00041 #  include <inttypes.h>
-00042 #  define SSH_EXPORT
-00043 #endif
-00044 
-00045 #ifndef int64_defined
-00046 #define int64_defined
-00047 typedef int64_t int64;
-00048 #endif
-00049 
-00050 #ifndef uint64_defined
-00051 #define uint64_defined
-00052 typedef uint64_t uint64;
-00053 #endif
-00054 
-00055 #ifndef int32_defined
-00056 #define int32_defined
-00057 typedef int32_t int32;
-00058 #endif
-00059 
-00060 #ifndef uint32_defined
-00061 #define uint32_defined
-00062 typedef uint32_t uint32;
-00063 #endif
-00064 
-00065 #ifndef int16_defined
-00066 #define int16_defined
-00067 typedef int16_t int16;
-00068 #endif
-00069 
-00070 #ifndef uint16_defined
-00071 #define uint16_defined
-00072 typedef uint16_t uint16;
-00073 #endif
-00074 
-00075 #ifndef int8_defined
-00076 #define int8_defined
-00077 typedef int8_t int8;
-00078 #endif
-00079 
-00080 #ifndef uint8_defined
-00081 #define uint8_defined
-00082 typedef uint8_t uint8;
-00083 #endif
-00084 
-00085 #ifndef Byte_defined
-00086 #define Byte_defined
-00087 typedef uint8_t Byte;
-00088 #endif
-00089 
-00090 #if defined(WIN32) || defined(__MINGW32__)
-00091 #  define usleep(time) Sleep(time)
-00092 #endif
-00093 
-00094 #endif
-00095 
-
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs-members.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs-members.html deleted file mode 100644 index e25204015a5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs-members.html +++ /dev/null @@ -1,39 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7SftpSubsystem::fileAttrs Member List

This is the complete list of members for Ne7SftpSubsystem::fileAttrs, including all inherited members.

- - - - - - -
atime (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
group (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
mtime (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
owner (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
permissions (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs
size (defined in Ne7SftpSubsystem::fileAttrs)Ne7SftpSubsystem::fileAttrs

-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs.html deleted file mode 100644 index a7c5b78971b..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7SftpSubsystem_1_1fileAttrs.html +++ /dev/null @@ -1,63 +0,0 @@ - - -ne7ssh.kdevelop: Ne7SftpSubsystem::fileAttrs Struct Reference - - - - - -
-

Ne7SftpSubsystem::fileAttrs Struct Reference

#include <ne7ssh.h> -

- -

-List of all members. - - - - - - - - - - - - - - -

Public Attributes

-uint64_t size
-uint32_t owner
-uint32_t group
-uint32_t permissions
-uint32_t atime
-uint32_t mtime
-


Detailed Description

-Structure used to store rmote file attributes.
The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:42 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error-members.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error-members.html deleted file mode 100644 index 3559d955169..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error-members.html +++ /dev/null @@ -1,35 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshError::Error Member List

This is the complete list of members for Ne7sshError::Error, including all inherited members.

- - -
channel (defined in Ne7sshError::Error)Ne7sshError::Error
errorStr (defined in Ne7sshError::Error)Ne7sshError::Error

-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error.html deleted file mode 100644 index 68d10d26fc2..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshError_1_1Error.html +++ /dev/null @@ -1,49 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshError::Error Struct Reference - - - - - -
-

Ne7sshError::Error Struct Reference

-

-List of all members. - - - - - - -

Public Attributes

-int32 channel
-char * errorStr
-


Detailed Description

-Structure for storing error messages.
The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:43 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile-members.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile-members.html deleted file mode 100644 index 20e6d888085..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile-members.html +++ /dev/null @@ -1,36 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshSftp::sftpFile Member List

This is the complete list of members for Ne7sshSftp::sftpFile, including all inherited members.

- - - -
fileID (defined in Ne7sshSftp::sftpFile)Ne7sshSftp::sftpFile
handle (defined in Ne7sshSftp::sftpFile)Ne7sshSftp::sftpFile
handleLen (defined in Ne7sshSftp::sftpFile)Ne7sshSftp::sftpFile

-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile.html deleted file mode 100644 index 56bf1b2af5f..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFile.html +++ /dev/null @@ -1,52 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshSftp::sftpFile Struct Reference - - - - - -
-

Ne7sshSftp::sftpFile Struct Reference

-

-List of all members. - - - - - - - - -

Public Attributes

-uint32 fileID
-uint16 handleLen
-char handle [256]
-


Detailed Description

-Structure used to store open rmote file.
The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs-members.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs-members.html deleted file mode 100644 index d3c995b9ee5..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs-members.html +++ /dev/null @@ -1,40 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

Ne7sshSftp::sftpFileAttrs Member List

This is the complete list of members for Ne7sshSftp::sftpFileAttrs, including all inherited members.

- - - - - - - -
atime (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
flags (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
group (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
mtime (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
owner (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
permissions (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs
size (defined in Ne7sshSftp::sftpFileAttrs)Ne7sshSftp::sftpFileAttrs

-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs.html b/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs.html deleted file mode 100644 index 53311c50173..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structNe7sshSftp_1_1sftpFileAttrs.html +++ /dev/null @@ -1,64 +0,0 @@ - - -ne7ssh.kdevelop: Ne7sshSftp::sftpFileAttrs Struct Reference - - - - - -
-

Ne7sshSftp::sftpFileAttrs Struct Reference

-

-List of all members. - - - - - - - - - - - - - - - - -

Public Attributes

-uint32 flags
-uint64 size
-uint32 owner
-uint32 group
-uint32 permissions
-uint32 atime
-uint32 mtime
-


Detailed Description

-Structure used to store rmote file attributes.
The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:44 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct-members.html b/src/libs/3rdparty/net7ssh/doc/html/structconnStruct-members.html deleted file mode 100644 index 2e63c113e16..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct-members.html +++ /dev/null @@ -1,35 +0,0 @@ - - -ne7ssh.kdevelop: Member List - - - - - -
-

connStruct Member List

This is the complete list of members for connStruct, including all inherited members.

- - -
connsconnStruct
countconnStruct

-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct.html b/src/libs/3rdparty/net7ssh/doc/html/structconnStruct.html deleted file mode 100644 index 9f9cdd92109..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct.html +++ /dev/null @@ -1,89 +0,0 @@ - - -ne7ssh.kdevelop: connStruct Struct Reference - - - - - -
-

connStruct Struct Reference

#include <ne7ssh.h> -

-

-Collaboration diagram for connStruct:
-
-

Collaboration graph
- - -
[legend]
- -

-List of all members. - - - - - - -

Public Attributes

ne7ssh_connection ** conns
uint32 count
-


Detailed Description

-Structure used to store connections. Used to better sync with selectThread.

Member Data Documentation

- -
- -
- -

-Pointer to all active connections. -

Referenced by ne7ssh::connectWithKey(), ne7ssh::connectWithPassword(), ne7ssh::ne7ssh(), and ne7ssh::selectThread().

- -
-

- -

-
- - - - -
uint32 connStruct::count
-
-
- -

-Active connection count. -

Referenced by ne7ssh::connectWithKey(), ne7ssh::connectWithPassword(), and ne7ssh::ne7ssh().

- -
-

-


The documentation for this struct was generated from the following file: -
-
Generated on Tue May 5 14:10:41 2009 for ne7ssh.kdevelop by  - -doxygen 1.5.9
- - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.map b/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.map deleted file mode 100644 index 62000438186..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.map +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.md5 b/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.md5 deleted file mode 100644 index f812527dcfe..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/structconnStruct__coll__graph.md5 +++ /dev/null @@ -1 +0,0 @@ -a70c5341fda0905a1c68e9544e7ad27d \ No newline at end of file diff --git a/src/libs/3rdparty/net7ssh/doc/html/tabs.css b/src/libs/3rdparty/net7ssh/doc/html/tabs.css deleted file mode 100644 index ab02c624aff..00000000000 --- a/src/libs/3rdparty/net7ssh/doc/html/tabs.css +++ /dev/null @@ -1,105 +0,0 @@ -/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ - -DIV.tabs -{ - float : left; - width : 100%; - background : url("tab_b.gif") repeat-x bottom; - margin-bottom : 4px; -} - -DIV.tabs UL -{ - margin : 0px; - padding-left : 10px; - list-style : none; -} - -DIV.tabs LI, DIV.tabs FORM -{ - display : inline; - margin : 0px; - padding : 0px; -} - -DIV.tabs FORM -{ - float : right; -} - -DIV.tabs A -{ - float : left; - background : url("tab_r.gif") no-repeat right top; - border-bottom : 1px solid #84B0C7; - font-size : 80%; - font-weight : bold; - text-decoration : none; -} - -DIV.tabs A:hover -{ - background-position: 100% -150px; -} - -DIV.tabs A:link, DIV.tabs A:visited, -DIV.tabs A:active, DIV.tabs A:hover -{ - color: #1A419D; -} - -DIV.tabs SPAN -{ - float : left; - display : block; - background : url("tab_l.gif") no-repeat left top; - padding : 5px 9px; - white-space : nowrap; -} - -DIV.tabs INPUT -{ - float : right; - display : inline; - font-size : 1em; -} - -DIV.tabs TD -{ - font-size : 80%; - font-weight : bold; - text-decoration : none; -} - - - -/* Commented Backslash Hack hides rule from IE5-Mac \*/ -DIV.tabs SPAN {float : none;} -/* End IE5-Mac hack */ - -DIV.tabs A:hover SPAN -{ - background-position: 0% -150px; -} - -DIV.tabs LI.current A -{ - background-position: 100% -150px; - border-width : 0px; -} - -DIV.tabs LI.current SPAN -{ - background-position: 0% -150px; - padding-bottom : 6px; -} - -DIV.navpath -{ - background : none; - border : none; - border-bottom : 1px solid #84B0C7; - text-align : center; - margin : 2px; - padding : 2px; -} diff --git a/src/libs/3rdparty/net7ssh/examples/generateKeys.cpp b/src/libs/3rdparty/net7ssh/examples/generateKeys.cpp deleted file mode 100644 index c5c0d70cbc0..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/generateKeys.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* An example of ne7ssh library usage. This code will generate a DSA key pair - and store private key in ./privKeyFile and public key in ./pubKeyFile. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - ne7ssh *_ssh = new ne7ssh(); - - // Generating DSA keys - if (!_ssh->generateKeyPair ("rsa", "test@test.com", "./privKeyFile", "./pubKeyFile", 2048)) - { - const char *errmsg = _ssh->errors()->pop(); - - if (errmsg == NULL) - errmsg = ""; - printf ("Key gneration failed with last error: %s.\n\n", errmsg); - } - - delete _ssh; - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/examples/getFile.cpp b/src/libs/3rdparty/net7ssh/examples/getFile.cpp deleted file mode 100644 index 926e31ca2cf..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/getFile.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWithPassword -function before compiling. - -This will work with on a unix/linux server with cat utility. - -If you are testing this with later openssh versions, make sure to add this -option to your server's configuration file to enable password authentication: - -PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - int channel1; - const char* result; - ne7ssh *_ssh = new ne7ssh(); - int filesize = 0; - FILE *testFi; - - // Set SSH connection options. - _ssh->setOptions ("aes256-cbc", "hmac-md5"); - - // Initiate connection without starting a remote shell. - channel1 = _ssh->connectWithPassword ("remote-server", 22, "remoteUser", "password", 0); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Connection failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // cat the remote file, works only on Unix systems. You may need to sepcifiy full path to cat. - // Timeout after 100 seconds. - - if (!_ssh->sendCmd ("cat ~/test.bin", channel1, 100)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Command failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Determine the size of received file. - filesize = _ssh->getReceivedSize(channel1); - - // Open a local file. - testFi = fopen ("./test.bin", "wb"); - - // Write binary data from the receive buffer to the opened file. - if (!fwrite (_ssh->readBinary(channel1), (size_t) filesize, 1, testFi)) - { - printf ("Error Writting to file\n\n"); - return EXIT_FAILURE; - } - - // Close the files. - fclose (testFi); - - // Destroy the instance. - delete _ssh; - - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/examples/keyAuth.cpp b/src/libs/3rdparty/net7ssh/examples/keyAuth.cpp deleted file mode 100644 index e12fc120697..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/keyAuth.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWitKeys - function before compiling. - - This will work with openssh server if default shell of authenticating user is bash. - When using a different shell or custom prompt replace " $" string in waitFor() - method with a string corresponding with your shell prompt. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - int channel1; - const char* result; - ne7ssh *_ssh = new ne7ssh(); - - // Set SSH connection options. - _ssh->setOptions ("aes128-cbc", "hmac-sha1"); - - // Initiate connection. - channel1 = _ssh->connectWithKey ("remoteHost", 22, "remoteUsr", "/local/path/to/privKeyFile"); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Connection failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, "$", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Send "ls" command. - if (!_ssh->send ("ls\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, "$", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site.Last error: %s\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - - if (!result) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("No data received. Last error: %s\n\n", errmsg); - } - else - printf ("Received data:\n %s\n", result); - - // Terminate connection by sending "exit" command. - _ssh->send ("exit\n", channel1); - - // Destroy the instance. - delete _ssh; - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/examples/multipleThreads.cpp b/src/libs/3rdparty/net7ssh/examples/multipleThreads.cpp deleted file mode 100644 index 5cb68649eca..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/multipleThreads.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWithPassword - function before compiling. - - This will work with openssh server if default shell of authenticating user is bash. - When using a different shell or custom prompt replace " $" string in waitFor() - method with a string corresponding with your shell prompt. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ -#include -#include - -#if defined(WIN32) || defined (__MINGW32__) -# include -typedef HANDLE pthread_t; -#endif - -void* thread1_proc (void* initData); -void* thread2_proc (void* initData); -void* thread3_proc (void* initData); -void* thread4_proc (void* initData); -pthread_t thread1, thread2, thread3, thread4; - -struct ssh_thrarg_t -{ - ne7ssh *ssh; - int thrid; -}; - -int main(int argc,char *argv[]) -{ - ne7ssh *_ssh = new ne7ssh(); - int status; - - // Set SSH connection options. - _ssh->setOptions ("aes128-cbc", "hmac-md5"); - - ssh_thrarg_t args[4]; - args[0].ssh = _ssh; - args[1].ssh = _ssh; - args[2].ssh = _ssh; - args[3].ssh = _ssh; - - args[0].thrid = 1; - args[1].thrid = 2; - args[2].thrid = 3; - args[3].thrid = 4; - -#if !defined(WIN32) && !defined(__MINGW32__) - status = pthread_create (&thread1, NULL, thread1_proc, (void*)&args[0]); - status = pthread_create (&thread2, NULL, thread2_proc, (void*)&args[1]); - status = pthread_create (&thread3, NULL, thread3_proc, (void*)&args[2]); - status = pthread_create (&thread4, NULL, thread4_proc, (void*)&args[3]); - pthread_join (thread1, NULL); - pthread_join (thread2, NULL); - pthread_join (thread3, NULL); - pthread_join (thread4, NULL); - -#else - HANDLE h[3]; - if ((thread1 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) thread1_proc, (LPVOID)&args[0], 0, NULL)) == NULL) - { - ne7ssh::errors()->push (-1, "Failure creating new thread."); - return (EXIT_FAILURE); - } - if ((thread2 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) thread2_proc, (LPVOID)&args[1], 0, NULL)) == NULL) - { - ne7ssh::errors()->push (-1, "Failure creating new thread."); - return (EXIT_FAILURE); - } - if ((thread3 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) thread3_proc, (LPVOID)&args[2], 0, NULL)) == NULL) - { - ne7ssh::errors()->push (-1, "Failure creating new thread."); - return (EXIT_FAILURE); - } - if ((thread4 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) thread4_proc, (LPVOID)&args[3], 0, NULL)) == NULL) - { - ne7ssh::errors()->push (-1, "Failure creating new thread."); - return (EXIT_FAILURE); - } - h[0] = thread1; - h[1] = thread2; - h[2] = thread3; - h[3] = thread4; - WaitForMultipleObjects(4, h, TRUE, INFINITE); -#endif - - delete _ssh; - return EXIT_SUCCESS; -} - - -void* thread1_proc (void* initData) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = ((ssh_thrarg_t*) initData)->ssh; - int thrid = ((ssh_thrarg_t*) initData)->thrid; - - for (i = 0; i < 50; i++) - { - // Initiate a connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", true, 30); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Thread1. Connection failed with last error: %s\n\n", errmsg); - continue; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Send "ls" command. - if (!_ssh->send ("ls -al\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - printf ("Data Thread %i: %s\n\n", thrid, result); - - // Close the connection. - _ssh->send ("exit\n", channel1); - } -} - -void* thread2_proc (void* initData) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = ((ssh_thrarg_t*) initData)->ssh; - int thrid = ((ssh_thrarg_t*) initData)->thrid; - - for (i = 0; i < 50; i++) - { - // Initiate a connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", true, 30); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Thread2. Connection failed with last error: %s\n\n", errmsg); - continue; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - result = _ssh->read (channel1); - - printf ("Data Count: %i, Thread %i: %s\n\n", i, thrid, result); - - // Send "ls" command. - if (!_ssh->send ("ls\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - printf ("Data Count: %i, Thread %i: %s\n\n", i, thrid, result); - - // Close the connection. - _ssh->send ("exit\n", channel1); - } -} - -void* thread3_proc (void* initData) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = ((ssh_thrarg_t*) initData)->ssh; - int thrid = ((ssh_thrarg_t*) initData)->thrid; - - for (i = 0; i < 50; i++) - { - // Initiate a connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", true, 30); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Thread3. Connection failed with last error: %s\n\n", errmsg); - continue; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Send "ls" command. - if (!_ssh->send ("ls\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - printf ("Data Thread %i: %s\n\n", thrid, result); - - // Close the connection. - _ssh->send ("exit\n", channel1); - } -} - -void* thread4_proc (void* initData) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = ((ssh_thrarg_t*) initData)->ssh; - int thrid = ((ssh_thrarg_t*) initData)->thrid; - - for (i = 0; i < 50; i++) - { - // Initiate a connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", true, 30); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Thread4. Connection failed with last error: %s\n\n", errmsg); - continue; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell wiht last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Send "ls" command. - if (!_ssh->send ("ls\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site. Last error: %s\n\n", errmsg); - _ssh->close(channel1); - continue; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - printf ("Data Thread %i: %s\n\n", thrid, result); - - // Close the connection. - _ssh->send ("exit\n", channel1); - } -} diff --git a/src/libs/3rdparty/net7ssh/examples/passwordAuth.cpp b/src/libs/3rdparty/net7ssh/examples/passwordAuth.cpp deleted file mode 100644 index d45e8a472d0..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/passwordAuth.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWithPassword - function before compiling. - - This will work with openssh server if default shell of authenticating user is bash. - When using a different shell or custom prompt replace " $" string in waitFor() - method with a string corresponding with your shell prompt. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - int channel1, i; - const char* result; - ne7ssh *_ssh = new ne7ssh(); - - // Set SSH connection options. - _ssh->setOptions ("aes192-cbc", "hmac-md5"); - - // Initiate connection. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remtoeUsr", "password"); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Connection failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds. - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Failed while waiting for remote shell with last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Send "ps ax" command. - if (!_ssh->send ("ps ax\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site.Last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - - if (!result) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("No data received. Last error: %s.\n\n", errmsg); - } - else - printf ("Received data:\n %s\n", result); - - // Send "netstat -na" command. - if (!_ssh->send ("netstat -na\n", channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not send the command. Last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Wait for bash prompt, or die in 5 seconds - if (!_ssh->waitFor (channel1, " $", 5)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Timeout while waiting for remote site.Last error: %s.\n\n", errmsg); - _ssh->close(channel1); - delete _ssh; - return EXIT_FAILURE; - } - - // Fetch recieved data. - result = _ssh->read (channel1); - - if (!result) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("No data received. Last error: %s.\n\n", errmsg); - } - else - printf ("Received data:\n %s\n", result); - // Terminate connection by sending "exit" command. - _ssh->send ("exit\n", channel1); - - // Destroy the instance. - delete _ssh; - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/examples/sftpExample.cpp b/src/libs/3rdparty/net7ssh/examples/sftpExample.cpp deleted file mode 100644 index c73a9920806..00000000000 --- a/src/libs/3rdparty/net7ssh/examples/sftpExample.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* An example of ne7ssh library usage. Please change the values in connectWithPassword - function before compiling. - - If you are testing this with later openssh versions, make sure to add this - option to your server's configuration file to enable password authentication: - - PasswordAuthentication yes -*/ - -#include - -int main(int argc,char *argv[]) -{ - int channel1; - const char* result; - ne7ssh *_ssh = new ne7ssh(); - int filesize = 0; - FILE *testFi; - Ne7SftpSubsystem _sftp; - const char* dirList; - - // Set SSH connection options. - _ssh->setOptions ("aes256-cbc", "hmac-md5"); - - // Initiate connection without starting a remote shell. - channel1 = _ssh->connectWithPassword ("remoteHost", 22, "remoteUsr", "password", 0, 20); - if (channel1 < 0) - { - const char *errmsg = _ssh->errors()->pop(); - if (errmsg == NULL) - errmsg = ""; - printf ("Connection failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Initiate SFTP subsystem. - if (!_ssh->initSftp (_sftp, channel1)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Command failed with last error: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Set a timeout for all SFTP communications. - _sftp.setTimeout (30); - - // Check remote file permissions. - Ne7SftpSubsystem::fileAttrs attrs; - if (_sftp.getFileAttrs (attrs, "test.bin", true)) - printf ("Permissions: %o\n", (attrs.permissions & 0777)); - - // Create a local file. - testFi = fopen ("test.bin", "wb+"); - if (!testFi) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not open local file: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Download a file. - if (!_sftp.get ("test.bin", testFi)) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not get File: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Change directory. - if (!_sftp.cd ("testing")) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not change Directory: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Upload the file. - if (!_sftp.put (testFi, "test2.bin")) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not put File: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Create a new directory. - if (!_sftp.mkdir ("testing3")) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not create Directory: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Get listing. - dirList = _sftp.ls (".", true); - if (!dirList) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not list Directory: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - else - printf ("Directory Listing:\n\n %s\n", dirList); - - // Change permisions on newly uploaded file. - if (!_sftp.chmod ("test2.bin", "755")) - { - const char *errmsg = _ssh->errors()->pop(channel1); - if (errmsg == NULL) - errmsg = ""; - printf ("Could not chmod: %s\n\n", errmsg); - delete _ssh; - return EXIT_FAILURE; - } - - // Destroy the instance. - delete _ssh; - - return EXIT_SUCCESS; -} diff --git a/src/libs/3rdparty/net7ssh/net7ssh.pri b/src/libs/3rdparty/net7ssh/net7ssh.pri deleted file mode 100644 index 6389d249ad4..00000000000 --- a/src/libs/3rdparty/net7ssh/net7ssh.pri +++ /dev/null @@ -1,3 +0,0 @@ -include(net7ssh_dependencies.pri) -INCLUDEPATH *= $$PWD/src -LIBS *= -l$$qtLibraryTarget(Net7ssh) diff --git a/src/libs/3rdparty/net7ssh/net7ssh.pro b/src/libs/3rdparty/net7ssh/net7ssh.pro deleted file mode 100644 index 862d64135dd..00000000000 --- a/src/libs/3rdparty/net7ssh/net7ssh.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs -CONFIG += ordered - -SUBDIRS += src diff --git a/src/libs/3rdparty/net7ssh/net7ssh_dependencies.pri b/src/libs/3rdparty/net7ssh/net7ssh_dependencies.pri deleted file mode 100644 index d83ea3954d2..00000000000 --- a/src/libs/3rdparty/net7ssh/net7ssh_dependencies.pri +++ /dev/null @@ -1 +0,0 @@ -include(../botan/botan.pri) diff --git a/src/libs/3rdparty/net7ssh/src/crypt.cpp b/src/libs/3rdparty/net7ssh/src/crypt.cpp deleted file mode 100644 index b7f4e151f54..00000000000 --- a/src/libs/3rdparty/net7ssh/src/crypt.cpp +++ /dev/null @@ -1,786 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#if !defined WIN32 && !defined(__MINGW32__) -# include -#endif - -#include -#include "crypt.h" -#include "ne7ssh_session.h" -#include "ne7ssh.h" - -using namespace Botan; - -ne7ssh_crypt::ne7ssh_crypt(ne7ssh_session* _session) : session(_session), kexMethod(DH_GROUP1_SHA1), c2sCryptoMethod(AES128_CBC), s2cCryptoMethod(AES128_CBC), c2sMacMethod(HMAC_MD5), s2cMacMethod(HMAC_MD5), inited(false), encrypt(0), decrypt(0), compress(0), decompress(0), hmacOut(0), hmacIn(0), privKexKey(0), encryptBlock(0), decryptBlock(0) -{ -} - - -ne7ssh_crypt::~ne7ssh_crypt() -{ - if (encrypt) delete encrypt; - if (decrypt) delete decrypt; - - if (compress) delete compress; - if (decompress) delete decompress; - - if (hmacOut) delete hmacOut; - if (hmacIn) delete hmacIn; - - if (privKexKey) delete privKexKey; -} - - -bool ne7ssh_crypt::agree (Botan::SecureVector &result, const char* local, Botan::SecureVector &remote) -{ - ne7ssh_string localAlgos (local, 0); - ne7ssh_string remoteAlgos (remote, 0); - char* localAlgo, *remoteAlgo; - bool match; - size_t len; - - localAlgos.split (','); - localAlgos.resetParts(); - remoteAlgos.split (','); - remoteAlgos.resetParts(); - - match = false; - while ((localAlgo = localAlgos.nextPart())) - { - len = strlen(localAlgo); - while ((remoteAlgo = remoteAlgos.nextPart())) - { - if (!memcmp (localAlgo, remoteAlgo, len)) - { - match = true; - break; - } - } - if (match) break; - remoteAlgos.resetParts(); - } - if (match) - { - result.set ((Botan::byte*)localAlgo, (uint32_t) len); - return true; - } - else - { - result.clear(); - return false; - } -} - -bool ne7ssh_crypt::negotiatedKex (Botan::SecureVector &kexAlgo) -{ - if (!memcmp (kexAlgo.begin(), "diffie-hellman-group1-sha1", kexAlgo.size())) - { - kexMethod = DH_GROUP1_SHA1; - return true; - } - else if (!memcmp (kexAlgo.begin(), "diffie-hellman-group14-sha1", kexAlgo.size())) - { - kexMethod = DH_GROUP14_SHA1; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "KEX algorithm: '%B' not defined.", &kexAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedHostkey (Botan::SecureVector &hostkeyAlgo) -{ - if (!memcmp (hostkeyAlgo.begin(), "ssh-dss", hostkeyAlgo.size())) - { - hostkeyMethod = SSH_DSS; - return true; - } - else if (!memcmp (hostkeyAlgo.begin(), "ssh-rsa", hostkeyAlgo.size())) - { - hostkeyMethod = SSH_RSA; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Hostkey algorithm: '%B' not defined.", &hostkeyAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedCryptoC2s (Botan::SecureVector &cryptoAlgo) -{ - if (!memcmp (cryptoAlgo.begin(), "3des-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = TDES_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes128-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = AES128_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes192-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = AES192_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes256-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = AES256_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "blowfish-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = BLOWFISH_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "cast128-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = CAST128_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "twofish-cbc", cryptoAlgo.size()) || !memcmp (cryptoAlgo.begin(), "twofish256-cbc", cryptoAlgo.size())) - { - c2sCryptoMethod = TWOFISH_CBC; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Cryptographic algorithm: '%B' not defined.", &cryptoAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedCryptoS2c (Botan::SecureVector &cryptoAlgo) -{ - if (!memcmp (cryptoAlgo.begin(), "3des-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = TDES_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes128-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = AES128_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes192-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = AES192_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "aes256-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = AES256_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "blowfish-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = BLOWFISH_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "cast128-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = CAST128_CBC; - return true; - } - else if (!memcmp (cryptoAlgo.begin(), "twofish-cbc", cryptoAlgo.size()) || !memcmp (cryptoAlgo.begin(), "twofish256-cbc", cryptoAlgo.size())) - { - s2cCryptoMethod = TWOFISH_CBC; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Cryptographic method: '%B' not defined.", &cryptoAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedMacC2s (Botan::SecureVector &macAlgo) -{ - if (!memcmp (macAlgo.begin(), "hmac-sha1", macAlgo.size())) - { - c2sMacMethod = HMAC_SHA1; - return true; - } - else if (!memcmp (macAlgo.begin(), "hmac-md5", macAlgo.size())) - { - c2sMacMethod = HMAC_MD5; - return true; - } - else if (!memcmp (macAlgo.begin(), "none", macAlgo.size())) - { - c2sMacMethod = HMAC_NONE; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "HMAC algorithm: '%B' not defined.", &macAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedMacS2c (Botan::SecureVector &macAlgo) -{ - if (!memcmp (macAlgo.begin(), "hmac-sha1", macAlgo.size())) - { - s2cMacMethod = HMAC_SHA1; - return true; - } - else if (!memcmp (macAlgo.begin(), "hmac-md5", macAlgo.size())) - { - s2cMacMethod = HMAC_MD5; - return true; - } - else if (!memcmp (macAlgo.begin(), "none", macAlgo.size())) - { - s2cMacMethod = HMAC_NONE; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "HMAC algorithm: '%B' not defined.", &macAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedCmprsC2s (Botan::SecureVector &cmprsAlgo) -{ - if (!memcmp (cmprsAlgo.begin(), "none", cmprsAlgo.size())) - { - c2sCmprsMethod = NONE; - return true; - } - else if (!memcmp (cmprsAlgo.begin(), "zlib", cmprsAlgo.size())) - { - c2sCmprsMethod = ZLIB; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Compression algorithm: '%B' not defined.", &cmprsAlgo); - return false; -} - -bool ne7ssh_crypt::negotiatedCmprsS2c (Botan::SecureVector &cmprsAlgo) -{ - if (!memcmp (cmprsAlgo.begin(), "none", cmprsAlgo.size())) - { - s2cCmprsMethod = NONE; - return true; - } - else if (!memcmp (cmprsAlgo.begin(), "zlib", cmprsAlgo.size())) - { - s2cCmprsMethod = ZLIB; - return true; - } - - ne7ssh::errors()->push (session->getSshChannel(), "Compression algorithm: '%B' not defined.", &cmprsAlgo); - return false; -} - -bool ne7ssh_crypt::getKexPublic (Botan::BigInt &publicKey) -{ - switch (kexMethod) - { - case DH_GROUP1_SHA1: - return getDHGroup1Sha1Public (publicKey); - - case DH_GROUP14_SHA1: - return getDHGroup14Sha1Public (publicKey); - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Undefined DH Group: '%s'.", kexMethod); - return false; - } -} - -bool ne7ssh_crypt::computeH (Botan::SecureVector &result, Botan::SecureVector &val) -{ - HashFunction* hashIt; - - switch (kexMethod) - { - case DH_GROUP1_SHA1: - case DH_GROUP14_SHA1: - hashIt = get_hash ("SHA-1"); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Undefined DH Group: '%s' while computing H.", kexMethod); - return false; - } - - if (!hashIt) return false; - H = hashIt->process (val); - result.set (H); - delete (hashIt); - return true; -} - -bool ne7ssh_crypt::verifySig (Botan::SecureVector &hostKey, Botan::SecureVector &sig) -{ - DSA_PublicKey *dsaKey = 0; - RSA_PublicKey *rsaKey = 0; - PK_Verifier *verifier; - ne7ssh_string signature (sig, 0); - SecureVector sigType, sigData; - bool result; - - if (H.is_empty()) - { - ne7ssh::errors()->push (session->getSshChannel(), "H was not initialzed."); - return false; - } - - if (!signature.getString (sigType)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Signature without type."); - return false; - } - if (!signature.getString (sigData)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Signature without data."); - return false; - } - - switch (hostkeyMethod) - { - case SSH_DSS: - dsaKey = getDSAKey (hostKey); - if (!dsaKey) - { - ne7ssh::errors()->push (session->getSshChannel(), "DSA key not generated."); - return false; - } - break; - - case SSH_RSA: - rsaKey = getRSAKey (hostKey); - if (!rsaKey) - { - ne7ssh::errors()->push (session->getSshChannel(), "RSA key not generated."); - return false; - } - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Hostkey algorithm: %i not supported.", hostkeyMethod); - return false; - } - - switch (kexMethod) - { - case DH_GROUP1_SHA1: - case DH_GROUP14_SHA1: - if (dsaKey) verifier = get_pk_verifier (*dsaKey, "EMSA1(SHA-1)"); - else if (rsaKey) verifier = get_pk_verifier (*rsaKey, "EMSA3(SHA-1)"); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Key Exchange algorithm: %i not supported.", kexMethod); - return false; - } - - result = verifier->verify_message (H, sigData); - delete verifier; - if (dsaKey) delete dsaKey; - if (rsaKey) delete rsaKey; - - if (!result) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failure to verify host signature."); - return false; - } - else return true; -} - -DSA_PublicKey* ne7ssh_crypt::getDSAKey (Botan::SecureVector &hostKey) -{ - ne7ssh_string hKey; - SecureVector field; - BigInt p, q, g, y; - DSA_PublicKey *pubKey; - - hKey.addVector (hostKey); - - if (!hKey.getString (field)) return 0; - if (!negotiatedHostkey (field)) return 0; - - if (!hKey.getBigInt (p)) return 0; - if (!hKey.getBigInt (q)) return 0; - if (!hKey.getBigInt (g)) return 0; - if (!hKey.getBigInt (y)) return 0; - - DL_Group keyDL (p, q, g); - pubKey = new DSA_PublicKey (keyDL, y); - return pubKey; -} - -RSA_PublicKey* ne7ssh_crypt::getRSAKey (Botan::SecureVector &hostKey) -{ - ne7ssh_string hKey; - SecureVector field; - BigInt e, n; - - hKey.addVector (hostKey); - - if (!hKey.getString (field)) return 0; - if (!negotiatedHostkey (field)) return 0; - - if (!hKey.getBigInt (e)) return 0; - if (!hKey.getBigInt (n)) return 0; - - return (new RSA_PublicKey (n, e)); -} - - - -bool ne7ssh_crypt::makeKexSecret (Botan::SecureVector &result, Botan::BigInt &f) -{ - SymmetricKey negotiated = privKexKey->derive_key (f); - if (!negotiated.length()) return false; - - BigInt Kint (negotiated.begin(), negotiated.length()); - ne7ssh_string::bn2vector(result, Kint); - K.set (result); - delete privKexKey; - privKexKey = 0; - return true; -} - -bool ne7ssh_crypt::getDHGroup1Sha1Public (Botan::BigInt &publicKey) -{ -#if BOTAN_PRE_15 - privKexKey = new DH_PrivateKey (get_dl_group("IETF-1024")); -#elif BOTAN_PRE_18 - privKexKey = new DH_PrivateKey (DL_Group("modp/ietf/1024")); -#else - privKexKey = new DH_PrivateKey (*ne7ssh::rng, DL_Group("modp/ietf/1024")); -#endif - DH_PublicKey pubKexKey = *privKexKey; - - publicKey = pubKexKey.get_y(); - if (publicKey.is_zero()) return false; - else return true; -} - -bool ne7ssh_crypt::getDHGroup14Sha1Public (Botan::BigInt &publicKey) -{ -#if BOTAN_PRE_15 - privKexKey = new DH_PrivateKey (get_dl_group("IETF-2048")); -#elif BOTAN_PRE_18 - privKexKey = new DH_PrivateKey (DL_Group("modp/ietf/2048")); -#else - privKexKey = new DH_PrivateKey (*ne7ssh::rng, DL_Group("modp/ietf/2048")); -#endif - DH_PublicKey pubKexKey = *privKexKey; - - publicKey = pubKexKey.get_y(); - if (publicKey.is_zero()) return false; - else return true; -} - -const char* ne7ssh_crypt::getHashAlgo () -{ - switch (kexMethod) - { - case DH_GROUP1_SHA1: - case DH_GROUP14_SHA1: - return "SHA-1"; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "DH Group: %i was not defined.", kexMethod); - return 0; - } -} - -const char* ne7ssh_crypt::getCryptAlgo (uint32 crypto) -{ - switch (crypto) - { - case TDES_CBC: - return "TripleDES"; - - case AES128_CBC: - return "AES-128"; - - case AES192_CBC: - return "AES-192"; - - case AES256_CBC: - return "AES-256"; - - case BLOWFISH_CBC: - return "Blowfish"; - - case CAST128_CBC: - return "CAST-128"; - - case TWOFISH_CBC: - return "Twofish"; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Cryptographic algorithm: %i was not defined.", crypto); - return 0; - } -} - -const char* ne7ssh_crypt::getHmacAlgo (uint32 method) -{ - switch (method) - { - case HMAC_SHA1: - return "SHA-1"; - - case HMAC_MD5: - return "MD5"; - - case HMAC_NONE: - return 0; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "HMAC algorithm: %i was not defined.", method); - return 0; - } -} - -uint32 ne7ssh_crypt::getMacKeyLen (uint32 method) -{ - switch (method) - { - case HMAC_SHA1: - return 20; - - case HMAC_MD5: - return 16; - - case HMAC_NONE: - return 0; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "HMAC algorithm: %i was not defined.", method); - return 0; - } -} - -uint32 ne7ssh_crypt::getMacDigestLen (uint32 method) -{ - switch (method) - { - case HMAC_SHA1: - return 20; - - case HMAC_MD5: - return 16; - - case HMAC_NONE: - return 0; - - default: - return 0; - } -} - -bool ne7ssh_crypt::makeNewKeys () -{ - const char* algo; - uint32 key_len, iv_len, macLen; - SecureVector key; -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 - const Botan::BlockCipher *cipher; - const Botan::HashFunction *hash_algo; -#endif - - algo = getCryptAlgo (c2sCryptoMethod); - key_len = max_keylength_of (algo); - if (c2sCryptoMethod == BLOWFISH_CBC) key_len = 16; - else if (c2sCryptoMethod == TWOFISH_CBC) key_len = 32; - encryptBlock = iv_len = block_size_of (algo); - macLen = getMacKeyLen (c2sMacMethod); - if (!algo) return false; - - if (!compute_key(key, 'A', iv_len)) return false; - InitializationVector c2s_iv (key); - - if (!compute_key(key, 'C', key_len)) return false; - SymmetricKey c2s_key (key); - - if (!compute_key(key, 'E', macLen)) return false; - SymmetricKey c2s_mac (key); - -#if BOTAN_PRE_18 && !BOTAN_PRE_15 - encrypt = new Pipe (new CBC_Encryption (algo, "NoPadding", c2s_key, c2s_iv)); -#else - Algorithm_Factory &af = global_state().algorithm_factory(); - cipher = af.prototype_block_cipher (algo); - encrypt = new Pipe (new CBC_Encryption (cipher->clone(), new Null_Padding, c2s_key, c2s_iv)); -#endif - - if (macLen) - { -#if BOTAN_PRE_18 && !BOTAN_PRE_15 - hmacOut = new HMAC (getHmacAlgo(c2sMacMethod)); -#else - hash_algo = af.prototype_hash_function (getHmacAlgo (c2sMacMethod)); - hmacOut = new HMAC (hash_algo->clone()); -#endif - hmacOut->set_key (c2s_mac); - } -// if (c2sCmprsMethod == ZLIB) compress = new Pipe (new Zlib_Compression(9)); - - - algo = getCryptAlgo (s2cCryptoMethod); - key_len = max_keylength_of (algo); - if (s2cCryptoMethod == BLOWFISH_CBC) key_len = 16; - else if (s2cCryptoMethod == TWOFISH_CBC) key_len = 32; - decryptBlock = iv_len = block_size_of (algo); - macLen = getMacKeyLen (c2sMacMethod); - if (!algo) return false; - - if (!compute_key(key, 'B', iv_len)) return false; - InitializationVector s2c_iv (key); - - if (!compute_key(key, 'D', key_len)) return false; - SymmetricKey s2c_key (key); - - if (!compute_key(key, 'F', macLen)) return false; - SymmetricKey s2c_mac (key); - -#if BOTAN_PRE_18 && !BOTAN_PRE_15 - decrypt = new Pipe (new CBC_Decryption (algo, "NoPadding", s2c_key, s2c_iv)); -#else - cipher = af.prototype_block_cipher (algo); - decrypt = new Pipe (new CBC_Decryption (cipher->clone(), new Null_Padding, s2c_key, s2c_iv)); -#endif - - if (macLen) - { -#if BOTAN_PRE_18 && !BOTAN_PRE_15 - hmacIn = new HMAC (getHmacAlgo(s2cMacMethod)); -#else - hash_algo = af.prototype_hash_function (getHmacAlgo (s2cMacMethod)); - hmacIn = new HMAC (hash_algo->clone()); -#endif - hmacIn->set_key (s2c_mac); - } -// if (s2cCmprsMethod == ZLIB) decompress = new Pipe (new Zlib_Decompression); - - inited = true; - return true; -} - -bool ne7ssh_crypt::compute_key (Botan::SecureVector& key, Botan::byte ID, uint32 nBytes) -{ - SecureVector hash, newKey; - ne7ssh_string hashBytes; - HashFunction* hashIt; - const char* algo = getHashAlgo(); - uint32 len; - - if (!algo) return false; - hashIt = get_hash (algo); - if (!hashIt) - { - ne7ssh::errors()->push (session->getSshChannel(), "Undefined HASH algorithm encountered while computing the key."); - return false; - } - - hashBytes.addVectorField (K); - hashBytes.addVector (H); - hashBytes.addChar (ID); - hashBytes.addVector (session->getSessionID()); - - hash = hashIt->process (hashBytes.value()); - newKey.set (hash); - len = newKey.size(); - - while (len < nBytes) - { - hashBytes.clear(); - hashBytes.addVectorField (K); - hashBytes.addVector (H); - hashBytes.addVector (newKey); - hash = hashIt->process (hashBytes.value()); - newKey.append (hash); - len = newKey.size(); - } - - key.set (newKey.begin(), nBytes); - delete (hashIt); - return true; -} - -bool ne7ssh_crypt::encryptPacket (Botan::SecureVector &crypted, Botan::SecureVector &hmac, Botan::SecureVector &packet, uint32 seq) -{ - SecureVector macStr; - uint32 nSeq = (uint32)htonl (seq); - - encrypt->start_msg(); - encrypt->write (packet.begin(), packet.size()); - encrypt->end_msg(); -// encrypt->process_msg (packet); - crypted = encrypt->read_all (encrypt->message_count() - 1); - - if (hmacOut) - { - macStr.set ((Botan::byte*)&nSeq, 4); - macStr.append (packet); - hmac = hmacOut->process (macStr); - } - - return true; -} - -bool ne7ssh_crypt::decryptPacket (Botan::SecureVector &decrypted, Botan::SecureVector &packet, uint32 len) -{ - uint32 pLen = packet.size(); - - if (len % decryptBlock) len = len + (len % decryptBlock); - - if (len > pLen) len = pLen; - - decrypt->process_msg (packet.begin(), len); - decrypted = decrypt->read_all (decrypt->message_count() - 1); - - return true; -} - -void ne7ssh_crypt::compressData (Botan::SecureVector &buffer) -{ - SecureVector tmpVar; - if (!compress) return; - - tmpVar.swap (buffer); - compress->process_msg (tmpVar); - tmpVar = compress->read_all (compress->message_count() - 1); - buffer.set (tmpVar); -} - -void ne7ssh_crypt::decompressData (Botan::SecureVector &buffer) -{ - SecureVector tmpVar; - if (!decompress) return; - - tmpVar.swap (buffer); - decompress->process_msg (tmpVar); - tmpVar = decompress->read_all (compress->message_count() - 1); - buffer.set (tmpVar); -} - -void ne7ssh_crypt::computeMac (Botan::SecureVector &hmac, Botan::SecureVector &packet, uint32 seq) -{ - SecureVector macStr; - uint32 nSeq = htonl (seq); - - if (hmacIn) - { - macStr.set ((Botan::byte*)&nSeq, 4); - macStr.append (packet); - hmac = hmacIn->process (macStr); - } - else hmac.destroy(); -} - diff --git a/src/libs/3rdparty/net7ssh/src/crypt.h b/src/libs/3rdparty/net7ssh/src/crypt.h deleted file mode 100644 index 003dcb520d6..00000000000 --- a/src/libs/3rdparty/net7ssh/src/crypt.h +++ /dev/null @@ -1,357 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef CRYPT_H -#define CRYPT_H - -#include -#include -#include -#include -#include -#include -#include -#include - - -// #if defined(BOTAN_EXT_COMPRESSOR_ZLIB) -// #include -// #else -// #error "Zlib support is not compiled into Botan" -// #endif - -#include -#include - -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -class ne7ssh_session; - -/** -@author Andrew Useckas -*/ -class ne7ssh_crypt -{ - private: - ne7ssh_session* session; - - enum kexMethods { DH_GROUP1_SHA1, DH_GROUP14_SHA1 }; - uint32 kexMethod; - - enum hostkeyMethods { SSH_DSS, SSH_RSA }; - uint32 hostkeyMethod; - - enum cryptoMethods { TDES_CBC, AES128_CBC, AES192_CBC, AES256_CBC, BLOWFISH_CBC, CAST128_CBC, TWOFISH_CBC }; - uint32 c2sCryptoMethod; - uint32 s2cCryptoMethod; - - enum macMethods { HMAC_SHA1, HMAC_MD5, HMAC_NONE }; - uint32 c2sMacMethod; - uint32 s2cMacMethod; - - enum cmprsMethods { NONE, ZLIB }; - uint32 c2sCmprsMethod; - uint32 s2cCmprsMethod; - - bool inited; - Botan::SecureVector H; - Botan::SecureVector K; - - Botan::Pipe *encrypt; - Botan::Pipe *decrypt; - Botan::Pipe *compress; - Botan::Pipe *decompress; - Botan::HMAC *hmacOut, *hmacIn; - - Botan::DH_PrivateKey *privKexKey; - - uint32 encryptBlock; - uint32 decryptBlock; - - /** - * Generates a new Public Key, based on Diffie Helman Group1, SHA1 standard. - * @param publicKey Reference to publick Key. The result will be dumped into this var. - * @return If generation successful returns true, otherwise false is returned. - */ - bool getDHGroup1Sha1Public (Botan::BigInt& publicKey); - - /** - * Generates a new Public Key, based on Diffie Helman Group14, SHA1 standard. - * @param publicKey Reference to publick Key. The result will be dumped into this var. - * @return If generation successful returns true, otherwise false is returned. - */ - bool getDHGroup14Sha1Public (Botan::BigInt &publicKey); - - /** - * Generates a new DSA public Key from p,q,g,y values extracted from the host key received from the server. - * @param hostKey Reference to vector containing host key received from a server. - * @return Returns newly generated DSA public Key. If host key vector is trash, more likely application will be aborted within Botan library. - */ - Botan::DSA_PublicKey* getDSAKey (Botan::SecureVector& hostKey); - - /** - * Generates a new RSA public Key from n and e values extracted from the host key received from the server. - * @param hostKey Reference to a vector containing host key. - * @return Returns newly generated ESA public Key. If the hostkey is trash, more likely application will abort within Botan library. - */ - Botan::RSA_PublicKey* getRSAKey (Botan::SecureVector &hostKey); - - /** - * Returns a string represenation of negotiated one way hash algorithm. For DH1_GROUP1_SHA1, "SHA-1" will be returned. - * @return A string containing algorithm name. - */ - const char* getHashAlgo(); - - /** - * Returns a string represenation of negotiated cipher algorithm. - * @param crypto Integer represenating a cipher algorithm. - * @return A string containing algorithm name. - */ - const char* getCryptAlgo (uint32 crypto); - - /** - * Returns a string represenation of negotiated HMAC algorithm. - * @param method Integer represenating HMAC algorithm. - * @return A string containing algorithm name. - */ - const char* getHmacAlgo (uint32 method); - - /** - * Returns key length of the negotiated HMAC algorithm. - *

Used in HMAC key generation. Key length coded in accordance with SSH protocol specs. - * @param method Integer represenating HMAC algorithm. - * @return Key length. - */ - uint32 getMacKeyLen (uint32 method); - - /** - * Returns digest length of negotiated HMAC algorithm. - *

If HMAC integrity checking is enabled, this value is used in the verification process. Digest length coded in accordance with SSH protocol specs. - * @param method Integer represenation of HMAC algorithm. - * @return Key length. - */ - uint32 getMacDigestLen (uint32 method); - - /** - * Function used to compute crypto and HMAC keys. - *

Keys are computed using K, H, ID and sessionID values. All these are concated and hashed. If hash is not long enough K, H, and newly generated key is used over and over again, till keys are long enough. - * @param key Resulting key will be dumped into this var. - * @param ID Single character ID, as specified in SSH protocol specs. - * @param nBytes Key length in bytes. - * @return True if key generation was successful, otherwise false is returned. - */ - bool compute_key (Botan::SecureVector& key, Botan::byte ID, uint32 nBytes); - - - public: - /** - * ne7ssh_crypt class constructor. - * @param _session Pointer to ne7ssh_session class. - */ - ne7ssh_crypt(ne7ssh_session* _session); - - /** - * ne7ssh_crypt class destructor. - */ - ~ne7ssh_crypt(); - - /** - * Checks if cryptographic engine has been initialized. - *

The engine is initialized when all crypto and hmac keys are generated and the cryptographic Pipes are created. - * @return True if cryptographic engine is initialized, otherwise false is returned. - */ - bool isInited () { return inited; } - - /** - * Returns the size of encryption block. - * @return Size of the block. - */ - uint32 getEncryptBlock () { return encryptBlock; } - - /** - * Returns the size of decryption block - * @return Size of the block - */ - uint32 getDecryptBlock () { return decryptBlock; } - - /** - * Returns digest length of HMAC algorithm used to verify integrity of transmited data. - * @return Digest length. - */ - uint32 getMacOutLen () { return getMacDigestLen (c2sMacMethod); } - - /** - * Returns digest length of HMAC algorithm used to verify integrity of data received. - * @return Digest length. - */ - uint32 getMacInLen () { return getMacDigestLen (s2cMacMethod); } - - /** - * This function is used in negotiations of crypto, signing and HMAC algorithms. - * @param result Reference to a vector where negotiated algorithm name will be dumped. - * @param local String containing a list of localy supported algorithms, separated by commas. - * @param remote Reference to vector containing a list of algorithms supported by remote side, separated by commas. - * @return True, if common algorithm was found, otherwise false is returned. - */ - bool agree (Botan::SecureVector& result, const char* local, Botan::SecureVector& remote); - - /** - * Parses negotiated key exchange algorithm vector, and registers it's integer representation with the class. - * @param kexAlgo Reference to a vector containing the negotiated KEX algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedKex (Botan::SecureVector& kexAlgo); - - /** - * Parses negotiated host key algorithm and registers it's integer representation with the class. - * @param hostKeyAlgo Reference to a vector containing the negotiated host key algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedHostkey (Botan::SecureVector& hostKeyAlgo); - - /** - * Parse negotiated client to server cipher algorithm and registers it's integer representation with the class. - * @param cryptoAlgo Reference to a vector containing the negotiated cipher algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedCryptoC2s (Botan::SecureVector& cryptoAlgo); - - /** - * Parses negotiated server to client cipher algorithm and registers it's integer representation with the class. - * @param cryptoAlgo Reference to a vector containing the negotiated cipher algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedCryptoS2c (Botan::SecureVector& cryptoAlgo); - - /** - * Parses negotiated client to server HMAC algorithm and registers it's integer representation with the class. - * @param macAlgo Reference to a vector containing the negotiated HMAC algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedMacC2s (Botan::SecureVector& macAlgo); - - /** - * Parses negotiated server to client HMAC algorithm vector and registers it's integer representation with the class. - * @param macAlgo Reference to a vector containing the negotiated HMAC algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedMacS2c (Botan::SecureVector& macAlgo); - - /** - * Parses negotiated client to server compression algorithm and registers it's integer representation with the class. - * @param cmprsAlgo Reference to a vector containing the negotiated compression algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedCmprsC2s (Botan::SecureVector& cmprsAlgo); - - /** - * Parses negotiated server to client compression algorithm and registers it's integer representation with the class. - * @param cmprsAlgo Reference to a vector containing the negotiated compression algorithm. - * @return True if negotiated algorithm is recognized, otherwise false is returned. - */ - bool negotiatedCmprsS2c (Botan::SecureVector& cmprsAlgo); - - /** - * Generates KEX public key. - * @param publicKey Public key will be dumped into this var. - * @return True if key generation was successful, otherwise false is returned. - */ - bool getKexPublic (Botan::BigInt& publicKey); - - /** - * At the end of key exchange this function is used to generate a shared secret key from private KEX key, that one gets from getKexPublic() function and F value received from a server. - * @param result Secret key will be dumped into this var. - * @param f Reference to F value. - * @return True if key generation was successful, otherwise false is returned. - */ - bool makeKexSecret (Botan::SecureVector& result, Botan::BigInt& f); - - /** - * Computes H value by checking what hash algorithm is used and hashing "val". - * @param result H value will be dumped into this var. - * @param val Reference to vector containing material for H variable generation. - * @return True if key generation was successful, otherwise false is returned. - */ - bool computeH (Botan::SecureVector& result, Botan::SecureVector& val); - - /** - * Verifies host signature. - * @param hostKey Reference to vector containing hostKey. - * @param sig Regerence to vector containing the signature. - * @return True if signature verification was successful, otherwise false is returned. - */ - bool verifySig (Botan::SecureVector& hostKey, Botan::SecureVector& sig); - - /** - * Generates new cipher and HMAC keys. - * @return True if key generation was successful, otherwise false is returned. - */ - bool makeNewKeys (); - - /** - * Encrypts a packet and generates HMAC, if enabled during negotiation. - *

The entire packet is encrypted, only HMAC stays in raw format. - * @param crypted Encrypted packet will be dumped into this var. - * @param hmac HMAC will be dumped into this var. - * @param packet Reference to vector containing unencrypted packet. - * @param seq Transmited packet sequence. - * @return True if encryption successful, otherwise false is returned. - */ - bool encryptPacket (Botan::SecureVector& crypted, Botan::SecureVector& hmac, Botan::SecureVector& packet, uint32 seq); - - /** - * Decrypts a packet. - * @param decrypted Decrypted payload will be dumped into this var. - * @param packet Reference to vector containing encrypted packet. - * @param len Specifies the length of chunk to be decrypted. - * @return True if decryption is successful, otherwise false returned. - */ - bool decryptPacket (Botan::SecureVector& decrypted, Botan::SecureVector& packet, uint32 len); - - /** - * Computes HMAC from specific packet. - * @param hmac Generated HMAC value will be dumped into this var. - * @param packet Reference to vector containing packet for HMAC generation. - * @param seq receive sequence. - */ - void computeMac (Botan::SecureVector& hmac, Botan::SecureVector& packet, uint32 seq); - - /** - * Compresses the data. - * @param buffer Reference to vector containing payload to be compress. Results will also be dumped into this var. - */ - void compressData (Botan::SecureVector& buffer); - - /** - * Decompresses the data. - * @param buffer Reference to vector containing packet payload to decompress. Result will also be dumped into this var. - */ - void decompressData (Botan::SecureVector& buffer); - - /** - * Checks if compression is enabled. - * @return If compression is enabled returns true, otherwise false is returned. - */ - bool isCompressed () { if (decompress) return true; else return false; } - - /** - * Returns private AutoSeededRNG object. - * @return Point to AutoSeededRNG object. - */ -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh.cpp deleted file mode 100644 index bb1d268582e..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh.cpp +++ /dev/null @@ -1,983 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include -#include -#include -#include -#include -#include "ne7ssh_string.h" -#include "ne7ssh_connection.h" -#include "ne7ssh.h" -#include "ne7ssh_keys.h" -#include "ne7ssh_mutex.h" - -#if defined(WIN32) || defined(__MINGW32__) -# define kill(pid,signo) raise(signo) -# define ne7ssh_thread_join(hndl,ign) WaitForSingleObject(hndl, INFINITE) -# define ne7ssh_thread_exit(sig) ExitThread(sig) -#else -# define ne7ssh_thread_create pthread_create -# define ne7ssh_thread_join pthread_join -# define ne7ssh_thread_exit pthread_exit -#endif - -using namespace Botan; -using namespace std; - -const char* ne7ssh::SSH_VERSION = "SSH-2.0-NetSieben_1.3.2"; -Ne7sshError* ne7ssh::errs = NULL; - -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 -RandomNumberGenerator* ne7ssh::rng = NULL; -#endif - -#ifdef _DEMO_BUILD -const char* ne7ssh::MAC_ALGORITHMS = "none"; -const char* ne7ssh::CIPHER_ALGORITHMS = "3des-cbc"; -const char* ne7ssh::KEX_ALGORITHMS = "diffie-hellman-group1-sha1"; -const char* ne7ssh::HOSTKEY_ALGORITHMS = "ssh-dss"; -#else -const char* ne7ssh::MAC_ALGORITHMS = "hmac-md5,hmac-sha1,none"; -const char* ne7ssh::CIPHER_ALGORITHMS = "aes256-cbc,aes192-cbc,twofish-cbc,twofish256-cbc,blowfish-cbc,3des-cbc,aes128-cbc,cast128-cbc"; -const char* ne7ssh::KEX_ALGORITHMS = "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1"; -const char* ne7ssh::HOSTKEY_ALGORITHMS = "ssh-dss,ssh-rsa"; -#endif - -const char* ne7ssh::COMPRESSION_ALGORITHMS = "none"; -char *ne7ssh::PREFERED_CIPHER = 0; -char *ne7ssh::PREFERED_MAC = 0; -Ne7ssh_Mutex ne7ssh::mut; -bool ne7ssh::running = false; -bool ne7ssh::selectActive = true; - -class Locking_AutoSeeded_RNG : public Botan::RandomNumberGenerator -{ - public: - Locking_AutoSeeded_RNG() { rng = new Botan::AutoSeeded_RNG(); } - ~Locking_AutoSeeded_RNG() { delete rng; } - - void randomize(Botan::byte output[], u32bit length) - { - mutex.lock(); - rng->randomize(output, length); - mutex.unlock(); - } - - void clear() throw() - { - mutex.lock(); - rng->clear(); - mutex.unlock(); - } - - std::string name() const { return rng->name(); } - - void reseed(u32bit bits_to_collect) - { - mutex.lock(); - rng->reseed(bits_to_collect); - mutex.unlock(); - } - - void add_entropy_source(EntropySource* source) - { - mutex.lock(); - rng->add_entropy_source(source); - mutex.unlock(); - } - - void add_entropy(const Botan::byte in[], u32bit length) - { - mutex.lock(); - rng->add_entropy(in, length); - mutex.unlock(); - } - - private: - Ne7ssh_Mutex mutex; - Botan::RandomNumberGenerator* rng; -}; - - - -ne7ssh::ne7ssh() : connections(0), conCount(0) -{ - errs = new Ne7sshError(); - if (ne7ssh::running) - { - errs->push (-1, "Cannot initialize more than more instance of ne7ssh class within the same application. Aborting."); - kill (0, SIGABRT); - return; - } - init = new LibraryInitializer("thread_safe"); - ne7ssh::running = true; - allConns.conns = 0; - allConns.count = 0; - -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 - ne7ssh::rng = new Locking_AutoSeeded_RNG(); -#endif - -#if !defined(WIN32) && !defined(__MINGW32__) - int status = ne7ssh_thread_create (&select_thread, NULL, selectThread, (void*)this); - if (status) - { - errs->push (-1, "Failure creating a new thread."); - return; - } -#else - if ((select_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) selectThread, (LPVOID)this, 0, NULL)) == NULL) - { - errs->push (-1, "Failure creating new thread."); - return; - } -#endif - -} - -ne7ssh::~ne7ssh() -{ - uint32 i; - long ign; - - ne7ssh::running = false; - lock(); - for (i = 0; i < conCount; i++) - close(i); - unlock(); - - ne7ssh_thread_join (select_thread, (void**)&ign); - - if (conCount) - { - for (i = 0; i < conCount; i++) - delete connections[i]; - free (connections); - } - else if (connections) free (connections); - - if (ne7ssh::PREFERED_CIPHER) - { - free (ne7ssh::PREFERED_CIPHER); - ne7ssh::PREFERED_CIPHER = 0; - } - if (ne7ssh::PREFERED_MAC) - { - free (ne7ssh::PREFERED_MAC); - ne7ssh::PREFERED_MAC = 0; - } - if (errs) - { - delete (errs); - errs = 0; - } -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 - if (ne7ssh::rng) - { - delete (rng); - rng = 0; - } -#endif - - delete init; - -} - -void *ne7ssh::selectThread (void *initData) -{ - ne7ssh *_ssh = (ne7ssh*) initData; - uint32 i, z; - int status = 0; - fd_set rd; - SOCKET rfds; - struct timeval waitTime; - connStruct* allConns; - bool cmdOrShell = false; - bool fdIsSet; - - while (running) - { - if (!lock()) - { - _ssh->selectDead(); - return 0; - } - allConns = _ssh->getConnetions (); - for (i = 0; i < allConns->count; i++) - { - if (allConns->conns[i]->isOpen() && allConns->conns[i]->data2Send() && !allConns->conns[i]->isSftpActive()) - allConns->conns[i]->sendData(); - } - - waitTime.tv_sec = 0; - waitTime.tv_usec = 10000; - - rfds = 0; - - FD_ZERO (&rd); - fdIsSet = false; - - for (i = 0; i < allConns->count; i++) - { - cmdOrShell = (allConns->conns[i]->isRemoteShell() || allConns->conns[i]->isCmdRunning()) ? true : false; - if (allConns->conns[i]->isOpen() && cmdOrShell) - { - rfds = rfds > allConns->conns[i]->getSocket() ? rfds : allConns->conns[i]->getSocket(); - FD_SET (allConns->conns[i]->getSocket(), &rd); - if (!fdIsSet) fdIsSet = true; - } - else if ((allConns->conns[i]->isConnected() && allConns->conns[i]->isRemoteShell()) || allConns->conns[i]->isCmdClosed()) - { - delete (allConns->conns[i]); - allConns->conns[i] = 0; - allConns->count--; - for (z = i; z < allConns->count; z++) - { - allConns->conns[z] = allConns->conns[z + 1]; - allConns->conns[z + 1] = 0; - } - _ssh->setCount (allConns->count); - i--; - } - } - if (!unlock()) - { - _ssh->selectDead(); - return 0; - } - - if (fdIsSet) - { - if (rfds) status = select(rfds + 1, &rd, NULL, NULL, &waitTime); - else status = select(rfds + 1, NULL, &rd, NULL, &waitTime); - } - else usleep (1000); - if (status == -1) - { - errs->push (-1, "Error within select thread."); - usleep (1000); - } - - if (!lock()) - { - _ssh->selectDead(); - return 0; - } - - allConns = _ssh->getConnetions (); - for (i = 0; i < allConns->count; i++) - { - if (allConns->conns[i]->isOpen() && FD_ISSET (allConns->conns[i]->getSocket(), &rd)) - allConns->conns[i]->handleData(); - } - if (!unlock()) - { - _ssh->selectDead(); - return 0; - } - } - return 0; -} - -int ne7ssh::connectWithPassword (const char *host, const int port, - const char* username, const char* password, bool shell, const int timeout, - void (*callbackFunc)(void *), void *callbackArg) -{ - int channel; - uint32 currentRecord, z; - uint32 channelID; - - - if (!lock()) return -1; - ne7ssh_connection* con = new ne7ssh_connection (callbackFunc, callbackArg); - if (!conCount) connections = (ne7ssh_connection**) malloc (sizeof (ne7ssh_connection*)); - else connections = (ne7ssh_connection**) realloc (connections, sizeof (ne7ssh_connection*) * (conCount + 1)); - connections[conCount++] = con; - allConns.count = conCount; - allConns.conns = connections; - channelID = getChannelNo(); - con->setChannelNo (channelID); - - if (!unlock()) return -1; - channel = con->connectWithPassword (channelID, host, port, username, password, shell, timeout); - - if (channel == -1) - { - if (!lock()) return -1; - for (z = 0; z < allConns.count; z++) - { - if (allConns.conns[z] == con) - { - currentRecord = z; - break; - } - } - if (z == allConns.count) - { - ne7ssh::errors()->push (-1, "Unexpected behaviour!"); - return -1; - } - - delete con; - allConns.conns[currentRecord] = 0; - allConns.count--; - for (z = currentRecord; z < allConns.count; z++) - { - allConns.conns[z] = allConns.conns[z + 1]; - allConns.conns[z + 1] = 0; - } - conCount = allConns.count; - if (!unlock()) return -1; - } - return channel; -} - -int ne7ssh::connectWithKey (const char* host, const int port, - const char* username, const char* privKeyFileName, bool shell, - const int timeout, void (*callbackFunc)(void *), void *callbackArg) -{ - int channel; - uint32 currentRecord, z; - uint32 channelID; - - if (!lock()) return -1; - ne7ssh_connection* con = new ne7ssh_connection (callbackFunc, callbackArg); - if (!conCount) connections = (ne7ssh_connection**) malloc (sizeof (ne7ssh_connection*) * (conCount + 1)); - else connections = (ne7ssh_connection**) realloc (connections, sizeof (ne7ssh_connection*) * (conCount + 1)); - connections[conCount++] = con; - allConns.count = conCount; - allConns.conns = connections; - channelID = getChannelNo(); - con->setChannelNo (channelID); - - if (!unlock()) return -1; - - channel = con->connectWithKey (channelID, host, port, username, privKeyFileName, shell, timeout); - - if (channel == -1) - { - if (!lock()) return -1; - for (z = 0; z < allConns.count; z++) - { - if (allConns.conns[z] == con) - { - currentRecord = z; - break; - } - } - if (z == allConns.count) - { - ne7ssh::errors()->push (-1, "Unexpected behaviour!"); - return -1; - } - - delete con; - allConns.conns[currentRecord] = 0; - allConns.count--; - for (z = currentRecord; z < allConns.count; z++) - { - allConns.conns[z] = allConns.conns[z + 1]; - allConns.conns[z + 1] = 0; - } - conCount = allConns.count; - if (!unlock()) return -1; - } - return channel; -} - - -bool ne7ssh::send (const char* data, int channel) -{ - uint32 i; - - if (!lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - connections[i]->sendData (data); - if (!unlock()) return false; - else return true; - } - } - errs->push (-1, "Bad channel: %i specified for sending.", channel); - if (!unlock()) return false; - return false; -} - -bool ne7ssh::initSftp (Ne7SftpSubsystem& _sftp, int channel) -{ - uint32 i; - Ne7sshSftp *__sftp; - - if (!lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - __sftp = connections[i]->startSftp (); - if (!__sftp) - { - if (!unlock()) return false; - return false; - } - else - { - Ne7SftpSubsystem sftpSubsystem (__sftp); - _sftp = sftpSubsystem; - if (!unlock()) return false; - return true; - } - } - } - if (!unlock()) return false; - errs->push (-1, "Bad channel: %i specified. Cannot initialize SFTP subsystem.", channel); - return false; -} - - -bool ne7ssh::sendCmd (const char* cmd, int channel, int timeout) -{ - uint32 i; - time_t cutoff = 0; - bool status; - - if (timeout) cutoff = time(NULL) + timeout; - - if (!lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - status = connections[i]->sendCmd (cmd); - if (!status) - { - if (!unlock()) return false; - return false; - } - - if (!timeout) - { - while (!connections[i]->getCmdComplete()) - { - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - break; - } - if (i == conCount) - { - errs->push (-1, "Bad channel: %i specified for sending.", channel); - unlock(); - return false; - } - if (!connections[i]->getCmdComplete()) - { - if (!unlock()) return false; - usleep (10000); - if (!lock()) return false; - } - } - } - else if (timeout > 0) - { - while (!connections[i]->getCmdComplete()) - { - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - break; - } - if (i == conCount) - { - errs->push (-1, "Bad channel: %i specified for sending.", channel); - if (!unlock()) return false; - return false; - } - if (!connections[i]->getCmdComplete()) - { - if (!unlock()) return false; - usleep (10000); - if (!lock()) return false; - if (!cutoff) continue; - if (time(NULL) >= cutoff) break; - } - } - } - if (!unlock()) return false; - return true; - } - } - errs->push (-1, "Bad channel: %i specified for sending.", channel); - if (!unlock()) return false; - return false; -} - - -bool ne7ssh::close (int channel) -{ - uint32 i; - bool status = false; - - if (channel == -1) - { - errs->push (-1, "Bad channel: %i specified for closing.", channel); - return false; - } - - if (!lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - status = connections[i]->sendClose(); - } - errs->deleteChannel (channel); - - if (!unlock()) return false; - - return status; -} - -bool ne7ssh::waitFor (int channel, const char* str, uint32 timeSec) -{ - Botan::byte one; - const Botan::byte *carret; - const char* buffer; - size_t len = 0, carretLen = 0, str_len = 0, prevLen = 0; - time_t cutoff = 0; - bool dataChange; - - if (timeSec) cutoff = time(NULL) + timeSec; - - if (channel == -1) - { - errs->push (-1, "Bad channel: %i specified for waiting.", channel); - return false; - } - - str_len = strlen (str); - - while (1) - { - if (!lock()) return false; - buffer = read (channel, false); - if (buffer) - { - len = getReceivedSize(channel, false); - if (cutoff && prevLen && len == prevLen) dataChange = false; - else - { - dataChange = true; - prevLen = len; - } - carret = (const Botan::byte*) buffer + len - 1; - one = *str; - carretLen = 1; - - while (carretLen <= len) - { - if ((*carret == one) && (str_len <= carretLen)) - { - if (!memcmp (carret, str, str_len)) - { - if (!unlock()) return false; - return true; - } - } - carretLen++; - carret--; - } - } - else (dataChange = false); - if (!unlock()) return false; - usleep (10000); - if (!cutoff) continue; - if (time(NULL) >= cutoff) break; - } - return false; -} - - -const char* ne7ssh::read (int channel, bool do_lock) -{ - uint32 i; - SecureVector data; - - if (channel == -1) - { - errs->push (-1, "Bad channel: %i specified for reading.", channel); - return false; - } - if (do_lock && !lock()) return false; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - data = connections[i]->getReceived(); - if (data.size()) - { - if (do_lock && !unlock()) return false; - return ((const char*)connections[i]->getReceived().begin()); - } - } - } - if (do_lock && !unlock()) return false; - return 0; -} - -char *ne7ssh::readAndReset(int channel, char *(*alloc)(size_t)) -{ - if (channel == -1) - { - errs->push (-1, "Bad channel: %i specified for reading.", channel); - return 0; - } - if (!lock()) return 0; - char *buffer = 0; - for (uint32 i = 0; i < conCount; i++) - { - SecureVector data; - if (channel == connections[i]->getChannelNo()) - { - data = connections[i]->getReceived(); - if (data.size()) - { - Botan::SecureVector& received=connections[i]->getReceived(); - buffer = alloc(received.size()); - strncpy(buffer, reinterpret_cast(received.begin()), received.size()); - connections[i]->resetReceiveBuffer(); - } - break; - } - } - if (!unlock()) return false; - return buffer; -} - - -void* ne7ssh::readBinary (int channel) -{ - uint32 i; - SecureVector data; - - if (channel == -1) - { - errs->push (-1, "Bad channel: %i specified for reading.", channel); - return false; - } - - if (!lock()) return 0; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - data = connections[i]->getReceived(); - if (data.size()) - { - if (!unlock()) return 0; - return ((void*)connections[i]->getReceived().begin()); - } - } - } - if (!unlock()) return 0; - return 0; -} - - -int ne7ssh::getReceivedSize (int channel, bool do_lock) -{ - uint32 i; - int size; - - if (do_lock && !lock()) return 0; - for (i = 0; i < conCount; i++) - { - if (channel == connections[i]->getChannelNo()) - { - if (!connections[i]->getReceived().size()) - { - if (do_lock && !unlock()) return 0; - return 0; - } - else - { - size = connections[i]->getReceived().size(); - if (do_lock && !unlock()) return 0; - return (size); - } - } - } - if (do_lock && !unlock()) return 0; - return 0; -} - -uint32 ne7ssh::getChannelNo () -{ - uint32 i; - int32 channelID = 1; - - if (!conCount) - { - return channelID; - } - - for (channelID = 1; channelID != 0x7FFFFFFF; channelID++) - { - for (i = 0; i < conCount; i++) - { - if (connections[i] && (connections[i]->getChannelNo() == channelID)) - break; - } - if (i == conCount) break; - } - - if (channelID == 0x7FFFFFFF) - { - errs->push (-1, "Maximum theoretical channel count reached!"); - return 0; - } - else return channelID; -} - -void ne7ssh::setOptions (const char* prefCipher, const char* prefHmac) -{ - size_t len = 0; - - if (prefCipher) len = strlen (prefCipher); - if (!ne7ssh::PREFERED_CIPHER && len) ne7ssh::PREFERED_CIPHER = (char*) malloc (len); - else if (len) ne7ssh::PREFERED_CIPHER = (char*) realloc (ne7ssh::PREFERED_CIPHER, len); - memcpy (ne7ssh::PREFERED_CIPHER, prefCipher, len); - - len = 0; - if (prefHmac) len = strlen (prefHmac); - if (!ne7ssh::PREFERED_MAC && len) ne7ssh::PREFERED_MAC = (char*) malloc (len); - else if (len) ne7ssh::PREFERED_MAC = (char*) realloc (ne7ssh::PREFERED_MAC, len); - memcpy (ne7ssh::PREFERED_MAC, prefHmac, len); -} - -bool ne7ssh::lock () -{ - int status; - status = ne7ssh::mut.lock(); - - if (!isSelectActive()) - { - errs->push (-1, "Select thread appears to be dead."); - return false; - } - - if (status) - { - errs->push (-1, "Could not aquire a mutex lock. Error: %i.", status); - return false; - } - return true; -} - -bool ne7ssh::unlock () -{ - int status; - status = ne7ssh::mut.unlock(); - - if (!isSelectActive()) - { - errs->push (-1, "Select thread appears to be dead."); - return false; - } - - if (status) - { - errs->push (-1, "Error while releasing a mutex lock. Error: %i.", status); - return false; - } - return true; -} - -SSH_EXPORT Ne7sshError* ne7ssh::errors() -{ - return errs; -} - -bool ne7ssh::generateKeyPair (const char* type, const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize) -{ - ne7ssh_keys keyPair; - enum keyAlgos { DSA, RSA }; - uint8 keyAlgo; - - if (!memcmp (type, "dsa", 3)) - keyAlgo = DSA; - else if (!memcmp (type, "rsa", 3)) - keyAlgo = RSA; - - switch (keyAlgo) - { - case DSA: - if (!keySize) - return keyPair.generateDSAKeys (fqdn, privKeyFileName, pubKeyFileName); - else - return keyPair.generateDSAKeys (fqdn, privKeyFileName, pubKeyFileName, keySize); - - case RSA: - if (!keySize) - return keyPair.generateRSAKeys (fqdn, privKeyFileName, pubKeyFileName); - else - return keyPair.generateRSAKeys (fqdn, privKeyFileName, pubKeyFileName, keySize); - - default: - errs->push (-1, "The specfied key algorithm: %i not supported", keyAlgo); - return false; - } - return false; -} - -Ne7SftpSubsystem::Ne7SftpSubsystem () : inited(false), sftp(0) -{ -} - -Ne7SftpSubsystem::Ne7SftpSubsystem (Ne7sshSftp* _sftp) : inited(true), sftp((Ne7sshSftp*)_sftp) -{ -} - -Ne7SftpSubsystem::~Ne7SftpSubsystem () -{ -} - -bool Ne7SftpSubsystem::setTimeout (uint32 _timeout) -{ - if (!inited) return errorNotInited(); - sftp->setTimeout (_timeout); - return true; -} - -uint32 Ne7SftpSubsystem::openFile (const char* filename, uint8 mode) -{ - if (!inited) return errorNotInited(); - return sftp->openFile (filename, mode); -} - -uint32 Ne7SftpSubsystem::openDir (const char* dirname) -{ - if (!inited) return errorNotInited(); - return sftp->openDir (dirname); -} - -bool Ne7SftpSubsystem::readFile (uint32 fileID, uint64 offset) -{ - if (!inited) return errorNotInited(); - return sftp->readFile (fileID, offset); -} - -bool Ne7SftpSubsystem::writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 /* offset */) -{ - if (!inited) return errorNotInited(); - return sftp->writeFile (fileID, data, len); -} - -bool Ne7SftpSubsystem::closeFile (uint32 fileID) -{ - if (!inited) return errorNotInited(); - return sftp->closeFile (fileID); -} - -bool Ne7SftpSubsystem::errorNotInited () -{ - ne7ssh::errors()->push (-1, "This SFTP system has not been initialized."); - return false; -} - -bool Ne7SftpSubsystem::getFileAttrs (fileAttrs& attrs, const char* filename, bool followSymLinks) -{ - if (!inited) return errorNotInited(); - return sftp->getFileAttrs (attrs, filename, followSymLinks); -} - -bool Ne7SftpSubsystem::get (const char* remoteFile, FILE* localFile) -{ - if (!inited) return errorNotInited(); - return sftp->get (remoteFile, localFile); -} - -bool Ne7SftpSubsystem::put (FILE* localFile, const char* remoteFile) -{ - if (!inited) return errorNotInited(); - return sftp->put (localFile, remoteFile); -} - -bool Ne7SftpSubsystem::rm (const char* remoteFile) -{ - if (!inited) return errorNotInited(); - return sftp->rm (remoteFile); -} - -bool Ne7SftpSubsystem::mv (const char* oldFile, const char* newFile) -{ - if (!inited) return errorNotInited(); - return sftp->mv (oldFile, newFile); -} - -bool Ne7SftpSubsystem::mkdir (const char* remoteDir) -{ - if (!inited) return errorNotInited(); - return sftp->mkdir (remoteDir); -} - -bool Ne7SftpSubsystem::rmdir (const char* remoteDir) -{ - if (!inited) return errorNotInited(); - return sftp->rmdir (remoteDir); -} - -const char* Ne7SftpSubsystem::ls (const char* remoteDir, bool longNames) -{ - if (!inited) - { - errorNotInited(); - return 0; - } - return sftp->ls (remoteDir, longNames); -} - -bool Ne7SftpSubsystem::cd (const char* remoteDir) -{ - if (!inited) return errorNotInited(); - return sftp->cd (remoteDir); -} - -bool Ne7SftpSubsystem::chmod (const char* remoteFile, const char* mode) -{ - if (!inited) return errorNotInited(); - return sftp->chmod (remoteFile, mode); -} - -bool Ne7SftpSubsystem::chown (const char* remoteFile, uint32_t uid, uint32_t gid) -{ - if (!inited) return errorNotInited(); - return sftp->chown (remoteFile, uid, gid); -} - -bool Ne7SftpSubsystem::isFile (const char* remoteFile) -{ - if (!inited) return errorNotInited(); - return sftp->isFile (remoteFile); -} - -bool Ne7SftpSubsystem::isDir (const char* remoteFile) -{ - if (!inited) return errorNotInited(); - return sftp->isDir (remoteFile); -} - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh.h b/src/libs/3rdparty/net7ssh/src/ne7ssh.h deleted file mode 100644 index 57cc281b902..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh.h +++ /dev/null @@ -1,521 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_H -#define NE7SSH_H - -#include - -//#include -//#include "error.h" - -#if BOTAN_VERSION_MAJOR > 1 -# error Unsupported Botan Version -#endif - -#define BOTAN_PRE_15 (BOTAN_VERSION_MINOR < 5) -#define BOTAN_PRE_18 (BOTAN_VERSION_MINOR < 8) - -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 -# include -# include -#endif - -#include -#include -#include -#if !defined(WIN32) && !defined(__MINGW32__) -# include -# include -# include -typedef pthread_t ne7ssh_thread_t; -#else -#include -typedef HANDLE ne7ssh_thread_t; -#endif - -#include "ne7ssh_types.h" -#include "ne7ssh_error.h" -#include "ne7ssh_mutex.h" - -#define SSH2_MSG_DISCONNECT 1 -#define SSH2_MSG_IGNORE 2 - -#define SSH2_MSG_KEXINIT 20 -#define SSH2_MSG_NEWKEYS 21 - -#define SSH2_MSG_KEXDH_INIT 30 -#define SSH2_MSG_KEXDH_REPLY 31 - -#define SSH2_MSG_SERVICE_REQUEST 5 -#define SSH2_MSG_SERVICE_ACCEPT 6 - -#define SSH2_MSG_USERAUTH_REQUEST 50 -#define SSH2_MSG_USERAUTH_FAILURE 51 -#define SSH2_MSG_USERAUTH_SUCCESS 52 -#define SSH2_MSG_USERAUTH_BANNER 53 -#define SSH2_MSG_USERAUTH_PK_OK 60 - -#define SSH2_MSG_CHANNEL_OPEN 90 -#define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION 91 -#define SSH2_MSG_CHANNEL_OPEN_FAILURE 92 -#define SSH2_MSG_CHANNEL_WINDOW_ADJUST 93 -#define SSH2_MSG_CHANNEL_DATA 94 -#define SSH2_MSG_CHANNEL_EXTENDED_DATA 95 -#define SSH2_MSG_CHANNEL_EOF 96 -#define SSH2_MSG_CHANNEL_CLOSE 97 -#define SSH2_MSG_CHANNEL_REQUEST 98 -#define SSH2_MSG_CHANNEL_SUCCESS 99 -#define SSH2_MSG_CHANNEL_FAILURE 100 - -class ne7ssh_connection; - -/** Structure used to store connections. Used to better sync with selectThread. */ -typedef struct { - /** Pointer to all active connections.*/ - ne7ssh_connection **conns; - /** Active connection count. */ - uint32 count; -} connStruct; - -/** definitions for Botan */ -namespace Botan -{ - class LibraryInitializer; -} - -class Ne7SftpSubsystem; - -/** -@author Andrew Useckas -*/ -class SSH_EXPORT ne7ssh -{ - private: - - static Ne7ssh_Mutex mut; - Botan::LibraryInitializer *init; - ne7ssh_connection **connections; - uint32 conCount; - static bool running; - static bool selectActive; - connStruct allConns; - - - /** - * Send / Receive thread. - *

For Internal use only - * @return Usually 0 when thread terminates - */ - static void *selectThread (void*); - - /** - * Returns the number of active channel. - * @return Active channel. - */ - uint32 getChannelNo (); - ne7ssh_thread_t select_thread; - bool connected; - - /** - * Lock the mutex. - * @return True if lock aquired. Oterwise false. - */ - static bool lock (); - - /** - * Unlock the mutext. - * @return True if the mutext successfully unlocked. Otherwise false. - */ - static bool unlock (); - static Ne7sshError* errs; - - public: -#if !BOTAN_PRE_18 && !BOTAN_PRE_15 - static Botan::RandomNumberGenerator *rng; -#endif - static const char* SSH_VERSION; - static const char* KEX_ALGORITHMS; - static const char* HOSTKEY_ALGORITHMS; - static const char* MAC_ALGORITHMS; - static const char* CIPHER_ALGORITHMS; - static const char* COMPRESSION_ALGORITHMS; - static char* PREFERED_CIPHER; - static char* PREFERED_MAC; - - /** - * Default constructor. Used to allocate required memory, as well as initializing cryptographic routines. - */ - ne7ssh(); - /** - * Destructor. - */ - ~ne7ssh(); - - /** - * Connect to remote host using SSH2 protocol, with password authentication. - * @param host Hostname or IP to connect to. - * @param port Port to connect to. - * @param username Username to use in authentication. - * @param password Password to use in authentication. - * @param shell Set this to true if you wish to launch the shell on the remote end. By default set to true. - * @param timeout Timeout for the connection procedure, in seconds. - * @return Returns newly assigned channel ID, or -1 if connection failed. - */ - int connectWithPassword (const char* host, const int port, const char* username, - const char* password, bool shell = true, const int timeout = 0, - void (*callbackFunc)(void *) = 0, void *callbackArg = 0); - - /** - * Connect to remote host using SSH2 protocol, with publickey authentication. - *

Reads private key from a file specified, and uses it to authenticate to remote host. - * Remote side must have public key from the key pair for authentication to succeed. - * @param host Hostname or IP to connect to. - * @param port Port to connect to. - * @param username Username to use in authentication. - * @param privKeyFileName Full path to file containing private key used in authentication. - * @param shell Set this to true if you wish to launch the shell on the remote end. By default set to true. - * @param timeout Timeout for the connection procedure, in seconds. - * @return Returns newly assigned channel ID, or -1 if connection failed. - */ - int connectWithKey (const char* host, const int port, const char* username, - const char* privKeyFileName, bool shell = true, const int timeout = 0, - void (*callbackFunc)(void *) = 0, void *callbackArg = 0); - - /** - * Retrieves a pointer to all current connections. - *

For internal use only. - * @return Returns pointer to pointers to ne7ssh_connection class, or 0 if no connection exist. - */ -// ne7ssh_connection** getConnections () { return connections; } - - connStruct* getConnetions () { return &allConns; } - - /** - * Retreives count of current connections - *

For internal use only. - * @return Returns current count of connections. - */ -// uint32 getConCount () { return conCount; } - - /** - * Sends a command string on specified channel, provided the specified channel has been previously opened through connectWithPassword() function. - * @param data Pointer to the command string to send to a channel. - * @param channel Channel to send data on. - * @return Returns true if the send was successful, otherwise false returned. - */ - bool send (const char* data, int channel); - - /** - * Can be used to send a single command and disconnect, similiar behavior to openssh when one appends a command to the end of ssh command. - * @param cmd Remote command to execute. Can be used to read files on unix with 'cat [filename]'. - * @param channel Channel to send the command. - * @param timeout How long to wait before giving up. - * @return Returns true if the send was successful, otherwise false returned. - */ - bool sendCmd (const char* cmd, int channel, int timeout); - - /** - * Closes specified channel. - * @param channel Channel to close. - * @return Returns true if closing was successful, otherwise false is returned. - */ - bool close (int channel); - - /** - * Sets connection count. - *

For internal use only. - * @param count Integer to set connection count. - */ - void setCount (uint32 count) { conCount = count; } - - /** - * Reads all data from receiving buffer on specified channel. - * @param channel Channel to read data on. - * @return Returns string read from receiver buffer or 0 if buffer is empty. - */ - const char* read (int channel, bool do_lock=true); - - /** - * Reads all data from receiving buffer on specified channel into a newly - * allocated buffer and empties the receive buffer afterwards. - * @param channel Channel to read data on. - * @param alloc Pointer to function allocating the memory for the buffer - * to return. - * @return Returns string read from receiver buffer or 0 if buffer is empty. - * Freeing the returned buffer is the user's responsibility. - */ - char* readAndReset (int channel, char* (*alloc)(size_t)); - - /** - * Reads all data from receiving buffer on specified channel. Returns pointer to void. Together with getReceivedSize and sendCmd can be used to read remote files. - * @param channel Channel to read data on. - * @return Returns pointer to the start of binary data or 0 if nothing received. - */ - void* readBinary (int channel); - - /** - * Returns the size of all data read. Used to read buffer passed 0x0. - * @param channel Channel number which buffer size to check. - * @return Return size of the buffer, or 0x0 if receive buffer empty. - */ - int getReceivedSize (int channel, bool do_lock=true); - - /** - * Wait until receiving buffer contains a string passed in str, or until the function timeouts as specified in timeout. - * @param channel Channel to wait on. - * @param str String to wait for. - * @param timeout Timeout in seconds. - * @return Returns true if string specified in str variable has been received, otherwise false returned. - */ - bool waitFor (int channel, const char* str, uint32 timeout=0); - - /** - * Sets prefered cipher and hmac algorithms. - *

This function as to be executed before connection functions, just after initialization of ne7ssh class. - * @param prefCipher prefered cipher algorithm string representation. Possible cipher algorithms are aes256-cbc, twofish-cbc, twofish256-cbc, blowfish-cbc, 3des-cbc, aes128-cbc, cast128-cbc. - * @param prefHmac preferede hmac algorithm string representation. Possible hmac algorithms are hmac-md5, hmac-sha1, none. - */ - void setOptions (const char* prefCipher, const char* prefHmac); - - - /** - * Generate key pair. - * @param type String specifying key type. Currently "dsa" and "rsa" are supported. - * @param fqdn User id. Usually an Email. For example "test@netsieben.com" - * @param privKeyFileName Full path to a file where generated private key should be written. - * @param pubKeyFileName Full path to a file where generated public key should be written. - * @param keySize Desired key size in bits. If not specified will default to 2048. - * @return Return true if keys generated and written to the files. Otherwise false is returned. - */ - bool generateKeyPair (const char* type, const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 0); - - /** - * This method is used to initialize a new SFTP subsystem. - * @param _sftp Reference to SFTP subsystem to be initialized. - * @param channel Channel ID returned by one of the connect methods. - * @return True if the new subsystem successfully initialized. False on any error. - */ - bool initSftp (Ne7SftpSubsystem& _sftp, int channel); - - /** - * This method returns a pointer to the current Error collection. - * @return the Error collection - */ - static Ne7sshError* errors(); - - static bool isSelectActive() { return selectActive; } - static void selectDead() { selectActive = false; } -}; - -class Ne7sshSftp; - -/** - @author Andrew Useckas -*/ -class SSH_EXPORT Ne7SftpSubsystem -{ - private: - bool inited; - Ne7sshSftp* sftp; - -/** - * Pushes and error to the error buffer, if this subsystem has not been initialized before usage. - * @return True if the push succeeds. Otherwise false. - */ -bool errorNotInited (); - - public: - /** Structure used to store rmote file attributes. */ - typedef struct - { - uint64_t size; - uint32_t owner; - uint32_t group; - uint32_t permissions; - uint32_t atime; - uint32_t mtime; - } fileAttrs; - - /** Modes used when opening a remote file. */ - enum writeMode { READ, OVERWRITE, APPEND }; - - /** - * Default constructor. - */ - Ne7SftpSubsystem (); - - /** - * Constructor used to initialize the subsystem with a new Ne7sshSftp class instance. - * @param _sftp Ne7sshSftp class instance. - */ - Ne7SftpSubsystem (class Ne7sshSftp* _sftp); - - /** - * Default destructor. - */ - ~Ne7SftpSubsystem(); - - /** - * This method is used to set a timeout for all SFTP subsystem communications. - * @param _timeout Timeout in seconds. - * @return True if timeout set, otherwise false. - */ - bool setTimeout (uint32 _timeout); - - /** - * Low level method used to open a remote file. - * @param filename Relative or full path to the file. - * @param mode Mode to be used when opening the file. Can be one of the modes defined by writeMode class variable. - * @return Newly opened file ID or 0 if file could not be opened. - */ - uint32 openFile (const char* filename, uint8 mode); - - /** - * Low level method used to open an inode containing file entries a.k.a directory. - * @param dirname Relative or full path to the inode. - * @return Newly opened file ID or 0 if the inode could not be opened. - */ - uint32 openDir (const char* dirname); - - /** - * Low level method used to read datablock up to the size of SFTP_MAX_MSG_SIZE from a file. - * @param fileID File ID retruned by openFile() method. - * @param offset Offset. - * @return True if file content successfully read and placed in the buffer. Otherwise false. - */ - bool readFile (uint32 fileID, uint64 offset = 0); - - /** - * Low level method used to write data-block up to the size of SFTP_MAX_MSG_SIZE to a remote file. - * @param fileID File ID returned by openFile() method. - * @param data Pointer to a buffer containing the data. - * @param len Length of the block. - * @param offset Offset in the remote file. If offset is passed EOF the space between EOF and offset will be filled by 0x0. - * @return True if file contect successfully written. False on any error. - */ - bool writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset = 0); - - /** - * Low level method used to close a file opened by using openFile() method. - * @param fileID File ID returned by openFile() method. - * @return True on success. False on any error. - */ - bool closeFile (uint32 fileID); - - /** - * This method is used to retrieve remote file attributes and place them into fileAttrs structure. - * @param attrs Reference to fileAttrs structure where retrieved attributes should be placed. - * @param filename Name of the remote file. - * @param followSymLinks If this variable is set to true, symbolic links will be followed. That is the default befavour. If this behavour is undesired, pass "false". - * @return True if the attributes successfully retrieved. Otherwise false is returned. - */ - bool getFileAttrs (fileAttrs& attrs, const char* filename, bool followSymLinks = true); - - - /** - * This method is used to retrieve a remote file and dump it into local file. - * @param remoteFile Full or relative path to the file on the remote side. - * @param localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function. - * @return True if getting the file is succeeds. False on any error. - */ - bool get (const char* remoteFile, FILE* localFile); - - /** - * This method is used to upload a file to a remote server. - * @param localFile Pointer to the FILE structure. If the file being retrieved is binary, use "r+" attributes in fopen function. - * @param remoteFile Full or relative path to the file on the remote side. - * @return True if putting the file succeeds. False on any error. - */ - bool put (FILE* localFile, const char* remoteFile); - - /** - * This method is used to remove a file on a remote server. - * @param remoteFile Full or relative path to the file on the remote side. - * @return True if remove succeeds. False on any error. - */ - bool rm (const char* remoteFile); - - /** - * This method is used to rename/move files. - * @param oldFile Full or relative path to an old file on the remote server. - * @param newFile Full or relative path to a new file on the remote side. - * @return True if renaming successfull. False on any error. - */ - bool mv (const char* oldFile, const char* newFile); - - /** - * This method is used to create a new directory. - * @param remoteDir Full or relative path to a new directory on the remote server. - * @return True if the directory successfully created. False on any error. - */ - bool mkdir (const char* remoteDir); - - /** - * This method is used to remove a remote directory. - * @param remoteDir Full or relative path to a directory to be removed. - * @return True if the directory successfully removed. False on any error. - */ - bool rmdir (const char* remoteDir); - - /** - * This methods is used retrieve a listing of a remote directory. - * @param remoteDir Full or relative path to a directory. - * @param longNames If set to "true" the returned string in addition to file strings will contain attributes for each file. - * @return A pointer to a string containing the directory listing. - */ - const char* ls (const char* remoteDir, bool longNames=false); - - /** - * This method is used to change the current working directory. - * @param remoteDir Full or relative path to the new working directory on the remote server. - * @return True if change of directory succedded. False on any error. - */ - bool cd (const char* remoteDir); - - /** - * This method is used for changing the permissions associated with a remote file. - * @param remoteFile Full or relative path to the remote file. - * @param mode Mode string. It can be either a numerical mode expression such as "755" or an expression showing the modifications to be made, such as "ug+w". Mode string is the same as used by *nix chmod command. - * @return True if the new permissions are succesfully applied to the remote file. False on any error. - */ - bool chmod (const char* remoteFile, const char* mode); - - /** - * This method is used to change the owner of a remote file. - * @param remoteFile Full or relative path to the remote file. - * @param uid Numerical new owner user ID. - * @param gid Numerical new owner group ID. - * @return True if the change of ownership succeeds. False on any error. - */ - bool chown (const char* remoteFile, uint32_t uid, uint32_t gid = 0); - - /** - * This method is used to determine if a remote inode is a regular file. - * @param remoteFile Full or relative path to the remote inode. - * @return True if the remote inode is a regular file. Otherwise false. - */ - bool isFile (const char* remoteFile); - - /** - * This method is used to determine if a remote inode is a directory. - * @param remoteFile Full or relative path to the remote file. - * @return True if the remote inode is a directory. Otherwise false. - */ - bool isDir (const char* remoteFile); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.cpp deleted file mode 100644 index 2f31e19a6d6..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_transport.h" -#include "ne7ssh_channel.h" -#include "ne7ssh_session.h" -#include "ne7ssh.h" - -using namespace Botan; - -//uint32 ne7ssh_channel::channelCount = 0; - -ne7ssh_channel::ne7ssh_channel(ne7ssh_session *_session) : eof(false), closed(false), cmdComplete(false), shellSpawned(false), session(_session), channelOpened(false) -{ -} - -ne7ssh_channel::~ne7ssh_channel() -{ -} - -uint32 ne7ssh_channel::open (uint32 channelID) -{ - ne7ssh_string packet; - ne7ssh_transport *_transport = session->transport; - - packet.addChar (SSH2_MSG_CHANNEL_OPEN); - packet.addString ("session"); - packet.addInt (channelID); -// ne7ssh_channel::channelCount++; - windowSend = 0; - windowRecv = MAX_PACKET_LEN - 2400; - packet.addInt (windowRecv); - packet.addInt (MAX_PACKET_LEN); - - if (!_transport->sendPacket (packet.value())) return 0; - if (!_transport->waitForPacket (SSH2_MSG_CHANNEL_OPEN_CONFIRMATION)) - { - ne7ssh::errors()->push (-1, "New channel: %i could not be open.", channelID); - return 0; - } - if (handleChannelConfirm ()) - { - channelOpened = true; - return channelID; -// return (ne7ssh_channel::channelCount - 1); - } - else return 0; -} - -bool ne7ssh_channel::handleChannelConfirm () -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - _transport->getPacket (packet); - ne7ssh_string channelConfirm (packet, 1); - uint32 field; - - // Receive Channel - field = channelConfirm.getInt(); - // Send Channel - field = channelConfirm.getInt(); - session->setSendChannel (field); - - // Window Size - field = channelConfirm.getInt(); - windowSend = field; - - // Max Packet - field = channelConfirm.getInt(); - session->setMaxPacket (field); - return true; -} - -bool ne7ssh_channel::adjustWindow (Botan::SecureVector& packet) -{ - ne7ssh_string adjustWindow (packet, 0); - ne7ssh_string newPacket; - uint32 field; - - // channel number - field = adjustWindow.getInt(); - - // add bytes to the window - field = adjustWindow.getInt(); - windowSend += field; - return true; -} - -bool ne7ssh_channel::handleEof (Botan::SecureVector& /* packet */) -{ - this->cmdComplete = true; - windowRecv = 0; - eof = true; - if (!closed) sendClose(); - closed = true; - channelOpened = false; - ne7ssh::errors()->push (session->getSshChannel(), "Remote side responded with EOF."); - return false; -} - -void ne7ssh_channel::handleClose (Botan::SecureVector& /* newPacket */) -{ - //ne7ssh_string packet; - - if (!closed) sendClose (); - windowRecv = 0; - closed = true; - channelOpened = false; -} - -bool ne7ssh_channel::handleDisconnect (Botan::SecureVector& packet) -{ - ne7ssh_string message (packet, 0); -// uint32 reasonCode = message.getInt (); - SecureVector description; - - message.getString (description); - windowSend = windowRecv = 0; - closed = true; - channelOpened = false; - - ne7ssh::errors()->push (session->getSshChannel(), "Remote Site disconnected with Error: %B.", &description); - return false; -} - -bool ne7ssh_channel::sendClose () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - - if (closed) return false; - packet.addChar (SSH2_MSG_CHANNEL_CLOSE); - packet.addInt (session->getSendChannel()); - - if (!_transport->sendPacket (packet.value())) return false; - windowSend = 0; - windowRecv = 0; - closed = true; - return true; -} - -bool ne7ssh_channel::sendEof () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - - if (closed) return false; - packet.addChar (SSH2_MSG_CHANNEL_EOF); - packet.addInt (session->getSendChannel()); - - if (!_transport->sendPacket (packet.value())) return false; - windowSend = 0; - windowRecv = 0; - closed = true; - return true; -} - -void ne7ssh_channel::sendAdjustWindow () -{ - uint32 len = session->getMaxPacket () - windowRecv - 2400; - ne7ssh_string packet; - ne7ssh_transport *_transport = session->transport; - - packet.addChar (SSH2_MSG_CHANNEL_WINDOW_ADJUST); - packet.addInt (session->getSendChannel()); - packet.addInt (len); - windowRecv = len; - - _transport->sendPacket (packet.value()); -} - -bool ne7ssh_channel::handleData (Botan::SecureVector& packet) -{ - ne7ssh_string handleData (packet, 0); - uint32 channelID; - SecureVector data; - - channelID = handleData.getInt(); - - if (!handleData.getString (data)) return false; - if (!data.size()) - ne7ssh::errors()->push (session->getSshChannel(), "Abnormal. End of stream detected."); - if (inBuffer.length()) inBuffer.chop(1); - inBuffer.addVector (data); - if (inBuffer.length()) inBuffer.addChar(0x00); - windowRecv -= data.size(); - if (windowRecv == 0) sendAdjustWindow (); - return true; -} - -bool ne7ssh_channel::handleExtendedData (Botan::SecureVector& packet) -{ - ne7ssh_string handleData (packet, 0); - uint32 channelID, dataType; - SecureVector data; - - channelID = handleData.getInt(); - dataType = handleData.getInt(); - if (dataType != 1) - { - ne7ssh::errors()->push (session->getSshChannel(), "Unable to handle received request."); - return false; - } - - if (handleData.getString (data)) - ne7ssh::errors()->push (session->getSshChannel(), "Remote side returned the following error: %B", &data); - else return false; - - windowRecv -= data.size(); - if (windowRecv == 0) sendAdjustWindow (); - return true; -} - -void ne7ssh_channel::handleRequest (Botan::SecureVector& packet) -{ - ne7ssh_string handleRequest (packet, 0); - uint32 channelID; - SecureVector field; - uint32 signal; - - channelID = handleRequest.getInt(); - handleRequest.getString (field); - if (!memcmp((char*)field.begin(), "exit-signal", 11)) - ne7ssh::errors()->push (session->getSshChannel(), "exit-signal ignored."); - else if (!memcmp((char*)field.begin(), "exit-status", 11)) - { - handleRequest.getByte(); - signal = handleRequest.getInt(); - ne7ssh::errors()->push (session->getSshChannel(), "Remote side exited with status: %i.", signal); - } - -// handleRequest.getByte(); -// handleRequest.getString (field); -} - -bool ne7ssh_channel::execCmd (const char* cmd) -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - - if (this->shellSpawned) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote shell is running. This command cannot be executed."); - return false; - } - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_REQUEST); - packet.addInt (session->getSendChannel()); - packet.addString ("exec"); - packet.addChar (0); - packet.addString (cmd); - - if (!_transport->sendPacket (packet.value())) - return false; - - cmdComplete = false; - return true; -} - -void ne7ssh_channel::getShell () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_REQUEST); - packet.addInt (session->getSendChannel()); - packet.addString ("pty-req"); - packet.addChar (0); - packet.addString ("dumb"); - packet.addInt (80); - packet.addInt (24); - packet.addInt (0); - packet.addInt (0); - packet.addString (""); - if (!_transport->sendPacket (packet.value())) return; - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_REQUEST); - packet.addInt (session->getSendChannel()); - packet.addString ("shell"); - packet.addChar (0); - if (!_transport->sendPacket (packet.value())) return; - this->shellSpawned = true; -} - -void ne7ssh_channel::receive () -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - uint32 padLen; - bool notFirst = false; - short status; - - if (eof) - { - return; - } - - while ((status = _transport->waitForPacket (0, notFirst))) - { - if (status == -1) - { - eof = true; - closed = true; - channelOpened = false; - return; - } - if (!notFirst) notFirst = true; - padLen = _transport->getPacket (packet); - handleReceived (packet); - } -} - -bool ne7ssh_channel::handleReceived (Botan::SecureVector& _packet) -{ - ne7ssh_string newPacket; - Botan::byte cmd; - - newPacket.addVector (_packet); - cmd = newPacket.getByte(); - switch (cmd) - { - case SSH2_MSG_CHANNEL_WINDOW_ADJUST: - adjustWindow(newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_DATA: - return handleData (newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_EXTENDED_DATA: - handleExtendedData(newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_EOF: - return handleEof (newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_CLOSE: - handleClose (newPacket.value()); - break; - - case SSH2_MSG_CHANNEL_REQUEST: - handleRequest (newPacket.value()); - break; - - case SSH2_MSG_IGNORE: - break; - - case SSH2_MSG_DISCONNECT: - return handleDisconnect(newPacket.value()); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Unhandled command encountered: %i.", cmd); - return false; - } - return true; -} - -void ne7ssh_channel::write (Botan::SecureVector& data) -{ - SecureVector dataBuff, outBuff, delayedBuff; - uint32 len, maxBytes, i, dataStart; - - if (delayedBuffer.length()) - { - dataBuff.set (delayedBuffer.value()); - delayedBuffer.clear(); - } - dataBuff.append (data); - - if (!windowSend) delayedBuff.set (dataBuff); - else if (windowSend < dataBuff.size()) - { - outBuff.append (dataBuff.begin(), windowSend); - delayedBuff.set (dataBuff.begin() + windowSend, dataBuff.size() - windowSend); - } - else outBuff.append (dataBuff); - - if (delayedBuff.size()) delayedBuffer.addVector (delayedBuff); - if (!outBuff.size()) return; - - len = outBuff.size(); - windowSend -= len; - - maxBytes = session->getMaxPacket(); - for (i = 0; len > maxBytes - 64; i++) - { - dataStart = maxBytes * i; - if (i) dataStart -= 64; - dataBuff.set (outBuff.begin() + dataStart, maxBytes - 64); - outBuffer.addVector (dataBuff); - len -= maxBytes - 64; - } - if (len) - { - dataStart = maxBytes * i; - if (i) dataStart -= 64; - dataBuff.set (outBuff.begin() + dataStart, len); - outBuffer.addVector (dataBuff); - inBuffer.clear(); - } -} - -void ne7ssh_channel::sendAll () -{ - ne7ssh_transport *_transport = session->transport; - SecureVector tmpVar; - ne7ssh_string packet; - - if (!outBuffer.length() && delayedBuffer.length()) - { - tmpVar.swap(delayedBuffer.value()); - delayedBuffer.clear(); - write (tmpVar); - } - if (!outBuffer.length()) return; - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_DATA); - packet.addInt (session->getSendChannel()); - packet.addVectorField (outBuffer.value()); - - windowSend -= outBuffer.length(); - inBuffer.clear(); - if (!_transport->sendPacket (packet.value())) return; - else outBuffer.clear(); - -} - -bool ne7ssh_channel::adjustRecvWindow (int bufferSize) -{ - windowRecv -= bufferSize; - if (windowRecv == 0) sendAdjustWindow (); - return true; -} - -void ne7ssh_channel::resetReceiveBuffer() -{ - inBuffer.clear(); -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.h deleted file mode 100644 index 6b9d0526c8b..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_channel.h +++ /dev/null @@ -1,228 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_CHANNEL_H -#define NE7SSH_CHANNEL_H - -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -class ne7ssh_session; - -/** -@author Andrew Useckas -*/ -class ne7ssh_channel -{ - private: - bool eof, closed; - bool cmdComplete; - bool shellSpawned; - -// static uint32 channelCount; - ne7ssh_session *session; - ne7ssh_string inBuffer; - ne7ssh_string outBuffer; - ne7ssh_string delayedBuffer; - - /** - * This function is used to handle the 'CHANNEL_OPEN_CONFIRMATION' packet. - *

After parsing the payload, send channel ID is assigned, along with send windows size and maximum packer size. - * @return Always returns true. - */ - bool handleChannelConfirm (); - - /** - * This function is used to handle the 'WINDOWS_ADJUST' packet. - *

It's used to increase our sending window size. - * @param packet Reference to vector containing WINDOW_ADJUST packet. - * @return If parsing of payload is successful, returns true, otherwise false is returned. - */ - bool adjustWindow (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'DATA' packet. - *

It's used to parse the payload, and add received data to the buffer. - * @param packet Reference to vector containing 'DATA' packet. - * @return If parsing of payload is successful, returns true, otherwise false is returned. - */ - virtual bool handleData (Botan::SecureVector& packet); - - /** - * This function is used to handle 'EXTENDED_DATA' packet. This packet is mostly used to transmit remote side errors. - * @param packet Reference to vector containing 'EXTENDED_DATA' packet. - * @return If parsing of payload is successful, returns true, otherwise false is returned. - */ - bool handleExtendedData (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'EOF' packet. - *

It's used to close the receiving window and channel. - * @param packet Reference to vector containing EOF packet. - */ - bool handleEof (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'CLOSE' packet. - *

If the close action wasn't initiated on this end, we also send a 'CLOSE' packet to the remote side, prompting the closing of remote side's receiving channel. - * @param packet Reference to vector containing the 'CLOSE' packet. - */ - void handleClose (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'REQUEST' packet. - *

At this point only two requests are supported, namely "exit-signal" and "exit-status". For the most part we ignore this packet, which is safe to do according to SSH specs. - * @param packet Reference to vector containing the 'REQUEST' packet. - */ - void handleRequest (Botan::SecureVector& packet); - - /** - * This function is used to handle the 'DISCONNECT' packet. - *

In normal operation we should not get this packet. Only if some serious error occurs, and makes remote side drop the connection, will this packet be received. And at that point we disconnect right away, and throw an error. - * @param packet Reference to vector containing the 'DISCONNECT' packet. - */ - bool handleDisconnect (Botan::SecureVector& packet); - - protected: - uint32 windowRecv, windowSend; - - bool channelOpened; - - /** - * Request adjustment of the send window size on the remote end, so we can receive more data. - */ - void sendAdjustWindow (); - - public: - /** - * ne7ssh_channel class consturctor. - * @param _session Pointer to ne7ssh_session. - */ - ne7ssh_channel(ne7ssh_session* _session); - - /** - * ne7ssh_channel class destructor. - */ - virtual ~ne7ssh_channel(); - - /** - * Requests 'CHANNEL_OPEN' from the remote side. - * @param channelID New receiving channel ID. - * @return Returns new channel ID, or 0 if open fails. - */ - uint32 open (uint32 channelID); - - /** - * Requests shell from remote side. Does not wait for or expect a reply. According to SSH specs that's an acceptable behavior. - */ - void getShell (); - - /** - * Executes a single command on the remote end and terminates the connection. - * @param cmd Remote command to execute. - * @return True if command if sening of a command succeded. False returned on failure. - */ - bool execCmd (const char* cmd); - - /** - * Receives new packet from remote side. This function is mostly used from selectThread. - */ - void receive (); - - /** - * Handle a packet received from remote side. - * @param _packet Reference to a newly received packet. - * @return True if the packet successfully processed. False on any error. - */ - bool handleReceived (Botan::SecureVector& _packet); - - /** - * Pushes a new command to the buffer where the selectThread will catch and send it. - * @param data Reference to vector containing a command to be added to the buffer. - */ - void write (Botan::SecureVector& data); - - /** - * Sends the entire buffer. Most often called from selectThread via ne7ssh_connection class. - */ - void sendAll (); - - /** - * Checks if there is any data waiting to be sent. Most often called from selectThread via ne7ssh_connection class. - * @return True if there is data to send, otherwise false is returned. - */ - bool data2Send () { if (outBuffer.length() || delayedBuffer.length()) return true; else return false; } - - /** - * Checks if current channel is in an open state. - * @return True if channel is open, otherwise false is returned. - */ - bool isOpen () { return channelOpened; } - - /** - * When closing a channel, initiates the closing procedure. - * @return False if sending fails. Otherwise true is returned. - */ - bool sendClose (); - - /** - * Send EOF to the remote side. - * @return True if sending succeeds, otherwise false. - */ - bool sendEof (); - - /** - * Gets last received packet. - * @return Reference to a vector containing the last received packet. - */ - Botan::SecureVector& getReceived () { return inBuffer.value(); } - - /** - * When executing a single command with ne7ssh::sendCmd this command is used to determine when remote side finishes the execution. - * @return True if execution of the command is complete. Otherwise false. - */ - bool getCmdComplete () { return cmdComplete; } - - /** - * Determines if the shell has been spawned on the remote side. - * @return True if the shell has been spawned. Otherwise false. - */ - bool isRemoteShell () { return shellSpawned; } - - /** - * Checks if receive window needs adjusting, if so send a window adjust request. - * @param bufferSize Current buffer size. - * @return False on any error, otherwise true. - */ - bool adjustRecvWindow (int bufferSize); - - /** - * Gets the current size of the receive window. - * @return Size of the revceive window. - */ - uint32 getRecvWindow () { return windowRecv; } - - /** - * Gets the current size of the send window. - * @return Size of the send window. - */ - uint32 getSendWindow () { return windowSend; } - - /** Empties the receive buffer. */ - void resetReceiveBuffer(); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.cpp deleted file mode 100644 index 7361dba4d80..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_connection.h" -#include "ne7ssh_kex.h" -#include "ne7ssh.h" - -using namespace Botan; - -ne7ssh_connection::ne7ssh_connection(void (*callbackFunc)(void *), - void *callbackArg) - : sock (-1), thisChannel(0), sftp(0), connected(false), cmdRunning(false), - cmdClosed(false), callbackFunc(callbackFunc), callbackArg(callbackArg) -{ - session = new ne7ssh_session(); - crypto = new ne7ssh_crypt(session); - transport = new ne7ssh_transport(session); - channel = new ne7ssh_channel(session); - session->transport = transport; - session->crypto = crypto; -} - - -ne7ssh_connection::~ne7ssh_connection() -{ - delete channel; - delete transport; - delete crypto; - delete session; - - if (sftp) delete sftp; -} - -int ne7ssh_connection::connectWithPassword (uint32 channelID, const char *host, uint32 port, const char* username, const char* password, bool shell, int timeout) -{ - sock = transport->establish (host, port, timeout); - if (sock == -1) return -1; - - if (!checkRemoteVersion()) return -1; - if (!sendLocalVersion()) return -1; - - ne7ssh_kex kex (session); - if (!kex.sendInit()) return -1; - if (!kex.handleInit ()) return -1; - - if (!kex.sendKexDHInit()) return -1; - if (!kex.handleKexDHReply()) return -1; - - if (!kex.sendKexNewKeys()) return -1; - - if (!requestService("ssh-userauth")) return -1; - if (!authWithPassword (username, password)) return -1; - - thisChannel = channel->open(channelID); - if (!thisChannel) return -1; - - if (shell) - channel->getShell (); - - connected = true; - this->session->setSshChannel (thisChannel); - return thisChannel; -} - -int ne7ssh_connection::connectWithKey (uint32 channelID, const char *host, uint32 port, const char* username, const char* privKeyFileName, bool shell, int timeout) -{ - sock = transport->establish (host, port, timeout); - if (sock == -1) return -1; - - if (!checkRemoteVersion()) return -1; - if (!sendLocalVersion()) return -1; - - ne7ssh_kex kex (session); - if (!kex.sendInit()) return -1; - if (!kex.handleInit ()) return -1; - - if (!kex.sendKexDHInit()) return -1; - if (!kex.handleKexDHReply()) return -1; - - if (!kex.sendKexNewKeys()) return -1; - - if (!requestService("ssh-userauth")) return -1; - if (!authWithKey (username, privKeyFileName)) return -1; - - thisChannel = channel->open(channelID); - if (!thisChannel) return -1; - - if (shell) - channel->getShell (); - - connected = true; - - this->session->setSshChannel (thisChannel); - return thisChannel; -} - - -bool ne7ssh_connection::requestService (const char* service) -{ - - ne7ssh_string packet; - packet.addChar (SSH2_MSG_SERVICE_REQUEST); - packet.addString (service); - - if (!transport->sendPacket (packet.value())) return false; - if (!transport->waitForPacket (SSH2_MSG_SERVICE_ACCEPT)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Service request failed."); - return false; - } - return true; -} - -bool ne7ssh_connection::authWithPassword (const char* username, const char* password) -{ - short _cmd; - ne7ssh_string packet; - SecureVector response; - Botan::byte canContinue; - SecureVector methods; - - - packet.addChar (SSH2_MSG_USERAUTH_REQUEST); - packet.addString (username); - packet.addString ("ssh-connection"); - packet.addString ("password"); - packet.addChar ('\0'); - packet.addString (password); - - if (!transport->sendPacket (packet.value())) return false; - _cmd = transport->waitForPacket (0); - if (_cmd == SSH2_MSG_USERAUTH_SUCCESS) - { - return true; - } - else if (_cmd == SSH2_MSG_USERAUTH_BANNER) - { - packet.clear(); - packet.addString (password); - if (!transport->sendPacket (packet.value())) return false; - _cmd = transport->waitForPacket (0); - if (_cmd == SSH2_MSG_USERAUTH_SUCCESS) return true; - } - - if (_cmd == SSH2_MSG_USERAUTH_FAILURE) - { - transport->getPacket (response); - ne7ssh_string message (response, 1); - message.getString (methods); - canContinue = message.getByte(); - ne7ssh::errors()->push (-1, "Authentication failed. Supported authentication methods: %B", &methods); - return false; - } - else return false; -} - -bool ne7ssh_connection::authWithKey (const char* username, const char* privKeyFileName) -{ - ne7ssh_keys keyPair; - ne7ssh_string packet, packetBegin, packetEnd; - SecureVector pubKeyBlob, sigBlob; - if (!keyPair.getKeyPairFromFile (privKeyFileName)) - return false; - short _cmd; - SecureVector response; - Botan::byte canContinue; - SecureVector methods; - - packetBegin.addChar (SSH2_MSG_USERAUTH_REQUEST); - packetBegin.addString (username); - packetBegin.addString ("ssh-connection"); - packetBegin.addString ("publickey"); - - switch (keyPair.getKeyAlgo()) - { - case ne7ssh_keys::DSA: - packetEnd.addString ("ssh-dss"); - break; - - case ne7ssh_keys::RSA: - packetEnd.addString ("ssh-rsa"); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "The key algorithm: %i is not supported.", keyPair.getKeyAlgo()); - return false; - } - pubKeyBlob = keyPair.getPublicKeyBlob(); - if (!pubKeyBlob.size()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Invallid public key."); - return false; - } - packetEnd.addVectorField (pubKeyBlob); - - packet.addVector (packetBegin.value()); - packet.addChar (0x0); - packet.addVector (packetEnd.value()); - - if (!transport->sendPacket (packet.value())) return false; - - _cmd = transport->waitForPacket (0); - if (_cmd == SSH2_MSG_USERAUTH_FAILURE) - { - transport->getPacket (response); - ne7ssh_string message (response, 1); - message.getString (methods); - canContinue = message.getByte(); - ne7ssh::errors()->push (-1, "Authentication failed. Supported methods are: %B", &methods); - return false; - } - else if (_cmd != SSH2_MSG_USERAUTH_PK_OK) return false; - - packet.clear(); - packet.addVector (packetBegin.value()); - packet.addChar (0x1); - packet.addVector (packetEnd.value()); - - sigBlob = keyPair.generateSignature (session->getSessionID(), packet.value()); - if (!sigBlob.size()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failure while generating the signature."); - return false; - } - - packet.addVectorField (sigBlob); - if (!transport->sendPacket (packet.value())) return false; - - _cmd = transport->waitForPacket (0); - if (_cmd == SSH2_MSG_USERAUTH_SUCCESS) return true; - else if (_cmd == SSH2_MSG_USERAUTH_FAILURE) - { - transport->getPacket (response); - ne7ssh_string message (response, 1); - message.getString (methods); - canContinue = message.getByte(); - ne7ssh::errors()->push (-1, "Authentication failed. Supported methods are: %B", &methods); - return false; - } - else return false; -} - -bool ne7ssh_connection::checkRemoteVersion () -{ - SecureVector remoteVer, tmpVar; - Botan::byte* _pos; - if (!transport->receive (remoteVer)) return false; - - if (remoteVer.size() < 4 || \ - (memcmp (remoteVer.begin(), "SSH-1.99", 8) && memcmp (remoteVer.begin(), "SSH-2", 5))) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote SSH version is not supported. Remote version: %B.", &remoteVer); - return false; - } - else - { - _pos = remoteVer.end() - 1; - while (*_pos == '\r' || *_pos == '\n') _pos--; - tmpVar.set (remoteVer.begin(), _pos - remoteVer.begin() + 1); - session->setRemoteVersion (tmpVar); - return true; - } -} - -bool ne7ssh_connection::sendLocalVersion () -{ - SecureVector localVer ((const Botan::byte*)ne7ssh::SSH_VERSION, (uint32_t) strlen(ne7ssh::SSH_VERSION)); - session->setLocalVersion (localVer); - localVer.append ((const Botan::byte*)"\r\n", 2); - - if (!transport->send (localVer)) return false; - else return true; -} - -void ne7ssh_connection::handleData () -{ - channel->receive(); - if (callbackFunc && getReceived().size() > 0) - callbackFunc(callbackArg); -} - -void ne7ssh_connection::sendData (const char* data) -{ - SecureVector _cmd ((const Botan::byte *) data, (uint32_t) strlen(data)); - channel->write (_cmd); -} - -bool ne7ssh_connection::sendCmd (const char* cmd) -{ - cmdRunning = true; - return channel->execCmd(cmd); -} - -Ne7sshSftp* ne7ssh_connection::startSftp () -{ - if (channel->isRemoteShell()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote shell is running. SFTP subsystem cannot be started."); - return 0; - } - sftp = new Ne7sshSftp (session, channel); - - if (sftp->init()) return sftp; - else - { - ne7ssh::errors()->push (session->getSshChannel(), "Failure to launch remote sftp subsystem."); - return 0; - } - - return 0; -} - -bool ne7ssh_connection::sendClose () -{ - bool status; - if (channel->isOpen() && !isSftpActive()) return (channel->sendClose ()); - else if (getCmdComplete()) cmdClosed=true; - if (isSftpActive()) - { - delete sftp; - sftp = 0; - status = channel->sendClose (); - return status; - } - else return false; -} - -bool ne7ssh_connection::isSftpActive () -{ - if (sftp) return true; - else return false; -} - -void ne7ssh_connection::resetReceiveBuffer() -{ - channel->resetReceiveBuffer(); -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.h deleted file mode 100644 index 182b48294fc..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_connection.h +++ /dev/null @@ -1,238 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_CONNECTION_H -#define NE7SSH_CONNECTION_H - -#include "ne7ssh_transport.h" -#include "ne7ssh_session.h" -#include "ne7ssh_channel.h" -#include "ne7ssh_keys.h" -#include "crypt.h" -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" -#include "ne7ssh_sftp.h" - - -/** -@author Andrew Useckas -*/ -class ne7ssh_connection -{ - private: - SOCKET sock; - int thisChannel; - ne7ssh_crypt *crypto; - ne7ssh_transport *transport; - ne7ssh_session *session; - ne7ssh_channel *channel; - Ne7sshSftp* sftp; - - Ne7ssh_Mutex mut; - bool connected; - bool cmdRunning; - bool cmdClosed; - - void (*callbackFunc)(void *); - void *callbackArg; - - /** - * Checks if remote side is returning a correctly formated SSH version string, and makes sure that version 2 of SSH protocol is supported by the remote side. - * @return False if version string is malformed, or version 2 is not supported, otherwise true is returned. - */ - bool checkRemoteVersion (); - - /** - * Sends local version string. - * @return Returns false is there any communication errors occur, otherwise true is returned. - */ - bool sendLocalVersion (); - - /** - * Sends an SSH service request, waits for 'SERVICE_ACCEPT' packet. - * @param service pointer to a string containing the requested SSH service. For example "ssh-userauth". - * @return True If SERVICE_ACCEPT packet was received, otherwise false is returned. - */ - bool requestService (const char* service); - - /** - * Sends an authentication request of "password" type. Waits for packet 'USERAUTH_SUCESS'. - * @param username Username used for authentication. - * @param password Password used for authentication. - * @return True if authentication was successful, otherwise false is returned. - */ - bool authWithPassword (const char* username, const char* password); - - /** - * Sends a test message to check if "publickey" authentication is allowed fo specified user. - * If succesfull proceeds wtih generating a signature and sending real authentication packet - * of "publickey" type. - * @param username Username used for authentication. - * @param privKeyFileName Full path to file containing private key to be used in authentication. - * @return True if authentication was successful, otherwise false is returned. - */ - bool authWithKey (const char* username, const char* privKeyFileName); - - public: - /** - * ne7ssh_connection class constructor. - */ - ne7ssh_connection(void (*callbackFunc)(void *) = 0, void *callbackArg = 0); - - /** - * ne7ssh_connection class destructor. - */ - ~ne7ssh_connection(); - - /** - * Connects to a remote host using SSH protocol version 2, with password based authentication. - * @param channelID ID of the new channel. - * @param host Hostname / IP of the remote host. - * @param port Connection port. - * @param username Username to use in the authentication. - * @param password Password to use in the authentication. - * @param shell Set this to true if you wish to launch the shell on the remote end. By default set to true. - * @param timeout Timeout for the connection procedure, in seconds. - * @return A newly assigned channel ID, or -1 if connection failed. - */ - int connectWithPassword (uint32 channelID, const char *host, uint32 port, const char* username, const char* password, bool shell = true, int timeout = 0); - - /** - * Connects to a remote host using SSH protocol version 2, with publickey based authentication. - * @param channelID ID assigned to the new channel. - * @param host Hostname / IP of the remote host. - * @param port Connection port. - * @param username Username to use in the authentication. - * @param privKeyFileName Full path to file containing private key to be used in authentication. - * @param shell Set this to true if you wish to launch the shell on the remote end. By default set to true. - * @param timeout Timeout for the connection procedure, in seconds. - * @return A newly assigned channel ID, or -1 if connection failed. - */ - int connectWithKey (uint32 channelID, const char *host, uint32 port, const char* username, const char* privKeyFileName, bool shell = true, int timeout = 0); - - /** - * Retrieves the tcp socket number. - * @return Socket, or -1 if not connected. - */ - SOCKET getSocket () { return sock; } - - /** - * When new data arrives, and is available for reading, this function is called from selectThread to handle it. - */ - void handleData (); - - /** - * This function is used to write commands to the buffer, later to be sent to the remote site for execution. - * @param data Pointer to a string, containing command to be written to the buffer. - */ - void sendData (const char* data); - - /** - * Sets the current SSH channel number. - */ - void setChannelNo (int channelID) { thisChannel = channelID; } - - /** - * Retrieves the current SSH channel. - * @return Returns SSH channel or -1 if not connected. - */ - int getChannelNo () { return thisChannel; } - - /** - * Checks for the data in the send buffer. - * @return True is there is data to send, otherwise false. - */ - bool data2Send () { return channel->data2Send(); } - - /** - * Sends the content of the buffer., - *

Usually used after data2Send returns true, executed by selectThread. - */ - void sendData () { channel->sendAll (); } - - /** - * - * @param cmd - * @return - */ - bool sendCmd (const char* cmd); - - /** - * This function is used to close the current connection. - *

First closes the channel, and then the connection itself. - * @return True, if packet sent successfully, otherwise false is returned. - */ - bool sendClose (); - - /** - * Checks if channel is open. - * @return True if channel is open, otherwise false is returned. - */ - bool isOpen () { return channel->isOpen(); } - - /** - * Checks if process is connected and authenticated to the remote side. - * @return True if connected, otherwise false is returned. - */ - bool isConnected () { return connected; } - - /** - * Retrieves the last received packet. - * @return A reference to a buffer containing the last received packet. - */ - Botan::SecureVector& getReceived () { return channel->getReceived(); } - - /** - * When executing a single command with ne7ssh::sendCmd this command is used to determine when remote side finishes the xecution. - * @return True if execution of the command is complete. Otherwise false. - */ - bool getCmdComplete() { return channel->getCmdComplete(); } - - /** - * When executing a single command with ne7ssh::sendCmd this command is used to determine when the user requested a close() on the channel. - * @return True if the user requested to close the channel. Otherwise false. - */ - bool isCmdClosed() { return cmdClosed; } - - /** - * Determines if the shell has been spawned on the remote side. - * @return True if the shell has been spawned. Otherwise false. - */ - bool isRemoteShell () { return channel->isRemoteShell(); } - - /** - * Checks if current connection is executing a single command, without a shell. - * @return True if a single command is running. Otherwise false. - */ - bool isCmdRunning () { return cmdRunning; } - - /** - * Starts a new sftp subsystem. - * @return Returns a pointer to the newly started Ne7sshSftp instance. - */ - Ne7sshSftp* startSftp (); - - /** - * Checks if SFTP subsystem is active on the current connection. - * @return True if SFTP subsystem is active, otherwise false. - */ - bool isSftpActive (); - - /** Empties this connection's receive buffer. */ - void resetReceiveBuffer(); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_error.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_error.cpp deleted file mode 100644 index acf848bfbe0..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_error.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_error.h" -#include -#include -#include -#include "stdarg.h" -#include "ne7ssh.h" - -using namespace Botan; -Ne7ssh_Mutex Ne7sshError::mut; - -Ne7sshError::Ne7sshError() : memberCount(0), ErrorBuffer(0) -{ - -} - -Ne7sshError::~Ne7sshError() -{ - uint16 i; - - for (i = 0; i < memberCount; i++) - { - if (ErrorBuffer[i] && ErrorBuffer[i]->errorStr) free (ErrorBuffer[i]->errorStr); - free (ErrorBuffer[i]); - } - free (ErrorBuffer); -} - - -bool Ne7sshError::push (int32 channel, const char* format, ...) -{ - va_list args; - char *s; - char* errStr = 0; - uint32 len = 0, msgLen = 0, _pos = 0; - bool isArg = false; - bool isUnsigned = false; - char converter[21]; - SecureVector *secVec; - int32 i; - - if (channel < -1 || !format) - return false; - - converter[0] = 0x00; - len = strlen (format); - - va_start (args, format); - errStr = (char*) malloc (len + 1); - - do - { - if (*format == '%' || isArg) - { - switch (*format) - { - case '%': - isArg = true; - break; - - case 'u': - isUnsigned = true; - break; - - case 's': - s = va_arg (args, char*); - msgLen = strlen (s); - if (msgLen > MAX_ERROR_LEN) msgLen = MAX_ERROR_LEN; - errStr = (char*) realloc (errStr, len + msgLen + 1); - memcpy ((errStr + _pos), s, msgLen); - if (isUnsigned) len += msgLen - 3; - else len += msgLen - 2; - _pos += msgLen; - isUnsigned = false; - isArg = false; - break; - - case 'B': - secVec = va_arg (args, SecureVector*); - msgLen = secVec->size(); - if (msgLen > MAX_ERROR_LEN) msgLen = MAX_ERROR_LEN; - errStr = (char*) realloc (errStr, len + msgLen + 1); - memcpy ((errStr + _pos), secVec->begin(), msgLen); - if (isUnsigned) len += msgLen - 3; - else len += msgLen - 2; - _pos += msgLen; - isUnsigned = false; - isArg = false; - break; - - case 'l': - case 'd': - case 'i': - i = va_arg (args, int32); - if (isUnsigned) sprintf (converter, "%u", i); - else sprintf (converter, "%d", i); - msgLen = strlen (converter); - errStr = (char*) realloc (errStr, len + msgLen + 1); - memcpy ((errStr + _pos), converter, msgLen); - if (isUnsigned) len += msgLen - 3; - else len += msgLen - 2; - _pos += msgLen; - isUnsigned = false; - isArg = false; - break; - - case 'x': - i = va_arg (args, int32); - sprintf (converter, "%x", i); - msgLen = strlen (converter); - errStr = (char*) realloc (errStr, len + msgLen + 1); - memcpy ((errStr + _pos), converter, msgLen); - if (isUnsigned) len += msgLen - 3; - else len += msgLen - 2; - _pos += msgLen; - isUnsigned = false; - isArg = false; - break; - } - } - else errStr[_pos++] = *format; - - } while (*format++); - - va_end (args); - - if (!lock()) - { - free(errStr); - return false; - } - if (!memberCount) - { - ErrorBuffer = (Error**) malloc (sizeof(Error*)); - ErrorBuffer[0] = (Error*) malloc (sizeof(Error)); - } - else - { - ErrorBuffer = (Error**) realloc (ErrorBuffer, sizeof(Error*) * (memberCount + 1)); - ErrorBuffer[memberCount] = (Error*) malloc (sizeof(Error)); - } - - ErrorBuffer[memberCount]->channel = channel; - ErrorBuffer[memberCount]->errorStr = errStr; - memberCount++; - if (!unlock()) return false; - return true; -} - -const char* Ne7sshError::pop () -{ - return pop(-1); -} - -const char* Ne7sshError::pop (int32 channel) -{ - uint16 i; - int32 recID = -1; - const char* result = 0; - uint32 len; - - if (!memberCount) return 0; - if (!lock()) return false; - - for (i = 0; i < memberCount; i++) - { - if (ErrorBuffer[i] && ErrorBuffer[i]->channel == channel) - { - recID = i; - result = ErrorBuffer[i]->errorStr; - } - } - if (recID < 0) - { - unlock(); - return 0; - } - - if (result) - { - len = strlen (result) < MAX_ERROR_LEN ? strlen (result) : MAX_ERROR_LEN; - memcpy (popedErr, result, len + 1); - deleteRecord (recID); - } - else - { - unlock(); - return 0; - } - if (!unlock()) return false; - - return popedErr; -} - -bool Ne7sshError::deleteRecord (uint16 recID) -{ - uint16 i; - - if (ErrorBuffer[recID] && ErrorBuffer[recID]->errorStr) free (ErrorBuffer[recID]->errorStr); - else return false; - free (ErrorBuffer[recID]); - ErrorBuffer[recID] = 0; - for (i = recID + 1; i < memberCount; i++) - { - ErrorBuffer[i - 1] = ErrorBuffer[i]; - } - memberCount--; - return true; -} - - -bool Ne7sshError::deleteCoreMsgs () -{ - return deleteChannel(-1); -} - -bool Ne7sshError::deleteChannel (int32 channel) -{ - uint16 i, offset=0; - - if (!lock()) return false; - for (i = 0; i < memberCount; i++) - { - if (ErrorBuffer[i] && ErrorBuffer[i]->channel == channel) - { - if (ErrorBuffer[i]->errorStr) free (ErrorBuffer[i]->errorStr); - free (ErrorBuffer[i]); - offset++; - } - else if (offset) ErrorBuffer[i - offset] = ErrorBuffer[i]; - } - memberCount -= offset; - if (!unlock()) return false; - return true; -} - -bool Ne7sshError::lock () -{ - int status; - status = Ne7sshError::mut.lock(); - if (status) - { - /// FIXME possible infinite loop - ne7ssh::errors()->push (-1, "Could not aquire a mutex lock. Error: %i.", status); - usleep (1000); - return false; - } - return true; -} - -bool Ne7sshError::unlock () -{ - int status; - status = Ne7sshError::mut.unlock(); - if (status) - { - ne7ssh::errors()->push (-1, "Error while releasing a mutex lock. Error: %i.", status); - return false; - } - return true; -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_error.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_error.h deleted file mode 100644 index 6ed167ea945..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_error.h +++ /dev/null @@ -1,113 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_ERROR_H -#define NE7SSH_ERROR_H - -#include -#if !defined(WIN32) && !defined(__MINGW32__) -# include -#endif - -#define MAX_ERROR_LEN 500 - -#include "ne7ssh_types.h" -#include "ne7ssh_mutex.h" - -/** - @author Andrew Useckas -*/ -class SSH_EXPORT Ne7sshError -{ - private: - uint16 memberCount; - char popedErr[MAX_ERROR_LEN + 1]; - static Ne7ssh_Mutex mut; - - /** - * Structure for storing error messages. - */ - struct Error - { - int32 channel; - char* errorStr; - } **ErrorBuffer; - - /** - * Delete a single error message. - * @param recID Position within the array. - * @return True on success, false on failure. - */ - bool deleteRecord (uint16 recID); - - /** - * Lock the mutex. - * @return True if lock aquired. Oterwise false. - */ - static bool lock (); - - /** - * Unlock the mutext. - * @return True if the mutext successfully unlocked. Otherwise false. - */ - static bool unlock (); - - public: - /** - * Ne7sshError constructor. - */ - Ne7sshError(); - - /** - * Ne7sshError destructor. - */ - ~Ne7sshError(); - - /** - * Pushes a new error message into the stack. - * @param channel Specifies the channel to bind the error message to. This is ne7ssh library channel, not the receive or send channels used by the transport layer. - * @param format Specifies the error message followed by argument in printf format. The following formatting characters are supported: %s,%d,%i,%l,%x. Modifier %u can be used together with decimal to specify an unsigned variable. Returns null if no there are no erros in the Core context. - * @return True on success, false on failure. - */ - bool push (int32 channel, const char* format, ...); - - /** - * Pops an error message from the Core context. - * @return The last error message in the Core context. The message is removed from the stack. - */ - const char* pop (); - - /** - * Pops an error message from the Channel context. - * @param channel Specifies the channel error message was bound to. This is ne7ssh library channel, not the receive or send channels used by the transport layer. - * @return The last error message in the Channel context. The message is removed from the stack. Returns null if no there are no erros in the Channel context. - */ - const char* pop (int32 channel); - - /** - * Removes all error messages within Core context from the stack. - * @return True on success, false on failure. - */ - bool deleteCoreMsgs (); - - /** - * Removes all error messages within Channel context from the stack. - * @param channel Specifies the channel error message was bound to. This is ne7ssh library channel, not the receive or send channels used by the transport layer. - * @return True on succes, false on failure. - */ - bool deleteChannel (int32 channel); - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.cpp deleted file mode 100644 index c0bfc413caa..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_kex.h" -#include "ne7ssh.h" -#include - -using namespace Botan; - -ne7ssh_kex::ne7ssh_kex(ne7ssh_session* _session) : session(_session) -{ -} - -ne7ssh_kex::~ne7ssh_kex() -{ -} - -void ne7ssh_kex::constructLocalKex() -{ - Botan::byte random[16]; - ne7ssh_string myCiphers (ne7ssh::CIPHER_ALGORITHMS, 0); - ne7ssh_string myMacs (ne7ssh::MAC_ALGORITHMS, 0); - SecureVector tmpCiphers, tmpMacs; - char* cipher, *hmac; - size_t len; - - localKex.clear(); - localKex.addChar (SSH2_MSG_KEXINIT); - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - Botan::Global_RNG::randomize (random, 16); -#else - ne7ssh::rng->randomize (random, 16); -#endif - - localKex.addBytes (random, 16); - localKex.addString (ne7ssh::KEX_ALGORITHMS); - localKex.addString (ne7ssh::HOSTKEY_ALGORITHMS); - - if (ne7ssh::PREFERED_CIPHER) - { - myCiphers.split (','); - myCiphers.resetParts(); - - while ((cipher = myCiphers.nextPart())) - { - len = strlen (cipher); - if (!memcmp (cipher, ne7ssh::PREFERED_CIPHER, len)) Ciphers.append ((Botan::byte*)cipher, (uint32_t) len); - else - { - tmpCiphers.append (','); - tmpCiphers.append ((Botan::byte*)cipher, (uint32_t) len); - } - } - } - if (Ciphers.size()) Ciphers.append (tmpCiphers); - else Ciphers.set (myCiphers.value()); -// Ciphers.append (&null_byte, 1); - - if (ne7ssh::PREFERED_MAC) - { - myMacs.split (','); - myMacs.resetParts(); - - while ((hmac = myMacs.nextPart())) - { - len = strlen (hmac); - if (!memcmp (hmac, ne7ssh::PREFERED_MAC, len)) Hmacs.append ((Botan::byte*)hmac, (uint32_t) len); - else - { - tmpMacs.append (','); - tmpMacs.append ((Botan::byte*)hmac, (uint32_t) len); - } - } - } - if (Hmacs.size()) Hmacs.append (tmpMacs); - else Hmacs.set (myMacs.value()); -// Hmacs.append (&null_byte, 1); - - localKex.addVectorField (Ciphers); - localKex.addVectorField (Ciphers); - localKex.addVectorField (Hmacs); - localKex.addVectorField (Hmacs); - localKex.addString (ne7ssh::COMPRESSION_ALGORITHMS); - localKex.addString (ne7ssh::COMPRESSION_ALGORITHMS); - localKex.addInt (0); - localKex.addInt (0); - localKex.addChar ('\0'); - localKex.addInt (0); -} - - -bool ne7ssh_kex::sendInit () -{ - ne7ssh_transport *_transport; - - if (!session->transport) - { - ne7ssh::errors()->push (session->getSshChannel(), "No transport. Cannot initialize key exchange."); - return false; - } - _transport = session->transport; - - constructLocalKex(); - - if (!_transport->sendPacket (localKex.value())) return false; - if (!_transport->waitForPacket (SSH2_MSG_KEXINIT)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Timeout while waiting for key exchange init reply"); - return false; - } - - return true; -} - -bool ne7ssh_kex::handleInit () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_crypt *_crypto = session->crypto; - SecureVector packet; - uint32 padLen = _transport->getPacket (packet); - ne7ssh_string remoteKex (packet, 17); - SecureVector algos; - SecureVector agreed; - - if (!_transport || !_crypto) return false; - remotKex.clear(); - remotKex.addBytes (packet.begin(), packet.size() - padLen - 1); - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, ne7ssh::KEX_ALGORITHMS, algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible key exchange algorithms."); - return false; - } - if (!_crypto->negotiatedKex (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, ne7ssh::HOSTKEY_ALGORITHMS, algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible Hostkey algorithms."); - return false; - } - if (!_crypto->negotiatedHostkey (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, (char*)Ciphers.begin(), algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible cryptographic algorithms."); - return false; - } - if (!_crypto->negotiatedCryptoC2s (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, (char*)Ciphers.begin(), algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible cryptographic algorithms."); - return false; - } - if (!_crypto->negotiatedCryptoS2c (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, (char*)Hmacs.begin(), algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible HMAC algorithms."); - return false; - } - if (!_crypto->negotiatedMacC2s (agreed)) return false; - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, (char*)Hmacs.begin(), algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible HMAC algorithms."); - return false; - } - if (!_crypto->negotiatedMacS2c (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, ne7ssh::COMPRESSION_ALGORITHMS, algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible compression algorithms."); - return false; - } - if (!_crypto->negotiatedCmprsC2s (agreed)) return false; - - - if (!remoteKex.getString (algos)) return false; - if (!_crypto->agree (agreed, ne7ssh::COMPRESSION_ALGORITHMS, algos)) - { - ne7ssh::errors()->push (session->getSshChannel(), "No compatible compression algorithms."); - return false; - } - if (!_crypto->negotiatedCmprsS2c (agreed)) return false; - - return true; -} - -bool ne7ssh_kex::sendKexDHInit () -{ - ne7ssh_string dhInit; - ne7ssh_transport *_transport = session->transport; - ne7ssh_crypt *_crypto = session->crypto; - BigInt publicKey; - SecureVector eVector; - - if (!_crypto->getKexPublic (publicKey)) return false; - - dhInit.addChar (SSH2_MSG_KEXDH_INIT); - dhInit.addBigInt (publicKey); - ne7ssh_string::bn2vector (eVector, publicKey); - e.clear(); - e.addVector (eVector); - - if (!_transport->sendPacket (dhInit.value())) return false; - if (!_transport->waitForPacket (SSH2_MSG_KEXDH_REPLY)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Timeout while waiting for key exchange dh reply."); - return false; - } - return true; -} - -bool ne7ssh_kex::handleKexDHReply () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_crypt *_crypto = session->crypto; - SecureVector packet; - _transport->getPacket (packet); - ne7ssh_string remoteKexDH (packet, 1); - SecureVector field, fVector, hSig, kVector, hVector; - BigInt publicKey; - - if (!remoteKexDH.getString (field)) return false; - hostKey.clear(); - hostKey.addVector (field); - - if (!remoteKexDH.getBigInt (publicKey)) return false; - ne7ssh_string::bn2vector (fVector, publicKey); - f.clear(); - f.addVector (fVector); - - if (!remoteKexDH.getString (hSig)) return false; - - if (!_crypto->makeKexSecret (kVector, publicKey)) return false; - k.clear(); - k.addVector (kVector); - - makeH (hVector); - if (hVector.is_empty()) return false; - if (!_crypto->isInited()) session->setSessionID (hVector); - - if (!_crypto->verifySig (hostKey.value(), hSig)) return false; - - return true; -} - -bool ne7ssh_kex::sendKexNewKeys () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_crypt *_crypto = session->crypto; - ne7ssh_string newKeys; - - if (!_transport->waitForPacket (SSH2_MSG_NEWKEYS)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Timeout while waiting for key exchange newkeys reply."); - return false; - } - - newKeys.addChar (SSH2_MSG_NEWKEYS); - if (!_transport->sendPacket (newKeys.value())) return false; - - if (!_crypto->makeNewKeys()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not make keys."); - return false; - } - - return true; -} - - -void ne7ssh_kex::makeH (Botan::SecureVector &hVector) -{ - ne7ssh_crypt *_crypto = session->crypto; - ne7ssh_string hashBytes; - - hashBytes.addVectorField (session->getLocalVersion()); - hashBytes.addVectorField (session->getRemoteVersion()); - hashBytes.addVectorField (localKex.value()); - hashBytes.addVectorField (remotKex.value()); - hashBytes.addVectorField (hostKey.value()); - hashBytes.addVectorField (e.value()); - hashBytes.addVectorField (f.value()); - hashBytes.addVectorField (k.value()); - - _crypto->computeH (hVector, hashBytes.value()); -} - - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.h deleted file mode 100644 index cd9167dd4b2..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_kex.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_KEX_H -#define NE7SSH_KEX_H - -#include "ne7ssh_types.h" -#include "ne7ssh_session.h" -#include "ne7ssh_string.h" -#include "ne7ssh_transport.h" -#include "crypt.h" - -/** -@author Andrew Useckas -*/ -class ne7ssh_kex -{ - private: - ne7ssh_session* session; - ne7ssh_string localKex; - ne7ssh_string remotKex; - ne7ssh_string hostKey; - ne7ssh_string e; - ne7ssh_string f; - ne7ssh_string k; - Botan::SecureVector Ciphers, Hmacs; - - /** - * Constructs local 'KEX_INIT' payload - */ - void constructLocalKex(); - - /** - * Computes H hash, from concated values of the local SSH version string, remote SSH version string, local KEX_INIT payload, remote KEX_INIT payload, host key, e, f and k BigInt values. - * @param hVector Reference to a vecor where H value will be stored. - */ - void makeH (Botan::SecureVector& hVector); - - public: - /** - * ne7ssh_kex class constructor. - * @param _session Pointer to ne7ssh_session variable. - */ - ne7ssh_kex(ne7ssh_session* _session); - - /** - * ne7ssh_kex class destructor. - */ - ~ne7ssh_kex(); - - /** - * Sends 'KEX_INIT' packet and waits for 'KEX_INIT' reply. - * @return True if successful, otherwise false is returned. - */ - bool sendInit(); - - /** - * After sendInit() function returnes true, this functions is used to parse the received 'KEX_INIT' packet. - *

Used to agree on cipher, hmac, etc. algorithms used in communication between client and server. - * @return True if parsing was succesful and all algorithms agreed upon, otherwise false is returned. - */ - bool handleInit(); - - /** - * Sends 'KEXDH_INIT' packet and waits for 'KEXDH_REPLY'. - * @return True if reply is received, otherwise false is returned. - */ - bool sendKexDHInit(); - - /** - * After sendKexDHInit() returns true, this function is used to handle the received 'KEXDH_REPLY'. - *

This is the function to create the shared secret K. It also extracts the host key and signature fields from the payload, generates DSA/RSA keys, and verifies the signature. - * @return True if all operations are completed successfully, otherwise false is returned. - */ - bool handleKexDHReply(); - - /** - * This function waits for 'NEWKEYS' packet from the remote host. - *

Once the packet is received, local 'NEWKEYS' packet is sent, all encryption and hmac keys are generated and encrypted communication is established. - * @return True if all operations are successful, otherwise false is returned. - */ - bool sendKexNewKeys(); - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.cpp deleted file mode 100644 index 2e20fe57b98..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.cpp +++ /dev/null @@ -1,573 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_keys.h" -#include "ne7ssh.h" -#include -#include -#include -#include - -using namespace std; -using namespace Botan; - -const u32bit PIPE_DEFAULT_MESSAGE = -1; - -ne7ssh_keys::ne7ssh_keys() : dsaPrivateKey(0), rsaPrivateKey(0), keyAlgo(0) -{ -} - - -ne7ssh_keys::~ne7ssh_keys() -{ - if (dsaPrivateKey) delete dsaPrivateKey; - if (rsaPrivateKey) delete rsaPrivateKey; -} - -bool ne7ssh_keys::generateRSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize) -{ - RSA_PrivateKey *rsaPrivKey; - BigInt e, n, d, p, q; - BigInt dmp1, dmq1, iqmp; - ne7ssh_string pubKeyBlob; - FILE *privKeyFile, *pubKeyFile; - std::string privKeyEncoded; - DER_Encoder encoder; - - if (keySize > MAX_KEYSIZE) - { - ne7ssh::errors()->push (-1, "Specified key size: '%i' is larger than allowed maximum.", keySize); - return false; - } - - if (keySize < 1024) - { - ne7ssh::errors()->push (-1, "Key Size: '%i' is too small. Use at least 1024 key size for RSA keys.", keySize); - return false; - } - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - rsaPrivKey = new RSA_PrivateKey (keySize); -#else - rsaPrivKey = new RSA_PrivateKey (*ne7ssh::rng, keySize); -#endif - privKeyFile = fopen (privKeyFileName, "w"); - - e = rsaPrivKey->get_e(); - n = rsaPrivKey->get_n(); - - d = rsaPrivKey->get_d(); - p = rsaPrivKey->get_p(); - q = rsaPrivKey->get_q(); - - dmp1 = d % (p - 1); - dmq1 = d % (q - 1); - iqmp = inverse_mod (q, p); - - pubKeyBlob.addString ("ssh-rsa"); - pubKeyBlob.addBigInt (e); - pubKeyBlob.addBigInt (n); - - Pipe base64it (new Base64_Encoder); - base64it.process_msg(pubKeyBlob.value()); - - SecureVector pubKeyBase64 = base64it.read_all (PIPE_DEFAULT_MESSAGE); - - pubKeyFile = fopen (pubKeyFileName, "w"); - - if (!pubKeyFile) - { - ne7ssh::errors()->push (-1, "Cannot open file where public key is stored. Filename: %s", pubKeyFileName); - delete rsaPrivKey; - return false; - } - - if ((!fwrite ("ssh-rsa ", 8, 1, pubKeyFile)) || - (!fwrite (pubKeyBase64.begin(), (size_t) pubKeyBase64.size(), 1, pubKeyFile)) || - (!fwrite (" ", 1, 1, pubKeyFile)) || - (!fwrite (fqdn, strlen(fqdn), 1, pubKeyFile)) || - (!fwrite ("\n", 1, 1, pubKeyFile))) - { - ne7ssh::errors()->push (-1, "I/O error while writting to file: %s.", pubKeyFileName); - delete rsaPrivKey; - return false; - } - - fclose (pubKeyFile); - -#if (BOTAN_PRE_15) - encoder.start_sequence(); - DER::encode (encoder, 0U); - DER::encode (encoder, n); - DER::encode (encoder, e); - DER::encode (encoder, d); - DER::encode (encoder, p); - DER::encode (encoder, q); - DER::encode (encoder, dmp1); - DER::encode (encoder, dmq1); - DER::encode (encoder, iqmp); - encoder.end_sequence(); - - privKeyEncoded = PEM_Code::encode (encoder.get_contents(), "RSA PRIVATE KEY"); -#else - privKeyEncoded = PEM_Code::encode ( - DER_Encoder().start_cons (SEQUENCE) - .encode(0U) - .encode(n) - .encode(e) - .encode(d) - .encode(p) - .encode(q) - .encode(dmp1) - .encode(dmq1) - .encode(iqmp) - .end_cons() - .get_contents(), "RSA PRIVATE KEY"); -#endif - - if (!privKeyFile) - { - ne7ssh::errors()->push (-1, "Cannot open file where the private key is stored. Filename: %s.", privKeyFileName); - delete rsaPrivKey; - return false; - } - - if (!fwrite (privKeyEncoded.c_str(), privKeyEncoded.length(), 1, privKeyFile)) - { - ne7ssh::errors()->push (-1, "IO error while writting to file: %s.", privKeyFileName); - delete rsaPrivKey; - return false; - } - fclose (privKeyFile); - - delete rsaPrivKey; - return true; -} - -bool ne7ssh_keys::generateDSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize) -{ - DER_Encoder encoder; - BigInt p, q, g, y, x; - ne7ssh_string pubKeyBlob; - FILE *privKeyFile, *pubKeyFile; - std::string privKeyEncoded; - - if (keySize != 1024) - { - ne7ssh::errors()->push (-1, "DSA keys must be 1024 bits."); - return false; - } - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - DL_Group dsaGroup (keySize, DL_Group::DSA_Kosherizer); - DSA_PrivateKey privDsaKey (dsaGroup); -#else - DL_Group dsaGroup (*ne7ssh::rng, Botan::DL_Group::DSA_Kosherizer, keySize); - DSA_PrivateKey privDsaKey (*ne7ssh::rng, dsaGroup); -#endif - - DSA_PublicKey pubDsaKey = privDsaKey; - - p = dsaGroup.get_p(); - q = dsaGroup.get_q(); - g = dsaGroup.get_g(); - y = pubDsaKey.get_y(); - x = privDsaKey.get_x(); - - pubKeyBlob.addString ("ssh-dss"); - pubKeyBlob.addBigInt (p); - pubKeyBlob.addBigInt (q); - pubKeyBlob.addBigInt (g); - pubKeyBlob.addBigInt (y); - - Pipe base64it (new Base64_Encoder); - base64it.process_msg(pubKeyBlob.value()); - - SecureVector pubKeyBase64 = base64it.read_all (PIPE_DEFAULT_MESSAGE); - - pubKeyFile = fopen (pubKeyFileName, "w"); - - if (!pubKeyFile) - { - ne7ssh::errors()->push (-1, "Cannot open file where public key is stored. Filename: %s", pubKeyFileName); - return false; - } - - if ((!fwrite ("ssh-dss ", 8, 1, pubKeyFile)) || - (!fwrite (pubKeyBase64.begin(), (size_t) pubKeyBase64.size(), 1, pubKeyFile)) || - (!fwrite (" ", 1, 1, pubKeyFile)) || - (!fwrite (fqdn, strlen(fqdn), 1, pubKeyFile)) || - (!fwrite ("\n", 1, 1, pubKeyFile))) - { - ne7ssh::errors()->push (-1, "I/O error while writting to file: %s.", pubKeyFileName); - return false; - } - fclose (pubKeyFile); - -#if BOTAN_PRE_15 - encoder.start_sequence(); - DER::encode (encoder, 0U); - DER::encode (encoder, p); - DER::encode (encoder, q); - DER::encode (encoder, g); - DER::encode (encoder, y); - DER::encode (encoder, x); - encoder.end_sequence(); -#else - encoder.start_cons(SEQUENCE) - .encode (0U) - .encode (p) - .encode (q) - .encode (g) - .encode (y) - .encode (x) - .end_cons(); -#endif - privKeyEncoded = PEM_Code::encode (encoder.get_contents(), "DSA PRIVATE KEY"); - - privKeyFile = fopen (privKeyFileName, "w"); - - if (!privKeyFile) - { - ne7ssh::errors()->push (-1, "Cannot open file where private key is stored. Filename: %s", privKeyFileName); - return false; - } - - if (!fwrite (privKeyEncoded.c_str(), (size_t) privKeyEncoded.length(), 1, privKeyFile)) - { - ne7ssh::errors()->push (-1, "I/O error while writting to file: %s.", privKeyFileName); - return false; - } - fclose (privKeyFile); - -// delete dsaGroup; - - return true; -} - - -SecureVector& ne7ssh_keys::generateSignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData) -{ - this->signature.destroy(); - switch (this->keyAlgo) - { - case DSA: - this->signature = generateDSASignature (sessionID, signingData); - return (signature); - - case RSA: - this->signature = generateRSASignature (sessionID, signingData); - return (signature); - - default: - this->signature.clear(); - return (signature); - } - -} - -SecureVector ne7ssh_keys::generateDSASignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData) -{ - SecureVector sigRaw; - ne7ssh_string sigData, sig; - - sigData.addVectorField (sessionID); - sigData.addVector (signingData); - if (!dsaPrivateKey) - { - ne7ssh::errors()->push (-1, "Private DSA key not initialized."); - return sig.value(); - } - - PK_Signer *DSASigner = get_pk_signer (*dsaPrivateKey, "EMSA1(SHA-1)"); -#if BOTAN_PRE_18 || BOTAN_PRE_15 - sigRaw = DSASigner->sign_message(sigData.value()); -#else - sigRaw = DSASigner->sign_message(sigData.value(), *ne7ssh::rng); -#endif - - if (!sigRaw.size()) - { - ne7ssh::errors()->push (-1, "Failure to generate DSA signature."); - delete DSASigner; - return sig.value(); - } - - if (sigRaw.size() != 40) - { - ne7ssh::errors()->push (-1, "DSS signature block <> 320 bits. Make sure you are using 1024 bit keys for authentication!"); - sig.clear(); - return sig.value(); - } - - delete DSASigner; - sig.addString ("ssh-dss"); - sig.addVectorField (sigRaw); - return (sig.value()); -} - -SecureVector ne7ssh_keys::generateRSASignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData) -{ - SecureVector sigRaw; - ne7ssh_string sigData, sig; - - sigData.addVectorField (sessionID); - sigData.addVector (signingData); - if (!rsaPrivateKey) - { - ne7ssh::errors()->push (-1, "Private RSA key not initialized."); - return sig.value(); - } - - PK_Signer *RSASigner = get_pk_signer (*rsaPrivateKey, "EMSA3(SHA-1)"); -#if BOTAN_PRE_18 || BOTAN_PRE_15 - sigRaw = RSASigner->sign_message(sigData.value()); -#else - sigRaw = RSASigner->sign_message(sigData.value(), *ne7ssh::rng); -#endif - if (!sigRaw.size()) - { - ne7ssh::errors()->push (-1, "Failure while generating RSA signature."); - delete RSASigner; - return sig.value(); - } - - delete RSASigner; - sig.addString ("ssh-rsa"); - sig.addVectorField (sigRaw); - return (sig.value()); -} - -bool ne7ssh_keys::getKeyPairFromFile (const char* privKeyFileName) -{ - ne7ssh_string privKeyStr; - char* buffer; - uint32 pos, i, length; - - if (!privKeyStr.addFile (privKeyFileName)) - { - ne7ssh::errors()->push (-1, "Cannot read PEM file: '%s'. Permission issues?", privKeyFileName); - return false; - } - - buffer = (char*) malloc (privKeyStr.length() + 1); - memcpy (buffer, (const char*)privKeyStr.value().begin(), privKeyStr.length()); - buffer[privKeyStr.length()] = 0x0; - - length = privKeyStr.length(); - - for (i = pos = 0; i < privKeyStr.length(); i++) - { - if (isspace(buffer[i])) - { - while (i < privKeyStr.length() && isspace (buffer[i])) - { - if (buffer[pos] != '\n') - buffer[pos] = buffer[i]; - if (++i >= privKeyStr.length()) break; - } - i--; - pos++; - continue; - } - buffer[pos] = buffer[i]; - pos++; - } - buffer[pos] = 0x00; - length = pos; - - if ((memcmp (buffer, "-----BEGIN", 10)) || - (memcmp (buffer + length - 17, "PRIVATE KEY-----", 16))) - { - ne7ssh::errors()->push (-1, "Encountered unknown PEM file format. Perhaps not an SSH private key file: '%s'.", privKeyFileName); - free (buffer); - return false; - } - - if (!memcmp (buffer, "-----BEGIN RSA PRIVATE KEY-----", 31)) - this->keyAlgo = ne7ssh_keys::RSA; - else if (!memcmp (buffer, "-----BEGIN DSA PRIVATE KEY-----", 31)) - this->keyAlgo = ne7ssh_keys::DSA; - else - { - ne7ssh::errors()->push (-1, "Encountered unknown PEM file format. Perhaps not an SSH private key file: '%s'.", privKeyFileName); - free (buffer); - return false; - } - - SecureVector keyVector ((Botan::byte*)buffer, length); - free (buffer); - switch (this->keyAlgo) - { - case DSA: - if (!getDSAKeys ((char*)keyVector.begin(), keyVector.size())) - return false; - break; - - case RSA: - if (!getRSAKeys ((char*)keyVector.begin(), keyVector.size())) - return false; - break; - } - - return true; - -} - -bool ne7ssh_keys::getDSAKeys (char* buffer, uint32 size) -{ -// DataSource_Memory privKeyPEMSrc (privKeyPEMStr); - const char* headerDSA = "-----BEGIN DSA PRIVATE KEY-----\n"; - const char* footerDSA = "-----END DSA PRIVATE KEY-----\n"; - SecureVector keyDataRaw; - BigInt p, q, g, y, x; - char *start; - uint32 version; - - start = buffer + strlen(headerDSA); - Pipe base64dec (new Base64_Decoder); - base64dec.process_msg ((Botan::byte*)start, size - strlen(footerDSA) - strlen(headerDSA)); - keyDataRaw = base64dec.read_all (PIPE_DEFAULT_MESSAGE); - - BER_Decoder decoder (keyDataRaw); - -#if BOTAN_PRE_15 - BER_Decoder sequence = BER::get_subsequence(decoder); - BER::decode (sequence, version); -#else - BER_Decoder sequence = decoder.start_cons (SEQUENCE); - sequence.decode (version); -#endif - - if (version) - { - ne7ssh::errors()->push (-1, "Encountered unknown DSA key version."); - return false; - } - -#if BOTAN_PRE_15 - BER::decode (sequence, p); - BER::decode (sequence, q); - BER::decode (sequence, g); - BER::decode (sequence, y); - BER::decode (sequence, x); -#else - sequence.decode (p); - sequence.decode (q); - sequence.decode (g); - sequence.decode (y); - sequence.decode (x); -#endif - - - sequence.discard_remaining(); - sequence.verify_end(); - - if (p.is_zero() || q.is_zero() || g.is_zero() || y.is_zero() || x.is_zero()) - { - ne7ssh::errors()->push (-1, "Could not decode the supplied DSA key."); - return false; - } - - DL_Group dsaGroup (p, q, g); - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - dsaPrivateKey = new DSA_PrivateKey (dsaGroup, x); -#else - dsaPrivateKey = new DSA_PrivateKey (*ne7ssh::rng, dsaGroup, x); -#endif - publicKeyBlob.clear(); - publicKeyBlob.addString ("ssh-dss"); - publicKeyBlob.addBigInt (p); - publicKeyBlob.addBigInt (q); - publicKeyBlob.addBigInt (g); - publicKeyBlob.addBigInt (y); - - return true; - -} - -bool ne7ssh_keys::getRSAKeys (char* buffer, uint32 size) -{ - const char* headerRSA = "-----BEGIN RSA PRIVATE KEY-----\n"; - const char* footerRSA = "-----END RSA PRIVATE KEY-----\n"; - SecureVector keyDataRaw; - BigInt p, q, e, d, n; - char *start; - uint32 version; - - start = buffer + strlen(headerRSA); - Pipe base64dec (new Base64_Decoder); - base64dec.process_msg ((Botan::byte*)start, size - strlen(footerRSA) - strlen(headerRSA)); - keyDataRaw = base64dec.read_all (PIPE_DEFAULT_MESSAGE); - - BER_Decoder decoder (keyDataRaw); - -#if BOTAN_PRE_15 - BER_Decoder sequence = BER::get_subsequence(decoder); - BER::decode (sequence, version); -#else - BER_Decoder sequence = decoder.start_cons(SEQUENCE); - sequence.decode (version); -#endif - - if (version) - { - ne7ssh::errors()->push (-1, "Encountered unknown RSA key version."); - return false; - } - -#if BOTAN_PRE_15 - BER::decode (sequence, n); - BER::decode (sequence, e); - BER::decode (sequence, d); - BER::decode (sequence, p); - BER::decode (sequence, q); -#else - sequence.decode (n); - sequence.decode (e); - sequence.decode (d); - sequence.decode (p); - sequence.decode (q); -#endif - - sequence.discard_remaining(); - sequence.verify_end(); - - if (n.is_zero() || e.is_zero() || d.is_zero() || p.is_zero() || q.is_zero()) - { - ne7ssh::errors()->push (-1, "Could not decode the supplied RSA key."); - return false; - } - -#if BOTAN_PRE_18 || BOTAN_PRE_15 - rsaPrivateKey = new RSA_PrivateKey (p, q, e, d, n); -#else - rsaPrivateKey = new RSA_PrivateKey (*ne7ssh::rng, p, q, e, d, n); -#endif - - publicKeyBlob.clear(); - publicKeyBlob.addString ("ssh-rsa"); - publicKeyBlob.addBigInt (e); - publicKeyBlob.addBigInt (n); - - return true; -} - -SecureVector& ne7ssh_keys::getPublicKeyBlob () -{ - return publicKeyBlob.value(); -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.h deleted file mode 100644 index f62c66f26a1..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_keys.h +++ /dev/null @@ -1,143 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_KEYS_H -#define NE7SSH_KEYS_H -#include -#include -#include -#include -#include -#include -#include - -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -#define MAX_KEYSIZE 8192 - - -/** - @author Andrew Useckas -*/ -class ne7ssh_keys -{ - private: - Botan::DSA_PrivateKey *dsaPrivateKey; - Botan::RSA_PrivateKey *rsaPrivateKey; - ne7ssh_string publicKeyBlob; - Botan::SecureVector signature; - - uint8 keyAlgo; - - /** - * Extracts DSA key pair from a PEM encoded stream. - * @param buffer PEM encoded string. - * @param size Length of the stream. - * @return True if keys succesfully extracted. Otherwise False is returned. - */ - bool getDSAKeys (char* buffer, uint32 size); - - /** - * Extracts RSA key pair from a PEM encoded stream. - * @param buffer PEM encoded string. - * @param size Length of the stream. - * @return True if keys succesfully extracted. Otherwise False is returned. - */ - bool getRSAKeys (char* buffer, uint32 size); - - public: - enum keyAlgos { DSA, RSA }; - - /** - * ne7ssh_keys constructor. - */ - ne7ssh_keys(); - - /** - * ne7ssh_keys destructor. - * @return - */ - ~ne7ssh_keys(); - - /** - * Generates DSA Key pair and saves keys in specified files. - * @param fqdn User id. Usually an Email. For example "test@netsieben.com" - * @param privKeyFileName Full path to a file where generated private key should be written. - * @param pubKeyFileName Full path to a file where generated public key should be written. - * @param keySize Desired key size in bits. If not specified will default to 2048. - * @return True if keys generated and written to the files. Otherwise false is returned. - */ - bool generateDSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 2048); - - /** - * Generates RSA Key pair and saves keys in specified files. - * @param fqdn User id. Usually an Email. For example "test@netsieben.com" - * @param privKeyFileName Full path to a file where generated private key should be written. - * @param pubKeyFileName Full path to a file where generated public key should be written. - * @param keySize Desired key size in bits. If not specified will default to 2048. - * @return True if keys generated and written to the files. Otherwise false is returned. - */ - bool generateRSAKeys (const char* fqdn, const char* privKeyFileName, const char* pubKeyFileName, uint16 keySize = 2048); - - /** - * Extracts key pair from a PEM encoded file. - *

Reads the file and determines the type of key, then passes processing to either getDsaKeys() or getRSAKeys(*) functions. - * @param privKeyFileName Full path to PEM encoded file. - * @return True if key succesfully extracted, otherwise False is returned. - */ - bool getKeyPairFromFile (const char* privKeyFileName); - - /** - * Generates a SHA-1 signature from sessionID and packet data provided. - *

Determines key type and passed the processing either to generateDSASignature() or generateRSAKeys() functions. - * @param sessionID SSH2 SessionID. - * @param signingData Packet data to sign. - * @return Returns signature, or 0 length vector if operation failed. - */ - Botan::SecureVector& generateSignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData); - - /** - * Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before. - * @param sessionID SSH2 SessionID. - * @param signingData Packet data to sign. - * @return Returns signature, or 0 length vector if operation failed. - */ - Botan::SecureVector generateDSASignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData); - - /** - * Generates a SHA-1 signature from sessionID and packet data provided, using DSA private key initialized before. - * @param sessionID SSH2 SessionID. - * @param signingData Packet data to sign. - * @return Returns signature, or 0 length vector if operation failed. - */ - Botan::SecureVector generateRSASignature (Botan::SecureVector& sessionID, Botan::SecureVector& signingData); - - /** - * After key pair has been initialized, this function returns public key blob, as specified by SSH2 specs. - * @return Public key blob or zero length vector, if there are initialized keys. - */ - Botan::SecureVector& getPublicKeyBlob (); - - /** - * Returns type of initialized keys. - * @return Type of keys. - */ - uint8 getKeyAlgo () { return keyAlgo; } - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.cpp deleted file mode 100644 index 1b8f4255156..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_mutex.h" - -Ne7ssh_Mutex::Ne7ssh_Mutex() -{ -#if defined(WIN32) || defined(__MINGW32__) - InitializeCriticalSection(&mutint); -#else - pthread_mutexattr_t mattr; - - pthread_mutexattr_init (&mattr); - pthread_mutexattr_settype (&mattr, PTHREAD_MUTEX_ERRORCHECK); - pthread_mutex_init (&mutint, &mattr); - pthread_mutexattr_destroy (&mattr); -#endif -} - -int Ne7ssh_Mutex::lock() -{ -#if defined(WIN32) || defined(__MINGW32__) - try - { - EnterCriticalSection(&mutint); - return 0; - } - catch (...) - { - return -1; - } -#else - return pthread_mutex_lock(&mutint); -#endif -} - -int Ne7ssh_Mutex::unlock() -{ -#if defined(WIN32) || defined(__MINGW32__) - LeaveCriticalSection(&mutint); - return 0; -#else - return pthread_mutex_unlock(&mutint); -#endif -} - -Ne7ssh_Mutex::~Ne7ssh_Mutex() -{ -#if defined(WIN32) || defined(__MINGW32__) - DeleteCriticalSection(&mutint); -#else - pthread_mutex_destroy(&mutint); -#endif -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.h deleted file mode 100644 index d48d7414f20..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_mutex.h +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2006 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - - -#ifndef NE7SSH_MUTEX_H -#define NE7SSH_MUTEX_H - -#if defined(WIN32) || defined(__MINGW32__) -# include -#else -# include -#endif - -class Ne7ssh_Mutex -{ -public: - Ne7ssh_Mutex(); - - int lock(); - - int unlock(); - - ~Ne7ssh_Mutex(); -private: -#if defined(WIN32) || defined(__MINGW32__) - CRITICAL_SECTION mutint; -#else - pthread_mutex_t mutint; -#endif -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_session.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_session.cpp deleted file mode 100644 index 57176695941..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_session.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_session.h" - -ne7ssh_session::ne7ssh_session() : sendChannel(0), receiveChannel(0), channelID(-1), transport(0) -{ -} - - -ne7ssh_session::~ne7ssh_session() -{ -} - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_session.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_session.h deleted file mode 100644 index ae312c3acfa..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_session.h +++ /dev/null @@ -1,139 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_SESSION_H -#define NE7SSH_SESSION_H - -#include "ne7ssh_types.h" -#include "ne7ssh_transport.h" -#include "crypt.h" - -/** -@author Andrew Useckas -*/ -class ne7ssh_session -{ - private: - Botan::SecureVector localVersion; - Botan::SecureVector remoteVersion; - Botan::SecureVector sessionID; - uint32 sendChannel; - uint32 receiveChannel; - uint32 maxPacket; - int32 channelID; - - public: - ne7ssh_transport *transport; - ne7ssh_crypt *crypto; - - /** - * ne7ssh_session class constructor. - */ - ne7ssh_session(); - - /** - * ne7ssh_session class desctructor. - */ - ~ne7ssh_session(); - - /** - * Sets the local SSH version string. - * @param version Reference to a vector containing the version string. - */ - void setLocalVersion (Botan::SecureVector& version) { localVersion = version; } - - /** - * Returns local SSH version. - * @return Reference to a vector containing the version string. - */ - Botan::SecureVector &getLocalVersion () { return localVersion; } - - /** - * Sets the remote SSH version string. - * @param version Reference to a vector containing the version string. - */ - void setRemoteVersion (Botan::SecureVector& version) { remoteVersion = version; } - - /** - * Returns remote SSH version. - * @return Reference to a vector containing the version string. - */ - Botan::SecureVector &getRemoteVersion () { return remoteVersion; } - - /** - * Sets SSH session ID, a.k.a. H from the first KEX. - * @param session Reference to a vector containing the session ID. - */ - void setSessionID (Botan::SecureVector& session) { sessionID = session; } - - /** - * Returns the current SSH session ID. - * @return Reference to a vector containing the session ID. - */ - Botan::SecureVector &getSessionID () { return sessionID; } - - /** - * After the channel is open this function sets the send channel ID. - * @param channel Channel ID. - */ - void setSendChannel (uint32 channel) { sendChannel = channel; } - - /** - * Returns the send channel ID. - * @return Channel ID. - */ - uint32 getSendChannel () const { return sendChannel; } - - /** - * After the channel is open this function sets the receive channel ID. - * @param channel Channel ID. - */ - void setReceiveChannel (uint32 channel) { receiveChannel = channel; } - - /** - * Returns the receive channel ID. - * @return Channel ID. - */ - uint32 getReceiveChannel () { return receiveChannel; } - - /** - * Sets maximum send packet size. - * @param size Maximum packet size. - */ - void setMaxPacket (uint32 size) { maxPacket = size; } - - /** - * Returns maximum send packet size. - * @return Maximum packet size. - */ - uint32 getMaxPacket () { return maxPacket; } - - /** - * Stores newly created ne7ssh channel. - * @param channel ne7ssh channel. - */ - void setSshChannel (int32 channel) { channelID = channel; } - - /** - * REtrieves current ne7ssh channel. - * @return ne7ssh channel or -1 if the session hasn't succesfully opened the channel yet. - */ - int32 getSshChannel () { return channelID; } - - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.cpp deleted file mode 100644 index 61d325634eb..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.cpp +++ /dev/null @@ -1,1366 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - - -#include -#include -#include "ne7ssh_transport.h" -#include "ne7ssh_sftp.h" -#include "ne7ssh_sftp_packet.h" -#include "ne7ssh.h" -#include "ne7ssh_session.h" -#include "ne7ssh_channel.h" - -using namespace Botan; - -Ne7sshSftp::Ne7sshSftp (ne7ssh_session* _session, ne7ssh_channel* _channel) : ne7ssh_channel (_session), session(_session), timeout(30), seq(1), sftpCmd(0), lastError(0), currentPath(0), sftpFiles(0), sftpFilesCount(0) -{ - windowRecv = _channel->getRecvWindow(); - windowSend = _channel->getSendWindow(); -} - -Ne7sshSftp::~Ne7sshSftp() -{ - uint16 i; - for (i = 0; i < sftpFilesCount; i++) - { - free (sftpFiles[i]); - } - if (sftpFiles) free (sftpFiles); - if (currentPath) free (currentPath); -} - -bool Ne7sshSftp::init () -{ - ne7ssh_transport *_transport = session->transport; - ne7ssh_string packet; - bool status; - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_REQUEST); - packet.addInt (session->getSendChannel()); - packet.addString ("subsystem"); - packet.addChar (0); - packet.addString ("sftp"); - - if (!_transport->sendPacket (packet.value())) - { - return false; - } - - packet.clear(); - packet.addChar (SSH2_MSG_CHANNEL_DATA); - packet.addInt (session->getSendChannel()); - packet.addInt (sizeof(uint32) * 2 + sizeof(char)); - packet.addInt (sizeof(uint32) + sizeof(char)); - packet.addChar (SSH2_FXP_INIT); - packet.addInt (SFTP_VERSION); - - windowSend -= 9; - - if (!_transport->sendPacket (packet.value())) - return false; - - channelOpened = true; - status = receiveUntil (SSH2_FXP_VERSION, this->timeout); - - return status; - -} - -bool Ne7sshSftp::handleData (Botan::SecureVector& packet) -{ - ne7ssh_string mainBuffer (packet, 0); - uint32 channelID; - SecureVector sftpBuffer; - uint32 len = 0; - Botan::byte _cmd; - - channelID = mainBuffer.getInt(); - - if (!mainBuffer.getString (sftpBuffer)) return false; - if (!sftpBuffer.size()) - ne7ssh::errors()->push (session->getSshChannel(), "Abnormal. End of stream detected in SFTP subsystem."); - - adjustRecvWindow (sftpBuffer.size()); - - if (seq >= SFTP_MAX_SEQUENCE) seq = 0; - - mainBuffer.clear(); - - len = commBuffer.length(); - - if (len) mainBuffer.addVector (commBuffer.value()); - - commBuffer.addVector (sftpBuffer); - mainBuffer.addVector (sftpBuffer); - - if (mainBuffer.length() < sizeof(uint32) - || mainBuffer.getInt() > mainBuffer.length()) - return true; - - commBuffer.clear(); - - _cmd = mainBuffer.getByte(); - - this->sftpCmd = _cmd; - switch (_cmd) - { - case SSH2_FXP_VERSION: - return handleVersion (mainBuffer.value()); - break; - - case SSH2_FXP_HANDLE: - return addOpenHandle (mainBuffer.value()); - - case SSH2_FXP_STATUS: - return handleStatus (mainBuffer.value()); - - case SSH2_FXP_DATA: - return handleSftpData (mainBuffer.value()); - - case SSH2_FXP_NAME: - return handleNames (mainBuffer.value()); - - case SSH2_FXP_ATTRS: - return processAttrs (mainBuffer.value()); - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Unhandled SFTP subsystem command: %i.", _cmd); - return false; - } - - return true; -} - -bool Ne7sshSftp::receiveWindowAdjust () -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - - if (!_transport->waitForPacket (SSH2_MSG_CHANNEL_WINDOW_ADJUST)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote side could not adjust the Window."); - return false; - } - _transport->getPacket (packet); - if (!handleReceived (packet)) return false; - return true; -} - -bool Ne7sshSftp::receiveUntil (short _cmd, uint32 timeSec) -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - uint32 cutoff = timeSec * 1000000, timeout = 0; - uint32 prevSize = 0; - - this->sftpCmd = 0; - commBuffer.clear(); - - while (true) - { - const short status = _transport->waitForPacket (0, false); - if (status > 0) - { - _transport->getPacket (packet); - if (!handleReceived (packet)) return false; - } - - if (commBuffer.length() > prevSize) timeout = 0; - - prevSize = commBuffer.length(); - - usleep (10000); - - if (sftpCmd == _cmd) return true; - if (!cutoff) continue; - if (timeout >= cutoff) break; - else timeout += 10000; - } - return false; -} - -bool Ne7sshSftp::receiveWhile (short _cmd, uint32 timeSec) -{ - ne7ssh_transport *_transport = session->transport; - SecureVector packet; - uint32 cutoff = timeSec * 1000000, timeout = 0; - uint32 prevSize = 0; - bool status; - - this->sftpCmd = _cmd; - commBuffer.clear(); - - while (true) - { - status = _transport->waitForPacket (0, false); - if (status) - { - _transport->getPacket (packet); - if (!handleReceived (packet)) return false; - } - - if (commBuffer.length() > prevSize) timeout = 0; - if (commBuffer.length() == 0) return true; - - prevSize = commBuffer.length(); - - usleep (10000); - - if (sftpCmd != _cmd) return true; - - if (!cutoff) continue; - if (timeout >= cutoff) break; - else timeout += 10000; - } - return false; -} - -bool Ne7sshSftp::handleVersion (Botan::SecureVector& packet) -{ - ne7ssh_string sftpBuffer (packet, 0); - uint32 version; - - version = sftpBuffer.getInt(); - - if (version != SFTP_VERSION) - { - ne7ssh::errors()->push (session->getSshChannel(), "Unsupported SFTP version: %i.", version); - return false; - } - - return true; - -} - -bool Ne7sshSftp::handleStatus (Botan::SecureVector& packet) -{ - ne7ssh_string sftpBuffer (packet, 0); - uint32 requestID, errorID; - SecureVector errorStr; - - - requestID = sftpBuffer.getInt(); - errorID = sftpBuffer.getInt(); - sftpBuffer.getString (errorStr); - - if (errorID) - { - lastError = errorID; - ne7ssh::errors()->push (session->getSshChannel(), "SFTP Error code: <%i>, description: %s.", errorID, errorStr.begin()); - return false; - } - return true; - -} - -bool Ne7sshSftp::addOpenHandle (Botan::SecureVector& packet) -{ - ne7ssh_string sftpBuffer (packet, 0); - uint32 requestID; - SecureVector handle; - uint16 len; - - requestID = sftpBuffer.getInt(); - sftpBuffer.getString (handle); - - if (!this->sftpFiles) this->sftpFiles = (sftpFile**) malloc (sizeof(sftpFile*)); - else this->sftpFiles = (sftpFile**) realloc (sftpFiles, sizeof(sftpFile*) * (this->sftpFilesCount + 1)); - - sftpFiles[sftpFilesCount] = (sftpFile*) malloc (sizeof(sftpFile)); - sftpFiles[sftpFilesCount]->fileID = requestID; - len = handle.size(); - if (len > 256) len = 256; - memcpy (sftpFiles[sftpFilesCount]->handle, handle.begin(), len); - sftpFiles[sftpFilesCount]->handleLen = len; - sftpFilesCount++; - return true; - -} - -bool Ne7sshSftp::handleSftpData (Botan::SecureVector& packet) -{ - ne7ssh_string sftpBuffer (packet, 0); - uint32 requestID; - SecureVector data; - uint16 len; - - requestID = sftpBuffer.getInt(); - sftpBuffer.getString (data); - len = data.size(); - - if (data.size() == 0) - { - ne7ssh::errors()->push (session->getSshChannel(), "Abnormal. End of stream detected."); - return false; - } - - commBuffer.clear(); - fileBuffer.destroy(); - fileBuffer.swap (data); - return true; -} - -bool Ne7sshSftp::handleNames (Botan::SecureVector& packet) -{ - Ne7sshSftpPacket sftpBuffer (packet, 0); - ne7ssh_string tmpVar; - uint32 requestID, fileCount, i; - SecureVector fileName; - - requestID = sftpBuffer.getInt(); - fileCount = sftpBuffer.getInt(); - tmpVar.addInt (fileCount); - - if (!fileCount) return true; - - for (i = 0; i < fileCount; i++) - { - sftpBuffer.getString (fileName); - tmpVar.addVectorField (fileName); - sftpBuffer.getString (fileName); - tmpVar.addVectorField (fileName); - attrs.flags = sftpBuffer.getInt(); - if (attrs.flags & SSH2_FILEXFER_ATTR_SIZE) - attrs.size = sftpBuffer.getInt64(); - - if (attrs.flags & SSH2_FILEXFER_ATTR_UIDGID) - { - attrs.owner = sftpBuffer.getInt(); - attrs.group = sftpBuffer.getInt(); - } - - if (attrs.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) - { - attrs.permissions = sftpBuffer.getInt(); - } - - if (attrs.flags & SSH2_FILEXFER_ATTR_ACMODTIME) - { - attrs.atime = sftpBuffer.getInt(); - attrs.mtime = sftpBuffer.getInt(); - } - } - fileBuffer.append(tmpVar.value()); - - return true; -} - -bool Ne7sshSftp::processAttrs (Botan::SecureVector& packet) -{ - Ne7sshSftpPacket sftpBuffer (packet, 0); - uint32 requestID; - SecureVector data; - - requestID = sftpBuffer.getInt(); - attrs.flags = sftpBuffer.getInt(); - if (attrs.flags & SSH2_FILEXFER_ATTR_SIZE) - attrs.size = sftpBuffer.getInt64(); - - if (attrs.flags & SSH2_FILEXFER_ATTR_UIDGID) - { - attrs.owner = sftpBuffer.getInt(); - attrs.group = sftpBuffer.getInt(); - } - - if (attrs.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) - { - attrs.permissions = sftpBuffer.getInt(); - } - - if (attrs.flags & SSH2_FILEXFER_ATTR_ACMODTIME) - { - attrs.atime = sftpBuffer.getInt(); - attrs.mtime = sftpBuffer.getInt(); - } - - return true; -} - - -uint32 Ne7sshSftp::openFile (const char* filename, uint8 shortMode) -{ - uint32 mode; - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - ne7ssh_string fullPath; - - fullPath = getFullPath (filename); - - if (!fullPath.length()) return 0; - - switch (shortMode) - { - case READ: - mode = SSH2_FXF_READ; - break; - - case OVERWRITE: - mode = SSH2_FXF_WRITE | SSH2_FXF_CREAT | SSH2_FXF_TRUNC; - break; - - case APPEND: - mode = SSH2_FXF_WRITE | SSH2_FXF_CREAT; - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Unsupported file opening mode: %i.", shortMode); - return 0; - - } - - packet.addChar (SSH2_FXP_OPEN); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (mode); - packet.addInt (0); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return 0; - - windowSend -= 21 + fullPath.length(); - - status = receiveUntil (SSH2_FXP_HANDLE, this->timeout); - - if (!status) return 0; - else return (seq - 1); -} - -uint32 Ne7sshSftp::openDir (const char* dirname) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - ne7ssh_string fullPath = getFullPath (dirname); - - if (!fullPath.length()) return 0; - - packet.addChar (SSH2_FXP_OPENDIR); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return 0; - - windowSend -= 13 + fullPath.length(); - - status = receiveUntil (SSH2_FXP_HANDLE, this->timeout); - - if (!status) return 0; - else return (seq - 1); -} - -bool Ne7sshSftp::readFile (uint32 fileID, uint64 offset) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - sftpFile *remoteFile = getFileHandle (fileID); - - if (!remoteFile) return false; - - packet.addChar (SSH2_FXP_READ); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - packet.addInt64 (offset); - packet.addInt (SFTP_MAX_MSG_SIZE); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= remoteFile->handleLen + 25; - - status = receiveWhile (SSH2_FXP_DATA, this->timeout); - - return status; -} - -bool Ne7sshSftp::writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - sftpFile *remoteFile = getFileHandle (fileID); - uint32 sent = 0, currentLen = 0; - Botan::SecureVector sendVector; - - if (len > SFTP_MAX_MSG_SIZE) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not write. Datablock larger than maximum msg size. Remote file ID %i.", fileID); - return false; - } - - if (!remoteFile) return false; - - packet.addChar (SSH2_FXP_WRITE); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - packet.addInt64 (offset); - packet.addInt (len); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return false; - } - windowSend -= remoteFile->handleLen + 25; - - while (sent < len) - { - currentLen = len - sent < windowSend ? len - sent : windowSend; - currentLen = currentLen < (uint32)(SFTP_MAX_PACKET_SIZE - (remoteFile->handleLen + 86)) ? currentLen : SFTP_MAX_PACKET_SIZE - (remoteFile->handleLen + 86); - - if (sent) packet.clear(); - packet.addBytes (data + sent, currentLen); - - if (sent) - sendVector = packet.valueFragment(); - else - sendVector = packet.valueFragment(remoteFile->handleLen + 21 + len); - - if (!sendVector.size()) return false; - - status = _transport->sendPacket (sendVector); - if (!status) return false; - - windowSend -= currentLen; - sent += currentLen; - if (!windowSend) - { - if (!receiveWindowAdjust()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Remote side could not adjust the Window."); - return false; - } - } -// if (sent - currentLen) break; - } - status = receiveUntil (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::closeFile (uint32 fileID) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - uint16 i; - bool status, match=false; - sftpFile *remoteFile = getFileHandle (fileID); - - if (!remoteFile) return false; - - packet.addChar (SSH2_FXP_CLOSE); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= remoteFile->handleLen + 13; - - for (i = 0; i < sftpFilesCount; i++) - { - if (match) sftpFiles[i - 1] = sftpFiles[i]; - else if (sftpFiles[i]->fileID == fileID) - { - free (sftpFiles[i]); - sftpFiles[i] = 0; - match = true; - } - } - if (match) sftpFilesCount--; - - status = receiveUntil (SSH2_FXP_STATUS, this->timeout); - return status; -} - -ne7ssh_string Ne7sshSftp::getFullPath (const char* filename) -{ - Botan::SecureVector result; - char *buffer = 0; - uint32 len, pos, last_char, i = 0; - - if (!filename) return ne7ssh_string(); - len = strlen (filename); - - buffer = (char*) malloc (len + 1); - memcpy (buffer, filename, len); - - while (isspace (buffer[i])) i++; - - for (pos = 0; i < len; i++) - { - if (buffer[i] == '\\') - buffer[pos] = '/'; - else buffer[pos] = buffer[i]; - pos++; - } - pos--; - while (isspace (buffer[pos])) pos--; - if (pos > 1 && buffer[pos] == '.' && buffer[pos-1] != '.') pos--; - else if (!pos && buffer[pos] == '.') buffer[pos] = 0; - - result.destroy(); - if ((buffer[0] != '/') && currentPath) - { - if (currentPath) len = strlen (this->currentPath); - else - { - free (buffer); - return ne7ssh_string(); - } - result.append ((uint8*)currentPath, len); - last_char = len - 1; - if (currentPath[last_char] && currentPath[last_char] != '/') - result.append ((uint8*)"/", 1); - } - while (buffer[pos] == '/') pos--; - buffer[++pos] = 0x00; - result.append ((uint8*)buffer, pos); - free (buffer); - return ne7ssh_string(result, 0); -} - -Ne7sshSftp::sftpFile* Ne7sshSftp::getFileHandle (uint32 fileID) -{ - uint16 i; - uint32 _fileID; - - for (i = 0; i < sftpFilesCount; i++) - { - _fileID = sftpFiles[i]->fileID; - if (sftpFiles[i]->fileID == fileID) - { - return sftpFiles[i]; - } - } - ne7ssh::errors()->push (session->getSshChannel(), "Invalid file ID: %i.", fileID); - return 0; -} - -bool Ne7sshSftp::getFileStats (const char* remoteFile, bool followSymLinks) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - uint8 _cmd = followSymLinks ? SSH2_FXP_STAT : SSH2_FXP_LSTAT; - ne7ssh_string fullPath = getFullPath (remoteFile); - - if (!fullPath.length()) return 0; - - if (!remoteFile) return false; - - packet.addChar (_cmd); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (SSH2_FILEXFER_ATTR_SIZE | SSH2_FILEXFER_ATTR_UIDGID | SSH2_FILEXFER_ATTR_PERMISSIONS | SSH2_FILEXFER_ATTR_ACMODTIME); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= 17 + fullPath.length(); - - status = receiveWhile (SSH2_FXP_ATTRS, this->timeout); - return status; -} - -bool Ne7sshSftp::getFStat (uint32 fileID) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - sftpFile *remoteFile = getFileHandle (fileID); - - if (!remoteFile) return false; - packet.addChar (SSH2_FXP_FSTAT); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= remoteFile->handleLen + 13; - - status = receiveWhile (SSH2_FXP_ATTRS, this->timeout); - return status; -} - -uint64 Ne7sshSftp::getFileSize (uint32 fileID) -{ - if (!getFStat (fileID)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return 0; - } - - return attrs.size; -} - -bool Ne7sshSftp::getFileAttrs (Ne7SftpSubsystem::fileAttrs& attributes, const char* remoteFile, bool /* followSymLinks */) -{ - if (!remoteFile) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - ne7ssh_string fullPath = getFullPath (remoteFile); - if (!fullPath.length()) return false; - - if (!getFileStats ((const char*)fullPath.value().begin())) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - - attributes.size = attrs.size; - attributes.owner = attrs.owner; - attributes.group = attrs.group; - attributes.permissions = attrs.permissions; - attributes.atime = attrs.atime; - attributes.mtime = attrs.mtime; - - return true; -} - -bool Ne7sshSftp::getFileAttrs (sftpFileAttrs& attributes, Botan::SecureVector& remoteFile, bool followSymLinks) -{ - if (!remoteFile.size()) return false; - if (!getFileStats ((const char*)remoteFile.begin())) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - attributes.size = attrs.size; - attributes.owner = attrs.owner; - attributes.group = attrs.group; - attributes.permissions = attrs.permissions; - attributes.atime = attrs.atime; - attributes.mtime = attrs.mtime; - - return true; -} - -bool Ne7sshSftp::isType (const char* remoteFile, uint32 type) -{ - uint32 perms; - if (!remoteFile) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - ne7ssh_string fullPath = getFullPath (remoteFile); - if (!fullPath.length()) return false; - - if (!getFileStats ((const char*)fullPath.value().begin())) - { - ne7ssh::errors()->push (session->getSshChannel(), "Failed to get remote file attributes."); - return false; - } - - perms = attrs.permissions; - if (perms & type) return true; - else return false; -} - -bool Ne7sshSftp::isFile (const char* remoteFile) -{ - return isType (remoteFile, S_IFREG); -} - -bool Ne7sshSftp::isDir (const char* remoteFile) -{ - return isType (remoteFile, S_IFDIR); -} - -bool Ne7sshSftp::get (const char* remoteFile, FILE* localFile) -{ - uint32 size; - uint64 offset = 0; - Botan::SecureVector localBuffer; - uint32 fileID; - - if (!localFile) - { - ne7ssh::errors()->push (session->getSshChannel(), "Invalid local or remote file."); - return false; - } - - fileID = openFile (remoteFile, READ); - - if (!fileID) return false; - - size = getFileSize (fileID); - - if (!size) - { - ne7ssh::errors()->push (session->getSshChannel(), "File size is zero."); - return false; - } - - while (size > offset) - { - readFile (fileID, offset); - if (fileBuffer.size() == 0) return false; - localBuffer.destroy(); - localBuffer.swap (fileBuffer); - - if (!fwrite (localBuffer.begin(), (size_t) localBuffer.size(), 1, localFile)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not write to local file. Remote file ID %i.", fileID); - return false; - } - offset += localBuffer.size(); - } - - if (!closeFile (fileID)) return false; - return true; - -} - -bool Ne7sshSftp::put (FILE* localFile, const char* remoteFile) -{ - size_t size; - uint64 offset = 0; - Botan::SecureVector localBuffer; - uint32 fileID; - uint8* buffer = 0; - uint32 len; - - if (!localFile || !remoteFile) - { - ne7ssh::errors()->push (session->getSshChannel(), "Invalid local or remote file."); - return false; - } - - fileID = openFile (remoteFile, OVERWRITE); - - if (!fileID) return false; - - fseek (localFile, 0L, SEEK_END); - size = ftell (localFile); - rewind (localFile); - - if (!size) - { - ne7ssh::errors()->push (session->getSshChannel(), "File size is zero."); - return false; - } - - buffer = (uint8*) malloc (SFTP_MAX_MSG_SIZE); - while (size > offset) - { - len = (size - offset) < SFTP_MAX_MSG_SIZE - 384 ? (size - offset) : SFTP_MAX_MSG_SIZE - 384; - - if (!fread (buffer, len, 1, localFile)) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not read from local file. Remote file ID %i.", fileID); - if (buffer) free (buffer); - return false; - } - if (!writeFile (fileID, buffer, len, offset)) - { - if (buffer) free (buffer); - return false; - } - offset += len; - } - - if (buffer) free (buffer); - if (!closeFile (fileID)) return false; - return true; - -} - -bool Ne7sshSftp::rm (const char* remoteFile) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!remoteFile) return false; - ne7ssh_string fullPath = getFullPath (remoteFile); - - if (!fullPath.length()) return false; - - packet.addChar (SSH2_FXP_REMOVE); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return false; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= 13 + fullPath.length(); - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::mv (const char* oldFile, const char* newFile) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!oldFile || !newFile) return false; - ne7ssh_string oldPath = getFullPath (oldFile); - ne7ssh_string newPath = getFullPath (newFile); - - if (!oldPath.length() || !newPath.length()) return false; - - packet.addChar (SSH2_FXP_RENAME); - packet.addInt (this->seq++); - packet.addVectorField (oldPath.value()); - packet.addVectorField (newPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= oldPath.length() + newPath.length() + 17; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::mkdir (const char* remoteDir) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!remoteDir) return false; - ne7ssh_string fullPath = getFullPath (remoteDir); - - if (!fullPath.length()) return false; - - packet.addChar (SSH2_FXP_MKDIR); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (0); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 17; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::rmdir (const char* remoteDir) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!remoteDir) return false; - ne7ssh_string fullPath = getFullPath (remoteDir); - - if (!fullPath.length()) return false; - - packet.addChar (SSH2_FXP_RMDIR); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 13; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -const char* Ne7sshSftp::ls (const char* remoteDir, bool longNames) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - ne7ssh_string tmpVar; - SecureVector fileName; - bool status = true; - uint32 fileID, fileCount, i; - sftpFile *remoteFile; - if (!remoteDir) return 0; - - fileID = openDir (remoteDir); - - if (!fileID) return 0; - remoteFile = getFileHandle (fileID); - if (!remoteFile) return 0; - fileBuffer.destroy(); - - while (status) - { - packet.clear(); - packet.addChar (SSH2_FXP_READDIR); - packet.addInt (this->seq++); - packet.addInt (remoteFile->handleLen); - packet.addBytes ((Botan::byte*)remoteFile->handle, remoteFile->handleLen); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return 0; - - windowSend -= remoteFile->handleLen + 13; - - status = receiveWhile (SSH2_FXP_NAME, this->timeout); - } - if (lastError > 1) return 0; - - packet.clear(); - packet.addVector (fileBuffer); - fileCount = packet.getInt(); - tmpVar.clear(); - for (i = 0; i < fileCount; i++) - { - packet.getString (fileName); - fileName.append ((const Botan::byte*)"\n", 1); - if (!longNames) tmpVar.addVector (fileName); - - packet.getString (fileName); - fileName.append ((const Botan::byte*)"\n", 1); - if (longNames) tmpVar.addVector (fileName); - } - fileBuffer.swap (tmpVar.value()); - - if (!closeFile (fileID)) return 0; - return (const char*)fileBuffer.begin(); -} - -bool Ne7sshSftp::cd (const char* remoteDir) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - SecureVector fileName; - uint32 fileCount; - bool status; - if (!remoteDir) return false; - ne7ssh_string fullPath = getFullPath (remoteDir); - - if (!fullPath.length()) return false; - - fileBuffer.destroy(); - - packet.addChar (SSH2_FXP_REALPATH); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return false; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 13; - - status = receiveWhile (SSH2_FXP_NAME, this->timeout); - if (!status) - { - ne7ssh::errors()->push (session->getSshChannel(), "Could not change to remote directory: %s.", remoteDir); - return false; - } - - - packet.clear(); - packet.addVector (fileBuffer); - fileCount = packet.getInt(); - if (!fileCount) return false; - packet.getString (fileName); - - if (!currentPath) currentPath = (char*) malloc (fileName.size() + 1); - else currentPath = (char*) realloc (currentPath, fileName.size() + 1); - memcpy (currentPath, fileName.begin(), fileName.size()); - currentPath[fileName.size()] = 0; - return status; -} - -bool Ne7sshSftp::chmod (const char* remoteFile, const char* mode) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - if (!remoteFile) return false; - ne7ssh_string fullPath = getFullPath (remoteFile); - uint32 perms, len, octet = 0; - bool u, g, o, plus; - const char* _pos; - uint8 i; - char converter[] = {'0', '0', '0', '0', '0'}; - - if (!fullPath.length()) return false; - - if (!getFileAttrs (attrs, fullPath.value(), true)) - return false; - - perms = attrs.permissions; - - len = strlen (mode); - if (len < 5 && len > 2) - { - for (i = 0; i < len; i++) - { - if (!isdigit (mode[i])) break; - } - - if (i != len) _pos = mode; - else - { - memcpy (converter + (5 - len), mode, len); - octet = strtol (converter, (char**)&_pos, 8); - if (octet > 07777) - { - ne7ssh::errors()->push (session->getSshChannel(), "Invalid permission octet."); - return false; - } - if (len == 3) perms = (perms & ~0777) | octet; - else perms = (perms & ~07777) | octet; - } - } - - _pos = mode; - if (!octet) - { - while (*_pos) - { - if (*_pos == ',') _pos++; - u = g = o = plus = false; - while (*_pos && *_pos != '+' && *_pos != '-') - { - switch (*_pos) - { - case 'u': - u = true; - break; - - case 'g': - g = true; - break; - - case 'o': - o = true; - break; - - case 'a': - u = g = o = true; - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Invalid mode string."); - return false; - - } - _pos++; - } - - if (*_pos == '+') plus = true; - _pos++; - while (*_pos && *_pos != ',') - { - switch (*_pos) - { - case 'r': - if (u) perms = plus ? perms | S_IRUSR : perms ^ S_IRUSR; - if (g) perms = plus ? perms | S_IRGRP : perms ^ S_IRGRP; - if (o) perms = plus ? perms | S_IROTH : perms ^ S_IROTH; - break; - - case 'w': - if (u) perms = plus ? perms | S_IWUSR : perms ^ S_IWUSR; - if (g) perms = plus ? perms | S_IWGRP : perms ^ S_IWGRP; - if (o) perms = plus ? perms | S_IWOTH : perms ^ S_IWOTH; - break; - - case 'x': - if (u) perms = plus ? perms | S_IXUSR : perms ^ S_IXUSR; - if (g) perms = plus ? perms | S_IXGRP : perms ^ S_IXGRP; - if (o) perms = plus ? perms | S_IXOTH : perms ^ S_IXOTH; - break; - - case 's': - if (u) perms = plus ? perms | S_ISUID : perms ^ S_ISUID; - if (g) perms = plus ? perms | S_ISGID : perms ^ S_ISGID; - break; - - case 't': - perms = plus ? perms | S_ISVTX : perms ^ S_ISVTX; - break; - - case 'X': - if ((perms & 111) == 0) break; - if (u) perms = plus ? perms | S_IXUSR : perms ^ S_IXUSR; - if (g) perms = plus ? perms | S_IXGRP : perms ^ S_IXGRP; - if (o) perms = plus ? perms | S_IXOTH : perms ^ S_IXOTH; - break; - - case 'u': - if (u) perms = plus ? perms | (perms & S_IRWXU) : perms ^ (perms & S_IRWXU); - if (g) perms = plus ? perms | (perms & S_IRWXU) : perms ^ (perms & S_IRWXU); - if (o) perms = plus ? perms | (perms & S_IRWXU) : perms ^ (perms & S_IRWXU); - break; - - case 'g': - if (u) perms = plus ? perms | (perms & S_IRWXG) : perms ^ (perms & S_IRWXG); - if (g) perms = plus ? perms | (perms & S_IRWXG) : perms ^ (perms & S_IRWXG); - if (o) perms = plus ? perms | (perms & S_IRWXG) : perms ^ (perms & S_IRWXG); - break; - - case 'o': - if (u) perms = plus ? perms | (perms & S_IRWXO) : perms ^ (perms & S_IRWXO); - if (g) perms = plus ? perms | (perms & S_IRWXO) : perms ^ (perms & S_IRWXO); - if (o) perms = plus ? perms | (perms & S_IRWXO) : perms ^ (perms & S_IRWXO); - break; - - default: - ne7ssh::errors()->push (session->getSshChannel(), "Invalid mode string."); - return false; - } - _pos++; - } - } - } - - - packet.addChar (SSH2_FXP_SETSTAT); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (SSH2_FILEXFER_ATTR_PERMISSIONS); - packet.addInt (perms); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return 0; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 21; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - -bool Ne7sshSftp::chown (const char* remoteFile, uint32 uid, uint32 gid) -{ - Ne7sshSftpPacket packet (session->getSendChannel()); - ne7ssh_transport *_transport = session->transport; - bool status; - uint32 old_uid, old_gid; - if (!remoteFile) return false; - ne7ssh_string fullPath = getFullPath (remoteFile); - - if (!fullPath.length()) return false; - - if (!getFileAttrs (attrs, fullPath.value(), true)) - return false; - - old_uid = attrs.owner; - old_gid = attrs.group; - - packet.addChar (SSH2_FXP_SETSTAT); - packet.addInt (this->seq++); - packet.addVectorField (fullPath.value()); - packet.addInt (SSH2_FILEXFER_ATTR_UIDGID); - if (uid) packet.addInt (uid); - else packet.addInt (old_uid); - if (gid) packet.addInt (gid); - else packet.addInt (old_gid); - - if (!packet.isChannelSet()) - { - ne7ssh::errors()->push (session->getSshChannel(), "Channel not set in sftp packet class."); - return false; - } - - if (!_transport->sendPacket (packet.value())) - return false; - - windowSend -= fullPath.length() + 25; - - status = receiveWhile (SSH2_FXP_STATUS, this->timeout); - return status; -} - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.h deleted file mode 100644 index 64074401b3e..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp.h +++ /dev/null @@ -1,438 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - - -#ifndef NE7SSHSFTP_H -#define NE7SSHSFTP_H - -#include "ne7ssh_channel.h" -#include "ne7ssh.h" - -#ifdef WIN32 -// 777 = 0x1ff -#ifndef __MINGW32__ -#define S_IRUSR 0x100 -#endif -#define S_IRGRP 0x020 -#define S_IROTH 0x004 -#ifndef __MINGW32__ -#define S_IWUSR 0x080 -#endif -#define S_IWGRP 0x010 -#define S_IWOTH 0x002 -#ifndef __MINGW32__ -#define S_IXUSR 0x040 -#endif -#define S_IXGRP 0x008 -#define S_IXOTH 0x001 -#define S_ISUID 0x800 -#define S_ISGID 0x400 -#define S_ISVTX 0x200 -#ifndef __MINGW32__ -#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) -#endif -#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) -#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) -#endif - -#define SSH2_FXP_INIT 1 -#define SSH2_FXP_VERSION 2 -#define SSH2_FXP_OPEN 3 -#define SSH2_FXP_CLOSE 4 -#define SSH2_FXP_READ 5 -#define SSH2_FXP_WRITE 6 -#define SSH2_FXP_LSTAT 7 -#define SSH2_FXP_FSTAT 8 -#define SSH2_FXP_SETSTAT 9 -#define SSH2_FXP_FSETSTAT 10 -#define SSH2_FXP_OPENDIR 11 -#define SSH2_FXP_READDIR 12 -#define SSH2_FXP_REMOVE 13 -#define SSH2_FXP_MKDIR 14 -#define SSH2_FXP_RMDIR 15 -#define SSH2_FXP_REALPATH 16 -#define SSH2_FXP_STAT 17 -#define SSH2_FXP_RENAME 18 -#define SSH2_FXP_READLINK 19 -#define SSH2_FXP_LINK 21 -#define SSH2_FXP_BLOCK 22 -#define SSH2_FXP_UNBLOCK 23 - -#define SSH2_FXP_STATUS 101 -#define SSH2_FXP_HANDLE 102 -#define SSH2_FXP_DATA 103 -#define SSH2_FXP_NAME 104 -#define SSH2_FXP_ATTRS 105 - -#define SSH2_FXP_EXTENDED 200 -#define SSH2_FXP_EXTENDED_REPLY 201 - -#define SFTP_VERSION 3 -#define SFTP_MAX_SEQUENCE 4294967295U -#define SFTP_MAX_PACKET_SIZE (32 * 1024) -#define SFTP_MAX_MSG_SIZE (256 * 1024) - -#define SSH2_FXF_READ 0x00000001 -#define SSH2_FXF_WRITE 0x00000002 -#define SSH2_FXF_APPEND 0x00000004 -#define SSH2_FXF_CREAT 0x00000008 -#define SSH2_FXF_TRUNC 0x00000010 -#define SSH2_FXF_EXCL 0x00000020 - -#define SSH2_FILEXFER_ATTR_SIZE 0x00000001 -#define SSH2_FILEXFER_ATTR_UIDGID 0x00000002 -#define SSH2_FILEXFER_ATTR_ACMODTIME 0x00000008 -#define SSH2_FILEXFER_ATTR_PERMISSIONS 0x00000004 - -class ne7ssh_session; -class ne7ssh_transport; - -/** - @author Andrew Useckas -*/ -class Ne7sshSftp : public ne7ssh_channel -{ - private: - ne7ssh_session* session; - uint32 timeout; - uint32 seq; - uint8 sftpCmd; - ne7ssh_string commBuffer; - Botan::SecureVector fileBuffer; - enum writeMode { READ, OVERWRITE, APPEND }; - uint8 lastError; - char* currentPath; - - /** - * Structure used to store rmote file attributes. - */ - typedef struct - { - uint32 flags; - uint64 size; - uint32 owner; - uint32 group; - uint32 permissions; - uint32 atime; - uint32 mtime; - } sftpFileAttrs; - - sftpFileAttrs attrs; - - /** - * Structure used to store open rmote file. - */ - typedef struct - { - uint32 fileID; - uint16 handleLen; - char handle[256]; - } sftpFile; - sftpFile **sftpFiles; - uint16 sftpFilesCount; - - /** - * Replacement for ne7ssh_channel handleData method. Processes SFTP specific packets. - * @param packet Reference to the newly received packet. - * @return True if data successfully processed. False on any error. - */ - bool handleData (Botan::SecureVector& packet); - - /** - * Processes the VERSION packet received from the server. - * @param packet VERSION packet. - * @return True if processing successful, otherwise false. - */ - bool handleVersion (Botan::SecureVector& packet); - - /** - * Processes the STATUS packet received from the server. - * @param packet STATUS packet. - * @return True if processing successful, otherwise false. - */ - bool handleStatus (Botan::SecureVector& packet); - - /** - * Method to add a new file to sftpFiles variable from the HANDLE packet. - * @param packet HANDLE packet. - * @return True if processing successful, otherwise false. - */ - bool addOpenHandle (Botan::SecureVector& packet); - - /** - * Method to process DATA packets. - * @param packet DATA packet. - * @return True if processing successful, otherwise false. - */ - bool handleSftpData (Botan::SecureVector& packet); - - /** - * Method to process NAME packets. - * @param packet NAME packet. - * @return True if processing successful, otherwise false. - */ - bool handleNames (Botan::SecureVector& packet); - - /** - * This method is used to get a pointer to currently open file stored in sftpFile structure. - * @param fileID File ID, received from fileOpen() method. - * @return Returns a pointer to sftpFile structyure containing opened file or directory. If file specified by fileID has not been opened, NULL is returned. - */ - sftpFile* getFileHandle (uint32 fileID); - - /** - * Receive packets until specific SFTP subsystem command is received. - * @param _cmd SFTP command to wait for. - * @param timeSec Timeout in seconds. - * @return True if the command specified has been received. Otherwise false. - */ - bool receiveUntil (short _cmd, uint32 timeSec = 0); - - /** - * Receive packets while SFTP subsystem commands received matches specified command. - * @param _cmd Command to receive. - * @param timeSec Timeout in seconds. - * @return True if all expected data received. Otherwise false. - */ - bool receiveWhile (short _cmd, uint32 timeSec = 0); - - /** - * Method to process ATTRS packet. - * @param packet ATTRS packet. - * @return True if processing successful, otherwise false. - */ - bool processAttrs (Botan::SecureVector& packet); - - /** - * Low level method to request file attributes. - * @param remoteFile Full or relative path to a remote file. - * @param followSymLinks If set to true symbolic links will be followed. That is the default behavior. If following symbolic links is undesired set to "false". - * @return True if the request succeeds. False on any error. - */ - bool getFileStats (const char* remoteFile, bool followSymLinks = true); - - /** - * Gets attributes of a remote file and dumps them into sfptFileAtts structure. - * @param attributes reference to sftpFileAttrs structure where the result will be stored. - * @param remoteFile Full or relative path to a remote file. - * @param followSymLinks If set to true symbolic links will be followed. That is the default behavior. If following symbolic links is undesired set to "false". - * @return True if the attributes successfully received. False on any error. - */ - bool getFileAttrs (sftpFileAttrs& attributes, Botan::SecureVector& remoteFile, bool followSymLinks = true); - - /** - * Works like getFileStats() method, except that it operates on a handle of already opened file instead of path. - * @param fileID File ID, returned by the openFile() method. - * @return True if the request succeeds. False on any error. - */ - bool getFStat (uint32 fileID); - - /** - * This methods returnes the size of an open file. - * @param fileID File ID, returned by the openFile() method. - * @return The size of the remote file. False on any error. - */ - uint64 getFileSize (uint32 fileID); - - /** - * This method is used to wait for an ADJUST_WINDOW packet, when the send window size is zero. - * @return True if the ADJUST_WINDOW packet has been received, otherwise false. - */ - bool receiveWindowAdjust (); - - /** - * Returns full path to a file or directory. - * @param filename Relative path to a remote file or directory. - * @return ne7ssh_string class containing full path to the remote file or directory. The class will contain an empty string on error. - */ - ne7ssh_string getFullPath (const char* filename); - - /** - * Determines the type of a remote file. - * @param remoteFile Relative or full path to the remote file. - * @param type Type, taken from sys/stat.h. - * @return True if file is of specified type. Otherwise false. - */ - bool isType (const char* remoteFile, uint32 type); - - public: - /** - * Constructor. - * @param _session Pointer to connections session data. - * @param _channel Pointer to the ne7ssh_channel instance, taken from the new ne7ssh_connection instance. - */ - Ne7sshSftp(ne7ssh_session* _session, ne7ssh_channel* _channel); - - /** - * Default destructor. - */ - ~Ne7sshSftp(); - - /** - * Initializes SFTP subsystem. - * @return True if the subsystem successfully initialized. False on any error. - */ - bool init(); - - /** - * This method is used to set a timeout for all SFTP subsystem communications. - * @param _timeout Timeout in seconds. - */ - void setTimeout (uint32 _timeout) { timeout = _timeout; } - - /** - * Low level method used to open a remote file. - * @param filename Relative or full path to the file. - * @param shortMode Mode to be used when opening the file. Can be one of the modes defined by writeMode class variable. - * @return Newly opened file ID or 0 if file could not be opened. - */ - uint32 openFile (const char* filename, uint8 shortMode); - - /** - * Low level method used to open an inode containing file entries a.k.a directory. - * @param dirname Relative or full path to the inode. - * @return Newly opened file ID or 0 if the inode could not be opened. - */ - uint32 openDir (const char* dirname); - - /** - * Low level method used to read datablock up to the size of SFTP_MAX_MSG_SIZE from a file. - * @param fileID File ID retruned by openFile() method. - * @param offset Offset. 0 by default. - * @return True if file content successfully read and placed in the buffer. Otherwise false. - */ - bool readFile (uint32 fileID, uint64 offset = 0); - - /** - * Low level method used to write data-block up to the size of SFTP_MAX_MSG_SIZE to a remote file. - * @param fileID File ID returned by openFile() method. - * @param data Pointer to a buffer containing the data. - * @param len Length of the block. - * @param offset Offset in the remote file. If offset is passed EOF the space between EOF and offset will be filled by 0x0. Variable is set to 0 by default. - * @return True if file contect successfully written. False on any error. - */ - bool writeFile (uint32 fileID, const uint8* data, uint32 len, uint64 offset = 0); - - /** - * Low level method used to close a file opened using openFile() method. - * @param fileID File ID returned by openFile() method. - * @return True on success. False on any error. - */ - bool closeFile (uint32 fileID); - - /** - * This method is used to retrieve remote file attributes and place them into fileAttrs structure. - * @param attributes Reference to fileAttrs structure where retrieved attributes should be placed. - * @param remoteFile Name of the remote file. - * @param followSymLinks If this variable is set to true, symbolic links will be followed. That is the default befavour. If this behavour is undesired, pass "false". - * @return True if the attributes successfully retrieved. Otherwise false is returned. - */ - bool getFileAttrs (Ne7SftpSubsystem::fileAttrs& attributes, const char* remoteFile, bool followSymLinks = true); - - /** - * This method is used to determine if a remote inode is a regular file. - * @param remoteFile Full or relative path to the remote inode. - * @return True if the remote inode is a regular file. Otherwise false. - */ - bool isFile (const char* remoteFile); - - /** - * This method is used to determine if a remote inode is a directory. - * @param remoteFile Full or relative path to the remote file. - * @return True if the remote inode is a directory. Otherwise false. - */ - bool isDir (const char* remoteFile); - - - /** - * This method is used to retrieve a remote file and dump it into local file. - * @param remoteFile Full or relative path to the file on the remote side. - * @param localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function. - * @return True if getting the file is succeeds. False on any error. - */ - bool get (const char* remoteFile, FILE* localFile); - - /** - * This method is used to upload a file to a remote server. - * @param localFile Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function. - * @param remoteFile Full or relative path to the file on the remote side. - * @return True if putting the file succeeds. False on any error. - */ - bool put (FILE* localFile, const char* remoteFile); - - /** - * This method is used to remove a file on a remote server. - * @param remoteFile Full or relative path to the file on the remote side. - * @return True if remove succeeds. False on any error. - */ - bool rm (const char* remoteFile); - - /** - * This method is used to rename/move files. - * @param oldFile Full or relative path to an old file on the remote server. - * @param newFile Full or relative path to a new file on the remote side. - * @return True if renaming successfull. False on any error. - */ - bool mv (const char* oldFile, const char* newFile); - - /** - * This method is used to create a new directory. - * @param remoteDir Full or relative path to a new directory on the remote server. - * @return True if the directory successfully created. False on any error. - */ - bool mkdir (const char* remoteDir); - - /** - * This method is used to remove a remote directory. - * @param remoteDir Full or relative path to a directory to be removed. - * @return True if the directory successfully removed. False on any error. - */ - bool rmdir (const char* remoteDir); - - /** - * This methods is used retrieve a listing of a remote directory. - * @param remoteDir Full or relative path to a directory. - * @param longNames If set to "true" the returned string in addition to file strings will contain attributes for each file. - * @return A pointer to a string containing the directory listing. - */ - const char* ls (const char* remoteDir, bool longNames=false); - - /** - * This method is used to change the current working directory. - * @param remoteDir Full or relative path to the new working directory on the remote server. - * @return True if change of directory succedded. False on any error. - */ - bool cd (const char* remoteDir); - - /** - * This method is used for changing the permissions associated with a remote file. - * @param remoteFile Full or relative path to the remote file. - * @param mode Mode string. It can be wither a numerical mode expression such as "755" or an expression showing the modifications to be made, such as "ug+w". Mode string is the same as used by *nix chmod command. - * @return True if the new permissions are succesfully applied to the remote file. False on any error. - */ - bool chmod (const char* remoteFile, const char* mode); - - /** - * This method is used to change the owner of a remote file. - * @param remoteFile Full or relative path to the remote file. - * @param uid Numerical new owner user ID. - * @param gid Numerical new owner group ID. - * @return True if the change of ownership succeeds. False on any error. - */ - bool chown (const char* remoteFile, uint32 uid, uint32 gid = 0); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.cpp deleted file mode 100644 index e926fe57aa6..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_sftp_packet.h" -#include "ne7ssh.h" - -using namespace Botan; - -Ne7sshSftpPacket::Ne7sshSftpPacket () : ne7ssh_string(), channel(-1) -{ -} - -Ne7sshSftpPacket::Ne7sshSftpPacket (int _channel) : ne7ssh_string (), channel (_channel) -{ -} - -Ne7sshSftpPacket::Ne7sshSftpPacket (Botan::SecureVector& var, uint32 position) : ne7ssh_string (var, position), channel(-1) -{ -} - -Ne7sshSftpPacket::~Ne7sshSftpPacket() -{ -} - -Botan::SecureVector &Ne7sshSftpPacket::value () -{ - ne7ssh_string tmpVar; - - if (this->channel < 0) - { - buffer.destroy(); - return buffer; - } - - tmpVar.addChar (SSH2_MSG_CHANNEL_DATA); - tmpVar.addInt (channel); - tmpVar.addInt (sizeof(uint32) + buffer.size()); - tmpVar.addVectorField (buffer); - - buffer.swap (tmpVar.value()); - return buffer; -} - -Botan::SecureVector Ne7sshSftpPacket::valueFragment (uint32 len) -{ - ne7ssh_string tmpVar; - - if (this->channel < 0) - { - buffer.destroy(); - return Botan::SecureVector(); - } - - tmpVar.addChar (SSH2_MSG_CHANNEL_DATA); - tmpVar.addInt (channel); - if (len) - { - tmpVar.addInt (sizeof(uint32) + buffer.size()); - tmpVar.addInt (len); - tmpVar.addVector (buffer); - } - else tmpVar.addVectorField (buffer); - - return Botan::SecureVector (tmpVar.value()); -} - -void Ne7sshSftpPacket::addInt64 (const uint64 var) -{ - uint8 converter[8]; - - converter[0] = (uint8) (var >> 56); - converter[1] = (uint8) (var >> 48); - converter[2] = (uint8) (var >> 40); - converter[3] = (uint8) (var >> 32); - converter[4] = (uint8) (var >> 24); - converter[5] = (uint8) (var >> 16); - converter[6] = (uint8) (var >> 8); - converter[7] = (uint8) var; - - addBytes (converter, 8); -} - - -uint64 Ne7sshSftpPacket::getInt64 () -{ - SecureVector tmpVar (buffer); - uint64 result; - uint8 converter[8]; - memcpy (converter, tmpVar.begin(), 8); - - result = (uint64)converter[0] << 56; - result |= (uint64)converter[1] << 48; - result |= (uint64)converter[2] << 40; - result |= (uint64)converter[3] << 32; - result |= (uint64)converter[4] << 24; - result |= (uint64)converter[5] << 16; - result |= (uint64)converter[6] << 8; - result |= (uint64)converter[7]; - - buffer.set (tmpVar.begin() + sizeof(uint64), tmpVar.size() - sizeof(uint64)); - return result; -} - -bool Ne7sshSftpPacket::isChannelSet () -{ - if (this->channel == -1) return false; - else return true; -} - - - - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.h deleted file mode 100644 index ab7408e5bc1..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_sftp_packet.h +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSHSFTPPACKET_H -#define NE7SSHSFTPPACKET_H - -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -/** - @author Andrew Useckas -*/ -class Ne7sshSftpPacket : public ne7ssh_string -{ - private: - int channel; - - public: - /** - * Default constructor. - */ - - Ne7sshSftpPacket(); - /** - * Constructor. - * @param channel Channel ID, returned by connect methods. - */ - Ne7sshSftpPacket(int channel); - - /** - * Constructor. Intializes the class with packet data. - * @param var Reference to packet data. - * @param position Offset. - */ - Ne7sshSftpPacket(Botan::SecureVector& var, uint32 position); - - /** - * Default destructor. - */ - ~Ne7sshSftpPacket(); - - /** - * Returns buffer as a vector appending the SFTP subsystem specific packet headers. - * @return Reference to the buffer. - */ - Botan::SecureVector &value (); - - /** - * Returns buffer as a vector appending the SFTP subsystem specific packet headers, including the length in the first packet transmitted. Used in transmissions when it's necessary to split the message into multiple packets. - * @param len Length to append to the first packet in the message. - * @return Reference to SFTP packet or empty vector on error. - */ - Botan::SecureVector valueFragment (uint32 len = 0); - - /** - * Appends 64 bit integer to the packet buffer. - * @param var 64 bit integer. - */ - void addInt64 (const uint64 var); - - /** - * Retrieves a 64 bit integer from a packet buffer. - * @return Unsigned 64 bit integer. - */ - uint64 getInt64 (); - - /** - * Checks if the channel ID is set in the instance. Channel ID is needed to construct a SFTP packet. - * @return True if the channel ID is set. Otherwise false. - */ - bool isChannelSet (); - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_string.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_string.cpp deleted file mode 100644 index ef64f143206..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_string.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_string.h" -#include "ne7ssh.h" -#include -#if !defined(WIN32) && !defined(__MINGW32__) -# include -#endif - -using namespace Botan; - -ne7ssh_string::ne7ssh_string() : positions(0), parts(0) -{ -} - -ne7ssh_string::ne7ssh_string(Botan::SecureVector& var, uint32 position) : positions(0), parts(0) -{ - buffer.set ((var.begin() + position), (var.size() - position)); -} - -ne7ssh_string::ne7ssh_string(const char* var, uint32 position) : positions(0), parts(0) -{ - char null_char=0x0; - buffer.set ((Botan::byte*)(var + position), (u32bit) (strlen(var) - position)); - buffer.append ((Botan::byte*) &null_char, 1); -} - -ne7ssh_string::~ne7ssh_string() -{ - if (positions) - free (positions); -} - -void ne7ssh_string::addString (const char* str) -{ - Botan::byte* value = (Botan::byte*) str; - size_t len = strlen(str); - uint32 nLen = htonl((long) len); - - buffer.append ((Botan::byte*)&nLen, sizeof(uint32)); - buffer.append (value, (u32bit) len); -} - -bool ne7ssh_string::addFile (const char* filename) -{ - FILE *FI = fopen (filename, "rb"); - size_t size; - Botan::byte* data; - - if (!FI) - { - ne7ssh::errors()->push (-1, "Could not open key file: %s.", filename); - return false; - } - - fseek (FI, 0L, SEEK_END); - size = ftell (FI); - if(size > 0) { - rewind (FI); - - data = (Botan::byte*) malloc (size); - fread (data, size, 1, FI); - fclose (FI); - buffer.append (data, (u32bit) size); - free (data); - return true; - } - fclose(FI); - return false; -} - -void ne7ssh_string::addBigInt (const Botan::BigInt& bn) -{ - SecureVector converted; - bn2vector (converted, bn); - uint32 nLen = htonl (converted.size()); - - buffer.append ((Botan::byte*)&nLen, sizeof(uint32)); - buffer.append (converted); -} - -void ne7ssh_string::addVectorField (const Botan::SecureVector &vector) -{ - uint32 nLen = htonl (vector.size()); - - buffer.append ((Botan::byte*)&nLen, sizeof(uint32)); - buffer.append (vector); -} - - -void ne7ssh_string::addBytes (const Botan::byte* buff, uint32 len) -{ - buffer.append(buff, len); -} - -void ne7ssh_string::addVector (Botan::SecureVector &secvec) -{ - buffer.append(secvec.begin(), secvec.size()); -} - -void ne7ssh_string::addChar (const char ch) -{ - buffer.append((Botan::byte*)&ch, 1); -} - -void ne7ssh_string::addInt (const uint32 var) -{ - uint32 nVar = htonl (var); - - buffer.append((Botan::byte*)&nVar, sizeof(uint32)); -} - -bool ne7ssh_string::getString (Botan::SecureVector& result) -{ - SecureVector tmpVar (buffer); - uint32 len; - - len = ntohl (*((uint32*)tmpVar.begin())); - if (len > tmpVar.size()) return false; - - result.set (tmpVar.begin() + sizeof(uint32), len); - buffer.set (tmpVar.begin() + sizeof(uint32) + len, tmpVar.size() - sizeof(uint32) - len); - return true; -} - -bool ne7ssh_string::getBigInt (Botan::BigInt& result) -{ - SecureVector tmpVar (buffer); - uint32 len; - - len = ntohl (*((uint32*)tmpVar.begin())); - if (len > tmpVar.size()) return false; - - BigInt tmpBI (tmpVar.begin() + sizeof(uint32), len); - result.swap (tmpBI); - buffer.set (tmpVar.begin() + sizeof(uint32) + len, tmpVar.size() - sizeof(uint32) - len); - return true; -} - -uint32 ne7ssh_string::getInt () -{ - SecureVector tmpVar (buffer); - uint32 result; - - result = ntohl (*((uint32*)tmpVar.begin())); - buffer.set (tmpVar.begin() + sizeof(uint32), tmpVar.size() - sizeof(uint32)); - return result; -} - -Botan::byte ne7ssh_string::getByte () -{ - SecureVector tmpVar (buffer); - Botan::byte result; - - result = *(tmpVar.begin()); - buffer.set (tmpVar.begin() + 1, tmpVar.size() - 1); - return result; -} - - -void ne7ssh_string::split (const char token) -{ - Botan::byte* _buffer = buffer.begin(); - uint32 len = buffer.size(); - uint32 i; - - if (positions) return; - positions = (Botan::byte**) malloc (sizeof(Botan::byte*) * (parts + 1)); - positions[parts] = _buffer; - parts++; - - for (i = 0; i < len; i++) - { - if (_buffer[i] == token) - { - _buffer[i] = '\0'; - positions = (Botan::byte**) realloc (positions, sizeof(Botan::byte*) * (parts + 1)); - - positions[parts] = _buffer + i + 1; - parts++; - } - } -} - -char* ne7ssh_string::nextPart () -{ - char* result; - if (currentPart >= parts || !positions) return 0; - - result = (char*) positions[currentPart]; - currentPart++; - - return result; -} - -void ne7ssh_string::chop (uint32 nBytes) -{ - SecureVector tmpVar (buffer); - buffer.set (tmpVar.begin(), tmpVar.size() - nBytes); -} - - -void ne7ssh_string::bn2vector (Botan::SecureVector& result, const Botan::BigInt& bi) -{ - int high; - Botan::byte zero = '\0'; - - SecureVector strVector = BigInt::encode (bi); - - high = (*(strVector.begin()) & 0x80) ? 1 : 0; - - if (high) result.set (&zero, 1); - else result.clear(); - result.append (strVector); -} diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_string.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_string.h deleted file mode 100644 index 1829fb48682..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_string.h +++ /dev/null @@ -1,196 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_STRING_H -#define NE7SSH_STRING_H - -#include "ne7ssh_types.h" -#include - -/** -@author Andrew Useckas -*/ -class ne7ssh_string -{ -private: - Botan::byte **positions; - uint32 parts; - uint32 currentPart; - -protected: - Botan::SecureVector buffer; - -public: - /** - * ne7ssh_string class default consturctor. - *

Zeros out 'positions' and 'parts'. - */ - ne7ssh_string(); - - /** - * ne7ssh_string class consturctor. - *

Takes a vector as an argument and places the data into 'buffer'. - * @param var Reference to a vector containing a string. - * @param position Position in the vector to start reading from. If '0', the entire vector is dumped into 'buffer'. - */ - ne7ssh_string(Botan::SecureVector& var, uint32 position); - - /** - * Same as above costructor, but instead of vector it works with a string (const char*). - * @param var Pointer to a string terminated by '/0'. - * @param position Read from this position onwards. - */ - ne7ssh_string(const char* var, uint32 position); - - /** - * ne7ssh_string class destructor. - */ - virtual ~ne7ssh_string(); - - /** - * Zeros out the buffer - */ - void clear() { buffer.destroy(); } - - /** - * Adds a string to the buffer. - *

Adds an integer representing the length of the string, converted to the network format, before the actual string data. - * Required by SSH protocol specifications. - * @param str pointer to a string. - */ - void addString (const char* str); - - /** - * Reads content of an ASCII file and appends it to the buffer. - * @param filename Full path to ASCII file. - * @return True is file is successfully read. Otherwise False is returned. - */ - bool addFile (const char* filename); - - /** - * Adds a byte stream to the buffer. - * @param buff Pointer to the byte stream. - * @param len Length of the byte stream. - */ - void addBytes (const Botan::byte* buff, uint32 len); - - /** - * Adds a vector to the buffer. - * @param secvec Reference to the vector. - */ - void addVector (Botan::SecureVector& secvec); - - /** - * Adds a vector to the buffer. - *

Adds an integer representing the length of the vector, converted to the network format, before the actual data. - * Required by SSH protocol specifications. - * @param vector Reference to a vector. - */ - void addVectorField (const Botan::SecureVector& vector); - - /** - * Adds a single character to the buffer. - * @param ch a single character. - */ - void addChar (const char ch); - - /** - * Adds a single integer to the buffer. - *

Integer is converted to network format as required by SSH protocol specifications. - * @param var a single integer. - */ - void addInt (const uint32 var); - - /** - * Adds a BigInt variable to the buffer. - *

BigInt is first converted to a vector, then the integer, representing length of the vector is converted to the network format. - * Converted ingeger is added to the buffer, followed by the vector. - * @param bn Reference to BigInt variable. - */ - void addBigInt (const Botan::BigInt& bn); - - /** - * Returns the buffer as a vector. - * @return Reference to the 'buffer' vector. - */ - virtual Botan::SecureVector &value () { return buffer; } - - /** - * Returns current length of the buffer. - * @return Length of the buffer. - */ - uint32 length () { return buffer.size(); } - - /** - * Extracts a single string from the payload field of SSH packet. - * @param result Reference to a buffer where the result will be stored. - * @return True if string field was found and successfully parsed, otherwise false is returned. - */ - bool getString (Botan::SecureVector& result); - - /** - * Extracts a single BigInt variable from the payload field of SSH packet. - * @param result Reference to a BigInt variable where the result will be stored. - * @return True if BigInt field was found and successfully parsed, otherwise false is returned. - */ - bool getBigInt (Botan::BigInt& result); - - /** - * Extracts a single unsigned integer (uint32) from the payload field of SSH packet. - * @return The integer extracted from the next 4 bytes of the payload. - */ - uint32 getInt (); - - /** - * Extracts a single byte from tje payload field of SSH packet. - * @return A byte extracted from thenext byte of the payload. - */ - Botan::byte getByte (); - - /** - * Splits the buffer into strings separated by null character. - * @param token Searches for this character in the buffer, replaces it with null and creates a part index. - */ - void split (const char token); - - /** - * Returns to the first part. - */ - void resetParts () { currentPart = 0; } - - /** - * Returns the next part. - * @return NULL terminated string, or 0 if this is the last part. - */ - char* nextPart (); - - /** - * Chops bytes off of the end of the buffer. - * @param nBytes How many bytes to chop off the end of the buffer. - */ - void chop (uint32 nBytes); - - /** - * Converts BigInt into vector - *

For internal use only - * @param result Reference to vector where the converted result will be dumped. - * @param bi Reference to BigInt to convert. - */ - static void bn2vector (Botan::SecureVector& result, const Botan::BigInt& bi); - -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.cpp b/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.cpp deleted file mode 100644 index 5ad1b0dc7c6..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#include "ne7ssh_transport.h" -#include "ne7ssh.h" -#include "ne7ssh_session.h" - -#if defined(WIN32) || defined(__MINGW32__) -# define SOCKET_BUFFER_TYPE char -# define close closesocket -# define SOCK_CAST (char *) -class WSockInitializer -{ -public: - WSockInitializer() - { - static WSADATA wsaData; - WSAStartup(MAKEWORD(2, 2), &wsaData); - } - ~WSockInitializer() - { - WSACleanup(); - } -} -; -WSockInitializer _wsock32_; -#else -# define SOCKET_BUFFER_TYPE void -# define SOCK_CAST (void *) -# include -# include -# include -#endif - -using namespace Botan; - -ne7ssh_transport::ne7ssh_transport(ne7ssh_session* _session) : seq(0), rSeq(0), session(_session), sock(-1) -{ -} - -ne7ssh_transport::~ne7ssh_transport() -{ - if (((long) sock) > -1) close (sock); -} - -SOCKET ne7ssh_transport::establish (const char *host, uint32 port, int timeout) -{ - sockaddr_in remoteAddr; - hostent *remoteHost; - - remoteHost = gethostbyname (host); - if (!remoteHost || remoteHost->h_length == 0) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Host: '%s' not found.", host); - return -1; - } - remoteAddr.sin_family = AF_INET; - remoteAddr.sin_addr.s_addr = *(long*) remoteHost->h_addr_list[0]; - remoteAddr.sin_port = htons (port); - - sock = socket (AF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Failure to bind to socket."); - return -1; - } - - if (timeout < 1) - { - if (connect (sock, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr))) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Unable to connect to remote server: '%s'.", host); - return -1; - } - - if (!NoBlock (sock, true)) return -1; - else return sock; - } - else - { - if (!NoBlock (sock, true)) - return -1; - - if (connect (sock, (struct sockaddr*) &remoteAddr, sizeof(remoteAddr)) == -1) - { - fd_set rfds; - struct timeval waitTime; - - waitTime.tv_sec = timeout; - waitTime.tv_usec = 0; - - FD_ZERO(&rfds); - FD_SET(sock, &rfds); - - int status; - status = select(sock+1, &rfds, NULL, NULL, &waitTime); - - if ( status == 0 ) - { - if ( ! FD_ISSET(sock, &rfds) ) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Couldn't connect to remote server : timeout"); - return -1; - } - } - if ( status < 0 ) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Couldn't connect to remote server during select"); - return -1; - } - } - return sock; - } -} - -bool ne7ssh_transport::NoBlock (SOCKET socket, bool on) -{ -#ifndef WIN32 - int options; - if ((options = fcntl ( socket, F_GETFL )) < 0) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Cannot read options of the socket: %i.", (int)socket); - return false; - } - - if ( on ) options = ( options | O_NONBLOCK ); - else options = ( options & ~O_NONBLOCK ); - fcntl (socket, F_SETFL, options); -#else - unsigned long options = 1; - if (ioctlsocket(socket, FIONBIO, &options)) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Cannot set asynch I/O on the socket: %i.", (int)socket); - return false; - } -#endif - return true; -} - -bool ne7ssh_transport::haveData () -{ - return wait (sock, 0, 0); -} - -bool ne7ssh_transport::wait (SOCKET socket, int rw, int timeout) -{ - int status; - fd_set rfds, wfds; - struct timeval waitTime; - - if (timeout > -1) - { - waitTime.tv_sec = timeout; - waitTime.tv_usec = 0; - } - - if (!rw) - { - FD_ZERO(&rfds); - FD_SET(socket, &rfds); - } - else - { - FD_ZERO(&wfds); - FD_SET(socket, &wfds); - } - - if (!rw) - { - if (timeout > -1) status = select(socket + 1, &rfds, NULL, NULL, &waitTime); - else status = select(socket + 1, &rfds, NULL, NULL, NULL); - } - else status = select(socket + 1, NULL, &wfds, NULL, NULL); - - if (status > 0) - return true; - else - return false; -} - - -bool ne7ssh_transport::send (Botan::SecureVector& buffer) -{ - long byteCount; - uint32 sent = 0; - - if (buffer.size() > MAX_PACKET_LEN) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Cannot send. Packet too large for the transport layer."); - return false; - } - - while (sent < buffer.size()) - { - if (wait(sock, 1)) - byteCount = ::send(sock, (const SOCKET_BUFFER_TYPE *) (buffer.begin() + sent), buffer.size() - sent, 0); - else return false; - if (byteCount < 0) - return false; - sent += byteCount; - } - - return true; -} - -bool ne7ssh_transport::receive (Botan::SecureVector& buffer, bool append) -{ - Botan::byte in_buffer[MAX_PACKET_LEN]; - int len; - - if (wait(sock, 0)) - len = ::recv (sock, (char*) in_buffer, MAX_PACKET_LEN, 0); - - if (!len) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Received a packet of zero length."); - return false; - } - - if (len > MAX_PACKET_LEN) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Received packet exceeds the maximum size"); - return false; - } - - if (len < 0) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Connection dropped"); - return false; - } - - if (append) buffer.append (in_buffer, len); - else - { - buffer.clear(); - buffer.set (in_buffer, len); - } - - return true; -} - -bool ne7ssh_transport::sendPacket (Botan::SecureVector &buffer) -{ - ne7ssh_crypt *_crypto = session->crypto; - ne7ssh_string out; - uint32 crypt_block; - char padLen; - uint32 packetLen; - Botan::byte *padBytes; - uint32 length; - SecureVector crypted, hmac; - -// No Zlib support right now -// if (_crypto->isInited()) _crypto->compressData (buffer); - length = buffer.size(); - - crypt_block = _crypto->getEncryptBlock(); - if (!crypt_block) crypt_block = 8; - - padLen = 3 + crypt_block - ((length + 8) % crypt_block); - packetLen = 1 + length + padLen; - - out.addInt (packetLen); - out.addChar (padLen); - out.addVector (buffer); - - padBytes = (Botan::byte*) malloc (padLen); - memset (padBytes, 0x00, padLen); - out.addBytes (padBytes, padLen); - free (padBytes); - - if (_crypto->isInited()) - { - if (!_crypto->encryptPacket (crypted, hmac, out.value(), seq)) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Failure to encrypt the payload."); - return false; - } - crypted.append (hmac); - if (!send (crypted)) return false; - } - else if (!send (out.value())) return false; - if (seq == MAX_SEQUENCE) seq = 0; - else seq++; - return true; -} - -short ne7ssh_transport::waitForPacket (Botan::byte cmd, bool bufferOnly) -{ - ne7ssh_crypt *_crypto = session->crypto; - Botan::byte _cmd; - SecureVector tmpVar, decrypted, uncommpressed, ourMac, hMac; - uint32 len, cryptoLen; - bool havePacket = false; - -/* if (_crypto->isInited()) - { - if (!in.is_empty()) _crypto->decryptPacket (tmpVar, in, _crypto->getDecryptBlock(), seq); - else tmpVar.destroy(); - } - else*/ - tmpVar.set (in); - - if (!tmpVar.is_empty()) - { - if (_crypto->isInited()) - { - if (!in.is_empty()) _crypto->decryptPacket (tmpVar, in, _crypto->getDecryptBlock()); - else tmpVar.destroy(); - } - _cmd = *(tmpVar.begin() + 5); - - if (_cmd > 0 && _cmd < 0xff) havePacket = true; - } - - if (!havePacket) - { - if (bufferOnly) return 0; - if (!receive(in)) return -1; - - if (_crypto->isInited()) - { - if (!in.is_empty()) _crypto->decryptPacket (tmpVar, in, _crypto->getDecryptBlock()); - else tmpVar.destroy(); - } - else - { - while (in.size() < 4) - if (!receive(in, true)) return -1; - - cryptoLen = ntohl (*((int*)in.begin())) + sizeof(uint32); - while (in.size() < cryptoLen) - if (!receive(in, true)) return -1; - - tmpVar.set (in); - } - } - - len = ntohl (*((int*)tmpVar.begin())); - cryptoLen = len + sizeof(uint32); - - decrypted.set (tmpVar); - if (_crypto->isInited()) - { - while (((cryptoLen + _crypto->getMacInLen()) > in.size()) || (in.size() % _crypto->getDecryptBlock())) - { - if (!receive(in, true)) return 0; - } - if (cryptoLen > _crypto->getDecryptBlock()) - { - tmpVar.set (in.begin() + _crypto->getDecryptBlock(), (cryptoLen - _crypto->getDecryptBlock())); - if (!in.is_empty()) _crypto->decryptPacket (tmpVar, tmpVar, tmpVar.size()); - decrypted.append (tmpVar); - } - if (_crypto->getMacInLen()) - { - _crypto->computeMac (ourMac, decrypted, rSeq ); - hMac.set (in.begin() + cryptoLen, _crypto->getMacInLen()); - if (hMac != ourMac) - { - ne7ssh::errors()->push (((ne7ssh_session*)session)->getSshChannel(), "Mismatched HMACs."); - return -1; - } - cryptoLen += _crypto->getMacInLen(); - } - - -// No Zlib support right now -/* if (_crypto->isCompressed()) - { - tmpVar.set (decrypted.begin() + 5, len); - _crypto->decompressData (tmpVar); - uncommpressed.set (decrypted.begin(), 4); - uncommpressed.append (tmpVar); - decrypted.set (uncommpressed); - }*/ - } - - if (rSeq == MAX_SEQUENCE) rSeq = 0; - else rSeq++; - _cmd = *(decrypted.begin() + 5); - - if (cmd == _cmd || !cmd) - { - inBuffer.set (decrypted); - if (!(in.size() - cryptoLen)) in.destroy(); - else - { - tmpVar.swap (in); - in.set (tmpVar.begin() + cryptoLen, tmpVar.size() - cryptoLen); - } - return _cmd; - } - else return 0; - -} - -uint32 ne7ssh_transport::getPacket (Botan::SecureVector &result) -{ - ne7ssh_crypt *_crypto = session->crypto; - SecureVector tmpVector(inBuffer); - uint32 len = ntohl (*((uint32*)tmpVector.begin())); - Botan::byte padLen = *(tmpVector.begin() + 4); - uint32 macLen = _crypto->getMacInLen(); - - if (inBuffer.is_empty()) - { - result.clear(); - return 0; - } - - if (_crypto->isInited()) - { - len += macLen; - if (len > tmpVector.size()) len -= macLen; - } - - tmpVector.append ((uint8*)"\0", 1); - result.set (tmpVector.begin() + 5, len); - _crypto->decompressData (result); - - inBuffer.destroy(); - return padLen; -} - diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.h deleted file mode 100644 index 2cbc6ced271..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_transport.h +++ /dev/null @@ -1,136 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_TRANSPORT_H -#define NE7SSH_TRANSPORT_H - -#include "crypt.h" -#include "ne7ssh_types.h" -#include "ne7ssh_string.h" - -#if defined(WIN32) || defined(__MINGW32__) -# include -#endif -#include - -//#define MAX_PACKET_LEN 35000 -#define MAX_PACKET_LEN 34816 -#define MAX_SEQUENCE 4294967295U - -#if !defined(WIN32) && !defined(__MINGW32__) -# define SOCKET int -#endif - -class ne7ssh_session; - -/** -@author Andrew Useckas -*/ -class ne7ssh_transport -{ - private: - uint32 seq, rSeq; - const ne7ssh_session* session; - SOCKET sock; - Botan::SecureVector in; - Botan::SecureVector inBuffer; - - /** - * Switches socket's NonBlocking option on or off. - * @param socket Socket number. - * @param on If set to true, NonBlocking option will be turned on, and vice versa. - * @return True if options have been successfuly set, otherwise false is returned. - */ - bool NoBlock (SOCKET socket, bool on); - - /** - * Waits for activity on a socket. - * @param socket Socket number. - * @param rw If set to true, checks if process can write to the socket, otherwise checks if there is data to be read from the socket. - * @param timeout Desired timeout. By default the function will block until socket is ready for reading/writting. If set to '0', the function will return right away. - * @return True if socket is ready for reading/writting, otherwise false is returned. - */ - bool wait (SOCKET socket, int rw, int timeout = -1); - - public: - /** - * ne7ssh_transport class constructor. - *

Transport class handles all socket communications for the ne7ssh library. - * @param _session Pointer to ne7ssh_session instance. - */ - ne7ssh_transport(ne7ssh_session* _session); - - /** - * ne7ssh_transport class destructor. - */ - ~ne7ssh_transport(); - - /** - * Establishes connection to a remote host. - * @param host Host name or IP. - * @param port Port. - * @param timeout Timeout for the establish procedure, in seconds. - * @return Socket number or -1 on failure. - */ - SOCKET establish (const char *host, uint32 port, int timeout = 0); - - /** - * Reads data from the socket. - * @param buffer The data will be placed here. - * @param append If set to true, received data will be appended to the buffer, instead of overwriting it. - * @return True if data successfuly read, otherwise false is returned. - */ - bool receive (Botan::SecureVector& buffer, bool append = false); - - /** - * Writes a buffer to the socket. - * @param buffer Data to be written to the socket. - * @return True if data successful sent, otherwise false is returned. - */ - bool send (Botan::SecureVector& buffer); - - /** - * Assembles an SSH packet, as specified in SSH standards and passes the buffer to send() function. - * @param buffer Payload to be sent. - * @return True if send successful, otherwise false is returned. - */ - bool sendPacket (Botan::SecureVector& buffer); - - /** - * Waits until specified type of packet is received. - *

If cmd is 0, waits for the first available packet of any kind. - *

Once the desired packet is received, it is decrypted / decommpressed, the hMac is checked, and dropped into inBuffer class variable. - * @param cmd SSH2 packet to wait for. If 0, first available packet will be read into inBuffer class variable. - * @param bufferOnly Does not wait to receive a new packet, only checks existing receive buffer for unprocessed packets. - * @return 1 if desired packet is received, 0 if there another packet is received, or -1 if HMAC checking is enabled, and remote and local HMACs do not match. - */ - short waitForPacket (Botan::byte cmd, bool bufferOnly = false); - - /** - * Gets the payload section from an SSH packet received by waitForPacket() function. - * @param result The payload will be stored here. - * @return The SSH packet passing length. - */ - uint32 getPacket (Botan::SecureVector& result); - - /** - * Checks to see if there is more data to be read from the socket. - * @return True if there is data to be read, otherwise false is returned. - */ - bool haveData (); -}; - -#endif diff --git a/src/libs/3rdparty/net7ssh/src/ne7ssh_types.h b/src/libs/3rdparty/net7ssh/src/ne7ssh_types.h deleted file mode 100644 index 68af80c0047..00000000000 --- a/src/libs/3rdparty/net7ssh/src/ne7ssh_types.h +++ /dev/null @@ -1,95 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by NetSieben Technologies INC * - * Author: Andrew Useckas * - * Email: andrew@netsieben.com * - * * - * Windows Port and bugfixes: Keef Aragon * - * * - * This program may be distributed under the terms of the Q Public * - * License as defined by Trolltech AS of Norway and appearing in the * - * file LICENSE.QPL included in the packaging of this file. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - ***************************************************************************/ - -#ifndef NE7SSH_TYPES_H -#define NE7SSH_TYPES_H - -#if defined(WIN32) || defined(__MINGW32) - typedef int int32_t; - typedef long long int64_t; - typedef short int16_t; - typedef signed char int8_t; - - typedef unsigned int uint32_t; - typedef unsigned long long uint64_t; - typedef unsigned short uint16_t; - typedef unsigned char uint8_t; - -# if defined(_WINDLL) || defined(_USRDLL) || defined(_CONSOLE) || defined(_WINDOWS) -# ifdef NE7SSH_EXPORTS -# define SSH_EXPORT __declspec(dllexport) -# else -# define SSH_EXPORT __declspec(dllimport) -# endif -# else -# define SSH_EXPORT -# endif -#else -# include -# define SSH_EXPORT __attribute__ ((visibility("default"))) -#endif - -#ifndef int64_defined -#define int64_defined -typedef int64_t int64; -#endif - -#ifndef uint64_defined -#define uint64_defined -typedef uint64_t uint64; -#endif - -#ifndef int32_defined -#define int32_defined -typedef int32_t int32; -#endif - -#ifndef uint32_defined -#define uint32_defined -typedef uint32_t uint32; -#endif - -#ifndef int16_defined -#define int16_defined -typedef int16_t int16; -#endif - -#ifndef uint16_defined -#define uint16_defined -typedef uint16_t uint16; -#endif - -#ifndef int8_defined -#define int8_defined -typedef int8_t int8; -#endif - -#ifndef uint8_defined -#define uint8_defined -typedef uint8_t uint8; -#endif - -#ifndef Byte_defined -#define Byte_defined -typedef uint8_t Byte; -#endif - -#if defined(WIN32) || defined(__MINGW32__) -# define usleep(time) Sleep(time / 1000) -#endif - -#endif - diff --git a/src/libs/3rdparty/net7ssh/src/src.pro b/src/libs/3rdparty/net7ssh/src/src.pro deleted file mode 100644 index 1584dc722c0..00000000000 --- a/src/libs/3rdparty/net7ssh/src/src.pro +++ /dev/null @@ -1,54 +0,0 @@ -TEMPLATE = lib -TARGET = Net7ssh - -CONFIG += dll - -include(../../../../qtcreatorlibrary.pri) - -DEPENDPATH += . -INCLUDEPATH += $$PWD $$PWD/../../botan $$PWD/../../botan/build - -include(../net7ssh_dependencies.pri) - -win32 { - LIBS += -lWs2_32 - win32-msvc*: QMAKE_CXXFLAGS += -wd4100 -wd4101 -wd4250 -wd4251 -wd4290 - - DEFINES += _CRT_SECURE_NO_WARNINGS - DEFINES += NE7SSH_EXPORTS=1 _WINDLL _USRDLL _CONSOLE _WINDOWS -} - -unix { - QMAKE_CXXFLAGS_HIDESYMS -= -fvisibility-inlines-hidden # for ubuntu 7.04 - QMAKE_CXXFLAGS += -Wno-unused-parameter -} - -# Input -HEADERS += crypt.h \ - ne7ssh.h \ - ne7ssh_channel.h \ - ne7ssh_connection.h \ - ne7ssh_error.h \ - ne7ssh_kex.h \ - ne7ssh_keys.h \ - ne7ssh_mutex.h \ - ne7ssh_session.h \ - ne7ssh_sftp.h \ - ne7ssh_sftp_packet.h \ - ne7ssh_string.h \ - ne7ssh_transport.h \ - ne7ssh_types.h - -SOURCES += crypt.cpp \ - ne7ssh.cpp \ - ne7ssh_channel.cpp \ - ne7ssh_connection.cpp \ - ne7ssh_error.cpp \ - ne7ssh_kex.cpp \ - ne7ssh_keys.cpp \ - ne7ssh_mutex.cpp \ - ne7ssh_session.cpp \ - ne7ssh_sftp.cpp \ - ne7ssh_sftp_packet.cpp \ - ne7ssh_string.cpp \ - ne7ssh_transport.cpp diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 8e0107ed406..8c7e9bede3c 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -34,7 +34,6 @@ #include "modemanager.h" #include "fileiconprovider.h" #include "designmode.h" -#include "ssh/ne7sshobject.h" #include @@ -89,7 +88,6 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) m_designMode = new DesignMode(editorManager); addObject(m_designMode); - Ne7SshObject::instance(); } return success; } @@ -113,7 +111,6 @@ void CorePlugin::fileOpenRequest(const QString &f) void CorePlugin::aboutToShutdown() { m_mainWindow->aboutToShutdown(); - Ne7SshObject::removeInstance(); } Q_EXPORT_PLUGIN(CorePlugin) diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index 3b607d037b6..ad81f39dc6e 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -85,10 +85,27 @@ SOURCES += mainwindow.cpp \ editormanager/systemeditor.cpp \ designmode.cpp \ editortoolbar.cpp \ - ssh/ne7sshobject.cpp \ - ssh/sshconnection.cpp \ + helpmanager.cpp \ + ssh/sshsendfacility.cpp \ + ssh/sshremoteprocess.cpp \ + ssh/sshpacketparser.cpp \ + ssh/sshpacket.cpp \ + ssh/sshoutgoingpacket.cpp \ ssh/sshkeygenerator.cpp \ - helpmanager.cpp + ssh/sshkeyexchange.cpp \ + ssh/sshincomingpacket.cpp \ + ssh/sshcryptofacility.cpp \ + ssh/sshconnection.cpp \ + ssh/sshchannelmanager.cpp \ + ssh/sshchannel.cpp \ + ssh/sshcapabilities.cpp \ + ssh/sftppacket.cpp \ + ssh/sftpoutgoingpacket.cpp \ + ssh/sftpoperation.cpp \ + ssh/sftpincomingpacket.cpp \ + ssh/sftpdefs.cpp \ + ssh/sftpchannel.cpp \ + ssh/sshdelayedsignal.cpp HEADERS += mainwindow.h \ editmode.h \ @@ -171,10 +188,33 @@ HEADERS += mainwindow.h \ editormanager/systemeditor.h \ designmode.h \ editortoolbar.h \ - ssh/ne7sshobject.h \ - ssh/sshconnection.h \ + helpmanager.h \ + ssh/sshsendfacility_p.h \ + ssh/sshremoteprocess.h \ + ssh/sshremoteprocess_p.h \ + ssh/sshpacketparser_p.h \ + ssh/sshpacket_p.h \ + ssh/sshoutgoingpacket_p.h \ ssh/sshkeygenerator.h \ - helpmanager.h + ssh/sshkeyexchange_p.h \ + ssh/sshincomingpacket_p.h \ + ssh/sshexception_p.h \ + ssh/ssherrors.h \ + ssh/sshcryptofacility_p.h \ + ssh/sshconnection.h \ + ssh/sshconnection_p.h \ + ssh/sshchannelmanager_p.h \ + ssh/sshchannel_p.h \ + ssh/sshcapabilities_p.h \ + ssh/sshbotanconversions_p.h \ + ssh/sftppacket_p.h \ + ssh/sftpoutgoingpacket_p.h \ + ssh/sftpoperation_p.h \ + ssh/sftpincomingpacket_p.h \ + ssh/sftpdefs.h \ + ssh/sftpchannel.h \ + ssh/sftpchannel_p.h \ + ssh/sshdelayedsignal_p.h FORMS += dialogs/newdialog.ui \ actionmanager/commandmappings.ui \ diff --git a/src/plugins/coreplugin/coreplugin_dependencies.pri b/src/plugins/coreplugin/coreplugin_dependencies.pri index 8726e1be080..e908601b226 100644 --- a/src/plugins/coreplugin/coreplugin_dependencies.pri +++ b/src/plugins/coreplugin/coreplugin_dependencies.pri @@ -1,3 +1,3 @@ include(../../libs/extensionsystem/extensionsystem.pri) include(../../libs/utils/utils.pri) -include(../../libs/3rdparty/net7ssh/net7ssh.pri) +include(../../libs/3rdparty/botan/botan.pri) diff --git a/src/plugins/coreplugin/ssh/ne7sshobject.cpp b/src/plugins/coreplugin/ssh/ne7sshobject.cpp deleted file mode 100644 index 9f94a55b970..00000000000 --- a/src/plugins/coreplugin/ssh/ne7sshobject.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of Qt Creator. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "ne7sshobject.h" - -#include - -#include - -namespace Core { -namespace Internal { - -Ne7SshObject *Ne7SshObject::instance() -{ - if (!m_instance) - m_instance = new Ne7SshObject; - return m_instance; -} - -void Ne7SshObject::removeInstance() -{ - delete m_instance; -} - -Ne7SshObject::Ptr Ne7SshObject::get() -{ - QMutexLocker locker(&m_mutex); - QSharedPointer shared = m_weakRef.toStrongRef(); - if (!shared) { - shared = QSharedPointer(new ne7ssh); - m_weakRef = shared; - } - return shared; -} - -Ne7SshObject::Ne7SshObject() -{ -} - -Ne7SshObject *Ne7SshObject::m_instance = 0; - -} // namespace Internal -} // namespace Core diff --git a/src/plugins/coreplugin/ssh/ne7sshobject.h b/src/plugins/coreplugin/ssh/ne7sshobject.h deleted file mode 100644 index 77d601ec869..00000000000 --- a/src/plugins/coreplugin/ssh/ne7sshobject.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of Qt Creator. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef NE7SSHOBJECT_H -#define NE7SSHOBJECT_H - -#include - -#include -#include -#include - -class ne7ssh; - -namespace Core { -namespace Internal { - -class Ne7SshObject -{ -public: - typedef QSharedPointer Ptr; - - static Ne7SshObject *instance(); - static void removeInstance(); - - Ptr get(); - -private: - Ne7SshObject(); - Ne7SshObject(const Ne7SshObject &); - Ne7SshObject &operator=(const Ne7SshObject &); - - static Ne7SshObject *m_instance; - - QWeakPointer m_weakRef; - QMutex m_mutex; -}; - -} // namespace Internal -} // namespace Core - -#endif // NE7SSHOBJECT_H diff --git a/src/plugins/coreplugin/ssh/sftpchannel.cpp b/src/plugins/coreplugin/ssh/sftpchannel.cpp new file mode 100644 index 00000000000..2cb31a3bcec --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpchannel.cpp @@ -0,0 +1,756 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpchannel.h" +#include "sftpchannel_p.h" + +#include "sshdelayedsignal_p.h" +#include "sshexception_p.h" +#include "sshsendfacility_p.h" + +#include +#include + +namespace Core { + +namespace Internal { +namespace { + const quint32 ProtocolVersion = 3; + + QString errorMessage(const QString &serverMessage, + const QString &alternativeMessage) + { + return serverMessage.isEmpty() ? alternativeMessage : serverMessage; + } + + QString errorMessage(const SftpStatusResponse &response, + const QString &alternativeMessage) + { + return response.status == SSH_FX_OK ? QString() + : errorMessage(response.errorString, alternativeMessage); + } +} // anonymous namespace +} // namespace Internal + +SftpChannel::SftpChannel(quint32 channelId, + Internal::SshSendFacility &sendFacility) + : d(new Internal::SftpChannelPrivate(channelId, sendFacility, this)) +{ +} + +SftpChannel::State SftpChannel::state() const +{ + switch (d->channelState()) { + case Internal::AbstractSshChannel::Inactive: + return Uninitialized; + case Internal::AbstractSshChannel::SessionRequested: + return Initializing; + case Internal::AbstractSshChannel::CloseRequested: + return Closing; + case Internal::AbstractSshChannel::Closed: + return Closed; + case Internal::AbstractSshChannel::SessionEstablished: + return d->m_sftpState == Internal::SftpChannelPrivate::Initialized + ? Initialized : Initializing; + default: + Q_ASSERT(!"Oh no, we forgot to handle a channel state!"); + return Closed; // For the compiler. + } +} + +void SftpChannel::initialize() +{ + d->requestSessionStart(); + d->m_sftpState = Internal::SftpChannelPrivate::SubsystemRequested; +} + +void SftpChannel::closeChannel() +{ + d->closeChannel(); +} + +SftpJobId SftpChannel::listDirectory(const QString &path) +{ + return d->createJob(Internal::SftpListDir::Ptr( + new Internal::SftpListDir(++d->m_nextJobId, path))); +} + +SftpJobId SftpChannel::createDirectory(const QString &path) +{ + return d->createJob(Internal::SftpMakeDir::Ptr( + new Internal::SftpMakeDir(++d->m_nextJobId, path))); +} + +SftpJobId SftpChannel::removeDirectory(const QString &path) +{ + return d->createJob(Internal::SftpRmDir::Ptr( + new Internal::SftpRmDir(++d->m_nextJobId, path))); +} + +SftpJobId SftpChannel::removeFile(const QString &path) +{ + return d->createJob(Internal::SftpRm::Ptr( + new Internal::SftpRm(++d->m_nextJobId, path))); +} + +SftpJobId SftpChannel::renameFileOrDirectory(const QString &oldPath, + const QString &newPath) +{ + return d->createJob(Internal::SftpRename::Ptr( + new Internal::SftpRename(++d->m_nextJobId, oldPath, newPath))); +} + +SftpJobId SftpChannel::createFile(const QString &path, SftpOverwriteMode mode) +{ + return d->createJob(Internal::SftpCreateFile::Ptr( + new Internal::SftpCreateFile(++d->m_nextJobId, path, mode))); +} + +SftpJobId SftpChannel::uploadFile(const QString &localFilePath, + const QString &remoteFilePath, SftpOverwriteMode mode) +{ + QSharedPointer localFile(new QFile(localFilePath)); + if (!localFile->open(QIODevice::ReadOnly)) + return SftpInvalidJob; + return d->createJob(Internal::SftpUpload::Ptr( + new Internal::SftpUpload(++d->m_nextJobId, remoteFilePath, localFile, mode))); +} + +SftpJobId SftpChannel::downloadFile(const QString &remoteFilePath, + const QString &localFilePath, SftpOverwriteMode mode) +{ + QSharedPointer localFile(new QFile(localFilePath)); + if (mode == SftpSkipExisting && localFile->exists()) + return SftpInvalidJob; + QIODevice::OpenMode openMode = QIODevice::WriteOnly; + if (mode == SftpOverwriteExisting) + openMode |= QIODevice::Truncate; + else if (mode == SftpAppendToExisting) + openMode |= QIODevice::Append; + if (!localFile->open(openMode)) + return SftpInvalidJob; + return d->createJob(Internal::SftpDownload::Ptr( + new Internal::SftpDownload(++d->m_nextJobId, remoteFilePath, localFile))); +} + +SftpChannel::~SftpChannel() +{ + delete d; +} + + +namespace Internal { + +SftpChannelPrivate::SftpChannelPrivate(quint32 channelId, + SshSendFacility &sendFacility, SftpChannel *sftp) + : AbstractSshChannel(channelId, sendFacility), + m_nextJobId(0), m_sftpState(Inactive), m_sftp(sftp) +{ +} + +SftpJobId SftpChannelPrivate::createJob(const AbstractSftpOperation::Ptr &job) +{ + if (m_sftp->state() != SftpChannel::Initialized) + return SftpInvalidJob; + m_jobs.insert(job->jobId, job); + sendData(job->initialPacket(m_outgoingPacket).rawData()); + return job->jobId; +} + +void SftpChannelPrivate::handleChannelSuccess() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("sftp subsystem initialized"); +#endif + sendData(m_outgoingPacket.generateInit(ProtocolVersion).rawData()); + m_sftpState = InitSent; +} + +void SftpChannelPrivate::handleChannelFailure() +{ + if (m_sftpState != SubsystemRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_FAILURE packet."); + } + createDelayedInitFailedSignal(SSH_TR("Server could not start sftp subsystem.")); + closeChannel(); +} + +void SftpChannelPrivate::handleChannelDataInternal(const QByteArray &data) +{ + m_incomingData += data; + m_incomingPacket.consumeData(m_incomingData); + while (m_incomingPacket.isComplete()) { + handleCurrentPacket(); + m_incomingPacket.clear(); + m_incomingPacket.consumeData(m_incomingData); + } +} + +void SftpChannelPrivate::handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data) +{ + qWarning("Unexpected extended data '%s' of type %d on SFTP channel.", + data.data(), type); +} + +void SftpChannelPrivate::handleCurrentPacket() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("Handling SFTP packet of type %d", m_incomingPacket.type()); +#endif + switch (m_incomingPacket.type()) { + case SSH_FXP_VERSION: + handleServerVersion(); + break; + case SSH_FXP_HANDLE: + handleHandle(); + break; + case SSH_FXP_NAME: + handleName(); + break; + case SSH_FXP_STATUS: + handleStatus(); + break; + case SSH_FXP_DATA: + handleReadData(); + break; + case SSH_FXP_ATTRS: + handleAttrs(); + break; + default: + throw SshServerException(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected packet.", + SSH_TR("Unexpected packet of type %d.").arg(m_incomingPacket.type())); + } +} + +void SftpChannelPrivate::handleServerVersion() +{ + checkChannelActive(); + if (m_sftpState != InitSent) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_VERSION packet."); + } + +#ifdef CREATOR_SSH_DEBUG + qDebug("sftp init received"); +#endif + const quint32 serverVersion = m_incomingPacket.extractServerVersion(); + if (serverVersion != ProtocolVersion) { + createDelayedInitFailedSignal(SSH_TR("Protocol version mismatch: Expected %1, got %2") + .arg(serverVersion).arg(ProtocolVersion)); + closeChannel(); + } else { + m_sftpState = Initialized; + createDelayedInitializedSignal(); + } +} + +void SftpChannelPrivate::handleHandle() +{ + const SftpHandleResponse &response = m_incomingPacket.asHandleResponse(); + JobMap::Iterator it = lookupJob(response.requestId); + const QSharedPointer job + = it.value().dynamicCast(); + if (job.isNull()) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_HANDLE packet."); + } + if (job->state != AbstractSftpOperationWithHandle::OpenRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_HANDLE packet."); + } + job->remoteHandle = response.handle; + job->state = AbstractSftpOperationWithHandle::Open; + + switch (it.value()->type()) { + case AbstractSftpOperation::ListDir: + handleLsHandle(it); + break; + case AbstractSftpOperation::CreateFile: + handleCreateFileHandle(it); + break; + case AbstractSftpOperation::Download: + handleGetHandle(it); + break; + case AbstractSftpOperation::Upload: + handlePutHandle(it); + break; + default: + Q_ASSERT(!"Oh no, I forgot to handle an SFTP operation type!"); + } +} + +void SftpChannelPrivate::handleLsHandle(const JobMap::Iterator &it) +{ + SftpListDir::Ptr op = it.value().staticCast(); + sendData(m_outgoingPacket.generateReadDir(op->remoteHandle, + op->jobId).rawData()); +} + +void SftpChannelPrivate::handleCreateFileHandle(const JobMap::Iterator &it) +{ + SftpCreateFile::Ptr op = it.value().staticCast(); + sendData(m_outgoingPacket.generateCloseHandle(op->remoteHandle, + op->jobId).rawData()); +} + +void SftpChannelPrivate::handleGetHandle(const JobMap::Iterator &it) +{ + SftpDownload::Ptr op = it.value().staticCast(); + sendData(m_outgoingPacket.generateFstat(op->remoteHandle, + op->jobId).rawData()); + op->statRequested = true; +} + +void SftpChannelPrivate::handlePutHandle(const JobMap::Iterator &it) +{ + SftpUpload::Ptr op = it.value().staticCast(); + + // OpenSSH does not implement the RFC's append functionality, so we + // have to emulate it. + if (op->mode == SftpAppendToExisting) { + sendData(m_outgoingPacket.generateFstat(op->remoteHandle, + op->jobId).rawData()); + op->statRequested = true; + } else { + spawnWriteRequests(it); + } +} + +void SftpChannelPrivate::handleStatus() +{ + const SftpStatusResponse &response = m_incomingPacket.asStatusResponse(); +#ifdef CREATOR_SSH_DEBUG + qDebug("%s: status = %d", Q_FUNC_INFO, response.status); +#endif + JobMap::Iterator it = lookupJob(response.requestId); + switch (it.value()->type()) { + case AbstractSftpOperation::ListDir: + handleLsStatus(it, response); + break; + case AbstractSftpOperation::Download: + handleGetStatus(it, response); + break; + case AbstractSftpOperation::Upload: + handlePutStatus(it, response); + break; + case AbstractSftpOperation::MakeDir: + case AbstractSftpOperation::RmDir: + case AbstractSftpOperation::Rm: + case AbstractSftpOperation::Rename: + case AbstractSftpOperation::CreateFile: + handleStatusGeneric(it, response); + break; + } +} + +void SftpChannelPrivate::handleStatusGeneric(const JobMap::Iterator &it, + const SftpStatusResponse &response) +{ + AbstractSftpOperation::Ptr op = it.value(); + const QString error = errorMessage(response, SSH_TR("Unknown error.")); + createDelayedJobFinishedSignal(op->jobId, error); + m_jobs.erase(it); +} + +void SftpChannelPrivate::handleLsStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response) +{ + SftpListDir::Ptr op = it.value().staticCast(); + switch (op->state) { + case SftpListDir::OpenRequested: + createDelayedJobFinishedSignal(op->jobId, errorMessage(response.errorString, + SSH_TR("Remote directory could not be opened for reading."))); + m_jobs.erase(it); + break; + case SftpListDir::Open: + if (response.status != SSH_FX_EOF) + reportRequestError(op, errorMessage(response.errorString, + SSH_TR("Failed to list remote directory contents."))); + op->state = SftpListDir::CloseRequested; + sendData(m_outgoingPacket.generateCloseHandle(op->remoteHandle, + op->jobId).rawData()); + break; + case SftpListDir::CloseRequested: + if (!op->hasError) { + const QString error = errorMessage(response, + SSH_TR("Failed to close remote directory.")); + createDelayedJobFinishedSignal(op->jobId, error); + } + m_jobs.erase(it); + break; + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_STATUS packet."); + } +} + +void SftpChannelPrivate::handleGetStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response) +{ + SftpDownload::Ptr op = it.value().staticCast(); + switch (op->state) { + case SftpDownload::OpenRequested: + createDelayedJobFinishedSignal(op->jobId, + errorMessage(response.errorString, + SSH_TR("Failed to open remote file for reading."))); + m_jobs.erase(it); + break; + case SftpDownload::Open: + if (op->statRequested) { + reportRequestError(op, errorMessage(response.errorString, + SSH_TR("Failed to stat remote file."))); + sendTransferCloseHandle(op, response.requestId); + } else { + if ((response.status != SSH_FX_EOF || response.requestId != op->eofId) + && !op->hasError) + reportRequestError(op, errorMessage(response.errorString, + SSH_TR("Failed to read remote file."))); + finishTransferRequest(it); + } + break; + case SftpDownload::CloseRequested: + Q_ASSERT(op->inFlightCount == 1); + if (!op->hasError) { + if (response.status == SSH_FX_OK) + createDelayedJobFinishedSignal(op->jobId); + else + reportRequestError(op, errorMessage(response.errorString, + SSH_TR("Failed to close remote file."))); + } + removeTransferRequest(it); + break; + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_STATUS packet."); + } +} + +void SftpChannelPrivate::handlePutStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response) +{ + SftpUpload::Ptr job = it.value().staticCast(); + switch (job->state) { + case SftpUpload::OpenRequested: + createDelayedJobFinishedSignal(job->jobId, + errorMessage(response.errorString, + SSH_TR("Failed to open remote file for writing."))); + m_jobs.erase(it); + break; + case SftpUpload::Open: + if (response.status == SSH_FX_OK) { + sendWriteRequest(it); + } else if(!job->hasError) { + reportRequestError(job, errorMessage(response.errorString, + SSH_TR("Failed to write remote file."))); + finishTransferRequest(it); + } + break; + case SftpUpload::CloseRequested: + Q_ASSERT(job->inFlightCount == 1); + if (!job->hasError) { + const QString error = errorMessage(response, + SSH_TR("Failed to close remote file.")); + createDelayedJobFinishedSignal(job->jobId, error); + } + m_jobs.erase(it); + break; + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_STATUS packet."); + } +} + +void SftpChannelPrivate::handleName() +{ + const SftpNameResponse &response = m_incomingPacket.asNameResponse(); + JobMap::Iterator it = lookupJob(response.requestId); + switch (it.value()->type()) { + case AbstractSftpOperation::ListDir: { + SftpListDir::Ptr op = it.value().staticCast(); + if (op->state != SftpListDir::Open) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_NAME packet."); + } + + for (int i = 0; i < response.files.count(); ++i) { + const SftpFile &file = response.files.at(i); + createDelayedDataAvailableSignal(op->jobId, file.fileName); + } + sendData(m_outgoingPacket.generateReadDir(op->remoteHandle, + op->jobId).rawData()); + break; + } + default: + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_NAME packet."); + } +} + +void SftpChannelPrivate::handleReadData() +{ + const SftpDataResponse &response = m_incomingPacket.asDataResponse(); + JobMap::Iterator it = lookupJob(response.requestId); + if (it.value()->type() != AbstractSftpOperation::Download) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_DATA packet."); + } + + SftpDownload::Ptr op = it.value().staticCast(); + if (op->hasError) { + finishTransferRequest(it); + return; + } + + if (!op->localFile->seek(op->offsets[response.requestId])) { + reportRequestError(op, op->localFile->errorString()); + finishTransferRequest(it); + return; + } + + if (op->localFile->write(response.data) != response.data.size()) { + reportRequestError(op, op->localFile->errorString()); + finishTransferRequest(it); + return; + } + + if (op->offset >= op->fileSize && op->fileSize != 0) + finishTransferRequest(it); + else + sendReadRequest(op, response.requestId); +} + +void SftpChannelPrivate::handleAttrs() +{ + const SftpAttrsResponse &response = m_incomingPacket.asAttrsResponse(); + JobMap::Iterator it = lookupJob(response.requestId); + AbstractSftpTransfer::Ptr transfer + = it.value().dynamicCast(); + if (!transfer || transfer->state != AbstractSftpTransfer::Open + || !transfer->statRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_FXP_ATTRS packet."); + } + Q_ASSERT(transfer->type() == AbstractSftpOperation::Upload + || transfer->type() == AbstractSftpOperation::Download); + + if (transfer->type() == AbstractSftpOperation::Download) { + SftpDownload::Ptr op = transfer.staticCast(); + if (response.attrs.sizePresent) { + op->fileSize = response.attrs.size; + } else { + op->fileSize = 0; + op->eofId = op->jobId; + } + op->statRequested = false; + spawnReadRequests(op); + } else { + SftpUpload::Ptr op = transfer.staticCast(); + if (response.attrs.sizePresent) { + op->offset = response.attrs.size; + spawnWriteRequests(it); + } else { + reportRequestError(op, SSH_TR("Cannot append to remote file: " + "Server does not support file size attribute.")); + sendTransferCloseHandle(op, op->jobId); + } + } +} + +SftpChannelPrivate::JobMap::Iterator SftpChannelPrivate::lookupJob(SftpJobId id) +{ + JobMap::Iterator it = m_jobs.find(id); + if (it == m_jobs.end()) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid request id in SFTP packet."); + } + return it; +} + +void SftpChannelPrivate::closeHook() +{ + createClosedSignal(); +} + +void SftpChannelPrivate::handleOpenSuccessInternal() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("SFTP session started"); +#endif + m_sendFacility.sendSftpPacket(remoteChannel()); + m_sftpState = SubsystemRequested; +} + +void SftpChannelPrivate::handleOpenFailureInternal() +{ + if (channelState() != SessionRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_OPEN_FAILURE packet."); + } + createDelayedInitFailedSignal(SSH_TR("Server could not start session.")); +} + +void SftpChannelPrivate::sendReadRequest(const SftpDownload::Ptr &job, + quint32 requestId) +{ + Q_ASSERT(job->eofId == SftpInvalidJob); + sendData(m_outgoingPacket.generateReadFile(job->remoteHandle, job->offset, + AbstractSftpPacket::MaxDataSize, requestId).rawData()); + job->offsets[requestId] = job->offset; + job->offset += AbstractSftpPacket::MaxDataSize; + if (job->offset >= job->fileSize) + job->eofId = requestId; +} + +void SftpChannelPrivate::reportRequestError(const AbstractSftpOperationWithHandle::Ptr &job, + const QString &error) +{ + createDelayedJobFinishedSignal(job->jobId, error); + job->hasError = true; +} + +void SftpChannelPrivate::finishTransferRequest(const JobMap::Iterator &it) +{ + AbstractSftpTransfer::Ptr job = it.value().staticCast(); + if (job->inFlightCount == 1) + sendTransferCloseHandle(job, it.key()); + else + removeTransferRequest(it); +} + +void SftpChannelPrivate::sendTransferCloseHandle(const AbstractSftpTransfer::Ptr &job, + quint32 requestId) +{ + sendData(m_outgoingPacket.generateCloseHandle(job->remoteHandle, + requestId).rawData()); + job->state = SftpDownload::CloseRequested; +} + +void SftpChannelPrivate::removeTransferRequest(const JobMap::Iterator &it) +{ + --it.value().staticCast()->inFlightCount; + m_jobs.erase(it); +} + +void SftpChannelPrivate::sendWriteRequest(const JobMap::Iterator &it) +{ + SftpUpload::Ptr job = it.value().staticCast(); + QByteArray data = job->localFile->read(AbstractSftpPacket::MaxDataSize); + if (job->localFile->error() != QFile::NoError) { + if (!job->hasError) { + reportRequestError(job, SSH_TR("Error reading local file: %1") + .arg(job->localFile->errorString())); + } + finishTransferRequest(it); + } else if (data.isEmpty()) { + finishTransferRequest(it); + } else { + sendData(m_outgoingPacket.generateWriteFile(job->remoteHandle, + job->offset, data, it.key()).rawData()); + job->offset += AbstractSftpPacket::MaxDataSize; + } +} + +void SftpChannelPrivate::spawnWriteRequests(const JobMap::Iterator &it) +{ + SftpUpload::Ptr op = it.value().staticCast(); + op->calculateInFlightCount(AbstractSftpPacket::MaxDataSize); + sendWriteRequest(it); + for (int i = 1; i < op->inFlightCount; ++i) + sendWriteRequest(m_jobs.insert(++m_nextJobId, op)); +} + +void SftpChannelPrivate::spawnReadRequests(const SftpDownload::Ptr &job) +{ + job->calculateInFlightCount(AbstractSftpPacket::MaxDataSize); + sendReadRequest(job, job->jobId); + for (int i = 1; i < job->inFlightCount; ++i) { + const quint32 requestId = ++m_nextJobId; + m_jobs.insert(requestId, job); + sendReadRequest(job, requestId); + } +} + +void SftpChannelPrivate::createDelayedInitFailedSignal(const QString &reason) +{ + new SftpInitializationFailedSignal(this, QWeakPointer(m_sftp), + reason); +} + +void SftpChannelPrivate::emitInitializationFailedSignal(const QString &reason) +{ + emit m_sftp->initializationFailed(reason); +} + +void SftpChannelPrivate::createDelayedInitializedSignal() +{ + new SftpInitializedSignal(this, QWeakPointer(m_sftp)); +} + +void SftpChannelPrivate::emitInitialized() +{ + emit m_sftp->initialized(); +} + +void SftpChannelPrivate::createDelayedJobFinishedSignal(SftpJobId jobId, + const QString &error) +{ + new SftpJobFinishedSignal(this, QWeakPointer(m_sftp), jobId, error); +} + +void SftpChannelPrivate::emitJobFinished(SftpJobId jobId, const QString &error) +{ + emit m_sftp->finished(jobId, error); +} + +void SftpChannelPrivate::createDelayedDataAvailableSignal(SftpJobId jobId, + const QString &data) +{ + new SftpDataAvailableSignal(this, QWeakPointer(m_sftp), jobId, data); +} + +void SftpChannelPrivate::emitDataAvailable(SftpJobId jobId, const QString &data) +{ + emit m_sftp->dataAvailable(jobId, data); +} + +void SftpChannelPrivate::createClosedSignal() +{ + new SftpClosedSignal(this, QWeakPointer(m_sftp)); +} + +void SftpChannelPrivate::emitClosed() +{ + emit m_sftp->closed(); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftpchannel.h b/src/plugins/coreplugin/ssh/sftpchannel.h new file mode 100644 index 00000000000..6b4ffea7e50 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpchannel.h @@ -0,0 +1,120 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTCHANNEL_H +#define SFTCHANNEL_H + +#include "sftpdefs.h" +#include "sftpincomingpacket_p.h" + +#include + +#include +#include +#include +#include + +namespace Core { + +namespace Internal { +class SftpChannelPrivate; +class SshChannelManager; +class SshSendFacility; +} // namespace Internal + +/* + * This class provides SFTP operations. + * Objects are created via SshConnection::createSftpChannel(). + * The channel needs to be initialized with + * a call to initialize() and is closed via closeChannel(). After closing + * a channel, no more operations are possible. It cannot be re-opened + * using initialize(); use SshConnection::createSftpChannel() if you need + * a new one. + * After the initialized() signal has been emitted, operations can be started. + * All SFTP operations are asynchronous (non-blocking) and can be in-flight + * simultaneously (though callers must ensure that concurrently running jobs + * are independent of each other, e.g. they must not write to the same file). + * Operations are identified by their job id, which is returned by + * the respective member function. If the function can right away detect that + * the operation cannot succeed, it returns SftpInvalidJob. If an error occurs + * later, the finishedWithError() signal is emitted for the respective job. + * Note that directory names must not have a trailing slash. + */ +class CORE_EXPORT SftpChannel : public QObject +{ + Q_OBJECT + + friend class Internal::SftpChannelPrivate; + friend class Internal::SshChannelManager; +public: + typedef QSharedPointer Ptr; + + enum State { Uninitialized, Initializing, Initialized, Closing, Closed }; + State state() const; + + void initialize(); + void closeChannel(); + + SftpJobId listDirectory(const QString &dirPath); + SftpJobId createDirectory(const QString &dirPath); + SftpJobId removeDirectory(const QString &dirPath); + SftpJobId removeFile(const QString &filePath); + SftpJobId renameFileOrDirectory(const QString &oldPath, + const QString &newPath); + SftpJobId createFile(const QString &filePath, SftpOverwriteMode mode); + SftpJobId uploadFile(const QString &localFilePath, + const QString &remoteFilePath, SftpOverwriteMode mode); + SftpJobId downloadFile(const QString &remoteFilePath, + const QString &localFilePath, SftpOverwriteMode mode); + + ~SftpChannel(); + +signals: + void initialized(); + void initializationFailed(const QString &reason); + void closed(); + + // error.isEmpty <=> finished successfully + void finished(Core::SftpJobId job, const QString &error = QString()); + + /* + * This signal is only emitted by the "List Directory" operation, + * one file at a time. + */ + void dataAvailable(SftpJobId job, const QString &data); + +private: + SftpChannel(quint32 channelId, Internal::SshSendFacility &sendFacility); + + Internal::SftpChannelPrivate *d; +}; + +} // namespace Core + +#endif // SFTPCHANNEL_H diff --git a/src/plugins/coreplugin/ssh/sftpchannel_p.h b/src/plugins/coreplugin/ssh/sftpchannel_p.h new file mode 100644 index 00000000000..8d27a2c01dc --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpchannel_p.h @@ -0,0 +1,130 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTCHANNEL_P_H +#define SFTCHANNEL_P_H + +#include "sftpdefs.h" +#include "sftpincomingpacket_p.h" +#include "sftpoperation_p.h" +#include "sftpoutgoingpacket_p.h" +#include "sshchannel_p.h" + +#include +#include + +namespace Core { +class SftpChannel; +namespace Internal { + +class SftpChannelPrivate : public AbstractSshChannel +{ + friend class Core::SftpChannel; +public: + + enum SftpState { Inactive, SubsystemRequested, InitSent, Initialized }; + + virtual void handleChannelSuccess(); + virtual void handleChannelFailure(); + + virtual void closeHook(); + + void emitInitializationFailedSignal(const QString &reason); + void emitInitialized(); + void emitJobFinished(SftpJobId jobId, const QString &error); + void emitDataAvailable(SftpJobId jobId, const QString &data); + void emitClosed(); + +private: + typedef QMap JobMap; + + SftpChannelPrivate(quint32 channelId, SshSendFacility &sendFacility, + SftpChannel *sftp); + SftpJobId createJob(const AbstractSftpOperation::Ptr &job); + + virtual void handleOpenSuccessInternal(); + virtual void handleOpenFailureInternal(); + virtual void handleChannelDataInternal(const QByteArray &data); + virtual void handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data); + + void handleCurrentPacket(); + void handleServerVersion(); + void handleHandle(); + void handleStatus(); + void handleName(); + void handleReadData(); + void handleAttrs(); + + void handleStatusGeneric(const JobMap::Iterator &it, + const SftpStatusResponse &response); + void handleLsStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response); + void handleGetStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response); + void handlePutStatus(const JobMap::Iterator &it, + const SftpStatusResponse &response); + + void handleLsHandle(const JobMap::Iterator &it); + void handleCreateFileHandle(const JobMap::Iterator &it); + void handleGetHandle(const JobMap::Iterator &it); + void handlePutHandle(const JobMap::Iterator &it); + + void spawnReadRequests(const SftpDownload::Ptr &job); + void spawnWriteRequests(const JobMap::Iterator &it); + void sendReadRequest(const SftpDownload::Ptr &job, quint32 requestId); + void sendWriteRequest(const JobMap::Iterator &it); + void finishTransferRequest(const JobMap::Iterator &it); + void removeTransferRequest(const JobMap::Iterator &it); + void reportRequestError(const AbstractSftpOperationWithHandle::Ptr &job, + const QString &error); + void sendTransferCloseHandle(const AbstractSftpTransfer::Ptr &job, + quint32 requestId); + + void createDelayedInitFailedSignal(const QString &reason); + void createDelayedInitializedSignal(); + void createDelayedJobFinishedSignal(SftpJobId jobId, + const QString &error = QString()); + void createDelayedDataAvailableSignal(SftpJobId jobId, const QString &data); + void createClosedSignal(); + + JobMap::Iterator lookupJob(SftpJobId id); + JobMap m_jobs; + SftpOutgoingPacket m_outgoingPacket; + SftpIncomingPacket m_incomingPacket; + QByteArray m_incomingData; + SftpJobId m_nextJobId; + SftpState m_sftpState; + SftpChannel *m_sftp; +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPCHANNEL_P_H diff --git a/src/plugins/coreplugin/ssh/sftpdefs.cpp b/src/plugins/coreplugin/ssh/sftpdefs.cpp new file mode 100644 index 00000000000..6a2f6de45e1 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpdefs.cpp @@ -0,0 +1,32 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpdefs.h" + +namespace Core { const SftpJobId SftpInvalidJob = 0; } diff --git a/src/plugins/coreplugin/ssh/sftpdefs.h b/src/plugins/coreplugin/ssh/sftpdefs.h new file mode 100644 index 00000000000..5f59582a055 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpdefs.h @@ -0,0 +1,48 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPDEFS_H +#define SFTPDEFS_H + +#include + +#include + +namespace Core { + +typedef quint32 SftpJobId; +CORE_EXPORT extern const SftpJobId SftpInvalidJob; + +enum SftpOverwriteMode { + SftpOverwriteExisting, SftpAppendToExisting, SftpSkipExisting +}; + +} // namespace Core + +#endif // SFTPDEFS_H diff --git a/src/plugins/coreplugin/ssh/sftpincomingpacket.cpp b/src/plugins/coreplugin/ssh/sftpincomingpacket.cpp new file mode 100644 index 00000000000..804bdb21d5c --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpincomingpacket.cpp @@ -0,0 +1,230 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpincomingpacket_p.h" + +#include "sshexception_p.h" +#include "sshpacketparser_p.h" + +namespace Core { +namespace Internal { + +namespace { + const int SSH_FILEXFER_ATTR_SIZE = 0x00000001; + const int SSH_FILEXFER_ATTR_UIDGID = 0x00000002; + const int SSH_FILEXFER_ATTR_PERMISSIONS = 0x00000004; + const int SSH_FILEXFER_ATTR_ACMODTIME = 0x00000008; + const int SSH_FILEXFER_ATTR_EXTENDED = 0x80000000; +} // anonymous namespace + +SftpIncomingPacket::SftpIncomingPacket() : m_length(0) +{ +} + +void SftpIncomingPacket::consumeData(QByteArray &newData) +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("%s: current data size = %d, new data size = %d", Q_FUNC_INFO, + m_data.size(), newData.size()); +#endif + + if (isComplete() || dataSize() + newData.size() < sizeof m_length) + return; + + if (dataSize() < sizeof m_length) { + moveFirstBytes(m_data, newData, sizeof m_length - m_data.size()); + m_length = SshPacketParser::asUint32(m_data, static_cast(0)); + if (m_length < static_cast(TypeOffset + 1) + || m_length > MaxPacketSize) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid length field in SFTP packet."); + } + } + + moveFirstBytes(m_data, newData, + qMin(m_length - dataSize() + 4, newData.size())); +} + +void SftpIncomingPacket::moveFirstBytes(QByteArray &target, QByteArray &source, + int n) +{ + target.append(source.left(n)); + source.remove(0, n); +} + +bool SftpIncomingPacket::isComplete() const +{ + return m_length == dataSize() - 4; +} + +void SftpIncomingPacket::clear() +{ + m_data.clear(); + m_length = 0; +} + +quint32 SftpIncomingPacket::extractServerVersion() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_VERSION); + try { + return SshPacketParser::asUint32(m_data, TypeOffset + 1); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_VERSION packet."); + } +} + +SftpHandleResponse SftpIncomingPacket::asHandleResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_HANDLE); + try { + SftpHandleResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + response.handle = SshPacketParser::asString(m_data, &offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_HANDLE packet"); + } +} + +SftpStatusResponse SftpIncomingPacket::asStatusResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_STATUS); + try { + SftpStatusResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + response.status = static_cast(SshPacketParser::asUint32(m_data, &offset)); + response.errorString = SshPacketParser::asUserString(m_data, &offset); + response.language = SshPacketParser::asString(m_data, &offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_STATUS packet."); + } +} + +SftpNameResponse SftpIncomingPacket::asNameResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_NAME); + try { + SftpNameResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + const quint32 count = SshPacketParser::asUint32(m_data, &offset); + for (quint32 i = 0; i < count; ++i) + response.files << asFile(offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_NAME packet."); + } +} + +SftpDataResponse SftpIncomingPacket::asDataResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_DATA); + try { + SftpDataResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + response.data = SshPacketParser::asString(m_data, &offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_DATA packet."); + } +} + +SftpAttrsResponse SftpIncomingPacket::asAttrsResponse() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_FXP_ATTRS); + try { + SftpAttrsResponse response; + quint32 offset = RequestIdOffset; + response.requestId = SshPacketParser::asUint32(m_data, &offset); + response.attrs = asFileAttributes(offset); + return response; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_FXP_ATTRS packet."); + } +} + +SftpFile SftpIncomingPacket::asFile(quint32 &offset) const +{ + SftpFile file; + file.fileName + = QString::fromUtf8(SshPacketParser::asString(m_data, &offset)); + file.longName + = QString::fromUtf8(SshPacketParser::asString(m_data, &offset)); + file.attributes = asFileAttributes(offset); + return file; +} + +SftpFileAttributes SftpIncomingPacket::asFileAttributes(quint32 &offset) const +{ + SftpFileAttributes attributes; + const quint32 flags = SshPacketParser::asUint32(m_data, &offset); + attributes.sizePresent = flags & SSH_FILEXFER_ATTR_SIZE; + attributes.timesPresent = flags & SSH_FILEXFER_ATTR_ACMODTIME; + attributes.uidAndGidPresent = flags & SSH_FILEXFER_ATTR_UIDGID; + attributes.permissionsPresent = flags & SSH_FILEXFER_ATTR_PERMISSIONS; + if (attributes.sizePresent) + attributes.size = SshPacketParser::asUint64(m_data, &offset); + if (attributes.uidAndGidPresent) { + attributes.uid = SshPacketParser::asUint32(m_data, &offset); + attributes.gid = SshPacketParser::asUint32(m_data, &offset); + } + if (attributes.permissionsPresent) + attributes.permissions = SshPacketParser::asUint32(m_data, &offset); + if (attributes.timesPresent) { + attributes.atime = SshPacketParser::asUint32(m_data, &offset); + attributes.mtime = SshPacketParser::asUint32(m_data, &offset); + } + if (flags & SSH_FILEXFER_ATTR_EXTENDED) { + const quint32 count = SshPacketParser::asUint32(m_data, &offset); + for (quint32 i = 0; i < count; ++i) { + SshPacketParser::asString(m_data, &offset); + SshPacketParser::asString(m_data, &offset); + } + } + return attributes; +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftpincomingpacket_p.h b/src/plugins/coreplugin/ssh/sftpincomingpacket_p.h new file mode 100644 index 00000000000..5a5b8d42fed --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpincomingpacket_p.h @@ -0,0 +1,111 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPINCOMINGPACKET_P_H +#define SFTPINCOMINGPACKET_P_H + +#include "sftppacket_p.h" + +namespace Core { +namespace Internal { + +struct SftpHandleResponse { + quint32 requestId; + QByteArray handle; +}; + +struct SftpStatusResponse { + quint32 requestId; + SftpStatusCode status; + QString errorString; + QByteArray language; +}; + +struct SftpFileAttributes { + bool sizePresent; + bool timesPresent; + bool uidAndGidPresent; + bool permissionsPresent; + quint64 size; + quint32 uid; + quint32 gid; + quint32 permissions; + quint32 atime; + quint32 mtime; +}; + +struct SftpFile { + QString fileName; + QString longName; // Not present in later RFCs, so we don't expose this to the user. + SftpFileAttributes attributes; +}; + +struct SftpNameResponse { + quint32 requestId; + QList files; +}; + +struct SftpDataResponse { + quint32 requestId; + QByteArray data; +}; + +struct SftpAttrsResponse { + quint32 requestId; + SftpFileAttributes attrs; +}; + +class SftpIncomingPacket : public AbstractSftpPacket +{ +public: + SftpIncomingPacket(); + + void consumeData(QByteArray &data); + void clear(); + bool isComplete() const; + quint32 extractServerVersion() const; + SftpHandleResponse asHandleResponse() const; + SftpStatusResponse asStatusResponse() const; + SftpNameResponse asNameResponse() const; + SftpDataResponse asDataResponse() const; + SftpAttrsResponse asAttrsResponse() const; + +private: + void moveFirstBytes(QByteArray &target, QByteArray &source, int n); + + SftpFileAttributes asFileAttributes(quint32 &offset) const; + SftpFile asFile(quint32 &offset) const; + + quint32 m_length; +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPINCOMINGPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sftpoperation.cpp b/src/plugins/coreplugin/ssh/sftpoperation.cpp new file mode 100644 index 00000000000..8acb126db1f --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpoperation.cpp @@ -0,0 +1,176 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpoperation_p.h" + +#include "sftpoutgoingpacket_p.h" + +#include +#include + +namespace Core { +namespace Internal { + +AbstractSftpOperation::AbstractSftpOperation(SftpJobId jobId) : jobId(jobId) +{ +} + +AbstractSftpOperation::~AbstractSftpOperation() { } + + +SftpMakeDir::SftpMakeDir(SftpJobId jobId, const QString &path) + : AbstractSftpOperation(jobId), remoteDir(path) +{ +} + +SftpOutgoingPacket &SftpMakeDir::initialPacket(SftpOutgoingPacket &packet) +{ + return packet.generateMkDir(remoteDir, jobId); +} + + +SftpRmDir::SftpRmDir(SftpJobId, const QString &path) + : AbstractSftpOperation(jobId), remoteDir(path) +{ +} + +SftpOutgoingPacket &SftpRmDir::initialPacket(SftpOutgoingPacket &packet) +{ + return packet.generateRmDir(remoteDir, jobId); +} + + +SftpRm::SftpRm(SftpJobId jobId, const QString &path) + : AbstractSftpOperation(jobId), remoteFile(path) {} + +SftpOutgoingPacket &SftpRm::initialPacket(SftpOutgoingPacket &packet) +{ + return packet.generateRm(remoteFile, jobId); +} + + +SftpRename::SftpRename(SftpJobId jobId, const QString &oldPath, + const QString &newPath) + : AbstractSftpOperation(jobId), oldPath(oldPath), newPath(newPath) +{ +} + +SftpOutgoingPacket &SftpRename::initialPacket(SftpOutgoingPacket &packet) +{ + return packet.generateRename(oldPath, newPath, jobId); +} + + +AbstractSftpOperationWithHandle::AbstractSftpOperationWithHandle(SftpJobId jobId, + const QString &remotePath) + : AbstractSftpOperation(jobId), + remotePath(remotePath), state(Inactive), hasError(false) +{ +} + +AbstractSftpOperationWithHandle::~AbstractSftpOperationWithHandle() { } + + +SftpListDir::SftpListDir(SftpJobId jobId, const QString &path) + : AbstractSftpOperationWithHandle(jobId, path) +{ +} + +SftpOutgoingPacket &SftpListDir::initialPacket(SftpOutgoingPacket &packet) +{ + state = OpenRequested; + return packet.generateOpenDir(remotePath, jobId); +} + + +SftpCreateFile::SftpCreateFile(SftpJobId jobId, const QString &path, + SftpOverwriteMode mode) + : AbstractSftpOperationWithHandle(jobId, path), mode(mode) +{ +} + +SftpOutgoingPacket & SftpCreateFile::initialPacket(SftpOutgoingPacket &packet) +{ + state = OpenRequested; + return packet.generateOpenFileForWriting(remotePath, mode, jobId); +} + + +const int AbstractSftpTransfer::MaxInFlightCount = 10; // Experimentally found to be enough. + +AbstractSftpTransfer::AbstractSftpTransfer(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile) + : AbstractSftpOperationWithHandle(jobId, remotePath), + localFile(localFile), fileSize(0), offset(0), inFlightCount(0), + statRequested(false) +{ +} + +void AbstractSftpTransfer::calculateInFlightCount(quint32 chunkSize) +{ + if (fileSize == 0) { + inFlightCount = 1; + } else { + inFlightCount = fileSize / chunkSize; + if (fileSize % chunkSize) + ++inFlightCount; + if (inFlightCount > MaxInFlightCount) + inFlightCount = MaxInFlightCount; + } +} + + +SftpDownload::SftpDownload(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile) + : AbstractSftpTransfer(jobId, remotePath, localFile), eofId(SftpInvalidJob) +{ +} + +SftpOutgoingPacket &SftpDownload::initialPacket(SftpOutgoingPacket &packet) +{ + state = OpenRequested; + return packet.generateOpenFileForReading(remotePath, jobId); +} + + +SftpUpload::SftpUpload(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile, SftpOverwriteMode mode) + : AbstractSftpTransfer(jobId, remotePath, localFile), mode(mode) +{ + fileSize = localFile->size(); +} + +SftpOutgoingPacket &SftpUpload::initialPacket(SftpOutgoingPacket &packet) +{ + state = OpenRequested; + return packet.generateOpenFileForWriting(remotePath, mode, jobId); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftpoperation_p.h b/src/plugins/coreplugin/ssh/sftpoperation_p.h new file mode 100644 index 00000000000..65987813322 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpoperation_p.h @@ -0,0 +1,193 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPOPERATION_P_H +#define SFTPOPERATION_P_H + +#include "sftpdefs.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QFile; +QT_END_NAMESPACE + +namespace Core { +namespace Internal { + +class SftpOutgoingPacket; + +struct AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + enum Type { + ListDir, MakeDir, RmDir, Rm, Rename, CreateFile, Download, Upload + }; + + AbstractSftpOperation(SftpJobId jobId); + virtual ~AbstractSftpOperation(); + virtual Type type() const=0; + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet)=0; + + const SftpJobId jobId; + +private: + AbstractSftpOperation(const AbstractSftpOperation &); + AbstractSftpOperation &operator=(const AbstractSftpOperation &); +}; + +struct SftpMakeDir : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + + SftpMakeDir(SftpJobId jobId, const QString &path); + virtual Type type() const { return MakeDir; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const QString remoteDir; +}; + +struct SftpRmDir : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + + SftpRmDir(SftpJobId jobId, const QString &path); + virtual Type type() const { return RmDir; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const QString remoteDir; +}; + +struct SftpRm : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + + SftpRm(SftpJobId jobId, const QString &path); + virtual Type type() const { return Rm; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const QString remoteFile; +}; + +struct SftpRename : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + + SftpRename(SftpJobId jobId, const QString &oldPath, const QString &newPath); + virtual Type type() const { return Rename; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const QString oldPath; + const QString newPath; +}; + + +struct AbstractSftpOperationWithHandle : public AbstractSftpOperation +{ + typedef QSharedPointer Ptr; + enum State { Inactive, OpenRequested, Open, CloseRequested }; + + AbstractSftpOperationWithHandle(SftpJobId jobId, const QString &remotePath); + ~AbstractSftpOperationWithHandle(); + + const QString remotePath; + QByteArray remoteHandle; + State state; + bool hasError; +}; + + +struct SftpListDir : public AbstractSftpOperationWithHandle +{ + typedef QSharedPointer Ptr; + + SftpListDir(SftpJobId jobId, const QString &path); + virtual Type type() const { return ListDir; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); +}; + + +struct SftpCreateFile : public AbstractSftpOperationWithHandle +{ + typedef QSharedPointer Ptr; + + SftpCreateFile(SftpJobId jobId, const QString &path, SftpOverwriteMode mode); + virtual Type type() const { return CreateFile; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + const SftpOverwriteMode mode; +}; + +struct AbstractSftpTransfer : public AbstractSftpOperationWithHandle +{ + typedef QSharedPointer Ptr; + + AbstractSftpTransfer(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile); + void calculateInFlightCount(quint32 chunkSize); + + static const int MaxInFlightCount; + + const QSharedPointer localFile; + quint64 fileSize; + quint64 offset; + int inFlightCount; + bool statRequested; +}; + +struct SftpDownload : public AbstractSftpTransfer +{ + typedef QSharedPointer Ptr; + SftpDownload(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile); + virtual Type type() const { return Download; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + QMap offsets; + SftpJobId eofId; +}; + +struct SftpUpload : public AbstractSftpTransfer +{ + typedef QSharedPointer Ptr; + + SftpUpload(SftpJobId jobId, const QString &remotePath, + const QSharedPointer &localFile, SftpOverwriteMode mode); + virtual Type type() const { return Upload; } + virtual SftpOutgoingPacket &initialPacket(SftpOutgoingPacket &packet); + + SftpOverwriteMode mode; +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPOPERATION_P_H diff --git a/src/plugins/coreplugin/ssh/sftpoutgoingpacket.cpp b/src/plugins/coreplugin/ssh/sftpoutgoingpacket.cpp new file mode 100644 index 00000000000..57fd85467e0 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpoutgoingpacket.cpp @@ -0,0 +1,202 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftpoutgoingpacket_p.h" + +#include "sshpacket_p.h" + +#include + +namespace Core { +namespace Internal { + +namespace { + const quint32 DefaultAttributes = 0; + const quint32 SSH_FXF_READ = 0x00000001; + const quint32 SSH_FXF_WRITE = 0x00000002; + const quint32 SSH_FXF_APPEND = 0x00000004; + const quint32 SSH_FXF_CREAT = 0x00000008; + const quint32 SSH_FXF_TRUNC = 0x00000010; + const quint32 SSH_FXF_EXCL = 0x00000020; +} + +SftpOutgoingPacket::SftpOutgoingPacket() +{ +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateInit(quint32 version) +{ + return init(SSH_FXP_INIT, 0).appendInt(version).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateOpenDir(const QString &path, + quint32 requestId) +{ + return init(SSH_FXP_OPENDIR, requestId).appendString(path).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateReadDir(const QByteArray &handle, + quint32 requestId) +{ + return init(SSH_FXP_READDIR, requestId).appendString(handle).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateCloseHandle(const QByteArray &handle, + quint32 requestId) +{ + return init(SSH_FXP_CLOSE, requestId).appendString(handle).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateMkDir(const QString &path, + quint32 requestId) +{ + return init(SSH_FXP_MKDIR, requestId).appendString(path) + .appendInt(DefaultAttributes).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateRmDir(const QString &path, + quint32 requestId) +{ + return init(SSH_FXP_RMDIR, requestId).appendString(path).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateRm(const QString &path, + quint32 requestId) +{ + return init(SSH_FXP_REMOVE, requestId).appendString(path).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateRename(const QString &oldPath, + const QString &newPath, quint32 requestId) +{ + return init(SSH_FXP_RENAME, requestId).appendString(oldPath) + .appendString(newPath).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateOpenFileForWriting(const QString &path, + SftpOverwriteMode mode, quint32 requestId) +{ + return generateOpenFile(path, Write, mode, requestId); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateOpenFileForReading(const QString &path, + quint32 requestId) +{ + // Note: Overwrite mode is irrelevant and will be ignored. + return generateOpenFile(path, Read, SftpSkipExisting, requestId); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateReadFile(const QByteArray &handle, + quint64 offset, quint32 length, quint32 requestId) +{ + return init(SSH_FXP_READ, requestId).appendString(handle).appendInt64(offset) + .appendInt(length).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateFstat(const QByteArray &handle, + quint32 requestId) +{ + return init(SSH_FXP_FSTAT, requestId).appendString(handle).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateWriteFile(const QByteArray &handle, + quint64 offset, const QByteArray &data, quint32 requestId) +{ + return init(SSH_FXP_WRITE, requestId).appendString(handle) + .appendInt64(offset).appendString(data).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::generateOpenFile(const QString &path, + OpenType openType, SftpOverwriteMode mode, quint32 requestId) +{ + quint32 pFlags; + switch (openType) { + case Read: + pFlags = SSH_FXF_READ; + break; + case Write: + pFlags = SSH_FXF_WRITE | SSH_FXF_CREAT; + switch (mode) { + case SftpOverwriteExisting: pFlags |= SSH_FXF_TRUNC; break; + case SftpAppendToExisting: pFlags |= SSH_FXF_APPEND; break; + case SftpSkipExisting: pFlags |= SSH_FXF_EXCL; break; + } + break; + } + return init(SSH_FXP_OPEN, requestId).appendString(path).appendInt(pFlags) + .appendInt(DefaultAttributes).finalize(); +} + +SftpOutgoingPacket &SftpOutgoingPacket::init(SftpPacketType type, + quint32 requestId) +{ + m_data.resize(TypeOffset + 1); + m_data[TypeOffset] = type; + if (type != SSH_FXP_INIT) { + appendInt(requestId); +#ifdef CREATOR_SSH_DEBUG + qDebug("Generating SFTP packet of type %d with request id %u", type, + requestId); +#endif + } + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::appendInt(quint32 val) +{ + m_data.append(AbstractSshPacket::encodeInt(val)); + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::appendInt64(quint64 value) +{ + m_data.append(AbstractSshPacket::encodeInt(value)); + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::appendString(const QString &string) +{ + m_data.append(AbstractSshPacket::encodeString(string.toUtf8())); + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::appendString(const QByteArray &string) +{ + m_data += AbstractSshPacket::encodeString(string); + return *this; +} + +SftpOutgoingPacket &SftpOutgoingPacket::finalize() +{ + AbstractSshPacket::setLengthField(m_data); + return *this; +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftpoutgoingpacket_p.h b/src/plugins/coreplugin/ssh/sftpoutgoingpacket_p.h new file mode 100644 index 00000000000..4f456e87542 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftpoutgoingpacket_p.h @@ -0,0 +1,83 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPOUTGOINGPACKET_P_H +#define SFTPOUTGOINGPACKET_P_H + +#include "sftppacket_p.h" +#include "sftpdefs.h" + +namespace Core { +namespace Internal { + +class SftpOutgoingPacket : public AbstractSftpPacket +{ +public: + SftpOutgoingPacket(); + SftpOutgoingPacket &generateInit(quint32 version); + SftpOutgoingPacket &generateOpenDir(const QString &path, quint32 requestId); + SftpOutgoingPacket &generateReadDir(const QByteArray &handle, + quint32 requestId); + SftpOutgoingPacket &generateCloseHandle(const QByteArray &handle, + quint32 requestId); + SftpOutgoingPacket &generateMkDir(const QString &path, quint32 requestId); + SftpOutgoingPacket &generateRmDir(const QString &path, quint32 requestId); + SftpOutgoingPacket &generateRm(const QString &path, quint32 requestId); + SftpOutgoingPacket &generateRename(const QString &oldPath, + const QString &newPath, quint32 requestId); + SftpOutgoingPacket &generateOpenFileForWriting(const QString &path, + SftpOverwriteMode mode, quint32 requestId); + SftpOutgoingPacket &generateOpenFileForReading(const QString &path, + quint32 requestId); + SftpOutgoingPacket &generateReadFile(const QByteArray &handle, + quint64 offset, quint32 length, quint32 requestId); + SftpOutgoingPacket &generateFstat(const QByteArray &handle, + quint32 requestId); + SftpOutgoingPacket &generateWriteFile(const QByteArray &handle, + quint64 offset, const QByteArray &data, quint32 requestId); + +private: + static QByteArray encodeString(const QString &string); + + enum OpenType { Read, Write }; + SftpOutgoingPacket &generateOpenFile(const QString &path, OpenType openType, + SftpOverwriteMode mode, quint32 requestId); + + SftpOutgoingPacket &init(SftpPacketType type, quint32 requestId); + SftpOutgoingPacket &appendInt(quint32 value); + SftpOutgoingPacket &appendInt64(quint64 value); + SftpOutgoingPacket &appendString(const QString &string); + SftpOutgoingPacket &appendString(const QByteArray &string); + SftpOutgoingPacket &finalize(); +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPOUTGOINGPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sftppacket.cpp b/src/plugins/coreplugin/ssh/sftppacket.cpp new file mode 100644 index 00000000000..0064bf39faf --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftppacket.cpp @@ -0,0 +1,54 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sftppacket_p.h" + +#include "sshpacketparser_p.h" + +namespace Core { +namespace Internal { + +const quint32 AbstractSftpPacket::MaxDataSize = 32768; +const quint32 AbstractSftpPacket::MaxPacketSize = 34000; +const int AbstractSftpPacket::TypeOffset = 4; +const int AbstractSftpPacket::RequestIdOffset = TypeOffset + 1; +const int AbstractSftpPacket::PayloadOffset = RequestIdOffset + 4; + + +AbstractSftpPacket::AbstractSftpPacket() +{ +} + +quint32 AbstractSftpPacket::requestId() const +{ + return SshPacketParser::asUint32(m_data, RequestIdOffset); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sftppacket_p.h b/src/plugins/coreplugin/ssh/sftppacket_p.h new file mode 100644 index 00000000000..aae1a15a97b --- /dev/null +++ b/src/plugins/coreplugin/ssh/sftppacket_p.h @@ -0,0 +1,108 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SFTPPACKET_P_H +#define SFTPPACKET_P_H + +#include +#include +#include + +namespace Core { +namespace Internal { + +enum SftpPacketType { + SSH_FXP_INIT = 1, + SSH_FXP_VERSION = 2, + SSH_FXP_OPEN = 3, + SSH_FXP_CLOSE = 4, + SSH_FXP_READ = 5, + SSH_FXP_WRITE = 6, + SSH_FXP_LSTAT = 7, + SSH_FXP_FSTAT = 8, + SSH_FXP_SETSTAT = 9, + SSH_FXP_FSETSTAT = 10, + SSH_FXP_OPENDIR = 11, + SSH_FXP_READDIR = 12, + SSH_FXP_REMOVE = 13, + SSH_FXP_MKDIR = 14, + SSH_FXP_RMDIR = 15, + SSH_FXP_REALPATH = 16, + SSH_FXP_STAT = 17, + SSH_FXP_RENAME = 18, + SSH_FXP_READLINK = 19, + SSH_FXP_SYMLINK = 20, // Removed from later protocol versions. Try not to use. + + SSH_FXP_STATUS = 101, + SSH_FXP_HANDLE = 102, + SSH_FXP_DATA = 103, + SSH_FXP_NAME = 104, + SSH_FXP_ATTRS = 105, + + SSH_FXP_EXTENDED = 200, + SSH_FXP_EXTENDED_REPLY = 201 +}; + +enum SftpStatusCode { + SSH_FX_OK = 0, + SSH_FX_EOF = 1, + SSH_FX_NO_SUCH_FILE = 2, + SSH_FX_PERMISSION_DENIED = 3, + SSH_FX_FAILURE = 4, + SSH_FX_BAD_MESSAGE = 5, + SSH_FX_NO_CONNECTION = 6, + SSH_FX_CONNECTION_LOST = 7, + SSH_FX_OP_UNSUPPORTED = 8 +}; + +class AbstractSftpPacket +{ +public: + AbstractSftpPacket(); + quint32 requestId() const; + const QByteArray &rawData() const { return m_data; } + SftpPacketType type() const { return static_cast(m_data.at(TypeOffset)); } + + static const quint32 MaxDataSize; // "Pure" data size per read/writepacket. + static const quint32 MaxPacketSize; + +protected: + quint32 dataSize() const { return static_cast(m_data.size()); } + + static const int TypeOffset; + static const int RequestIdOffset; + static const int PayloadOffset; + + QByteArray m_data; +}; + +} // namespace Internal +} // namespace Core + +#endif // SFTPPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sshbotanconversions_p.h b/src/plugins/coreplugin/ssh/sshbotanconversions_p.h new file mode 100644 index 00000000000..05829779423 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshbotanconversions_p.h @@ -0,0 +1,97 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef BYTEARRAYCONVERSIONS_P_H +#define BYTEARRAYCONVERSIONS_P_H + +#include "sshcapabilities_p.h" + +#include +#include + +namespace Core { +namespace Internal { + +inline const Botan::byte *convertByteArray(const QByteArray &a) +{ + return reinterpret_cast(a.constData()); +} + +inline Botan::byte *convertByteArray(QByteArray &a) +{ + return reinterpret_cast(a.data()); +} + +inline QByteArray convertByteArray(const Botan::SecureVector &v) +{ + return QByteArray(reinterpret_cast(v.begin()), v.size()); +} + +inline const char *botanKeyExchangeAlgoName(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::DiffieHellmanGroup1Sha1 + || rfcAlgoName == SshCapabilities::DiffieHellmanGroup14Sha1); + return rfcAlgoName == SshCapabilities::DiffieHellmanGroup1Sha1 + ? "modp/ietf/1024" : "modp/ietf/2048"; +} + +inline const char *botanCryptAlgoName(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::CryptAlgo3Des + || rfcAlgoName == SshCapabilities::CryptAlgoAes128); + return rfcAlgoName == SshCapabilities::CryptAlgo3Des + ? "TripleDES" : "AES-128"; +} + +inline const char *botanEmsaAlgoName(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::PubKeyDss + || rfcAlgoName == SshCapabilities::PubKeyRsa); + return rfcAlgoName == SshCapabilities::PubKeyDss + ? "EMSA1(SHA-1)" : "EMSA3(SHA-1)"; +} + +inline const char *botanSha1Name() { return "SHA-1"; } + +inline const char *botanHMacAlgoName(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::HMacSha1); + return botanSha1Name(); +} + +inline quint32 botanHMacKeyLen(const QByteArray &rfcAlgoName) +{ + Q_ASSERT(rfcAlgoName == SshCapabilities::HMacSha1); + return 20; +} + +} // namespace Internal +} // namespace Core + +#endif // BYTEARRAYCONVERSIONS_P_H diff --git a/src/plugins/coreplugin/ssh/sshcapabilities.cpp b/src/plugins/coreplugin/ssh/sshcapabilities.cpp new file mode 100644 index 00000000000..56db394206a --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshcapabilities.cpp @@ -0,0 +1,103 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshcapabilities_p.h" + +#include "sshexception_p.h" + +#include +#include + +namespace Core { +namespace Internal { + +namespace { + QByteArray listAsByteArray(const QList &list) + { + QByteArray array; + foreach(const QByteArray &elem, list) + array += elem + ','; + if (!array.isEmpty()) + array.remove(array.count() - 1, 1); + return array; + } +} // anonymous namspace + +const QByteArray SshCapabilities::DiffieHellmanGroup1Sha1("diffie-hellman-group1-sha1"); +const QByteArray SshCapabilities::DiffieHellmanGroup14Sha1("diffie-hellman-group14-sha1"); +const QList SshCapabilities::KeyExchangeMethods + = QList() << SshCapabilities::DiffieHellmanGroup1Sha1 + << SshCapabilities::DiffieHellmanGroup14Sha1; + +const QByteArray SshCapabilities::PubKeyDss("ssh-dss"); +const QByteArray SshCapabilities::PubKeyRsa("ssh-rsa"); +const QList SshCapabilities::PublicKeyAlgorithms + = QList() << SshCapabilities::PubKeyRsa + << SshCapabilities::PubKeyDss; + +const QByteArray SshCapabilities::CryptAlgo3Des("3des-cbc"); +const QByteArray SshCapabilities::CryptAlgoAes128("aes128-cbc"); +const QList SshCapabilities::EncryptionAlgorithms + = QList() << SshCapabilities::CryptAlgoAes128 + << SshCapabilities::CryptAlgo3Des; + +const QByteArray SshCapabilities::HMacSha1("hmac-sha1"); +const QByteArray SshCapabilities::HMacSha196("hmac-sha1-96"); +const QList SshCapabilities::MacAlgorithms + = QList() /* << SshCapabilities::HMacSha196 */ + << SshCapabilities::HMacSha1; + +const QList SshCapabilities::CompressionAlgorithms + = QList() << "none"; + +const QByteArray SshCapabilities::SshConnectionService("ssh-connection"); + +const QByteArray SshCapabilities::PublicKeyAuthMethod("publickey"); +const QByteArray SshCapabilities::PasswordAuthMethod("password"); + + +QByteArray SshCapabilities::findBestMatch(const QList &myCapabilities, + const QList &serverCapabilities) +{ + foreach (const QByteArray &myCapability, myCapabilities) { + if (serverCapabilities.contains(myCapability)) + return myCapability; + } + + throw SshServerException(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Server and client capabilities don't match.", + QCoreApplication::translate("SshConnection", + "Server and client capabilities don't match. " + "Client list was: %1.\nServer list was %2.") + .arg(listAsByteArray(myCapabilities).data()) + .arg(listAsByteArray(serverCapabilities).data())); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshcapabilities_p.h b/src/plugins/coreplugin/ssh/sshcapabilities_p.h new file mode 100644 index 00000000000..7c58c830f56 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshcapabilities_p.h @@ -0,0 +1,72 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef CAPABILITIES_P_H +#define CAPABILITIES_P_H + +#include +#include + +namespace Core { +namespace Internal { + +class SshCapabilities +{ +public: + static const QByteArray DiffieHellmanGroup1Sha1; + static const QByteArray DiffieHellmanGroup14Sha1; + static const QList KeyExchangeMethods; + + static const QByteArray PubKeyDss; + static const QByteArray PubKeyRsa; + static const QList PublicKeyAlgorithms; + + static const QByteArray CryptAlgo3Des; + static const QByteArray CryptAlgoAes128; + static const QList EncryptionAlgorithms; + + static const QByteArray HMacSha1; + static const QByteArray HMacSha196; + static const QList MacAlgorithms; + + static const QList CompressionAlgorithms; + + static const QByteArray SshConnectionService; + + static const QByteArray PublicKeyAuthMethod; + static const QByteArray PasswordAuthMethod; + + static QByteArray findBestMatch(const QList &myCapabilities, + const QList &serverCapabilities); +}; + +} // namespace Internal +} // namespace Core + +#endif // CAPABILITIES_P_H diff --git a/src/plugins/coreplugin/ssh/sshchannel.cpp b/src/plugins/coreplugin/ssh/sshchannel.cpp new file mode 100644 index 00000000000..6e1b9c43f52 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshchannel.cpp @@ -0,0 +1,244 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshchannel_p.h" + +#include "sshincomingpacket_p.h" +#include "sshsendfacility_p.h" + +#include + +namespace Core { +namespace Internal { + +namespace { + const quint32 MinMaxPacketSize = 32768; + const quint32 MaxPacketSize = 16 * 1024 * 1024; + const quint32 InitialWindowSize = MaxPacketSize; + const quint32 NoChannel = 0xffffffffu; +} // anonymous namespace + +AbstractSshChannel::AbstractSshChannel(quint32 channelId, + SshSendFacility &sendFacility) + : m_sendFacility(sendFacility), m_localChannel(channelId), + m_remoteChannel(NoChannel), m_localWindowSize(InitialWindowSize), + m_remoteWindowSize(0), m_state(Inactive) +{ +} + +AbstractSshChannel::~AbstractSshChannel() +{ + +} + +void AbstractSshChannel::setChannelState(ChannelState state) +{ + m_state = state; + if (state == Closed) + closeHook(); +} + +void AbstractSshChannel::requestSessionStart() +{ + // Note: We are just being paranoid here about the Botan exceptions, + // which are extremely unlikely to happen, because if there was a problem + // with our cryptography stuff, it would have hit us before, on + // establishing the connection. + try { + m_sendFacility.sendSessionPacket(m_localChannel, InitialWindowSize, + MaxPacketSize); + setChannelState(SessionRequested); + } catch (Botan::Exception &e) { + m_errorString = QString::fromAscii(e.what()); + closeChannel(); + } +} + +void AbstractSshChannel::sendData(const QByteArray &data) +{ + try { + m_sendBuffer += data; + flushSendBuffer(); + } catch (Botan::Exception &e) { + m_errorString = QString::fromAscii(e.what()); + closeChannel(); + } +} + +void AbstractSshChannel::handleWindowAdjust(quint32 bytesToAdd) +{ + checkChannelActive(); + + const quint64 newValue = m_remoteWindowSize + bytesToAdd; + if (newValue > 0xffffffffu) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Illegal window size requested."); + } + + m_remoteWindowSize = newValue; + flushSendBuffer(); +} + +void AbstractSshChannel::flushSendBuffer() +{ + const quint32 bytesToSend + = qMin(m_remoteWindowSize, m_sendBuffer.size()); + if (bytesToSend > 0) { + const QByteArray &data = m_sendBuffer.left(bytesToSend); + m_sendFacility.sendChannelDataPacket(m_remoteChannel, data); + m_sendBuffer.remove(0, bytesToSend); + m_remoteWindowSize -= bytesToSend; + } +} + +void AbstractSshChannel::handleOpenSuccess(quint32 remoteChannelId, + quint32 remoteWindowSize, quint32 remoteMaxPacketSize) +{ + if (m_state != SessionRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet."); + } + + if (remoteMaxPacketSize < MinMaxPacketSize) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Maximum packet size too low."); + } + +#ifdef CREATOR_SSH_DEBUG + qDebug("Channel opened. remote channel id: %u, remote window size: %u, " + "remote max packet size: %u", + remoteChannelId, remoteWindowSize, remoteMaxPacketSize); +#endif + m_remoteChannel = remoteChannelId; + m_remoteWindowSize = remoteWindowSize; + m_remoteMaxPacketSize = remoteMaxPacketSize; + setChannelState(SessionEstablished); + handleOpenSuccessInternal(); +} + +void AbstractSshChannel::handleOpenFailure(const QString &reason) +{ + if (m_state != SessionRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_OPEN_FAILURE packet."); + } + +#ifdef CREATOR_SSH_DEBUG + qDebug("Channel open request failed for channel %u", m_localChannel); +#endif + m_errorString = reason; + handleOpenFailureInternal(); +} + +void AbstractSshChannel::handleChannelEof() +{ + if (m_state == Inactive || m_state == Closed) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_EOF message."); + } + m_localWindowSize = 0; +} + +void AbstractSshChannel::handleChannelClose() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("Receiving CLOSE for channel %u", m_localChannel); +#endif + if (channelState() == Inactive || channelState() == Closed) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_CLOSE message."); + } + closeChannel(); + setChannelState(Closed); +} + +void AbstractSshChannel::handleChannelData(const QByteArray &data) +{ + const int bytesToDeliver = handleChannelOrExtendedChannelData(data); + handleChannelDataInternal(bytesToDeliver == data.size() + ? data : data.left(bytesToDeliver)); +} + +void AbstractSshChannel::handleChannelExtendedData(quint32 type, const QByteArray &data) +{ + const int bytesToDeliver = handleChannelOrExtendedChannelData(data); + handleChannelExtendedDataInternal(type, bytesToDeliver == data.size() + ? data : data.left(bytesToDeliver)); +} + +void AbstractSshChannel::handleChannelRequest(const SshIncomingPacket &packet) +{ + qWarning("Ignoring unknown request type '%s'", + packet.extractChannelRequestType().data()); +} + +int AbstractSshChannel::handleChannelOrExtendedChannelData(const QByteArray &data) +{ + checkChannelActive(); + + const int bytesToDeliver = qMin(data.size(), maxDataSize()); + if (bytesToDeliver != data.size()) + qWarning("Misbehaving server does not respect local window, clipping."); + + m_localWindowSize -= bytesToDeliver; + if (m_localWindowSize < MaxPacketSize) { + m_localWindowSize += MaxPacketSize; + m_sendFacility.sendWindowAdjustPacket(m_remoteChannel, + MaxPacketSize); + } + return bytesToDeliver; +} + +void AbstractSshChannel::closeChannel() +{ + if (m_state != CloseRequested && m_state != Closed) { + if (m_state == Inactive) { + setChannelState(Closed); + } else { + setChannelState(CloseRequested); + m_sendFacility.sendChannelEofPacket(m_remoteChannel); + m_sendFacility.sendChannelClosePacket(m_remoteChannel); + } + } +} + +void AbstractSshChannel::checkChannelActive() +{ + if (channelState() == Inactive || channelState() == Closed) + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Channel not open."); +} + +quint32 AbstractSshChannel::maxDataSize() const +{ + return qMin(m_localWindowSize, MaxPacketSize); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshchannel_p.h b/src/plugins/coreplugin/ssh/sshchannel_p.h new file mode 100644 index 00000000000..993357d8713 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshchannel_p.h @@ -0,0 +1,111 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHCHANNEL_P_H +#define SSHCHANNEL_P_H + +#include +#include + +namespace Core { +namespace Internal { + +class SshIncomingPacket; +class SshSendFacility; + +class AbstractSshChannel +{ +public: + enum ChannelState { + Inactive, SessionRequested, SessionEstablished, CloseRequested, Closed + }; + + ChannelState channelState() const { return m_state; } + void setChannelState(ChannelState state); + + void setError(const QString &error) { m_errorString = error; } + QString errorString() const { return m_errorString; } + + quint32 localChannelId() const { return m_localChannel; } + quint32 remoteChannel() const { return m_remoteChannel; } + + virtual void handleChannelSuccess()=0; + virtual void handleChannelFailure()=0; + virtual void handleChannelRequest(const SshIncomingPacket &packet); + + virtual void closeHook()=0; + + void handleOpenSuccess(quint32 remoteChannelId, quint32 remoteWindowSize, + quint32 remoteMaxPacketSize); + void handleOpenFailure(const QString &reason); + void handleWindowAdjust(quint32 bytesToAdd); + void handleChannelEof(); + void handleChannelClose(); + void handleChannelData(const QByteArray &data); + void handleChannelExtendedData(quint32 type, const QByteArray &data); + + void requestSessionStart(); + void sendData(const QByteArray &data); + void closeChannel(); + + virtual ~AbstractSshChannel(); + +protected: + AbstractSshChannel(quint32 channelId, SshSendFacility &sendFacility); + + quint32 maxDataSize() const; + void checkChannelActive(); + + SshSendFacility &m_sendFacility; + +private: + virtual void handleOpenSuccessInternal()=0; + virtual void handleOpenFailureInternal()=0; + virtual void handleChannelDataInternal(const QByteArray &data)=0; + virtual void handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data)=0; + + void setState(ChannelState newState); + void flushSendBuffer(); + int handleChannelOrExtendedChannelData(const QByteArray &data); + + const quint32 m_localChannel; + quint32 m_remoteChannel; + quint32 m_localWindowSize; + quint32 m_remoteWindowSize; + quint32 m_remoteMaxPacketSize; + ChannelState m_state; + QByteArray m_sendBuffer; + QString m_errorString; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHCHANNEL_P_H diff --git a/src/plugins/coreplugin/ssh/sshchannelmanager.cpp b/src/plugins/coreplugin/ssh/sshchannelmanager.cpp new file mode 100644 index 00000000000..c7d31136971 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshchannelmanager.cpp @@ -0,0 +1,188 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshchannelmanager_p.h" + +#include "sftpchannel.h" +#include "sftpchannel_p.h" +#include "sshincomingpacket_p.h" +#include "sshremoteprocess.h" +#include "sshremoteprocess_p.h" +#include "sshsendfacility_p.h" + +#include + +namespace Core { +namespace Internal { + +SshChannelManager::SshChannelManager(SshSendFacility &sendFacility) + : m_sendFacility(sendFacility), m_nextLocalChannelId(0) +{ +} + +SshChannelManager::~SshChannelManager() {} + +void SshChannelManager::handleChannelRequest(const SshIncomingPacket &packet) +{ + lookupChannel(packet.extractRecipientChannel()) + ->handleChannelRequest(packet); +} + +void SshChannelManager::handleChannelOpen(const SshIncomingPacket &) +{ + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Server tried to open channel on client."); +} + +void SshChannelManager::handleChannelOpenFailure(const SshIncomingPacket &packet) +{ + const SshChannelOpenFailure &failure = packet.extractChannelOpenFailure(); + ChannelIterator it = lookupChannelAsIterator(failure.localChannel); + try { + it.value()->handleOpenFailure(failure.reasonString); + } catch (SshServerException &e) { + removeChannel(it); + throw e; + } + removeChannel(it); +} + +void SshChannelManager::handleChannelOpenConfirmation(const SshIncomingPacket &packet) +{ + const SshChannelOpenConfirmation &confirmation + = packet.extractChannelOpenConfirmation(); + lookupChannel(confirmation.localChannel)->handleOpenSuccess(confirmation.remoteChannel, + confirmation.remoteWindowSize, confirmation.remoteMaxPacketSize); +} + +void SshChannelManager::handleChannelSuccess(const SshIncomingPacket &packet) +{ + lookupChannel(packet.extractRecipientChannel())->handleChannelSuccess(); +} + +void SshChannelManager::handleChannelFailure(const SshIncomingPacket &packet) +{ + lookupChannel(packet.extractRecipientChannel())->handleChannelFailure(); +} + +void SshChannelManager::handleChannelWindowAdjust(const SshIncomingPacket &packet) +{ + const SshChannelWindowAdjust adjust = packet.extractWindowAdjust(); + lookupChannel(adjust.localChannel)->handleWindowAdjust(adjust.bytesToAdd); +} + +void SshChannelManager::handleChannelData(const SshIncomingPacket &packet) +{ + const SshChannelData &data = packet.extractChannelData(); + lookupChannel(data.localChannel)->handleChannelData(data.data); +} + +void SshChannelManager::handleChannelExtendedData(const SshIncomingPacket &packet) +{ + const SshChannelExtendedData &data = packet.extractChannelExtendedData(); + lookupChannel(data.localChannel)->handleChannelExtendedData(data.type, data.data); +} + +void SshChannelManager::handleChannelEof(const SshIncomingPacket &packet) +{ + AbstractSshChannel * const channel + = lookupChannel(packet.extractRecipientChannel(), true); + if (channel) + channel->handleChannelEof(); +} + +void SshChannelManager::handleChannelClose(const SshIncomingPacket &packet) +{ + const quint32 channelId = packet.extractRecipientChannel(); + + ChannelIterator it = lookupChannelAsIterator(channelId, true); + if (it != m_channels.end()) { + it.value()->handleChannelClose(); + removeChannel(it); + } +} + +SshChannelManager::ChannelIterator SshChannelManager::lookupChannelAsIterator(quint32 channelId, + bool allowNotFound) +{ + ChannelIterator it = m_channels.find(channelId); + if (it == m_channels.end() && !allowNotFound) { + throw SshServerException(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid channel id.", + SSH_TR("Invalid channel id %1").arg(channelId)); + } + return it; +} + +AbstractSshChannel *SshChannelManager::lookupChannel(quint32 channelId, + bool allowNotFound) +{ + ChannelIterator it = lookupChannelAsIterator(channelId, allowNotFound); + return it == m_channels.end() ? 0 : it.value(); +} + +Core::SshRemoteProcess::Ptr SshChannelManager::createRemoteProcess(const QByteArray &command) +{ + SshRemoteProcess::Ptr proc(new SshRemoteProcess(command, m_nextLocalChannelId++, m_sendFacility)); + insertChannel(proc->d, proc); + return proc; +} + +Core::SftpChannel::Ptr SshChannelManager::createSftpChannel() +{ + SftpChannel::Ptr sftp(new SftpChannel(m_nextLocalChannelId++, m_sendFacility)); + insertChannel(sftp->d, sftp); + return sftp; +} + +void SshChannelManager::insertChannel(AbstractSshChannel *priv, + const QSharedPointer &pub) +{ + m_channels.insert(priv->localChannelId(), priv); + m_sessions.insert(priv, pub); +} + +void SshChannelManager::closeAllChannels() +{ + for (ChannelIterator it = m_channels.begin(); it != m_channels.end(); ++it) + it.value()->closeChannel(); + m_channels.clear(); + m_sessions.clear(); +} + +void SshChannelManager::removeChannel(ChannelIterator it) +{ + Q_ASSERT(it != m_channels.end() && "Unexpected channel lookup failure."); + const int removeCount = m_sessions.remove(it.value()); + Q_ASSERT(removeCount == 1 && "Session for channel not found."); + m_channels.erase(it); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshchannelmanager_p.h b/src/plugins/coreplugin/ssh/sshchannelmanager_p.h new file mode 100644 index 00000000000..fe62c009241 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshchannelmanager_p.h @@ -0,0 +1,89 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHCHANNELLAYER_P_H +#define SSHCHANNELLAYER_P_H + +#include +#include + +namespace Core { + +class SftpChannel; +class SshRemoteProcess; + +namespace Internal { + +class AbstractSshChannel; +class SshIncomingPacket; +class SshSendFacility; + +class SshChannelManager +{ +public: + SshChannelManager(SshSendFacility &sendFacility); + ~SshChannelManager(); + + QSharedPointer createRemoteProcess(const QByteArray &command); + QSharedPointer createSftpChannel(); + void closeAllChannels(); + + void handleChannelRequest(const SshIncomingPacket &packet); + void handleChannelOpen(const SshIncomingPacket &packet); + void handleChannelOpenFailure(const SshIncomingPacket &packet); + void handleChannelOpenConfirmation(const SshIncomingPacket &packet); + void handleChannelSuccess(const SshIncomingPacket &packet); + void handleChannelFailure(const SshIncomingPacket &packet); + void handleChannelWindowAdjust(const SshIncomingPacket &packet); + void handleChannelData(const SshIncomingPacket &packet); + void handleChannelExtendedData(const SshIncomingPacket &packet); + void handleChannelEof(const SshIncomingPacket &packet); + void handleChannelClose(const SshIncomingPacket &packet); + +private: + typedef QHash::Iterator ChannelIterator; + + ChannelIterator lookupChannelAsIterator(quint32 channelId, + bool allowNotFound = false); + AbstractSshChannel *lookupChannel(quint32 channelId, + bool allowNotFound = false); + void removeChannel(ChannelIterator it); + void insertChannel(AbstractSshChannel *priv, + const QSharedPointer &pub); + + SshSendFacility &m_sendFacility; + QHash m_channels; + QHash > m_sessions; + quint32 m_nextLocalChannelId; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHCHANNELLAYER_P_H diff --git a/src/plugins/coreplugin/ssh/sshconnection.cpp b/src/plugins/coreplugin/ssh/sshconnection.cpp index 7433bbebd8d..fbf63d76705 100644 --- a/src/plugins/coreplugin/ssh/sshconnection.cpp +++ b/src/plugins/coreplugin/ssh/sshconnection.cpp @@ -1,19 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of Qt Creator. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** 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 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -21,471 +22,540 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +**************************************************************************/ #include "sshconnection.h" +#include "sshconnection_p.h" -#include "ne7sshobject.h" +#include "sftpchannel.h" +#include "sshcapabilities_p.h" +#include "sshchannelmanager_p.h" +#include "sshcryptofacility_p.h" +#include "sshexception_p.h" +#include "sshkeyexchange_p.h" -#include -#include -#include +#include +#include + +#include #include -#include -#include - -#include - -#include +#include namespace Core { namespace { + const QByteArray ClientId("SSH-2.0-QtCreator\r\n"); -class GenericSshConnection -{ - Q_DECLARE_TR_FUNCTIONS(GenericSshConnection) -public: - GenericSshConnection(const SshServerInfo &server) - : ssh(Internal::Ne7SshObject::instance()->get()), - m_server(server), - m_channel(-1) - { } + bool staticInitializationsDone = false; + QMutex staticInitMutex; - ~GenericSshConnection() + void doStaticInitializationsIfNecessary() { - quit(); - } - - bool start(bool shell, void (*callbackFunc)(void *), void *callbackArg) - { - Q_ASSERT(m_channel == -1); - - try { - const QString *authString; - int (ne7ssh::*connFunc)(const char *, int, const char *, - const char *, bool, int, void (*)(void *), void *); - if (m_server.authType == SshServerInfo::AuthByPwd) { - authString = &m_server.pwd; - connFunc = &ne7ssh::connectWithPassword; - } else { - authString = &m_server.privateKeyFile; - connFunc = &ne7ssh::connectWithKey; + if (!staticInitializationsDone) { + staticInitMutex.lock(); + if (!staticInitializationsDone) { + Botan::LibraryInitializer::initialize("thread_safe=true"); + qRegisterMetaType("SshError"); + staticInitializationsDone = true; } - m_channel = (ssh.data()->*connFunc)(m_server.host.toLatin1(), - m_server.port, m_server.uname.toAscii(), authString->toLatin1(), - shell, m_server.timeout, callbackFunc, callbackArg); - if (m_channel == -1) { - setError(tr("Could not connect to host."), false); - return false; - } - } catch (const std::exception &e) { - // Should in theory not be necessary, but Net7 leaks Botan exceptions. - setError(tr("Error in cryptography backend: %1") - .arg(QLatin1String(e.what())), false); - return false; - } - - return true; - } - - void quit() - { - const int channel = m_channel; - if (channel != -1) { - m_channel = -1; - if (!ssh->close(channel)) - qWarning("%s: close() failed.", Q_FUNC_INFO); + staticInitMutex.unlock(); } } - - bool isConnected() const { return channel() != -1; } - bool hasError() const { return !m_error.isEmpty(); } - QString error() const { return m_error; } - int channel() const { return m_channel; } - QString lastNe7Error() { return ssh->errors()->pop(channel()); } - const SshServerInfo &server() { return m_server; } - - void setError(const QString error, bool appendNe7ErrMsg) - { - m_error = error; - if (appendNe7ErrMsg) - m_error += QLatin1String(": ") + lastNe7Error(); - } - - QSharedPointer ssh; -private: - const SshServerInfo m_server; - QString m_error; - int m_channel; -}; - -char *alloc(size_t n) -{ - return new char[n]; } -} // anonymous namespace +// TODO: Mechanism for checking the host key. First connection to host: save, later: compare + +SshConnection::Ptr SshConnection::create() +{ + doStaticInitializationsIfNecessary(); + return Ptr(new SshConnection); +} + +SshConnection::SshConnection() : d(new Internal::SshConnectionPrivate(this)) +{ + connect(d, SIGNAL(connected()), this, SIGNAL(connected()), + Qt::QueuedConnection); + connect(d, SIGNAL(dataAvailable(QString)), this, + SIGNAL(dataAvailable(QString)), Qt::QueuedConnection); + connect(d, SIGNAL(disconnected()), this, SIGNAL(disconnected()), + Qt::QueuedConnection); + connect(d, SIGNAL(error(SshError)), this, SIGNAL(error(SshError)), + Qt::QueuedConnection); +} + +void SshConnection::connectToHost(const SshConnectionParameters &serverInfo) +{ + d->connectToHost(serverInfo); +} + +void SshConnection::disconnectFromHost() +{ + d->closeConnection(Internal::SSH_DISCONNECT_BY_APPLICATION, SshNoError, "", + QString()); +} + +SshConnection::State SshConnection::state() const +{ + switch (d->state()) { + case Internal::SocketUnconnected: + return Unconnected; + case Internal::ConnectionEstablished: + return Connected; + default: + return Connecting; + } +} + +SshError SshConnection::errorState() const +{ + return d->error(); +} + +QString SshConnection::errorString() const +{ + return d->errorString(); +} + +SshConnectionParameters SshConnection::connectionParameters() const +{ + return d->m_connParams; +} + +SshConnection::~SshConnection() +{ + disconnect(); + disconnectFromHost(); + delete d; +} + +QSharedPointer SshConnection::createRemoteProcess(const QByteArray &command) +{ + return state() == Connected + ? d->createRemoteProcess(command) : QSharedPointer(); +} + +QSharedPointer SshConnection::createSftpChannel() +{ + return state() == Connected + ? d->createSftpChannel() : QSharedPointer(); +} + namespace Internal { -struct InteractiveSshConnectionPrivate +SshConnectionPrivate::SshConnectionPrivate(SshConnection *conn) + : m_socket(new QTcpSocket(this)), m_state(SocketUnconnected), + m_sendFacility(m_socket), + m_channelManager(new SshChannelManager(m_sendFacility)), + m_error(SshNoError), m_ignoreNextPacket(false), m_conn(conn) { - InteractiveSshConnectionPrivate(const SshServerInfo &server) - : conn(server), outputReader(0) {} + setupPacketHandlers(); + connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(handleTimeout())); +} - GenericSshConnection conn; - ConnectionOutputReader *outputReader; - QByteArray remoteOutput; - QMutex mutex; - QWaitCondition waitCond; -}; - -struct NonInteractiveSshConnectionPrivate +SshConnectionPrivate::~SshConnectionPrivate() { - NonInteractiveSshConnectionPrivate(const SshServerInfo &server) - : conn(server) {} + disconnect(); +} - GenericSshConnection conn; - Ne7SftpSubsystem sftp; -}; - -class ConnectionOutputReader : public QThread +void SshConnectionPrivate::setupPacketHandlers() { -public: - ConnectionOutputReader(InteractiveSshConnection *parent) - : QThread(parent), m_conn(parent), m_stopRequested(false), - m_dataAvailable(false) - {} + typedef SshConnectionPrivate This; - ~ConnectionOutputReader() - { - stop(); - wait(); + setupPacketHandler(SSH_MSG_KEXINIT, StateList() << SocketConnected, + &This::handleKeyExchangeInitPacket); + setupPacketHandler(SSH_MSG_KEXDH_REPLY, StateList() << KeyExchangeStarted, + &This::handleKeyExchangeReplyPacket); + + setupPacketHandler(SSH_MSG_NEWKEYS, StateList() << KeyExchangeSuccess, + &This::handleNewKeysPacket); + setupPacketHandler(SSH_MSG_SERVICE_ACCEPT, + StateList() << UserAuthServiceRequested, + &This::handleServiceAcceptPacket); + setupPacketHandler(SSH_MSG_USERAUTH_PASSWD_CHANGEREQ, + StateList() << UserAuthRequested, &This::handlePasswordExpiredPacket); + setupPacketHandler(SSH_MSG_GLOBAL_REQUEST, + StateList() << ConnectionEstablished, &This::handleGlobalRequest); + + const StateList authReqList = StateList() << UserAuthRequested; + setupPacketHandler(SSH_MSG_USERAUTH_BANNER, authReqList, + &This::handleUserAuthBannerPacket); + setupPacketHandler(SSH_MSG_USERAUTH_SUCCESS, authReqList, + &This::handleUserAuthSuccessPacket); + setupPacketHandler(SSH_MSG_USERAUTH_FAILURE, authReqList, + &This::handleUserAuthFailurePacket); + + const StateList connectedList + = StateList() << ConnectionEstablished; + setupPacketHandler(SSH_MSG_CHANNEL_REQUEST, connectedList, + &This::handleChannelRequest); + setupPacketHandler(SSH_MSG_CHANNEL_OPEN, connectedList, + &This::handleChannelOpen); + setupPacketHandler(SSH_MSG_CHANNEL_OPEN_FAILURE, connectedList, + &This::handleChannelOpenFailure); + setupPacketHandler(SSH_MSG_CHANNEL_OPEN_CONFIRMATION, connectedList, + &This::handleChannelOpenConfirmation); + setupPacketHandler(SSH_MSG_CHANNEL_SUCCESS, connectedList, + &This::handleChannelSuccess); + setupPacketHandler(SSH_MSG_CHANNEL_FAILURE, connectedList, + &This::handleChannelFailure); + setupPacketHandler(SSH_MSG_CHANNEL_WINDOW_ADJUST, connectedList, + &This::handleChannelWindowAdjust); + setupPacketHandler(SSH_MSG_CHANNEL_DATA, connectedList, + &This::handleChannelData); + setupPacketHandler(SSH_MSG_CHANNEL_EXTENDED_DATA, connectedList, + &This::handleChannelExtendedData); + + const StateList connectedOrClosedList + = StateList() << SocketUnconnected << ConnectionEstablished; + setupPacketHandler(SSH_MSG_CHANNEL_EOF, connectedOrClosedList, + &This::handleChannelEof); + setupPacketHandler(SSH_MSG_CHANNEL_CLOSE, connectedOrClosedList, + &This::handleChannelClose); + + setupPacketHandler(SSH_MSG_DISCONNECT, StateList() << SocketConnected + << KeyExchangeStarted << KeyExchangeSuccess + << UserAuthServiceRequested << UserAuthRequested + << ConnectionEstablished, &This::handleDisconnect); +} + +void SshConnectionPrivate::setupPacketHandler(SshPacketType type, + const SshConnectionPrivate::StateList &states, + SshConnectionPrivate::PacketHandler handler) +{ + m_packetHandlers.insert(type, HandlerInStates(states, handler)); +} + +void SshConnectionPrivate::handleSocketConnected() +{ + m_state = SocketConnected; + sendData(ClientId); +} + +void SshConnectionPrivate::handleIncomingData() +{ + if (m_state == SocketUnconnected) + return; // For stuff queued in the event loop after we've called closeConnection(); + + try { + m_incomingData += m_socket->readAll(); +#ifdef CREATOR_SSH_DEBUG + qDebug("state = %d, remote data size = %d", m_state, + m_incomingData.count()); +#endif + if (m_state == SocketConnected) + handleServerId(); + handlePackets(); + } catch (SshServerException &e) { + closeConnection(e.error, SshProtocolError, e.errorStringServer, + tr("SSH Protocol error: %1").arg(e.errorStringUser)); + } catch (SshClientException &e) { + closeConnection(SSH_DISCONNECT_BY_APPLICATION, e.error, "", + e.errorString); + } catch (Botan::Exception &e) { + closeConnection(SSH_DISCONNECT_BY_APPLICATION, SshInternalError, "", + tr("Botan exception: %1").arg(e.what())); + } +} + +void SshConnectionPrivate::handleServerId() +{ + const int idOffset = m_incomingData.indexOf("SSH-"); + if (idOffset == -1) + return; + m_incomingData.remove(0, idOffset); + if (m_incomingData.size() < 7) + return; + const QByteArray &version = m_incomingData.mid(4, 3); + if (version != "2.0") { + throw SshServerException(SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED, + "Invalid protocol version.", + tr("Invalid protocol version: Expected '2.0', got '%1'.") + .arg(SshPacketParser::asUserString(version))); + } + const int endOffset = m_incomingData.indexOf("\r\n"); + if (endOffset == -1) + return; + if (m_incomingData.at(7) != '-') { + throw SshServerException(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid server id.", tr("Invalid server id '%1'.") + .arg(SshPacketParser::asUserString(m_incomingData))); } - void stop() - { - m_mutex.lock(); - m_stopRequested = true; - m_waitCond.wakeOne(); - m_mutex.unlock(); + m_keyExchange.reset(new SshKeyExchange(m_sendFacility)); + m_keyExchange->sendKexInitPacket(m_incomingData.left(endOffset)); + m_incomingData.remove(0, endOffset + 2); +} + +void SshConnectionPrivate::handlePackets() +{ + m_incomingPacket.consumeData(m_incomingData); + while (m_incomingPacket.isComplete()) { + handleCurrentPacket(); + m_incomingPacket.clear(); + m_incomingPacket.consumeData(m_incomingData); + } +} + +void SshConnectionPrivate::handleCurrentPacket() +{ + Q_ASSERT(m_incomingPacket.isComplete()); + Q_ASSERT(m_state == KeyExchangeStarted || !m_ignoreNextPacket); + + if (m_ignoreNextPacket) { + m_ignoreNextPacket = false; + return; } - void dataAvailable() - { - m_mutex.lock(); - m_dataAvailable = true; - m_waitCond.wakeOne(); - m_mutex.unlock(); + QHash::ConstIterator it + = m_packetHandlers.find(m_incomingPacket.type()); + if (it == m_packetHandlers.end()) { + m_sendFacility.sendMsgUnimplementedPacket(m_incomingPacket.serverSeqNr()); + return; } + if (!it.value().first.contains(m_state)) { + throw SshServerException(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected packet.", tr("Unexpected packet of type %1.") + .arg(m_incomingPacket.type())); + } + (this->*it.value().second)(); +} -private: - virtual void run() - { - while (true) { - m_mutex.lock(); - if (m_stopRequested) { - m_mutex.unlock(); - return; - } - const int channel = m_conn->d->conn.channel(); - if (!m_dataAvailable || channel == -1) - m_waitCond.wait(&m_mutex); - m_dataAvailable = false; - m_mutex.unlock(); - QScopedPointer > - output(m_conn->d->conn.ssh->readAndReset(channel, alloc)); - if (output) { - m_conn->d->mutex.lock(); - m_conn->d->remoteOutput += output.data(); - emit m_conn->remoteOutputAvailable(); - m_conn->d->mutex.unlock(); - } +void SshConnectionPrivate::handleKeyExchangeInitPacket() +{ + // If the server sends a guessed packet, the guess must be wrong, + // because the algorithms we support requires us to initiate the + // key exchange. + if (m_keyExchange->sendDhInitPacket(m_incomingPacket)) + m_ignoreNextPacket = true; + m_state = KeyExchangeStarted; +} + +void SshConnectionPrivate::handleKeyExchangeReplyPacket() +{ + m_keyExchange->sendNewKeysPacket(m_incomingPacket, + ClientId.left(ClientId.size() - 2)); + m_sendFacility.recreateKeys(*m_keyExchange); + m_state = KeyExchangeSuccess; +} + +void SshConnectionPrivate::handleNewKeysPacket() +{ + m_incomingPacket.recreateKeys(*m_keyExchange); + m_keyExchange.reset(); + m_sendFacility.sendUserAuthServiceRequestPacket(); + m_state = UserAuthServiceRequested; +} + +void SshConnectionPrivate::handleServiceAcceptPacket() +{ + if (m_connParams.authType == SshConnectionParameters::AuthByPwd) { + m_sendFacility.sendUserAuthByPwdRequestPacket(m_connParams.uname.toUtf8(), + SshCapabilities::SshConnectionService, m_connParams.pwd.toUtf8()); + } else { + QFile privKeyFile(m_connParams.privateKeyFile); + bool couldOpen = privKeyFile.open(QIODevice::ReadOnly); + QByteArray contents; + if (couldOpen) + contents = privKeyFile.readAll(); + if (!couldOpen || privKeyFile.error() != QFile::NoError) { + throw SshClientException(SshKeyFileError, + tr("Could not read private key file: %1") + .arg(privKeyFile.errorString())); } + + m_sendFacility.createAuthenticationKey(contents); + m_sendFacility.sendUserAuthByKeyRequestPacket(m_connParams.uname.toUtf8(), + SshCapabilities::SshConnectionService); + } + m_state = UserAuthRequested; +} + +void SshConnectionPrivate::handlePasswordExpiredPacket() +{ + if (m_connParams.authType == SshConnectionParameters::AuthByKey) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Got SSH_MSG_USERAUTH_PASSWD_CHANGEREQ, but did not use password."); } - InteractiveSshConnection *m_conn; - bool m_stopRequested; - bool m_dataAvailable; - QMutex m_mutex; - QWaitCondition m_waitCond; -}; + throw SshClientException(SshAuthenticationError, tr("Password expired.")); +} + +void SshConnectionPrivate::handleUserAuthBannerPacket() +{ + emit dataAvailable(m_incomingPacket.extractUserAuthBanner().message); +} + +void SshConnectionPrivate::handleGlobalRequest() +{ + m_sendFacility.sendRequestFailurePacket(); +} + +void SshConnectionPrivate::handleUserAuthSuccessPacket() +{ + m_state = ConnectionEstablished; + m_timeoutTimer.stop(); + emit connected(); +} + +void SshConnectionPrivate::handleUserAuthFailurePacket() +{ + const QString errorMsg = m_connParams.authType == SshConnectionParameters::AuthByPwd + ? tr("Server rejected password.") : tr("Server rejected key."); + throw SshClientException(SshAuthenticationError, errorMsg); +} +void SshConnectionPrivate::handleDebugPacket() +{ + const SshDebug &msg = m_incomingPacket.extractDebug(); + if (msg.display) + emit dataAvailable(msg.message); +} + +void SshConnectionPrivate::handleChannelRequest() +{ + m_channelManager->handleChannelRequest(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelOpen() +{ + m_channelManager->handleChannelOpen(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelOpenFailure() +{ + m_channelManager->handleChannelOpenFailure(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelOpenConfirmation() +{ + m_channelManager->handleChannelOpenConfirmation(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelSuccess() +{ + m_channelManager->handleChannelSuccess(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelFailure() +{ + m_channelManager->handleChannelFailure(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelWindowAdjust() +{ + m_channelManager->handleChannelWindowAdjust(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelData() +{ + m_channelManager->handleChannelData(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelExtendedData() +{ + m_channelManager->handleChannelExtendedData(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelEof() +{ + m_channelManager->handleChannelEof(m_incomingPacket); +} + +void SshConnectionPrivate::handleChannelClose() +{ + m_channelManager->handleChannelClose(m_incomingPacket); +} + +void SshConnectionPrivate::handleDisconnect() +{ + const SshDisconnect msg = m_incomingPacket.extractDisconnect(); + throw SshServerException(SSH_DISCONNECT_CONNECTION_LOST, + "", tr("Server closed connection: %1").arg(msg.description)); +} + +void SshConnectionPrivate::sendData(const QByteArray &data) +{ + m_socket->write(data); +} + +void SshConnectionPrivate::handleSocketDisconnected() +{ + closeConnection(SSH_DISCONNECT_CONNECTION_LOST, SshClosedByServerError, + "Connection closed unexpectedly.", + tr("Connection closed unexpectedly.")); +} + +void SshConnectionPrivate::handleSocketError() +{ + if (m_error == SshNoError) { + closeConnection(SSH_DISCONNECT_CONNECTION_LOST, SshSocketError, + "Network error", m_socket->errorString()); + } +} + +void SshConnectionPrivate::handleTimeout() +{ + if (m_state != ConnectionEstablished) + closeConnection(SSH_DISCONNECT_BY_APPLICATION, SshTimeoutError, "", + tr("Connection timed out.")); +} + +void SshConnectionPrivate::connectToHost(const SshConnectionParameters &serverInfo) +{ + m_incomingData.clear(); + m_incomingPacket.reset(); + m_sendFacility.reset(); + m_error = SshNoError; + m_ignoreNextPacket = false; + m_errorString.clear(); + connect(m_socket, SIGNAL(connected()), this, SLOT(handleSocketConnected())); + connect(m_socket, SIGNAL(readyRead()), this, SLOT(handleIncomingData())); + connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, + SLOT(handleSocketError())); + connect(m_socket, SIGNAL(disconnected()), this, + SLOT(handleSocketDisconnected())); + this->m_connParams = serverInfo; + m_state = SocketConnecting; + m_timeoutTimer.start(m_connParams.timeout * 1000); + m_socket->connectToHost(serverInfo.host, serverInfo.port); +} + +void SshConnectionPrivate::closeConnection(SshErrorCode sshError, + SshError userError, const QByteArray &serverErrorString, + const QString &userErrorString) +{ + // Prevent endless loops by recursive exceptions. + if (m_state == SocketUnconnected || m_error != SshNoError) + return; + + m_error = userError; + m_errorString = userErrorString; + m_timeoutTimer.stop(); + disconnect(m_socket, 0, this, 0); + try { + m_channelManager->closeAllChannels(); + m_sendFacility.sendDisconnectPacket(sshError, serverErrorString); + } catch (Botan::Exception &) {} // Nothing sensible to be done here. + if (m_error != SshNoError) + emit error(userError); + if (m_state == ConnectionEstablished) + emit disconnected(); + m_socket->disconnectFromHost(); + m_state = SocketUnconnected; +} + +QSharedPointer SshConnectionPrivate::createRemoteProcess(const QByteArray &command) +{ + return m_channelManager->createRemoteProcess(command); +} + +QSharedPointer SshConnectionPrivate::createSftpChannel() +{ + return m_channelManager->createSftpChannel(); +} } // namespace Internal - - -namespace { - -void wakeupReader(void *opaqueReader) -{ - static_cast(opaqueReader)->dataAvailable(); -} - -} // Anonymous namespace - - -InteractiveSshConnection::InteractiveSshConnection(const SshServerInfo &server) - : d(new Internal::InteractiveSshConnectionPrivate(server)) -{ - d->outputReader = new Internal::ConnectionOutputReader(this); -} - -InteractiveSshConnection::~InteractiveSshConnection() -{ - d->conn.ssh->send("exit\n", d->conn.channel()); - quit(); - delete d; -} - -bool InteractiveSshConnection::start() -{ - if (isConnected()) - return true; - - if (!d->conn.start(true, wakeupReader, d->outputReader)) - return false; - - d->outputReader->start(); - return true; -} - -bool InteractiveSshConnection::sendInput(const QByteArray &input) -{ - if (!d->conn.ssh->send(input.data(), d->conn.channel())) { - d->conn.setError(tr("Error sending input"), true); - return false; - } - return true; -} - -void InteractiveSshConnection::quit() -{ - d->mutex.lock(); - d->waitCond.wakeOne(); - d->mutex.unlock(); - d->outputReader->stop(); - d->conn.quit(); -} - -QByteArray InteractiveSshConnection::waitForRemoteOutput(int msecs) -{ - d->mutex.lock(); - if (d->remoteOutput.isEmpty()) - d->waitCond.wait(&d->mutex, msecs == -1 ? ULONG_MAX : msecs); - const QByteArray remoteOutput = d->remoteOutput; - d->remoteOutput.clear(); - d->mutex.unlock(); - return remoteOutput; -} - - -InteractiveSshConnection::Ptr InteractiveSshConnection::create(const SshServerInfo &server) -{ - return Ptr(new InteractiveSshConnection(server)); -} - -bool InteractiveSshConnection::isConnected() const -{ - return d->conn.isConnected(); -} - -bool InteractiveSshConnection::hasError() const -{ - return d->conn.hasError(); -} - -QString InteractiveSshConnection::error() const -{ - return d->conn.error(); -} - - -namespace { - -class FileMgr -{ -public: - FileMgr(const QString &filePath, const char *mode) - : m_file(fopen(filePath.toLatin1().data(), mode)) {} - ~FileMgr() { if (m_file) fclose(m_file); } - FILE *file() const { return m_file; } -private: - FILE * const m_file; -}; - -} // Anonymous namespace - -SftpConnection::SftpConnection(const SshServerInfo &server) - : d(new Internal::NonInteractiveSshConnectionPrivate(server)) -{ } - -SftpConnection::~SftpConnection() -{ - quit(); - delete d; -} - -bool SftpConnection::start() -{ - if (isConnected()) - return true; - if (!d->conn.start(false, 0, 0)) - return false; - if (!d->conn.ssh->initSftp(d->sftp, d->conn.channel()) - || !d->sftp.setTimeout(d->conn.server().timeout)) { - d->conn.setError(tr("Error setting up SFTP subsystem"), true); - quit(); - return false; - } - return true; -} - -bool SftpConnection::transferFiles(const QList &transferList) -{ - for (int i = 0; i < transferList.count(); ++i) { - const SftpTransferInfo &transfer = transferList.at(i); - bool success; - if (transfer.type == SftpTransferInfo::Upload) { - success = upload(transfer.localFilePath, transfer.remoteFilePath); - } else { - success = download(transfer.remoteFilePath, transfer.localFilePath); - } - if (!success) - return false; - } - - return true; -} - -bool SftpConnection::upload(const QString &localFilePath, - const QByteArray &remoteFilePath) -{ - FileMgr fileMgr(localFilePath, "rb"); - if (!fileMgr.file()) { - d->conn.setError(tr("Could not open file '%1'").arg(localFilePath), - false); - return false; - } - - if (!d->sftp.put(fileMgr.file(), remoteFilePath.data())) { - d->conn.setError(tr("Could not uplodad file '%1'") - .arg(localFilePath), true); - return false; - } - - emit fileCopied(localFilePath); - return true; -} - -bool SftpConnection::download(const QByteArray &remoteFilePath, - const QString &localFilePath) -{ - FileMgr fileMgr(localFilePath, "wb"); - if (!fileMgr.file()) { - d->conn.setError(tr("Could not open file '%1'").arg(localFilePath), - false); - return false; - } - - if (!d->sftp.get(remoteFilePath.data(), fileMgr.file())) { - d->conn.setError(tr("Could not copy remote file '%1' to local file '%2'") - .arg(remoteFilePath, localFilePath), false); - return false; - } - - emit fileCopied(remoteFilePath); - return true; -} - -bool SftpConnection::createRemoteDir(const QByteArray &remoteDir) -{ - if (!d->sftp.mkdir(remoteDir.data())) { - d->conn.setError(tr("Could not create remote directory"), true); - return false; - } - return true; -} - -bool SftpConnection::removeRemoteDir(const QByteArray &remoteDir) -{ - if (!d->sftp.rmdir(remoteDir.data())) { - d->conn.setError(tr("Could not remove remote directory"), true); - return false; - } - return true; -} - -QByteArray SftpConnection::listRemoteDirContents(const QByteArray &remoteDir, - bool withAttributes, bool &ok) -{ - const char * const buffer = d->sftp.ls(remoteDir.data(), withAttributes); - if (!buffer) { - d->conn.setError(tr("Could not get remote directory contents"), true); - ok = false; - return QByteArray(); - } - ok = true; - return QByteArray(buffer); -} - -bool SftpConnection::removeRemoteFile(const QByteArray &remoteFile) -{ - if (!d->sftp.rm(remoteFile.data())) { - d->conn.setError(tr("Could not remove remote file"), true); - return false; - } - return true; -} - -bool SftpConnection::changeRemoteWorkingDir(const QByteArray &newRemoteDir) -{ - if (!d->sftp.cd(newRemoteDir.data())) { - d->conn.setError(tr("Could not change remote working directory"), true); - return false; - } - return true; -} - -void SftpConnection::quit() -{ - d->conn.quit(); -} - -bool SftpConnection::isConnected() const -{ - return d->conn.isConnected(); -} - -bool SftpConnection::hasError() const -{ - return d->conn.hasError(); -} - -QString SftpConnection::error() const -{ - return d->conn.error(); -} - -SftpConnection::Ptr SftpConnection::create(const SshServerInfo &server) -{ - return Ptr(new SftpConnection(server)); -} - } // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshconnection.h b/src/plugins/coreplugin/ssh/sshconnection.h index 8c7b59f594b..e7f73995a4a 100644 --- a/src/plugins/coreplugin/ssh/sshconnection.h +++ b/src/plugins/coreplugin/ssh/sshconnection.h @@ -1,19 +1,20 @@ -/**************************************************************************** +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of Qt Creator. +** Commercial Usage ** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** ** 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 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -21,27 +22,16 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +**************************************************************************/ #ifndef SSHCONNECTION_H #define SSHCONNECTION_H +#include "ssherrors.h" + #include #include @@ -50,14 +40,14 @@ #include namespace Core { +class SftpChannel; +class SshRemoteProcess; namespace Internal { - struct InteractiveSshConnectionPrivate; - struct NonInteractiveSshConnectionPrivate; - class ConnectionOutputReader; -} +class SshConnectionPrivate; +} // namespace Internal -struct CORE_EXPORT SshServerInfo +struct CORE_EXPORT SshConnectionParameters { QString host; QString uname; @@ -69,85 +59,44 @@ struct CORE_EXPORT SshServerInfo }; -class CORE_EXPORT InteractiveSshConnection : public QObject +/* + * This class provides an SSH connection, implementing protocol version 2.0 + * It can spawn channels for remote execution and SFTP operations (version 3). + * It operates asynchronously (non-blocking) and is not thread-safe. + */ +class CORE_EXPORT SshConnection : public QObject { Q_OBJECT - Q_DISABLE_COPY(InteractiveSshConnection) - friend class Internal::ConnectionOutputReader; + Q_DISABLE_COPY(SshConnection) public: - typedef QSharedPointer Ptr; + enum State { Unconnected, Connecting, Connected }; + typedef QSharedPointer Ptr; - static Ptr create(const SshServerInfo &server); + static Ptr create(); - bool start(); - void quit(); - bool isConnected() const; - bool sendInput(const QByteArray &input); // Should normally end in newline. - QByteArray waitForRemoteOutput(int msecs = -1); - bool hasError() const; - QString error() const; - ~InteractiveSshConnection(); + void connectToHost(const SshConnectionParameters &serverInfo); + void disconnectFromHost(); + State state() const; + SshError errorState() const; + QString errorString() const; + SshConnectionParameters connectionParameters() const; + ~SshConnection(); + + QSharedPointer createRemoteProcess(const QByteArray &command); + QSharedPointer createSftpChannel(); signals: - void remoteOutputAvailable(); + void connected(); + void disconnected(); + void dataAvailable(const QString &message); + void error(SshError); private: - InteractiveSshConnection(const SshServerInfo &server); + SshConnection(); - struct Internal::InteractiveSshConnectionPrivate *d; + Internal::SshConnectionPrivate *d; }; - -struct CORE_EXPORT SftpTransferInfo -{ - enum Type { Upload, Download }; - - SftpTransferInfo(const QString &localFilePath, - const QByteArray &remoteFilePath, Type type) - : localFilePath(localFilePath), - remoteFilePath(remoteFilePath), - type(type) - { - } - - QString localFilePath; - QByteArray remoteFilePath; - Type type; -}; - -class CORE_EXPORT SftpConnection : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY(SftpConnection) -public: - typedef QSharedPointer Ptr; - - static Ptr create(const SshServerInfo &server); - bool start(); - void quit(); - bool isConnected() const; - bool hasError() const; - QString error() const; - bool upload(const QString &localFilePath, const QByteArray &remoteFilePath); - bool download(const QByteArray &remoteFilePath, const QString &localFilePath); - bool transferFiles(const QList &transferList); - bool createRemoteDir(const QByteArray &remoteDir); - bool removeRemoteDir(const QByteArray &remoteDir); - bool removeRemoteFile(const QByteArray &remoteFile); - bool changeRemoteWorkingDir(const QByteArray &newRemoteDir); - QByteArray listRemoteDirContents(const QByteArray &remoteDir, - bool withAttributes, bool &ok); - ~SftpConnection(); - -signals: - void fileCopied(const QString &filePath); - -private: - SftpConnection(const SshServerInfo &server); - - Internal::NonInteractiveSshConnectionPrivate *d; -}; - -} // namespace Core +} // namespace Internal #endif // SSHCONNECTION_H diff --git a/src/plugins/coreplugin/ssh/sshconnection_p.h b/src/plugins/coreplugin/ssh/sshconnection_p.h new file mode 100644 index 00000000000..c20ccf78b52 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshconnection_p.h @@ -0,0 +1,157 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHCONNECTION_P_H +#define SSHCONNECTION_P_H + +#include "sshconnection.h" +#include "sshexception_p.h" +#include "sshincomingpacket_p.h" +#include "sshremoteprocess.h" +#include "sshsendfacility_p.h" + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QTcpSocket; +QT_END_NAMESPACE + +namespace Botan { class Exception; } + +namespace Core { +class SftpChannel; + +namespace Internal { +class SshChannelManager; + +// NOTE: When you add stuff here, don't forget to update m_packetHandlers. +enum SshStateInternal { + SocketUnconnected, // initial and after disconnect + SocketConnecting, // After connectToHost() + SocketConnected, // After socket's connected() signal + KeyExchangeStarted, // After server's KEXINIT message + KeyExchangeSuccess, // After server's DH_REPLY message + UserAuthServiceRequested, + UserAuthRequested, + + ConnectionEstablished // After service has been started + // ... +}; + +class SshConnectionPrivate : public QObject +{ + Q_OBJECT + friend class Core::SshConnection; +public: + SshConnectionPrivate(SshConnection *conn); + ~SshConnectionPrivate(); + + void connectToHost(const SshConnectionParameters &serverInfo); + void closeConnection(SshErrorCode sshError, SshError userError, + const QByteArray &serverErrorString, const QString &userErrorString); + QSharedPointer createRemoteProcess(const QByteArray &command); + QSharedPointer createSftpChannel(); + SshStateInternal state() const { return m_state; } + SshError error() const { return m_error; } + QString errorString() const { return m_errorString; } + +signals: + void connected(); + void disconnected(); + void dataAvailable(const QString &message); + void error(SshError); + +private: + Q_SLOT void handleSocketConnected(); + Q_SLOT void handleIncomingData(); + Q_SLOT void handleSocketError(); + Q_SLOT void handleSocketDisconnected(); + Q_SLOT void handleTimeout(); + + void handleServerId(); + void handlePackets(); + void handleCurrentPacket(); + void handleKeyExchangeInitPacket(); + void handleKeyExchangeReplyPacket(); + void handleNewKeysPacket(); + void handleServiceAcceptPacket(); + void handlePasswordExpiredPacket(); + void handleUserAuthSuccessPacket(); + void handleUserAuthFailurePacket(); + void handleUserAuthBannerPacket(); + void handleGlobalRequest(); + void handleDebugPacket(); + void handleChannelRequest(); + void handleChannelOpen(); + void handleChannelOpenFailure(); + void handleChannelOpenConfirmation(); + void handleChannelSuccess(); + void handleChannelFailure(); + void handleChannelWindowAdjust(); + void handleChannelData(); + void handleChannelExtendedData(); + void handleChannelEof(); + void handleChannelClose(); + void handleDisconnect(); + + void sendData(const QByteArray &data); + + typedef void (SshConnectionPrivate::*PacketHandler)(); + typedef QList StateList; + void setupPacketHandlers(); + void setupPacketHandler(SshPacketType type, const StateList &states, + PacketHandler handler); + + typedef QPair HandlerInStates; + QHash m_packetHandlers; + + QTcpSocket *m_socket; + SshStateInternal m_state; + SshIncomingPacket m_incomingPacket; + SshSendFacility m_sendFacility; + QScopedPointer m_channelManager; + SshConnectionParameters m_connParams; + QByteArray m_incomingData; + SshError m_error; + QString m_errorString; + QScopedPointer m_keyExchange; + QTimer m_timeoutTimer; + bool m_ignoreNextPacket; + SshConnection *m_conn; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHCONNECTION_P_H diff --git a/src/plugins/coreplugin/ssh/sshcryptofacility.cpp b/src/plugins/coreplugin/ssh/sshcryptofacility.cpp new file mode 100644 index 00000000000..fd2fe320444 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshcryptofacility.cpp @@ -0,0 +1,369 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshcryptofacility_p.h" + +#include "sshbotanconversions_p.h" +#include "sshcapabilities_p.h" +#include "sshexception_p.h" +#include "sshkeyexchange_p.h" +#include "sshpacket_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +using namespace Botan; + +namespace Core { +namespace Internal { + +SshAbstractCryptoFacility::SshAbstractCryptoFacility() + : m_cipherBlockSize(0), m_macLength(0) +{ +} + +SshAbstractCryptoFacility::~SshAbstractCryptoFacility() {} + +void SshAbstractCryptoFacility::clearKeys() +{ + m_cipherBlockSize = 0; + m_macLength = 0; + m_sessionId.clear(); + m_pipe.reset(0); + m_hMac.reset(0); +} + +void SshAbstractCryptoFacility::recreateKeys(const SshKeyExchange &kex) +{ + checkInvariant(); + + if (m_sessionId.isEmpty()) + m_sessionId = kex.h(); + Algorithm_Factory &af = global_state().algorithm_factory(); + const std::string &cryptAlgo = botanCryptAlgoName(cryptAlgoName(kex)); + BlockCipher * const cipher = af.prototype_block_cipher(cryptAlgo)->clone(); + + m_cipherBlockSize = cipher->BLOCK_SIZE; + const QByteArray ivData = generateHash(kex, ivChar(), m_cipherBlockSize); + const InitializationVector iv(convertByteArray(ivData), m_cipherBlockSize); + + const quint32 keySize = max_keylength_of(cryptAlgo); + const QByteArray cryptKeyData = generateHash(kex, keyChar(), keySize); + SymmetricKey cryptKey(convertByteArray(cryptKeyData), keySize); + + BlockCipherMode * const cipherMode + = makeCipherMode(cipher, new Null_Padding, iv, cryptKey); + m_pipe.reset(new Pipe(cipherMode)); + + m_macLength = botanHMacKeyLen(hMacAlgoName(kex)); + const QByteArray hMacKeyData = generateHash(kex, macChar(), macLength()); + SymmetricKey hMacKey(convertByteArray(hMacKeyData), macLength()); + const HashFunction * const hMacProto + = af.prototype_hash_function(botanHMacAlgoName(hMacAlgoName(kex))); + m_hMac.reset(new HMAC(hMacProto->clone())); + m_hMac->set_key(hMacKey); +} + +void SshAbstractCryptoFacility::convert(QByteArray &data, quint32 offset, + quint32 dataSize) const +{ + Q_ASSERT(offset + dataSize <= static_cast(data.size())); + checkInvariant(); + + // Session id empty => No key exchange has happened yet. + if (dataSize == 0 || m_sessionId.isEmpty()) + return; + + if (dataSize % cipherBlockSize() != 0) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid packet size"); + } + m_pipe->process_msg(reinterpret_cast(data.constData()) + offset, + dataSize); + quint32 bytesRead = m_pipe->read(reinterpret_cast(data.data()) + offset, + dataSize, m_pipe->message_count() - 1); // Can't use Pipe::LAST_MESSAGE because of a VC bug. + Q_ASSERT(bytesRead == dataSize); +} + +QByteArray SshAbstractCryptoFacility::generateMac(const QByteArray &data, + quint32 dataSize) const +{ + return m_sessionId.isEmpty() + ? QByteArray() + : convertByteArray(m_hMac->process(reinterpret_cast(data.constData()), + dataSize)); +} + +QByteArray SshAbstractCryptoFacility::generateHash(const SshKeyExchange &kex, + char c, quint32 length) +{ + const QByteArray &k = kex.k(); + const QByteArray &h = kex.h(); + QByteArray data(k); + data.append(h).append(c).append(m_sessionId); + SecureVector key + = kex.hash()->process(convertByteArray(data), data.size()); + while (key.size() < length) { + SecureVector tmpKey; + tmpKey.append(convertByteArray(k), k.size()); + tmpKey.append(convertByteArray(h), h.size()); + tmpKey.append(key); + key.append(kex.hash()->process(tmpKey)); + } + return QByteArray(reinterpret_cast(key.begin()), length); +} + +void SshAbstractCryptoFacility::checkInvariant() const +{ + Q_ASSERT(m_sessionId.isEmpty() == !m_pipe); +} + + +const QByteArray SshEncryptionFacility::PrivKeyFileStartLineRsa("-----BEGIN RSA PRIVATE KEY-----"); +const QByteArray SshEncryptionFacility::PrivKeyFileStartLineDsa("-----BEGIN DSA PRIVATE KEY-----"); +const QByteArray SshEncryptionFacility::PrivKeyFileEndLineRsa("-----END RSA PRIVATE KEY-----"); +const QByteArray SshEncryptionFacility::PrivKeyFileEndLineDsa("-----END DSA PRIVATE KEY-----"); + +QByteArray SshEncryptionFacility::cryptAlgoName(const SshKeyExchange &kex) const +{ + return kex.encryptionAlgo(); +} + +QByteArray SshEncryptionFacility::hMacAlgoName(const SshKeyExchange &kex) const +{ + return kex.hMacAlgoClientToServer(); +} + +BlockCipherMode *SshEncryptionFacility::makeCipherMode(BlockCipher *cipher, + BlockCipherModePaddingMethod *paddingMethod, const InitializationVector &iv, + const SymmetricKey &key) +{ + return new CBC_Encryption(cipher, paddingMethod, key, iv); +} + +void SshEncryptionFacility::encrypt(QByteArray &data) const +{ + convert(data, 0, data.size()); +} + +void SshEncryptionFacility::createAuthenticationKey(const QByteArray &privKeyFileContents) +{ + if (privKeyFileContents == m_cachedPrivKeyContents) + return; + +#ifdef CREATOR_SSH_DEBUG + qDebug("%s: Key not cached, reading", Q_FUNC_INFO); +#endif + QList pubKeyParams; + QList allKeyParams; + try { + createAuthenticationKeyFromPKCS8(privKeyFileContents, pubKeyParams, + allKeyParams); + } catch (Botan::Exception &) { + createAuthenticationKeyFromOpenSSL(privKeyFileContents, pubKeyParams, + allKeyParams); + } + + foreach (const BigInt &b, allKeyParams) { + if (b.is_zero()) { + throw SshClientException(SshKeyFileError, + SSH_TR("Decoding of private key file failed.")); + } + } + + m_authPubKeyBlob = AbstractSshPacket::encodeString(m_authKeyAlgoName); + foreach (const BigInt &b, pubKeyParams) + m_authPubKeyBlob += AbstractSshPacket::encodeMpInt(b); + m_cachedPrivKeyContents = privKeyFileContents; +} + +void SshEncryptionFacility::createAuthenticationKeyFromPKCS8(const QByteArray &privKeyFileContents, + QList &pubKeyParams, QList &allKeyParams) +{ + Pipe pipe; + pipe.process_msg(convertByteArray(privKeyFileContents), + privKeyFileContents.size()); + Private_Key * const key = PKCS8::load_key(pipe, m_rng); + if (DSA_PrivateKey * const dsaKey = dynamic_cast(key)) { + m_authKey.reset(dsaKey); + pubKeyParams << dsaKey->group_p() << dsaKey->group_q() + << dsaKey->group_g() << dsaKey->get_y(); + allKeyParams << pubKeyParams << dsaKey->get_x(); + } else if (RSA_PrivateKey * const rsaKey = dynamic_cast(key)) { + m_authKey.reset(rsaKey); + pubKeyParams << rsaKey->get_e() << rsaKey->get_n(); + allKeyParams << pubKeyParams << rsaKey->get_p() << rsaKey->get_q() + << rsaKey->get_d(); + } else { + throw Botan::Exception(); + } +} + +void SshEncryptionFacility::createAuthenticationKeyFromOpenSSL(const QByteArray &privKeyFileContents, + QList &pubKeyParams, QList &allKeyParams) +{ + bool syntaxOk = true; + QList lines = privKeyFileContents.split('\n'); + while (lines.last().isEmpty()) + lines.removeLast(); + if (lines.count() < 3) { + syntaxOk = false; + } else if (lines.first() == PrivKeyFileStartLineRsa) { + if (lines.last() != PrivKeyFileEndLineRsa) + syntaxOk =false; + else + m_authKeyAlgoName = SshCapabilities::PubKeyRsa; + } else if (lines.first() == PrivKeyFileStartLineDsa) { + if (lines.last() != PrivKeyFileEndLineDsa) + syntaxOk = false; + else + m_authKeyAlgoName = SshCapabilities::PubKeyDss; + } else { + syntaxOk = false; + } + if (!syntaxOk) { + throw SshClientException(SshKeyFileError, + SSH_TR("Private key file has unexpected format.")); + } + + QByteArray privateKeyBlob; + for (int i = 1; i < lines.size() - 1; ++i) + privateKeyBlob += lines.at(i); + privateKeyBlob = QByteArray::fromBase64(privateKeyBlob); + + BER_Decoder decoder(convertByteArray(privateKeyBlob), + privateKeyBlob.size()); + BER_Decoder sequence = decoder.start_cons(SEQUENCE); + quint32 version; + sequence.decode (version); + if (version != 0) { + throw SshClientException(SshKeyFileError, + SSH_TR("Private key encoding has version %1, expected 0.") + .arg(version)); + } + + if (m_authKeyAlgoName == SshCapabilities::PubKeyDss) { + BigInt p, q, g, y, x; + sequence.decode (p).decode (q).decode (g).decode (y).decode (x); + DSA_PrivateKey * const dsaKey + = new DSA_PrivateKey(m_rng, DL_Group(p, q, g), x); + m_authKey.reset(dsaKey); + pubKeyParams << p << q << g << y; + allKeyParams << pubKeyParams << x; + } else { + BigInt p, q, e, d, n; + sequence.decode (n).decode (e).decode (d).decode (p).decode (q); + RSA_PrivateKey * const rsaKey + = new RSA_PrivateKey (m_rng, p, q, e, d, n); + m_authKey.reset(rsaKey); + pubKeyParams << e << n; + allKeyParams << pubKeyParams << p << q << d; + } + + sequence.discard_remaining(); + sequence.verify_end(); +} + +QByteArray SshEncryptionFacility::authenticationAlgorithmName() const +{ + Q_ASSERT(m_authKey); + return m_authKeyAlgoName; +} + +QByteArray SshEncryptionFacility::authenticationKeySignature(const QByteArray &data) const +{ + Q_ASSERT(m_authKey); + + QScopedPointer signer(get_pk_signer (*m_authKey, + botanEmsaAlgoName(m_authKeyAlgoName))); + QByteArray dataToSign = AbstractSshPacket::encodeString(sessionId()) + data; + QByteArray signature + = convertByteArray(signer->sign_message(convertByteArray(dataToSign), + dataToSign.size(), m_rng)); + return AbstractSshPacket::encodeString(m_authKeyAlgoName) + + AbstractSshPacket::encodeString(signature); +} + +QByteArray SshEncryptionFacility::getRandomNumbers(int count) const +{ + QByteArray data; + data.resize(count); + m_rng.randomize(convertByteArray(data), count); + return data; +} + +SshEncryptionFacility::~SshEncryptionFacility() {} + + +QByteArray SshDecryptionFacility::cryptAlgoName(const SshKeyExchange &kex) const +{ + return kex.decryptionAlgo(); +} + +QByteArray SshDecryptionFacility::hMacAlgoName(const SshKeyExchange &kex) const +{ + return kex.hMacAlgoServerToClient(); +} + +BlockCipherMode *SshDecryptionFacility::makeCipherMode(BlockCipher *cipher, + BlockCipherModePaddingMethod *paddingMethod, const InitializationVector &iv, + const SymmetricKey &key) +{ + return new CBC_Decryption(cipher, paddingMethod, key, iv); +} + +void SshDecryptionFacility::decrypt(QByteArray &data, quint32 offset, + quint32 dataSize) const +{ + convert(data, offset, dataSize); +#ifdef CREATOR_SSH_DEBUG + qDebug("Decrypted data:"); + const char * const start = data.constData() + offset; + const char * const end = start + dataSize; + for (const char *c = start; c < end; ++c) + qDebug() << "'" << *c << "' (0x" << (static_cast(*c) & 0xff) << ")"; +#endif +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshcryptofacility_p.h b/src/plugins/coreplugin/ssh/sshcryptofacility_p.h new file mode 100644 index 00000000000..f60e6d4b8de --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshcryptofacility_p.h @@ -0,0 +1,154 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHABSTRACTCRYPTOFACILITY_P_H +#define SSHABSTRACTCRYPTOFACILITY_P_H + +#include +#include + +#include +#include + +namespace Botan { + class BigInt; + class BlockCipher; + class BlockCipherMode; + class BlockCipherModePaddingMethod; + class HashFunction; + class HMAC; + class Pipe; + class PK_Signing_Key; +} + +namespace Core { +namespace Internal { + +class SshKeyExchange; + +class SshAbstractCryptoFacility +{ +public: + virtual ~SshAbstractCryptoFacility(); + + void clearKeys(); + void recreateKeys(const SshKeyExchange &kex); + QByteArray generateMac(const QByteArray &data, quint32 dataSize) const; + quint32 cipherBlockSize() const { return m_cipherBlockSize; } + quint32 macLength() const { return m_macLength; } + +protected: + SshAbstractCryptoFacility(); + void convert(QByteArray &data, quint32 offset, quint32 dataSize) const; + QByteArray sessionId() const { return m_sessionId; } + +private: + SshAbstractCryptoFacility(const SshAbstractCryptoFacility &); + SshAbstractCryptoFacility &operator=(const SshAbstractCryptoFacility &); + + virtual QByteArray cryptAlgoName(const SshKeyExchange &kex) const=0; + virtual QByteArray hMacAlgoName(const SshKeyExchange &kex) const=0; + virtual Botan::BlockCipherMode *makeCipherMode(Botan::BlockCipher *cipher, + Botan::BlockCipherModePaddingMethod *paddingMethod, + const Botan::InitializationVector &iv, + const Botan::SymmetricKey &key)=0; + virtual char ivChar() const=0; + virtual char keyChar() const=0; + virtual char macChar() const=0; + + QByteArray generateHash(const SshKeyExchange &kex, char c, quint32 length); + void checkInvariant() const; + + QByteArray m_sessionId; + QScopedPointer m_pipe; + QScopedPointer m_hMac; + quint32 m_cipherBlockSize; + quint32 m_macLength; +}; + +class SshEncryptionFacility : public SshAbstractCryptoFacility +{ +public: + void encrypt(QByteArray &data) const; + + void createAuthenticationKey(const QByteArray &privKeyFileContents); + QByteArray authenticationAlgorithmName() const; + QByteArray authenticationPublicKey() const { return m_authPubKeyBlob; } + QByteArray authenticationKeySignature(const QByteArray &data) const; + QByteArray getRandomNumbers(int count) const; + + ~SshEncryptionFacility(); + +private: + virtual QByteArray cryptAlgoName(const SshKeyExchange &kex) const; + virtual QByteArray hMacAlgoName(const SshKeyExchange &kex) const; + virtual Botan::BlockCipherMode *makeCipherMode(Botan::BlockCipher *cipher, + Botan::BlockCipherModePaddingMethod *paddingMethod, + const Botan::InitializationVector &iv, const Botan::SymmetricKey &key); + virtual char ivChar() const { return 'A'; } + virtual char keyChar() const { return 'C'; } + virtual char macChar() const { return 'E'; } + + void createAuthenticationKeyFromPKCS8(const QByteArray &privKeyFileContents, + QList &pubKeyParams, QList &allKeyParams); + void createAuthenticationKeyFromOpenSSL(const QByteArray &privKeyFileContents, + QList &pubKeyParams, QList &allKeyParams); + + static const QByteArray PrivKeyFileStartLineRsa; + static const QByteArray PrivKeyFileStartLineDsa; + static const QByteArray PrivKeyFileEndLineRsa; + static const QByteArray PrivKeyFileEndLineDsa; + + QByteArray m_authKeyAlgoName; + QByteArray m_authPubKeyBlob; + QByteArray m_cachedPrivKeyContents; + QScopedPointer m_authKey; + mutable Botan::AutoSeeded_RNG m_rng; +}; + +class SshDecryptionFacility : public SshAbstractCryptoFacility +{ +public: + void decrypt(QByteArray &data, quint32 offset, quint32 dataSize) const; + +private: + virtual QByteArray cryptAlgoName(const SshKeyExchange &kex) const; + virtual QByteArray hMacAlgoName(const SshKeyExchange &kex) const; + virtual Botan::BlockCipherMode *makeCipherMode(Botan::BlockCipher *cipher, + Botan::BlockCipherModePaddingMethod *paddingMethod, + const Botan::InitializationVector &iv, const Botan::SymmetricKey &key); + virtual char ivChar() const { return 'B'; } + virtual char keyChar() const { return 'D'; } + virtual char macChar() const { return 'F'; } +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHABSTRACTCRYPTOFACILITY_P_H diff --git a/src/plugins/coreplugin/ssh/sshdelayedsignal.cpp b/src/plugins/coreplugin/ssh/sshdelayedsignal.cpp new file mode 100644 index 00000000000..d35075bf77f --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshdelayedsignal.cpp @@ -0,0 +1,165 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshdelayedsignal_p.h" + +#include "sftpchannel_p.h" +#include "sshremoteprocess_p.h" + +#include + +namespace Core { +namespace Internal { + +SshDelayedSignal::SshDelayedSignal(const QWeakPointer &checkObject) + : m_checkObject(checkObject) +{ + QTimer::singleShot(0, this, SLOT(handleTimeout())); +} + +void SshDelayedSignal::handleTimeout() +{ + if (!m_checkObject.isNull()) + emitSignal(); + deleteLater(); +} + + +SftpDelayedSignal::SftpDelayedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject) + : SshDelayedSignal(checkObject), m_privChannel(privChannel) {} + + +SftpInitializationFailedSignal::SftpInitializationFailedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, const QString &reason) + : SftpDelayedSignal(privChannel, checkObject), m_reason(reason) {} + +void SftpInitializationFailedSignal::emitSignal() +{ + m_privChannel->emitInitializationFailedSignal(m_reason); +} + + +SftpInitializedSignal::SftpInitializedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject) + : SftpDelayedSignal(privChannel, checkObject) {} + +void SftpInitializedSignal::emitSignal() +{ + m_privChannel->emitInitialized(); +} + + +SftpJobFinishedSignal::SftpJobFinishedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, SftpJobId jobId, + const QString &error) + : SftpDelayedSignal(privChannel, checkObject), m_jobId(jobId), m_error(error) +{ +} + +void SftpJobFinishedSignal::emitSignal() +{ + m_privChannel->emitJobFinished(m_jobId, m_error); +} + + +SftpDataAvailableSignal::SftpDataAvailableSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, SftpJobId jobId, + const QString &data) + : SftpDelayedSignal(privChannel, checkObject), m_jobId(jobId), m_data(data) {} + +void SftpDataAvailableSignal::emitSignal() +{ + m_privChannel->emitDataAvailable(m_jobId, m_data); +} + + +SftpClosedSignal::SftpClosedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject) + : SftpDelayedSignal(privChannel, checkObject) {} + +void SftpClosedSignal::emitSignal() +{ + m_privChannel->emitClosed(); +} + + +SshRemoteProcessDelayedSignal::SshRemoteProcessDelayedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject) + : SshDelayedSignal(checkObject), m_privChannel(privChannel) {} + + +SshRemoteProcessStartedSignal::SshRemoteProcessStartedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject) + : SshRemoteProcessDelayedSignal(privChannel, checkObject) {} + +void SshRemoteProcessStartedSignal::emitSignal() +{ + m_privChannel->emitStartedSignal(); +} + + +SshRemoteProcessOutputAvailableSignal::SshRemoteProcessOutputAvailableSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, const QByteArray &output) + : SshRemoteProcessDelayedSignal(privChannel, checkObject), m_output(output) +{ +} + +void SshRemoteProcessOutputAvailableSignal::emitSignal() +{ + m_privChannel->emitOutputAvailableSignal(m_output); +} + + +SshRemoteProcessErrorOutputAvailableSignal::SshRemoteProcessErrorOutputAvailableSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, const QByteArray &output) + : SshRemoteProcessDelayedSignal(privChannel, checkObject), m_output(output) +{ +} + +void SshRemoteProcessErrorOutputAvailableSignal::emitSignal() +{ + m_privChannel->emitErrorOutputAvailableSignal(m_output); +} + + +SshRemoteProcessClosedSignal::SshRemoteProcessClosedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, int exitStatus) + : SshRemoteProcessDelayedSignal(privChannel, checkObject), + m_exitStatus(exitStatus) +{ +} + +void SshRemoteProcessClosedSignal::emitSignal() +{ + m_privChannel->emitClosedSignal(m_exitStatus); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshdelayedsignal_p.h b/src/plugins/coreplugin/ssh/sshdelayedsignal_p.h new file mode 100644 index 00000000000..09163fb6861 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshdelayedsignal_p.h @@ -0,0 +1,190 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHDELAYEDSIGNAL_P_H +#define SSHDELAYEDSIGNAL_P_H + +#include "sftpdefs.h" + +#include +#include +#include + +namespace Core { +namespace Internal { +class SftpChannelPrivate; +class SshRemoteProcessPrivate; + +class SshDelayedSignal : public QObject +{ + Q_OBJECT +public: + SshDelayedSignal(const QWeakPointer &checkObject); + +private: + Q_SLOT void handleTimeout(); + virtual void emitSignal()=0; + + const QWeakPointer m_checkObject; +}; + + +class SftpDelayedSignal : public SshDelayedSignal +{ +public: + SftpDelayedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject); + +protected: + SftpChannelPrivate * const m_privChannel; +}; + +class SftpInitializationFailedSignal : public SftpDelayedSignal +{ +public: + SftpInitializationFailedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, const QString &reason); + +private: + virtual void emitSignal(); + + const QString m_reason; +}; + +class SftpInitializedSignal : public SftpDelayedSignal +{ +public: + SftpInitializedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject); + +private: + virtual void emitSignal(); +}; + +class SftpJobFinishedSignal : public SftpDelayedSignal +{ +public: + SftpJobFinishedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, SftpJobId jobId, + const QString &error); + +private: + virtual void emitSignal(); + + const SftpJobId m_jobId; + const QString m_error; +}; + +class SftpDataAvailableSignal : public SftpDelayedSignal +{ +public: + SftpDataAvailableSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject, SftpJobId jobId, + const QString &data); + +private: + virtual void emitSignal(); + + const SftpJobId m_jobId; + const QString m_data; +}; + +class SftpClosedSignal : public SftpDelayedSignal +{ +public: + SftpClosedSignal(SftpChannelPrivate *privChannel, + const QWeakPointer &checkObject); + +private: + virtual void emitSignal(); +}; + + +class SshRemoteProcessDelayedSignal : public SshDelayedSignal +{ +public: + SshRemoteProcessDelayedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject); + +protected: + SshRemoteProcessPrivate * const m_privChannel; +}; + +class SshRemoteProcessStartedSignal : public SshRemoteProcessDelayedSignal +{ +public: + SshRemoteProcessStartedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject); + +private: + virtual void emitSignal(); +}; + +class SshRemoteProcessOutputAvailableSignal + : public SshRemoteProcessDelayedSignal +{ +public: + SshRemoteProcessOutputAvailableSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, const QByteArray &output); + +private: + virtual void emitSignal(); + + const QByteArray m_output; +}; + +class SshRemoteProcessErrorOutputAvailableSignal + : public SshRemoteProcessDelayedSignal +{ +public: + SshRemoteProcessErrorOutputAvailableSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, const QByteArray &output); + +private: + virtual void emitSignal(); + + const QByteArray m_output; +}; + +class SshRemoteProcessClosedSignal : public SshRemoteProcessDelayedSignal +{ +public: + SshRemoteProcessClosedSignal(SshRemoteProcessPrivate *privChannel, + const QWeakPointer &checkObject, int exitStatus); + +private: + virtual void emitSignal(); + + const int m_exitStatus; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHDELAYEDSIGNAL_P_H diff --git a/src/plugins/coreplugin/ssh/ssherrors.h b/src/plugins/coreplugin/ssh/ssherrors.h new file mode 100644 index 00000000000..01587edfc53 --- /dev/null +++ b/src/plugins/coreplugin/ssh/ssherrors.h @@ -0,0 +1,43 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHERRORS_P_H +#define SSHERRORS_P_H + +namespace Core { + +enum SshError { + SshNoError, SshSocketError, SshTimeoutError, SshProtocolError, + SshHostKeyError, SshKeyFileError, SshAuthenticationError, + SshClosedByServerError, SshInternalError +}; + +} // namespace Core + +#endif // SSHERRORS_P_H diff --git a/src/plugins/coreplugin/ssh/sshexception_p.h b/src/plugins/coreplugin/ssh/sshexception_p.h new file mode 100644 index 00000000000..6812fabc49e --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshexception_p.h @@ -0,0 +1,89 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHEXCEPTION_P_H +#define SSHEXCEPTION_P_H + +#include "ssherrors.h" + +#include +#include +#include + +namespace Core { +namespace Internal { + +enum SshErrorCode { + SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1, + SSH_DISCONNECT_PROTOCOL_ERROR = 2, + SSH_DISCONNECT_KEY_EXCHANGE_FAILED = 3, + SSH_DISCONNECT_RESERVED = 4, + SSH_DISCONNECT_MAC_ERROR = 5, + SSH_DISCONNECT_COMPRESSION_ERROR = 6, + SSH_DISCONNECT_SERVICE_NOT_AVAILABLE = 7, + SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8, + SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9, + SSH_DISCONNECT_CONNECTION_LOST = 10, + SSH_DISCONNECT_BY_APPLICATION = 11, + SSH_DISCONNECT_TOO_MANY_CONNECTIONS = 12, + SSH_DISCONNECT_AUTH_CANCELLED_BY_USER = 13, + SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 14, + SSH_DISCONNECT_ILLEGAL_USER_NAME = 15 +}; + +#define SSH_TR(string) QCoreApplication::translate("SshConnection", string) + +#define SSH_SERVER_EXCEPTION(error, errorString) \ + SshServerException((error), (errorString), SSH_TR(errorString)) + +struct SshServerException +{ + SshServerException(SshErrorCode error, const QByteArray &errorStringServer, + const QString &errorStringUser) + : error(error), errorStringServer(errorStringServer), + errorStringUser(errorStringUser) {} + + const SshErrorCode error; + const QByteArray errorStringServer; + const QString errorStringUser; +}; + +struct SshClientException +{ + SshClientException(SshError error, const QString &errorString) + : error(error), errorString(errorString) {} + + const SshError error; + const QString errorString; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHEXCEPTION_P_H diff --git a/src/plugins/coreplugin/ssh/sshincomingpacket.cpp b/src/plugins/coreplugin/ssh/sshincomingpacket.cpp new file mode 100644 index 00000000000..fdc274bbbdb --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshincomingpacket.cpp @@ -0,0 +1,442 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshincomingpacket_p.h" + +#include "sshcapabilities_p.h" + +namespace Core { +namespace Internal { + +const QByteArray SshIncomingPacket::ExitStatusType("exit-status"); +const QByteArray SshIncomingPacket::ExitSignalType("exit-signal"); + +SshIncomingPacket::SshIncomingPacket() : m_serverSeqNr(0) { } + +quint32 SshIncomingPacket::cipherBlockSize() const +{ + return qMax(m_decrypter.cipherBlockSize(), 8U); +} + +quint32 SshIncomingPacket::macLength() const +{ + return m_decrypter.macLength(); +} + +void SshIncomingPacket::recreateKeys(const SshKeyExchange &keyExchange) +{ + m_decrypter.recreateKeys(keyExchange); +} + +void SshIncomingPacket::reset() +{ + clear(); + m_serverSeqNr = 0; + m_decrypter.clearKeys(); +} + +void SshIncomingPacket::consumeData(QByteArray &newData) +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("%s: current data size = %d, new data size = %d", + Q_FUNC_INFO, m_data.size(), newData.size()); +#endif + + if (isComplete() || newData.isEmpty()) + return; + + /* + * Until we have reached the minimum packet size, we cannot decrypt the + * length field. + */ + const quint32 minSize = minPacketSize(); + if (currentDataSize() < minSize) { + const int bytesToTake + = qMin(minSize - currentDataSize(), newData.size()); + moveFirstBytes(m_data, newData, bytesToTake); +#ifdef CREATOR_SSH_DEBUG + qDebug("Took %d bytes from new data", bytesToTake); +#endif + if (currentDataSize() < minSize) + return; + } + + const int bytesToTake + = qMin(length() + 4 + macLength() - currentDataSize(), + newData.size()); + moveFirstBytes(m_data, newData, bytesToTake); +#ifdef CREATOR_SSH_DEBUG + qDebug("Took %d bytes from new data", bytesToTake); +#endif + if (isComplete()) { +#ifdef CREATOR_SSH_DEBUG + qDebug("Message complete. Overall size: %u, payload size: %u", + m_data.size(), m_length - paddingLength() - 1); +#endif + decrypt(); + ++m_serverSeqNr; + } +} + +void SshIncomingPacket::decrypt() +{ + Q_ASSERT(isComplete()); + const quint32 netDataLength = length() + 4; + m_decrypter.decrypt(m_data, cipherBlockSize(), + netDataLength - cipherBlockSize()); + const QByteArray &mac = m_data.mid(netDataLength, macLength()); + if (mac != generateMac(m_decrypter, m_serverSeqNr)) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_MAC_ERROR, + "Message authentication failed."); + } +} + +void SshIncomingPacket::moveFirstBytes(QByteArray &target, QByteArray &source, + int n) +{ + target.append(source.left(n)); + source.remove(0, n); +} + +SshKeyExchangeInit SshIncomingPacket::extractKeyExchangeInitData() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_KEXINIT); + + SshKeyExchangeInit exchangeData; + try { + quint32 offset = TypeOffset + 1; + std::memcpy(exchangeData.cookie, &m_data.constData()[offset], + sizeof exchangeData.cookie); + offset += sizeof exchangeData.cookie; + exchangeData.keyAlgorithms + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.serverHostKeyAlgorithms + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.encryptionAlgorithmsClientToServer + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.encryptionAlgorithmsServerToClient + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.macAlgorithmsClientToServer + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.macAlgorithmsServerToClient + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.compressionAlgorithmsClientToServer + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.compressionAlgorithmsServerToClient + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.languagesClientToServer + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.languagesServerToClient + = SshPacketParser::asNameList(m_data, &offset); + exchangeData.firstKexPacketFollows + = SshPacketParser::asBool(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Key exchange failed: Server sent invalid SSH_MSG_KEXINIT packet."); + } + return exchangeData; +} + +SshKeyExchangeReply SshIncomingPacket::extractKeyExchangeReply(const QByteArray &pubKeyAlgo) const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_KEXDH_REPLY); + + try { + SshKeyExchangeReply replyData; + quint32 offset = TypeOffset + 1; + const quint32 k_sLength + = SshPacketParser::asUint32(m_data, &offset); + if (offset + k_sLength > currentDataSize()) + throw SshPacketParseException(); + replyData.k_s = m_data.mid(offset - 4, k_sLength + 4); + if (SshPacketParser::asString(m_data, &offset) != pubKeyAlgo) + throw SshPacketParseException(); + + // DSS: p and q, RSA: e and n + replyData.parameters << SshPacketParser::asBigInt(m_data, &offset); + replyData.parameters << SshPacketParser::asBigInt(m_data, &offset); + + // g and y + if (pubKeyAlgo == SshCapabilities::PubKeyDss) { + replyData.parameters << SshPacketParser::asBigInt(m_data, &offset); + replyData.parameters << SshPacketParser::asBigInt(m_data, &offset); + } + + replyData.f = SshPacketParser::asBigInt(m_data, &offset); + offset += 4; + if (SshPacketParser::asString(m_data, &offset) != pubKeyAlgo) + throw SshPacketParseException(); + replyData.signatureBlob = SshPacketParser::asString(m_data, &offset); + return replyData; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Key exchange failed: " + "Server sent invalid SSH_MSG_KEXDH_REPLY packet."); + } +} + +SshDisconnect SshIncomingPacket::extractDisconnect() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_DISCONNECT); + + SshDisconnect msg; + try { + quint32 offset = TypeOffset + 1; + msg.reasonCode = SshPacketParser::asUint32(m_data, &offset); + msg.description = SshPacketParser::asUserString(m_data, &offset); + msg.language = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_DISCONNECT."); + } + + return msg; +} + +SshUserAuthBanner SshIncomingPacket::extractUserAuthBanner() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_USERAUTH_BANNER); + + try { + SshUserAuthBanner msg; + quint32 offset = TypeOffset + 1; + msg.message = SshPacketParser::asUserString(m_data, &offset); + msg.language = SshPacketParser::asString(m_data, &offset); + return msg; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_USERAUTH_BANNER."); + } +} + +SshDebug SshIncomingPacket::extractDebug() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_DEBUG); + + try { + SshDebug msg; + quint32 offset = TypeOffset + 1; + msg.display = SshPacketParser::asBool(m_data, &offset); + msg.message = SshPacketParser::asUserString(m_data, &offset); + msg.language = SshPacketParser::asString(m_data, &offset); + return msg; + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_USERAUTH_BANNER."); + } +} + +SshChannelOpenFailure SshIncomingPacket::extractChannelOpenFailure() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_OPEN_FAILURE); + + SshChannelOpenFailure openFailure; + try { + quint32 offset = TypeOffset + 1; + openFailure.localChannel = SshPacketParser::asUint32(m_data, &offset); + openFailure.reasonCode = SshPacketParser::asUint32(m_data, &offset); + openFailure.reasonString = SshPacketParser::asString(m_data, &offset); + openFailure.language = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Server sent invalid SSH_MSG_CHANNEL_OPEN_FAILURE packet."); + } + return openFailure; +} + +SshChannelOpenConfirmation SshIncomingPacket::extractChannelOpenConfirmation() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_OPEN_CONFIRMATION); + + SshChannelOpenConfirmation confirmation; + try { + quint32 offset = TypeOffset + 1; + confirmation.localChannel = SshPacketParser::asUint32(m_data, &offset); + confirmation.remoteChannel = SshPacketParser::asUint32(m_data, &offset); + confirmation.remoteWindowSize = SshPacketParser::asUint32(m_data, &offset); + confirmation.remoteMaxPacketSize = SshPacketParser::asUint32(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Server sent invalid SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet."); + } + return confirmation; +} + +SshChannelWindowAdjust SshIncomingPacket::extractWindowAdjust() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_WINDOW_ADJUST); + + SshChannelWindowAdjust adjust; + try { + quint32 offset = TypeOffset + 1; + adjust.localChannel = SshPacketParser::asUint32(m_data, &offset); + adjust.bytesToAdd = SshPacketParser::asUint32(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_WINDOW_ADJUST packet."); + } + return adjust; +} + +SshChannelData SshIncomingPacket::extractChannelData() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_DATA); + + SshChannelData data; + try { + quint32 offset = TypeOffset + 1; + data.localChannel = SshPacketParser::asUint32(m_data, &offset); + data.data = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_DATA packet."); + } + return data; +} + +SshChannelExtendedData SshIncomingPacket::extractChannelExtendedData() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_EXTENDED_DATA); + + SshChannelExtendedData data; + try { + quint32 offset = TypeOffset + 1; + data.localChannel = SshPacketParser::asUint32(m_data, &offset); + data.type = SshPacketParser::asUint32(m_data, &offset); + data.data = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_EXTENDED_DATA packet."); + } + return data; +} + +SshChannelExitStatus SshIncomingPacket::extractChannelExitStatus() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_REQUEST); + + SshChannelExitStatus exitStatus; + try { + quint32 offset = TypeOffset + 1; + exitStatus.localChannel = SshPacketParser::asUint32(m_data, &offset); + const QByteArray &type = SshPacketParser::asString(m_data, &offset); + Q_ASSERT(type == ExitStatusType); + if (SshPacketParser::asBool(m_data, &offset)) + throw SshPacketParseException(); + exitStatus.exitStatus = SshPacketParser::asUint32(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid exit-status packet."); + } + return exitStatus; +} + +SshChannelExitSignal SshIncomingPacket::extractChannelExitSignal() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_REQUEST); + + SshChannelExitSignal exitSignal; + try { + quint32 offset = TypeOffset + 1; + exitSignal.localChannel = SshPacketParser::asUint32(m_data, &offset); + const QByteArray &type = SshPacketParser::asString(m_data, &offset); + Q_ASSERT(type == ExitSignalType); + if (SshPacketParser::asBool(m_data, &offset)) + throw SshPacketParseException(); + exitSignal.signal = SshPacketParser::asString(m_data, &offset); + exitSignal.coreDumped = SshPacketParser::asBool(m_data, &offset); + exitSignal.error = SshPacketParser::asUserString(m_data, &offset); + exitSignal.language = SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid exit-signal packet."); + } + return exitSignal; +} + +quint32 SshIncomingPacket::extractRecipientChannel() const +{ + Q_ASSERT(isComplete()); + + try { + quint32 offset = TypeOffset + 1; + return SshPacketParser::asUint32(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Server sent invalid packet."); + } +} + +QByteArray SshIncomingPacket::extractChannelRequestType() const +{ + Q_ASSERT(isComplete()); + Q_ASSERT(type() == SSH_MSG_CHANNEL_REQUEST); + + try { + quint32 offset = TypeOffset + 1; + SshPacketParser::asUint32(m_data, &offset); + return SshPacketParser::asString(m_data, &offset); + } catch (SshPacketParseException &) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Invalid SSH_MSG_CHANNEL_REQUEST packet."); + } +} + +void SshIncomingPacket::calculateLength() const +{ + Q_ASSERT(currentDataSize() >= minPacketSize()); +#ifdef CREATOR_SSH_DEBUG + 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); +#endif + m_decrypter.decrypt(m_data, 0, cipherBlockSize()); +#ifdef CREATOR_SSH_DEBUG + 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); + qDebug("message type = %d", m_data.at(TypeOffset)); +#endif + m_length = SshPacketParser::asUint32(m_data, static_cast(0)); +#ifdef CREATOR_SSH_DEBUG + qDebug("decrypted length is %u", m_length); +#endif +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshincomingpacket_p.h b/src/plugins/coreplugin/ssh/sshincomingpacket_p.h new file mode 100644 index 00000000000..9b10c8f7998 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshincomingpacket_p.h @@ -0,0 +1,186 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHINCOMINGPACKET_P_H +#define SSHINCOMINGPACKET_P_H + +#include "sshpacket_p.h" + +#include "sshcryptofacility_p.h" +#include "sshpacketparser_p.h" + +#include +#include + +namespace Core { +namespace Internal { + +class SshKeyExchange; + +struct SshKeyExchangeInit +{ + char cookie[16]; + SshNameList keyAlgorithms; + SshNameList serverHostKeyAlgorithms; + SshNameList encryptionAlgorithmsClientToServer; + SshNameList encryptionAlgorithmsServerToClient; + SshNameList macAlgorithmsClientToServer; + SshNameList macAlgorithmsServerToClient; + SshNameList compressionAlgorithmsClientToServer; + SshNameList compressionAlgorithmsServerToClient; + SshNameList languagesClientToServer; + SshNameList languagesServerToClient; + bool firstKexPacketFollows; +}; + +struct SshKeyExchangeReply +{ + QByteArray k_s; + QList parameters; // DSS: p, q, g, y. RSA: e, n. + Botan::BigInt f; + QByteArray signatureBlob; +}; + +struct SshDisconnect +{ + quint32 reasonCode; + QString description; + QByteArray language; +}; + +struct SshUserAuthBanner +{ + QString message; + QByteArray language; +}; + +struct SshDebug +{ + bool display; + QString message; + QByteArray language; +}; + +struct SshChannelOpenFailure +{ + quint32 localChannel; + quint32 reasonCode; + QString reasonString; + QByteArray language; +}; + +struct SshChannelOpenConfirmation +{ + quint32 localChannel; + quint32 remoteChannel; + quint32 remoteWindowSize; + quint32 remoteMaxPacketSize; +}; + +struct SshChannelWindowAdjust +{ + quint32 localChannel; + quint32 bytesToAdd; +}; + +struct SshChannelData +{ + quint32 localChannel; + QByteArray data; +}; + +struct SshChannelExtendedData +{ + quint32 localChannel; + quint32 type; + QByteArray data; +}; + +struct SshChannelExitStatus +{ + quint32 localChannel; + quint32 exitStatus; +}; + +struct SshChannelExitSignal +{ + quint32 localChannel; + QByteArray signal; + bool coreDumped; + QString error; + QByteArray language; +}; + + +class SshIncomingPacket : public AbstractSshPacket +{ +public: + SshIncomingPacket(); + + void consumeData(QByteArray &data); + void recreateKeys(const SshKeyExchange &keyExchange); + void reset(); + + SshKeyExchangeInit extractKeyExchangeInitData() const; + SshKeyExchangeReply extractKeyExchangeReply(const QByteArray &pubKeyAlgo) const; + SshDisconnect extractDisconnect() const; + SshUserAuthBanner extractUserAuthBanner() const; + SshDebug extractDebug() const; + + SshChannelOpenFailure extractChannelOpenFailure() const; + SshChannelOpenConfirmation extractChannelOpenConfirmation() const; + SshChannelWindowAdjust extractWindowAdjust() const; + SshChannelData extractChannelData() const; + SshChannelExtendedData extractChannelExtendedData() const; + SshChannelExitStatus extractChannelExitStatus() const; + SshChannelExitSignal extractChannelExitSignal() const; + quint32 extractRecipientChannel() const; + QByteArray extractChannelRequestType() const; + + quint32 serverSeqNr() const { return m_serverSeqNr; } + + static const QByteArray ExitStatusType; + static const QByteArray ExitSignalType; + +private: + virtual quint32 cipherBlockSize() const; + virtual quint32 macLength() const; + virtual void calculateLength() const; + + void decrypt(); + void moveFirstBytes(QByteArray &target, QByteArray &source, int n); + + quint32 m_serverSeqNr; + SshDecryptionFacility m_decrypter; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHINCOMINGPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sshkeyexchange.cpp b/src/plugins/coreplugin/ssh/sshkeyexchange.cpp new file mode 100644 index 00000000000..7875d2ecd07 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshkeyexchange.cpp @@ -0,0 +1,197 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshkeyexchange_p.h" + +#include "sshbotanconversions_p.h" +#include "sshcapabilities_p.h" +#include "sshsendfacility_p.h" +#include "sshexception_p.h" +#include "sshincomingpacket_p.h" + +#include +#include +#include +#include +#include + +#include + +using namespace Botan; + +namespace Core { +namespace Internal { + +namespace { + + // For debugging + void printNameList(const char *listName, const SshNameList &list) + { +#ifdef CREATOR_SSH_DEBUG + qDebug("%s:", listName); + foreach (const QByteArray &name, list.names) + qDebug("%s", name.constData()); +#else + Q_UNUSED(listName); + Q_UNUSED(list); +#endif + } +} // anonymous namespace + +SshKeyExchange::SshKeyExchange(SshSendFacility &sendFacility) + : m_sendFacility(sendFacility) +{ +} + +SshKeyExchange::~SshKeyExchange() {} + +void SshKeyExchange::sendKexInitPacket(const QByteArray &serverId) +{ + m_serverId = serverId; + const AbstractSshPacket::Payload &payload + = m_sendFacility.sendKeyExchangeInitPacket(); + m_clientKexInitPayload = QByteArray(payload.data, payload.size); +} + +bool SshKeyExchange::sendDhInitPacket(const SshIncomingPacket &serverKexInit) +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("server requests key exchange"); +#endif + serverKexInit.printRawBytes(); + SshKeyExchangeInit kexInitParams + = serverKexInit.extractKeyExchangeInitData(); + + printNameList("Key Algorithms", kexInitParams.keyAlgorithms); + printNameList("Server Host Key Algorithms", kexInitParams.serverHostKeyAlgorithms); + printNameList("Encryption algorithms client to server", kexInitParams.encryptionAlgorithmsClientToServer); + printNameList("Encryption algorithms server to client", kexInitParams.encryptionAlgorithmsServerToClient); + printNameList("MAC algorithms client to server", kexInitParams.macAlgorithmsClientToServer); + printNameList("MAC algorithms server to client", kexInitParams.macAlgorithmsServerToClient); + 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 server to client", kexInitParams.languagesServerToClient); +#ifdef CREATOR_SSH_DEBUG + qDebug("First packet follows: %d", kexInitParams.firstKexPacketFollows); +#endif + + const QByteArray &keyAlgo + = SshCapabilities::findBestMatch(SshCapabilities::KeyExchangeMethods, + kexInitParams.keyAlgorithms.names); + m_serverHostKeyAlgo + = SshCapabilities::findBestMatch(SshCapabilities::PublicKeyAlgorithms, + kexInitParams.serverHostKeyAlgorithms.names); + m_encryptionAlgo + = SshCapabilities::findBestMatch(SshCapabilities::EncryptionAlgorithms, + kexInitParams.encryptionAlgorithmsClientToServer.names); + m_decryptionAlgo + = SshCapabilities::findBestMatch(SshCapabilities::EncryptionAlgorithms, + kexInitParams.encryptionAlgorithmsServerToClient.names); + m_c2sHMacAlgo + = SshCapabilities::findBestMatch(SshCapabilities::MacAlgorithms, + kexInitParams.macAlgorithmsClientToServer.names); + m_s2cHMacAlgo + = SshCapabilities::findBestMatch(SshCapabilities::MacAlgorithms, + kexInitParams.macAlgorithmsServerToClient.names); + SshCapabilities::findBestMatch(SshCapabilities::CompressionAlgorithms, + kexInitParams.compressionAlgorithmsClientToServer.names); + SshCapabilities::findBestMatch(SshCapabilities::CompressionAlgorithms, + kexInitParams.compressionAlgorithmsServerToClient.names); + + AutoSeeded_RNG rng; + m_dhKey.reset(new DH_PrivateKey(rng, + DL_Group(botanKeyExchangeAlgoName(keyAlgo)))); + + const AbstractSshPacket::Payload &payload = serverKexInit.payLoad(); + m_serverKexInitPayload = QByteArray(payload.data, payload.size); + m_sendFacility.sendKeyDhInitPacket(m_dhKey->get_y()); + return kexInitParams.firstKexPacketFollows; +} + +void SshKeyExchange::sendNewKeysPacket(const SshIncomingPacket &dhReply, + const QByteArray &clientId) +{ + const SshKeyExchangeReply &reply + = dhReply.extractKeyExchangeReply(m_serverHostKeyAlgo); + if (reply.f <= 0 || reply.f >= m_dhKey->group_p()) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Server sent invalid f."); + } + + QByteArray concatenatedData = AbstractSshPacket::encodeString(clientId); + concatenatedData += AbstractSshPacket::encodeString(m_serverId); + concatenatedData += AbstractSshPacket::encodeString(m_clientKexInitPayload); + concatenatedData += AbstractSshPacket::encodeString(m_serverKexInitPayload); + concatenatedData += reply.k_s; + concatenatedData += AbstractSshPacket::encodeMpInt(m_dhKey->get_y()); + concatenatedData += AbstractSshPacket::encodeMpInt(reply.f); + SymmetricKey k = m_dhKey->derive_key(reply.f); + m_k = AbstractSshPacket::encodeMpInt(BigInt(k.begin(), k.length())); + concatenatedData += m_k; + + m_hash.reset(get_hash(botanSha1Name())); + const SecureVector &hashResult + = m_hash->process(convertByteArray(concatenatedData), + concatenatedData.size()); + m_h = convertByteArray(hashResult); + + QScopedPointer sigKey; + QScopedPointer verifier; + if (m_serverHostKeyAlgo == SshCapabilities::PubKeyDss) { + const DL_Group group(reply.parameters.at(0), reply.parameters.at(1), + reply.parameters.at(2)); + DSA_PublicKey * const dsaKey + = new DSA_PublicKey(group, reply.parameters.at(3)); + sigKey.reset(dsaKey); + verifier.reset(get_pk_verifier(*dsaKey, + botanEmsaAlgoName(SshCapabilities::PubKeyDss))); + } else if (m_serverHostKeyAlgo == SshCapabilities::PubKeyRsa) { + RSA_PublicKey * const rsaKey + = new RSA_PublicKey(reply.parameters.at(1), reply.parameters.at(0)); + sigKey.reset(rsaKey); + verifier.reset(get_pk_verifier(*rsaKey, + botanEmsaAlgoName(SshCapabilities::PubKeyRsa))); + } else { + Q_ASSERT(!"Impossible: Neither DSS nor RSA!"); + } + const byte * const botanH = convertByteArray(m_h); + const Botan::byte * const botanSig + = convertByteArray(reply.signatureBlob); + if (!verifier->verify_message(botanH, m_h.size(), botanSig, + reply.signatureBlob.size())) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_KEY_EXCHANGE_FAILED, + "Invalid signature in SSH_MSG_KEXDH_REPLY packet."); + } + + m_sendFacility.sendNewKeysPacket(); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshkeyexchange_p.h b/src/plugins/coreplugin/ssh/sshkeyexchange_p.h new file mode 100644 index 00000000000..076f5bedd6e --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshkeyexchange_p.h @@ -0,0 +1,87 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHKEYEXCHANGE_P_H +#define SSHKEYEXCHANGE_P_H + +#include + +#include +#include + +namespace Botan { class HashFunction; } + +namespace Core { +namespace Internal { + +class SshSendFacility; +class SshIncomingPacket; + +class SshKeyExchange +{ +public: + SshKeyExchange(SshSendFacility &sendFacility); + ~SshKeyExchange(); + + void sendKexInitPacket(const QByteArray &serverId); + + // Returns true <=> the server sends a guessed package. + bool sendDhInitPacket(const SshIncomingPacket &serverKexInit); + + void sendNewKeysPacket(const SshIncomingPacket &dhReply, + const QByteArray &clientId); + + QByteArray k() const { return m_k; } + QByteArray h() const { return m_h; } + Botan::HashFunction *hash() const { return m_hash.data(); } + QByteArray encryptionAlgo() const { return m_encryptionAlgo; } + QByteArray decryptionAlgo() const { return m_decryptionAlgo; } + QByteArray hMacAlgoClientToServer() const { return m_c2sHMacAlgo; } + QByteArray hMacAlgoServerToClient() const { return m_s2cHMacAlgo; } + +private: + QByteArray m_serverId; + QByteArray m_clientKexInitPayload; + QByteArray m_serverKexInitPayload; + QScopedPointer m_dhKey; + QByteArray m_k; + QByteArray m_h; + QByteArray m_serverHostKeyAlgo; + QByteArray m_encryptionAlgo; + QByteArray m_decryptionAlgo; + QByteArray m_c2sHMacAlgo; + QByteArray m_s2cHMacAlgo; + QScopedPointer m_hash; + SshSendFacility &m_sendFacility; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHKEYEXCHANGE_P_H diff --git a/src/plugins/coreplugin/ssh/sshkeygenerator.cpp b/src/plugins/coreplugin/ssh/sshkeygenerator.cpp index 17a63886e31..976d0094c78 100644 --- a/src/plugins/coreplugin/ssh/sshkeygenerator.cpp +++ b/src/plugins/coreplugin/ssh/sshkeygenerator.cpp @@ -1,55 +1,138 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #include "sshkeygenerator.h" -#include "ne7sshobject.h" +#include "sshbotanconversions_p.h" +#include "sshcapabilities_p.h" +#include "sshpacket_p.h" -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include namespace Core { -SshKeyGenerator::SshKeyGenerator() +using namespace Botan; +using namespace Internal; + +SshKeyGenerator::SshKeyGenerator() { } + +bool SshKeyGenerator::generateKeys(KeyType type, PrivateKeyFormat format, + int keySize) { + try { + AutoSeeded_RNG rng; + KeyPtr key; + if (type == Rsa) + key = KeyPtr(new RSA_PrivateKey(rng, keySize)); + else + key = KeyPtr(new DSA_PrivateKey(rng, DL_Group(rng, DL_Group::Strong, + keySize))); + return format == Pkcs8 + ? generatePkcs8Keys(key) : generateOpenSslKeys(key, type); + } catch (Botan::Exception &e) { + m_error = tr("Error generating key: %1").arg(e.what()); + return false; + } } -bool SshKeyGenerator::generateKeys(KeyType type, const QString &id, int keySize) +bool SshKeyGenerator::generatePkcs8Keys(const KeyPtr &key) { - QTemporaryFile tmpPubKeyFile; - QTemporaryFile tmpPrivKeyFile; - if (!tmpPubKeyFile.open() || !tmpPrivKeyFile.open()) { - m_error = tr("Error creating temporary files."); - return false; + generatePkcs8Key(key, false); + generatePkcs8Key(key, true); + return true; +} + +void SshKeyGenerator::generatePkcs8Key(const KeyPtr &key, bool privateKey) +{ + Pipe pipe; + pipe.start_msg(); + QByteArray *keyData; + if (privateKey) { + PKCS8::encode(*key, pipe); + keyData = &m_privateKey; + } else { + X509::encode(*key, pipe); + keyData = &m_publicKey; } - tmpPubKeyFile.setAutoRemove(false); - tmpPubKeyFile.close(); - tmpPrivKeyFile.close(); - const char * const typeStr = type == Rsa ? "rsa" : "dsa"; - Internal::Ne7SshObject::Ptr ne7Object - = Internal::Ne7SshObject::instance()->get(); - if (!ne7Object->generateKeyPair(typeStr, id.toUtf8(), - tmpPrivKeyFile.fileName().toUtf8(), - tmpPubKeyFile.fileName().toUtf8(), keySize)) { - // TODO: Race condition on pop() call. Perhaps not use Net7 errors? Or hack API - m_error = tr("Error generating keys: %1") - .arg(ne7Object->errors()->pop()); - return false; + pipe.end_msg(); + keyData->resize(pipe.remaining(pipe.message_count() - 1)); + pipe.read(convertByteArray(*keyData), keyData->size(), + pipe.message_count() - 1); +} + +bool SshKeyGenerator::generateOpenSslKeys(const KeyPtr &key, KeyType type) +{ + QList publicParams; + QList allParams; + QByteArray keyId; + if (type == Rsa) { + const QSharedPointer rsaKey + = key.dynamicCast(); + publicParams << rsaKey->get_e() << rsaKey->get_n(); + allParams << rsaKey->get_n() << rsaKey->get_e() << rsaKey->get_d() + << rsaKey->get_p() << rsaKey->get_q(); + keyId = SshCapabilities::PubKeyRsa; + } else { + const QSharedPointer dsaKey + = key.dynamicCast(); + publicParams << dsaKey->group_p() << dsaKey->group_q() + << dsaKey->group_g() << dsaKey->get_y(); + allParams << publicParams << dsaKey->get_x(); + keyId = SshCapabilities::PubKeyDss; } - if (!tmpPubKeyFile.open() || !tmpPrivKeyFile.open()) { - m_error = tr("Error reading temporary files."); - return false; - } + QByteArray publicKeyBlob = AbstractSshPacket::encodeString(keyId); + foreach (const BigInt &b, publicParams) + publicKeyBlob += AbstractSshPacket::encodeMpInt(b); + publicKeyBlob = publicKeyBlob.toBase64(); + const QByteArray id = "QtCreator/" + + QDateTime::currentDateTime().toString(Qt::ISODate).toUtf8(); + m_publicKey = keyId + ' ' + publicKeyBlob + ' ' + id; - m_publicKey = tmpPubKeyFile.readAll(); - m_privateKey = tmpPrivKeyFile.readAll(); - if (tmpPubKeyFile.error() != QFile::NoError - || tmpPrivKeyFile.error() != QFile::NoError) { - m_error = tr("Error reading temporary files."); - return false; - } - - m_type = type; + DER_Encoder encoder; + encoder.start_cons(SEQUENCE).encode (0U); + foreach (const BigInt &b, allParams) + encoder.encode(b); + encoder.end_cons(); + const char * const label + = type == Rsa ? "RSA PRIVATE KEY" : "DSA PRIVATE KEY"; + m_privateKey + = QByteArray(PEM_Code::encode (encoder.get_contents(), label).c_str()); return true; } diff --git a/src/plugins/coreplugin/ssh/sshkeygenerator.h b/src/plugins/coreplugin/ssh/sshkeygenerator.h index a68237e576f..ada06150a04 100644 --- a/src/plugins/coreplugin/ssh/sshkeygenerator.h +++ b/src/plugins/coreplugin/ssh/sshkeygenerator.h @@ -1,10 +1,43 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + #ifndef SSHKEYGENERATOR_H #define SSHKEYGENERATOR_H #include #include -#include +#include + +namespace Botan { + class Private_Key; +} namespace Core { @@ -13,19 +46,28 @@ class CORE_EXPORT SshKeyGenerator Q_DECLARE_TR_FUNCTIONS(SshKeyGenerator) public: enum KeyType { Rsa, Dsa }; + enum PrivateKeyFormat { Pkcs8, OpenSsl }; SshKeyGenerator(); - bool generateKeys(KeyType type, const QString &id, int keySize); + bool generateKeys(KeyType type, PrivateKeyFormat format, int keySize); QString error() const { return m_error; } - QString privateKey() const { return m_privateKey; } - QString publicKey() const { return m_publicKey; } + QByteArray privateKey() const { return m_privateKey; } + QByteArray publicKey() const { return m_publicKey; } KeyType type() const { return m_type; } + PrivateKeyFormat format() const { return m_format; } private: + typedef QSharedPointer KeyPtr; + + bool generatePkcs8Keys(const KeyPtr &key); + void generatePkcs8Key(const KeyPtr &key, bool privateKey); + bool generateOpenSslKeys(const KeyPtr &key, KeyType type); + QString m_error; - QString m_publicKey; - QString m_privateKey; + QByteArray m_publicKey; + QByteArray m_privateKey; KeyType m_type; + PrivateKeyFormat m_format; }; } // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshoutgoingpacket.cpp b/src/plugins/coreplugin/ssh/sshoutgoingpacket.cpp new file mode 100644 index 00000000000..c6cf99443d4 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshoutgoingpacket.cpp @@ -0,0 +1,284 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshoutgoingpacket_p.h" + +#include "sshcapabilities_p.h" +#include "sshcryptofacility_p.h" + +#include + +namespace Core { +namespace Internal { + +SshOutgoingPacket::SshOutgoingPacket(const SshEncryptionFacility &encrypter, + const quint32 &seqNr) : m_encrypter(encrypter), m_seqNr(seqNr) +{ +} + +quint32 SshOutgoingPacket::cipherBlockSize() const +{ + return qMax(m_encrypter.cipherBlockSize(), 4U); +} + +quint32 SshOutgoingPacket::macLength() const +{ + return m_encrypter.macLength(); +} + +void SshOutgoingPacket::generateKeyExchangeInitPacket() +{ + const QByteArray &supportedkeyExchangeMethods + = encodeNameList(SshCapabilities::KeyExchangeMethods); + const QByteArray &supportedPublicKeyAlgorithms + = encodeNameList(SshCapabilities::PublicKeyAlgorithms); + const QByteArray &supportedEncryptionAlgorithms + = encodeNameList(SshCapabilities::EncryptionAlgorithms); + const QByteArray &supportedMacAlgorithms + = encodeNameList(SshCapabilities::MacAlgorithms); + const QByteArray &supportedCompressionAlgorithms + = encodeNameList(SshCapabilities::CompressionAlgorithms); + const QByteArray &supportedLanguages = encodeNameList(QList()); + + init(SSH_MSG_KEXINIT); + m_data += m_encrypter.getRandomNumbers(16); + m_data.append(supportedkeyExchangeMethods); + m_data.append(supportedPublicKeyAlgorithms); + m_data.append(supportedEncryptionAlgorithms) + .append(supportedEncryptionAlgorithms); + m_data.append(supportedMacAlgorithms).append(supportedMacAlgorithms); + m_data.append(supportedCompressionAlgorithms) + .append(supportedCompressionAlgorithms); + m_data.append(supportedLanguages).append(supportedLanguages); + appendBool(false); // No guessed packet. + m_data.append(QByteArray(4, 0)); // Reserved. + finalize(); +} + +void SshOutgoingPacket::generateKeyDhInitPacket(const Botan::BigInt &e) +{ + init(SSH_MSG_KEXDH_INIT).appendMpInt(e).finalize(); +} + +void SshOutgoingPacket::generateNewKeysPacket() +{ + init(SSH_MSG_NEWKEYS).finalize(); +} + +void SshOutgoingPacket::generateUserAuthServiceRequestPacket() +{ + generateServiceRequest("ssh-userauth"); +} + +void SshOutgoingPacket::generateServiceRequest(const QByteArray &service) +{ + init(SSH_MSG_SERVICE_REQUEST).appendString(service).finalize(); +} + +void SshOutgoingPacket::generateUserAuthByPwdRequestPacket(const QByteArray &user, + const QByteArray &service, const QByteArray &pwd) +{ + init(SSH_MSG_USERAUTH_REQUEST).appendString(user).appendString(service) + .appendString("password").appendBool(false).appendString(pwd) + .finalize(); +} + +void SshOutgoingPacket::generateUserAuthByKeyRequestPacket(const QByteArray &user, + const QByteArray &service) +{ + init(SSH_MSG_USERAUTH_REQUEST).appendString(user).appendString(service) + .appendString("publickey").appendBool(true) + .appendString(m_encrypter.authenticationAlgorithmName()) + .appendString(m_encrypter.authenticationPublicKey()); + const QByteArray &dataToSign = m_data.mid(PayloadOffset); + appendString(m_encrypter.authenticationKeySignature(dataToSign)); + finalize(); +} + +void SshOutgoingPacket::generateRequestFailurePacket() +{ + init(SSH_MSG_REQUEST_FAILURE).finalize(); +} + +void SshOutgoingPacket::generateSessionPacket(quint32 channelId, + quint32 windowSize, quint32 maxPacketSize) +{ + init(SSH_MSG_CHANNEL_OPEN).appendString("session").appendInt(channelId) + .appendInt(windowSize).appendInt(maxPacketSize).finalize(); +} + +void SshOutgoingPacket::generateEnvPacket(quint32 remoteChannel, + const QByteArray &var, const QByteArray &value) +{ + init(SSH_MSG_CHANNEL_REQUEST).appendInt(remoteChannel).appendString("env") + .appendBool(false).appendString(var).appendString(value); +} + +void SshOutgoingPacket::generateExecPacket(quint32 remoteChannel, + const QByteArray &command) +{ + init(SSH_MSG_CHANNEL_REQUEST).appendInt(remoteChannel).appendString("exec") + .appendBool(true).appendString(command).finalize(); +} + +void SshOutgoingPacket::generateSftpPacket(quint32 remoteChannel) +{ + init(SSH_MSG_CHANNEL_REQUEST).appendInt(remoteChannel) + .appendString("subsystem").appendBool(true).appendString("sftp") + .finalize(); +} + +void SshOutgoingPacket::generateWindowAdjustPacket(quint32 remoteChannel, + quint32 bytesToAdd) +{ + init(SSH_MSG_CHANNEL_WINDOW_ADJUST).appendInt(remoteChannel) + .appendInt(bytesToAdd).finalize(); +} + +void SshOutgoingPacket::generateChannelDataPacket(quint32 remoteChannel, + const QByteArray &data) +{ + init(SSH_MSG_CHANNEL_DATA).appendInt(remoteChannel).appendString(data) + .finalize(); +} + +void SshOutgoingPacket::generateChannelSignalPacket(quint32 remoteChannel, + const QByteArray &signalName) +{ + init(SSH_MSG_CHANNEL_REQUEST).appendInt(remoteChannel) + .appendString("signal").appendBool(false).appendString(signalName) + .finalize(); +} + +void SshOutgoingPacket::generateChannelEofPacket(quint32 remoteChannel) +{ + init(SSH_MSG_CHANNEL_EOF).appendInt(remoteChannel).finalize(); +} + +void SshOutgoingPacket::generateChannelClosePacket(quint32 remoteChannel) +{ + init(SSH_MSG_CHANNEL_CLOSE).appendInt(remoteChannel).finalize(); +} + +void SshOutgoingPacket::generateDisconnectPacket(SshErrorCode reason, + const QByteArray &reasonString) +{ + init(SSH_MSG_DISCONNECT).appendInt(reason).appendString(reasonString) + .appendString(QByteArray()).finalize(); +} + +void SshOutgoingPacket::generateMsgUnimplementedPacket(quint32 serverSeqNr) +{ + init(SSH_MSG_UNIMPLEMENTED).appendInt(serverSeqNr).finalize(); +} + +SshOutgoingPacket &SshOutgoingPacket::appendInt(quint32 val) +{ + m_data.append(encodeInt(val)); + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::appendMpInt(const Botan::BigInt &number) +{ + m_data.append(encodeMpInt(number)); + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::appendBool(bool b) +{ + m_data += static_cast(b); + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::appendString(const QByteArray &string) +{ + m_data.append(encodeString(string)); + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::init(SshPacketType type) +{ + m_data.resize(TypeOffset + 1); + m_data[TypeOffset] = type; + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::setPadding() +{ + m_data += m_encrypter.getRandomNumbers(MinPaddingLength); + int padLength = MinPaddingLength; + const int divisor = sizeDivisor(); + const int mod = m_data.size() % divisor; + padLength += divisor - mod; + m_data += m_encrypter.getRandomNumbers(padLength - MinPaddingLength); + m_data[PaddingLengthOffset] = padLength; + return *this; +} + +SshOutgoingPacket &SshOutgoingPacket::encrypt() +{ + const QByteArray &mac + = generateMac(m_encrypter, m_seqNr); + m_encrypter.encrypt(m_data); + m_data += mac; + return *this; +} + +void SshOutgoingPacket::finalize() +{ + setPadding(); + setLengthField(m_data); + m_length = m_data.size() - 4; +#ifdef CREATOR_SSH_DEBUG + qDebug("Encrypting packet of type %u", m_data.at(TypeOffset)); +#endif + encrypt(); + Q_ASSERT(isComplete()); +} + +int SshOutgoingPacket::sizeDivisor() const +{ + return qMax(cipherBlockSize(), 8U); +} + +QByteArray SshOutgoingPacket::encodeNameList(const QList &list) +{ + QByteArray data; + data.resize(4); + for (int i = 0; i < list.count(); ++i) { + if (i > 0) + data.append(','); + data.append(list.at(i)); + } + AbstractSshPacket::setLengthField(data); + return data; +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshoutgoingpacket_p.h b/src/plugins/coreplugin/ssh/sshoutgoingpacket_p.h new file mode 100644 index 00000000000..eb9c2f520d6 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshoutgoingpacket_p.h @@ -0,0 +1,98 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHOUTGOINGPACKET_P_H +#define SSHOUTGOINGPACKET_P_H + +#include "sshpacket_p.h" + +namespace Core { +namespace Internal { + +class SshEncryptionFacility; + +class SshOutgoingPacket : public AbstractSshPacket +{ +public: + SshOutgoingPacket(const SshEncryptionFacility &encrypter, + const quint32 &seqNr); + + void generateKeyExchangeInitPacket(); + void generateKeyDhInitPacket(const Botan::BigInt &e); + void generateNewKeysPacket(); + void generateDisconnectPacket(SshErrorCode reason, + const QByteArray &reasonString); + void generateMsgUnimplementedPacket(quint32 serverSeqNr); + void generateUserAuthServiceRequestPacket(); + void generateUserAuthByPwdRequestPacket(const QByteArray &user, + const QByteArray &service, const QByteArray &pwd); + void generateUserAuthByKeyRequestPacket(const QByteArray &user, + const QByteArray &service); + void generateRequestFailurePacket(); + void generateSessionPacket(quint32 channelId, quint32 windowSize, + quint32 maxPacketSize); + void generateEnvPacket(quint32 remoteChannel, const QByteArray &var, + const QByteArray &value); + void generateExecPacket(quint32 remoteChannel, const QByteArray &command); + void generateSftpPacket(quint32 remoteChannel); + void generateWindowAdjustPacket(quint32 remoteChannel, quint32 bytesToAdd); + void generateChannelDataPacket(quint32 remoteChannel, + const QByteArray &data); + void generateChannelSignalPacket(quint32 remoteChannel, + const QByteArray &signalName); + void generateChannelEofPacket(quint32 remoteChannel); + void generateChannelClosePacket(quint32 remoteChannel); + +private: + virtual quint32 cipherBlockSize() const; + virtual quint32 macLength() const; + + static QByteArray encodeNameList(const QList &list); + + void generateServiceRequest(const QByteArray &service); + + SshOutgoingPacket &init(SshPacketType type); + SshOutgoingPacket &setPadding(); + SshOutgoingPacket &encrypt(); + void finalize(); + + SshOutgoingPacket &appendInt(quint32 val); + SshOutgoingPacket &appendString(const QByteArray &string); + SshOutgoingPacket &appendMpInt(const Botan::BigInt &number); + SshOutgoingPacket &appendBool(bool b); + int sizeDivisor() const; + + const SshEncryptionFacility &m_encrypter; + const quint32 &m_seqNr; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHOUTGOINGPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sshpacket.cpp b/src/plugins/coreplugin/ssh/sshpacket.cpp new file mode 100644 index 00000000000..ff705093554 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshpacket.cpp @@ -0,0 +1,167 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshpacket_p.h" + +#include "sshcapabilities_p.h" +#include "sshcryptofacility_p.h" +#include "sshexception_p.h" +#include "sshpacketparser_p.h" + +#include + +#include + +namespace Core { +namespace Internal { + +const quint32 AbstractSshPacket::PaddingLengthOffset = 4; +const quint32 AbstractSshPacket::PayloadOffset = PaddingLengthOffset + 1; +const quint32 AbstractSshPacket::TypeOffset = PayloadOffset; +const quint32 AbstractSshPacket::MinPaddingLength = 4; + +namespace { + + void printByteArray(const QByteArray &data) + { +#ifdef CREATOR_SSH_DEBUG + for (int i = 0; i < data.count(); ++i) + qDebug() << std::hex << (static_cast(data[i]) & 0xff) << " "; +#else + Q_UNUSED(data); +#endif + } +} // anonymous namespace + + +AbstractSshPacket::AbstractSshPacket() : m_length(0) { } +AbstractSshPacket::~AbstractSshPacket() {} + +bool AbstractSshPacket::isComplete() const +{ + if (currentDataSize() < minPacketSize()) + return false; + Q_ASSERT(4 + length() + macLength() >= currentDataSize()); + return 4 + length() + macLength() == currentDataSize(); +} + +void AbstractSshPacket::clear() +{ + m_data.clear(); + m_length = 0; +} + +SshPacketType AbstractSshPacket::type() const +{ + Q_ASSERT(isComplete()); + return static_cast(m_data.at(TypeOffset)); +} + +AbstractSshPacket::Payload AbstractSshPacket::payLoad() const +{ + Payload p; + p.data = m_data.constData() + PayloadOffset; + p.size = length() - paddingLength() - 1; + return p; +} + +void AbstractSshPacket::printRawBytes() const +{ + printByteArray(m_data); +} + +QByteArray AbstractSshPacket::encodeString(const QByteArray &string) +{ + QByteArray data; + data.resize(4); + data += string; + setLengthField(data); + return data; +} + +QByteArray AbstractSshPacket::encodeMpInt(const Botan::BigInt &number) +{ + if (number.is_zero()) + return QByteArray(4, 0); + + int stringLength = number.bytes(); + const bool positiveAndMsbSet = number.sign() == Botan::BigInt::Positive + && (number.byte_at(stringLength - 1) & 0x80); + if (positiveAndMsbSet) + ++stringLength; + QByteArray data; + data.resize(4 + stringLength); + int pos = 4; + if (positiveAndMsbSet) + data[pos++] = '\0'; + number.binary_encode(reinterpret_cast(data.data()) + pos); + setLengthField(data); + return data; +} + +int AbstractSshPacket::paddingLength() const +{ + return m_data[PaddingLengthOffset]; +} + +quint32 AbstractSshPacket::length() const +{ + //Q_ASSERT(currentDataSize() >= minPacketSize()); + if (m_length == 0) + calculateLength(); + return m_length; +} + +void AbstractSshPacket::calculateLength() const +{ + m_length = SshPacketParser::asUint32(m_data, static_cast(0)); +} + +QByteArray AbstractSshPacket::generateMac(const SshAbstractCryptoFacility &crypt, + quint32 seqNr) const +{ + const quint32 seqNrBe = qToBigEndian(seqNr); + QByteArray data(reinterpret_cast(&seqNrBe), sizeof seqNrBe); + data += QByteArray(m_data.constData(), length() + 4); + return crypt.generateMac(data, data.size()); +} + +quint32 AbstractSshPacket::minPacketSize() const +{ + return qMax(cipherBlockSize(), 16) + macLength(); +} + +void AbstractSshPacket::setLengthField(QByteArray &data) +{ + const quint32 length = qToBigEndian(data.size() - 4); + data.replace(0, 4, reinterpret_cast(&length), 4); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshpacket_p.h b/src/plugins/coreplugin/ssh/sshpacket_p.h new file mode 100644 index 00000000000..7120f001fd5 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshpacket_p.h @@ -0,0 +1,137 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHPACKET_P_H +#define SSHPACKET_P_H + +#include "sshexception_p.h" + +#include +#include +#include + +#include + +namespace Core { +namespace Internal { + +enum SshPacketType { + SSH_MSG_DISCONNECT = 1, + SSH_MSG_IGNORE = 2, + SSH_MSG_UNIMPLEMENTED = 3, + SSH_MSG_DEBUG = 4, + SSH_MSG_SERVICE_REQUEST = 5, + SSH_MSG_SERVICE_ACCEPT = 6, + + SSH_MSG_KEXINIT = 20, + SSH_MSG_NEWKEYS = 21, + SSH_MSG_KEXDH_INIT = 30, + SSH_MSG_KEXDH_REPLY = 31, + + SSH_MSG_USERAUTH_REQUEST = 50, + SSH_MSG_USERAUTH_FAILURE = 51, + SSH_MSG_USERAUTH_SUCCESS = 52, + SSH_MSG_USERAUTH_BANNER = 53, + SSH_MSG_USERAUTH_PK_OK = 60, + SSH_MSG_USERAUTH_PASSWD_CHANGEREQ = 60, + + SSH_MSG_GLOBAL_REQUEST = 80, + SSH_MSG_REQUEST_SUCCESS = 81, + SSH_MSG_REQUEST_FAILURE = 82, + + SSH_MSG_CHANNEL_OPEN = 90, + SSH_MSG_CHANNEL_OPEN_CONFIRMATION = 91, + SSH_MSG_CHANNEL_OPEN_FAILURE = 92, + SSH_MSG_CHANNEL_WINDOW_ADJUST = 93, + SSH_MSG_CHANNEL_DATA = 94, + SSH_MSG_CHANNEL_EXTENDED_DATA = 95, + SSH_MSG_CHANNEL_EOF = 96, + SSH_MSG_CHANNEL_CLOSE = 97, + SSH_MSG_CHANNEL_REQUEST = 98, + SSH_MSG_CHANNEL_SUCCESS = 99, + SSH_MSG_CHANNEL_FAILURE = 100, +}; + +enum SshExtendedDataType { SSH_EXTENDED_DATA_STDERR = 1 }; + +class SshAbstractCryptoFacility; + +class AbstractSshPacket +{ +public: + virtual ~AbstractSshPacket(); + + void clear(); + bool isComplete() const; + SshPacketType type() const; + + static QByteArray encodeString(const QByteArray &string); + static QByteArray encodeMpInt(const Botan::BigInt &number); + template static QByteArray encodeInt(T value) + { + const T valMsb = qToBigEndian(value); + return QByteArray(reinterpret_cast(&valMsb), sizeof valMsb); + } + + static void setLengthField(QByteArray &data); + + void printRawBytes() const; // For Debugging. + + const QByteArray &rawData() const { return m_data; } + + struct Payload { const char *data; quint32 size; }; + Payload payLoad() const; + +protected: + AbstractSshPacket(); + + virtual quint32 cipherBlockSize() const=0; + virtual quint32 macLength() const=0; + virtual void calculateLength() const; + + quint32 length() const; + int paddingLength() const; + quint32 minPacketSize() const; + quint32 currentDataSize() const { return m_data.size(); } + QByteArray generateMac(const SshAbstractCryptoFacility &crypt, + quint32 seqNr) const; + + static const quint32 PaddingLengthOffset; + static const quint32 PayloadOffset; + static const quint32 TypeOffset; + static const quint32 MinPaddingLength; + + mutable QByteArray m_data; + mutable quint32 m_length; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHPACKET_P_H diff --git a/src/plugins/coreplugin/ssh/sshpacketparser.cpp b/src/plugins/coreplugin/ssh/sshpacketparser.cpp new file mode 100644 index 00000000000..2f339c03d92 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshpacketparser.cpp @@ -0,0 +1,153 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshpacketparser_p.h" + +#include + +namespace Core { +namespace Internal { + +namespace { quint32 size(const QByteArray &data) { return data.size(); } } + +QString SshPacketParser::asUserString(const QByteArray &rawString) +{ + QByteArray filteredString; + filteredString.resize(rawString.size()); + for (int i = 0; i < rawString.size(); ++i) { + const char c = rawString.at(i); + filteredString[i] + = std::isprint(c) || c == '\n' || c == '\r' || c == '\t' ? c : '?'; + } + return QString::fromUtf8(filteredString); +} + +bool SshPacketParser::asBool(const QByteArray &data, quint32 offset) +{ + if (size(data) <= offset) + throw SshPacketParseException(); + return data.at(offset); +} + +bool SshPacketParser::asBool(const QByteArray &data, quint32 *offset) +{ + bool b = asBool(data, *offset); + ++(*offset); + return b; +} + + +quint32 SshPacketParser::asUint32(const QByteArray &data, quint32 offset) +{ + if (size(data) < offset + 4) + throw SshPacketParseException(); + const quint32 value = ((data.at(offset) & 0xff) << 24) + + ((data.at(offset + 1) & 0xff) << 16) + + ((data.at(offset + 2) & 0xff) << 8) + (data.at(offset + 3) & 0xff); + return value; +} + +quint32 SshPacketParser::asUint32(const QByteArray &data, quint32 *offset) +{ + const quint32 v = asUint32(data, *offset); + *offset += 4; + return v; +} + +quint64 SshPacketParser::asUint64(const QByteArray &data, quint32 offset) +{ + if (size(data) < offset + 8) + throw SshPacketParseException(); + const quint64 value = (static_cast(data.at(offset) & 0xff) << 56) + + (static_cast(data.at(offset + 1) & 0xff) << 48) + + (static_cast(data.at(offset + 2) & 0xff) << 40) + + (static_cast(data.at(offset + 3) & 0xff) << 32) + + ((data.at(offset + 4) & 0xff) << 24) + + ((data.at(offset + 5) & 0xff) << 16) + + ((data.at(offset + 6) & 0xff) << 8) + + (data.at(offset + 7) & 0xff); + return value; +} + +quint64 SshPacketParser::asUint64(const QByteArray &data, quint32 *offset) +{ + const quint64 val = asUint64(data, *offset); + *offset += 8; + return val; +} + +QByteArray SshPacketParser::asString(const QByteArray &data, quint32 *offset) +{ + const quint32 length = asUint32(data, offset); + if (size(data) < *offset + length) + throw SshPacketParseException(); + const QByteArray &string = data.mid(*offset, length); + *offset += length; + return string; +} + +QString SshPacketParser::asUserString(const QByteArray &data, quint32 *offset) +{ + return asUserString(asString(data, offset)); +} + +SshNameList SshPacketParser::asNameList(const QByteArray &data, quint32 *offset) +{ + const quint32 length = asUint32(data, offset); + const int listEndPos = *offset + length; + if (data.size() < listEndPos) + throw SshPacketParseException(); + SshNameList names(length + 4); + int nextNameOffset = *offset; + int nextCommaOffset = data.indexOf(',', nextNameOffset); + while (nextNameOffset > 0 && nextNameOffset < listEndPos) { + const int stringEndPos = nextCommaOffset == -1 + || nextCommaOffset > listEndPos ? listEndPos : nextCommaOffset; + names.names << QByteArray(data.constData() + nextNameOffset, + stringEndPos - nextNameOffset); + nextNameOffset = nextCommaOffset + 1; + nextCommaOffset = data.indexOf(',', nextNameOffset); + } + *offset += length; + return names; +} + +Botan::BigInt SshPacketParser::asBigInt(const QByteArray &data, quint32 *offset) +{ + const quint32 length = asUint32(data, offset); + if (length == 0) + return Botan::BigInt(); + const Botan::byte *numberStart + = reinterpret_cast(data.constData() + *offset); + *offset += length; + return Botan::BigInt::decode(numberStart, length); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshpacketparser_p.h b/src/plugins/coreplugin/ssh/sshpacketparser_p.h new file mode 100644 index 00000000000..253f256b7be --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshpacketparser_p.h @@ -0,0 +1,81 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHPACKETPARSER_P_H +#define SSHPACKETPARSER_P_H + +#include + +#include +#include +#include + +namespace Core { +namespace Internal { + +struct SshNameList +{ + SshNameList() : originalLength(0) {} + SshNameList(quint32 originalLength) : originalLength(originalLength) {} + quint32 originalLength; + QList names; +}; + +class SshPacketParseException { }; + +// This class's functions try to read a byte array at a certain offset +// as the respective chunk of data as specified in the SSH RFCs. +// If they succeed, they update the offset, so they can easily +// be called in succession by client code. +// For convenience, some have also versions that don't update the offset, +// so they can be called with rvalues if the new value is not needed. +// If they fail, they throw an SshPacketParseException. +class SshPacketParser +{ +public: + static bool asBool(const QByteArray &data, quint32 offset); + static bool asBool(const QByteArray &data, quint32 *offset); + static quint16 asUint16(const QByteArray &data, quint32 offset); + static quint16 asUint16(const QByteArray &data, quint32 *offset); + static quint64 asUint64(const QByteArray &data, quint32 offset); + static quint64 asUint64(const QByteArray &data, quint32 *offset); + static quint32 asUint32(const QByteArray &data, quint32 offset); + static quint32 asUint32(const QByteArray &data, quint32 *offset); + static QByteArray asString(const QByteArray &data, quint32 *offset); + static QString asUserString(const QByteArray &data, quint32 *offset); + static SshNameList asNameList(const QByteArray &data, quint32 *offset); + static Botan::BigInt asBigInt(const QByteArray &data, quint32 *offset); + + static QString asUserString(const QByteArray &rawString); +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHPACKETPARSER_P_H diff --git a/src/plugins/coreplugin/ssh/sshremoteprocess.cpp b/src/plugins/coreplugin/ssh/sshremoteprocess.cpp new file mode 100644 index 00000000000..c9566e9aca9 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshremoteprocess.cpp @@ -0,0 +1,270 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshremoteprocess.h" +#include "sshremoteprocess_p.h" + +#include "sshdelayedsignal_p.h" +#include "sshincomingpacket_p.h" +#include "sshsendfacility_p.h" + +#include + +namespace Core { + +const QByteArray SshRemoteProcess::AbrtSignal("ABRT"); +const QByteArray SshRemoteProcess::AlrmSignal("ALRM"); +const QByteArray SshRemoteProcess::FpeSignal("FPE"); +const QByteArray SshRemoteProcess::HupSignal("HUP"); +const QByteArray SshRemoteProcess::IllSignal("ILL"); +const QByteArray SshRemoteProcess::IntSignal("INT"); +const QByteArray SshRemoteProcess::KillSignal("KILL"); +const QByteArray SshRemoteProcess::PipeSignal("PIPE"); +const QByteArray SshRemoteProcess::QuitSignal("QUIT"); +const QByteArray SshRemoteProcess::SegvSignal("SEGV"); +const QByteArray SshRemoteProcess::TermSignal("TERM"); +const QByteArray SshRemoteProcess::Usr1Signal("USR1"); +const QByteArray SshRemoteProcess::Usr2Signal("USR2"); + +SshRemoteProcess::SshRemoteProcess(const QByteArray &command, quint32 channelId, + Internal::SshSendFacility &sendFacility) + : d(new Internal::SshRemoteProcessPrivate(command, channelId, sendFacility, this)) +{ +} + +SshRemoteProcess::~SshRemoteProcess() +{ + Q_ASSERT(d->channelState() == Internal::SshRemoteProcessPrivate::Inactive + || d->channelState() == Internal::SshRemoteProcessPrivate::CloseRequested + || d->channelState() == Internal::SshRemoteProcessPrivate::Closed); + delete d; +} + +void SshRemoteProcess::addToEnvironment(const QByteArray &var, const QByteArray &value) +{ + if (d->channelState() == Internal::SshRemoteProcessPrivate::Inactive) + d->m_env << qMakePair(var, value); // Cached locally and sent on start() +} + +void SshRemoteProcess::start() +{ + if (d->channelState() == Internal::SshRemoteProcessPrivate::Inactive) { +#ifdef CREATOR_SSH_DEBUG + qDebug("process start requested, channel id = %u", d->localChannelId()); +#endif + d->requestSessionStart(); + } +} + +void SshRemoteProcess::sendSignal(const QByteArray &signal) +{ + try { + if (isRunning()) + d->m_sendFacility.sendChannelSignalPacket(d->remoteChannel(), + signal); + } catch (Botan::Exception &e) { + d->setError(QString::fromAscii(e.what())); + d->closeChannel(); + } +} + +void SshRemoteProcess::closeChannel() +{ + d->closeChannel(); +} + +void SshRemoteProcess::sendInput(const QByteArray &data) +{ + if (isRunning()) + d->sendData(data); +} + +bool SshRemoteProcess::isRunning() const +{ + return d->m_procState == Internal::SshRemoteProcessPrivate::Running; +} + +QString SshRemoteProcess::errorString() const { return d->errorString(); } + +int SshRemoteProcess::exitCode() const { return d->m_exitCode; } + +QByteArray SshRemoteProcess::exitSignal() const { return d->m_signal; } + +namespace Internal { + +SshRemoteProcessPrivate::SshRemoteProcessPrivate(const QByteArray &command, + quint32 channelId, SshSendFacility &sendFacility, SshRemoteProcess *proc) + : AbstractSshChannel(channelId, sendFacility), m_procState(NotYetStarted), + m_wasRunning(false), m_exitCode(0), m_command(command), m_proc(proc) +{ +} + +void SshRemoteProcessPrivate::setProcState(ProcessState newState) +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("channel: old state = %d,new state = %d", m_procState, newState); +#endif + m_procState = newState; + if (newState == StartFailed) { + createClosedSignal(SshRemoteProcess::FailedToStart); + } else if (newState == Running) { + m_wasRunning = true; + createStartedSignal(); + } +} + +void SshRemoteProcessPrivate::closeHook() +{ + if (m_wasRunning) { + if (!m_signal.isEmpty()) + createClosedSignal(SshRemoteProcess::KilledBySignal); + else + createClosedSignal(SshRemoteProcess::ExitedNormally); + } +} + +void SshRemoteProcessPrivate::handleOpenSuccessInternal() +{ + foreach (const EnvVar &envVar, m_env) { + m_sendFacility.sendEnvPacket(remoteChannel(), envVar.first, + envVar.second); + } + + m_sendFacility.sendExecPacket(remoteChannel(), m_command); + setProcState(ExecRequested); +} + +void SshRemoteProcessPrivate::handleOpenFailureInternal() +{ + setProcState(StartFailed); +} + +void SshRemoteProcessPrivate::handleChannelSuccess() +{ + if (m_procState != ExecRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_SUCCESS message."); + } + setProcState(Running); +} + +void SshRemoteProcessPrivate::handleChannelFailure() +{ + if (m_procState != ExecRequested) { + throw SSH_SERVER_EXCEPTION(SSH_DISCONNECT_PROTOCOL_ERROR, + "Unexpected SSH_MSG_CHANNEL_FAILURE message."); + } + + setProcState(StartFailed); + closeChannel(); +} + +void SshRemoteProcessPrivate::handleChannelDataInternal(const QByteArray &data) +{ + createOutputAvailableSignal(data); +} + +void SshRemoteProcessPrivate::handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data) +{ + if (type != SSH_EXTENDED_DATA_STDERR) + qWarning("Unknown extended data type %u", type); + else + createErrorOutputAvailableSignal(data); +} + +void SshRemoteProcessPrivate::handleChannelRequest(const SshIncomingPacket &packet) +{ + checkChannelActive(); + const QByteArray &requestType = packet.extractChannelRequestType(); + if (requestType == SshIncomingPacket::ExitStatusType) { + const SshChannelExitStatus status = packet.extractChannelExitStatus(); +#ifdef CREATOR_SSH_DEBUG + qDebug("Process exiting with exit code %d", status.exitStatus); +#endif + m_exitCode = status.exitStatus; + m_procState = Exited; + } else if (requestType == SshIncomingPacket::ExitSignalType) { + const SshChannelExitSignal &signal = packet.extractChannelExitSignal(); +#ifdef CREATOR_SSH_DEBUG + qDebug("Exit due to signal %s", signal.signal.data()); +#endif + setError(signal.error); + m_signal = signal.signal; + m_procState = Exited; + } else { + qWarning("Ignoring unknown request type '%s'", requestType.data()); + } +} + +void SshRemoteProcessPrivate::createStartedSignal() +{ + new SshRemoteProcessStartedSignal(this, QWeakPointer(m_proc)); +} + +void SshRemoteProcessPrivate::emitStartedSignal() +{ + emit m_proc->started(); +} + +void SshRemoteProcessPrivate::createOutputAvailableSignal(const QByteArray &output) +{ + new SshRemoteProcessOutputAvailableSignal(this, + QWeakPointer(m_proc), output); +} + +void SshRemoteProcessPrivate::emitOutputAvailableSignal(const QByteArray &output) +{ + emit m_proc->outputAvailable(output); +} + +void SshRemoteProcessPrivate::createErrorOutputAvailableSignal(const QByteArray &output) +{ + new SshRemoteProcessErrorOutputAvailableSignal(this, + QWeakPointer(m_proc), output); +} + +void SshRemoteProcessPrivate::emitErrorOutputAvailableSignal(const QByteArray &output) +{ + emit m_proc->errorOutputAvailable(output); +} + +void SshRemoteProcessPrivate::createClosedSignal(int exitStatus) +{ + new SshRemoteProcessClosedSignal(this, + QWeakPointer(m_proc), exitStatus); +} + +void SshRemoteProcessPrivate::emitClosedSignal(int exitStatus) +{ + emit m_proc->closed(exitStatus); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshremoteprocess.h b/src/plugins/coreplugin/ssh/sshremoteprocess.h new file mode 100644 index 00000000000..941894990f6 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshremoteprocess.h @@ -0,0 +1,130 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHREMOTECOMMAND_H +#define SSHREMOTECOMMAND_H + +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QByteArray; +QT_END_NAMESPACE + +namespace Core { +namespace Internal { +class SshChannelManager; +class SshRemoteProcessPrivate; +class SshSendFacility; +} // namespace Internal + + +/* + * This class implements an SSH channel for running a remote process. + * Objects are created via SshConnection::createRemoteProcess. + * The process is started via the start() member function. + * A closeChannel() function is provided, but rarely useful, because + * a) when the process ends, the channel is closed automatically, and + * b) closing a channel will not necessarily kill the remote process. + * Therefore, the only sensible use case for calling closeChannel() is to + * get rid of an SshRemoteProces object before the process is actually started. + * Note that the process does not have a terminal, so you can't use it + * for applications that require one. + */ +class CORE_EXPORT SshRemoteProcess : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(SshRemoteProcess) + + friend class Internal::SshChannelManager; + friend class Internal::SshRemoteProcessPrivate; + +public: + typedef QSharedPointer Ptr; + enum ExitStatus { FailedToStart, KilledBySignal, ExitedNormally }; + + static const QByteArray AbrtSignal; + static const QByteArray AlrmSignal; + static const QByteArray FpeSignal; + static const QByteArray HupSignal; + static const QByteArray IllSignal; + static const QByteArray IntSignal; + static const QByteArray KillSignal; + static const QByteArray PipeSignal; + static const QByteArray QuitSignal; + static const QByteArray SegvSignal; + static const QByteArray TermSignal; + static const QByteArray Usr1Signal; + static const QByteArray Usr2Signal; + + ~SshRemoteProcess(); + + /* + * Note that this is of limited value in practice, because servers are + * usually configured to ignore such requests for security reasons. + */ + void addToEnvironment(const QByteArray &var, const QByteArray &value); + + void start(); + void closeChannel(); + + bool isRunning() const; + QString errorString() const; + int exitCode() const; + QByteArray exitSignal() const; + + // Note: This is ignored by the OpenSSH server. + void sendSignal(const QByteArray &signal); + void kill() { sendSignal(KillSignal); } + + void sendInput(const QByteArray &data); // Should usually have a trailing newline. + +signals: + void started(); + void outputAvailable(const QByteArray &output); + void errorOutputAvailable(const QByteArray &output); + + /* + * Parameter is of type ExitStatus, but we use int because of + * signal/slot awkwardness (full namespace required). + */ + void closed(int exitStatus); + +private: + SshRemoteProcess(const QByteArray &command, quint32 channelId, + Internal::SshSendFacility &sendFacility); + + Internal::SshRemoteProcessPrivate *d; +}; + +} // namespace Core + +#endif // SSHREMOTECOMMAND_H diff --git a/src/plugins/coreplugin/ssh/sshremoteprocess_p.h b/src/plugins/coreplugin/ssh/sshremoteprocess_p.h new file mode 100644 index 00000000000..951ca247310 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshremoteprocess_p.h @@ -0,0 +1,96 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHREMOTEPROCESS_P_H +#define SSHREMOTEPROCESS_P_H + +#include "sshchannel_p.h" + +#include +#include + +namespace Core { +class SshRemoteProcess; + +namespace Internal { +class SshSendFacility; + +class SshRemoteProcessPrivate : public AbstractSshChannel +{ + friend class Core::SshRemoteProcess; +public: + enum ProcessState { + NotYetStarted, ExecRequested, StartFailed,Running, Exited + }; + + virtual void handleChannelSuccess(); + virtual void handleChannelFailure(); + + virtual void closeHook(); + + void emitStartedSignal(); + void emitOutputAvailableSignal(const QByteArray &output); + void emitErrorOutputAvailableSignal(const QByteArray &output); + void emitClosedSignal(int exitStatus); + +private: + SshRemoteProcessPrivate(const QByteArray &command, quint32 channelId, + SshSendFacility &sendFacility, SshRemoteProcess *proc); + + virtual void handleOpenSuccessInternal(); + virtual void handleOpenFailureInternal(); + virtual void handleChannelDataInternal(const QByteArray &data); + virtual void handleChannelExtendedDataInternal(quint32 type, + const QByteArray &data); + virtual void handleChannelRequest(const SshIncomingPacket &packet); + + void setProcState(ProcessState newState); + + void createStartedSignal(); + void createOutputAvailableSignal(const QByteArray &output); + void createErrorOutputAvailableSignal(const QByteArray &output); + void createClosedSignal(int exitStatus); + + ProcessState m_procState; + bool m_wasRunning; + QByteArray m_signal; + int m_exitCode; + + const QByteArray m_command; + + typedef QPair EnvVar; + QList m_env; + + SshRemoteProcess *m_proc; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHREMOTEPROCESS_P_H diff --git a/src/plugins/coreplugin/ssh/sshsendfacility.cpp b/src/plugins/coreplugin/ssh/sshsendfacility.cpp new file mode 100644 index 00000000000..3c793af24d7 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshsendfacility.cpp @@ -0,0 +1,191 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "sshsendfacility_p.h" + +#include "sshkeyexchange_p.h" +#include "sshoutgoingpacket_p.h" + +#include + +namespace Core { +namespace Internal { + +SshSendFacility::SshSendFacility(QTcpSocket *socket) + : m_clientSeqNr(0), m_socket(socket), + m_outgoingPacket(m_encrypter, m_clientSeqNr) +{ +} + +void SshSendFacility::sendPacket() +{ +#ifdef CREATOR_SSH_DEBUG + qDebug("Sending packet, client seq nr is %u", m_clientSeqNr); +#endif + m_socket->write(m_outgoingPacket.rawData()); + ++m_clientSeqNr; +} + +void SshSendFacility::reset() +{ + m_clientSeqNr = 0; + m_encrypter.clearKeys(); +} + +void SshSendFacility::recreateKeys(const SshKeyExchange &keyExchange) +{ + m_encrypter.recreateKeys(keyExchange); +} + +void SshSendFacility::createAuthenticationKey(const QByteArray &privKeyFileContents) +{ + m_encrypter.createAuthenticationKey(privKeyFileContents); +} + +SshOutgoingPacket::Payload SshSendFacility::sendKeyExchangeInitPacket() +{ + m_outgoingPacket.generateKeyExchangeInitPacket(); + sendPacket(); + return m_outgoingPacket.payLoad(); +} + +void SshSendFacility::sendKeyDhInitPacket(const Botan::BigInt &e) +{ + m_outgoingPacket.generateKeyDhInitPacket(e); + sendPacket(); +} + +void SshSendFacility::sendNewKeysPacket() +{ + m_outgoingPacket.generateNewKeysPacket(); + sendPacket(); +} + +void SshSendFacility::sendDisconnectPacket(SshErrorCode reason, + const QByteArray &reasonString) +{ + m_outgoingPacket.generateDisconnectPacket(reason, reasonString); + sendPacket(); + } + +void SshSendFacility::sendMsgUnimplementedPacket(quint32 serverSeqNr) +{ + m_outgoingPacket.generateMsgUnimplementedPacket(serverSeqNr); + sendPacket(); +} + +void SshSendFacility::sendUserAuthServiceRequestPacket() +{ + m_outgoingPacket.generateUserAuthServiceRequestPacket(); + sendPacket(); +} + +void SshSendFacility::sendUserAuthByPwdRequestPacket(const QByteArray &user, + const QByteArray &service, const QByteArray &pwd) +{ + m_outgoingPacket.generateUserAuthByPwdRequestPacket(user, service, pwd); + sendPacket(); + } + +void SshSendFacility::sendUserAuthByKeyRequestPacket(const QByteArray &user, + const QByteArray &service) +{ + m_outgoingPacket.generateUserAuthByKeyRequestPacket(user, service); + sendPacket(); +} + +void SshSendFacility::sendRequestFailurePacket() +{ + m_outgoingPacket.generateRequestFailurePacket(); + sendPacket(); +} + +void SshSendFacility::sendSessionPacket(quint32 channelId, quint32 windowSize, + quint32 maxPacketSize) +{ + m_outgoingPacket.generateSessionPacket(channelId, windowSize, + maxPacketSize); + sendPacket(); +} + +void SshSendFacility::sendEnvPacket(quint32 remoteChannel, + const QByteArray &var, const QByteArray &value) +{ + m_outgoingPacket.generateEnvPacket(remoteChannel, var, value); + sendPacket(); +} + +void SshSendFacility::sendExecPacket(quint32 remoteChannel, + const QByteArray &command) +{ + m_outgoingPacket.generateExecPacket(remoteChannel, command); + sendPacket(); +} + +void SshSendFacility::sendSftpPacket(quint32 remoteChannel) +{ + m_outgoingPacket.generateSftpPacket(remoteChannel); + sendPacket(); +} + +void SshSendFacility::sendWindowAdjustPacket(quint32 remoteChannel, + quint32 bytesToAdd) +{ + m_outgoingPacket.generateWindowAdjustPacket(remoteChannel, bytesToAdd); + sendPacket(); +} + +void SshSendFacility::sendChannelDataPacket(quint32 remoteChannel, + const QByteArray &data) +{ + m_outgoingPacket.generateChannelDataPacket(remoteChannel, data); + sendPacket(); +} + +void SshSendFacility::sendChannelSignalPacket(quint32 remoteChannel, + const QByteArray &signalName) +{ + m_outgoingPacket.generateChannelSignalPacket(remoteChannel, signalName); + sendPacket(); +} + +void SshSendFacility::sendChannelEofPacket(quint32 remoteChannel) +{ + m_outgoingPacket.generateChannelEofPacket(remoteChannel); + sendPacket(); +} + +void SshSendFacility::sendChannelClosePacket(quint32 remoteChannel) +{ + m_outgoingPacket.generateChannelClosePacket(remoteChannel); + sendPacket(); +} + +} // namespace Internal +} // namespace Core diff --git a/src/plugins/coreplugin/ssh/sshsendfacility_p.h b/src/plugins/coreplugin/ssh/sshsendfacility_p.h new file mode 100644 index 00000000000..6f1cdf76f38 --- /dev/null +++ b/src/plugins/coreplugin/ssh/sshsendfacility_p.h @@ -0,0 +1,90 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SSHCONNECTIONOUTSTATE_P_H +#define SSHCONNECTIONOUTSTATE_P_H + +#include "sshcryptofacility_p.h" +#include "sshoutgoingpacket_p.h" + +QT_BEGIN_NAMESPACE +class QTcpSocket; +QT_END_NAMESPACE + + +namespace Core { +namespace Internal { +class SshKeyExchange; + +class SshSendFacility +{ +public: + SshSendFacility(QTcpSocket *socket); + void reset(); + void recreateKeys(const SshKeyExchange &keyExchange); + void createAuthenticationKey(const QByteArray &privKeyFileContents); + + SshOutgoingPacket::Payload sendKeyExchangeInitPacket(); + void sendKeyDhInitPacket(const Botan::BigInt &e); + void sendNewKeysPacket(); + void sendDisconnectPacket(SshErrorCode reason, + const QByteArray &reasonString); + void sendMsgUnimplementedPacket(quint32 serverSeqNr); + void sendUserAuthServiceRequestPacket(); + void sendUserAuthByPwdRequestPacket(const QByteArray &user, + const QByteArray &service, const QByteArray &pwd); + void sendUserAuthByKeyRequestPacket(const QByteArray &user, + const QByteArray &service); + void sendRequestFailurePacket(); + void sendSessionPacket(quint32 channelId, quint32 windowSize, + quint32 maxPacketSize); + void sendEnvPacket(quint32 remoteChannel, const QByteArray &var, + const QByteArray &value); + void sendExecPacket(quint32 remoteChannel, const QByteArray &command); + void sendSftpPacket(quint32 remoteChannel); + void sendWindowAdjustPacket(quint32 remoteChannel, quint32 bytesToAdd); + void sendChannelDataPacket(quint32 remoteChannel, const QByteArray &data); + void sendChannelSignalPacket(quint32 remoteChannel, + const QByteArray &signalName); + void sendChannelEofPacket(quint32 remoteChannel); + void sendChannelClosePacket(quint32 remoteChannel); + +private: + void sendPacket(); + + quint32 m_clientSeqNr; + SshEncryptionFacility m_encrypter; + QTcpSocket *m_socket; + SshOutgoingPacket m_outgoingPacket; +}; + +} // namespace Internal +} // namespace Core + +#endif // SSHCONNECTIONOUTSTATE_P_H diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 0f7ba095238..c542087c251 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -87,7 +87,7 @@ public: QString dumperLibrary; QStringList dumperLibraryLocations; - Core::SshServerInfo sshserver; + Core::SshConnectionParameters connParams; DebuggerStartMode startMode; }; diff --git a/src/plugins/debugger/gdb/remotegdbprocess.cpp b/src/plugins/debugger/gdb/remotegdbprocess.cpp index fb7e2d02817..7288f44c7b8 100644 --- a/src/plugins/debugger/gdb/remotegdbprocess.cpp +++ b/src/plugins/debugger/gdb/remotegdbprocess.cpp @@ -33,14 +33,15 @@ #include +using namespace Core; + namespace Debugger { namespace Internal { -RemoteGdbProcess::RemoteGdbProcess(const Core::SshServerInfo &server, +RemoteGdbProcess::RemoteGdbProcess(const Core::SshConnectionParameters &connParams, RemotePlainGdbAdapter *adapter, QObject *parent) - : AbstractGdbProcess(parent), m_serverInfo(server), m_adapter(adapter) + : AbstractGdbProcess(parent), m_connParams(connParams), m_adapter(adapter) { - } QByteArray RemoteGdbProcess::readAllStandardOutput() @@ -59,68 +60,122 @@ QByteArray RemoteGdbProcess::readAllStandardError() void RemoteGdbProcess::start(const QString &cmd, const QStringList &args) { - m_gdbConn = Core::InteractiveSshConnection::create(m_serverInfo); - m_appOutputConn = Core::InteractiveSshConnection::create(m_serverInfo); - m_errOutputConn = Core::InteractiveSshConnection::create(m_serverInfo); m_command = cmd; m_cmdArgs = args; - m_errOutputConn->start(); - m_appOutputConn->start(); - m_gdbConn->start(); - } + m_gdbStarted = false; + m_error.clear(); + m_conn = SshConnection::create(); + connect(m_conn.data(), SIGNAL(connected()), this, SLOT(handleConnected())); + connect(m_conn.data(), SIGNAL(error(SshError)), this, + SLOT(handleConnectionError())); + m_conn->connectToHost(m_connParams); +} + +void RemoteGdbProcess::handleConnected() +{ + m_fifoCreator = m_conn->createRemoteProcess( "rm -f " + + AppOutputFile + " && mkfifo " + AppOutputFile); + connect(m_fifoCreator.data(), SIGNAL(closed(int)), this, + SLOT(handleFifoCreationFinished(int))); + m_fifoCreator->start(); +} + +void RemoteGdbProcess::handleConnectionError() +{ + emitErrorExit(tr("Connection could not be established.")); +} + +void RemoteGdbProcess::handleFifoCreationFinished(int exitStatus) +{ + if (exitStatus != SshRemoteProcess::ExitedNormally) { + emitErrorExit(tr("Could not create FIFO.")); + } else { + m_appOutputReader = m_conn->createRemoteProcess("cat " + AppOutputFile); + connect(m_appOutputReader.data(), SIGNAL(started()), this, + SLOT(handleAppOutputReaderStarted())); + connect(m_appOutputReader.data(), SIGNAL(closed(int)), this, + SLOT(handleAppOutputReaderFinished(int))); + m_appOutputReader->start(); + } +} + +void RemoteGdbProcess::handleAppOutputReaderStarted() +{ + connect(m_appOutputReader.data(), SIGNAL(outputAvailable(QByteArray)), + this, SLOT(handleAppOutput(QByteArray))); + QByteArray cmdLine = "DISPLAY=:0.0 " + m_command.toUtf8() + ' ' + + m_cmdArgs.join(QLatin1String(" ")).toUtf8() + + " -tty=" + AppOutputFile; + if (!m_wd.isEmpty()) + cmdLine.prepend("cd " + m_wd.toUtf8() + " && "); + m_gdbProc = m_conn->createRemoteProcess(cmdLine); + connect(m_gdbProc.data(), SIGNAL(started()), this, + SLOT(handleGdbStarted())); + connect(m_gdbProc.data(), SIGNAL(closed(int)), this, + SLOT(handleGdbFinished(int))); + connect(m_gdbProc.data(), SIGNAL(outputAvailable(QByteArray)), this, + SLOT(handleGdbOutput(QByteArray))); + connect(m_gdbProc.data(), SIGNAL(errorOutputAvailable(QByteArray)), this, + SLOT(handleErrOutput(QByteArray))); + m_gdbProc->start(); +} + +void RemoteGdbProcess::handleAppOutputReaderFinished(int exitStatus) +{ + if (exitStatus != SshRemoteProcess::ExitedNormally) + emitErrorExit(tr("Application output reader unexpectedly finished.")); +} + +void RemoteGdbProcess::handleGdbStarted() +{ + m_gdbStarted = true; +} + +void RemoteGdbProcess::handleGdbFinished(int exitStatus) +{ + switch (exitStatus) { + case SshRemoteProcess::FailedToStart: + emitErrorExit(tr("Remote gdb failed to start.")); + break; + case SshRemoteProcess::KilledBySignal: + emitErrorExit(tr("Remote gdb crashed.")); + break; + case SshRemoteProcess::ExitedNormally: + emit finished(m_gdbProc->exitCode(), QProcess::NormalExit); + break; + } + disconnect(m_conn.data(), 0, this, 0); + m_gdbProc = SshRemoteProcess::Ptr(); + m_appOutputReader = SshRemoteProcess::Ptr(); + m_conn->disconnectFromHost(); +} bool RemoteGdbProcess::waitForStarted() { - if (!waitForInputReady(m_appOutputConn)) - return false; - if (!sendAndWaitForEcho(m_appOutputConn, readerCmdLine(AppOutputFile))) - return false; - if (!waitForInputReady(m_errOutputConn)) - return false; - if (!sendAndWaitForEcho(m_errOutputConn, readerCmdLine(ErrOutputFile))) - return false; - if (!waitForInputReady(m_gdbConn)) - return false; - connect(m_appOutputConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleAppOutput())); - connect(m_errOutputConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleErrOutput())); - connect(m_gdbConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleGdbOutput())); - m_gdbStarted = false; - m_gdbCmdLine = "stty -echo && DISPLAY=:0.0 " + m_command.toUtf8() + ' ' - + m_cmdArgs.join(QLatin1String(" ")).toUtf8() - + " -tty=" + AppOutputFile + " 2>" + ErrOutputFile + '\n'; - if (!m_wd.isEmpty()) - m_gdbCmdLine.prepend("cd " + m_wd.toUtf8() + " && "); - if (sendInput(m_gdbCmdLine) != m_gdbCmdLine.count()) - return false; - - return true; + return m_error.isEmpty(); } qint64 RemoteGdbProcess::write(const QByteArray &data) { - if (!m_gdbStarted || !m_inputToSend.isEmpty() || !m_lastSeqNr.isEmpty()) { + if (!m_gdbStarted || !m_inputToSend.isEmpty() || !m_lastSeqNr.isEmpty()) m_inputToSend.enqueue(data); - return data.size(); - } else { - return sendInput(data); - } + else + sendInput(data); + return data.size(); } void RemoteGdbProcess::kill() { - stopReaders(); - Core::InteractiveSshConnection::Ptr controlConn - = Core::InteractiveSshConnection::create(m_serverInfo); - if (!controlConn->hasError()) { - if (controlConn->start()) - controlConn->sendInput("pkill -x gdb\r\n"); - } + SshRemoteProcess::Ptr killProc + = m_conn->createRemoteProcess("pkill -SIGKILL -x gdb"); + killProc->start(); +} - m_gdbConn->quit(); - emit finished(0, QProcess::CrashExit); +void RemoteGdbProcess::interruptInferior() +{ + SshRemoteProcess::Ptr intProc + = m_conn->createRemoteProcess("pkill -x -SIGINT gdb"); + intProc->start(); } QProcess::ProcessState RemoteGdbProcess::state() const @@ -130,35 +185,19 @@ QProcess::ProcessState RemoteGdbProcess::state() const QString RemoteGdbProcess::errorString() const { - return m_gdbConn ? m_gdbConn->error() : QString(); + return m_error; } -void RemoteGdbProcess::handleGdbOutput() +void RemoteGdbProcess::handleGdbOutput(const QByteArray &output) { - m_currentGdbOutput - += removeCarriageReturn(m_gdbConn->waitForRemoteOutput(0)); + // TODO: Carriage return removal still necessary? + m_currentGdbOutput += removeCarriageReturn(output); #if 0 qDebug("%s: complete unread output is '%s'", Q_FUNC_INFO, m_currentGdbOutput.data()); #endif - if (checkForGdbExit(m_currentGdbOutput)) { - m_currentGdbOutput.clear(); - return; - } - if (!m_currentGdbOutput.endsWith('\n')) return; - if (!m_gdbStarted) { - const int index = m_currentGdbOutput.indexOf(m_gdbCmdLine); - if (index != -1) - m_currentGdbOutput.remove(index, m_gdbCmdLine.size()); - // Note: We can't guarantee that we will match the command line, - // because the remote terminal sometimes inserts control characters. - // Otherwise we could set m_gdbStarted here. - } - - m_gdbStarted = true; - if (m_currentGdbOutput.contains(m_lastSeqNr + '^')) m_lastSeqNr.clear(); @@ -187,7 +226,7 @@ QProcessEnvironment RemoteGdbProcess::processEnvironment() const void RemoteGdbProcess::setProcessEnvironment(const QProcessEnvironment & /* env */) { - // TODO: Do something. + // TODO: Do something. (if remote process exists: set, otherwise queue) } void RemoteGdbProcess::setEnvironment(const QStringList & /* env */) @@ -211,48 +250,27 @@ int RemoteGdbProcess::findAnchor(const QByteArray &data) const return -1; } -qint64 RemoteGdbProcess::sendInput(const QByteArray &data) +void RemoteGdbProcess::sendInput(const QByteArray &data) { int pos; for (pos = 0; pos < data.size(); ++pos) if (!isdigit(data.at(pos))) break; m_lastSeqNr = data.left(pos); - return m_gdbConn->sendInput(data) ? data.size() : 0; + m_gdbProc->sendInput(data); } -void RemoteGdbProcess::handleAppOutput() +void RemoteGdbProcess::handleAppOutput(const QByteArray &output) { - m_adapter->handleApplicationOutput(m_appOutputConn->waitForRemoteOutput(0)); + m_adapter->handleApplicationOutput(output); } -void RemoteGdbProcess::handleErrOutput() +void RemoteGdbProcess::handleErrOutput(const QByteArray &output) { - m_errorOutput += m_errOutputConn->waitForRemoteOutput(0); + m_errorOutput += output; emit readyReadStandardError(); } -void RemoteGdbProcess::stopReaders() -{ - if (m_appOutputConn) { - disconnect(m_appOutputConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleAppOutput())); - m_appOutputConn->sendInput(CtrlC); - m_appOutputConn->quit(); - } - if (m_errOutputConn) { - disconnect(m_errOutputConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleErrOutput())); - m_errOutputConn->sendInput(CtrlC); - m_errOutputConn->quit(); - } -} - -QByteArray RemoteGdbProcess::readerCmdLine(const QByteArray &file) -{ - return "rm -f " + file + " && mkfifo " + file + " && cat " + file + "\r\n"; -} - QByteArray RemoteGdbProcess::removeCarriageReturn(const QByteArray &data) { QByteArray output; @@ -264,48 +282,16 @@ QByteArray RemoteGdbProcess::removeCarriageReturn(const QByteArray &data) return output; } -bool RemoteGdbProcess::checkForGdbExit(QByteArray &output) +void RemoteGdbProcess::emitErrorExit(const QString &error) { - const QByteArray exitString("^exit"); - const int exitPos = output.indexOf(exitString); - if (exitPos == -1) - return false; - - emit finished(0, QProcess::NormalExit); - disconnect(m_gdbConn.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleGdbOutput())); - output.remove(exitPos + exitString.size(), output.size()); - stopReaders(); - return true; -} - -bool RemoteGdbProcess::waitForInputReady(Core::InteractiveSshConnection::Ptr &conn) -{ - if (conn->waitForRemoteOutput(m_serverInfo.timeout).isEmpty()) - return false; - while (!conn->waitForRemoteOutput(100).isEmpty()) - ; - return true; -} - -bool RemoteGdbProcess::sendAndWaitForEcho(Core::InteractiveSshConnection::Ptr &conn, - const QByteArray &cmdLine) -{ - conn->sendInput(cmdLine); - QByteArray allOutput; - while (!allOutput.endsWith(cmdLine)) { - const QByteArray curOutput = conn->waitForRemoteOutput(100); - if (curOutput.isEmpty()) - return false; - allOutput += curOutput; + if (m_error.isEmpty()) { + m_error = error; + emit finished(-1, QProcess::CrashExit); } - return true; } - const QByteArray RemoteGdbProcess::CtrlC = QByteArray(1, 0x3); const QByteArray RemoteGdbProcess::AppOutputFile("app_output"); -const QByteArray RemoteGdbProcess::ErrOutputFile("err_output"); } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/gdb/remotegdbprocess.h b/src/plugins/debugger/gdb/remotegdbprocess.h index 1008b334da7..9a9679b6952 100644 --- a/src/plugins/debugger/gdb/remotegdbprocess.h +++ b/src/plugins/debugger/gdb/remotegdbprocess.h @@ -33,6 +33,7 @@ #include "abstractgdbprocess.h" #include +#include #include #include @@ -46,7 +47,7 @@ class RemoteGdbProcess : public AbstractGdbProcess { Q_OBJECT public: - RemoteGdbProcess(const Core::SshServerInfo &server, + RemoteGdbProcess(const Core::SshConnectionParameters &server, RemotePlainGdbAdapter *adapter, QObject *parent = 0); virtual QByteArray readAllStandardOutput(); @@ -65,32 +66,37 @@ public: virtual void setEnvironment(const QStringList &env); virtual void setWorkingDirectory(const QString &dir); + void interruptInferior(); + static const QByteArray CtrlC; private slots: - void handleGdbOutput(); - void handleAppOutput(); - void handleErrOutput(); + void handleConnected(); + void handleConnectionError(); + void handleFifoCreationFinished(int exitStatus); + void handleAppOutputReaderStarted(); + void handleAppOutputReaderFinished(int exitStatus); + void handleGdbStarted(); + void handleGdbFinished(int exitStatus); + void handleGdbOutput(const QByteArray &output); + void handleAppOutput(const QByteArray &output); + void handleErrOutput(const QByteArray &output); private: static QByteArray readerCmdLine(const QByteArray &file); int findAnchor(const QByteArray &data) const; - qint64 sendInput(const QByteArray &data); - void stopReaders(); + void sendInput(const QByteArray &data); QByteArray removeCarriageReturn(const QByteArray &data); - bool checkForGdbExit(QByteArray &output); - bool sendAndWaitForEcho(Core::InteractiveSshConnection::Ptr &conn, - const QByteArray &cmdLine); - bool waitForInputReady(Core::InteractiveSshConnection::Ptr &conn); + void emitErrorExit(const QString &error); static const QByteArray AppOutputFile; - static const QByteArray ErrOutputFile; - Core::SshServerInfo m_serverInfo; - Core::InteractiveSshConnection::Ptr m_gdbConn; - Core::InteractiveSshConnection::Ptr m_appOutputConn; - Core::InteractiveSshConnection::Ptr m_errOutputConn; + Core::SshConnectionParameters m_connParams; + Core::SshConnection::Ptr m_conn; + Core::SshRemoteProcess::Ptr m_gdbProc; + Core::SshRemoteProcess::Ptr m_appOutputReader; + Core::SshRemoteProcess::Ptr m_fifoCreator; QByteArray m_gdbOutput; QByteArray m_errorOutput; QString m_command; @@ -99,7 +105,7 @@ private: QQueue m_inputToSend; QByteArray m_currentGdbOutput; QByteArray m_lastSeqNr; - QByteArray m_gdbCmdLine; + QString m_error; bool m_gdbStarted; RemotePlainGdbAdapter *m_adapter; diff --git a/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp b/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp index 2f519188833..88946c11360 100644 --- a/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp +++ b/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp @@ -40,7 +40,7 @@ namespace Internal { RemotePlainGdbAdapter::RemotePlainGdbAdapter(GdbEngine *engine, QObject *parent) : AbstractPlainGdbAdapter(engine, parent), - m_gdbProc(engine->startParameters().sshserver, this) + m_gdbProc(engine->startParameters().connParams, this) { } @@ -60,7 +60,7 @@ void RemotePlainGdbAdapter::startAdapter() void RemotePlainGdbAdapter::interruptInferior() { - m_gdbProc.write(RemoteGdbProcess::CtrlC); + m_gdbProc.interruptInferior(); } QByteArray RemotePlainGdbAdapter::execFilePath() const diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoconfigtestdialog.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoconfigtestdialog.cpp index eddb077acdd..575da23144e 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoconfigtestdialog.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoconfigtestdialog.cpp @@ -35,38 +35,14 @@ #include "maemoconfigtestdialog.h" #include "ui_maemoconfigtestdialog.h" -#include "maemosshthread.h" +#include "maemodeviceconfigurations.h" + +#include +#include #include -namespace { - -/** - * Class that waits until a thread is finished and then deletes it, and then - * schedules itself to be deleted. - */ -class SafeThreadDeleter : public QThread -{ -public: - SafeThreadDeleter(QThread *thread) : m_thread(thread) {} - ~SafeThreadDeleter() { wait(); } - -protected: - void run() - { - // Wait for m_thread to finish and then delete it - m_thread->wait(); - delete m_thread; - - // Schedule this thread for deletion - deleteLater(); - } - -private: - QThread *m_thread; -}; - -} // anonymous namespace +using namespace Core; namespace Qt4ProjectManager { namespace Internal { @@ -75,7 +51,6 @@ MaemoConfigTestDialog::MaemoConfigTestDialog(const MaemoDeviceConfig &config, QW : QDialog(parent) , m_ui(new Ui_MaemoConfigTestDialog) , m_config(config) - , m_deviceTester(0) { setAttribute(Qt::WA_DeleteOnClose); @@ -94,65 +69,86 @@ MaemoConfigTestDialog::~MaemoConfigTestDialog() void MaemoConfigTestDialog::startConfigTest() { - if (m_deviceTester) + if (m_testProcess) return; m_ui->testResultEdit->setPlainText(tr("Testing configuration...")); m_closeButton->setText(tr("Stop Test")); + m_connection = SshConnection::create(); + connect(m_connection.data(), SIGNAL(connected()), this, + SLOT(handleConnected())); + connect(m_connection.data(), SIGNAL(error(SshError)), this, + SLOT(handleConnectionError())); + m_connection->connectToHost(m_config.server); +} +void MaemoConfigTestDialog::handleConnected() +{ + if (!m_connection) + return; QLatin1String sysInfoCmd("uname -rsm"); QLatin1String qtInfoCmd("dpkg -l |grep libqt " "|sed 's/[[:space:]][[:space:]]*/ /g' " "|cut -d ' ' -f 2,3 |sed 's/~.*//g'"); QString command(sysInfoCmd + " && " + qtInfoCmd); - m_deviceTester = new MaemoSshRunner(m_config.server, command); - connect(m_deviceTester, SIGNAL(remoteOutput(QString)), - this, SLOT(processSshOutput(QString))); - connect(m_deviceTester, SIGNAL(finished()), - this, SLOT(handleTestThreadFinished())); - - m_deviceTester->start(); + m_testProcess = m_connection->createRemoteProcess(command.toUtf8()); + connect(m_testProcess.data(), SIGNAL(closed(int)), this, + SLOT(handleProcessFinished(int))); + connect(m_testProcess.data(), SIGNAL(outputAvailable(QByteArray)), this, + SLOT(processSshOutput(QByteArray))); + m_testProcess->start(); } -void MaemoConfigTestDialog::handleTestThreadFinished() +void MaemoConfigTestDialog::handleConnectionError() { - if (!m_deviceTester) + if (!m_connection) + return; + QString output = tr("Could not connect to host: %1") + .arg(m_connection->errorString()); + if (m_config.type == MaemoDeviceConfig::Simulator) + output += tr("\nDid you start Qemu?"); + m_ui->testResultEdit->setPlainText(output); + stopConfigTest(); +} + +void MaemoConfigTestDialog::handleProcessFinished(int exitStatus) +{ + Q_ASSERT(exitStatus == SshRemoteProcess::FailedToStart + || exitStatus == SshRemoteProcess::KilledBySignal + || exitStatus == SshRemoteProcess::ExitedNormally); + + if (!m_testProcess) return; - QString output; - if (m_deviceTester->hasError()) { - output = tr("Device configuration test failed:\n%1").arg(m_deviceTester->error()); - if (m_config.type == MaemoDeviceConfig::Simulator) - output.append(tr("\nDid you start Qemu?")); + if (exitStatus != SshRemoteProcess::ExitedNormally + || m_testProcess->exitCode() != 0) { + m_ui->testResultEdit->setPlainText(tr("Remote process failed: %1") + .arg(m_testProcess->errorString())); } else { - output = parseTestOutput(); + const QString &output = parseTestOutput(); if (!m_qtVersionOk) { m_ui->errorLabel->setText(tr("Qt version mismatch! " " Expected Qt on device: 4.6.2 or later.")); } + m_ui->testResultEdit->setPlainText(output); } - m_ui->testResultEdit->setPlainText(output); stopConfigTest(); } void MaemoConfigTestDialog::stopConfigTest() { - if (m_deviceTester) { - m_deviceTester->disconnect(); // Disconnect signals - m_deviceTester->stop(); + if (m_testProcess) + disconnect(m_testProcess.data(), 0, this, 0); + if (m_connection) + disconnect(m_connection.data(), 0, this, 0); - SafeThreadDeleter *deleter = new SafeThreadDeleter(m_deviceTester); - deleter->start(); - - m_deviceTester = 0; - m_deviceTestOutput.clear(); - m_closeButton->setText(tr("Close")); - } + m_deviceTestOutput.clear(); + m_closeButton->setText(tr("Close")); } -void MaemoConfigTestDialog::processSshOutput(const QString &data) +void MaemoConfigTestDialog::processSshOutput(const QByteArray &output) { - m_deviceTestOutput.append(data); + m_deviceTestOutput.append(QString::fromUtf8(output)); } QString MaemoConfigTestDialog::parseTestOutput() diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoconfigtestdialog.h b/src/plugins/qt4projectmanager/qt-maemo/maemoconfigtestdialog.h index 8bc2d639306..a6ec321ca2c 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoconfigtestdialog.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoconfigtestdialog.h @@ -35,18 +35,23 @@ #ifndef MAEMOCONFIGTESTDIALOG_H #define MAEMOCONFIGTESTDIALOG_H -#include +#include +#include QT_BEGIN_NAMESPACE class QPushButton; class Ui_MaemoConfigTestDialog; QT_END_NAMESPACE +namespace Core { + class SshConnection; + class SshRemoteProcess; +} // namespace Core + namespace Qt4ProjectManager { namespace Internal { class MaemoDeviceConfig; -class MaemoSshRunner; /** * A dialog that runs a test of a device configuration. @@ -60,8 +65,10 @@ public: private slots: void stopConfigTest(); - void processSshOutput(const QString &data); - void handleTestThreadFinished(); + void processSshOutput(const QByteArray &output); + void handleConnected(); + void handleConnectionError(); + void handleProcessFinished(int exitStatus); private: void startConfigTest(); @@ -71,7 +78,8 @@ private: QPushButton *m_closeButton; const MaemoDeviceConfig &m_config; - MaemoSshRunner *m_deviceTester; + QSharedPointer m_connection; + QSharedPointer m_testProcess; QString m_deviceTestOutput; bool m_qtVersionOk; }; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.cpp index 7ff2747ddfc..d1d7d6645ef 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.cpp @@ -42,7 +42,7 @@ #include -typedef Core::SshServerInfo::AuthType AuthType; +typedef Core::SshConnectionParameters::AuthType AuthType; namespace Qt4ProjectManager { namespace Internal { @@ -80,7 +80,7 @@ namespace { const QString DefaultHostNameHW(QLatin1String("192.168.2.15")); const QString DefaultHostNameSim(QLatin1String("localhost")); const QString DefaultUserName(QLatin1String("developer")); - const AuthType DefaultAuthType(Core::SshServerInfo::AuthByKey); + const AuthType DefaultAuthType(Core::SshConnectionParameters::AuthByKey); const int DefaultTimeout(30); const MaemoDeviceConfig::DeviceType DefaultDeviceType(MaemoDeviceConfig::Physical); }; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.h index 7ffa28251ee..43ea377006b 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.h @@ -60,7 +60,7 @@ public: void save(QSettings &settings) const; bool isValid() const; - Core::SshServerInfo server; + Core::SshConnectionParameters server; QString name; DeviceType type; int gdbServerPort; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp index c173ddb6070..4d5a3cbc57c 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp @@ -40,6 +40,9 @@ #include #include +#include +#include +#include #include #include #include @@ -57,6 +60,8 @@ #include +using namespace Core; + namespace Qt4ProjectManager { namespace Internal { @@ -78,152 +83,278 @@ AbstractMaemoRunControl::~AbstractMaemoRunControl() { } + // TODO: We can cache the connection. We'd have to check if the connection + // is active and its parameters are the same as m_devConfig. If yes, + // skip the connection step and jump right to handleConnected() void AbstractMaemoRunControl::start() { - m_stoppedByUser = false; if (!m_devConfig.isValid()) { handleError(tr("No device configuration set for run configuration.")); } else { + m_stopped = false; emit started(); - startInitialCleanup(); + m_connection = SshConnection::create(); + connect(m_connection.data(), SIGNAL(connected()), this, + SLOT(handleConnected())); + connect(m_connection.data(), SIGNAL(error(SshError)), this, + SLOT(handleConnectionFailure())); + m_connection->connectToHost(m_devConfig.server); } } -void AbstractMaemoRunControl::startInitialCleanup() -{ +void AbstractMaemoRunControl::handleConnected() +{ + if (m_stopped) + return; + emit appendMessage(this, tr("Cleaning up remote leftovers first ..."), false); - const QStringList appsToKill - = QStringList() << executableFileName() << QLatin1String("gdbserver"); + const QStringList appsToKill = QStringList() << executableFileName() +#ifdef USE_GDBSERVER + << QLatin1String("gdbserver"); +#else + << QLatin1String("gdb"); +#endif killRemoteProcesses(appsToKill, true); } +void AbstractMaemoRunControl::handleConnectionFailure() +{ + if (m_stopped) + return; + + handleError(tr("Could not connect to host: %1") + .arg(m_connection->errorString())); + emit finished(); +} + void AbstractMaemoRunControl::stop() { - m_stoppedByUser = true; - if (isCleaning()) - m_initialCleaner->stop(); - else if (isDeploying()) - m_sshDeployer->stop(); - else - stopInternal(); -} - -void AbstractMaemoRunControl::handleInitialCleanupFinished() -{ - if (m_stoppedByUser) { - emit appendMessage(this, tr("Initial cleanup canceled by user."), false); + m_stopped = true; + if (m_connection && m_connection->state() == SshConnection::Connecting) { + disconnect(m_connection.data(), 0, this, 0); + m_connection->disconnectFromHost(); emit finished(); - } else if (m_initialCleaner->hasError()) { - handleError(tr("Error running initial cleanup: %1") - .arg(m_initialCleaner->error())); + } else if (m_initialCleaner && m_initialCleaner->isRunning()) { + disconnect(m_initialCleaner.data(), 0, this, 0); + emit finished(); + } else if (m_installer && m_installer->isRunning()) { + disconnect(m_installer.data(), 0, this, 0); + emit finished(); + } else if (isDeploying()) { + m_uploadsInProgress.clear(); + m_linksInProgress.clear(); + disconnect(m_uploader.data(), 0, this, 0); + m_progress.reportCanceled(); + m_progress.reportFinished(); emit finished(); } else { - emit appendMessage(this, tr("Initial cleanup done."), false); - startInternal(); + stopInternal(); } } -void AbstractMaemoRunControl::startDeployment(bool forDebugging) +void AbstractMaemoRunControl::startDeployment() { QTC_ASSERT(m_runConfig, return); - if (m_stoppedByUser) { - emit finished(); - } else { - m_needsInstall = false; - m_deployables.clear(); - m_remoteLinks.clear(); - const MaemoPackageCreationStep * const packageStep - = m_runConfig->packageStep(); - if (packageStep->isPackagingEnabled()) { - const MaemoDeployable d(packageFilePath(), uploadDir()); - m_needsInstall = addDeployableIfNeeded(d); - } else { - const MaemoDeployables * const deployables - = packageStep->deployables(); - const int deployableCount = deployables->deployableCount(); - for (int i = 0; i < deployableCount; ++i) { - const MaemoDeployable &d = deployables->deployableAt(i); - if (addDeployableIfNeeded(d)) - m_needsInstall = true; - } - } - - if (forDebugging) { - QFileInfo dumperInfo(m_runConfig->dumperLib()); - if (dumperInfo.exists()) { - const MaemoDeployable d(m_runConfig->dumperLib(), uploadDir()); - m_needsInstall = addDeployableIfNeeded(d); - } - } - deploy(); - } + m_uploader = m_connection->createSftpChannel(); + connect(m_uploader.data(), SIGNAL(initialized()), this, + SLOT(handleSftpChannelInitialized())); + connect(m_uploader.data(), SIGNAL(initializationFailed(QString)), this, + SLOT(handleSftpChannelInitializationFailed(QString))); + connect(m_uploader.data(), SIGNAL(finished(Core::SftpJobId, QString)), + this, SLOT(handleSftpJobFinished(Core::SftpJobId, QString))); + m_uploader->initialize(); } -bool AbstractMaemoRunControl::addDeployableIfNeeded(const MaemoDeployable &deployable) +void AbstractMaemoRunControl::handleSftpChannelInitialized() { - if (m_runConfig->currentlyNeedsDeployment(m_devConfig.server.host, - deployable)) { - const QString fileName - = QFileInfo(deployable.localFilePath).fileName(); - const QString remoteFilePath = deployable.remoteDir + '/' + fileName; - const QString uploadFilePath =uploadDir() + '/' + fileName + '.' + if (m_stopped) + return; + + m_uploadsInProgress.clear(); + m_linksInProgress.clear(); + m_needsInstall = false; + const QList &deployables = filesToDeploy(); + foreach (const MaemoDeployable &d, deployables) { + const QString fileName = QFileInfo(d.localFilePath).fileName(); + const QString remoteFilePath = d.remoteDir + '/' + fileName; + const QString uploadFilePath = uploadDir() + '/' + fileName + '.' + QCryptographicHash::hash(remoteFilePath.toUtf8(), QCryptographicHash::Md5).toHex(); - m_deployables.append(Core::SftpTransferInfo(deployable.localFilePath, - uploadFilePath.toUtf8(), Core::SftpTransferInfo::Upload)); - m_remoteLinks.insert(uploadFilePath, remoteFilePath); - return true; - } else { - return false; + const SftpJobId job = m_uploader->uploadFile(d.localFilePath, + uploadFilePath, SftpOverwriteExisting); + if (job == SftpInvalidJob) { + handleError(tr("Upload failed: Could not open file '%1'") + .arg(d.localFilePath)); + return; + } + emit appendMessage(this, tr("Started uploading file '%1'.") + .arg(d.localFilePath), false); + m_uploadsInProgress.insert(job, DeployInfo(d, uploadFilePath)); } -} -void AbstractMaemoRunControl::deploy() -{ Core::ICore::instance()->progressManager() ->addTask(m_progress.future(), tr("Deploying"), QLatin1String("Maemo.Deploy")); - if (!m_deployables.isEmpty()) { - QList deploySpecs; - QStringList files; - foreach (const Core::SftpTransferInfo &deployable, m_deployables) - files << deployable.localFilePath; - emit appendMessage(this, - tr("Files to deploy: %1.").arg(files.join(" ")), false); - m_sshDeployer.reset(new MaemoSshDeployer(m_devConfig.server, m_deployables)); - connect(m_sshDeployer.data(), SIGNAL(finished()), - this, SLOT(handleDeployThreadFinished())); - connect(m_sshDeployer.data(), SIGNAL(fileCopied(QString)), - this, SLOT(handleFileCopied())); - m_progress.setProgressRange(0, m_deployables.count()); + if (!m_uploadsInProgress.isEmpty()) { + m_progress.setProgressRange(0, m_uploadsInProgress.count()); m_progress.setProgressValue(0); m_progress.reportStarted(); - m_sshDeployer->start(); } else { m_progress.reportFinished(); startExecutionIfPossible(); } } -void AbstractMaemoRunControl::handleFileCopied() +void AbstractMaemoRunControl::handleSftpChannelInitializationFailed(const QString &error) { - const Core::SftpTransferInfo &deployable = m_deployables.takeFirst(); - const QString remoteDir - = QFileInfo(m_remoteLinks.value(QString::fromUtf8(deployable.remoteFilePath))) - .dir().path(); + if (m_stopped) + return; + handleError(tr("Could not set up SFTP connection: %1").arg(error)); +} - // TODO: This should be done after the linking step, in case the - // operation is cancelled directly after the upload. - m_runConfig->setDeployed(m_devConfig.server.host, - MaemoDeployable(deployable.localFilePath, remoteDir)); +void AbstractMaemoRunControl::handleSftpJobFinished(Core::SftpJobId job, + const QString &error) +{ + if (m_stopped) + return; + + QMap::Iterator it = m_uploadsInProgress.find(job); + if (it == m_uploadsInProgress.end()) { + qWarning("%s: Job %u not found in map.", Q_FUNC_INFO, job); + return; + } + + const DeployInfo &deployInfo = it.value(); + if (!error.isEmpty()) { + handleError(tr("Failed to upload file %1: %2") + .arg(deployInfo.first.localFilePath, error)); + return; + } m_progress.setProgressValue(m_progress.progressValue() + 1); + appendMessage(this, tr("Successfully uploaded file '%1'.") + .arg(deployInfo.first.localFilePath), false); + + const QString remoteFilePath = deployInfo.first.remoteDir + '/' + + QFileInfo(deployInfo.first.localFilePath).fileName(); + QByteArray linkCommand = remoteSudo().toUtf8() + " ln -sf " + + deployInfo.second.toUtf8() + ' ' + remoteFilePath.toUtf8(); + SshRemoteProcess::Ptr linkProcess + = m_connection->createRemoteProcess(linkCommand); + connect(linkProcess.data(), SIGNAL(closed(int)), this, + SLOT(handleLinkProcessFinished(int))); + m_linksInProgress.insert(linkProcess, deployInfo.first); + linkProcess->start(); + m_uploadsInProgress.erase(it); +} + +void AbstractMaemoRunControl::handleLinkProcessFinished(int exitStatus) +{ + if (m_stopped) + return; + + SshRemoteProcess * const proc = static_cast(sender()); + + // TODO: List instead of map? We can't use it for lookup anyway. + QMap::Iterator it; + for (it = m_linksInProgress.begin(); it != m_linksInProgress.end(); ++it) { + if (it.key().data() == proc) + break; + } + if (it == m_linksInProgress.end()) { + qWarning("%s: Remote process %p not found in process list.", + Q_FUNC_INFO, proc); + return; + } + + const MaemoDeployable &deployable = it.value(); + if (exitStatus != SshRemoteProcess::ExitedNormally + || proc->exitCode() != 0) { + handleError(tr("Deployment failed for file '%1': " + "Could not create link '%2' on remote system.") + .arg(deployable.localFilePath, deployable.remoteDir + '/' + + QFileInfo(deployable.localFilePath).fileName())); + return; + } + + m_runConfig->setDeployed(m_devConfig.server.host, it.value()); + m_linksInProgress.erase(it); + if (m_linksInProgress.isEmpty() && m_uploadsInProgress.isEmpty()) { + if (m_needsInstall) { + emit appendMessage(this, tr("Installing package ..."), false); + const QByteArray cmd = remoteSudo().toUtf8() + " dpkg -i " + + packageFileName().toUtf8(); + m_installer = m_connection->createRemoteProcess(cmd); + connect(m_installer.data(), SIGNAL(closed(int)), this, + SLOT(handleInstallationFinished(int))); + connect(m_installer.data(), SIGNAL(outputAvailable(QByteArray)), + this, SLOT(handleRemoteOutput(QByteArray))); + connect(m_installer.data(), + SIGNAL(errorOutputAvailable(QByteArray)), this, + SLOT(handleRemoteErrorOutput(QByteArray))); + m_installer->start(); + } else { + handleDeploymentFinished(); + } + } +} + +void AbstractMaemoRunControl::handleInstallationFinished(int exitStatus) +{ + if (m_stopped) + return; + + if (exitStatus != SshRemoteProcess::ExitedNormally + || m_installer->exitCode() != 0) { + handleError(tr("Installing package failed.")); + } else { + emit appendMessage(this, tr("Package installation finished."), false); + handleDeploymentFinished(); + } +} + +void AbstractMaemoRunControl::handleDeploymentFinished() +{ + emit appendMessage(this, tr("Deployment finished."), false); + m_progress.reportFinished(); + startExecutionIfPossible(); +} + +QList AbstractMaemoRunControl::filesToDeploy() +{ + QList deployableList; + if (m_runConfig->packageStep()->isPackagingEnabled()) { + const MaemoDeployable d(packageFilePath(), uploadDir()); + m_needsInstall = addDeployableIfNeeded(deployableList, d); + } else { + const MaemoDeployables * const deployables + = m_runConfig->packageStep()->deployables(); + const int deployableCount = deployables->deployableCount(); + for (int i = 0; i < deployableCount; ++i) { + const MaemoDeployable &d = deployables->deployableAt(i); + addDeployableIfNeeded(deployableList, d); + } + m_needsInstall = false; + } + return deployableList; +} + +bool AbstractMaemoRunControl::addDeployableIfNeeded(QList &deployables, + const MaemoDeployable &deployable) +{ + if (m_runConfig->currentlyNeedsDeployment(m_devConfig.server.host, + deployable)) { + deployables << deployable; + return true; + } else { + return false; + } } bool AbstractMaemoRunControl::isDeploying() const { - return m_sshDeployer && m_sshDeployer->isRunning(); + return !m_uploadsInProgress.isEmpty() || !m_linksInProgress.isEmpty(); } QString AbstractMaemoRunControl::packageFileName() const @@ -260,33 +391,68 @@ void AbstractMaemoRunControl::startExecutionIfPossible() void AbstractMaemoRunControl::startExecution() { - m_sshRunner.reset(new MaemoSshRunner(m_devConfig.server, remoteCall())); - connect(m_sshRunner.data(), SIGNAL(finished()), - this, SLOT(handleRunThreadFinished())); - connect(m_sshRunner.data(), SIGNAL(remoteOutput(QString)), - this, SLOT(handleRemoteOutput(QString))); + m_runner = m_connection->createRemoteProcess(remoteCall().toUtf8()); + connect(m_runner.data(), SIGNAL(started()), this, + SLOT(handleRemoteProcessStarted())); + connect(m_runner.data(), SIGNAL(closed(int)), this, + SLOT(handleRemoteProcessFinished(int))); + connect(m_runner.data(), SIGNAL(outputAvailable(QByteArray)), this, + SLOT(handleRemoteOutput(QByteArray))); + connect(m_runner.data(), SIGNAL(errorOutputAvailable(QByteArray)), this, + SLOT(handleRemoteErrorOutput(QByteArray))); emit appendMessage(this, tr("Starting remote application."), false); - m_sshRunner->start(); + m_runner->start(); +} + +void AbstractMaemoRunControl::handleRemoteProcessFinished(int exitStatus) +{ + Q_ASSERT(exitStatus == SshRemoteProcess::FailedToStart + || exitStatus == SshRemoteProcess::KilledBySignal + || exitStatus == SshRemoteProcess::ExitedNormally); + + if (m_stopped) + return; + + if (exitStatus == SshRemoteProcess::ExitedNormally) { + emit appendMessage(this, + tr("Finished running remote process. Exit code was %1.") + .arg(m_runner->exitCode()), false); + emit finished(); + } else { + handleError(tr("Error running remote process: %1") + .arg(m_runner->errorString())); + } +} + +void AbstractMaemoRunControl::handleRemoteOutput(const QByteArray &output) +{ + emit addToOutputWindowInline(this, QString::fromUtf8(output), false); +} + +void AbstractMaemoRunControl::handleRemoteErrorOutput(const QByteArray &output) +{ + emit addToOutputWindowInline(this, QString::fromUtf8(output), true); } bool AbstractMaemoRunControl::isRunning() const { - return isDeploying() || (m_sshRunner && m_sshRunner->isRunning()); + return isDeploying() || (m_runner && m_runner->isRunning()); } void AbstractMaemoRunControl::stopRunning(bool forDebugging) { - if (m_sshRunner && m_sshRunner->isRunning()) { - m_sshRunner->stop(); + if (m_runner && m_runner->isRunning()) { + disconnect(m_runner.data(), 0, this, 0); QStringList apps(executableFileName()); if (forDebugging) apps << QLatin1String("gdbserver"); killRemoteProcesses(apps, false); + emit finished(); } } void AbstractMaemoRunControl::killRemoteProcesses(const QStringList &apps, - bool initialCleanup) + bool initialCleanup) { QString niceKill; QString brutalKill; @@ -296,54 +462,34 @@ void AbstractMaemoRunControl::killRemoteProcesses(const QStringList &apps, } QString remoteCall = niceKill + QLatin1String("sleep 1; ") + brutalKill; remoteCall.remove(remoteCall.count() - 1, 1); // Get rid of trailing semicolon. - QScopedPointer &runner - = initialCleanup ? m_initialCleaner : m_sshStopper; - runner.reset(new MaemoSshRunner(m_devConfig.server, remoteCall)); - if (initialCleanup) - connect(runner.data(), SIGNAL(finished()), - this, SLOT(handleInitialCleanupFinished())); - runner->start(); + SshRemoteProcess::Ptr proc + = m_connection->createRemoteProcess(remoteCall.toUtf8()); + if (initialCleanup) { + m_initialCleaner = proc; + connect(m_initialCleaner.data(), SIGNAL(closed(int)), this, + SLOT(handleInitialCleanupFinished(int))); + } else { + m_stopper = proc; + } + proc->start(); } -void AbstractMaemoRunControl::handleDeployThreadFinished() +void AbstractMaemoRunControl::handleInitialCleanupFinished(int exitStatus) { - bool cancel; - if (m_stoppedByUser) { - emit appendMessage(this, tr("Deployment canceled by user."), false); - cancel = true; - } else if (m_sshDeployer->hasError()) { - handleError(tr("Deployment failed: %1").arg(m_sshDeployer->error())); - cancel = true; - } else { - emit appendMessage(this, tr("Deployment finished."), false); - cancel = false; - } + Q_ASSERT(exitStatus == SshRemoteProcess::FailedToStart + || exitStatus == SshRemoteProcess::KilledBySignal + || exitStatus == SshRemoteProcess::ExitedNormally); - if (cancel) { - m_progress.reportCanceled(); - m_progress.reportFinished(); - emit finished(); - } else { - m_progress.reportFinished(); - startExecutionIfPossible(); - } -} + if (m_stopped) + return; -void AbstractMaemoRunControl::handleRunThreadFinished() -{ - if (m_stoppedByUser) { - emit appendMessage(this, - tr("Remote execution canceled due to user request."), - false); - } else if (m_sshRunner && m_sshRunner->hasError()) { - emit appendMessage(this, tr("Error running remote process: %1") - .arg(m_sshRunner->error()), - true); + if (exitStatus != SshRemoteProcess::ExitedNormally) { + handleError(tr("Initial cleanup failed: %1") + .arg(m_initialCleaner->errorString())); } else { - emit appendMessage(this, tr("Finished running remote process."), - false); + emit appendMessage(this, tr("Initial cleanup done."), false); + startDeployment(); } - emit finished(); } const QString AbstractMaemoRunControl::executableOnHost() const @@ -366,32 +512,10 @@ QString AbstractMaemoRunControl::remoteSudo() const return QLatin1String("/usr/lib/mad-developer/devrootsh"); } -QString AbstractMaemoRunControl::remoteInstallCommand() const -{ - Q_ASSERT(m_needsInstall); - QString cmd; - for (QMap::ConstIterator it = m_remoteLinks.begin(); - it != m_remoteLinks.end(); ++it) { - cmd += QString::fromLocal8Bit("%1 ln -sf %2 %3 && ") - .arg(remoteSudo(), it.key(), it.value()); - } - if (m_runConfig->packageStep()->isPackagingEnabled()) { - cmd += QString::fromLocal8Bit("%1 dpkg -i %2").arg(remoteSudo()) - .arg(packageFileName()); - } else if (!m_remoteLinks.isEmpty()) { - return cmd.remove(cmd.length() - 4, 4); // Trailing " && " - } - - return cmd; -} - const QString AbstractMaemoRunControl::targetCmdLinePrefix() const { - const QString &installPrefix = m_needsInstall - ? remoteInstallCommand() + QLatin1String(" && ") - : QString(); - return QString::fromLocal8Bit("%1%2 chmod a+x %3 && source /etc/profile && DISPLAY=:0.0 ") - .arg(installPrefix).arg(remoteSudo()).arg(executableFilePathOnTarget()); + return QString::fromLocal8Bit("%1 chmod a+x %2 && source /etc/profile && DISPLAY=:0.0 ") + .arg(remoteSudo()).arg(executableFilePathOnTarget()); } QString AbstractMaemoRunControl::targetCmdLineSuffix() const @@ -403,6 +527,15 @@ void AbstractMaemoRunControl::handleError(const QString &errString) { QMessageBox::critical(0, tr("Remote Execution Failure"), errString); emit appendMessage(this, errString, true); + stop(); +} + +template void AbstractMaemoRunControl::closeSshChannel(SshChannel &channel) +{ + if (channel) { + disconnect(channel.data(), 0, this, 0); + // channel->closeChannel(); + } } @@ -416,11 +549,6 @@ MaemoRunControl::~MaemoRunControl() stop(); } -void MaemoRunControl::startInternal() -{ - startDeployment(false); -} - QString MaemoRunControl::remoteCall() const { return QString::fromLocal8Bit("%1 %2 %3").arg(targetCmdLinePrefix()) @@ -432,11 +560,6 @@ void MaemoRunControl::stopInternal() AbstractMaemoRunControl::stopRunning(false); } -void MaemoRunControl::handleRemoteOutput(const QString &output) -{ - emit addToOutputWindowInline(this, output, false); -} - MaemoDebugRunControl::MaemoDebugRunControl(RunConfiguration *runConfiguration) : AbstractMaemoRunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE) @@ -453,8 +576,9 @@ MaemoDebugRunControl::MaemoDebugRunControl(RunConfiguration *runConfiguration) #else m_startParams->startMode = StartRemoteGdb; m_startParams->executable = executableFilePathOnTarget(); - m_startParams->debuggerCommand = QLatin1String("/usr/bin/gdb"); - m_startParams->sshserver = m_devConfig.server; + m_startParams->debuggerCommand = targetCmdLinePrefix() + + QLatin1String(" /usr/bin/gdb"); + m_startParams->connParams = m_devConfig.server; #endif m_startParams->processArgs = m_runConfig->arguments(); m_startParams->sysRoot = m_runConfig->sysRoot(); @@ -475,12 +599,6 @@ MaemoDebugRunControl::~MaemoDebugRunControl() stop(); } -void MaemoDebugRunControl::startInternal() -{ - m_debuggingStarted = false; - startDeployment(true); -} - QString MaemoDebugRunControl::remoteCall() const { return QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4") @@ -497,17 +615,6 @@ void MaemoDebugRunControl::startExecution() #endif } -void MaemoDebugRunControl::handleRemoteOutput(const QString &output) -{ -#ifdef USE_GDBSERVER - if (!m_debuggingStarted) { - m_debuggingStarted = true; - startDebugging(); - } -#endif - emit addToOutputWindowInline(m_debuggerRunControl, output, false); -} - void MaemoDebugRunControl::startDebugging() { DebuggerPlugin::startDebugger(m_debuggerRunControl); @@ -529,10 +636,20 @@ void MaemoDebugRunControl::debuggingFinished() #ifdef USE_GDBSERVER AbstractMaemoRunControl::stopRunning(true); #else - AbstractMaemoRunControl::handleRunThreadFinished(); + emit finished(); #endif } +void MaemoDebugRunControl::handleRemoteProcessStarted() +{ + startDebugging(); +} + +void MaemoDebugRunControl::debuggerOutput(const QString &output) +{ + emit appendMessage(this, QLatin1String("[gdb says:] ") + output, true); +} + QString MaemoDebugRunControl::gdbServerPort() const { return m_devConfig.type == MaemoDeviceConfig::Physical @@ -542,5 +659,14 @@ QString MaemoDebugRunControl::gdbServerPort() const // but we will make sure we use the right port from the information file. } +QList MaemoDebugRunControl::filesToDeploy() +{ + QList deployables + = AbstractMaemoRunControl::filesToDeploy(); + const MaemoDeployable d(m_runConfig->dumperLib(), uploadDir()); + addDeployableIfNeeded(deployables, d); + return deployables; +} + } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h index ec6849b3252..a5ede3fde26 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h @@ -37,11 +37,12 @@ #include "maemodeviceconfigurations.h" #include "maemodeployable.h" -#include "maemosshthread.h" +#include #include #include +#include #include #include @@ -49,6 +50,12 @@ QT_BEGIN_NAMESPACE class QProcess; QT_END_NAMESPACE +namespace Core { + class SftpChannel; + class SshConnection; + class SshRemoteProcess; +} + namespace Debugger { class DebuggerRunControl; class DebuggerStartParameters; @@ -56,8 +63,6 @@ namespace Debugger { namespace Qt4ProjectManager { namespace Internal { -class MaemoSshDeployer; -class MaemoSshRunner; class MaemoRunConfiguration; class AbstractMaemoRunControl : public ProjectExplorer::RunControl @@ -73,8 +78,7 @@ protected: virtual void start(); virtual void stop(); - void startDeployment(bool forDebugging); - void deploy(); + void startDeployment(); void stopRunning(bool forDebugging); virtual void startExecution(); void handleError(const QString &errString); @@ -86,46 +90,55 @@ protected: QString packageFileName() const; QString packageFilePath() const; QString executableFilePathOnTarget() const; - -protected slots: - void handleRunThreadFinished(); + virtual QList filesToDeploy(); + bool addDeployableIfNeeded(QList &deployables, + const MaemoDeployable &deployable); private slots: - virtual void handleRemoteOutput(const QString &output)=0; - void handleInitialCleanupFinished(); - void handleDeployThreadFinished(); - void handleFileCopied(); + void handleConnected(); + void handleConnectionFailure(); + void handleInitialCleanupFinished(int exitStatus); + void handleSftpChannelInitialized(); + void handleSftpChannelInitializationFailed(const QString &error); + void handleSftpJobFinished(Core::SftpJobId job, const QString &error); + void handleLinkProcessFinished(int exitStatus); + void handleInstallationFinished(int exitStatus); + virtual void handleRemoteProcessStarted() {} + void handleRemoteProcessFinished(int exitStatus); + void handleRemoteOutput(const QByteArray &output); + void handleRemoteErrorOutput(const QByteArray &output); protected: MaemoRunConfiguration *m_runConfig; // TODO this pointer can be invalid const MaemoDeviceConfig m_devConfig; private: - bool addDeployableIfNeeded(const MaemoDeployable &deployable); - - virtual void startInternal()=0; virtual void stopInternal()=0; virtual QString remoteCall() const=0; - void startInitialCleanup(); void killRemoteProcesses(const QStringList &apps, bool initialCleanup); + void cancelActions(); + template void closeSshChannel(SshChannel &channel); void startExecutionIfPossible(); bool isCleaning() const; bool isDeploying() const; QString remoteSudo() const; - QString remoteInstallCommand() const; QString uploadFilePath(const MaemoDeployable &deployable) const; + void handleDeploymentFinished(); QFutureInterface m_progress; - QScopedPointer m_sshDeployer; - QScopedPointer m_sshRunner; - QScopedPointer m_sshStopper; - QScopedPointer m_initialCleaner; - bool m_stoppedByUser; + QSharedPointer m_connection; + QSharedPointer m_uploader; + QSharedPointer m_installer; + QSharedPointer m_runner; + QSharedPointer m_stopper; + QSharedPointer m_initialCleaner; - QList m_deployables; - QMap m_remoteLinks; + typedef QPair DeployInfo; + QMap m_uploadsInProgress; + QMap, MaemoDeployable> m_linksInProgress; bool m_needsInstall; + bool m_stopped; }; class MaemoRunControl : public AbstractMaemoRunControl @@ -135,11 +148,7 @@ public: explicit MaemoRunControl(ProjectExplorer::RunConfiguration *runConfiguration); ~MaemoRunControl(); -private slots: - virtual void handleRemoteOutput(const QString &output); - private: - virtual void startInternal(); virtual void stopInternal(); virtual QString remoteCall() const; }; @@ -153,22 +162,21 @@ public: bool isRunning() const; private slots: - virtual void handleRemoteOutput(const QString &output); + virtual void handleRemoteProcessStarted(); + void debuggerOutput(const QString &output); void debuggingFinished(); private: - virtual void startInternal(); virtual void stopInternal(); virtual void startExecution(); virtual QString remoteCall() const; + virtual QList filesToDeploy(); QString gdbServerPort() const; void startDebugging(); Debugger::DebuggerRunControl *m_debuggerRunControl; QSharedPointer m_startParams; - - bool m_debuggingStarted; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.cpp index 6ef22cf3d4f..0d2e3a7fbec 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.cpp @@ -39,7 +39,9 @@ #include "maemoconfigtestdialog.h" #include "maemodeviceconfigurations.h" #include "maemosshconfigdialog.h" -#include "maemosshthread.h" + +#include +#include #include #include @@ -52,6 +54,8 @@ #include +using namespace Core; + namespace Qt4ProjectManager { namespace Internal { @@ -97,8 +101,7 @@ MaemoSettingsWidget::MaemoSettingsWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui_MaemoSettingsWidget), m_devConfs(MaemoDeviceConfigurations::instance().devConfigs()), - m_nameValidator(new NameValidator(m_devConfs)), - m_keyDeployer(0) + m_nameValidator(new NameValidator(m_devConfs)) { initGui(); } @@ -195,7 +198,7 @@ void MaemoSettingsWidget::display(const MaemoDeviceConfig &devConfig) otherConfig->server.pwd = devConfig.server.pwd; otherConfig->server.privateKeyFile = devConfig.server.privateKeyFile; - if (devConfig.server.authType == Core::SshServerInfo::AuthByPwd) + if (devConfig.server.authType == Core::SshConnectionParameters::AuthByPwd) m_ui->passwordButton->setChecked(true); else m_ui->keyButton->setChecked(true); @@ -272,7 +275,7 @@ void MaemoSettingsWidget::authenticationTypeChanged() { const bool usePassword = m_ui->passwordButton->isChecked(); currentConfig().server.authType - = usePassword ? Core::SshServerInfo::AuthByPwd : Core::SshServerInfo::AuthByKey; + = usePassword ? Core::SshConnectionParameters::AuthByPwd : Core::SshConnectionParameters::AuthByKey; m_ui->pwdLineEdit->setEnabled(usePassword); m_ui->passwordLabel->setEnabled(usePassword); m_ui->keyFileLineEdit->setEnabled(!usePassword); @@ -337,13 +340,32 @@ void MaemoSettingsWidget::deployKey() if (m_keyDeployer) return; + disconnect(m_ui->deployKeyButton, 0, this, 0); + m_ui->deployKeyButton->setText(tr("Stop Deploying")); + connect(m_ui->deployKeyButton, SIGNAL(clicked()), this, + SLOT(stopDeploying())); + m_connection = SshConnection::create(); + connect(m_connection.data(), SIGNAL(connected()), this, + SLOT(handleConnected())); + connect(m_connection.data(), SIGNAL(error(SshError)), this, + SLOT(handleConnectionFailure())); + m_connection->connectToHost(currentConfig().server); +} + +void MaemoSettingsWidget::handleConnected() +{ + if (!m_connection) + return; + const QString &dir = QFileInfo(currentConfig().server.privateKeyFile).path(); QString publicKeyFileName = QFileDialog::getOpenFileName(this, tr("Choose Public Key File"), dir, tr("Public Key Files(*.pub);;All Files (*)")); - if (publicKeyFileName.isEmpty()) + if (publicKeyFileName.isEmpty()) { + stopDeploying(); return; + } QFile keyFile(publicKeyFileName); QByteArray key; @@ -353,32 +375,45 @@ void MaemoSettingsWidget::deployKey() if (!keyFileAccessible || keyFile.error() != QFile::NoError) { QMessageBox::critical(this, tr("Deployment Failed"), tr("Could not read public key file '%1'.").arg(publicKeyFileName)); + stopDeploying(); return; } - m_ui->deployKeyButton->disconnect(); - const QString command = QLatin1String("test -d .ssh " - "|| mkdir .ssh && chmod 0700 .ssh && echo '") - + key + QLatin1String("' >> .ssh/authorized_keys"); - m_keyDeployer = new MaemoSshRunner(currentConfig().server, command); - connect(m_keyDeployer, SIGNAL(finished()), - this, SLOT(handleDeployThreadFinished())); - m_ui->deployKeyButton->setText(tr("Stop Deploying")); - connect(m_ui->deployKeyButton, SIGNAL(clicked()), this, SLOT(stopDeploying())); + const QByteArray command = "test -d .ssh " + "|| mkdir .ssh && chmod 0700 .ssh && echo '" + + key + "' >> .ssh/authorized_keys"; + m_keyDeployer = m_connection->createRemoteProcess(command); + connect(m_keyDeployer.data(), SIGNAL(closed(int)), this, + SLOT(handleKeyUploadFinished(int))); m_keyDeployer->start(); } -void MaemoSettingsWidget::handleDeployThreadFinished() +void MaemoSettingsWidget::handleConnectionFailure() { - if (!m_keyDeployer) + if (!m_connection) return; - if (m_keyDeployer->hasError()) { - QMessageBox::critical(this, tr("Deployment Failed"), - tr("Key deployment failed: %1").arg(m_keyDeployer->error())); - } else { + QMessageBox::critical(this, tr("Deployment Failed"), + tr("Could not connect to host: %1").arg(m_connection->errorString())); + stopDeploying(); +} + +void MaemoSettingsWidget::handleKeyUploadFinished(int exitStatus) +{ + Q_ASSERT(exitStatus == SshRemoteProcess::FailedToStart + || exitStatus == SshRemoteProcess::KilledBySignal + || exitStatus == SshRemoteProcess::ExitedNormally); + + if (!m_connection) + return; + + if (exitStatus == SshRemoteProcess::ExitedNormally + && m_keyDeployer->exitCode() == 0) { QMessageBox::information(this, tr("Deployment Succeeded"), tr("Key was successfully deployed.")); + } else { + QMessageBox::critical(this, tr("Deployment Failed"), + tr("Key deployment failed: %1.").arg(m_keyDeployer->errorString())); } stopDeploying(); } @@ -386,14 +421,14 @@ void MaemoSettingsWidget::handleDeployThreadFinished() void MaemoSettingsWidget::stopDeploying() { if (m_keyDeployer) { - m_ui->deployKeyButton->disconnect(); - m_keyDeployer->disconnect(); - m_keyDeployer->stop(); - delete m_keyDeployer; - m_keyDeployer = 0; - m_ui->deployKeyButton->setText(tr("Deploy Public Key ...")); - connect(m_ui->deployKeyButton, SIGNAL(clicked()), this, SLOT(deployKey())); + disconnect(m_keyDeployer.data(), 0, this, 0); + m_keyDeployer = SshRemoteProcess::Ptr(); } + if (m_connection) + disconnect(m_connection.data(), 0, this, 0); + m_ui->deployKeyButton->disconnect(); + m_ui->deployKeyButton->setText(tr("Deploy Public Key ...")); + connect(m_ui->deployKeyButton, SIGNAL(clicked()), this, SLOT(deployKey())); } void MaemoSettingsWidget::currentConfigChanged(int index) diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.h b/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.h index e8c676696a0..cc17e2262cd 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.h @@ -38,6 +38,7 @@ #include "maemodeviceconfigurations.h" #include +#include #include #include @@ -47,6 +48,11 @@ class QLineEdit; class Ui_MaemoSettingsWidget; QT_END_NAMESPACE +namespace Core { +class SshConnection; +class SshRemoteProcess; +} + namespace Qt4ProjectManager { namespace Internal { @@ -86,8 +92,10 @@ private slots: // For key deploying. void deployKey(); - void handleDeployThreadFinished(); void stopDeploying(); + void handleConnected(); + void handleConnectionFailure(); + void handleKeyUploadFinished(int exitStatus); private: void initGui(); @@ -102,7 +110,8 @@ private: MaemoDeviceConfig m_lastConfigHW; MaemoDeviceConfig m_lastConfigSim; NameValidator * const m_nameValidator; - MaemoSshRunner *m_keyDeployer; + QSharedPointer m_connection; + QSharedPointer m_keyDeployer; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.cpp index 6052b702a24..48d48fb0f91 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.cpp @@ -45,13 +45,13 @@ #include #include - +using namespace Core; using namespace Qt4ProjectManager::Internal; MaemoSshConfigDialog::MaemoSshConfigDialog(QWidget *parent) : QDialog(parent) , home(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)) - , m_keyGenerator(new Core::SshKeyGenerator) + , m_keyGenerator(new SshKeyGenerator) { m_ui.setupUi(this); @@ -75,16 +75,16 @@ void MaemoSshConfigDialog::slotToggled() void MaemoSshConfigDialog::generateSshKey() { - const Core::SshKeyGenerator::KeyType keyType = m_ui.rsa->isChecked() - ? Core::SshKeyGenerator::Rsa - : Core::SshKeyGenerator::Dsa; + const SshKeyGenerator::KeyType keyType = m_ui.rsa->isChecked() + ? SshKeyGenerator::Rsa + : SshKeyGenerator::Dsa; QByteArray userId = QString(home.mid(home.lastIndexOf(QLatin1Char('/')) + 1) + QLatin1Char('@') + QHostInfo::localHostName()).toUtf8(); QApplication::setOverrideCursor(Qt::BusyCursor); - if (m_keyGenerator->generateKeys(keyType, userId, + if (m_keyGenerator->generateKeys(keyType, SshKeyGenerator::OpenSsl, m_ui.comboBox->currentText().toUShort())) { m_ui.plainTextEdit->setPlainText(m_keyGenerator->publicKey()); m_ui.savePublicKey->setEnabled(true); @@ -117,7 +117,7 @@ void MaemoSshConfigDialog::saveKey(bool publicKey) { checkSshDir(); const QString suggestedTypeSuffix = - m_keyGenerator->type() == Core::SshKeyGenerator::Rsa ? "rsa" : "dsa"; + m_keyGenerator->type() == SshKeyGenerator::Rsa ? "rsa" : "dsa"; const QString suggestedName = home + QString::fromLatin1("/.ssh/id_%1%2") .arg(suggestedTypeSuffix).arg(publicKey ? ".pub" : ""); const QString dlgTitle @@ -131,8 +131,8 @@ void MaemoSshConfigDialog::saveKey(bool publicKey) const bool canOpen = file.open(QIODevice::WriteOnly); if (canOpen) file.write(publicKey - ? m_keyGenerator->publicKey().toUtf8() - : m_keyGenerator->privateKey().toUtf8()); + ? m_keyGenerator->publicKey() + : m_keyGenerator->privateKey()); if (!canOpen || file.error() != QFile::NoError) { QMessageBox::critical(this, tr("Error writing file"), tr("Could not write file '%1':\n %2") diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp deleted file mode 100644 index a31c06dec4e..00000000000 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Creator. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "maemosshthread.h" - -namespace Qt4ProjectManager { -namespace Internal { - -template MaemoSshThread::MaemoSshThread(const Core::SshServerInfo &server) - : m_server(server), m_stopRequested(false) -{ -} - -template MaemoSshThread::~MaemoSshThread() -{ - stop(); - wait(); -} - -template void MaemoSshThread::run() -{ - if (m_stopRequested) - return; - - if (!runInternal()) - m_error = m_connection->error(); -} - -template void MaemoSshThread::stop() -{ - m_mutex.lock(); - m_stopRequested = true; - m_waitCond.wakeAll(); - const bool hasConnection = !m_connection.isNull(); - if (hasConnection) - m_connection->quit(); - m_mutex.unlock(); -} - -template void MaemoSshThread::waitForStop() -{ - m_mutex.lock(); - while (!stopRequested()) - m_waitCond.wait(&m_mutex); - m_mutex.unlock(); -} - -template void MaemoSshThread::createConnection() -{ - typename SshConnection::Ptr connection = SshConnection::create(m_server); - m_mutex.lock(); - m_connection = connection; - m_mutex.unlock(); -} - -MaemoSshRunner::MaemoSshRunner(const Core::SshServerInfo &server, - const QString &command) - : MaemoSshThread(server), - m_command(command) -{ - m_prompt = server.uname == QLatin1String("root") ? "#" : "$"; -} - -bool MaemoSshRunner::runInternal() -{ - createConnection(); - connect(m_connection.data(), SIGNAL(remoteOutputAvailable()), - this, SLOT(handleRemoteOutput())); - initState(); - if (!m_connection->start()) - return false; - if (stopRequested()) - return true; - - waitForStop(); - return !m_connection->hasError(); -} - -void MaemoSshRunner::initState() -{ - m_endMarkerCount = 0; - m_promptEncountered = false; - m_potentialEndMarkerPrefix.clear(); -} - -void MaemoSshRunner::handleRemoteOutput() -{ - const QByteArray output - = m_potentialEndMarkerPrefix + m_connection->waitForRemoteOutput(0); - - // Wait for a prompt before sending the command. - if (!m_promptEncountered) { - if (output.indexOf(m_prompt) != -1) { - m_promptEncountered = true; - - /* - * We don't have access to the remote process management, so we - * try to track the lifetime of the process by adding a second command - * that prints a rare character. When it occurs for the second time (the - * first one is the echo from the remote terminal), we assume the - * process has finished. If anyone actually prints this special character - * in their application, they are out of luck. - */ - const QString finalCommand = m_command + QLatin1String(";echo ") - + QString::fromUtf8(EndMarker) + QLatin1Char('\n'); - if (!m_connection->sendInput(finalCommand.toUtf8())) - stop(); - } - return; - } - - /* - * The output the user should see is everything after the first - * and before the last occurrence of our marker string. - */ - int firstCharToEmit; - int charsToEmitCount; - const int endMarkerPos = output.indexOf(EndMarker); - if (endMarkerPos != -1) { - if (m_endMarkerCount++ == 0) { - firstCharToEmit = endMarkerPos + EndMarker.count() + 1; - int endMarkerPos2 - = output.indexOf(EndMarker, firstCharToEmit); - if (endMarkerPos2 != -1) { - ++ m_endMarkerCount; - charsToEmitCount = endMarkerPos2 - firstCharToEmit; - } else { - charsToEmitCount = -1; - } - } else { - firstCharToEmit = m_potentialEndMarkerPrefix.count(); - charsToEmitCount = endMarkerPos - firstCharToEmit; - } - } else { - if (m_endMarkerCount == 0) { - charsToEmitCount = 0; - } else { - firstCharToEmit = m_potentialEndMarkerPrefix.count(); - charsToEmitCount = -1; - } - } - - if (charsToEmitCount != 0) { - emit remoteOutput(QString::fromUtf8(output.data() + firstCharToEmit, - charsToEmitCount)); - } - if (m_endMarkerCount == 2) - stop(); - - m_potentialEndMarkerPrefix = output.right(EndMarker.count() - 1); -} - -const QByteArray MaemoSshRunner::EndMarker(QString(QChar(0x13a0)).toUtf8()); - - -MaemoSshDeployer::MaemoSshDeployer(const Core::SshServerInfo &server, - const QList &deploySpecs) - : MaemoSshThread(server), - m_deploySpecs(deploySpecs) -{ -} - -bool MaemoSshDeployer::runInternal() -{ - createConnection(); - if (!m_connection->start()) - return false; - if (stopRequested()) - return true; - - connect(m_connection.data(), SIGNAL(fileCopied(QString)), - this, SIGNAL(fileCopied(QString))); - return m_connection->transferFiles(m_deploySpecs); -} - -} // namespace Internal -} // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h deleted file mode 100644 index 79107d0f602..00000000000 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Creator. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAEMOSSHTHREAD_H -#define MAEMOSSHTHREAD_H - -#include "maemodeviceconfigurations.h" - -#include - -#include -#include -#include -#include -#include - -namespace Qt4ProjectManager { -namespace Internal { - -template class MaemoSshThread : public QThread -{ - Q_DISABLE_COPY(MaemoSshThread) -public: - QString error() const { return m_error; } - bool hasError() const { return !m_error.isEmpty(); } - void stop(); - virtual void run(); - ~MaemoSshThread(); - -protected: - MaemoSshThread(const Core::SshServerInfo &server); - void createConnection(); - bool stopRequested() const { return m_stopRequested; } - void waitForStop(); - - typename SshConnection::Ptr m_connection; - -private: - virtual bool runInternal() = 0; - - const Core::SshServerInfo m_server; - bool m_stopRequested; - QString m_error; - QMutex m_mutex; - QWaitCondition m_waitCond; -}; - - -class MaemoSshRunner : public MaemoSshThread -{ - Q_OBJECT - Q_DISABLE_COPY(MaemoSshRunner) -public: - MaemoSshRunner(const Core::SshServerInfo &server, const QString &command); - -signals: - void remoteOutput(const QString &output); - -private: - virtual bool runInternal(); - Q_SLOT void handleRemoteOutput(); - void initState(); - - static const QByteArray EndMarker; - - const QString m_command; - const char *m_prompt; - int m_endMarkerCount; - bool m_promptEncountered; - QByteArray m_potentialEndMarkerPrefix; -}; - - -class MaemoSshDeployer : public MaemoSshThread -{ - Q_OBJECT - Q_DISABLE_COPY(MaemoSshDeployer) -public: - MaemoSshDeployer(const Core::SshServerInfo &server, - const QList &deploySpecs); - -signals: - void fileCopied(const QString &filePath); - -private: - virtual bool runInternal(); - - const QList m_deploySpecs; -}; - -} // namespace Internal -} // namespace Qt4ProjectManager - -#endif // MAEMOSSHTHREAD_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri index 346c1b8a062..30633dd68dd 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri +++ b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri @@ -10,7 +10,6 @@ HEADERS += \ $$PWD/maemosettingspage.h \ $$PWD/maemosettingswidget.h \ $$PWD/maemosshconfigdialog.h \ - $$PWD/maemosshthread.h \ $$PWD/maemotoolchain.h \ $$PWD/maemopackagecreationstep.h \ $$PWD/maemopackagecreationfactory.h \ @@ -33,7 +32,6 @@ SOURCES += \ $$PWD/maemosettingspage.cpp \ $$PWD/maemosettingswidget.cpp \ $$PWD/maemosshconfigdialog.cpp \ - $$PWD/maemosshthread.cpp \ $$PWD/maemotoolchain.cpp \ $$PWD/maemopackagecreationstep.cpp \ $$PWD/maemopackagecreationfactory.cpp \ diff --git a/tests/manual/ssh/main.cpp b/tests/manual/ssh/main.cpp new file mode 100644 index 00000000000..3a17c436fa3 --- /dev/null +++ b/tests/manual/ssh/main.cpp @@ -0,0 +1,177 @@ +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace Core; + +class Test : public QObject { + Q_OBJECT +public: + Test() + { + m_timeoutTimer.setSingleShot(true); + m_connection = SshConnection::create(); + if (m_connection->state() != SshConnection::Unconnected) { + qDebug("Error: Newly created SSH connection has state %d.", + m_connection->state()); + } + + if (m_connection->createRemoteProcess("")) + qDebug("Error: Unconnected SSH connection creates remote process."); + if (m_connection->createSftpChannel()) + qDebug("Error: Unconnected SSH connection creates SFTP channel."); + + SshConnectionParameters noHost; + noHost.host = QLatin1String("hgdfxgfhgxfhxgfchxgcf"); + noHost.port = 12345; + noHost.timeout = 10; + + SshConnectionParameters noUser; + noUser.host = QLatin1String("localhost"); + noUser.port = 22; + noUser.timeout = 30; + noUser.authType = SshConnectionParameters::AuthByPwd; + noUser.uname = QLatin1String("dumdidumpuffpuff"); + noUser.uname = QLatin1String("whatever"); + + SshConnectionParameters wrongPwd; + wrongPwd.host = QLatin1String("localhost"); + wrongPwd.port = 22; + wrongPwd.timeout = 30; + wrongPwd.authType = SshConnectionParameters::AuthByPwd; + wrongPwd.uname = QLatin1String("root"); + noUser.uname = QLatin1String("thiscantpossiblybeapasswordcanit"); + + SshConnectionParameters invalidKeyFile; + invalidKeyFile.host = QLatin1String("localhost"); + invalidKeyFile.port = 22; + invalidKeyFile.timeout = 30; + invalidKeyFile.authType = SshConnectionParameters::AuthByKey; + invalidKeyFile.uname = QLatin1String("root"); + invalidKeyFile.privateKeyFile + = QLatin1String("somefilenamethatwedontexpecttocontainavalidkey"); + + // TODO: Create a valid key file and check for authentication error. + + m_testSet << TestItem("Behavior with non-existing host", + noHost, ErrorList() << SshSocketError); + m_testSet << TestItem("Behavior with non-existing user", noUser, + ErrorList() << SshSocketError << SshTimeoutError + << SshAuthenticationError); + m_testSet << TestItem("Behavior with wrong password", wrongPwd, + ErrorList() << SshSocketError << SshTimeoutError + << SshAuthenticationError); + m_testSet << TestItem("Behavior with invalid key file", invalidKeyFile, + ErrorList() << SshSocketError << SshTimeoutError + << SshKeyFileError); + + runNextTest(); + } + + ~Test(); + +private slots: + void handleConnected() + { + qDebug("Error: Received unexpected connected() signal."); + qApp->quit(); + } + + void handleDisconnected() + { + qDebug("Error: Received unexpected disconnected() signal."); + qApp->quit(); + } + + void handleDataAvailable(const QString &msg) + { + qDebug("Error: Received unexpected dataAvailable() signal. " + "Message was: '%s'.", qPrintable(msg)); + qApp->quit(); + } + + void handleError(SshError error) + { + if (m_testSet.isEmpty()) { + qDebug("Error: Received error %d, but no test was running.", error); + qApp->quit(); + } + + const TestItem testItem = m_testSet.takeFirst(); + if (testItem.allowedErrors.contains(error)) { + qDebug("Received error %d, as expected.", error); + if (m_testSet.isEmpty()) { + qDebug("All tests finished successfully."); + qApp->quit(); + } else { + runNextTest(); + } + } else { + qDebug("Received unexpected error %d.", error); + qApp->quit(); + } + } + + void handleTimeout() + { + if (m_testSet.isEmpty()) { + qDebug("Error: timeout, but no test was running."); + qApp->quit(); + } + const TestItem testItem = m_testSet.takeFirst(); + qDebug("Error: The following test timed out: %s", testItem.description); + } + +private: + void runNextTest() + { + if (m_connection) + disconnect(m_connection.data(), 0, this, 0); + m_connection = SshConnection::create(); + connect(m_connection.data(), SIGNAL(connected()), this, + SLOT(handleConnected())); + connect(m_connection.data(), SIGNAL(disconnected()), this, + SLOT(handleDisconnected())); + connect(m_connection.data(), SIGNAL(dataAvailable(QString)), this, + SLOT(handleDataAvailable(QString))); + connect(m_connection.data(), SIGNAL(error(SshError)), this, + SLOT(handleError(SshError))); + const TestItem &nextItem = m_testSet.first(); + m_timeoutTimer.stop(); + m_timeoutTimer.setInterval(qMax(10000, nextItem.params.timeout * 1000)); + qDebug("Testing: %s", nextItem.description); + m_connection->connectToHost(m_testSet.first().params); + } + + SshConnection::Ptr m_connection; + typedef QList ErrorList; + struct TestItem { + TestItem(const char *d, const SshConnectionParameters &p, + const ErrorList &e) : description(d), params(p), allowedErrors(e) {} + + const char *description; + SshConnectionParameters params; + ErrorList allowedErrors; + }; + QList m_testSet; + QTimer m_timeoutTimer; +}; + +Test::~Test() {} + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + Test t; + + return a.exec(); +} + + +#include "main.moc" diff --git a/tests/manual/ssh/ssh.pro b/tests/manual/ssh/ssh.pro new file mode 100644 index 00000000000..ac61d201669 --- /dev/null +++ b/tests/manual/ssh/ssh.pro @@ -0,0 +1,25 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-07-01T09:44:44 +# +#------------------------------------------------- + +INCLUDEPATH += ../../../src/plugins +CREATORLIBPATH = ../../../lib/qtcreator +PLUGINPATH=$$CREATORLIBPATH/plugins/Nokia +LIBS *= -L$$PLUGINPATH -lCore +LIBS *= -L$$CREATORLIBPATH +include (../../../src/plugins/coreplugin/coreplugin_dependencies.pri) + +QT += core + +QT -= gui + +TARGET = ssh +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + + +SOURCES += main.cpp