This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient-contrib. commit bfbc1e99c4dc16e4ab3e107a98573784b49eadea Author: Mike DePaulo <mikedep333@gmail.com> Date: Tue Jan 13 00:24:56 2015 -0500 Add libssh 0.6.4 ( + the 3 0.6.x commits since 0.6.4 was released) with our current 2 patches applied. --- .../CMake-Show-My-Changes.txt | 17 + .../CMake/libssh/libssh-config-version.cmake | 11 + .../CMake/libssh/libssh-config.cmake | 13 + libssh/0.6.4-x2go1-mingw482_bin/bin/libssh.dll | Bin 0 -> 446214 bytes .../bin/libssh_threads.dll | Bin 0 -> 41391 bytes libssh/0.6.4-x2go1-mingw482_bin/build-log.txt | 89 ++ .../include/libssh/callbacks.h | 855 +++++++++++++++++ .../include/libssh/legacy.h | 120 +++ .../include/libssh/libssh.h | 644 +++++++++++++ .../include/libssh/server.h | 336 +++++++ .../0.6.4-x2go1-mingw482_bin/include/libssh/sftp.h | 1000 ++++++++++++++++++++ .../0.6.4-x2go1-mingw482_bin/include/libssh/ssh2.h | 80 ++ libssh/0.6.4-x2go1-mingw482_bin/lib/libssh.dll.a | Bin 0 -> 237438 bytes .../lib/libssh_threads.dll.a | Bin 0 -> 1538 bytes .../lib/pkgconfig/libssh.pc | 6 + .../lib/pkgconfig/libssh_threads.pc | 6 + libssh/0.6.4-x2go1-mingw482_bin_set-timestamps.sh | 16 + .../0.6.4-x2go1-mingw482_src.zip | Bin 0 -> 515193 bytes .../0001-options-Fix-setting-the-port.patch | 112 +++ ...heck-that-errno-is-0-to-fix-Windows-build.patch | 31 + .../0003-Fix-the-dh.c-build-with-libgcrypt.patch | 55 ++ .../CMake-Show-My-Changes.txt | 17 + ...support-for-putty-s-pageant-0.6.4-71a931b.patch | 540 +++++++++++ .../libssh-fix-mingw482-build.patch | 33 + .../why-patches-0001-0003-exist.txt | 16 + 25 files changed, 3997 insertions(+) diff --git a/libssh/0.6.4-x2go1-mingw482_bin/CMake-Show-My-Changes.txt b/libssh/0.6.4-x2go1-mingw482_bin/CMake-Show-My-Changes.txt new file mode 100755 index 0000000..66391e0 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/CMake-Show-My-Changes.txt @@ -0,0 +1,17 @@ +Commandline options: +-DCMAKE_INSTALL_PREFIX:PATH="C:/x2gobuilds/libssh/build/install_dir" -DZLIB_LIBRARY:FILEPATH="C:/x2gobuilds/libssh_depends/zlib128-dll/zlib1.dll" -DSSL_EAY:FILEPATH="C:/OpenSSL-Win32/bin/ssleay32.dll" -DCMAKE_BUILD_TYPE:STRING="Release" -DZLIB_ROOT_DIR:PATH="C:/x2gobuilds/libssh_depends/zlib128-dll" -DCMAKE_CXX_FLAGS:STRING="" -DWITH_NACL:BOOL="0" -DWITH_GSSAPI:BOOL="0" -DZLIB_INCLUDE_DIR:PATH="C:/x2gobuilds/libssh_depends/zlib128-dll/include" -DWITH_EXAMPLES:BOOL="0" -DLIB_EAY:FILEPATH= [...] + + +Cache file: +CMAKE_INSTALL_PREFIX:PATH=C:/x2gobuilds/libssh/build/install_dir +ZLIB_LIBRARY:FILEPATH=C:/x2gobuilds/libssh_depends/zlib128-dll/zlib1.dll +SSL_EAY:FILEPATH=C:/OpenSSL-Win32/bin/ssleay32.dll +CMAKE_BUILD_TYPE:STRING=Release +ZLIB_ROOT_DIR:PATH=C:/x2gobuilds/libssh_depends/zlib128-dll +CMAKE_CXX_FLAGS:STRING= +WITH_NACL:BOOL=0 +WITH_GSSAPI:BOOL=0 +ZLIB_INCLUDE_DIR:PATH=C:/x2gobuilds/libssh_depends/zlib128-dll/include +WITH_EXAMPLES:BOOL=0 +LIB_EAY:FILEPATH=C:/OpenSSL-Win32/bin/libeay32.dll +BIN_INSTALL_DIR:PATH=bin diff --git a/libssh/0.6.4-x2go1-mingw482_bin/CMake/libssh/libssh-config-version.cmake b/libssh/0.6.4-x2go1-mingw482_bin/CMake/libssh/libssh-config-version.cmake new file mode 100755 index 0000000..3214b6d --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/CMake/libssh/libssh-config-version.cmake @@ -0,0 +1,11 @@ +set(PACKAGE_VERSION 0.6.4) + +# Check whether the requested PACKAGE_FIND_VERSION is compatible +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/libssh/0.6.4-x2go1-mingw482_bin/CMake/libssh/libssh-config.cmake b/libssh/0.6.4-x2go1-mingw482_bin/CMake/libssh/libssh-config.cmake new file mode 100755 index 0000000..37a636b --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/CMake/libssh/libssh-config.cmake @@ -0,0 +1,13 @@ +get_filename_component(LIBSSH_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + +if (EXISTS "${LIBSSH_CMAKE_DIR}/CMakeCache.txt") + # In build tree + include(${LIBSSH_CMAKE_DIR}/libssh-build-tree-settings.cmake) +else() + set(LIBSSH_INCLUDE_DIR include) +endif() + +set(LIBSSH_LIBRARY lib/libssh.dll) +set(LIBSSH_LIBRARIES lib/libssh.dll) + +set(LIBSSH_THREADS_LIBRARY lib/libssh.dll) diff --git a/libssh/0.6.4-x2go1-mingw482_bin/bin/libssh.dll b/libssh/0.6.4-x2go1-mingw482_bin/bin/libssh.dll new file mode 100755 index 0000000..3699250 Binary files /dev/null and b/libssh/0.6.4-x2go1-mingw482_bin/bin/libssh.dll differ diff --git a/libssh/0.6.4-x2go1-mingw482_bin/bin/libssh_threads.dll b/libssh/0.6.4-x2go1-mingw482_bin/bin/libssh_threads.dll new file mode 100755 index 0000000..5b57b0a Binary files /dev/null and b/libssh/0.6.4-x2go1-mingw482_bin/bin/libssh_threads.dll differ diff --git a/libssh/0.6.4-x2go1-mingw482_bin/build-log.txt b/libssh/0.6.4-x2go1-mingw482_bin/build-log.txt new file mode 100755 index 0000000..b4e0d5d --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/build-log.txt @@ -0,0 +1,89 @@ +C:\x2gobuilds\libssh\build>make -j4 +[ 4%] [ 4%] [ 6%] [ 8%] Building C object src/CMakeFiles/ssh_shared.dir/agent.c.obj +Building C object src/CMakeFiles/ssh_shared.dir/auth.c.obj +Building C object src/CMakeFiles/ssh_shared.dir/base64.c.obj +Building C object src/CMakeFiles/ssh_shared.dir/buffer.c.obj +C:\x2gobuilds\libssh\src\agent.c: In function 'agent_talk': +C:\x2gobuilds\libssh\src\agent.c:346:3: warning: 'ssh_log' is deprecated (declared at C:/x2gobuilds/libssh/include/libssh/libssh.h:453) [-Wdeprecated-declarations] + ssh_log(session, SSH_LOG_PACKET, "agent_talk - len of request: %u", inlen); + ^ +C:\x2gobuilds\libssh\src\agent.c:355:3: warning: passing argument 3 of 'agent_query' from incompatible pointer type [enabled by default] + agent_query((void*)payload, inlen + 4, &t, &outlen); + ^ +In file included from C:\x2gobuilds\libssh\src\agent.c:68:0: +C:\x2gobuilds\libssh\src\winpgntc.h:31:5: note: expected 'void **' but argument is of type 'uint8_t **' + int agent_query(void *in, int inlen, void **out, int *outlen); + ^ +C:\x2gobuilds\libssh\src\agent.c:362:3: warning: 'ssh_log' is deprecated (declared at C:/x2gobuilds/libssh/include/libssh/libssh.h:453) [-Wdeprecated-declarations] + ssh_log(session, SSH_LOG_PACKET, "agent_talk - response length: %u", outlen); + ^ +C:\x2gobuilds\libssh\src\agent.c:367:5: warning: 'ssh_log' is deprecated (declared at C:/x2gobuilds/libssh/include/libssh/libssh.h:453) [-Wdeprecated-declarations] + ssh_log(session, SSH_LOG_FUNCTIONS, + ^ +[ 11%] [ 13%] Building C object src/CMakeFiles/ssh_shared.dir/callbacks.c.obj +Building C object src/CMakeFiles/ssh_shared.dir/channels.c.obj +[ 15%] Building C object src/CMakeFiles/ssh_shared.dir/client.c.obj +[ 17%] Building C object src/CMakeFiles/ssh_shared.dir/config.c.obj +[ 20%] Building C object src/CMakeFiles/ssh_shared.dir/connect.c.obj +[ 22%] Building C object src/CMakeFiles/ssh_shared.dir/curve25519.c.obj +[ 24%] Building C object src/CMakeFiles/ssh_shared.dir/dh.c.obj +[ 26%] Building C object src/CMakeFiles/ssh_shared.dir/ecdh.c.obj +[ 28%] Building C object src/CMakeFiles/ssh_shared.dir/error.c.obj +[ 31%] Building C object src/CMakeFiles/ssh_shared.dir/getpass.c.obj +[ 33%] [ 35%] Building C object src/CMakeFiles/ssh_shared.dir/init.c.obj +Building C object src/CMakeFiles/ssh_shared.dir/kex.c.obj +[ 37%] Building C object src/CMakeFiles/ssh_shared.dir/known_hosts.c.obj +[ 40%] Building C object src/CMakeFiles/ssh_shared.dir/legacy.c.obj +[ 42%] Building C object src/CMakeFiles/ssh_shared.dir/libcrypto.c.obj +[ 44%] Building C object src/CMakeFiles/ssh_shared.dir/log.c.obj +[ 46%] Building C object src/CMakeFiles/ssh_shared.dir/match.c.obj +[ 48%] Building C object src/CMakeFiles/ssh_shared.dir/messages.c.obj +[ 51%] Building C object src/CMakeFiles/ssh_shared.dir/misc.c.obj +[ 53%] Building C object src/CMakeFiles/ssh_shared.dir/options.c.obj +[ 55%] Building C object src/CMakeFiles/ssh_shared.dir/packet.c.obj +[ 57%] Building C object src/CMakeFiles/ssh_shared.dir/packet_cb.c.obj +[ 62%] [ 62%] Building C object src/CMakeFiles/ssh_shared.dir/packet_crypt.c.obj +Building C object src/CMakeFiles/ssh_shared.dir/pcap.c.obj +[ 64%] Building C object src/CMakeFiles/ssh_shared.dir/pki.c.obj +[ 66%] Building C object src/CMakeFiles/ssh_shared.dir/poll.c.obj +[ 68%] [ 71%] Building C object src/CMakeFiles/ssh_shared.dir/session.c.obj +Building C object src/CMakeFiles/ssh_shared.dir/scp.c.obj +[ 75%] [ 75%] Building C object src/CMakeFiles/ssh_shared.dir/string.c.obj +Building C object src/CMakeFiles/ssh_shared.dir/socket.c.obj +[ 80%] [ 80%] Building C object src/CMakeFiles/ssh_shared.dir/wrapper.c.obj +Building C object src/CMakeFiles/ssh_shared.dir/threads.c.obj +[ 82%] Building C object src/CMakeFiles/ssh_shared.dir/winpgntc.c.obj +[ 84%] Building C object src/CMakeFiles/ssh_shared.dir/pki_crypto.c.obj +[ 86%] Building C object src/CMakeFiles/ssh_shared.dir/sftp.c.obj +[ 88%] Building C object src/CMakeFiles/ssh_shared.dir/sftpserver.c.obj +[ 91%] Building C object src/CMakeFiles/ssh_shared.dir/server.c.obj +[ 93%] Building C object src/CMakeFiles/ssh_shared.dir/bind.c.obj +[ 95%] Building C object src/CMakeFiles/ssh_shared.dir/gzip.c.obj +[ 97%] Building C object src/CMakeFiles/ssh_shared.dir/curve25519_ref.c.obj +Linking C shared library libssh.dll +[ 97%] Built target ssh_shared +[100%] Building C object src/threads/CMakeFiles/ssh_threads_shared.dir/pthread.c.obj +Linking C shared library libssh_threads.dll +[100%] Built target ssh_threads_shared + +C:\x2gobuilds\libssh\build>make install +[ 97%] Built target ssh_shared +[100%] Built target ssh_threads_shared +Install the project... +-- Install configuration: "Release" +-- Installing: C:/x2gobuilds/libssh/build/install_dir/lib/pkgconfig/libssh.pc +-- Installing: C:/x2gobuilds/libssh/build/install_dir/lib/pkgconfig/libssh_threads.pc +-- Installing: C:/x2gobuilds/libssh/build/install_dir/CMake/libssh/libssh-config.cmake +-- Installing: C:/x2gobuilds/libssh/build/install_dir/CMake/libssh/libssh-config-version.cmake +-- Installing: C:/x2gobuilds/libssh/build/install_dir/include/libssh/callbacks.h +-- Installing: C:/x2gobuilds/libssh/build/install_dir/include/libssh/libssh.h +-- Installing: C:/x2gobuilds/libssh/build/install_dir/include/libssh/ssh2.h +-- Installing: C:/x2gobuilds/libssh/build/install_dir/include/libssh/legacy.h +-- Installing: C:/x2gobuilds/libssh/build/install_dir/include/libssh/sftp.h +-- Installing: C:/x2gobuilds/libssh/build/install_dir/include/libssh/server.h +-- Installing: C:/x2gobuilds/libssh/build/install_dir/lib/libssh.dll.a +-- Installing: C:/x2gobuilds/libssh/build/install_dir/bin/libssh.dll +-- Installing: C:/x2gobuilds/libssh/build/install_dir/lib/libssh_threads.dll.a +-- Installing: C:/x2gobuilds/libssh/build/install_dir/bin/libssh_threads.dll + +C:\x2gobuilds\libssh\build> \ No newline at end of file diff --git a/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/callbacks.h b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/callbacks.h new file mode 100755 index 0000000..6bd8c57 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/callbacks.h @@ -0,0 +1,855 @@ +/* + * This file is part of the SSH Library + * + * Copyright (c) 2009 Aris Adamantiadis <aris@0xbadc0de.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* callback.h + * This file includes the public declarations for the libssh callback mechanism + */ + +#ifndef _SSH_CALLBACK_H +#define _SSH_CALLBACK_H + +#include <libssh/libssh.h> +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup libssh_callbacks The libssh callbacks + * @ingroup libssh + * + * Callback which can be replaced in libssh. + * + * @{ + */ + +/** @internal + * @brief callback to process simple codes + * @param code value to transmit + * @param user Userdata to pass in callback + */ +typedef void (*ssh_callback_int) (int code, void *user); + +/** @internal + * @brief callback for data received messages. + * @param data data retrieved from the socket or stream + * @param len number of bytes available from this stream + * @param user user-supplied pointer sent along with all callback messages + * @returns number of bytes processed by the callee. The remaining bytes will + * be sent in the next callback message, when more data is available. + */ +typedef int (*ssh_callback_data) (const void *data, size_t len, void *user); + +typedef void (*ssh_callback_int_int) (int code, int errno_code, void *user); + +typedef int (*ssh_message_callback) (ssh_session, ssh_message message, void *user); +typedef int (*ssh_channel_callback_int) (ssh_channel channel, int code, void *user); +typedef int (*ssh_channel_callback_data) (ssh_channel channel, int code, void *data, size_t len, void *user); + +/** + * @brief SSH log callback. All logging messages will go through this callback + * @param session Current session handler + * @param priority Priority of the log, the smaller being the more important + * @param message the actual message + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_log_callback) (ssh_session session, int priority, + const char *message, void *userdata); + +/** + * @brief SSH log callback. + * + * All logging messages will go through this callback. + * + * @param priority Priority of the log, the smaller being the more important. + * + * @param function The function name calling the the logging fucntions. + * + * @param message The actual message + * + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_logging_callback) (int priority, + const char *function, + const char *buffer, + void *userdata); + +/** + * @brief SSH Connection status callback. + * @param session Current session handler + * @param status Percentage of connection status, going from 0.0 to 1.0 + * once connection is done. + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_status_callback) (ssh_session session, float status, + void *userdata); + +/** + * @brief SSH global request callback. All global request will go through this + * callback. + * @param session Current session handler + * @param message the actual message + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_global_request_callback) (ssh_session session, + ssh_message message, void *userdata); + +/** + * @brief Handles an SSH new channel open X11 request. This happens when the server + * sends back an X11 connection attempt. This is a client-side API + * @param session current session handler + * @param userdata Userdata to be passed to the callback function. + * @returns a valid ssh_channel handle if the request is to be allowed + * @returns NULL if the request should not be allowed + * @warning The channel pointer returned by this callback must be closed by the application. + */ +typedef ssh_channel (*ssh_channel_open_request_x11_callback) (ssh_session session, + const char * originator_address, int originator_port, void *userdata); + +/** + * The structure to replace libssh functions with appropriate callbacks. + */ +struct ssh_callbacks_struct { + /** DON'T SET THIS use ssh_callbacks_init() instead. */ + size_t size; + /** + * User-provided data. User is free to set anything he wants here + */ + void *userdata; + /** + * This functions will be called if e.g. a keyphrase is needed. + */ + ssh_auth_callback auth_function; + /** + * This function will be called each time a loggable event happens. + */ + ssh_log_callback log_function; + /** + * This function gets called during connection time to indicate the + * percentage of connection steps completed. + */ + void (*connect_status_function)(void *userdata, float status); + /** + * This function will be called each time a global request is received. + */ + ssh_global_request_callback global_request_function; + /** This function will be called when an incoming X11 request is received. + */ + ssh_channel_open_request_x11_callback channel_open_request_x11_function; +}; +typedef struct ssh_callbacks_struct *ssh_callbacks; + +/** These are callbacks used specifically in SSH servers. + */ + +/** + * @brief SSH authentication callback. + * @param session Current session handler + * @param user User that wants to authenticate + * @param password Password used for authentication + * @param userdata Userdata to be passed to the callback function. + * @returns SSH_AUTH_SUCCESS Authentication is accepted. + * @returns SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed. + * @returns SSH_AUTH_DENIED Authentication failed. + */ +typedef int (*ssh_auth_password_callback) (ssh_session session, const char *user, const char *password, + void *userdata); + +/** + * @brief SSH authentication callback. Tries to authenticates user with the "none" method + * which is anonymous or passwordless. + * @param session Current session handler + * @param user User that wants to authenticate + * @param userdata Userdata to be passed to the callback function. + * @returns SSH_AUTH_SUCCESS Authentication is accepted. + * @returns SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed. + * @returns SSH_AUTH_DENIED Authentication failed. + */ +typedef int (*ssh_auth_none_callback) (ssh_session session, const char *user, void *userdata); + +/** + * @brief SSH authentication callback. Tries to authenticates user with the "gssapi-with-mic" method + * @param session Current session handler + * @param user Username of the user (can be spoofed) + * @param principal Authenticated principal of the user, including realm. + * @param userdata Userdata to be passed to the callback function. + * @returns SSH_AUTH_SUCCESS Authentication is accepted. + * @returns SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed. + * @returns SSH_AUTH_DENIED Authentication failed. + * @warning Implementations should verify that parameter user matches in some way the principal. + * user and principal can be different. Only the latter is guaranteed to be safe. + */ +typedef int (*ssh_auth_gssapi_mic_callback) (ssh_session session, const char *user, const char *principal, + void *userdata); + +/** + * @brief SSH authentication callback. + * @param session Current session handler + * @param user User that wants to authenticate + * @param pubkey public key used for authentication + * @param signature_state SSH_PUBLICKEY_STATE_NONE if the key is not signed (simple public key probe), + * SSH_PUBLICKEY_STATE_VALID if the signature is valid. Others values should be + * replied with a SSH_AUTH_DENIED. + * @param userdata Userdata to be passed to the callback function. + * @returns SSH_AUTH_SUCCESS Authentication is accepted. + * @returns SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed. + * @returns SSH_AUTH_DENIED Authentication failed. + */ +typedef int (*ssh_auth_pubkey_callback) (ssh_session session, const char *user, struct ssh_key_struct *pubkey, + char signature_state, void *userdata); + + +/** + * @brief Handles an SSH service request + * @param session current session handler + * @param service name of the service (e.g. "ssh-userauth") requested + * @param userdata Userdata to be passed to the callback function. + * @returns 0 if the request is to be allowed + * @returns -1 if the request should not be allowed + */ + +typedef int (*ssh_service_request_callback) (ssh_session session, const char *service, void *userdata); + +/** + * @brief Handles an SSH new channel open session request + * @param session current session handler + * @param userdata Userdata to be passed to the callback function. + * @returns a valid ssh_channel handle if the request is to be allowed + * @returns NULL if the request should not be allowed + * @warning The channel pointer returned by this callback must be closed by the application. + */ +typedef ssh_channel (*ssh_channel_open_request_session_callback) (ssh_session session, void *userdata); + +/* + * @brief handle the beginning of a GSSAPI authentication, server side. + * @param session current session handler + * @param user the username of the client + * @param n_oid number of available oids + * @param oids OIDs provided by the client + * @returns an ssh_string containing the chosen OID, that's supported by both + * client and server. + * @warning It is not necessary to fill this callback in if libssh is linked + * with libgssapi. + */ +typedef ssh_string (*ssh_gssapi_select_oid_callback) (ssh_session session, const char *user, + int n_oid, ssh_string *oids, void *userdata); + +/* + * @brief handle the negociation of a security context, server side. + * @param session current session handler + * @param[in] input_token input token provided by client + * @param[out] output_token output of the gssapi accept_sec_context method, + * NULL after completion. + * @returns SSH_OK if the token was generated correctly or accept_sec_context + * returned GSS_S_COMPLETE + * @returns SSH_ERROR in case of error + * @warning It is not necessary to fill this callback in if libssh is linked + * with libgssapi. + */ +typedef int (*ssh_gssapi_accept_sec_ctx_callback) (ssh_session session, + ssh_string input_token, ssh_string *output_token, void *userdata); + +/* + * @brief Verify and authenticates a MIC, server side. + * @param session current session handler + * @param[in] mic input mic to be verified provided by client + * @param[in] mic_buffer buffer of data to be signed. + * @param[in] mic_buffer_size size of mic_buffer + * @returns SSH_OK if the MIC was authenticated correctly + * @returns SSH_ERROR in case of error + * @warning It is not necessary to fill this callback in if libssh is linked + * with libgssapi. + */ +typedef int (*ssh_gssapi_verify_mic_callback) (ssh_session session, + ssh_string mic, void *mic_buffer, size_t mic_buffer_size, void *userdata); + + +/** + * This structure can be used to implement a libssh server, with appropriate callbacks. + */ + +struct ssh_server_callbacks_struct { + /** DON'T SET THIS use ssh_callbacks_init() instead. */ + size_t size; + /** + * User-provided data. User is free to set anything he wants here + */ + void *userdata; + /** This function gets called when a client tries to authenticate through + * password method. + */ + ssh_auth_password_callback auth_password_function; + + /** This function gets called when a client tries to authenticate through + * none method. + */ + ssh_auth_none_callback auth_none_function; + + /** This function gets called when a client tries to authenticate through + * gssapi-mic method. + */ + ssh_auth_gssapi_mic_callback auth_gssapi_mic_function; + + /** this function gets called when a client tries to authenticate or offer + * a public key. + */ + ssh_auth_pubkey_callback auth_pubkey_function; + + /** This functions gets called when a service request is issued by the + * client + */ + ssh_service_request_callback service_request_function; + /** This functions gets called when a new channel request is issued by + * the client + */ + ssh_channel_open_request_session_callback channel_open_request_session_function; + /** This function will be called when a new gssapi authentication is attempted. + */ + ssh_gssapi_select_oid_callback gssapi_select_oid_function; + /** This function will be called when a gssapi token comes in. + */ + ssh_gssapi_accept_sec_ctx_callback gssapi_accept_sec_ctx_function; + /* This function will be called when a MIC needs to be verified. + */ + ssh_gssapi_verify_mic_callback gssapi_verify_mic_function; +}; +typedef struct ssh_server_callbacks_struct *ssh_server_callbacks; + +/** + * @brief Set the session server callback functions. + * + * This functions sets the callback structure to use your own callback + * functions for user authentication, new channels and requests. + * + * @code + * struct ssh_server_callbacks_struct cb = { + * .userdata = data, + * .auth_password_function = my_auth_function + * }; + * ssh_callbacks_init(&cb); + * ssh_set_server_callbacks(session, &cb); + * @endcode + * + * @param session The session to set the callback structure. + * + * @param cb The callback structure itself. + * + * @return SSH_OK on success, SSH_ERROR on error. + */ +LIBSSH_API int ssh_set_server_callbacks(ssh_session session, ssh_server_callbacks cb); + +/** + * These are the callbacks exported by the socket structure + * They are called by the socket module when a socket event appears + */ +struct ssh_socket_callbacks_struct { + /** + * User-provided data. User is free to set anything he wants here + */ + void *userdata; + /** + * This function will be called each time data appears on socket. The data + * not consumed will appear on the next data event. + */ + ssh_callback_data data; + /** This function will be called each time a controlflow state changes, i.e. + * the socket is available for reading or writing. + */ + ssh_callback_int controlflow; + /** This function will be called each time an exception appears on socket. An + * exception can be a socket problem (timeout, ...) or an end-of-file. + */ + ssh_callback_int_int exception; + /** This function is called when the ssh_socket_connect was used on the socket + * on nonblocking state, and the connection successed. + */ + ssh_callback_int_int connected; +}; +typedef struct ssh_socket_callbacks_struct *ssh_socket_callbacks; + +#define SSH_SOCKET_FLOW_WRITEWILLBLOCK 1 +#define SSH_SOCKET_FLOW_WRITEWONTBLOCK 2 + +#define SSH_SOCKET_EXCEPTION_EOF 1 +#define SSH_SOCKET_EXCEPTION_ERROR 2 + +#define SSH_SOCKET_CONNECTED_OK 1 +#define SSH_SOCKET_CONNECTED_ERROR 2 +#define SSH_SOCKET_CONNECTED_TIMEOUT 3 + +/** + * @brief Initializes an ssh_callbacks_struct + * A call to this macro is mandatory when you have set a new + * ssh_callback_struct structure. Its goal is to maintain the binary + * compatibility with future versions of libssh as the structure + * evolves with time. + */ +#define ssh_callbacks_init(p) do {\ + (p)->size=sizeof(*(p)); \ +} while(0); + +/** + * @internal + * @brief tests if a callback can be called without crash + * verifies that the struct size if big enough + * verifies that the callback pointer exists + * @param p callback pointer + * @param c callback name + * @returns nonzero if callback can be called + */ +#define ssh_callbacks_exists(p,c) (\ + (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \ + ((p)-> c != NULL) \ + ) + +/** @brief Prototype for a packet callback, to be called when a new packet arrives + * @param session The current session of the packet + * @param type packet type (see ssh2.h) + * @param packet buffer containing the packet, excluding size, type and padding fields + * @param user user argument to the callback + * and are called each time a packet shows up + * @returns SSH_PACKET_USED Packet was parsed and used + * @returns SSH_PACKET_NOT_USED Packet was not used or understood, processing must continue + */ +typedef int (*ssh_packet_callback) (ssh_session session, uint8_t type, ssh_buffer packet, void *user); + +/** return values for a ssh_packet_callback */ +/** Packet was used and should not be parsed by another callback */ +#define SSH_PACKET_USED 1 +/** Packet was not used and should be passed to any other callback + * available */ +#define SSH_PACKET_NOT_USED 2 + + +/** @brief This macro declares a packet callback handler + * @code + * SSH_PACKET_CALLBACK(mycallback){ + * ... + * } + * @endcode + */ +#define SSH_PACKET_CALLBACK(name) \ + int name (ssh_session session, uint8_t type, ssh_buffer packet, void *user) + +struct ssh_packet_callbacks_struct { + /** Index of the first packet type being handled */ + uint8_t start; + /** Number of packets being handled by this callback struct */ + uint8_t n_callbacks; + /** A pointer to n_callbacks packet callbacks */ + ssh_packet_callback *callbacks; + /** + * User-provided data. User is free to set anything he wants here + */ + void *user; +}; + +typedef struct ssh_packet_callbacks_struct *ssh_packet_callbacks; + +/** + * @brief Set the session callback functions. + * + * This functions sets the callback structure to use your own callback + * functions for auth, logging and status. + * + * @code + * struct ssh_callbacks_struct cb = { + * .userdata = data, + * .auth_function = my_auth_function + * }; + * ssh_callbacks_init(&cb); + * ssh_set_callbacks(session, &cb); + * @endcode + * + * @param session The session to set the callback structure. + * + * @param cb The callback structure itself. + * + * @return SSH_OK on success, SSH_ERROR on error. + */ +LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb); + +/** + * @brief SSH channel data callback. Called when data is available on a channel + * @param session Current session handler + * @param channel the actual channel + * @param data the data that has been read on the channel + * @param len the length of the data + * @param is_stderr is 0 for stdout or 1 for stderr + * @param userdata Userdata to be passed to the callback function. + * @returns number of bytes processed by the callee. The remaining bytes will + * be sent in the next callback message, when more data is available. + */ +typedef int (*ssh_channel_data_callback) (ssh_session session, + ssh_channel channel, + void *data, + uint32_t len, + int is_stderr, + void *userdata); + +/** + * @brief SSH channel eof callback. Called when a channel receives EOF + * @param session Current session handler + * @param channel the actual channel + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_channel_eof_callback) (ssh_session session, + ssh_channel channel, + void *userdata); + +/** + * @brief SSH channel close callback. Called when a channel is closed by remote peer + * @param session Current session handler + * @param channel the actual channel + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_channel_close_callback) (ssh_session session, + ssh_channel channel, + void *userdata); + +/** + * @brief SSH channel signal callback. Called when a channel has received a signal + * @param session Current session handler + * @param channel the actual channel + * @param signal the signal name (without the SIG prefix) + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_channel_signal_callback) (ssh_session session, + ssh_channel channel, + const char *signal, + void *userdata); + +/** + * @brief SSH channel exit status callback. Called when a channel has received an exit status + * @param session Current session handler + * @param channel the actual channel + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_channel_exit_status_callback) (ssh_session session, + ssh_channel channel, + int exit_status, + void *userdata); + +/** + * @brief SSH channel exit signal callback. Called when a channel has received an exit signal + * @param session Current session handler + * @param channel the actual channel + * @param signal the signal name (without the SIG prefix) + * @param core a boolean telling wether a core has been dumped or not + * @param errmsg the description of the exception + * @param lang the language of the description (format: RFC 3066) + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_channel_exit_signal_callback) (ssh_session session, + ssh_channel channel, + const char *signal, + int core, + const char *errmsg, + const char *lang, + void *userdata); + +/** + * @brief SSH channel PTY request from a client. + * @param channel the channel + * @param term The type of terminal emulation + * @param width width of the terminal, in characters + * @param height height of the terminal, in characters + * @param pxwidth width of the terminal, in pixels + * @param pxheight height of the terminal, in pixels + * @param userdata Userdata to be passed to the callback function. + * @returns 0 if the pty request is accepted + * @returns -1 if the request is denied + */ +typedef int (*ssh_channel_pty_request_callback) (ssh_session session, + ssh_channel channel, + const char *term, + int width, int height, + int pxwidth, int pwheight, + void *userdata); + +/** + * @brief SSH channel Shell request from a client. + * @param channel the channel + * @param userdata Userdata to be passed to the callback function. + * @returns 0 if the shell request is accepted + * @returns 1 if the request is denied + */ +typedef int (*ssh_channel_shell_request_callback) (ssh_session session, + ssh_channel channel, + void *userdata); +/** + * @brief SSH auth-agent-request from the client. This request is + * sent by a client when agent forwarding is available. + * Server is free to ignore this callback, no answer is expected. + * @param channel the channel + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_channel_auth_agent_req_callback) (ssh_session session, + ssh_channel channel, + void *userdata); + +/** + * @brief SSH X11 request from the client. This request is + * sent by a client when X11 forwarding is requested(and available). + * Server is free to ignore this callback, no answer is expected. + * @param channel the channel + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_channel_x11_req_callback) (ssh_session session, + ssh_channel channel, + int single_connection, + const char *auth_protocol, + const char *auth_cookie, + uint32_t screen_number, + void *userdata); +/** + * @brief SSH channel PTY windows change (terminal size) from a client. + * @param channel the channel + * @param width width of the terminal, in characters + * @param height height of the terminal, in characters + * @param pxwidth width of the terminal, in pixels + * @param pxheight height of the terminal, in pixels + * @param userdata Userdata to be passed to the callback function. + * @returns 0 if the pty request is accepted + * @returns -1 if the request is denied + */ +typedef int (*ssh_channel_pty_window_change_callback) (ssh_session session, + ssh_channel channel, + int width, int height, + int pxwidth, int pwheight, + void *userdata); + +/** + * @brief SSH channel Exec request from a client. + * @param channel the channel + * @param command the shell command to be executed + * @param userdata Userdata to be passed to the callback function. + * @returns 0 if the exec request is accepted + * @returns 1 if the request is denied + */ +typedef int (*ssh_channel_exec_request_callback) (ssh_session session, + ssh_channel channel, + const char *command, + void *userdata); + +/** + * @brief SSH channel environment request from a client. + * @param channel the channel + * @param env_name name of the environment value to be set + * @param env_value value of the environment value to be set + * @param userdata Userdata to be passed to the callback function. + * @returns 0 if the env request is accepted + * @returns 1 if the request is denied + * @warning some environment variables can be dangerous if changed (e.g. + * LD_PRELOAD) and should not be fulfilled. + */ +typedef int (*ssh_channel_env_request_callback) (ssh_session session, + ssh_channel channel, + const char *env_name, + const char *env_value, + void *userdata); +/** + * @brief SSH channel subsystem request from a client. + * @param channel the channel + * @param subsystem the subsystem required + * @param userdata Userdata to be passed to the callback function. + * @returns 0 if the subsystem request is accepted + * @returns 1 if the request is denied + */ +typedef int (*ssh_channel_subsystem_request_callback) (ssh_session session, + ssh_channel channel, + const char *subsystem, + void *userdata); + + +struct ssh_channel_callbacks_struct { + /** DON'T SET THIS use ssh_callbacks_init() instead. */ + size_t size; + /** + * User-provided data. User is free to set anything he wants here + */ + void *userdata; + /** + * This functions will be called when there is data available. + */ + ssh_channel_data_callback channel_data_function; + /** + * This functions will be called when the channel has received an EOF. + */ + ssh_channel_eof_callback channel_eof_function; + /** + * This functions will be called when the channel has been closed by remote + */ + ssh_channel_close_callback channel_close_function; + /** + * This functions will be called when a signal has been received + */ + ssh_channel_signal_callback channel_signal_function; + /** + * This functions will be called when an exit status has been received + */ + ssh_channel_exit_status_callback channel_exit_status_function; + /** + * This functions will be called when an exit signal has been received + */ + ssh_channel_exit_signal_callback channel_exit_signal_function; + /** + * This function will be called when a client requests a PTY + */ + ssh_channel_pty_request_callback channel_pty_request_function; + /** + * This function will be called when a client requests a shell + */ + ssh_channel_shell_request_callback channel_shell_request_function; + /** This function will be called when a client requests agent + * authentication forwarding. + */ + ssh_channel_auth_agent_req_callback channel_auth_agent_req_function; + /** This function will be called when a client requests X11 + * forwarding. + */ + ssh_channel_x11_req_callback channel_x11_req_function; + /** This function will be called when a client requests a + * window change. + */ + ssh_channel_pty_window_change_callback channel_pty_window_change_function; + /** This function will be called when a client requests a + * command execution. + */ + ssh_channel_exec_request_callback channel_exec_request_function; + /** This function will be called when a client requests an environment + * variable to be set. + */ + ssh_channel_env_request_callback channel_env_request_function; + /** This function will be called when a client requests a subsystem + * (like sftp). + */ + ssh_channel_subsystem_request_callback channel_subsystem_request_function; +}; + +typedef struct ssh_channel_callbacks_struct *ssh_channel_callbacks; + +/** + * @brief Set the channel callback functions. + * + * This functions sets the callback structure to use your own callback + * functions for channel data and exceptions + * + * @code + * struct ssh_channel_callbacks_struct cb = { + * .userdata = data, + * .channel_data = my_channel_data_function + * }; + * ssh_callbacks_init(&cb); + * ssh_set_channel_callbacks(channel, &cb); + * @endcode + * + * @param channel The channel to set the callback structure. + * + * @param cb The callback structure itself. + * + * @return SSH_OK on success, SSH_ERROR on error. + */ +LIBSSH_API int ssh_set_channel_callbacks(ssh_channel channel, + ssh_channel_callbacks cb); + +/** @} */ + +/** @group libssh_threads + * @{ + */ + +typedef int (*ssh_thread_callback) (void **lock); + +typedef unsigned long (*ssh_thread_id_callback) (void); +struct ssh_threads_callbacks_struct { + const char *type; + ssh_thread_callback mutex_init; + ssh_thread_callback mutex_destroy; + ssh_thread_callback mutex_lock; + ssh_thread_callback mutex_unlock; + ssh_thread_id_callback thread_id; +}; + +/** + * @brief Set the thread callbacks structure. + * + * This is necessary if your program is using libssh in a multithreaded fashion. + * This function must be called first, outside of any threading context (in your + * main() function for instance), before you call ssh_init(). + * + * @param[in] cb A pointer to a ssh_threads_callbacks_struct structure, which + * contains the different callbacks to be set. + * + * @returns Always returns SSH_OK. + * + * @see ssh_threads_callbacks_struct + * @see SSH_THREADS_PTHREAD + * @bug libgcrypt 1.6 and bigger backend does not support custom callback. + * Using anything else than pthreads here will fail. + */ +LIBSSH_API int ssh_threads_set_callbacks(struct ssh_threads_callbacks_struct + *cb); + +/** + * @brief returns a pointer on the pthread threads callbacks, to be used with + * ssh_threads_set_callbacks. + * @warning you have to link with the library ssh_threads. + * @see ssh_threads_set_callbacks + */ +LIBSSH_API struct ssh_threads_callbacks_struct *ssh_threads_get_pthread(void); + +/** + * @brief Get the noop threads callbacks structure + * + * This can be used with ssh_threads_set_callbacks. These callbacks do nothing + * and are being used by default. + * + * @return Always returns a valid pointer to the noop callbacks structure. + * + * @see ssh_threads_set_callbacks + */ +LIBSSH_API struct ssh_threads_callbacks_struct *ssh_threads_get_noop(void); + +/** + * @brief Set the logging callback function. + * + * @param[in] cb The callback to set. + * + * @return 0 on success, < 0 on errror. + */ +LIBSSH_API int ssh_set_log_callback(ssh_logging_callback cb); + +/** + * @brief Get the pointer to the logging callback function. + * + * @return The pointer the the callback or NULL if none set. + */ +LIBSSH_API ssh_logging_callback ssh_get_log_callback(void); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /*_SSH_CALLBACK_H */ + +/* @} */ diff --git a/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/legacy.h b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/legacy.h new file mode 100755 index 0000000..771fe56 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/legacy.h @@ -0,0 +1,120 @@ +/* + * This file is part of the SSH Library + * + * Copyright (c) 2010 by Aris Adamantiadis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* Since libssh.h includes legacy.h, it's important that libssh.h is included + * first. we don't define LEGACY_H now because we want it to be defined when + * included from libssh.h + * All function calls declared in this header are deprecated and meant to be + * removed in future. + */ + +#ifndef LEGACY_H_ +#define LEGACY_H_ + +typedef struct ssh_private_key_struct* ssh_private_key; +typedef struct ssh_public_key_struct* ssh_public_key; + +LIBSSH_API int ssh_auth_list(ssh_session session); +LIBSSH_API int ssh_userauth_offer_pubkey(ssh_session session, const char *username, int type, ssh_string publickey); +LIBSSH_API int ssh_userauth_pubkey(ssh_session session, const char *username, ssh_string publickey, ssh_private_key privatekey); +#ifndef _WIN32 +LIBSSH_API int ssh_userauth_agent_pubkey(ssh_session session, const char *username, + ssh_public_key publickey); +#endif +LIBSSH_API int ssh_userauth_autopubkey(ssh_session session, const char *passphrase); +LIBSSH_API int ssh_userauth_privatekey_file(ssh_session session, const char *username, + const char *filename, const char *passphrase); + +LIBSSH_API void buffer_free(ssh_buffer buffer); +LIBSSH_API void *buffer_get(ssh_buffer buffer); +LIBSSH_API uint32_t buffer_get_len(ssh_buffer buffer); +LIBSSH_API ssh_buffer buffer_new(void); + +LIBSSH_API ssh_channel channel_accept_x11(ssh_channel channel, int timeout_ms); +LIBSSH_API int channel_change_pty_size(ssh_channel channel,int cols,int rows); +LIBSSH_API ssh_channel channel_forward_accept(ssh_session session, int timeout_ms); +LIBSSH_API int channel_close(ssh_channel channel); +LIBSSH_API int channel_forward_cancel(ssh_session session, const char *address, int port); +LIBSSH_API int channel_forward_listen(ssh_session session, const char *address, int port, int *bound_port); +LIBSSH_API void channel_free(ssh_channel channel); +LIBSSH_API int channel_get_exit_status(ssh_channel channel); +LIBSSH_API ssh_session channel_get_session(ssh_channel channel); +LIBSSH_API int channel_is_closed(ssh_channel channel); +LIBSSH_API int channel_is_eof(ssh_channel channel); +LIBSSH_API int channel_is_open(ssh_channel channel); +LIBSSH_API ssh_channel channel_new(ssh_session session); +LIBSSH_API int channel_open_forward(ssh_channel channel, const char *remotehost, + int remoteport, const char *sourcehost, int localport); +LIBSSH_API int channel_open_session(ssh_channel channel); +LIBSSH_API int channel_poll(ssh_channel channel, int is_stderr); +LIBSSH_API int channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr); + +LIBSSH_API int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count, + int is_stderr); + +LIBSSH_API int channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count, + int is_stderr); +LIBSSH_API int channel_request_env(ssh_channel channel, const char *name, const char *value); +LIBSSH_API int channel_request_exec(ssh_channel channel, const char *cmd); +LIBSSH_API int channel_request_pty(ssh_channel channel); +LIBSSH_API int channel_request_pty_size(ssh_channel channel, const char *term, + int cols, int rows); +LIBSSH_API int channel_request_shell(ssh_channel channel); +LIBSSH_API int channel_request_send_signal(ssh_channel channel, const char *signum); +LIBSSH_API int channel_request_sftp(ssh_channel channel); +LIBSSH_API int channel_request_subsystem(ssh_channel channel, const char *subsystem); +LIBSSH_API int channel_request_x11(ssh_channel channel, int single_connection, const char *protocol, + const char *cookie, int screen_number); +LIBSSH_API int channel_send_eof(ssh_channel channel); +LIBSSH_API int channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct + timeval * timeout); +LIBSSH_API void channel_set_blocking(ssh_channel channel, int blocking); +LIBSSH_API int channel_write(ssh_channel channel, const void *data, uint32_t len); + +LIBSSH_API void privatekey_free(ssh_private_key prv); +LIBSSH_API ssh_private_key privatekey_from_file(ssh_session session, const char *filename, + int type, const char *passphrase); +LIBSSH_API void publickey_free(ssh_public_key key); +LIBSSH_API int ssh_publickey_to_file(ssh_session session, const char *file, + ssh_string pubkey, int type); +LIBSSH_API ssh_string publickey_from_file(ssh_session session, const char *filename, + int *type); +LIBSSH_API ssh_public_key publickey_from_privatekey(ssh_private_key prv); +LIBSSH_API ssh_string publickey_to_string(ssh_public_key key); +LIBSSH_API int ssh_try_publickey_from_file(ssh_session session, const char *keyfile, + ssh_string *publickey, int *type); +LIBSSH_API enum ssh_keytypes_e ssh_privatekey_type(ssh_private_key privatekey); + +LIBSSH_API ssh_string ssh_get_pubkey(ssh_session session); + +LIBSSH_API ssh_message ssh_message_retrieve(ssh_session session, uint32_t packettype); +LIBSSH_API ssh_public_key ssh_message_auth_publickey(ssh_message msg); + +LIBSSH_API void string_burn(ssh_string str); +LIBSSH_API ssh_string string_copy(ssh_string str); +LIBSSH_API void *string_data(ssh_string str); +LIBSSH_API int string_fill(ssh_string str, const void *data, size_t len); +LIBSSH_API void string_free(ssh_string str); +LIBSSH_API ssh_string string_from_char(const char *what); +LIBSSH_API size_t string_len(ssh_string str); +LIBSSH_API ssh_string string_new(size_t size); +LIBSSH_API char *string_to_char(ssh_string str); + +#endif /* LEGACY_H_ */ diff --git a/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/libssh.h b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/libssh.h new file mode 100755 index 0000000..e5339b1 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/libssh.h @@ -0,0 +1,644 @@ +/* + * This file is part of the SSH Library + * + * Copyright (c) 2003-2009 by Aris Adamantiadis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _LIBSSH_H +#define _LIBSSH_H + +#if defined _WIN32 || defined __CYGWIN__ + #ifdef LIBSSH_STATIC + #define LIBSSH_API + #else + #ifdef LIBSSH_EXPORTS + #ifdef __GNUC__ + #define LIBSSH_API __attribute__((dllexport)) + #else + #define LIBSSH_API __declspec(dllexport) + #endif + #else + #ifdef __GNUC__ + #define LIBSSH_API __attribute__((dllimport)) + #else + #define LIBSSH_API __declspec(dllimport) + #endif + #endif + #endif +#else + #if __GNUC__ >= 4 && !defined(__OS2__) + #define LIBSSH_API __attribute__((visibility("default"))) + #else + #define LIBSSH_API + #endif +#endif + +#ifdef _MSC_VER + /* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */ + typedef int int32_t; + typedef unsigned int uint32_t; + typedef unsigned short uint16_t; + typedef unsigned char uint8_t; + typedef unsigned long long uint64_t; + typedef int mode_t; +#else /* _MSC_VER */ + #include <unistd.h> + #include <inttypes.h> +#endif /* _MSC_VER */ + +#ifdef _WIN32 + #include <winsock2.h> +#else /* _WIN32 */ + #include <sys/select.h> /* for fd_set * */ + #include <netdb.h> +#endif /* _WIN32 */ + +#define SSH_STRINGIFY(s) SSH_TOSTRING(s) +#define SSH_TOSTRING(s) #s + +/* libssh version macros */ +#define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c)) +#define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c +#define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c) + +/* libssh version */ +#define LIBSSH_VERSION_MAJOR 0 +#define LIBSSH_VERSION_MINOR 6 +#define LIBSSH_VERSION_MICRO 4 + +#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \ + LIBSSH_VERSION_MINOR, \ + LIBSSH_VERSION_MICRO) +#define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \ + LIBSSH_VERSION_MINOR, \ + LIBSSH_VERSION_MICRO) + +/* GCC have printf type attribute check. */ +#ifdef __GNUC__ +#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b))) +#else +#define PRINTF_ATTRIBUTE(a,b) +#endif /* __GNUC__ */ + +#ifdef __GNUC__ +#define SSH_DEPRECATED __attribute__ ((deprecated)) +#else +#define SSH_DEPRECATED +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct ssh_agent_struct* ssh_agent; +typedef struct ssh_buffer_struct* ssh_buffer; +typedef struct ssh_channel_struct* ssh_channel; +typedef struct ssh_message_struct* ssh_message; +typedef struct ssh_pcap_file_struct* ssh_pcap_file; +typedef struct ssh_key_struct* ssh_key; +typedef struct ssh_scp_struct* ssh_scp; +typedef struct ssh_session_struct* ssh_session; +typedef struct ssh_string_struct* ssh_string; +typedef struct ssh_event_struct* ssh_event; +typedef void* ssh_gssapi_creds; + +/* Socket type */ +#ifdef _WIN32 +#ifndef socket_t +typedef SOCKET socket_t; +#endif /* socket_t */ +#else /* _WIN32 */ +#ifndef socket_t +typedef int socket_t; +#endif +#endif /* _WIN32 */ + +#define SSH_INVALID_SOCKET ((socket_t) -1) + +/* the offsets of methods */ +enum ssh_kex_types_e { + SSH_KEX=0, + SSH_HOSTKEYS, + SSH_CRYPT_C_S, + SSH_CRYPT_S_C, + SSH_MAC_C_S, + SSH_MAC_S_C, + SSH_COMP_C_S, + SSH_COMP_S_C, + SSH_LANG_C_S, + SSH_LANG_S_C +}; + +#define SSH_CRYPT 2 +#define SSH_MAC 3 +#define SSH_COMP 4 +#define SSH_LANG 5 + +enum ssh_auth_e { + SSH_AUTH_SUCCESS=0, + SSH_AUTH_DENIED, + SSH_AUTH_PARTIAL, + SSH_AUTH_INFO, + SSH_AUTH_AGAIN, + SSH_AUTH_ERROR=-1 +}; + +/* auth flags */ +#define SSH_AUTH_METHOD_UNKNOWN 0 +#define SSH_AUTH_METHOD_NONE 0x0001 +#define SSH_AUTH_METHOD_PASSWORD 0x0002 +#define SSH_AUTH_METHOD_PUBLICKEY 0x0004 +#define SSH_AUTH_METHOD_HOSTBASED 0x0008 +#define SSH_AUTH_METHOD_INTERACTIVE 0x0010 +#define SSH_AUTH_METHOD_GSSAPI_MIC 0x0020 + +/* messages */ +enum ssh_requests_e { + SSH_REQUEST_AUTH=1, + SSH_REQUEST_CHANNEL_OPEN, + SSH_REQUEST_CHANNEL, + SSH_REQUEST_SERVICE, + SSH_REQUEST_GLOBAL +}; + +enum ssh_channel_type_e { + SSH_CHANNEL_UNKNOWN=0, + SSH_CHANNEL_SESSION, + SSH_CHANNEL_DIRECT_TCPIP, + SSH_CHANNEL_FORWARDED_TCPIP, + SSH_CHANNEL_X11 +}; + +enum ssh_channel_requests_e { + SSH_CHANNEL_REQUEST_UNKNOWN=0, + SSH_CHANNEL_REQUEST_PTY, + SSH_CHANNEL_REQUEST_EXEC, + SSH_CHANNEL_REQUEST_SHELL, + SSH_CHANNEL_REQUEST_ENV, + SSH_CHANNEL_REQUEST_SUBSYSTEM, + SSH_CHANNEL_REQUEST_WINDOW_CHANGE, + SSH_CHANNEL_REQUEST_X11 +}; + +enum ssh_global_requests_e { + SSH_GLOBAL_REQUEST_UNKNOWN=0, + SSH_GLOBAL_REQUEST_TCPIP_FORWARD, + SSH_GLOBAL_REQUEST_CANCEL_TCPIP_FORWARD, +}; + +enum ssh_publickey_state_e { + SSH_PUBLICKEY_STATE_ERROR=-1, + SSH_PUBLICKEY_STATE_NONE=0, + SSH_PUBLICKEY_STATE_VALID=1, + SSH_PUBLICKEY_STATE_WRONG=2 +}; + +/* Status flags */ +/** Socket is closed */ +#define SSH_CLOSED 0x01 +/** Reading to socket won't block */ +#define SSH_READ_PENDING 0x02 +/** Session was closed due to an error */ +#define SSH_CLOSED_ERROR 0x04 +/** Output buffer not empty */ +#define SSH_WRITE_PENDING 0x08 + +enum ssh_server_known_e { + SSH_SERVER_ERROR=-1, + SSH_SERVER_NOT_KNOWN=0, + SSH_SERVER_KNOWN_OK, + SSH_SERVER_KNOWN_CHANGED, + SSH_SERVER_FOUND_OTHER, + SSH_SERVER_FILE_NOT_FOUND +}; + +#ifndef MD5_DIGEST_LEN + #define MD5_DIGEST_LEN 16 +#endif +/* errors */ + +enum ssh_error_types_e { + SSH_NO_ERROR=0, + SSH_REQUEST_DENIED, + SSH_FATAL, + SSH_EINTR +}; + +/* some types for keys */ +enum ssh_keytypes_e{ + SSH_KEYTYPE_UNKNOWN=0, + SSH_KEYTYPE_DSS=1, + SSH_KEYTYPE_RSA, + SSH_KEYTYPE_RSA1, + SSH_KEYTYPE_ECDSA +}; + +enum ssh_keycmp_e { + SSH_KEY_CMP_PUBLIC = 0, + SSH_KEY_CMP_PRIVATE +}; + +/* Error return codes */ +#define SSH_OK 0 /* No error */ +#define SSH_ERROR -1 /* Error of some kind */ +#define SSH_AGAIN -2 /* The nonblocking call must be repeated */ +#define SSH_EOF -127 /* We have already a eof */ + +/** + * @addtogroup libssh_log + * + * @{ + */ + +enum { + /** No logging at all + */ + SSH_LOG_NOLOG=0, + /** Only warnings + */ + SSH_LOG_WARNING, + /** High level protocol information + */ + SSH_LOG_PROTOCOL, + /** Lower level protocol infomations, packet level + */ + SSH_LOG_PACKET, + /** Every function path + */ + SSH_LOG_FUNCTIONS +}; +/** @} */ +#define SSH_LOG_RARE SSH_LOG_WARNING + +/** + * @name Logging levels + * + * @brief Debug levels for logging. + * @{ + */ + +/** No logging at all */ +#define SSH_LOG_NONE 0 +/** Show only warnings */ +#define SSH_LOG_WARN 1 +/** Get some information what's going on */ +#define SSH_LOG_INFO 2 +/** Get detailed debuging information **/ +#define SSH_LOG_DEBUG 3 +/** Get trace output, packet information, ... */ +#define SSH_LOG_TRACE 4 + +/** @} */ + +enum ssh_options_e { + SSH_OPTIONS_HOST, + SSH_OPTIONS_PORT, + SSH_OPTIONS_PORT_STR, + SSH_OPTIONS_FD, + SSH_OPTIONS_USER, + SSH_OPTIONS_SSH_DIR, + SSH_OPTIONS_IDENTITY, + SSH_OPTIONS_ADD_IDENTITY, + SSH_OPTIONS_KNOWNHOSTS, + SSH_OPTIONS_TIMEOUT, + SSH_OPTIONS_TIMEOUT_USEC, + SSH_OPTIONS_SSH1, + SSH_OPTIONS_SSH2, + SSH_OPTIONS_LOG_VERBOSITY, + SSH_OPTIONS_LOG_VERBOSITY_STR, + SSH_OPTIONS_CIPHERS_C_S, + SSH_OPTIONS_CIPHERS_S_C, + SSH_OPTIONS_COMPRESSION_C_S, + SSH_OPTIONS_COMPRESSION_S_C, + SSH_OPTIONS_PROXYCOMMAND, + SSH_OPTIONS_BINDADDR, + SSH_OPTIONS_STRICTHOSTKEYCHECK, + SSH_OPTIONS_COMPRESSION, + SSH_OPTIONS_COMPRESSION_LEVEL, + SSH_OPTIONS_KEY_EXCHANGE, + SSH_OPTIONS_HOSTKEYS, + SSH_OPTIONS_GSSAPI_SERVER_IDENTITY, + SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY, + SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS, +}; + +enum { + /** Code is going to write/create remote files */ + SSH_SCP_WRITE, + /** Code is going to read remote files */ + SSH_SCP_READ, + SSH_SCP_RECURSIVE=0x10 +}; + +enum ssh_scp_request_types { + /** A new directory is going to be pulled */ + SSH_SCP_REQUEST_NEWDIR=1, + /** A new file is going to be pulled */ + SSH_SCP_REQUEST_NEWFILE, + /** End of requests */ + SSH_SCP_REQUEST_EOF, + /** End of directory */ + SSH_SCP_REQUEST_ENDDIR, + /** Warning received */ + SSH_SCP_REQUEST_WARNING +}; + +LIBSSH_API int ssh_blocking_flush(ssh_session session, int timeout); +LIBSSH_API ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms); +LIBSSH_API int ssh_channel_change_pty_size(ssh_channel channel,int cols,int rows); +LIBSSH_API int ssh_channel_close(ssh_channel channel); +LIBSSH_API void ssh_channel_free(ssh_channel channel); +LIBSSH_API int ssh_channel_get_exit_status(ssh_channel channel); +LIBSSH_API ssh_session ssh_channel_get_session(ssh_channel channel); +LIBSSH_API int ssh_channel_is_closed(ssh_channel channel); +LIBSSH_API int ssh_channel_is_eof(ssh_channel channel); +LIBSSH_API int ssh_channel_is_open(ssh_channel channel); +LIBSSH_API ssh_channel ssh_channel_new(ssh_session session); +LIBSSH_API int ssh_channel_open_auth_agent(ssh_channel channel); +LIBSSH_API int ssh_channel_open_forward(ssh_channel channel, const char *remotehost, + int remoteport, const char *sourcehost, int localport); +LIBSSH_API int ssh_channel_open_session(ssh_channel channel); +LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, const char *orig_addr, int orig_port); +LIBSSH_API int ssh_channel_poll(ssh_channel channel, int is_stderr); +LIBSSH_API int ssh_channel_poll_timeout(ssh_channel channel, int timeout, int is_stderr); +LIBSSH_API int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr); +LIBSSH_API int ssh_channel_read_timeout(ssh_channel channel, void *dest, uint32_t count, int is_stderr, int timeout_ms); +LIBSSH_API int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count, + int is_stderr); +LIBSSH_API int ssh_channel_request_env(ssh_channel channel, const char *name, const char *value); +LIBSSH_API int ssh_channel_request_exec(ssh_channel channel, const char *cmd); +LIBSSH_API int ssh_channel_request_pty(ssh_channel channel); +LIBSSH_API int ssh_channel_request_pty_size(ssh_channel channel, const char *term, + int cols, int rows); +LIBSSH_API int ssh_channel_request_shell(ssh_channel channel); +LIBSSH_API int ssh_channel_request_send_signal(ssh_channel channel, const char *signum); +LIBSSH_API int ssh_channel_request_sftp(ssh_channel channel); +LIBSSH_API int ssh_channel_request_subsystem(ssh_channel channel, const char *subsystem); +LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connection, const char *protocol, + const char *cookie, int screen_number); +LIBSSH_API int ssh_channel_send_eof(ssh_channel channel); +LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct + timeval * timeout); +LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking); +LIBSSH_API int ssh_channel_write(ssh_channel channel, const void *data, uint32_t len); +LIBSSH_API uint32_t ssh_channel_window_size(ssh_channel channel); + +LIBSSH_API char *ssh_basename (const char *path); +LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash); +LIBSSH_API int ssh_connect(ssh_session session); +LIBSSH_API const char *ssh_copyright(void); +LIBSSH_API void ssh_disconnect(ssh_session session); +LIBSSH_API char *ssh_dirname (const char *path); +LIBSSH_API int ssh_finalize(void); +LIBSSH_API ssh_channel ssh_forward_accept(ssh_session session, int timeout_ms); +LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session, int timeout_ms, int *destination_port); +LIBSSH_API int ssh_forward_cancel(ssh_session session, const char *address, int port); +LIBSSH_API int ssh_forward_listen(ssh_session session, const char *address, int port, int *bound_port); +LIBSSH_API void ssh_free(ssh_session session); +LIBSSH_API const char *ssh_get_disconnect_message(ssh_session session); +LIBSSH_API const char *ssh_get_error(void *error); +LIBSSH_API int ssh_get_error_code(void *error); +LIBSSH_API socket_t ssh_get_fd(ssh_session session); +LIBSSH_API char *ssh_get_hexa(const unsigned char *what, size_t len); +LIBSSH_API char *ssh_get_issue_banner(ssh_session session); +LIBSSH_API int ssh_get_openssh_version(ssh_session session); + +LIBSSH_API int ssh_get_publickey(ssh_session session, ssh_key *key); + +enum ssh_publickey_hash_type { + SSH_PUBLICKEY_HASH_SHA1, + SSH_PUBLICKEY_HASH_MD5 +}; +LIBSSH_API int ssh_get_publickey_hash(const ssh_key key, + enum ssh_publickey_hash_type type, + unsigned char **hash, + size_t *hlen); + +SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash); + +LIBSSH_API int ssh_get_random(void *where,int len,int strong); +LIBSSH_API int ssh_get_version(ssh_session session); +LIBSSH_API int ssh_get_status(ssh_session session); +LIBSSH_API int ssh_get_poll_flags(ssh_session session); +LIBSSH_API int ssh_init(void); +LIBSSH_API int ssh_is_blocking(ssh_session session); +LIBSSH_API int ssh_is_connected(ssh_session session); +LIBSSH_API int ssh_is_server_known(ssh_session session); + +/* LOGGING */ +LIBSSH_API int ssh_set_log_level(int level); +LIBSSH_API int ssh_get_log_level(void); +LIBSSH_API void *ssh_get_log_userdata(void); +LIBSSH_API int ssh_set_log_userdata(void *data); +LIBSSH_API void _ssh_log(int verbosity, + const char *function, + const char *format, ...) PRINTF_ATTRIBUTE(3, 4); + +/* legacy */ +SSH_DEPRECATED LIBSSH_API void ssh_log(ssh_session session, + int prioriry, + const char *format, ...) PRINTF_ATTRIBUTE(3, 4); + +LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg); +LIBSSH_API int ssh_message_channel_request_reply_success(ssh_message msg); +LIBSSH_API void ssh_message_free(ssh_message msg); +LIBSSH_API ssh_message ssh_message_get(ssh_session session); +LIBSSH_API int ssh_message_subtype(ssh_message msg); +LIBSSH_API int ssh_message_type(ssh_message msg); +LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode); +LIBSSH_API ssh_session ssh_new(void); + +LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest); +LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char **argv); +LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename); +LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type, + const void *value); +LIBSSH_API int ssh_options_get(ssh_session session, enum ssh_options_e type, + char **value); +LIBSSH_API int ssh_options_get_port(ssh_session session, unsigned int * port_target); +LIBSSH_API int ssh_pcap_file_close(ssh_pcap_file pcap); +LIBSSH_API void ssh_pcap_file_free(ssh_pcap_file pcap); +LIBSSH_API ssh_pcap_file ssh_pcap_file_new(void); +LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename); + +/** + * @brief SSH authentication callback. + * + * @param prompt Prompt to be displayed. + * @param buf Buffer to save the password. You should null-terminate it. + * @param len Length of the buffer. + * @param echo Enable or disable the echo of what you type. + * @param verify Should the password be verified? + * @param userdata Userdata to be passed to the callback function. Useful + * for GUI applications. + * + * @return 0 on success, < 0 on error. + */ +typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len, + int echo, int verify, void *userdata); + +LIBSSH_API ssh_key ssh_key_new(void); +LIBSSH_API void ssh_key_free (ssh_key key); +LIBSSH_API enum ssh_keytypes_e ssh_key_type(const ssh_key key); +LIBSSH_API const char *ssh_key_type_to_char(enum ssh_keytypes_e type); +LIBSSH_API enum ssh_keytypes_e ssh_key_type_from_name(const char *name); +LIBSSH_API int ssh_key_is_public(const ssh_key k); +LIBSSH_API int ssh_key_is_private(const ssh_key k); +LIBSSH_API int ssh_key_cmp(const ssh_key k1, + const ssh_key k2, + enum ssh_keycmp_e what); + +LIBSSH_API int ssh_pki_generate(enum ssh_keytypes_e type, int parameter, + ssh_key *pkey); +LIBSSH_API int ssh_pki_import_privkey_base64(const char *b64_key, + const char *passphrase, + ssh_auth_callback auth_fn, + void *auth_data, + ssh_key *pkey); +LIBSSH_API int ssh_pki_import_privkey_file(const char *filename, + const char *passphrase, + ssh_auth_callback auth_fn, + void *auth_data, + ssh_key *pkey); +LIBSSH_API int ssh_pki_export_privkey_file(const ssh_key privkey, + const char *passphrase, + ssh_auth_callback auth_fn, + void *auth_data, + const char *filename); + +LIBSSH_API int ssh_pki_import_pubkey_base64(const char *b64_key, + enum ssh_keytypes_e type, + ssh_key *pkey); +LIBSSH_API int ssh_pki_import_pubkey_file(const char *filename, + ssh_key *pkey); + +LIBSSH_API int ssh_pki_export_privkey_to_pubkey(const ssh_key privkey, + ssh_key *pkey); +LIBSSH_API int ssh_pki_export_pubkey_base64(const ssh_key key, + char **b64_key); +LIBSSH_API int ssh_pki_export_pubkey_file(const ssh_key key, + const char *filename); + +LIBSSH_API const char *ssh_pki_key_ecdsa_name(const ssh_key key); + +LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len); +LIBSSH_API int ssh_send_ignore (ssh_session session, const char *data); +LIBSSH_API int ssh_send_debug (ssh_session session, const char *message, int always_display); +LIBSSH_API void ssh_gssapi_set_creds(ssh_session session, const ssh_gssapi_creds creds); +LIBSSH_API int ssh_scp_accept_request(ssh_scp scp); +LIBSSH_API int ssh_scp_close(ssh_scp scp); +LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason); +LIBSSH_API void ssh_scp_free(ssh_scp scp); +LIBSSH_API int ssh_scp_init(ssh_scp scp); +LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp); +LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location); +LIBSSH_API int ssh_scp_pull_request(ssh_scp scp); +LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode); +LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms); +LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms); +LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size); +LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp); +LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp); +LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp); +LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp); +LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp); +LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len); +LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd, + fd_set *readfds, struct timeval *timeout); +LIBSSH_API int ssh_service_request(ssh_session session, const char *service); +LIBSSH_API int ssh_set_agent_channel(ssh_session session, ssh_channel channel); +LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking); +LIBSSH_API void ssh_set_fd_except(ssh_session session); +LIBSSH_API void ssh_set_fd_toread(ssh_session session); +LIBSSH_API void ssh_set_fd_towrite(ssh_session session); +LIBSSH_API void ssh_silent_disconnect(ssh_session session); +LIBSSH_API int ssh_set_pcap_file(ssh_session session, ssh_pcap_file pcapfile); + +/* USERAUTH */ +LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username); +LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username); +LIBSSH_API int ssh_userauth_try_publickey(ssh_session session, + const char *username, + const ssh_key pubkey); +LIBSSH_API int ssh_userauth_publickey(ssh_session session, + const char *username, + const ssh_key privkey); +#ifndef _WIN32 +LIBSSH_API int ssh_userauth_agent(ssh_session session, + const char *username); +#endif +LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session, + const char *username, + const char *passphrase); +LIBSSH_API int ssh_userauth_password(ssh_session session, + const char *username, + const char *password); + +LIBSSH_API int ssh_userauth_kbdint(ssh_session session, const char *user, const char *submethods); +LIBSSH_API const char *ssh_userauth_kbdint_getinstruction(ssh_session session); +LIBSSH_API const char *ssh_userauth_kbdint_getname(ssh_session session); +LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session); +LIBSSH_API const char *ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i, char *echo); +LIBSSH_API int ssh_userauth_kbdint_getnanswers(ssh_session session); +LIBSSH_API const char *ssh_userauth_kbdint_getanswer(ssh_session session, unsigned int i); +LIBSSH_API int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i, + const char *answer); +LIBSSH_API int ssh_userauth_gssapi(ssh_session session); +LIBSSH_API const char *ssh_version(int req_version); +LIBSSH_API int ssh_write_knownhost(ssh_session session); + +LIBSSH_API void ssh_string_burn(ssh_string str); +LIBSSH_API ssh_string ssh_string_copy(ssh_string str); +LIBSSH_API void *ssh_string_data(ssh_string str); +LIBSSH_API int ssh_string_fill(ssh_string str, const void *data, size_t len); +LIBSSH_API void ssh_string_free(ssh_string str); +LIBSSH_API ssh_string ssh_string_from_char(const char *what); +LIBSSH_API size_t ssh_string_len(ssh_string str); +LIBSSH_API ssh_string ssh_string_new(size_t size); +LIBSSH_API const char *ssh_string_get_char(ssh_string str); +LIBSSH_API char *ssh_string_to_char(ssh_string str); +LIBSSH_API void ssh_string_free_char(char *s); + +LIBSSH_API int ssh_getpass(const char *prompt, char *buf, size_t len, int echo, + int verify); + + +typedef int (*ssh_event_callback)(socket_t fd, int revents, void *userdata); + +LIBSSH_API ssh_event ssh_event_new(void); +LIBSSH_API int ssh_event_add_fd(ssh_event event, socket_t fd, short events, + ssh_event_callback cb, void *userdata); +LIBSSH_API int ssh_event_add_session(ssh_event event, ssh_session session); +LIBSSH_API int ssh_event_dopoll(ssh_event event, int timeout); +LIBSSH_API int ssh_event_remove_fd(ssh_event event, socket_t fd); +LIBSSH_API int ssh_event_remove_session(ssh_event event, ssh_session session); +LIBSSH_API void ssh_event_free(ssh_event event); +LIBSSH_API const char* ssh_get_clientbanner(ssh_session session); +LIBSSH_API const char* ssh_get_serverbanner(ssh_session session); +LIBSSH_API const char* ssh_get_cipher_in(ssh_session session); +LIBSSH_API const char* ssh_get_cipher_out(ssh_session session); + +#ifndef LIBSSH_LEGACY_0_4 +#include "libssh/legacy.h" +#endif + +#ifdef __cplusplus +} +#endif +#endif /* _LIBSSH_H */ +/* vim: set ts=2 sw=2 et cindent: */ diff --git a/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/server.h b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/server.h new file mode 100755 index 0000000..385a10a --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/server.h @@ -0,0 +1,336 @@ +/* Public include file for server support */ +/* + * This file is part of the SSH Library + * + * Copyright (c) 2003-2008 by Aris Adamantiadis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @defgroup libssh_server The libssh server API + * + * @{ + */ + +#ifndef SERVER_H +#define SERVER_H + +#include "libssh/libssh.h" +#define SERVERBANNER CLIENTBANNER + +#ifdef __cplusplus +extern "C" { +#endif + +enum ssh_bind_options_e { + SSH_BIND_OPTIONS_BINDADDR, + SSH_BIND_OPTIONS_BINDPORT, + SSH_BIND_OPTIONS_BINDPORT_STR, + SSH_BIND_OPTIONS_HOSTKEY, + SSH_BIND_OPTIONS_DSAKEY, + SSH_BIND_OPTIONS_RSAKEY, + SSH_BIND_OPTIONS_BANNER, + SSH_BIND_OPTIONS_LOG_VERBOSITY, + SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, + SSH_BIND_OPTIONS_ECDSAKEY +}; + +typedef struct ssh_bind_struct* ssh_bind; + +/* Callback functions */ + +/** + * @brief Incoming connection callback. This callback is called when a ssh_bind + * has a new incoming connection. + * @param sshbind Current sshbind session handler + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_bind_incoming_connection_callback) (ssh_bind sshbind, + void *userdata); + +/** + * @brief These are the callbacks exported by the ssh_bind structure. + * + * They are called by the server module when events appear on the network. + */ +struct ssh_bind_callbacks_struct { + /** DON'T SET THIS use ssh_callbacks_init() instead. */ + size_t size; + /** A new connection is available. */ + ssh_bind_incoming_connection_callback incoming_connection; +}; +typedef struct ssh_bind_callbacks_struct *ssh_bind_callbacks; + +/** + * @brief Creates a new SSH server bind. + * + * @return A newly allocated ssh_bind session pointer. + */ +LIBSSH_API ssh_bind ssh_bind_new(void); + +LIBSSH_API int ssh_bind_options_set(ssh_bind sshbind, + enum ssh_bind_options_e type, const void *value); + +/** + * @brief Start listening to the socket. + * + * @param ssh_bind_o The ssh server bind to use. + * + * @return 0 on success, < 0 on error. + */ +LIBSSH_API int ssh_bind_listen(ssh_bind ssh_bind_o); + +/** + * @brief Set the callback for this bind. + * + * @param[in] sshbind The bind to set the callback on. + * + * @param[in] callbacks An already set up ssh_bind_callbacks instance. + * + * @param[in] userdata A pointer to private data to pass to the callbacks. + * + * @return SSH_OK on success, SSH_ERROR if an error occured. + * + * @code + * struct ssh_callbacks_struct cb = { + * .userdata = data, + * .auth_function = my_auth_function + * }; + * ssh_callbacks_init(&cb); + * ssh_bind_set_callbacks(session, &cb); + * @endcode + */ +LIBSSH_API int ssh_bind_set_callbacks(ssh_bind sshbind, ssh_bind_callbacks callbacks, + void *userdata); + +/** + * @brief Set the session to blocking/nonblocking mode. + * + * @param ssh_bind_o The ssh server bind to use. + * + * @param blocking Zero for nonblocking mode. + */ +LIBSSH_API void ssh_bind_set_blocking(ssh_bind ssh_bind_o, int blocking); + +/** + * @brief Recover the file descriptor from the session. + * + * @param ssh_bind_o The ssh server bind to get the fd from. + * + * @return The file descriptor. + */ +LIBSSH_API socket_t ssh_bind_get_fd(ssh_bind ssh_bind_o); + +/** + * @brief Set the file descriptor for a session. + * + * @param ssh_bind_o The ssh server bind to set the fd. + * + * @param fd The file descriptssh_bind B + */ +LIBSSH_API void ssh_bind_set_fd(ssh_bind ssh_bind_o, socket_t fd); + +/** + * @brief Allow the file descriptor to accept new sessions. + * + * @param ssh_bind_o The ssh server bind to use. + */ +LIBSSH_API void ssh_bind_fd_toaccept(ssh_bind ssh_bind_o); + +/** + * @brief Accept an incoming ssh connection and initialize the session. + * + * @param ssh_bind_o The ssh server bind to accept a connection. + * @param session A preallocated ssh session + * @see ssh_new + * @return SSH_OK when a connection is established + */ +LIBSSH_API int ssh_bind_accept(ssh_bind ssh_bind_o, ssh_session session); + +/** + * @brief Accept an incoming ssh connection on the given file descriptor + * and initialize the session. + * + * @param ssh_bind_o The ssh server bind to accept a connection. + * @param session A preallocated ssh session + * @param fd A file descriptor of an already established TCP + * inbound connection + * @see ssh_new + * @see ssh_bind_accept + * @return SSH_OK when a connection is established + */ +LIBSSH_API int ssh_bind_accept_fd(ssh_bind ssh_bind_o, ssh_session session, + socket_t fd); + +LIBSSH_API ssh_gssapi_creds ssh_gssapi_get_creds(ssh_session session); + +/** + * @brief Handles the key exchange and set up encryption + * + * @param session A connected ssh session + * @see ssh_bind_accept + * @return SSH_OK if the key exchange was successful + */ +LIBSSH_API int ssh_handle_key_exchange(ssh_session session); + +/** + * @brief Free a ssh servers bind. + * + * @param ssh_bind_o The ssh server bind to free. + */ +LIBSSH_API void ssh_bind_free(ssh_bind ssh_bind_o); + +LIBSSH_API void ssh_set_auth_methods(ssh_session session, int auth_methods); + +/********************************************************** + * SERVER MESSAGING + **********************************************************/ + +/** + * @brief Reply with a standard reject message. + * + * Use this function if you don't know what to respond or if you want to reject + * a request. + * + * @param[in] msg The message to use for the reply. + * + * @return 0 on success, -1 on error. + * + * @see ssh_message_get() + */ +LIBSSH_API int ssh_message_reply_default(ssh_message msg); + +/** + * @brief Get the name of the authenticated user. + * + * @param[in] msg The message to get the username from. + * + * @return The username or NULL if an error occured. + * + * @see ssh_message_get() + * @see ssh_message_type() + */ +LIBSSH_API const char *ssh_message_auth_user(ssh_message msg); + +/** + * @brief Get the password of the authenticated user. + * + * @param[in] msg The message to get the password from. + * + * @return The username or NULL if an error occured. + * + * @see ssh_message_get() + * @see ssh_message_type() + */ +LIBSSH_API const char *ssh_message_auth_password(ssh_message msg); + +/** + * @brief Get the publickey of the authenticated user. + * + * If you need the key for later user you should duplicate it. + * + * @param[in] msg The message to get the public key from. + * + * @return The public key or NULL. + * + * @see ssh_key_dup() + * @see ssh_key_cmp() + * @see ssh_message_get() + * @see ssh_message_type() + */ +LIBSSH_API ssh_key ssh_message_auth_pubkey(ssh_message msg); + +LIBSSH_API int ssh_message_auth_kbdint_is_response(ssh_message msg); +LIBSSH_API enum ssh_publickey_state_e ssh_message_auth_publickey_state(ssh_message msg); +LIBSSH_API int ssh_message_auth_reply_success(ssh_message msg,int partial); +LIBSSH_API int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey); +LIBSSH_API int ssh_message_auth_reply_pk_ok_simple(ssh_message msg); + +LIBSSH_API int ssh_message_auth_set_methods(ssh_message msg, int methods); + +LIBSSH_API int ssh_message_auth_interactive_request(ssh_message msg, + const char *name, const char *instruction, + unsigned int num_prompts, const char **prompts, char *echo); + +LIBSSH_API int ssh_message_service_reply_success(ssh_message msg); +LIBSSH_API const char *ssh_message_service_service(ssh_message msg); + +LIBSSH_API int ssh_message_global_request_reply_success(ssh_message msg, + uint16_t bound_port); + +LIBSSH_API void ssh_set_message_callback(ssh_session session, + int(*ssh_bind_message_callback)(ssh_session session, ssh_message msg, void *data), + void *data); +LIBSSH_API int ssh_execute_message_callbacks(ssh_session session); + +LIBSSH_API const char *ssh_message_channel_request_open_originator(ssh_message msg); +LIBSSH_API int ssh_message_channel_request_open_originator_port(ssh_message msg); +LIBSSH_API const char *ssh_message_channel_request_open_destination(ssh_message msg); +LIBSSH_API int ssh_message_channel_request_open_destination_port(ssh_message msg); + +LIBSSH_API ssh_channel ssh_message_channel_request_channel(ssh_message msg); + +LIBSSH_API const char *ssh_message_channel_request_pty_term(ssh_message msg); +LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg); +LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg); +LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg); +LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg); + +LIBSSH_API const char *ssh_message_channel_request_env_name(ssh_message msg); +LIBSSH_API const char *ssh_message_channel_request_env_value(ssh_message msg); + +LIBSSH_API const char *ssh_message_channel_request_command(ssh_message msg); + +LIBSSH_API const char *ssh_message_channel_request_subsystem(ssh_message msg); + +LIBSSH_API int ssh_message_channel_request_x11_single_connection(ssh_message msg); +LIBSSH_API const char *ssh_message_channel_request_x11_auth_protocol(ssh_message msg); +LIBSSH_API const char *ssh_message_channel_request_x11_auth_cookie(ssh_message msg); +LIBSSH_API int ssh_message_channel_request_x11_screen_number(ssh_message msg); + +LIBSSH_API const char *ssh_message_global_request_address(ssh_message msg); +LIBSSH_API int ssh_message_global_request_port(ssh_message msg); + +LIBSSH_API int ssh_channel_open_reverse_forward(ssh_channel channel, const char *remotehost, + int remoteport, const char *sourcehost, int localport); +LIBSSH_API int ssh_channel_open_x11(ssh_channel channel, + const char *orig_addr, int orig_port); + +LIBSSH_API int ssh_channel_request_send_exit_status(ssh_channel channel, + int exit_status); +LIBSSH_API int ssh_channel_request_send_exit_signal(ssh_channel channel, + const char *signum, + int core, + const char *errmsg, + const char *lang); +LIBSSH_API int ssh_channel_write_stderr(ssh_channel channel, + const void *data, + uint32_t len); + +LIBSSH_API int ssh_send_keepalive(ssh_session session); + +/* deprecated functions */ +SSH_DEPRECATED LIBSSH_API int ssh_accept(ssh_session session); +SSH_DEPRECATED LIBSSH_API int channel_write_stderr(ssh_channel channel, + const void *data, uint32_t len); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SERVER_H */ + +/** @} */ diff --git a/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/sftp.h b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/sftp.h new file mode 100755 index 0000000..d370f0e --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/sftp.h @@ -0,0 +1,1000 @@ +/* + * This file is part of the SSH Library + * + * Copyright (c) 2003-2008 by Aris Adamantiadis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @defgroup libssh_sftp The libssh SFTP API + * + * @brief SFTP handling functions + * + * SFTP commands are channeled by the ssh sftp subsystem. Every packet is + * sent/read using a sftp_packet type structure. Related to these packets, + * most of the server answers are messages having an ID and a message + * specific part. It is described by sftp_message when reading a message, + * the sftp system puts it into the queue, so the process having asked for + * it can fetch it, while continuing to read for other messages (it is + * unspecified in which order messages may be sent back to the client + * + * @{ + */ + +#ifndef SFTP_H +#define SFTP_H + +#include <sys/types.h> + +#include "libssh.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WIN32 +#ifndef uid_t + typedef uint32_t uid_t; +#endif /* uid_t */ +#ifndef gid_t + typedef uint32_t gid_t; +#endif /* gid_t */ +#ifdef _MSC_VER +#ifndef ssize_t + typedef _W64 SSIZE_T ssize_t; +#endif /* ssize_t */ +#endif /* _MSC_VER */ +#endif /* _WIN32 */ + +#define LIBSFTP_VERSION 3 + +typedef struct sftp_attributes_struct* sftp_attributes; +typedef struct sftp_client_message_struct* sftp_client_message; +typedef struct sftp_dir_struct* sftp_dir; +typedef struct sftp_ext_struct *sftp_ext; +typedef struct sftp_file_struct* sftp_file; +typedef struct sftp_message_struct* sftp_message; +typedef struct sftp_packet_struct* sftp_packet; +typedef struct sftp_request_queue_struct* sftp_request_queue; +typedef struct sftp_session_struct* sftp_session; +typedef struct sftp_status_message_struct* sftp_status_message; +typedef struct sftp_statvfs_struct* sftp_statvfs_t; + +struct sftp_session_struct { + ssh_session session; + ssh_channel channel; + int server_version; + int client_version; + int version; + sftp_request_queue queue; + uint32_t id_counter; + int errnum; + void **handles; + sftp_ext ext; +}; + +struct sftp_packet_struct { + sftp_session sftp; + uint8_t type; + ssh_buffer payload; +}; + +/* file handler */ +struct sftp_file_struct { + sftp_session sftp; + char *name; + uint64_t offset; + ssh_string handle; + int eof; + int nonblocking; +}; + +struct sftp_dir_struct { + sftp_session sftp; + char *name; + ssh_string handle; /* handle to directory */ + ssh_buffer buffer; /* contains raw attributes from server which haven't been parsed */ + uint32_t count; /* counts the number of following attributes structures into buffer */ + int eof; /* end of directory listing */ +}; + +struct sftp_message_struct { + sftp_session sftp; + uint8_t packet_type; + ssh_buffer payload; + uint32_t id; +}; + +/* this is a bunch of all data that could be into a message */ +struct sftp_client_message_struct { + sftp_session sftp; + uint8_t type; + uint32_t id; + char *filename; /* can be "path" */ + uint32_t flags; + sftp_attributes attr; + ssh_string handle; + uint64_t offset; + uint32_t len; + int attr_num; + ssh_buffer attrbuf; /* used by sftp_reply_attrs */ + ssh_string data; /* can be newpath of rename() */ + ssh_buffer complete_message; /* complete message in case of retransmission*/ + char *str_data; /* cstring version of data */ +}; + +struct sftp_request_queue_struct { + sftp_request_queue next; + sftp_message message; +}; + +/* SSH_FXP_MESSAGE described into .7 page 26 */ +struct sftp_status_message_struct { + uint32_t id; + uint32_t status; + ssh_string error; + ssh_string lang; + char *errormsg; + char *langmsg; +}; + +struct sftp_attributes_struct { + char *name; + char *longname; /* ls -l output on openssh, not reliable else */ + uint32_t flags; + uint8_t type; + uint64_t size; + uint32_t uid; + uint32_t gid; + char *owner; /* set if openssh and version 4 */ + char *group; /* set if openssh and version 4 */ + uint32_t permissions; + uint64_t atime64; + uint32_t atime; + uint32_t atime_nseconds; + uint64_t createtime; + uint32_t createtime_nseconds; + uint64_t mtime64; + uint32_t mtime; + uint32_t mtime_nseconds; + ssh_string acl; + uint32_t extended_count; + ssh_string extended_type; + ssh_string extended_data; +}; + +/** + * @brief SFTP statvfs structure. + */ +struct sftp_statvfs_struct { + uint64_t f_bsize; /** file system block size */ + uint64_t f_frsize; /** fundamental fs block size */ + uint64_t f_blocks; /** number of blocks (unit f_frsize) */ + uint64_t f_bfree; /** free blocks in file system */ + uint64_t f_bavail; /** free blocks for non-root */ + uint64_t f_files; /** total file inodes */ + uint64_t f_ffree; /** free file inodes */ + uint64_t f_favail; /** free file inodes for to non-root */ + uint64_t f_fsid; /** file system id */ + uint64_t f_flag; /** bit mask of f_flag values */ + uint64_t f_namemax; /** maximum filename length */ +}; + +/** + * @brief Start a new sftp session. + * + * @param session The ssh session to use. + * + * @return A new sftp session or NULL on error. + * + * @see sftp_free() + */ +LIBSSH_API sftp_session sftp_new(ssh_session session); + +/** + * @brief Start a new sftp session with an existing channel. + * + * @param session The ssh session to use. + * @param channel An open session channel with subsystem already allocated + * + * @return A new sftp session or NULL on error. + * + * @see sftp_free() + */ +LIBSSH_API sftp_session sftp_new_channel(ssh_session session, ssh_channel channel); + + +/** + * @brief Close and deallocate a sftp session. + * + * @param sftp The sftp session handle to free. + */ +LIBSSH_API void sftp_free(sftp_session sftp); + +/** + * @brief Initialize the sftp session with the server. + * + * @param sftp The sftp session to initialize. + * + * @return 0 on success, < 0 on error with ssh error set. + * + * @see sftp_new() + */ +LIBSSH_API int sftp_init(sftp_session sftp); + +/** + * @brief Get the last sftp error. + * + * Use this function to get the latest error set by a posix like sftp function. + * + * @param sftp The sftp session where the error is saved. + * + * @return The saved error (see server responses), < 0 if an error + * in the function occured. + * + * @see Server responses + */ +LIBSSH_API int sftp_get_error(sftp_session sftp); + +/** + * @brief Get the count of extensions provided by the server. + * + * @param sftp The sftp session to use. + * + * @return The count of extensions provided by the server, 0 on error or + * not available. + */ +LIBSSH_API unsigned int sftp_extensions_get_count(sftp_session sftp); + +/** + * @brief Get the name of the extension provided by the server. + * + * @param sftp The sftp session to use. + * + * @param indexn The index number of the extension name you want. + * + * @return The name of the extension. + */ +LIBSSH_API const char *sftp_extensions_get_name(sftp_session sftp, unsigned int indexn); + +/** + * @brief Get the data of the extension provided by the server. + * + * This is normally the version number of the extension. + * + * @param sftp The sftp session to use. + * + * @param indexn The index number of the extension data you want. + * + * @return The data of the extension. + */ +LIBSSH_API const char *sftp_extensions_get_data(sftp_session sftp, unsigned int indexn); + +/** + * @brief Check if the given extension is supported. + * + * @param sftp The sftp session to use. + * + * @param name The name of the extension. + * + * @param data The data of the extension. + * + * @return 1 if supported, 0 if not. + * + * Example: + * + * @code + * sftp_extension_supported(sftp, "statvfs@openssh.com", "2"); + * @endcode + */ +LIBSSH_API int sftp_extension_supported(sftp_session sftp, const char *name, + const char *data); + +/** + * @brief Open a directory used to obtain directory entries. + * + * @param session The sftp session handle to open the directory. + * @param path The path of the directory to open. + * + * @return A sftp directory handle or NULL on error with ssh and + * sftp error set. + * + * @see sftp_readdir + * @see sftp_closedir + */ +LIBSSH_API sftp_dir sftp_opendir(sftp_session session, const char *path); + +/** + * @brief Get a single file attributes structure of a directory. + * + * @param session The sftp session handle to read the directory entry. + * @param dir The opened sftp directory handle to read from. + * + * @return A file attribute structure or NULL at the end of the + * directory. + * + * @see sftp_opendir() + * @see sftp_attribute_free() + * @see sftp_closedir() + */ +LIBSSH_API sftp_attributes sftp_readdir(sftp_session session, sftp_dir dir); + +/** + * @brief Tell if the directory has reached EOF (End Of File). + * + * @param dir The sftp directory handle. + * + * @return 1 if the directory is EOF, 0 if not. + * + * @see sftp_readdir() + */ +LIBSSH_API int sftp_dir_eof(sftp_dir dir); + +/** + * @brief Get information about a file or directory. + * + * @param session The sftp session handle. + * @param path The path to the file or directory to obtain the + * information. + * + * @return The sftp attributes structure of the file or directory, + * NULL on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API sftp_attributes sftp_stat(sftp_session session, const char *path); + +/** + * @brief Get information about a file or directory. + * + * Identical to sftp_stat, but if the file or directory is a symbolic link, + * then the link itself is stated, not the file that it refers to. + * + * @param session The sftp session handle. + * @param path The path to the file or directory to obtain the + * information. + * + * @return The sftp attributes structure of the file or directory, + * NULL on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API sftp_attributes sftp_lstat(sftp_session session, const char *path); + +/** + * @brief Get information about a file or directory from a file handle. + * + * @param file The sftp file handle to get the stat information. + * + * @return The sftp attributes structure of the file or directory, + * NULL on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API sftp_attributes sftp_fstat(sftp_file file); + +/** + * @brief Free a sftp attribute structure. + * + * @param file The sftp attribute structure to free. + */ +LIBSSH_API void sftp_attributes_free(sftp_attributes file); + +/** + * @brief Close a directory handle opened by sftp_opendir(). + * + * @param dir The sftp directory handle to close. + * + * @return Returns SSH_NO_ERROR or SSH_ERROR if an error occured. + */ +LIBSSH_API int sftp_closedir(sftp_dir dir); + +/** + * @brief Close an open file handle. + * + * @param file The open sftp file handle to close. + * + * @return Returns SSH_NO_ERROR or SSH_ERROR if an error occured. + * + * @see sftp_open() + */ +LIBSSH_API int sftp_close(sftp_file file); + +/** + * @brief Open a file on the server. + * + * @param session The sftp session handle. + * + * @param file The file to be opened. + * + * @param accesstype Is one of O_RDONLY, O_WRONLY or O_RDWR which request + * opening the file read-only,write-only or read/write. + * Acesss may also be bitwise-or'd with one or more of + * the following: + * O_CREAT - If the file does not exist it will be + * created. + * O_EXCL - When used with O_CREAT, if the file already + * exists it is an error and the open will fail. + * O_TRUNC - If the file already exists it will be + * truncated. + * + * @param mode Mode specifies the permissions to use if a new file is + * created. It is modified by the process's umask in + * the usual way: The permissions of the created file are + * (mode & ~umask) + * + * @return A sftp file handle, NULL on error with ssh and sftp + * error set. + * + * @see sftp_get_error() + */ +LIBSSH_API sftp_file sftp_open(sftp_session session, const char *file, int accesstype, + mode_t mode); + +/** + * @brief Make the sftp communication for this file handle non blocking. + * + * @param[in] handle The file handle to set non blocking. + */ +LIBSSH_API void sftp_file_set_nonblocking(sftp_file handle); + +/** + * @brief Make the sftp communication for this file handle blocking. + * + * @param[in] handle The file handle to set blocking. + */ +LIBSSH_API void sftp_file_set_blocking(sftp_file handle); + +/** + * @brief Read from a file using an opened sftp file handle. + * + * @param file The opened sftp file handle to be read from. + * + * @param buf Pointer to buffer to recieve read data. + * + * @param count Size of the buffer in bytes. + * + * @return Number of bytes written, < 0 on error with ssh and sftp + * error set. + * + * @see sftp_get_error() + */ +LIBSSH_API ssize_t sftp_read(sftp_file file, void *buf, size_t count); + +/** + * @brief Start an asynchronous read from a file using an opened sftp file handle. + * + * Its goal is to avoid the slowdowns related to the request/response pattern + * of a synchronous read. To do so, you must call 2 functions: + * + * sftp_async_read_begin() and sftp_async_read(). + * + * The first step is to call sftp_async_read_begin(). This function returns a + * request identifier. The second step is to call sftp_async_read() using the + * returned identifier. + * + * @param file The opened sftp file handle to be read from. + * + * @param len Size to read in bytes. + * + * @return An identifier corresponding to the sent request, < 0 on + * error. + * + * @warning When calling this function, the internal offset is + * updated corresponding to the len parameter. + * + * @warning A call to sftp_async_read_begin() sends a request to + * the server. When the server answers, libssh allocates + * memory to store it until sftp_async_read() is called. + * Not calling sftp_async_read() will lead to memory + * leaks. + * + * @see sftp_async_read() + * @see sftp_open() + */ +LIBSSH_API int sftp_async_read_begin(sftp_file file, uint32_t len); + +/** + * @brief Wait for an asynchronous read to complete and save the data. + * + * @param file The opened sftp file handle to be read from. + * + * @param data Pointer to buffer to recieve read data. + * + * @param len Size of the buffer in bytes. It should be bigger or + * equal to the length parameter of the + * sftp_async_read_begin() call. + * + * @param id The identifier returned by the sftp_async_read_begin() + * function. + * + * @return Number of bytes read, 0 on EOF, SSH_ERROR if an error + * occured, SSH_AGAIN if the file is opened in nonblocking + * mode and the request hasn't been executed yet. + * + * @warning A call to this function with an invalid identifier + * will never return. + * + * @see sftp_async_read_begin() + */ +LIBSSH_API int sftp_async_read(sftp_file file, void *data, uint32_t len, uint32_t id); + +/** + * @brief Write to a file using an opened sftp file handle. + * + * @param file Open sftp file handle to write to. + * + * @param buf Pointer to buffer to write data. + * + * @param count Size of buffer in bytes. + * + * @return Number of bytes written, < 0 on error with ssh and sftp + * error set. + * + * @see sftp_open() + * @see sftp_read() + * @see sftp_close() + */ +LIBSSH_API ssize_t sftp_write(sftp_file file, const void *buf, size_t count); + +/** + * @brief Seek to a specific location in a file. + * + * @param file Open sftp file handle to seek in. + * + * @param new_offset Offset in bytes to seek. + * + * @return 0 on success, < 0 on error. + */ +LIBSSH_API int sftp_seek(sftp_file file, uint32_t new_offset); + +/** + * @brief Seek to a specific location in a file. This is the + * 64bit version. + * + * @param file Open sftp file handle to seek in. + * + * @param new_offset Offset in bytes to seek. + * + * @return 0 on success, < 0 on error. + */ +LIBSSH_API int sftp_seek64(sftp_file file, uint64_t new_offset); + +/** + * @brief Report current byte position in file. + * + * @param file Open sftp file handle. + * + * @return The offset of the current byte relative to the beginning + * of the file associated with the file descriptor. < 0 on + * error. + */ +LIBSSH_API unsigned long sftp_tell(sftp_file file); + +/** + * @brief Report current byte position in file. + * + * @param file Open sftp file handle. + * + * @return The offset of the current byte relative to the beginning + * of the file associated with the file descriptor. < 0 on + * error. + */ +LIBSSH_API uint64_t sftp_tell64(sftp_file file); + +/** + * @brief Rewinds the position of the file pointer to the beginning of the + * file. + * + * @param file Open sftp file handle. + */ +LIBSSH_API void sftp_rewind(sftp_file file); + +/** + * @brief Unlink (delete) a file. + * + * @param sftp The sftp session handle. + * + * @param file The file to unlink/delete. + * + * @return 0 on success, < 0 on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API int sftp_unlink(sftp_session sftp, const char *file); + +/** + * @brief Remove a directoy. + * + * @param sftp The sftp session handle. + * + * @param directory The directory to remove. + * + * @return 0 on success, < 0 on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API int sftp_rmdir(sftp_session sftp, const char *directory); + +/** + * @brief Create a directory. + * + * @param sftp The sftp session handle. + * + * @param directory The directory to create. + * + * @param mode Specifies the permissions to use. It is modified by the + * process's umask in the usual way: + * The permissions of the created file are (mode & ~umask) + * + * @return 0 on success, < 0 on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API int sftp_mkdir(sftp_session sftp, const char *directory, mode_t mode); + +/** + * @brief Rename or move a file or directory. + * + * @param sftp The sftp session handle. + * + * @param original The original url (source url) of file or directory to + * be moved. + * + * @param newname The new url (destination url) of the file or directory + * after the move. + * + * @return 0 on success, < 0 on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API int sftp_rename(sftp_session sftp, const char *original, const char *newname); + +/** + * @brief Set file attributes on a file, directory or symbolic link. + * + * @param sftp The sftp session handle. + * + * @param file The file which attributes should be changed. + * + * @param attr The file attributes structure with the attributes set + * which should be changed. + * + * @return 0 on success, < 0 on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API int sftp_setstat(sftp_session sftp, const char *file, sftp_attributes attr); + +/** + * @brief Change the file owner and group + * + * @param sftp The sftp session handle. + * + * @param file The file which owner and group should be changed. + * + * @param owner The new owner which should be set. + * + * @param group The new group which should be set. + * + * @return 0 on success, < 0 on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API int sftp_chown(sftp_session sftp, const char *file, uid_t owner, gid_t group); + +/** + * @brief Change permissions of a file + * + * @param sftp The sftp session handle. + * + * @param file The file which owner and group should be changed. + * + * @param mode Specifies the permissions to use. It is modified by the + * process's umask in the usual way: + * The permissions of the created file are (mode & ~umask) + * + * @return 0 on success, < 0 on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API int sftp_chmod(sftp_session sftp, const char *file, mode_t mode); + +/** + * @brief Change the last modification and access time of a file. + * + * @param sftp The sftp session handle. + * + * @param file The file which owner and group should be changed. + * + * @param times A timeval structure which contains the desired access + * and modification time. + * + * @return 0 on success, < 0 on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API int sftp_utimes(sftp_session sftp, const char *file, const struct timeval *times); + +/** + * @brief Create a symbolic link. + * + * @param sftp The sftp session handle. + * + * @param target Specifies the target of the symlink. + * + * @param dest Specifies the path name of the symlink to be created. + * + * @return 0 on success, < 0 on error with ssh and sftp error set. + * + * @see sftp_get_error() + */ +LIBSSH_API int sftp_symlink(sftp_session sftp, const char *target, const char *dest); + +/** + * @brief Read the value of a symbolic link. + * + * @param sftp The sftp session handle. + * + * @param path Specifies the path name of the symlink to be read. + * + * @return The target of the link, NULL on error. + * + * @see sftp_get_error() + */ +LIBSSH_API char *sftp_readlink(sftp_session sftp, const char *path); + +/** + * @brief Get information about a mounted file system. + * + * @param sftp The sftp session handle. + * + * @param path The pathname of any file within the mounted file system. + * + * @return A statvfs structure or NULL on error. + * + * @see sftp_get_error() + */ +LIBSSH_API sftp_statvfs_t sftp_statvfs(sftp_session sftp, const char *path); + +/** + * @brief Get information about a mounted file system. + * + * @param file An opened file. + * + * @return A statvfs structure or NULL on error. + * + * @see sftp_get_error() + */ +LIBSSH_API sftp_statvfs_t sftp_fstatvfs(sftp_file file); + +/** + * @brief Free the memory of an allocated statvfs. + * + * @param statvfs_o The statvfs to free. + */ +LIBSSH_API void sftp_statvfs_free(sftp_statvfs_t statvfs_o); + +/** + * @brief Canonicalize a sftp path. + * + * @param sftp The sftp session handle. + * + * @param path The path to be canonicalized. + * + * @return The canonicalize path, NULL on error. + */ +LIBSSH_API char *sftp_canonicalize_path(sftp_session sftp, const char *path); + +/** + * @brief Get the version of the SFTP protocol supported by the server + * + * @param sftp The sftp session handle. + * + * @return The server version. + */ +LIBSSH_API int sftp_server_version(sftp_session sftp); + +#ifdef WITH_SERVER +/** + * @brief Create a new sftp server session. + * + * @param session The ssh session to use. + * + * @param chan The ssh channel to use. + * + * @return A new sftp server session. + */ +LIBSSH_API sftp_session sftp_server_new(ssh_session session, ssh_channel chan); + +/** + * @brief Intialize the sftp server. + * + * @param sftp The sftp session to init. + * + * @return 0 on success, < 0 on error. + */ +LIBSSH_API int sftp_server_init(sftp_session sftp); +#endif /* WITH_SERVER */ + +/* this is not a public interface */ +#define SFTP_HANDLES 256 +sftp_packet sftp_packet_read(sftp_session sftp); +int sftp_packet_write(sftp_session sftp,uint8_t type, ssh_buffer payload); +void sftp_packet_free(sftp_packet packet); +int buffer_add_attributes(ssh_buffer buffer, sftp_attributes attr); +sftp_attributes sftp_parse_attr(sftp_session session, ssh_buffer buf,int expectname); +/* sftpserver.c */ + +LIBSSH_API sftp_client_message sftp_get_client_message(sftp_session sftp); +LIBSSH_API void sftp_client_message_free(sftp_client_message msg); +LIBSSH_API uint8_t sftp_client_message_get_type(sftp_client_message msg); +LIBSSH_API const char *sftp_client_message_get_filename(sftp_client_message msg); +LIBSSH_API void sftp_client_message_set_filename(sftp_client_message msg, const char *newname); +LIBSSH_API const char *sftp_client_message_get_data(sftp_client_message msg); +LIBSSH_API uint32_t sftp_client_message_get_flags(sftp_client_message msg); +LIBSSH_API int sftp_send_client_message(sftp_session sftp, sftp_client_message msg); +int sftp_reply_name(sftp_client_message msg, const char *name, + sftp_attributes attr); +int sftp_reply_handle(sftp_client_message msg, ssh_string handle); +ssh_string sftp_handle_alloc(sftp_session sftp, void *info); +int sftp_reply_attr(sftp_client_message msg, sftp_attributes attr); +void *sftp_handle(sftp_session sftp, ssh_string handle); +int sftp_reply_status(sftp_client_message msg, uint32_t status, const char *message); +int sftp_reply_names_add(sftp_client_message msg, const char *file, + const char *longname, sftp_attributes attr); +int sftp_reply_names(sftp_client_message msg); +int sftp_reply_data(sftp_client_message msg, const void *data, int len); +void sftp_handle_remove(sftp_session sftp, void *handle); + +/* SFTP commands and constants */ +#define SSH_FXP_INIT 1 +#define SSH_FXP_VERSION 2 +#define SSH_FXP_OPEN 3 +#define SSH_FXP_CLOSE 4 +#define SSH_FXP_READ 5 +#define SSH_FXP_WRITE 6 +#define SSH_FXP_LSTAT 7 +#define SSH_FXP_FSTAT 8 +#define SSH_FXP_SETSTAT 9 +#define SSH_FXP_FSETSTAT 10 +#define SSH_FXP_OPENDIR 11 +#define SSH_FXP_READDIR 12 +#define SSH_FXP_REMOVE 13 +#define SSH_FXP_MKDIR 14 +#define SSH_FXP_RMDIR 15 +#define SSH_FXP_REALPATH 16 +#define SSH_FXP_STAT 17 +#define SSH_FXP_RENAME 18 +#define SSH_FXP_READLINK 19 +#define SSH_FXP_SYMLINK 20 + +#define SSH_FXP_STATUS 101 +#define SSH_FXP_HANDLE 102 +#define SSH_FXP_DATA 103 +#define SSH_FXP_NAME 104 +#define SSH_FXP_ATTRS 105 + +#define SSH_FXP_EXTENDED 200 +#define SSH_FXP_EXTENDED_REPLY 201 + +/* attributes */ +/* sftp draft is completely braindead : version 3 and 4 have different flags for same constants */ +/* and even worst, version 4 has same flag for 2 different constants */ +/* follow up : i won't develop any sftp4 compliant library before having a clarification */ + +#define SSH_FILEXFER_ATTR_SIZE 0x00000001 +#define SSH_FILEXFER_ATTR_PERMISSIONS 0x00000004 +#define SSH_FILEXFER_ATTR_ACCESSTIME 0x00000008 +#define SSH_FILEXFER_ATTR_ACMODTIME 0x00000008 +#define SSH_FILEXFER_ATTR_CREATETIME 0x00000010 +#define SSH_FILEXFER_ATTR_MODIFYTIME 0x00000020 +#define SSH_FILEXFER_ATTR_ACL 0x00000040 +#define SSH_FILEXFER_ATTR_OWNERGROUP 0x00000080 +#define SSH_FILEXFER_ATTR_SUBSECOND_TIMES 0x00000100 +#define SSH_FILEXFER_ATTR_EXTENDED 0x80000000 +#define SSH_FILEXFER_ATTR_UIDGID 0x00000002 + +/* types */ +#define SSH_FILEXFER_TYPE_REGULAR 1 +#define SSH_FILEXFER_TYPE_DIRECTORY 2 +#define SSH_FILEXFER_TYPE_SYMLINK 3 +#define SSH_FILEXFER_TYPE_SPECIAL 4 +#define SSH_FILEXFER_TYPE_UNKNOWN 5 + +/** + * @name Server responses + * + * @brief Responses returned by the sftp server. + * @{ + */ + +/** No error */ +#define SSH_FX_OK 0 +/** End-of-file encountered */ +#define SSH_FX_EOF 1 +/** File doesn't exist */ +#define SSH_FX_NO_SUCH_FILE 2 +/** Permission denied */ +#define SSH_FX_PERMISSION_DENIED 3 +/** Generic failure */ +#define SSH_FX_FAILURE 4 +/** Garbage received from server */ +#define SSH_FX_BAD_MESSAGE 5 +/** No connection has been set up */ +#define SSH_FX_NO_CONNECTION 6 +/** There was a connection, but we lost it */ +#define SSH_FX_CONNECTION_LOST 7 +/** Operation not supported by the server */ +#define SSH_FX_OP_UNSUPPORTED 8 +/** Invalid file handle */ +#define SSH_FX_INVALID_HANDLE 9 +/** No such file or directory path exists */ +#define SSH_FX_NO_SUCH_PATH 10 +/** An attempt to create an already existing file or directory has been made */ +#define SSH_FX_FILE_ALREADY_EXISTS 11 +/** We are trying to write on a write-protected filesystem */ +#define SSH_FX_WRITE_PROTECT 12 +/** No media in remote drive */ +#define SSH_FX_NO_MEDIA 13 + +/** @} */ + +/* file flags */ +#define SSH_FXF_READ 0x01 +#define SSH_FXF_WRITE 0x02 +#define SSH_FXF_APPEND 0x04 +#define SSH_FXF_CREAT 0x08 +#define SSH_FXF_TRUNC 0x10 +#define SSH_FXF_EXCL 0x20 +#define SSH_FXF_TEXT 0x40 + +/* rename flags */ +#define SSH_FXF_RENAME_OVERWRITE 0x00000001 +#define SSH_FXF_RENAME_ATOMIC 0x00000002 +#define SSH_FXF_RENAME_NATIVE 0x00000004 + +#define SFTP_OPEN SSH_FXP_OPEN +#define SFTP_CLOSE SSH_FXP_CLOSE +#define SFTP_READ SSH_FXP_READ +#define SFTP_WRITE SSH_FXP_WRITE +#define SFTP_LSTAT SSH_FXP_LSTAT +#define SFTP_FSTAT SSH_FXP_FSTAT +#define SFTP_SETSTAT SSH_FXP_SETSTAT +#define SFTP_FSETSTAT SSH_FXP_FSETSTAT +#define SFTP_OPENDIR SSH_FXP_OPENDIR +#define SFTP_READDIR SSH_FXP_READDIR +#define SFTP_REMOVE SSH_FXP_REMOVE +#define SFTP_MKDIR SSH_FXP_MKDIR +#define SFTP_RMDIR SSH_FXP_RMDIR +#define SFTP_REALPATH SSH_FXP_REALPATH +#define SFTP_STAT SSH_FXP_STAT +#define SFTP_RENAME SSH_FXP_RENAME +#define SFTP_READLINK SSH_FXP_READLINK +#define SFTP_SYMLINK SSH_FXP_SYMLINK + +/* openssh flags */ +#define SSH_FXE_STATVFS_ST_RDONLY 0x1 /* read-only */ +#define SSH_FXE_STATVFS_ST_NOSUID 0x2 /* no setuid */ + +#ifdef __cplusplus +} ; +#endif + +#endif /* SFTP_H */ + +/** @} */ +/* vim: set ts=2 sw=2 et cindent: */ diff --git a/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/ssh2.h b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/ssh2.h new file mode 100755 index 0000000..8b39b9a --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/include/libssh/ssh2.h @@ -0,0 +1,80 @@ +#ifndef __SSH2_H +#define __SSH2_H + +#define SSH2_MSG_DISCONNECT 1 +#define SSH2_MSG_IGNORE 2 +#define SSH2_MSG_UNIMPLEMENTED 3 +#define SSH2_MSG_DEBUG 4 +#define SSH2_MSG_SERVICE_REQUEST 5 +#define SSH2_MSG_SERVICE_ACCEPT 6 + +#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_KEX_ECDH_INIT 30 +#define SSH2_MSG_KEX_ECDH_REPLY 31 +#define SSH2_MSG_ECMQV_INIT 30 +#define SSH2_MSG_ECMQV_REPLY 31 + +#define SSH2_MSG_KEX_DH_GEX_REQUEST_OLD 30 +#define SSH2_MSG_KEX_DH_GEX_GROUP 31 +#define SSH2_MSG_KEX_DH_GEX_INIT 32 +#define SSH2_MSG_KEX_DH_GEX_REPLY 33 +#define SSH2_MSG_KEX_DH_GEX_REQUEST 34 +#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_USERAUTH_PASSWD_CHANGEREQ 60 +#define SSH2_MSG_USERAUTH_INFO_REQUEST 60 +#define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 +#define SSH2_MSG_USERAUTH_INFO_RESPONSE 61 +#define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 +#define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 +#define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 +#define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 +#define SSH2_MSG_USERAUTH_GSSAPI_MIC 66 + +#define SSH2_MSG_GLOBAL_REQUEST 80 +#define SSH2_MSG_REQUEST_SUCCESS 81 +#define SSH2_MSG_REQUEST_FAILURE 82 +#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 + +#define SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT 1 +#define SSH2_DISCONNECT_PROTOCOL_ERROR 2 +#define SSH2_DISCONNECT_KEY_EXCHANGE_FAILED 3 +#define SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED 4 +#define SSH2_DISCONNECT_RESERVED 4 +#define SSH2_DISCONNECT_MAC_ERROR 5 +#define SSH2_DISCONNECT_COMPRESSION_ERROR 6 +#define SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE 7 +#define SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED 8 +#define SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE 9 +#define SSH2_DISCONNECT_CONNECTION_LOST 10 +#define SSH2_DISCONNECT_BY_APPLICATION 11 +#define SSH2_DISCONNECT_TOO_MANY_CONNECTIONS 12 +#define SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER 13 +#define SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE 14 +#define SSH2_DISCONNECT_ILLEGAL_USER_NAME 15 + +#define SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED 1 +#define SSH2_OPEN_CONNECT_FAILED 2 +#define SSH2_OPEN_UNKNOWN_CHANNEL_TYPE 3 +#define SSH2_OPEN_RESOURCE_SHORTAGE 4 + +#define SSH2_EXTENDED_DATA_STDERR 1 + +#endif diff --git a/libssh/0.6.4-x2go1-mingw482_bin/lib/libssh.dll.a b/libssh/0.6.4-x2go1-mingw482_bin/lib/libssh.dll.a new file mode 100755 index 0000000..460205e Binary files /dev/null and b/libssh/0.6.4-x2go1-mingw482_bin/lib/libssh.dll.a differ diff --git a/libssh/0.6.4-x2go1-mingw482_bin/lib/libssh_threads.dll.a b/libssh/0.6.4-x2go1-mingw482_bin/lib/libssh_threads.dll.a new file mode 100755 index 0000000..becdf5d Binary files /dev/null and b/libssh/0.6.4-x2go1-mingw482_bin/lib/libssh_threads.dll.a differ diff --git a/libssh/0.6.4-x2go1-mingw482_bin/lib/pkgconfig/libssh.pc b/libssh/0.6.4-x2go1-mingw482_bin/lib/pkgconfig/libssh.pc new file mode 100755 index 0000000..986490a --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/lib/pkgconfig/libssh.pc @@ -0,0 +1,6 @@ +Name: libssh +Description: The SSH Library +Version: 0.6.4 +Libs: -Llib -lssh +Cflags: -Iinclude + diff --git a/libssh/0.6.4-x2go1-mingw482_bin/lib/pkgconfig/libssh_threads.pc b/libssh/0.6.4-x2go1-mingw482_bin/lib/pkgconfig/libssh_threads.pc new file mode 100755 index 0000000..6f8f962 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin/lib/pkgconfig/libssh_threads.pc @@ -0,0 +1,6 @@ +Name: libssh_threads +Description: The SSH Library Thread Extension +Version: 0.6.4 +Libs: -Llib -lssh_threads +Cflags: -Iinclude + diff --git a/libssh/0.6.4-x2go1-mingw482_bin_set-timestamps.sh b/libssh/0.6.4-x2go1-mingw482_bin_set-timestamps.sh new file mode 100755 index 0000000..856d523 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_bin_set-timestamps.sh @@ -0,0 +1,16 @@ +touch --no-create -d "2015-01-12 23:53:41.257903400 -0500" "0.6.4-x2go1-mingw482_bin/bin/libssh.dll" +touch --no-create -d "2015-01-12 23:53:41.929549300 -0500" "0.6.4-x2go1-mingw482_bin/bin/libssh_threads.dll" +touch --no-create -d "2015-01-12 23:54:28.362840300 -0500" "0.6.4-x2go1-mingw482_bin/build-log.txt" +touch --no-create -d "2015-01-12 23:49:31.405676500 -0500" "0.6.4-x2go1-mingw482_bin/CMake/libssh/libssh-config-version.cmake" +touch --no-create -d "2015-01-12 23:49:31.400672500 -0500" "0.6.4-x2go1-mingw482_bin/CMake/libssh/libssh-config.cmake" +touch --no-create -d "2015-01-12 23:55:01.562945400 -0500" "0.6.4-x2go1-mingw482_bin/CMake-Show-My-Changes.txt" +touch --no-create -d "2015-01-11 08:49:15.811499900 -0500" "0.6.4-x2go1-mingw482_bin/include/libssh/callbacks.h" +touch --no-create -d "2015-01-11 08:49:15.822514000 -0500" "0.6.4-x2go1-mingw482_bin/include/libssh/legacy.h" +touch --no-create -d "2015-01-11 08:57:07.142959600 -0500" "0.6.4-x2go1-mingw482_bin/include/libssh/libssh.h" +touch --no-create -d "2015-01-11 08:57:07.146954600 -0500" "0.6.4-x2go1-mingw482_bin/include/libssh/server.h" +touch --no-create -d "2015-01-11 08:49:15.842529800 -0500" "0.6.4-x2go1-mingw482_bin/include/libssh/sftp.h" +touch --no-create -d "2015-01-11 08:49:15.844533700 -0500" "0.6.4-x2go1-mingw482_bin/include/libssh/ssh2.h" +touch --no-create -d "2015-01-12 23:53:41.228873000 -0500" "0.6.4-x2go1-mingw482_bin/lib/libssh.dll.a" +touch --no-create -d "2015-01-12 23:53:41.924530500 -0500" "0.6.4-x2go1-mingw482_bin/lib/libssh_threads.dll.a" +touch --no-create -d "2015-01-12 23:49:31.390662700 -0500" "0.6.4-x2go1-mingw482_bin/lib/pkgconfig/libssh.pc" +touch --no-create -d "2015-01-12 23:49:31.395667800 -0500" "0.6.4-x2go1-mingw482_bin/lib/pkgconfig/libssh_threads.pc" diff --git a/libssh/0.6.4-x2go1-mingw482_src/0.6.4-x2go1-mingw482_src.zip b/libssh/0.6.4-x2go1-mingw482_src/0.6.4-x2go1-mingw482_src.zip new file mode 100644 index 0000000..68eed7a Binary files /dev/null and b/libssh/0.6.4-x2go1-mingw482_src/0.6.4-x2go1-mingw482_src.zip differ diff --git a/libssh/0.6.4-x2go1-mingw482_src/0001-options-Fix-setting-the-port.patch b/libssh/0.6.4-x2go1-mingw482_src/0001-options-Fix-setting-the-port.patch new file mode 100644 index 0000000..d571ddd --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_src/0001-options-Fix-setting-the-port.patch @@ -0,0 +1,112 @@ +From a45dd8e00037125d0789fe6d4a8ab1557a02e5ac Mon Sep 17 00:00:00 2001 +From: Andreas Schneider <asn@cryptomilk.org> +Date: Tue, 28 Oct 2014 10:33:20 +0100 +Subject: [PATCH] options: Fix setting the port. + +Make sure we correctly read the port from the config file. + +Signed-off-by: Andreas Schneider <asn@cryptomilk.org> +(cherry picked from commit bb18442fe8f58a483713eb2b988b3da9869ddf86) +--- + src/client.c | 2 +- + src/config.c | 2 +- + src/known_hosts.c | 6 +++--- + src/options.c | 9 ++++++--- + src/session.c | 2 +- + 5 files changed, 12 insertions(+), 9 deletions(-) + +diff --git a/src/client.c b/src/client.c +index ca6cf05..40e3101 100644 +--- a/src/client.c ++++ b/src/client.c +@@ -526,7 +526,7 @@ int ssh_connect(ssh_session session) { + } else { + ret=ssh_socket_connect(session->socket, + session->opts.host, +- session->opts.port, ++ session->opts.port > 0 ? session->opts.port : 22, + session->opts.bindaddr); + } + if (ret == SSH_ERROR) { +diff --git a/src/config.c b/src/config.c +index f21a71a..6a7f1ee 100644 +--- a/src/config.c ++++ b/src/config.c +@@ -245,7 +245,7 @@ static int ssh_config_parse_line(ssh_session session, const char *line, + } + break; + case SOC_PORT: +- if (session->opts.port == 22) { ++ if (session->opts.port == 0) { + p = ssh_config_get_str_tok(&s, NULL); + if (p && *parsing) { + ssh_options_set(session, SSH_OPTIONS_PORT_STR, p); +diff --git a/src/known_hosts.c b/src/known_hosts.c +index e80697d..cd999fd 100644 +--- a/src/known_hosts.c ++++ b/src/known_hosts.c +@@ -435,7 +435,7 @@ int ssh_is_server_known(ssh_session session) { + return SSH_SERVER_ERROR; + } + host = ssh_lowercase(session->opts.host); +- hostport = ssh_hostport(host, session->opts.port); ++ hostport = ssh_hostport(host, session->opts.port > 0 ? session->opts.port : 22); + if (host == NULL || hostport == NULL) { + ssh_set_error_oom(session); + SAFE_FREE(host); +@@ -542,7 +542,7 @@ int ssh_write_knownhost(ssh_session session) { + + host = ssh_lowercase(session->opts.host); + /* If using a nonstandard port, save the host in the [host]:port format */ +- if(session->opts.port != 22) { ++ if (session->opts.port > 0 && session->opts.port != 22) { + hostport = ssh_hostport(host, session->opts.port); + SAFE_FREE(host); + if (hostport == NULL) { +@@ -682,7 +682,7 @@ char **ssh_knownhosts_algorithms(ssh_session session) { + } + + host = ssh_lowercase(session->opts.host); +- hostport = ssh_hostport(host, session->opts.port); ++ hostport = ssh_hostport(host, session->opts.port > 0 ? session->opts.port : 22); + array = malloc(sizeof(char *) * KNOWNHOSTS_MAXTYPES); + + if (host == NULL || hostport == NULL || array == NULL) { +diff --git a/src/options.c b/src/options.c +index 3b702ef..8d17020 100644 +--- a/src/options.c ++++ b/src/options.c +@@ -871,11 +871,14 @@ int ssh_options_get_port(ssh_session session, unsigned int* port_target) { + if (session == NULL) { + return -1; + } +- if (!session->opts.port) { +- ssh_set_error_invalid(session); +- return -1; ++ ++ if (session->opts.port == 0) { ++ *port_target = 22; ++ return 0; + } ++ + *port_target = session->opts.port; ++ + return 0; + } + +diff --git a/src/session.c b/src/session.c +index 91b36b7..87a9f1a 100644 +--- a/src/session.c ++++ b/src/session.c +@@ -100,7 +100,7 @@ ssh_session ssh_new(void) { + + /* OPTIONS */ + session->opts.StrictHostKeyChecking = 1; +- session->opts.port = 22; ++ session->opts.port = 0; + session->opts.fd = -1; + session->opts.ssh2 = 1; + session->opts.compressionlevel=7; +-- +1.9.4.msysgit.0 + diff --git a/libssh/0.6.4-x2go1-mingw482_src/0002-connect-Check-that-errno-is-0-to-fix-Windows-build.patch b/libssh/0.6.4-x2go1-mingw482_src/0002-connect-Check-that-errno-is-0-to-fix-Windows-build.patch new file mode 100644 index 0000000..4fa2df5 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_src/0002-connect-Check-that-errno-is-0-to-fix-Windows-build.patch @@ -0,0 +1,31 @@ +From 0e969e0316fe6437898c31ca57a3d187e5ee59f1 Mon Sep 17 00:00:00 2001 +From: Andreas Schneider <asn@cryptomilk.org> +Date: Thu, 25 Dec 2014 12:33:29 +0100 +Subject: [PATCH] connect: Check that errno is 0 to fix Windows build. + +Thanks to Viktor Butskih. + +Signed-off-by: Andreas Schneider <asn@cryptomilk.org> +(cherry picked from commit e051135a0516f686456b9f3d089f91ded177ef1a) +--- + src/connect.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/connect.c b/src/connect.c +index 4ef85bc..da1bf44 100644 +--- a/src/connect.c ++++ b/src/connect.c +@@ -382,8 +382,9 @@ socket_t ssh_connect_host_nonblocking(ssh_session session, const char *host, + continue; + } + ++ errno = 0; + rc = connect(s, itr->ai_addr, itr->ai_addrlen); +- if (rc == -1 && (errno != EINPROGRESS)) { ++ if (rc == -1 && (errno != 0) && (errno != EINPROGRESS)) { + ssh_set_error(session, SSH_FATAL, + "Failed to connect: %s", strerror(errno)); + ssh_connect_socket_close(s); +-- +1.9.4.msysgit.0 + diff --git a/libssh/0.6.4-x2go1-mingw482_src/0003-Fix-the-dh.c-build-with-libgcrypt.patch b/libssh/0.6.4-x2go1-mingw482_src/0003-Fix-the-dh.c-build-with-libgcrypt.patch new file mode 100644 index 0000000..dd90651 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_src/0003-Fix-the-dh.c-build-with-libgcrypt.patch @@ -0,0 +1,55 @@ +From 3880a8ed80a4b1e2c052bd62f328bba2f869d5ae Mon Sep 17 00:00:00 2001 +From: Aris Adamantiadis <aris@0xbadc0de.be> +Date: Mon, 29 Dec 2014 16:06:33 +0100 +Subject: [PATCH] Fix the dh.c build with libgcrypt + +Fixes bug reported by gentoo at https://bugs.gentoo.org/show_bug.cgi?id=533424 +The function was only used by EDCSA backend which are not supported by the libgcrypt code anyway. +--- + include/libssh/dh.h | 2 ++ + src/dh.c | 11 +++++++---- + 2 files changed, 9 insertions(+), 4 deletions(-) + +diff --git a/include/libssh/dh.h b/include/libssh/dh.h +index f28b916..89872e3 100644 +--- a/include/libssh/dh.h ++++ b/include/libssh/dh.h +@@ -49,7 +49,9 @@ int hashbufin_add_cookie(ssh_session session, unsigned char *cookie); + int hashbufout_add_cookie(ssh_session session); + int generate_session_keys(ssh_session session); + bignum make_string_bn(ssh_string string); ++#ifdef HAVE_LIBCRYPTO + void make_string_bn_inplace(ssh_string string, bignum bnout); ++#endif /* HAVE_LIBCRYPTO */ + ssh_string make_bignum_string(bignum num); + + #endif /* DH_H_ */ +diff --git a/src/dh.c b/src/dh.c +index 84355d4..010a1dd 100644 +--- a/src/dh.c ++++ b/src/dh.c +@@ -407,14 +407,17 @@ bignum make_string_bn(ssh_string string){ + return bn; + } + ++#ifdef HAVE_LIBCRYPTO ++/** @internal ++ * @brief converts the content of a SSH string in an already allocated bignum ++ * @warning only available with OpenSSL builds ++ */ + void make_string_bn_inplace(ssh_string string, bignum bnout) { + unsigned int len = ssh_string_len(string); +-#ifdef HAVE_LIBGCRYPT +- #error "unsupported" +-#elif defined HAVE_LIBCRYPTO + bignum_bin2bn(string->data, len, bnout); +-#endif + } ++#endif /* HAVE_LIBCRYPTO */ ++ + + ssh_string dh_get_e(ssh_session session) { + return make_bignum_string(session->next_crypto->e); +-- +1.9.4.msysgit.0 + diff --git a/libssh/0.6.4-x2go1-mingw482_src/CMake-Show-My-Changes.txt b/libssh/0.6.4-x2go1-mingw482_src/CMake-Show-My-Changes.txt new file mode 100644 index 0000000..66391e0 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_src/CMake-Show-My-Changes.txt @@ -0,0 +1,17 @@ +Commandline options: +-DCMAKE_INSTALL_PREFIX:PATH="C:/x2gobuilds/libssh/build/install_dir" -DZLIB_LIBRARY:FILEPATH="C:/x2gobuilds/libssh_depends/zlib128-dll/zlib1.dll" -DSSL_EAY:FILEPATH="C:/OpenSSL-Win32/bin/ssleay32.dll" -DCMAKE_BUILD_TYPE:STRING="Release" -DZLIB_ROOT_DIR:PATH="C:/x2gobuilds/libssh_depends/zlib128-dll" -DCMAKE_CXX_FLAGS:STRING="" -DWITH_NACL:BOOL="0" -DWITH_GSSAPI:BOOL="0" -DZLIB_INCLUDE_DIR:PATH="C:/x2gobuilds/libssh_depends/zlib128-dll/include" -DWITH_EXAMPLES:BOOL="0" -DLIB_EAY:FILEPATH= [...] + + +Cache file: +CMAKE_INSTALL_PREFIX:PATH=C:/x2gobuilds/libssh/build/install_dir +ZLIB_LIBRARY:FILEPATH=C:/x2gobuilds/libssh_depends/zlib128-dll/zlib1.dll +SSL_EAY:FILEPATH=C:/OpenSSL-Win32/bin/ssleay32.dll +CMAKE_BUILD_TYPE:STRING=Release +ZLIB_ROOT_DIR:PATH=C:/x2gobuilds/libssh_depends/zlib128-dll +CMAKE_CXX_FLAGS:STRING= +WITH_NACL:BOOL=0 +WITH_GSSAPI:BOOL=0 +ZLIB_INCLUDE_DIR:PATH=C:/x2gobuilds/libssh_depends/zlib128-dll/include +WITH_EXAMPLES:BOOL=0 +LIB_EAY:FILEPATH=C:/OpenSSL-Win32/bin/libeay32.dll +BIN_INSTALL_DIR:PATH=bin diff --git a/libssh/0.6.4-x2go1-mingw482_src/implement-support-for-putty-s-pageant-0.6.4-71a931b.patch b/libssh/0.6.4-x2go1-mingw482_src/implement-support-for-putty-s-pageant-0.6.4-71a931b.patch new file mode 100644 index 0000000..4ad27da --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_src/implement-support-for-putty-s-pageant-0.6.4-71a931b.patch @@ -0,0 +1,540 @@ +From 71a931b5f3a2bab042c342802a5ac78cf985124f Mon Sep 17 00:00:00 2001 +From: Mike DePaulo <mikedep333@gmail.com> +Date: Sat, 6 Sep 2014 18:53:03 -0400 +Subject: [PATCH] Port KDE for WIndows's Pageant patch + (0001-implement-support-for-putty-s-pageant-0.5.3.patch) to libssh-0.6.3 + +--- + include/libssh/agent.h | 2 - + src/CMakeLists.txt | 6 +++ + src/agent.c | 79 ++++++++++++++++++++++++++++++++---- + src/auth.c | 7 ---- + src/pki.c | 2 - + src/session.c | 4 -- + src/winpgntc.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ + src/winpgntc.h | 34 ++++++++++++++++ + 8 files changed, 218 insertions(+), 23 deletions(-) + create mode 100644 src/winpgntc.c + create mode 100644 src/winpgntc.h + +diff --git a/include/libssh/agent.h b/include/libssh/agent.h +index 77209d0..c65fe32 100644 +--- a/include/libssh/agent.h ++++ b/include/libssh/agent.h +@@ -74,7 +74,6 @@ struct ssh_agent_struct { + ssh_channel channel; + }; + +-#ifndef _WIN32 + /* agent.c */ + /** + * @brief Create a new ssh agent structure. +@@ -112,7 +111,6 @@ ssh_key ssh_agent_get_first_ident(struct ssh_session_struct *session, + ssh_string ssh_agent_sign_data(ssh_session session, + const ssh_key pubkey, + struct ssh_buffer_struct *data); +-#endif + + #endif /* __AGENT_H */ + /* vim: set ts=2 sw=2 et cindent: */ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 1891a00..66ba103 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -143,6 +143,12 @@ set(libssh_SRCS + threads.c + wrapper.c + ) ++if (WIN32) ++ set(libssh_SRCS ++ ${libssh_SRCS} ++ winpgntc.c ++ ) ++endif (WIN32) + + if (WITH_GCRYPT) + set(libssh_SRCS +diff --git a/src/agent.c b/src/agent.c +index 6fcef0c..487264c 100644 +--- a/src/agent.c ++++ b/src/agent.c +@@ -33,8 +33,6 @@ + * the agent returns the signed data + */ + +-#ifndef _WIN32 +- + #include "config.h" + + #include <stdlib.h> +@@ -42,26 +40,44 @@ + #include <string.h> + #include <stdio.h> + ++#ifdef _WIN32 ++#include <winsock2.h> ++#include <windows.h> ++#else + #ifdef HAVE_UNISTD_H + #include <unistd.h> + #endif ++#endif + ++#ifndef _WIN32 + #include <netinet/in.h> + #include <arpa/inet.h> ++#endif /* _WIN32 */ + + #include "libssh/agent.h" + #include "libssh/priv.h" + #include "libssh/socket.h" + #include "libssh/buffer.h" + #include "libssh/session.h" ++#ifndef _WIN32 ++#include "libssh/priv.h" ++#include "libssh/socket.h" + #include "libssh/poll.h" + #include "libssh/pki.h" ++#else ++#include "winpgntc.h" ++#endif + + /* macro to check for "agent failure" message */ + #define agent_failed(x) \ + (((x) == SSH_AGENT_FAILURE) || ((x) == SSH_COM_AGENT2_FAILURE) || \ + ((x) == SSH2_AGENT_FAILURE)) + ++#ifdef _WIN32 ++#define AGENT_COPYDATA_ID 0x804e50ba /* random goop */ ++#endif ++ ++ + static uint32_t agent_get_u32(const void *vp) { + const uint8_t *p = (const uint8_t *)vp; + uint32_t v; +@@ -83,6 +99,7 @@ static void agent_put_u32(void *vp, uint32_t v) { + p[3] = (uint8_t)v & 0xff; + } + ++#ifndef _WIN32 + static size_t atomicio(struct ssh_agent_struct *agent, void *buf, size_t n, int do_read) { + char *b = buf; + size_t pos = 0; +@@ -109,10 +126,11 @@ static size_t atomicio(struct ssh_agent_struct *agent, void *buf, size_t n, int + continue; + } + #ifdef EWOULDBLOCK +- if (errno == EAGAIN || errno == EWOULDBLOCK) { ++ if (errno == EAGAIN || errno == EWOULDBLOCK) + #else +- if (errno == EAGAIN) { ++ if (errno == EAGAIN) + #endif ++ { + (void) ssh_poll(&pfd, 1, -1); + continue; + } +@@ -142,6 +160,7 @@ static size_t atomicio(struct ssh_agent_struct *agent, void *buf, size_t n, int + return pos; + } + } ++#endif + + ssh_agent agent_new(struct ssh_session_struct *session) { + ssh_agent agent = NULL; +@@ -153,11 +172,13 @@ ssh_agent agent_new(struct ssh_session_struct *session) { + ZERO_STRUCTP(agent); + + agent->count = 0; ++ #ifndef _WIN32 + agent->sock = ssh_socket_new(session); + if (agent->sock == NULL) { + SAFE_FREE(agent); + return NULL; + } ++ #endif + agent->channel = NULL; + return agent; + } +@@ -187,6 +208,7 @@ int ssh_set_agent_channel(ssh_session session, ssh_channel channel){ + + + void agent_close(struct ssh_agent_struct *agent) { ++ #ifndef _WIN32 + if (agent == NULL) { + return; + } +@@ -194,6 +216,7 @@ void agent_close(struct ssh_agent_struct *agent) { + if (getenv("SSH_AUTH_SOCK")) { + ssh_socket_close(agent->sock); + } ++ #endif + } + + void agent_free(ssh_agent agent) { +@@ -201,15 +224,18 @@ void agent_free(ssh_agent agent) { + if (agent->ident) { + ssh_buffer_free(agent->ident); + } ++#ifndef _WIN32 + if (agent->sock) { + agent_close(agent); + ssh_socket_free(agent->sock); + } ++#endif + SAFE_FREE(agent); + } + } + + static int agent_connect(ssh_session session) { ++#ifndef _WIN32 + const char *auth_sock = NULL; + + if (session == NULL || session->agent == NULL) { +@@ -229,6 +255,9 @@ static int agent_connect(ssh_session session) { + } + + return -1; ++#else ++ return 0; ++#endif + } + + #if 0 +@@ -253,6 +282,7 @@ static int agent_decode_reply(struct ssh_session_struct *session, int type) { + + static int agent_talk(struct ssh_session_struct *session, + struct ssh_buffer_struct *request, struct ssh_buffer_struct *reply) { ++#ifndef _WIN32 + uint32_t len = 0; + uint8_t payload[1024] = {0}; + +@@ -306,7 +336,39 @@ static int agent_talk(struct ssh_session_struct *session, + } + len -= n; + } ++#else ++ uint32_t inlen = 0, outlen = 0, i = 0; ++ uint8_t payload[1024] = {0}; ++ uint8_t outload[1024] = {0}; ++ uint8_t *t = outload; ++ ++ inlen = buffer_get_len(request); ++ ssh_log(session, SSH_LOG_PACKET, "agent_talk - len of request: %u", inlen); ++ agent_put_u32(payload, inlen); ++ ++ /* FIXME: make a clean copy here */ ++ for(i = 0; i < inlen; i++) { ++ if(i == 1024) exit(1); ++ payload[i+4] = request->data[i]; ++ } ++ ++ agent_query((void*)payload, inlen + 4, &t, &outlen); ++ ++ if (outlen > 256 * 1024) { ++ ssh_set_error(session, SSH_FATAL, ++ "Authentication response too long: %u", outlen); ++ return -1; ++ } ++ ssh_log(session, SSH_LOG_PACKET, "agent_talk - response length: %u", outlen); + ++ outlen = outlen + 4; ++ /* the first 4 bytes are the size of the buffer */ ++ if (buffer_add_data(reply, (t + 4), outlen) < 0) { ++ ssh_log(session, SSH_LOG_FUNCTIONS, ++ "Not enough space"); ++ return -1; ++ } ++#endif + return 0; + } + +@@ -468,7 +530,7 @@ int agent_is_running(ssh_session session) { + if (session == NULL || session->agent == NULL) { + return 0; + } +- ++#ifndef _WIN32 + if (ssh_socket_is_open(session->agent->sock)) { + return 1; + } else { +@@ -478,7 +540,10 @@ int agent_is_running(ssh_session session) { + return 1; + } + } +- ++#else ++ if(FindWindow(TEXT("Pageant"), TEXT("Pageant"))) ++ return 1; ++#endif + return 0; + } + +@@ -572,6 +637,4 @@ ssh_string ssh_agent_sign_data(ssh_session session, + return sig_blob; + } + +-#endif /* _WIN32 */ +- + /* vim: set ts=4 sw=4 et cindent: */ +diff --git a/src/auth.c b/src/auth.c +index a801e45..cd06e1b 100644 +--- a/src/auth.c ++++ b/src/auth.c +@@ -793,7 +793,6 @@ fail: + return SSH_AUTH_ERROR; + } + +-#ifndef _WIN32 + static int ssh_userauth_agent_publickey(ssh_session session, + const char *username, + ssh_key pubkey) +@@ -941,7 +940,6 @@ struct ssh_agent_state_struct { + char *comment; + }; + +- + /** + * @brief Try to do public key authentication with ssh agent. + * +@@ -1041,7 +1039,6 @@ int ssh_userauth_agent(ssh_session session, + SAFE_FREE(session->agent_state); + return rc; + } +-#endif + + enum ssh_auth_auto_state_e { + SSH_AUTH_AUTO_STATE_NONE=0, +@@ -1114,13 +1111,11 @@ int ssh_userauth_publickey_auto(ssh_session session, + } + state = session->auth_auto_state; + if (state->state == SSH_AUTH_AUTO_STATE_NONE) { +-#ifndef _WIN32 + /* Try authentication with ssh-agent first */ + rc = ssh_userauth_agent(session, username); + if (rc == SSH_AUTH_SUCCESS || rc == SSH_AUTH_AGAIN) { + return rc; + } +-#endif + state->state = SSH_AUTH_AUTO_STATE_PUBKEY; + } + if (state->it == NULL) { +@@ -1420,7 +1415,6 @@ fail: + return SSH_AUTH_ERROR; + } + +-#ifndef _WIN32 + /* LEGACY */ + int ssh_userauth_agent_pubkey(ssh_session session, + const char *username, +@@ -1448,7 +1442,6 @@ int ssh_userauth_agent_pubkey(ssh_session session, + + return rc; + } +-#endif /* _WIN32 */ + + ssh_kbdint ssh_kbdint_new(void) { + ssh_kbdint kbd; +diff --git a/src/pki.c b/src/pki.c +index bbda155..08e0b2f 100644 +--- a/src/pki.c ++++ b/src/pki.c +@@ -1436,7 +1436,6 @@ ssh_string ssh_pki_do_sign(ssh_session session, + return sig_blob; + } + +-#ifndef _WIN32 + ssh_string ssh_pki_do_sign_agent(ssh_session session, + struct ssh_buffer_struct *buf, + const ssh_key pubkey) { +@@ -1486,7 +1485,6 @@ ssh_string ssh_pki_do_sign_agent(ssh_session session, + + return sig_blob; + } +-#endif /* _WIN32 */ + + #ifdef WITH_SERVER + ssh_string ssh_srv_pki_do_sign_sessionid(ssh_session session, +diff --git a/src/session.c b/src/session.c +index 87a9f1a..0ca88ac 100644 +--- a/src/session.c ++++ b/src/session.c +@@ -91,12 +91,10 @@ ssh_session ssh_new(void) { + ssh_set_blocking(session, 1); + session->maxchannel = FIRST_CHANNEL; + +-#ifndef _WIN32 + session->agent = agent_new(session); + if (session->agent == NULL) { + goto err; + } +-#endif /* _WIN32 */ + + /* OPTIONS */ + session->opts.StrictHostKeyChecking = 1; +@@ -221,9 +219,7 @@ void ssh_free(ssh_session session) { + crypto_free(session->current_crypto); + crypto_free(session->next_crypto); + +-#ifndef _WIN32 + agent_free(session->agent); +-#endif /* _WIN32 */ + + ssh_key_free(session->srv.dsa_key); + session->srv.dsa_key = NULL; +diff --git a/src/winpgntc.c b/src/winpgntc.c +new file mode 100644 +index 0000000..756ba79 +--- /dev/null ++++ b/src/winpgntc.c +@@ -0,0 +1,107 @@ ++/* ++ * winpgntc.c - interact with pageant on windows ++ * ++ * This file is part of the SSH Library ++ * ++ * Copyright (c) 2012 Patrick Spendrin <ps_ml@gmx.de> ++ * ++ * The SSH Library is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU Lesser General Public License as published by ++ * the Free Software Foundation; either version 2.1 of the License, or (at your ++ * option) any later version. ++ * ++ * The SSH Library 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. See the GNU Lesser General Public ++ * License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public License ++ * along with the SSH Library; see the file COPYING. If not, write to ++ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, ++ * MA 02111-1307, USA. ++ */ ++ ++/* This file is based on the winpgntc.c from Putty sources: ++ PuTTY is copyright 1997-2012 Simon Tatham. ++ ++ Portions copyright Robert de Bath, Joris van Rantwijk, Delian Delchev, ++ Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry, Justin ++ Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus Kuhn, Colin ++ Watson, and CORE SDI S.A. ++ ++ Permission is hereby granted, free of charge, to any person obtaining a ++ copy of this software and associated documentation files (the "Software"), ++ to deal in the Software without restriction, including without limitation ++ the rights to use, copy, modify, merge, publish, distribute, sublicense, ++ and/or sell copies of the Software, and to permit persons to whom the ++ Software is furnished to do so, subject to the following conditions: ++ ++ The above copyright notice and this permission notice shall be included in ++ all copies or substantial portions of the Software. ++ ++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ++ SIMON TATHAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER ++ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ++ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ++ ++#include <stdio.h> ++#include <stdlib.h> ++ ++#include "libssh/agent.h" ++ ++#define AGENT_COPYDATA_ID 0x804e50ba /* random goop */ ++#define AGENT_MAX_MSGLEN 8192 ++ ++#define GET_32BIT(cp) \ ++ (((unsigned long)(unsigned char)(cp)[0] << 24) | \ ++ ((unsigned long)(unsigned char)(cp)[1] << 16) | \ ++ ((unsigned long)(unsigned char)(cp)[2] << 8) | \ ++ ((unsigned long)(unsigned char)(cp)[3])) ++ ++int agent_query(void *in, int inlen, void **out, int *outlen) ++{ ++ HWND hwnd; ++ char mapname[25]; ++ HANDLE filemap; ++ unsigned char *p, *ret; ++ int id, retlen; ++ COPYDATASTRUCT cds; ++ ++ *out = NULL; ++ *outlen = 0; ++ ++ hwnd = FindWindow("Pageant", "Pageant"); ++ if (!hwnd) ++ return 1; /* *out == NULL, so failure */ ++ sprintf(mapname, "PageantRequest%08x", (unsigned)GetCurrentThreadId()); ++ filemap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, ++ 0, AGENT_MAX_MSGLEN, mapname); ++ if (filemap == NULL || filemap == INVALID_HANDLE_VALUE) ++ return 1; /* *out == NULL, so failure */ ++ p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, 0); ++ memcpy(p, in, inlen); ++ cds.dwData = AGENT_COPYDATA_ID; ++ cds.cbData = 1 + strlen(mapname); ++ cds.lpData = mapname; ++ ++ /* ++ * The user either passed a null callback (indicating that the ++ * query is required to be synchronous) or CreateThread failed. ++ * Either way, we need a synchronous request. ++ */ ++ id = SendMessage(hwnd, WM_COPYDATA, (WPARAM) NULL, (LPARAM) &cds); ++ if (id > 0) { ++ retlen = 4 + GET_32BIT(p); ++ ret = (unsigned char *)malloc(retlen*sizeof(unsigned char)); ++ if (ret) { ++ memcpy(ret, p, retlen); ++ *out = ret; ++ *outlen = retlen; ++ } ++ } ++ UnmapViewOfFile(p); ++ CloseHandle(filemap); ++ return 1; ++} +diff --git a/src/winpgntc.h b/src/winpgntc.h +new file mode 100644 +index 0000000..195a482 +--- /dev/null ++++ b/src/winpgntc.h +@@ -0,0 +1,34 @@ ++/* ++ * winpgntc.h - interact with pageant on windows ++ * ++ * This file is part of the SSH Library ++ * ++ * Copyright (c) 2012 Patrick Spendrin <ps_ml@gmx.de> ++ * ++ * The SSH Library is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU Lesser General Public License as published by ++ * the Free Software Foundation; either version 2.1 of the License, or (at your ++ * option) any later version. ++ * ++ * The SSH Library 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. See the GNU Lesser General Public ++ * License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public License ++ * along with the SSH Library; see the file COPYING. If not, write to ++ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, ++ * MA 02111-1307, USA. ++ */ ++ ++ ++#ifndef __WINPGNTC_H ++#define __WINPGNTC_H ++ ++#ifdef _WIN32 ++#include "libssh/agent.h" ++ ++int agent_query(void *in, int inlen, void **out, int *outlen); ++ ++#endif ++#endif /* __WINPGNTC_H */ +-- +1.9.4.msysgit.0 + diff --git a/libssh/0.6.4-x2go1-mingw482_src/libssh-fix-mingw482-build.patch b/libssh/0.6.4-x2go1-mingw482_src/libssh-fix-mingw482-build.patch new file mode 100644 index 0000000..42db620 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_src/libssh-fix-mingw482-build.patch @@ -0,0 +1,33 @@ +From 143709bc19c20d1b7e6e032fb749623964670df7 Mon Sep 17 00:00:00 2001 +From: Mike DePaulo <mikedep333@gmail.com> +Date: Thu, 11 Sep 2014 08:00:14 -0400 +Subject: [PATCH] Fix build under MinGW 4.8.2 with POSIX threads (Patch + provided by: "George Trakatelis" <trakatelis@uom.edu.gr>) + +--- + src/threads/pthread.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/threads/pthread.c b/src/threads/pthread.c +index 829fa5c..64e0ba3 100644 +--- a/src/threads/pthread.c ++++ b/src/threads/pthread.c +@@ -75,11 +75,11 @@ static int ssh_pthread_mutex_unlock (void **lock){ + } + + static unsigned long ssh_pthread_thread_id (void){ +-#if _WIN32 +- return (unsigned long) pthread_self().p; +-#else ++//#if _WIN32 ++// return (unsigned long) pthread_self().p; ++//#else + return (unsigned long) pthread_self(); +-#endif ++//#endif + } + + static struct ssh_threads_callbacks_struct ssh_threads_pthread = +-- +1.9.4.msysgit.0 + diff --git a/libssh/0.6.4-x2go1-mingw482_src/why-patches-0001-0003-exist.txt b/libssh/0.6.4-x2go1-mingw482_src/why-patches-0001-0003-exist.txt new file mode 100644 index 0000000..adeff32 --- /dev/null +++ b/libssh/0.6.4-x2go1-mingw482_src/why-patches-0001-0003-exist.txt @@ -0,0 +1,16 @@ +* Now talking on #libssh +* Topic for #libssh is: ][ Welcome to #libssh ][ Homepage: http://www.libssh.org/ ][ libssh 0.6.1 has been released! ][ Please stick around for a bit when asking questions, there may not always be somebody around ][ +* Topic for #libssh set by gladiac!~asn@milliways.cryptomilk.org at Mon Feb 10 04:30:15 2014 +* Channel #libssh url: http://www.libssh.org/ +<mikedep333> Hi. The libssh git repo does not have a tag for 0.6.4 +<mikedep333> I am assuming it is this commit? +<mikedep333> http://git.libssh.org/projects/libssh.git/commit/?h=v0-6&id=319129399d3191e9ddd04bef05d2c707ecaa9455 +<mikedep333> (it's the last commit on 2014-12-17. The next commit is on 2014-12-25. And 0.6.4 was released on 2014-12-19) +<mikedep333> Also, I intend to build with mingw 4.8. Based on the email thread, I am assuming I should cherry-pick this commit. http://git.libssh.org/projects/libssh.git/commit/?h=v0-6&id=0e969e0316fe6437898c31ca57a3d187e5ee59f1 +<gladiac> yep +<gladiac> mikedep333: you're right +<gladiac> you can just use the v0-6 branch +<gladiac> it is a bugfix only branch +<mikedep333> you think I should use the latest commits in that branch? +<gladiac> yep :) +<mikedep333> thanks, will do -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient-contrib.git