1
1

Merge branch 'master' of git://git.libssh.org/projects/libssh/libssh

Этот коммит содержится в:
Aris Adamantiadis 2009-08-12 00:04:30 +02:00
родитель 1e1c13f756 db284d60b9
Коммит 86418bfbbe
16 изменённых файлов: 315 добавлений и 679 удалений

Просмотреть файл

@ -1,5 +1,3 @@
include(InstallRequiredSystemLibraries)
# For help take a look at:
# http://www.cmake.org/Wiki/CMake:CPackConfiguration

Просмотреть файл

@ -16,6 +16,8 @@ set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
set(BINARYDIR ${CMAKE_BINARY_DIR})
set(SOURCEDIR ${CMAKE_SOURCE_DIR})
check_c_compiler_flag("-fvisibility=hidden" WITH_VISIBILITY_HIDDEN)
# HEADER FILES
check_include_file(pty.h HAVE_PTY_H)
check_include_file(terminos.h HAVE_TERMIOS_H)

Просмотреть файл

@ -48,3 +48,8 @@ if (UNIX AND NOT WIN32)
endif (WITH_FORTIFY_SOURCE)
endif (CMAKE_COMPILER_IS_GNUCC)
endif (UNIX AND NOT WIN32)
# suppress warning about "deprecated" functions
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)

Просмотреть файл

@ -94,7 +94,7 @@ endif (UNIX)
if (WIN32)
# Same same
set(BIN_INSTALL_DIR "." CACHE PATH "-")
set(BIN_INSTALL_DIR "bin" CACHE PATH "-")
set(SBIN_INSTALL_DIR "." CACHE PATH "-")
set(LIB_INSTALL_DIR "lib" CACHE PATH "-")
set(INCLUDE_INSTALL_DIR "include" CACHE PATH "-")

Просмотреть файл

@ -87,6 +87,10 @@ else (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
NAMES
crypto
libcrypto
eay
eay32
libeay
libeay32
PATHS
${_OPENSSL_LIBDIR}
/usr/lib

Просмотреть файл

@ -82,3 +82,17 @@
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#cmakedefine WORDS_BIGENDIAN 1
/************************* MS Windows ***************************/
#ifdef _WIN32
# ifdef _MSC_VER
/* On Microsoft compilers define inline to __inline on all others use inline */
# undef inline
# define inline __inline
# undef strdup
# define strdup _strdup
# endif // _MSC_VER
#endif /* _WIN32 */

Просмотреть файл

@ -22,22 +22,48 @@
#ifndef _LIBSSH_H
#define _LIBSSH_H
#ifndef _MSC_VER
#include <unistd.h>
#include <inttypes.h>
#ifdef LIBSSH_STATIC
#define LIBSSH_API
#else
#if defined _WIN32 || defined __CYGWIN__
#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
#else
#if __GNUC__ >= 4
#define LIBSSH_API __attribute__((visibility("default")))
#else
#define LIBSSH_API
#endif
#endif
#endif
#ifdef _MSC_VER
/* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
typedef unsigned long long uint64_t;
#else /* _MSC_VER */
//visual studio hasn't inttypes.h so it doesn't know uint32_t
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
typedef unsigned long long uint64_t;
#include <unistd.h>
#include <inttypes.h>
#endif /* _MSC_VER */
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/select.h> /* for fd_set * */
#include <netdb.h>
#include <winsock2.h>
#else /* _WIN32 */
#include <sys/select.h> /* for fd_set * */
#include <netdb.h>
#endif /* _WIN32 */
#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
@ -182,11 +208,11 @@ typedef int socket_t;
#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
#define SSH_EOF -127 /* We have already a eof */
const char *ssh_get_error(void *error);
int ssh_get_error_code(void *error);
LIBSSH_API const char *ssh_get_error(void *error);
LIBSSH_API int ssh_get_error_code(void *error);
/* version checks */
const char *ssh_version(int req_version);
LIBSSH_API const char *ssh_version(int req_version);
/** \addtogroup ssh_log
* @{
@ -220,113 +246,113 @@ enum {
#define SSH_LOG_FUNCTIONS 4 // every function in and return
*/
/* log.c */
void ssh_log(SSH_SESSION *session, int prioriry, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
LIBSSH_API void ssh_log(SSH_SESSION *session, int prioriry, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
/* session.c */
SSH_SESSION *ssh_new(void);
socket_t ssh_get_fd(SSH_SESSION *session);
int ssh_get_version(SSH_SESSION *session);
int ssh_get_status(SSH_SESSION *session);
const char *ssh_get_disconnect_message(SSH_SESSION *session);
void ssh_set_options(SSH_SESSION *session, SSH_OPTIONS *options);
void ssh_set_fd_toread(SSH_SESSION *session);
void ssh_set_fd_towrite(SSH_SESSION *session);
void ssh_set_fd_except(SSH_SESSION *session);
void ssh_set_blocking(SSH_SESSION *session, int blocking);
void ssh_silent_disconnect(SSH_SESSION *session);
LIBSSH_API SSH_SESSION *ssh_new(void);
LIBSSH_API socket_t ssh_get_fd(SSH_SESSION *session);
LIBSSH_API int ssh_get_version(SSH_SESSION *session);
LIBSSH_API int ssh_get_status(SSH_SESSION *session);
LIBSSH_API const char *ssh_get_disconnect_message(SSH_SESSION *session);
LIBSSH_API void ssh_set_options(SSH_SESSION *session, SSH_OPTIONS *options);
LIBSSH_API void ssh_set_fd_toread(SSH_SESSION *session);
LIBSSH_API void ssh_set_fd_towrite(SSH_SESSION *session);
LIBSSH_API void ssh_set_fd_except(SSH_SESSION *session);
LIBSSH_API void ssh_set_blocking(SSH_SESSION *session, int blocking);
LIBSSH_API void ssh_silent_disconnect(SSH_SESSION *session);
/* client.c */
int ssh_connect(SSH_SESSION *session);
void ssh_disconnect(SSH_SESSION *session);
int ssh_service_request(SSH_SESSION *session, const char *service);
char *ssh_get_issue_banner(SSH_SESSION *session);
int ssh_get_openssh_version(ssh_session session);
LIBSSH_API int ssh_connect(SSH_SESSION *session);
LIBSSH_API void ssh_disconnect(SSH_SESSION *session);
LIBSSH_API int ssh_service_request(SSH_SESSION *session, const char *service);
LIBSSH_API char *ssh_get_issue_banner(SSH_SESSION *session);
LIBSSH_API int ssh_get_openssh_version(ssh_session session);
/* get copyright informations */
const char *ssh_copyright(void);
LIBSSH_API const char *ssh_copyright(void);
/* string.h */
/* You can use these functions, they won't change */
/* string_from_char returns a newly allocated string from a char *ptr */
ssh_string string_from_char(const char *what);
LIBSSH_API ssh_string string_from_char(const char *what);
/* it returns the string len in host byte orders. str->size is big endian warning ! */
size_t string_len(ssh_string str);
ssh_string string_new(size_t size);
LIBSSH_API size_t string_len(ssh_string str);
LIBSSH_API ssh_string string_new(size_t size);
/* string_fill copies the data in the string. */
int string_fill(ssh_string str, const void *data, size_t len);
LIBSSH_API int string_fill(ssh_string str, const void *data, size_t len);
/* returns a newly allocated char array with the str string and a final nul caracter */
char *string_to_char(ssh_string str);
ssh_string string_copy(ssh_string str);
LIBSSH_API char *string_to_char(ssh_string str);
LIBSSH_API ssh_string string_copy(ssh_string str);
/* burns the data inside a string */
void string_burn(ssh_string str);
void *string_data(ssh_string str);
void string_free(ssh_string str);
LIBSSH_API void string_burn(ssh_string str);
LIBSSH_API void *string_data(ssh_string str);
LIBSSH_API void string_free(ssh_string str);
/* useful for debug */
char *ssh_get_hexa(const unsigned char *what, size_t len);
void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
int ssh_get_random(void *where,int len,int strong);
LIBSSH_API char *ssh_get_hexa(const unsigned char *what, size_t len);
LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
LIBSSH_API int ssh_get_random(void *where,int len,int strong);
/* this one can be called by the client to see the hash of the public key before accepting it */
int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash);
void ssh_clean_pubkey_hash(unsigned char **hash);
ssh_string ssh_get_pubkey(SSH_SESSION *session);
LIBSSH_API int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash);
LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash);
LIBSSH_API ssh_string ssh_get_pubkey(SSH_SESSION *session);
/* in connect.c */
int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
fd_set *readfds, struct timeval *timeout);
void publickey_free(ssh_public_key key);
LIBSSH_API void publickey_free(ssh_public_key key);
/* in keyfiles.c */
ssh_private_key privatekey_from_file(SSH_SESSION *session, const char *filename,
LIBSSH_API ssh_private_key privatekey_from_file(SSH_SESSION *session, const char *filename,
int type, const char *passphrase);
ssh_string publickey_to_string(ssh_public_key key);
ssh_public_key publickey_from_privatekey(ssh_private_key prv);
void privatekey_free(ssh_private_key prv);
ssh_string publickey_from_file(SSH_SESSION *session, const char *filename,
LIBSSH_API ssh_string publickey_to_string(ssh_public_key key);
LIBSSH_API ssh_public_key publickey_from_privatekey(ssh_private_key prv);
LIBSSH_API void privatekey_free(ssh_private_key prv);
LIBSSH_API ssh_string publickey_from_file(SSH_SESSION *session, const char *filename,
int *type);
int ssh_is_server_known(SSH_SESSION *session);
int ssh_write_knownhost(SSH_SESSION *session);
LIBSSH_API int ssh_is_server_known(SSH_SESSION *session);
LIBSSH_API int ssh_write_knownhost(SSH_SESSION *session);
/* in channels.c */
ssh_channel channel_new(SSH_SESSION *session);
int channel_open_forward(ssh_channel channel, const char *remotehost,
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);
int channel_open_session(ssh_channel channel);
void channel_free(ssh_channel channel);
int channel_request_pty(ssh_channel channel);
int channel_request_pty_size(ssh_channel channel, const char *term,
LIBSSH_API int channel_open_session(ssh_channel channel);
LIBSSH_API void channel_free(ssh_channel channel);
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);
int channel_change_pty_size(ssh_channel channel,int cols,int rows);
int channel_request_shell(ssh_channel channel);
int channel_request_subsystem(ssh_channel channel, const char *system);
int channel_request_env(ssh_channel channel, const char *name, const char *value);
int channel_request_exec(ssh_channel channel, const char *cmd);
int channel_request_sftp(ssh_channel channel);
int channel_request_x11(ssh_channel channel, int single_connection, const char *protocol,
LIBSSH_API int channel_change_pty_size(ssh_channel channel,int cols,int rows);
LIBSSH_API int channel_request_shell(ssh_channel channel);
LIBSSH_API int channel_request_subsystem(ssh_channel channel, const char *system);
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_sftp(ssh_channel channel);
LIBSSH_API int channel_request_x11(ssh_channel channel, int single_connection, const char *protocol,
const char *cookie, int screen_number);
ssh_channel channel_accept_x11(ssh_channel channel, int timeout_ms);
int channel_write(ssh_channel channel, const void *data, uint32_t len);
int channel_send_eof(ssh_channel channel);
int channel_is_eof(ssh_channel channel);
int channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr);
int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count,
LIBSSH_API ssh_channel channel_accept_x11(ssh_channel channel, int timeout_ms);
LIBSSH_API int channel_write(ssh_channel channel, const void *data, uint32_t len);
LIBSSH_API int channel_send_eof(ssh_channel channel);
LIBSSH_API int channel_is_eof(ssh_channel channel);
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);
int channel_poll(ssh_channel channel, int is_stderr);
int channel_close(ssh_channel channel);
void channel_set_blocking(ssh_channel channel, int blocking);
int channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count,
LIBSSH_API int channel_poll(ssh_channel channel, int is_stderr);
LIBSSH_API int channel_close(ssh_channel channel);
LIBSSH_API void channel_set_blocking(ssh_channel channel, int blocking);
LIBSSH_API int channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count,
int is_stderr);
int channel_is_open(ssh_channel channel);
int channel_is_closed(ssh_channel channel);
int channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
LIBSSH_API int channel_is_open(ssh_channel channel);
LIBSSH_API int channel_is_closed(ssh_channel channel);
LIBSSH_API int channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
timeval * timeout);
SSH_SESSION *channel_get_session(ssh_channel channel);
int channel_get_exit_status(ssh_channel channel);
LIBSSH_API SSH_SESSION *channel_get_session(ssh_channel channel);
LIBSSH_API int channel_get_exit_status(ssh_channel channel);
/* in options.c */
/**
@ -345,31 +371,31 @@ int channel_get_exit_status(ssh_channel channel);
typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
int echo, int verify, void *userdata);
SSH_OPTIONS *ssh_options_new(void);
SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt);
void ssh_options_free(SSH_OPTIONS *opt);
int ssh_options_set_wanted_algos(SSH_OPTIONS *opt, int algo, const char *list);
int ssh_options_set_username(SSH_OPTIONS *opt, const char *username);
int ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port);
int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv);
int ssh_options_set_host(SSH_OPTIONS *opt, const char *host);
int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd);
int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port);
int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir);
int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir);
int ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity);
int ssh_options_set_banner(SSH_OPTIONS *opt, const char *banner);
int ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback)
LIBSSH_API SSH_OPTIONS *ssh_options_new(void);
LIBSSH_API SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt);
LIBSSH_API void ssh_options_free(SSH_OPTIONS *opt);
LIBSSH_API int ssh_options_set_wanted_algos(SSH_OPTIONS *opt, int algo, const char *list);
LIBSSH_API int ssh_options_set_username(SSH_OPTIONS *opt, const char *username);
LIBSSH_API int ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port);
LIBSSH_API int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv);
LIBSSH_API int ssh_options_set_host(SSH_OPTIONS *opt, const char *host);
LIBSSH_API int ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd);
LIBSSH_API int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port);
LIBSSH_API int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir);
LIBSSH_API int ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir);
LIBSSH_API int ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity);
LIBSSH_API int ssh_options_set_banner(SSH_OPTIONS *opt, const char *banner);
LIBSSH_API int ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback)
(void *arg, float status), void *arg);
int ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec);
int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow);
int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
int ssh_options_set_log_function(SSH_OPTIONS *opt,
LIBSSH_API int ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec);
LIBSSH_API int ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow);
LIBSSH_API int ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
LIBSSH_API int ssh_options_set_log_function(SSH_OPTIONS *opt,
void (*callback)(const char *message, SSH_SESSION *session, int verbosity));
int ssh_options_set_log_verbosity(SSH_OPTIONS *opt, int verbosity);
int ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey);
int ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey);
int ssh_options_set_auth_callback(SSH_OPTIONS *opt, ssh_auth_callback cb,
LIBSSH_API int ssh_options_set_log_verbosity(SSH_OPTIONS *opt, int verbosity);
LIBSSH_API int ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey);
LIBSSH_API int ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey);
LIBSSH_API int ssh_options_set_auth_callback(SSH_OPTIONS *opt, ssh_auth_callback cb,
void *userdata);
@ -377,52 +403,54 @@ int ssh_options_set_auth_callback(SSH_OPTIONS *opt, ssh_auth_callback cb,
/** creates a new buffer
*/
ssh_buffer buffer_new(void);
void buffer_free(ssh_buffer buffer);
LIBSSH_API ssh_buffer buffer_new(void);
LIBSSH_API void buffer_free(ssh_buffer buffer);
/* buffer_get returns a pointer to the begining of the buffer. no position is taken into account */
void *buffer_get(ssh_buffer buffer);
LIBSSH_API void *buffer_get(ssh_buffer buffer);
/* same here */
/* FIXME should be size_t */
uint32_t buffer_get_len(ssh_buffer buffer);
LIBSSH_API uint32_t buffer_get_len(ssh_buffer buffer);
/* in auth.c */
int ssh_auth_list(SSH_SESSION *session);
LIBSSH_API int ssh_auth_list(SSH_SESSION *session);
/* these functions returns AUTH_ERROR is some serious error has happened,
AUTH_SUCCESS if success,
AUTH_PARTIAL if partial success,
AUTH_DENIED if refused */
int ssh_userauth_list(SSH_SESSION *session, const char *username);
int ssh_userauth_none(SSH_SESSION *session, const char *username);
int ssh_userauth_password(SSH_SESSION *session, const char *username, const char *password);
int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username, int type, ssh_string publickey);
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username, ssh_string publickey, ssh_private_key privatekey);
int ssh_userauth_agent_pubkey(SSH_SESSION *session, const char *username,
LIBSSH_API int ssh_userauth_list(SSH_SESSION *session, const char *username);
LIBSSH_API int ssh_userauth_none(SSH_SESSION *session, const char *username);
LIBSSH_API int ssh_userauth_password(SSH_SESSION *session, const char *username, const char *password);
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);
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase);
int ssh_userauth_kbdint(SSH_SESSION *session, const char *user, const char *submethods);
int ssh_userauth_kbdint_getnprompts(SSH_SESSION *session);
const char *ssh_userauth_kbdint_getname(SSH_SESSION *session);
const char *ssh_userauth_kbdint_getinstruction(SSH_SESSION *session);
const char *ssh_userauth_kbdint_getprompt(SSH_SESSION *session, unsigned int i, char *echo);
int ssh_userauth_kbdint_setanswer(SSH_SESSION *session, unsigned int i,
#endif
LIBSSH_API int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase);
LIBSSH_API int ssh_userauth_kbdint(SSH_SESSION *session, const char *user, const char *submethods);
LIBSSH_API int ssh_userauth_kbdint_getnprompts(SSH_SESSION *session);
LIBSSH_API const char *ssh_userauth_kbdint_getname(SSH_SESSION *session);
LIBSSH_API const char *ssh_userauth_kbdint_getinstruction(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_setanswer(SSH_SESSION *session, unsigned int i,
const char *answer);
/* init.c */
int ssh_init(void);
int ssh_finalize(void);
LIBSSH_API int ssh_init(void);
LIBSSH_API int ssh_finalize(void);
/* messages.c */
typedef struct ssh_message SSH_MESSAGE;
SSH_MESSAGE *ssh_message_retrieve(SSH_SESSION *session, uint32_t packettype);
SSH_MESSAGE *ssh_message_get(SSH_SESSION *session);
int ssh_message_type(SSH_MESSAGE *msg);
int ssh_message_subtype(SSH_MESSAGE *msg);
void ssh_message_free(SSH_MESSAGE *msg);
LIBSSH_API SSH_MESSAGE *ssh_message_retrieve(SSH_SESSION *session, uint32_t packettype);
LIBSSH_API SSH_MESSAGE *ssh_message_get(SSH_SESSION *session);
LIBSSH_API int ssh_message_type(SSH_MESSAGE *msg);
LIBSSH_API int ssh_message_subtype(SSH_MESSAGE *msg);
LIBSSH_API void ssh_message_free(SSH_MESSAGE *msg);
ssh_channel ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg);
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);
/* scp.c */
enum {
@ -432,12 +460,12 @@ enum {
SSH_SCP_READ
};
ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location);
int ssh_scp_init(ssh_scp scp);
int ssh_scp_close(ssh_scp scp);
void ssh_scp_free(ssh_scp scp);
int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, const char *perms);
int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location);
LIBSSH_API int ssh_scp_init(ssh_scp scp);
LIBSSH_API int ssh_scp_close(ssh_scp scp);
LIBSSH_API void ssh_scp_free(ssh_scp scp);
LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, const char *perms);
LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
#ifdef __cplusplus
}

Просмотреть файл

@ -152,13 +152,25 @@ typedef struct pollfd_s {
} pollfd_t;
/* poll.c */
#define POLLIN 0x001 /* There is data to read. */
#ifndef POLLIN
# define POLLIN 0x001 /* There is data to read. */
#endif
#ifndef POLLPRI
#define POLLPRI 0x002 /* There is urgent data to read. */
#endif
#ifndef POLLOUT
#define POLLOUT 0x004 /* Writing now will not block. */
#endif
#ifndef POLLERR
#define POLLERR 0x008 /* Error condition. */
#endif
#ifndef POLLHUP
#define POLLHUP 0x010 /* Hung up. */
#endif
#ifndef POLLNVAL
#define POLLNVAL 0x020 /* Invalid polling request. */
#endif
typedef unsigned long int nfds_t;
#endif /* HAVE_POLL */

Просмотреть файл

@ -42,7 +42,7 @@ typedef struct ssh_bind_struct SSH_BIND;
*
* @return A newly allocated ssh_bind session pointer.
*/
SSH_BIND *ssh_bind_new(void);
LIBSSH_API SSH_BIND *ssh_bind_new(void);
/**
* @brief Set the opitons for the current SSH server bind.
@ -51,7 +51,7 @@ SSH_BIND *ssh_bind_new(void);
*
* @param options The option structure to set.
*/
void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options);
LIBSSH_API void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options);
/**
* @brief Start listening to the socket.
@ -60,7 +60,7 @@ void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options);
*
* @return 0 on success, < 0 on error.
*/
int ssh_bind_listen(SSH_BIND *ssh_bind);
LIBSSH_API int ssh_bind_listen(SSH_BIND *ssh_bind);
/**
* @brief Set the session to blocking/nonblocking mode.
@ -69,7 +69,7 @@ int ssh_bind_listen(SSH_BIND *ssh_bind);
*
* @param blocking Zero for nonblocking mode.
*/
void ssh_bind_set_blocking(SSH_BIND *ssh_bind, int blocking);
LIBSSH_API void ssh_bind_set_blocking(SSH_BIND *ssh_bind, int blocking);
/**
* @brief Recover the file descriptor from the session.
@ -78,7 +78,7 @@ void ssh_bind_set_blocking(SSH_BIND *ssh_bind, int blocking);
*
* @return The file descriptor.
*/
socket_t ssh_bind_get_fd(SSH_BIND *ssh_bind);
LIBSSH_API socket_t ssh_bind_get_fd(SSH_BIND *ssh_bind);
/**
* @brief Set the file descriptor for a session.
@ -87,14 +87,14 @@ socket_t ssh_bind_get_fd(SSH_BIND *ssh_bind);
*
* @param fd The file descriptor.
*/
void ssh_bind_set_fd(SSH_BIND *ssh_bind, socket_t fd);
LIBSSH_API void ssh_bind_set_fd(SSH_BIND *ssh_bind, socket_t fd);
/**
* @brief Allow the file descriptor to accept new sessions.
*
* @param ssh_bind The ssh server bind to use.
*/
void ssh_bind_fd_toaccept(SSH_BIND *ssh_bind);
LIBSSH_API void ssh_bind_fd_toaccept(SSH_BIND *ssh_bind);
/**
* @brief Accept an incoming ssh connection and initialize the session.
@ -103,14 +103,14 @@ void ssh_bind_fd_toaccept(SSH_BIND *ssh_bind);
*
* @return A newly allocated ssh session, NULL on error.
*/
SSH_SESSION *ssh_bind_accept(SSH_BIND *ssh_bind);
LIBSSH_API SSH_SESSION *ssh_bind_accept(SSH_BIND *ssh_bind);
/**
* @brief Free a ssh servers bind.
*
* @param ssh_bind The ssh server bind to free.
*/
void ssh_bind_free(SSH_BIND *ssh_bind);
LIBSSH_API void ssh_bind_free(SSH_BIND *ssh_bind);
/**
* @brief Exchange the banner and cryptographic keys.
@ -119,45 +119,45 @@ void ssh_bind_free(SSH_BIND *ssh_bind);
*
* @return 0 on success, < 0 on error.
*/
int ssh_accept(SSH_SESSION *session);
LIBSSH_API int ssh_accept(SSH_SESSION *session);
int channel_write_stderr(ssh_channel channel, const void *data, uint32_t len);
LIBSSH_API int channel_write_stderr(ssh_channel channel, const void *data, uint32_t len);
/* messages.c */
int ssh_message_reply_default(SSH_MESSAGE *msg);
LIBSSH_API int ssh_message_reply_default(SSH_MESSAGE *msg);
char *ssh_message_auth_user(SSH_MESSAGE *msg);
char *ssh_message_auth_password(SSH_MESSAGE *msg);
ssh_public_key ssh_message_auth_publickey(SSH_MESSAGE *msg);
int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial);
int ssh_message_auth_reply_pk_ok(SSH_MESSAGE *msg, ssh_string algo, ssh_string pubkey);
int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
LIBSSH_API char *ssh_message_auth_user(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_auth_password(SSH_MESSAGE *msg);
LIBSSH_API ssh_public_key ssh_message_auth_publickey(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_set_methods(SSH_MESSAGE *msg, int methods);
int ssh_message_service_reply_success(SSH_MESSAGE *msg);
char *ssh_message_service_service(SSH_MESSAGE *msg);
LIBSSH_API int ssh_message_service_reply_success(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_service_service(SSH_MESSAGE *msg);
void ssh_set_message_callback(SSH_SESSION *session,
LIBSSH_API void ssh_set_message_callback(SSH_SESSION *session,
int(*ssh_message_callback)(ssh_session session, struct ssh_message *msg));
char *ssh_message_channel_request_open_originator(SSH_MESSAGE *msg);
int ssh_message_channel_request_open_originator_port(SSH_MESSAGE *msg);
char *ssh_message_channel_request_open_destination(SSH_MESSAGE *msg);
int ssh_message_channel_request_open_destination_port(SSH_MESSAGE *msg);
LIBSSH_API 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 char *ssh_message_channel_request_open_destination(SSH_MESSAGE *msg);
LIBSSH_API int ssh_message_channel_request_open_destination_port(SSH_MESSAGE *msg);
ssh_channel ssh_message_channel_request_channel(SSH_MESSAGE *msg);
LIBSSH_API ssh_channel ssh_message_channel_request_channel(SSH_MESSAGE *msg);
char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg);
int ssh_message_channel_request_pty_width(SSH_MESSAGE *msg);
int ssh_message_channel_request_pty_height(SSH_MESSAGE *msg);
int ssh_message_channel_request_pty_pxwidth(SSH_MESSAGE *msg);
int ssh_message_channel_request_pty_pxheight(SSH_MESSAGE *msg);
LIBSSH_API 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);
char *ssh_message_channel_request_env_name(SSH_MESSAGE *msg);
char *ssh_message_channel_request_env_value(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_channel_request_env_name(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_channel_request_env_value(SSH_MESSAGE *msg);
char *ssh_message_channel_request_command(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_channel_request_command(SSH_MESSAGE *msg);
char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg);
#ifdef __cplusplus
}

Просмотреть файл

@ -183,14 +183,14 @@ typedef struct sftp_attributes{
*
* @return A new sftp session or NULL on error.
*/
SFTP_SESSION *sftp_new(SSH_SESSION *session);
LIBSSH_API SFTP_SESSION *sftp_new(SSH_SESSION *session);
/**
* @brief Close and deallocate a sftp session.
*
* @param sftp The sftp session handle to free.
*/
void sftp_free(SFTP_SESSION *sftp);
LIBSSH_API void sftp_free(SFTP_SESSION *sftp);
/**
* @brief Initialize the sftp session with the server.
@ -199,7 +199,7 @@ void sftp_free(SFTP_SESSION *sftp);
*
* @return 0 on success, < 0 on error with ssh error set.
*/
int sftp_init(SFTP_SESSION *sftp);
LIBSSH_API int sftp_init(SFTP_SESSION *sftp);
/**
* @brief Get the last sftp error.
@ -211,7 +211,7 @@ int sftp_init(SFTP_SESSION *sftp);
* @return The saved error (see server responses), < 0 if an error
* in the function occured.
*/
int sftp_get_error(SFTP_SESSION *sftp);
LIBSSH_API int sftp_get_error(SFTP_SESSION *sftp);
/**
* @brief Get the count of extensions provided by the server.
@ -221,7 +221,7 @@ int sftp_get_error(SFTP_SESSION *sftp);
* @return The count of extensions provided by the server, 0 on error or
* not available.
*/
unsigned int sftp_extensions_get_count(SFTP_SESSION *sftp);
LIBSSH_API unsigned int sftp_extensions_get_count(SFTP_SESSION *sftp);
/**
* @brief Get the name of the extension provided by the server.
@ -232,7 +232,7 @@ unsigned int sftp_extensions_get_count(SFTP_SESSION *sftp);
*
* @return The name of the extension.
*/
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 index);
/**
* @brief Get the data of the extension provided by the server.
@ -245,7 +245,7 @@ const char *sftp_extensions_get_name(SFTP_SESSION *sftp, unsigned int index);
*
* @return The data of the extension.
*/
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 index);
/**
* @brief Open a directory used to obtain directory entries.
@ -259,7 +259,7 @@ const char *sftp_extensions_get_data(SFTP_SESSION *sftp, unsigned int index);
* @see sftp_readdir
* @see sftp_closedir
*/
SFTP_DIR *sftp_opendir(SFTP_SESSION *session, const char *path);
LIBSSH_API SFTP_DIR *sftp_opendir(SFTP_SESSION *session, const char *path);
/**
* @brief Get a single file attributes structure of a directory.
@ -274,7 +274,7 @@ SFTP_DIR *sftp_opendir(SFTP_SESSION *session, const char *path);
* @see sftp_attribute_free()
* @see sftp_closedir()
*/
SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *session, SFTP_DIR *dir);
LIBSSH_API SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *session, SFTP_DIR *dir);
/**
* @brief Tell if the directory has reached EOF (End Of File).
@ -285,7 +285,7 @@ SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *session, SFTP_DIR *dir);
*
* @see sftp_readdir()
*/
int sftp_dir_eof(SFTP_DIR *dir);
LIBSSH_API int sftp_dir_eof(SFTP_DIR *dir);
/**
* @brief Get information about a file or directory.
@ -297,7 +297,7 @@ int sftp_dir_eof(SFTP_DIR *dir);
* @return The sftp attributes structure of the file or directory,
* NULL on error with ssh and sftp error set.
*/
SFTP_ATTRIBUTES *sftp_stat(SFTP_SESSION *session, const char *path);
LIBSSH_API SFTP_ATTRIBUTES *sftp_stat(SFTP_SESSION *session, const char *path);
/**
* @brief Get information about a file or directory.
@ -312,7 +312,7 @@ SFTP_ATTRIBUTES *sftp_stat(SFTP_SESSION *session, const char *path);
* @return The sftp attributes structure of the file or directory,
* NULL on error with ssh and sftp error set.
*/
SFTP_ATTRIBUTES *sftp_lstat(SFTP_SESSION *session, const char *path);
LIBSSH_API SFTP_ATTRIBUTES *sftp_lstat(SFTP_SESSION *session, const char *path);
/**
* @brief Get information about a file or directory from a file handle.
@ -322,14 +322,14 @@ SFTP_ATTRIBUTES *sftp_lstat(SFTP_SESSION *session, const char *path);
* @return The sftp attributes structure of the file or directory,
* NULL on error with ssh and sftp error set.
*/
SFTP_ATTRIBUTES *sftp_fstat(SFTP_FILE *file);
LIBSSH_API SFTP_ATTRIBUTES *sftp_fstat(SFTP_FILE *file);
/**
* @brief Free a sftp attribute structure.
*
* @param file The sftp attribute structure to free.
*/
void sftp_attributes_free(SFTP_ATTRIBUTES *file);
LIBSSH_API void sftp_attributes_free(SFTP_ATTRIBUTES *file);
/**
* @brief Close a directory handle opened by sftp_opendir().
@ -338,12 +338,12 @@ void sftp_attributes_free(SFTP_ATTRIBUTES *file);
*
* @return Returns SSH_NO_ERROR or SSH_ERROR if an error occured.
*/
int sftp_closedir(SFTP_DIR *dir);
LIBSSH_API int sftp_closedir(SFTP_DIR *dir);
/**
* @deprecated Use sftp_closedir() instead.
*/
int sftp_dir_close(SFTP_DIR *dir) SFTP_DEPRECATED;
LIBSSH_API int sftp_dir_close(SFTP_DIR *dir) SFTP_DEPRECATED;
/**
* @brief Close an open file handle.
@ -354,12 +354,12 @@ int sftp_dir_close(SFTP_DIR *dir) SFTP_DEPRECATED;
*
* @see sftp_open()
*/
int sftp_close(SFTP_FILE *file);
LIBSSH_API int sftp_close(SFTP_FILE *file);
/**
* @deprecated Use sftp_close() instead.
*/
int sftp_file_close(SFTP_FILE *file) SFTP_DEPRECATED;
LIBSSH_API int sftp_file_close(SFTP_FILE *file) SFTP_DEPRECATED;
/**
* @brief Open a file on the server.
@ -387,12 +387,12 @@ int sftp_file_close(SFTP_FILE *file) SFTP_DEPRECATED;
* @return A sftp file handle, NULL on error with ssh and sftp
* error set.
*/
SFTP_FILE *sftp_open(SFTP_SESSION *session, const char *file, int flags,
LIBSSH_API SFTP_FILE *sftp_open(SFTP_SESSION *session, const char *file, int flags,
mode_t mode);
void sftp_file_set_nonblocking(SFTP_FILE *handle);
LIBSSH_API void sftp_file_set_nonblocking(SFTP_FILE *handle);
void sftp_file_set_blocking(SFTP_FILE *handle);
LIBSSH_API void sftp_file_set_blocking(SFTP_FILE *handle);
/**
* @brief Read from a file using an opened sftp file handle.
@ -406,7 +406,7 @@ void sftp_file_set_blocking(SFTP_FILE *handle);
* @return Number of bytes written, < 0 on error with ssh and sftp
* error set.
*/
ssize_t sftp_read(SFTP_FILE *file, void *buf, size_t count);
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.
@ -439,7 +439,7 @@ ssize_t sftp_read(SFTP_FILE *file, void *buf, size_t count);
* @see sftp_async_read()
* @see sftp_open()
*/
int sftp_async_read_begin(SFTP_FILE *file, uint32_t len);
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.
@ -464,7 +464,7 @@ int sftp_async_read_begin(SFTP_FILE *file, uint32_t len);
*
* @see sftp_async_read_begin()
*/
int sftp_async_read(SFTP_FILE *file, void *data, uint32_t len, uint32_t id);
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.
@ -482,7 +482,7 @@ int sftp_async_read(SFTP_FILE *file, void *data, uint32_t len, uint32_t id);
* @see sftp_read()
* @see sftp_close()
*/
ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count);
LIBSSH_API ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count);
/**
* @brief Seek to a specific location in a file.
@ -493,7 +493,7 @@ ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count);
*
* @return 0 on success, < 0 on error.
*/
int sftp_seek(SFTP_FILE *file, uint32_t new_offset);
LIBSSH_API int sftp_seek(SFTP_FILE *file, uint32_t new_offset);
/**
* @brief Seek to a specific location in a file. This is the
@ -505,7 +505,7 @@ int sftp_seek(SFTP_FILE *file, uint32_t new_offset);
*
* @return 0 on success, < 0 on error.
*/
int sftp_seek64(SFTP_FILE *file, uint64_t new_offset);
LIBSSH_API int sftp_seek64(SFTP_FILE *file, uint64_t new_offset);
/**
* @brief Report current byte position in file.
@ -516,7 +516,7 @@ int sftp_seek64(SFTP_FILE *file, uint64_t new_offset);
* of the file associated with the file descriptor. < 0 on
* error.
*/
unsigned long sftp_tell(SFTP_FILE *file);
LIBSSH_API unsigned long sftp_tell(SFTP_FILE *file);
/**
* @brief Report current byte position in file.
@ -527,7 +527,7 @@ unsigned long sftp_tell(SFTP_FILE *file);
* of the file associated with the file descriptor. < 0 on
* error.
*/
uint64_t sftp_tell64(SFTP_FILE *file);
LIBSSH_API uint64_t sftp_tell64(SFTP_FILE *file);
/**
* @brief Rewinds the position of the file pointer to the beginning of the
@ -535,12 +535,12 @@ uint64_t sftp_tell64(SFTP_FILE *file);
*
* @param file Open sftp file handle.
*/
void sftp_rewind(SFTP_FILE *file);
LIBSSH_API void sftp_rewind(SFTP_FILE *file);
/**
* @deprecated Use sftp_unlink() instead.
*/
int sftp_rm(SFTP_SESSION *sftp, const char *file) SFTP_DEPRECATED;
LIBSSH_API int sftp_rm(SFTP_SESSION *sftp, const char *file) SFTP_DEPRECATED;
/**
* @brief Unlink (delete) a file.
@ -551,7 +551,7 @@ int sftp_rm(SFTP_SESSION *sftp, const char *file) SFTP_DEPRECATED;
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
int sftp_unlink(SFTP_SESSION *sftp, const char *file);
LIBSSH_API int sftp_unlink(SFTP_SESSION *sftp, const char *file);
/**
* @brief Remove a directoy.
@ -562,7 +562,7 @@ int sftp_unlink(SFTP_SESSION *sftp, const char *file);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
int sftp_rmdir(SFTP_SESSION *sftp, const char *directory);
LIBSSH_API int sftp_rmdir(SFTP_SESSION *sftp, const char *directory);
/**
* @brief Create a directory.
@ -577,7 +577,7 @@ int sftp_rmdir(SFTP_SESSION *sftp, const char *directory);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode);
LIBSSH_API int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode);
/**
* @brief Rename or move a file or directory.
@ -592,7 +592,7 @@ int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname);
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.
@ -606,7 +606,7 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr);
LIBSSH_API int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr);
/**
* @brief Change the file owner and group
@ -621,7 +621,7 @@ int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
int sftp_chown(SFTP_SESSION *sftp, const char *file, uid_t owner, gid_t group);
LIBSSH_API int sftp_chown(SFTP_SESSION *sftp, const char *file, uid_t owner, gid_t group);
/**
* @brief Change permissions of a file
@ -636,7 +636,7 @@ int sftp_chown(SFTP_SESSION *sftp, const char *file, uid_t owner, gid_t group);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
int sftp_chmod(SFTP_SESSION *sftp, const char *file, mode_t mode);
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.
@ -650,7 +650,7 @@ int sftp_chmod(SFTP_SESSION *sftp, const char *file, mode_t mode);
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
int sftp_utimes(SFTP_SESSION *sftp, const char *file, const struct timeval *times);
LIBSSH_API int sftp_utimes(SFTP_SESSION *sftp, const char *file, const struct timeval *times);
/**
* @brief Create a symbolic link.
@ -663,7 +663,7 @@ int sftp_utimes(SFTP_SESSION *sftp, const char *file, const struct timeval *time
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
int sftp_symlink(SFTP_SESSION *sftp, const char *target, const char *dest);
LIBSSH_API int sftp_symlink(SFTP_SESSION *sftp, const char *target, const char *dest);
/**
* @brief Read the value of a symbolic link.
@ -674,7 +674,7 @@ int sftp_symlink(SFTP_SESSION *sftp, const char *target, const char *dest);
*
* @return The target of the link, NULL on error.
*/
char *sftp_readlink(SFTP_SESSION *sftp, const char *path);
LIBSSH_API char *sftp_readlink(SFTP_SESSION *sftp, const char *path);
/**
* @brief Canonicalize a sftp path.
@ -685,7 +685,7 @@ char *sftp_readlink(SFTP_SESSION *sftp, const char *path);
*
* @return The canonicalize path, NULL on error.
*/
char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path);
LIBSSH_API char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path);
/**
* @brief Get the version of the SFTP protocol supported by the server
@ -694,7 +694,7 @@ char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path);
*
* @return The server version.
*/
int sftp_server_version(SFTP_SESSION *sftp);
LIBSSH_API int sftp_server_version(SFTP_SESSION *sftp);
#ifdef WITH_SERVER
/**
@ -706,7 +706,7 @@ int sftp_server_version(SFTP_SESSION *sftp);
*
* @return A new sftp server session.
*/
SFTP_SESSION *sftp_server_new(SSH_SESSION *session, ssh_channel chan);
LIBSSH_API SFTP_SESSION *sftp_server_new(SSH_SESSION *session, ssh_channel chan);
/**
* @brief Intialize the sftp server.
@ -715,7 +715,7 @@ SFTP_SESSION *sftp_server_new(SSH_SESSION *session, ssh_channel chan);
*
* @return 0 on success, < 0 on error.
*/
int sftp_server_init(SFTP_SESSION *sftp);
LIBSSH_API int sftp_server_init(SFTP_SESSION *sftp);
#endif /* WITH_SERVER */
/* this is not a public interface */

Просмотреть файл

@ -73,6 +73,9 @@ if (GCRYPT_LIBRARY)
)
endif (GCRYPT_LIBRARY)
if (WITH_VISIBILITY_HIDDEN)
set(LIBSSH_SHARED_CFLAGS "-fvisibility=hidden")
endif (WITH_VISIBILITY_HIDDEN)
set(libssh_SRCS
agent.c
@ -104,7 +107,6 @@ set(libssh_SRCS
socket.c
string.c
wrapper.c
libssh.map
)
if (WITH_SFTP)
@ -136,13 +138,6 @@ if (WITH_SERVER)
)
endif (WITH_SERVER)
if (MSVC)
set(libssh_SRCS
${libssh_SRCS}
libssh.def
)
endif (MSVC)
include_directories(
${LIBSSH_PUBLIC_INCLUDE_DIRS}
${LIBSSH_PRIVATE_INCLUDE_DIRS}
@ -161,31 +156,24 @@ set_target_properties(
${LIBRARY_SOVERSION}
OUTPUT_NAME
ssh
DEFINE_SYMBOL
LIBSSH_EXPORTS
COMPILE_FLAGS
${LIBSSH_SHARED_CFLAGS}
)
if (UNIX AND CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set_target_properties(
${LIBSSH_SHARED_LIBRARY}
PROPERTIES
LINK_FLAGS
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libssh.map
)
endif (UNIX AND CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
install(
TARGETS
${LIBSSH_SHARED_LIBRARY}
DESTINATION
${LIB_INSTALL_DIR}
COMPONENT
libraries
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
COMPONENT libraries
)
if (WITH_STATIC_LIB)
add_library(${LIBSSH_STATIC_LIBRARY} STATIC ${libssh_SRCS})
target_link_libraries(${LIBSSH_STATIC_LIBRARY} ${LIBSSH_LINK_LIBRARIES})
set_target_properties(
${LIBSSH_STATIC_LIBRARY}
PROPERTIES
@ -193,8 +181,8 @@ if (WITH_STATIC_LIB)
${LIBRARY_VERSION}
SOVERSION
${LIBRARY_SOVERSION}
OUTPUT_NAME
ssh
COMPILE_FLAGS
"-DLIBSSH_STATIC"
)
install(

Просмотреть файл

@ -1335,6 +1335,7 @@ error:
return rc;
}
#ifndef _WIN32
/**
* @brief Accept an X11 forwarding channel.
*
@ -1372,6 +1373,7 @@ ssh_channel channel_accept_x11(ssh_channel channel, int timeout_ms) {
return NULL;
}
#endif
/**
* @brief Set environement variables.

Просмотреть файл

@ -1,208 +0,0 @@
LIBRARY libssh
EXPORTS
buffer_free
buffer_get
buffer_get_len
buffer_new
channel_change_pty_size
channel_close
channel_free
channel_get_exit_status
channel_get_session
channel_is_closed
channel_is_eof
channel_is_open
channel_new
channel_open_forward
channel_open_session
channel_poll
channel_read
channel_read_buffer
channel_read_nonblocking
channel_request_env
channel_request_exec
channel_request_pty
channel_request_pty_size
channel_request_sftp
channel_request_shell
channel_request_subsystem
channel_request_x11
channel_accept_x11
channel_select
channel_send_eof
channel_set_blocking
channel_write
channel_write_stderr
privatekey_free
privatekey_from_file
publickey_free
publickey_from_file
publickey_from_privatekey
publickey_to_string
sftp_async_read
sftp_async_read_begin
sftp_attributes_free
sftp_canonicalize_path
sftp_chmod
sftp_chown
sftp_close
sftp_closedir
sftp_dir_eof
sftp_extensions_get_count
sftp_extensions_get_data
sftp_extensions_get_name
sftp_file_set_blocking
sftp_file_set_nonblocking
sftp_free
sftp_fstat
sftp_get_error
sftp_init
sftp_lstat
sftp_mkdir
sftp_new
sftp_open
sftp_opendir
sftp_read
sftp_readdir
sftp_readlink
sftp_rename
sftp_rewind
sftp_rmdir
sftp_seek
sftp_seek64
sftp_server_init
sftp_server_new
sftp_server_version
sftp_setstat
sftp_stat
sftp_symlink
sftp_tell
sftp_tell64
sftp_unlink
sftp_utimes
sftp_write
ssh_accept
ssh_auth_list
ssh_bind_accept
ssh_bind_fd_toaccept
ssh_bind_free
ssh_bind_get_fd
ssh_bind_listen
ssh_bind_new
ssh_bind_set_blocking
ssh_bind_set_fd
ssh_bind_set_options
ssh_clean_pubkey_hash
ssh_connect
ssh_copyright
ssh_disconnect
ssh_finalize
ssh_get_disconnect_message
ssh_get_error
ssh_get_error_code
ssh_get_fd
ssh_get_hexa
ssh_get_issue_banner
ssh_get_openssh_version
ssh_get_pubkey
ssh_get_pubkey_hash
ssh_get_random
ssh_get_status
ssh_get_version
ssh_init
ssh_is_server_known
ssh_log
ssh_message_auth_password
ssh_message_auth_publickey
ssh_message_auth_reply_pk_ok
ssh_message_auth_reply_success
ssh_message_auth_set_methods
ssh_message_auth_user
ssh_message_channel_request_channel
ssh_message_channel_request_command
ssh_message_channel_request_env_name
ssh_message_channel_request_env_value
ssh_message_channel_request_open_destination
ssh_message_channel_request_open_destination_port
ssh_message_channel_request_open_originator
ssh_message_channel_request_open_originator_port
ssh_message_channel_request_open_reply_accept
ssh_message_channel_request_pty_height
ssh_message_channel_request_pty_pxheight
ssh_message_channel_request_pty_pxwidth
ssh_message_channel_request_pty_term
ssh_message_channel_request_pty_width
ssh_message_channel_request_reply_success
ssh_message_channel_request_subsystem
ssh_message_free
ssh_message_get
ssh_message_reply_default
ssh_message_retrieve
ssh_message_service_reply_success
ssh_message_service_service
ssh_message_subtype
ssh_message_type
ssh_new
ssh_options_allow_ssh1
ssh_options_allow_ssh2
ssh_options_copy
ssh_options_free
ssh_options_getopt
ssh_options_new
ssh_options_set_auth_callback
ssh_options_set_banner
ssh_options_set_bind
ssh_options_set_dsa_server_key
ssh_options_set_fd
ssh_options_set_host
ssh_options_set_identity
ssh_options_set_known_hosts_file
ssh_options_set_log_function
ssh_options_set_log_verbosity
ssh_options_set_port
ssh_options_set_rsa_server_key
ssh_options_set_ssh_dir
ssh_options_set_status_callback
ssh_options_set_timeout
ssh_options_set_username
ssh_options_set_wanted_algos
ssh_print_hexa
ssh_scp_close
ssh_scp_free
ssh_scp_init
ssh_scp_new
ssh_scp_push_file
ssh_scp_write
ssh_select
ssh_service_request
ssh_set_blocking
ssh_set_fd_except
ssh_set_fd_toread
ssh_set_fd_towrite
ssh_set_message_callback
ssh_set_options
ssh_silent_disconnect
ssh_userauth_agent_pubkey
ssh_userauth_autopubkey
ssh_userauth_kbdint
ssh_userauth_kbdint_getinstruction
ssh_userauth_kbdint_getname
ssh_userauth_kbdint_getnprompts
ssh_userauth_kbdint_getprompt
ssh_userauth_kbdint_setanswer
ssh_userauth_list
ssh_userauth_none
ssh_userauth_offer_pubkey
ssh_userauth_password
ssh_userauth_pubkey
ssh_version
ssh_write_knownhost
string_burn
string_copy
string_data
string_fill
string_free
string_from_char
string_len
string_new
string_to_char

Просмотреть файл

@ -1,215 +0,0 @@
SSH_0.3 {
global:
buffer_free;
buffer_get;
buffer_get_len;
buffer_new;
channel_change_pty_size;
channel_close;
channel_free;
channel_get_exit_status;
channel_get_session;
channel_is_closed;
channel_is_eof;
channel_is_open;
channel_new;
channel_open_forward;
channel_open_session;
channel_poll;
channel_read;
channel_read_buffer;
channel_read_nonblocking;
channel_request_env;
channel_request_exec;
channel_request_pty;
channel_request_pty_size;
channel_request_sftp;
channel_request_shell;
channel_request_subsystem;
channel_select;
channel_send_eof;
channel_set_blocking;
channel_write;
privatekey_free;
privatekey_from_file;
publickey_free;
publickey_from_file;
publickey_from_privatekey;
publickey_to_string;
sftp_async_read;
sftp_async_read_begin;
sftp_attributes_free;
sftp_canonicalize_path;
sftp_chmod;
sftp_chown;
sftp_close;
sftp_closedir;
sftp_dir_eof;
sftp_file_set_blocking;
sftp_file_set_nonblocking;
sftp_free;
sftp_fstat;
sftp_get_error;
sftp_init;
sftp_lstat;
sftp_mkdir;
sftp_new;
sftp_open;
sftp_opendir;
sftp_read;
sftp_readdir;
sftp_readlink;
sftp_rename;
sftp_rewind;
sftp_rmdir;
sftp_seek;
sftp_seek64;
sftp_server_init;
sftp_server_new;
sftp_server_version;
sftp_setstat;
sftp_stat;
sftp_symlink;
sftp_tell;
sftp_tell64;
sftp_unlink;
sftp_utimes;
sftp_write;
ssh_accept;
ssh_auth_list;
ssh_bind_accept;
ssh_bind_fd_toaccept;
ssh_bind_free;
ssh_bind_get_fd;
ssh_bind_listen;
ssh_bind_new;
ssh_bind_set_blocking;
ssh_bind_set_fd;
ssh_bind_set_options;
ssh_clean_pubkey_hash;
ssh_connect;
ssh_copyright;
ssh_disconnect;
ssh_finalize;
ssh_get_disconnect_message;
ssh_get_error;
ssh_get_error_code;
ssh_get_fd;
ssh_get_hexa;
ssh_get_issue_banner;
ssh_get_openssh_version;
ssh_get_pubkey;
ssh_get_pubkey_hash;
ssh_get_random;
ssh_get_status;
ssh_get_version;
ssh_init;
ssh_is_server_known;
ssh_log;
ssh_message_auth_password;
ssh_message_auth_publickey;
ssh_message_auth_reply_pk_ok;
ssh_message_auth_reply_success;
ssh_message_auth_set_methods;
ssh_message_auth_user;
ssh_message_channel_request_open_reply_accept;
ssh_message_channel_request_reply_success;
ssh_message_free;
ssh_message_get;
ssh_message_reply_default;
ssh_message_retrieve;
ssh_message_service_reply_success;
ssh_message_service_service;
ssh_message_subtype;
ssh_message_type;
ssh_new;
ssh_options_allow_ssh1;
ssh_options_allow_ssh2;
ssh_options_copy;
ssh_options_free;
ssh_options_getopt;
ssh_options_new;
ssh_options_set_auth_callback;
ssh_options_set_banner;
ssh_options_set_bind;
ssh_options_set_dsa_server_key;
ssh_options_set_fd;
ssh_options_set_host;
ssh_options_set_identity;
ssh_options_set_known_hosts_file;
ssh_options_set_log_function;
ssh_options_set_log_verbosity;
ssh_options_set_port;
ssh_options_set_rsa_server_key;
ssh_options_set_ssh_dir;
ssh_options_set_status_callback;
ssh_options_set_timeout;
ssh_options_set_username;
ssh_options_set_wanted_algos;
ssh_print_hexa;
ssh_select;
ssh_service_request;
ssh_set_blocking;
ssh_set_fd_except;
ssh_set_fd_toread;
ssh_set_fd_towrite;
ssh_set_options;
ssh_silent_disconnect;
ssh_userauth_agent_pubkey;
ssh_userauth_autopubkey;
ssh_userauth_kbdint;
ssh_userauth_kbdint_getinstruction;
ssh_userauth_kbdint_getname;
ssh_userauth_kbdint_getnprompts;
ssh_userauth_kbdint_getprompt;
ssh_userauth_kbdint_setanswer;
ssh_userauth_list;
ssh_userauth_none;
ssh_userauth_offer_pubkey;
ssh_userauth_password;
ssh_userauth_pubkey;
ssh_version;
ssh_write_knownhost;
string_burn;
string_copy;
string_data;
string_fill;
string_free;
string_from_char;
string_len;
string_new;
string_to_char;
local:
*;
};
SSH_0.4 {
global:
channel_write_stderr;
channel_request_x11;
channel_accept_x11;
ssh_scp_close;
ssh_scp_free;
ssh_scp_init;
ssh_scp_new;
ssh_scp_push_file;
ssh_scp_write;
sftp_extensions_get_count;
sftp_extensions_get_data;
sftp_extensions_get_name;
ssh_message_channel_request_channel;
ssh_message_channel_request_command;
ssh_message_channel_request_env_name;
ssh_message_channel_request_env_value;
ssh_message_channel_request_open_destination;
ssh_message_channel_request_open_destination_port;
ssh_message_channel_request_open_originator;
ssh_message_channel_request_open_originator_port;
ssh_message_channel_request_pty_height;
ssh_message_channel_request_pty_pxheight;
ssh_message_channel_request_pty_pxwidth;
ssh_message_channel_request_pty_term;
ssh_message_channel_request_pty_width;
ssh_message_channel_request_subsystem;
ssh_set_message_callback;
} SSH_0.3;

Просмотреть файл

@ -43,9 +43,14 @@ ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location){
ssh_scp_free(scp);
return NULL;
}
scp->location=strdup(location);
if (scp->location == NULL) {
ssh_set_error(session,SSH_FATAL,"Error allocating memory for ssh_scp");
ssh_scp_free(scp);
return NULL;
}
scp->session=session;
scp->mode=mode;
scp->location=strdup(location);
scp->channel=NULL;
scp->state=SSH_SCP_NEW;
return scp;
@ -54,7 +59,7 @@ ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location){
int ssh_scp_init(ssh_scp scp){
int r;
char execbuffer[1024];
u_int8_t code;
uint8_t code;
if(scp->state != SSH_SCP_NEW){
ssh_set_error(scp->session,SSH_FATAL,"ssh_scp_init called under invalid state");
return SSH_ERROR;
@ -126,7 +131,7 @@ void ssh_scp_free(ssh_scp scp){
int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, const char *perms){
char buffer[1024];
int r;
u_int8_t code;
uint8_t code;
if(scp->state != SSH_SCP_WRITE_INITED){
ssh_set_error(scp->session,SSH_FATAL,"ssh_scp_push_file called under invalid state");
return SSH_ERROR;
@ -158,7 +163,7 @@ int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, const char
int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len){
int w;
//int r;
//u_int8_t code;
//uint8_t code;
if(scp->state != SSH_SCP_WRITE_WRITING){
ssh_set_error(scp->session,SSH_FATAL,"ssh_scp_write called under invalid state");
return SSH_ERROR;

Просмотреть файл

@ -97,8 +97,9 @@ void ssh_cleanup(SSH_SESSION *session) {
SAFE_FREE(session->serverbanner);
SAFE_FREE(session->clientbanner);
SAFE_FREE(session->banner);
buffer_reinit(session->in_buffer);
buffer_reinit(session->out_buffer);
buffer_free(session->in_buffer);
buffer_free(session->out_buffer);
session->in_buffer=session->out_buffer=NULL;
crypto_free(session->current_crypto);
crypto_free(session->next_crypto);
ssh_socket_free(session->socket);