From c0e091a52f8521d0cdcb9c22b4caa88bbe40e604 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Tue, 3 Nov 2009 21:03:22 +0100 Subject: Fix openssl header inclusion caused cbc_encrypt to be redefined by an openssl macro --- include/libssh/crypto.h | 11 ++++++----- libssh/crypt.c | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/libssh/crypto.h b/include/libssh/crypto.h index d838f245..00bb1c97 100644 --- a/include/libssh/crypto.h +++ b/include/libssh/crypto.h @@ -27,6 +27,12 @@ #define _CRYPTO_H_ #include "config.h" + +#ifdef HAVE_LIBGCRYPT +#include +#endif +#include "libssh/wrapper.h" + #ifdef cbc_encrypt #undef cbc_encrypt #endif @@ -34,11 +40,6 @@ #undef cbc_decrypt #endif -#ifdef HAVE_LIBGCRYPT -#include -#endif -#include "libssh/wrapper.h" - struct ssh_crypto_struct { bignum e,f,x,k,y; unsigned char session_id[SHA_DIGEST_LEN]; diff --git a/libssh/crypt.c b/libssh/crypt.c index 172d2151..2e05146b 100644 --- a/libssh/crypt.c +++ b/libssh/crypt.c @@ -37,10 +37,9 @@ #endif #include "libssh/priv.h" -#include "libssh/crypto.h" #include "libssh/session.h" #include "libssh/wrapper.h" - +#include "libssh/crypto.h" uint32_t packet_decrypt_len(ssh_session session, char *crypted){ uint32_t decrypted; -- cgit v1.2.3 From e71c28f6a0049617b1bae700524c69c2c8215e09 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Tue, 3 Nov 2009 21:04:07 +0100 Subject: Fix warnings on old gcc's they don't like variable names having type names --- include/libssh/server.h | 28 ++++++++++++++-------------- include/libssh/sftp.h | 10 +++++----- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/libssh/server.h b/include/libssh/server.h index c9cf634e..a235ffa6 100644 --- a/include/libssh/server.h +++ b/include/libssh/server.h @@ -71,62 +71,62 @@ LIBSSH_API int ssh_bind_options_set(ssh_bind sshbind, /** * @brief Start listening to the socket. * - * @param ssh_bind The ssh server bind to use. + * @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); +LIBSSH_API int ssh_bind_listen(ssh_bind ssh_bind_o); /** * @brief Set the session to blocking/nonblocking mode. * - * @param ssh_bind The ssh server bind to use. + * @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 sshbind, int blocking); +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 The ssh server bind to get the fd from. + * @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); +LIBSSH_API socket_t ssh_bind_get_fd(ssh_bind ssh_bind_o); /** * @brief Set the file descriptor for a session. * - * @param ssh_bind The ssh server bind to set the fd. + * @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 sshbind, socket_t fd); +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 The ssh server bind to use. + * @param ssh_bind_o The ssh server bind to use. */ -LIBSSH_API void ssh_bind_fd_toaccept(ssh_bind ssh_bind); +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 The ssh server bind to accept a connection. + * @param ssh_bind_o The ssh server bind to accept a connection. * @param session A preallocated ssh session * @see ssh_new * @return A newly allocated ssh session, NULL on error. */ -LIBSSH_API int ssh_bind_accept(ssh_bind ssh_bind, ssh_session session); +LIBSSH_API int ssh_bind_accept(ssh_bind ssh_bind_o, ssh_session session); /** * @brief Free a ssh servers bind. * - * @param ssh_bind The ssh server bind to free. + * @param ssh_bind_o The ssh server bind to free. */ -LIBSSH_API void ssh_bind_free(ssh_bind ssh_bind); +LIBSSH_API void ssh_bind_free(ssh_bind ssh_bind_o); /** * @brief Exchange the banner and cryptographic keys. diff --git a/include/libssh/sftp.h b/include/libssh/sftp.h index 0293f29b..403d0c57 100644 --- a/include/libssh/sftp.h +++ b/include/libssh/sftp.h @@ -243,11 +243,11 @@ LIBSSH_API unsigned int sftp_extensions_get_count(sftp_session sftp); * * @param sftp The sftp session to use. * - * @param index The index number of the extension name you want. + * @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 index); +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. @@ -256,11 +256,11 @@ LIBSSH_API const char *sftp_extensions_get_name(sftp_session sftp, unsigned int * * @param sftp The sftp session to use. * - * @param index The index number of the extension data you want. + * @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 index); +LIBSSH_API const char *sftp_extensions_get_data(sftp_session sftp, unsigned int indexn); /** * @brief Check if the given extension is supported. @@ -284,7 +284,7 @@ LIBSSH_API int sftp_extension_supported(sftp_session sftp, const char *name, /** * @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. * -- cgit v1.2.3 From 5e002635fcfda365a0f7c0e84cd534c44abaa6a9 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Tue, 3 Nov 2009 21:04:36 +0100 Subject: Fix compilation on freebsd 6.0 which lacks argp.h --- ConfigureChecks.cmake | 1 + examples/samplesshd.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 8ca82585..c2bed2ec 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -21,6 +21,7 @@ check_c_compiler_flag("-fvisibility=hidden" WITH_VISIBILITY_HIDDEN) endif(CMAKE_COMPILER_IS_GNUC) # HEADER FILES +check_include_file(argp.h HAVE_ARGP_H) check_include_file(pty.h HAVE_PTY_H) check_include_file(terminos.h HAVE_TERMIOS_H) if (WIN32) diff --git a/examples/samplesshd.c b/examples/samplesshd.c index 142e8805..f2013b76 100644 --- a/examples/samplesshd.c +++ b/examples/samplesshd.c @@ -14,7 +14,10 @@ clients must be made or how a client should react. #include #include + +#ifdef HAVE_ARGP_H #include +#endif #include #include #include @@ -34,7 +37,7 @@ static int auth_password(char *user, char *password){ return 0; return 1; // authenticated } - +#ifdef HAVE_ARGP_H const char *argp_program_version = "libssh server example " SSH_STRINGIFY(LIBSSH_VERSION); const char *argp_program_bug_address = ""; @@ -135,6 +138,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { /* Our argp parser. */ static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL}; +#endif /* HAVE_ARGP_H */ int main(int argc, char **argv){ ssh_session session; @@ -153,12 +157,13 @@ int main(int argc, char **argv){ ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, KEYS_FOLDER "ssh_host_dsa_key"); ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, KEYS_FOLDER "ssh_host_rsa_key"); +#ifdef HAVE_ARGP_H /* * Parse our arguments; every option seen by parse_opt will * be reflected in arguments. */ argp_parse (&argp, argc, argv, 0, 0, sshbind); - +#endif if(ssh_bind_listen(sshbind)<0){ printf("Error listening to socket: %s\n",ssh_get_error(sshbind)); return 1; -- cgit v1.2.3 From 535ff07f0fa62beb611b759af12588f7f4148911 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Thu, 5 Nov 2009 13:09:42 +0100 Subject: Forgot to update config.h.cmake --- config.h.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.h.cmake b/config.h.cmake index 5b75e6b8..b483ea1c 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -14,6 +14,9 @@ /************************** HEADER FILES *************************/ +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ARGP_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_PTY_H 1 -- cgit v1.2.3 From 75f066dfcd530914fad6b69890b5b4c454d1d1e7 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Thu, 5 Nov 2009 16:00:05 +0100 Subject: channel_read() won't block until count b. are read --- libssh/channels.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libssh/channels.c b/libssh/channels.c index 6f1e3ee2..229fe205 100644 --- a/libssh/channels.c +++ b/libssh/channels.c @@ -1838,7 +1838,8 @@ int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count, * @param is_stderr A boolean value to mark reading from the stderr flow. * * @return The number of bytes read, 0 on end of file or SSH_ERROR on error. - * + * @warning This function may return less than count bytes of data, and won't + * block until count bytes have been read. * @warning The read function using a buffer has been renamed to * channel_read_buffer(). */ @@ -1876,9 +1877,10 @@ int channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr) } } - /* block reading if asked bytes=0 */ - while (buffer_get_rest_len(stdbuf) == 0 || - buffer_get_rest_len(stdbuf) < count) { + /* block reading until at least one byte is read + * and ignore the trivial case count=0 + */ + while (buffer_get_rest_len(stdbuf) == 0 && count > 0) { if (channel->remote_eof && buffer_get_rest_len(stdbuf) == 0) { leave_function(); return 0; -- cgit v1.2.3