Compare commits
61 Commits
libssh2-1.
...
libssh2-1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
507d5f96cf | ||
![]() |
84d8728835 | ||
![]() |
296d57bb2c | ||
![]() |
9e79031ad7 | ||
![]() |
689fc5c596 | ||
![]() |
31a9e8860d | ||
![]() |
b26c3e7cce | ||
![]() |
e4eeb85f01 | ||
![]() |
7de77e94bf | ||
![]() |
8c0294db66 | ||
![]() |
900c90ccbe | ||
![]() |
d5eec4aad9 | ||
![]() |
19864f0f64 | ||
![]() |
420f0b7793 | ||
![]() |
7aa4bfc671 | ||
![]() |
462996b064 | ||
![]() |
07d7a85bdb | ||
![]() |
95d69d3a81 | ||
![]() |
2fe1770d9f | ||
![]() |
3c71ad4fce | ||
![]() |
79f48e4881 | ||
![]() |
49453c9ae2 | ||
![]() |
b232eeb598 | ||
![]() |
f922df9e1b | ||
![]() |
7e47bd6640 | ||
![]() |
4ae907cdef | ||
![]() |
01d199180a | ||
![]() |
7e18862eae | ||
![]() |
45ffdcfe3c | ||
![]() |
dadc05fdfd | ||
![]() |
733bf877f8 | ||
![]() |
2db7d9c655 | ||
![]() |
9a24b03402 | ||
![]() |
81d53de4dc | ||
![]() |
5b004a4b67 | ||
![]() |
da64618c9a | ||
![]() |
566894494b | ||
![]() |
0723dab4d7 | ||
![]() |
67ba8713a6 | ||
![]() |
dade304c47 | ||
![]() |
6e8229a221 | ||
![]() |
821fb6ca71 | ||
![]() |
59673a111e | ||
![]() |
5b66a5f38d | ||
![]() |
ce8f0b29a4 | ||
![]() |
26dad4590b | ||
![]() |
4ed1e9d96b | ||
![]() |
c5ec167881 | ||
![]() |
e652b4c7b8 | ||
![]() |
cc84d875eb | ||
![]() |
c01737e679 | ||
![]() |
4825171919 | ||
![]() |
d881e7e8ef | ||
![]() |
5dc5c80a39 | ||
![]() |
9f477073bc | ||
![]() |
78498e0588 | ||
![]() |
0b0aa209f6 | ||
![]() |
aa07cdee9a | ||
![]() |
274fb2169c | ||
![]() |
f0a37bdadc | ||
![]() |
1249dd2272 |
@@ -26,10 +26,9 @@ vms/libssh2_make_kit.dcl vms/libssh2_make_lib.dcl vms/man2help.c \
|
||||
vms/readme.vms vms/libssh2_config.h
|
||||
|
||||
|
||||
WIN32FILES = win32/Makefile.win32 win32/libssh2.dsw \
|
||||
win32/config.mk win32/Makefile win32/test/Makefile.win32 \
|
||||
win32/libssh2_config.h win32/tests.dsp win32/rules.mk $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc \
|
||||
WIN32FILES = win32/libssh2.dsw win32/config.mk win32/Makefile \
|
||||
win32/libssh2_config.h win32/tests.dsp win32/rules.mk $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc \
|
||||
win32/Makefile.Watcom
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk HACKING \
|
||||
|
@@ -1,44 +1,19 @@
|
||||
libssh2 1.2.8
|
||||
libssh2 1.3.0
|
||||
|
||||
This release includes the following changes:
|
||||
|
||||
o added libssh2_free, libssh2_channel_get_exit_signal and
|
||||
libssh2_session_handshake
|
||||
o SFTP read/write remade and now MUCH faster, especially on high latency
|
||||
connections
|
||||
o added new examples: ssh2_echo.c, sftp_append.c and sftp_write_sliding.c
|
||||
o userauth: derive publickey from private
|
||||
o NEWS: now generated from git
|
||||
o Added custom callbacks for performing low level socket I/O
|
||||
|
||||
This release includes the following bugfixes:
|
||||
|
||||
o Support unlimited number of host names in a single line of the
|
||||
known_hosts file.
|
||||
o fix memory leak in userauth_keyboard_interactive()
|
||||
o fix memory leaks (two times cipher_data) for each sftp session
|
||||
o session_startup: manage server data before server identification
|
||||
o SCP: allow file names with bytes > 126
|
||||
o scp_recv: improved treatment of channel_read() returning zero
|
||||
o libssh2_userauth_authenticated: make it work as documented
|
||||
o variable size cleanup: match internal variable sizes better with the sizes
|
||||
of the fields used on the wire
|
||||
o channel_request_pty_size: fix reqPTY_state
|
||||
o sftp_symlink: return error if receive buffer too small
|
||||
o sftp_readdir: return error if buffer is too small
|
||||
o libssh2_knownhost_readfile.3: clarify return value
|
||||
o configure: stop using the deprecated AM_INIT_AUTOMAKE syntax
|
||||
o Fixed Win32 makefile which was now broken at resource build
|
||||
o kex_agree_hostkey: fix NULL pointer derefence
|
||||
o _libssh2_ntohu64: fix conversion from network bytes to uint64
|
||||
o ssize_t: proper typedef with MSVC compilers
|
||||
o zlib: Add debug tracing of zlib errors
|
||||
o decomp: increase decompression buffer sizes
|
||||
o sftp_read: advance offset correctly for buffered copies
|
||||
o libssh2_sftp_seek64: flush packetlist and buffered data
|
||||
o _libssh2_packet_add: adjust window size when truncating
|
||||
o sftp_read: a short read is not end of file
|
||||
|
||||
This release would not have looked like this without help, code, reports and
|
||||
advice from friends like these:
|
||||
|
||||
Alexander Lamaison, Alfred Gebert, Guenter Knauf, Dan Fandrich,
|
||||
Daniel Stenberg, Jasmeet Bagga, Joey Degges, Mark Smith, Peter Stuge,
|
||||
Pierre Joye, Simon Josefsson, TJ Saunders, Tommy Lindgren
|
||||
Henrik Nordstrom, liuzl, Guenter Knauf
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
|
10
configure.ac
10
configure.ac
@@ -15,12 +15,14 @@ if test "x$SED" = "xsed-was-not-found-by-configure"; then
|
||||
fi
|
||||
|
||||
dnl figure out the libssh2 version
|
||||
VERSION=`$SED -ne 's/^#define LIBSSH2_VERSION *"\(.*\)"/\1/p' ${srcdir}/include/libssh2.h`
|
||||
LIBSSH2VER=`$SED -ne 's/^#define LIBSSH2_VERSION *"\(.*\)"/\1/p' ${srcdir}/include/libssh2.h`
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_MSG_CHECKING([libssh2 version])
|
||||
AC_MSG_RESULT($VERSION)
|
||||
AC_MSG_RESULT($LIBSSH2VER)
|
||||
|
||||
AB_VERSION=$VERSION
|
||||
AC_SUBST(LIBSSH2VER)
|
||||
|
||||
AB_VERSION=$LIBSSH2VER
|
||||
|
||||
AB_INIT
|
||||
|
||||
@@ -289,7 +291,7 @@ AC_OUTPUT
|
||||
|
||||
AC_MSG_NOTICE([summary of build options:
|
||||
|
||||
version: ${VERSION}
|
||||
version: ${LIBSSH2VER}
|
||||
Host type: ${host}
|
||||
Install prefix: ${prefix}
|
||||
Compiler: ${CC}
|
||||
|
@@ -25,8 +25,8 @@ dist_man_MANS = \
|
||||
libssh2_channel_forward_listen.3 \
|
||||
libssh2_channel_forward_listen_ex.3 \
|
||||
libssh2_channel_free.3 \
|
||||
libssh2_channel_get_exit_status.3 \
|
||||
libssh2_channel_get_exit_signal.3 \
|
||||
libssh2_channel_get_exit_status.3 \
|
||||
libssh2_channel_handle_extended_data.3 \
|
||||
libssh2_channel_handle_extended_data2.3 \
|
||||
libssh2_channel_ignore_extended_data.3 \
|
||||
@@ -61,10 +61,10 @@ dist_man_MANS = \
|
||||
libssh2_channel_x11_req_ex.3 \
|
||||
libssh2_exit.3 \
|
||||
libssh2_free.3 \
|
||||
libssh2_free_host_entry.3 \
|
||||
libssh2_host_entry_match.3 \
|
||||
libssh2_hostkey_hash.3 \
|
||||
libssh2_init.3 \
|
||||
libssh2_keepalive_config.3 \
|
||||
libssh2_keepalive_send.3 \
|
||||
libssh2_knownhost_add.3 \
|
||||
libssh2_knownhost_addc.3 \
|
||||
libssh2_knownhost_check.3 \
|
||||
@@ -77,7 +77,6 @@ dist_man_MANS = \
|
||||
libssh2_knownhost_readline.3 \
|
||||
libssh2_knownhost_writefile.3 \
|
||||
libssh2_knownhost_writeline.3 \
|
||||
libssh2_new_host_entry.3 \
|
||||
libssh2_poll.3 \
|
||||
libssh2_poll_channel_read.3 \
|
||||
libssh2_publickey_add.3 \
|
||||
@@ -90,8 +89,8 @@ dist_man_MANS = \
|
||||
libssh2_publickey_shutdown.3 \
|
||||
libssh2_scp_recv.3 \
|
||||
libssh2_scp_send.3 \
|
||||
libssh2_scp_send_ex.3 \
|
||||
libssh2_scp_send64.3 \
|
||||
libssh2_scp_send_ex.3 \
|
||||
libssh2_session_abstract.3 \
|
||||
libssh2_session_block_directions.3 \
|
||||
libssh2_session_callback_set.3 \
|
||||
@@ -100,6 +99,7 @@ dist_man_MANS = \
|
||||
libssh2_session_flag.3 \
|
||||
libssh2_session_free.3 \
|
||||
libssh2_session_get_blocking.3 \
|
||||
libssh2_session_get_timeout.3 \
|
||||
libssh2_session_hostkey.3 \
|
||||
libssh2_session_init.3 \
|
||||
libssh2_session_init_ex.3 \
|
||||
@@ -108,6 +108,7 @@ dist_man_MANS = \
|
||||
libssh2_session_method_pref.3 \
|
||||
libssh2_session_methods.3 \
|
||||
libssh2_session_set_blocking.3 \
|
||||
libssh2_session_set_timeout.3 \
|
||||
libssh2_session_startup.3 \
|
||||
libssh2_sftp_close.3 \
|
||||
libssh2_sftp_close_handle.3 \
|
||||
|
@@ -6,7 +6,8 @@ libssh2_channel_direct_tcpip - convenience macro for \fIlibssh2_channel_direct_t
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_direct_tcpip(arguments)
|
||||
LIBSSH2_CHANNEL *
|
||||
libssh2_channel_direct_tcpip(LIBSSH2_SESSION *session, const char *host, int port);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +17,4 @@ See \fIlibssh2_channel_direct_tcpip_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_direct_tcpip_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_direct_tcpip_ex(3)\fP
|
||||
.BR libssh2_channel_direct_tcpip_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_exec - convenience macro for \fIlibssh2_channel_process_startup(
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_exec(arguments)
|
||||
int libssh2_channel_exec(LIBSSH2_CHANNEL *channel, const char *command);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_process_startup(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_process_startup(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_process_startup(3)\fP
|
||||
.BR libssh2_channel_process_startup(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_flush - convenience macro for \fIlibssh2_channel_flush_ex(3)\fP
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_flush(arguments)
|
||||
int libssh2_channel_flush(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_flush_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_flush_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_flush_ex(3)\fP
|
||||
.BR libssh2_channel_flush_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_flush_stderr - convenience macro for \fIlibssh2_channel_flush_ex
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_flush_stderr(arguments)
|
||||
int libssh2_channel_flush_stderr(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_flush_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_flush_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_flush_ex(3)\fP
|
||||
.BR libssh2_channel_flush_ex(3)
|
||||
|
@@ -15,7 +15,8 @@ libssh2_channel_forward_accept(LIBSSH2_LISTENER *listener);
|
||||
.SH RETURN VALUE
|
||||
A newly allocated channel instance or NULL on failure.
|
||||
.SH ERRORS
|
||||
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call
|
||||
would block.
|
||||
When this function returns NULL use \fIlibssh2_session_last_errno(3)\fP to
|
||||
extract the error code. If that code is \fILIBSSH2_ERROR_EAGAIN\fP, the
|
||||
session is set to do non-blocking I/O but the call would block.
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_channel_forward_listen_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_forward_listen - convenience macro for \fIlibssh2_channel_forwar
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_forward_listen(arguments)
|
||||
int libssh2_channel_forward_listen(LIBSSH2_SESSION *session, int port);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_forward_listen_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_forward_listen_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_forward_listen_ex(3)\fP
|
||||
.BR libssh2_channel_forward_listen_ex(3)
|
||||
|
@@ -9,6 +9,9 @@ libssh2_channel_ignore_extended_data - convenience macro for \fIlibssh2_channel_
|
||||
libssh2_channel_ignore_extended_data(arguments)
|
||||
|
||||
.SH DESCRIPTION
|
||||
This function is deprecated. Use the
|
||||
\fIlibssh2_channel_handle_extended_data2(3)\fP function instead!
|
||||
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
underlying function \fIlibssh2_channel_handle_extended_data(3)\fP.
|
||||
.SH RETURN VALUE
|
||||
@@ -16,4 +19,4 @@ See \fIlibssh2_channel_handle_extended_data(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_handle_extended_data(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_handle_extended_data(3)\fP
|
||||
.BR libssh2_channel_handle_extended_data(3)
|
||||
|
@@ -6,7 +6,8 @@ libssh2_channel_open_session - convenience macro for \fIlibssh2_channel_open_ex(
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_open_session(arguments)
|
||||
LIBSSH2_CHANNEL *
|
||||
libssh2_channel_open_session(LIBSSH2_SESSION *session);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +17,4 @@ See \fIlibssh2_channel_open_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_open_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_open_ex(3)\fP
|
||||
.BR libssh2_channel_open_ex(3)
|
||||
|
@@ -4,20 +4,14 @@
|
||||
.SH NAME
|
||||
libssh2_channel_process_startup - request a shell on a channel
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <libssh2.h>
|
||||
|
||||
int
|
||||
libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel, const char *request, unsigned int request_len, const char *message, unsigned int message_len);
|
||||
|
||||
int
|
||||
libssh2_channel_shell(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
int
|
||||
libssh2_channel_exec(LIBSSH2_CHANNEL *channel, const char *message);
|
||||
|
||||
int
|
||||
libssh2_channel_subsystem(LIBSSH2_CHANNEL *channel, const char *message);
|
||||
|
||||
int libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
|
||||
const char *request,
|
||||
unsigned int request_len,
|
||||
const char *message,
|
||||
unsigned int message_len);
|
||||
.SH DESCRIPTION
|
||||
\fIchannel\fP - Active session channel instance.
|
||||
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_read - convenience macro for \fIlibssh2_channel_read_ex(3)\fP ca
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_read(arguments)
|
||||
ssize_t libssh2_channel_read(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_read_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_read_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_read_ex(3)\fP
|
||||
.BR libssh2_channel_read_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_read_stderr - convenience macro for \fIlibssh2_channel_read_ex(3
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_read_stderr(arguments)
|
||||
ssize_t libssh2_channel_read_stderr(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_read_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_read_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_read_ex(3)\fP
|
||||
.BR libssh2_channel_read_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_request_pty - convenience macro for \fIlibssh2_channel_request_p
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_request_pty(arguments)
|
||||
int libssh2_channel_request_pty(LIBSSH2_SESSION *session, const char *term);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_request_pty_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_request_pty_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_request_pty_ex(3)\fP
|
||||
.BR libssh2_channel_request_pty_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_request_pty_size - convenience macro for \fIlibssh2_channel_requ
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_request_pty_size(arguments)
|
||||
int libssh2_channel_request_pty_size(LIBSSH2_CHANNEL *channel, int width, int height);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_request_pty_size_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_request_pty_size_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_request_pty_size_ex(3)\fP
|
||||
.BR libssh2_channel_request_pty_size_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_setenv - convenience macro for \fIlibssh2_channel_setenv_ex(3)\f
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_setenv(arguments)
|
||||
int libssh2_channel_setenv(LIBSSH2_CHANNEL *channel, const char *varname, const char *value);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_setenv_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_setenv_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_setenv_ex(3)\fP
|
||||
.BR libssh2_channel_setenv_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_shell - convenience macro for \fIlibssh2_channel_process_startup
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_shell(arguments)
|
||||
int libssh2_channel_shell(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_process_startup(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_process_startup(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_process_startup(3)\fP
|
||||
.BR libssh2_channel_process_startup(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_subsystem - convenience macro for \fIlibssh2_channel_process_sta
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_subsystem(arguments)
|
||||
int libssh2_channel_subsystem(LIBSSH2_CHANNEL *channel, const char *subsystem);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_process_startup(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_process_startup(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_process_startup(3)\fP
|
||||
.BR libssh2_channel_process_startup(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_window_read - convenience macro for \fIlibssh2_channel_window_re
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_window_read(arguments)
|
||||
unsigned long libssh2_channel_window_read(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_window_read_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_window_read_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_window_read_ex(3)\fP
|
||||
.BR libssh2_channel_window_read_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_window_write - convenience macro for \fIlibssh2_channel_window_w
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_window_write(arguments)
|
||||
unsigend long libssh2_channel_window_write(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_window_write_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_window_write_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_window_write_ex(3)\fP
|
||||
.BR libssh2_channel_window_write_ex(3)
|
||||
|
@@ -7,8 +7,8 @@ libssh2_channel_write - convenience macro for \fIlibssh2_channel_write_ex(3)\fP
|
||||
.nf
|
||||
#include <libssh2.h>
|
||||
|
||||
#define libssh2_channel_write(channel, buf, buflen) \\
|
||||
libssh2_channel_write_ex((channel), 0, (buf), (buflen))
|
||||
ssize_t libssh2_channel_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t buflen);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
underlying function \fIlibssh2_channel_write_ex(3)\fP.
|
||||
@@ -17,4 +17,4 @@ See \fIlibssh2_channel_write_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_write_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_write_ex(3)\fP
|
||||
.BR libssh2_channel_write_ex(3)
|
||||
|
@@ -7,8 +7,8 @@ libssh2_channel_write_stderr - convenience macro for \fIlibssh2_channel_write_ex
|
||||
.nf
|
||||
#include <libssh2.h>
|
||||
|
||||
#define libssh2_channel_write_stderr(channel, buf, buflen) \\
|
||||
libssh2_channel_write_ex((channel), SSH_EXTENDED_DATA_STDERR, (buf), (buflen))
|
||||
ssize_t libssh2_channel_write_stderr(LIBSSH2_CHANNEL *channel, const char *buf, size_t buflen);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
underlying function \fIlibssh2_channel_write_ex(3)\fP.
|
||||
@@ -17,4 +17,4 @@ See \fIlibssh2_channel_write_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_write_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_write_ex(3)\fP
|
||||
.BR libssh2_channel_write_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_channel_x11_req - convenience macro for \fIlibssh2_channel_x11_req_ex(3)
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_channel_x11_req(arguments)
|
||||
int libssh2_channel_x11_req(LIBSSH2_CHANNEL *channel, int screen_number);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_channel_x11_req_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_channel_x11_req_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_channel_x11_req_ex(3)\fP
|
||||
.BR libssh2_channel_x11_req_ex(3)
|
||||
|
@@ -1,14 +0,0 @@
|
||||
.\" $Id: libssh2_free_host_entry.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
|
||||
.\"
|
||||
.TH libssh2_free_host_entry 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_free_host_entry - TODO
|
||||
.SH SYNOPSIS
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
.SH RETURN VALUE
|
||||
|
||||
.SH ERRORS
|
||||
|
||||
.SH SEE ALSO
|
@@ -1,14 +0,0 @@
|
||||
.\" $Id: libssh2_host_entry_match.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
|
||||
.\"
|
||||
.TH libssh2_host_entry_match 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_host_entry_match - TODO
|
||||
.SH SYNOPSIS
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
.SH RETURN VALUE
|
||||
|
||||
.SH ERRORS
|
||||
|
||||
.SH SEE ALSO
|
27
docs/libssh2_keepalive_config.3
Normal file
27
docs/libssh2_keepalive_config.3
Normal file
@@ -0,0 +1,27 @@
|
||||
.TH libssh2_keepalive_config 3 "12 Apr 2011" "libssh2 1.2.5" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_keepalive_config - short function description
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
.nf
|
||||
|
||||
void libssh2_keepalive_config(LIBSSH2_SESSION *session,
|
||||
int want_reply,
|
||||
unsigned interval);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
Set how often keepalive messages should be sent. \fBwant_reply\fP indicates
|
||||
whether the keepalive messages should request a response from the server.
|
||||
\fBinterval\fP is number of seconds that can pass without any I/O, use 0 (the
|
||||
default) to disable keepalives. To avoid some busy-loop corner-cases, if you
|
||||
specify an interval of 1 it will be treated as 2.
|
||||
|
||||
Note that non-blocking applications are responsible for sending the keepalive
|
||||
messages using \fBlibssh2_keepalive_send(3)\fP.
|
||||
.SH RETURN VALUE
|
||||
Nothing
|
||||
.SH AVAILABILITY
|
||||
Added in libssh2 1.2.5
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_keepalive_send(3)
|
||||
|
20
docs/libssh2_keepalive_send.3
Normal file
20
docs/libssh2_keepalive_send.3
Normal file
@@ -0,0 +1,20 @@
|
||||
.\" $Id: keepalive_send.3,v 1.4 2007/06/13 16:41:33 jehousley Exp $
|
||||
.\"
|
||||
.TH libssh2_keepalive_send 3 "13 Apr 2011" "libssh2 1.2.5" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_keepalive_send - short function description
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
.nf
|
||||
|
||||
int libssh2_keepalive_send(LIBSSH2_SESSION *session,
|
||||
int *seconds_to_next);
|
||||
.SH DESCRIPTION
|
||||
Send a keepalive message if needed. \fBseconds_to_next\fP indicates how many
|
||||
seconds you can sleep after this call before you need to call it again.
|
||||
.SH RETURN VALUE
|
||||
Returns 0 on success, or LIBSSH2_ERROR_SOCKET_SEND on I/O errors.
|
||||
.SH AVAILABILITY
|
||||
Added in libssh2 1.2.5
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_keepalive_config(3)
|
@@ -1,14 +0,0 @@
|
||||
.\" $Id: libssh2_new_host_entry.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
|
||||
.\"
|
||||
.TH libssh2_new_host_entry 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_new_host_entry - TODO
|
||||
.SH SYNOPSIS
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
.SH RETURN VALUE
|
||||
|
||||
.SH ERRORS
|
||||
|
||||
.SH SEE ALSO
|
@@ -6,7 +6,10 @@ libssh2_publickey_add - convenience macro for \fIlibssh2_publickey_add_ex(3)\fP
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_publickey_add(arguments)
|
||||
int libssh2_publickey_add(LIBSSH2_PUBLICKEY *pkey,
|
||||
const unsigned char *name,
|
||||
const unsigned char *blob, unsigned long blob_len, char overwrite,
|
||||
unsigned long num_attrs, const libssh2_publickey_attribute attrs[]);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +19,4 @@ See \fIlibssh2_publickey_add_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_publickey_add_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_publickey_add_ex(3)\fP
|
||||
.BR libssh2_publickey_add_ex(3)
|
||||
|
@@ -2,13 +2,26 @@
|
||||
.\"
|
||||
.TH libssh2_publickey_add_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_publickey_add_ex - TODO
|
||||
libssh2_publickey_add_ex - Add a public key entry
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
int
|
||||
libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY *pkey, const unsigned char *name,
|
||||
unsigned long name_len, const unsigned char *blob,
|
||||
unsigned long blob_len, char overwrite,
|
||||
unsigned long num_attrs,
|
||||
const libssh2_publickey_attribute attrs[])
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
TBD
|
||||
.SH RETURN VALUE
|
||||
|
||||
Returns 0 on success, negative on failure.
|
||||
.SH ERRORS
|
||||
|
||||
LIBSSH2_ERROR_BAD_USE
|
||||
LIBSSH2_ERROR_ALLOC,
|
||||
LIBSSH2_ERROR_EAGAIN
|
||||
LIBSSH2_ERROR_SOCKET_SEND,
|
||||
LIBSSH2_ERROR_SOCKET_TIMEOUT,
|
||||
LIBSSH2_ERROR_PUBLICKEY_PROTOCOL,
|
||||
.SH SEE ALSO
|
||||
|
@@ -6,7 +6,9 @@ libssh2_publickey_remove - convenience macro for \fIlibssh2_publickey_remove_ex(
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_publickey_remove(arguments)
|
||||
int libssh2_publickey_remove(LIBSSH2_PUBLICKEY *pkey,
|
||||
const unsigned char *name, unsigned long name_len,
|
||||
const unsigned char *blob, unsigned long blob_len);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +18,4 @@ See \fIlibssh2_publickey_remove_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_publickey_remove_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_publickey_remove_ex(3)\fP
|
||||
.BR libssh2_publickey_remove_ex(3)
|
||||
|
@@ -6,7 +6,8 @@ libssh2_scp_send - convenience macro for \fIlibssh2_scp_send_ex(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_scp_send(arguments)
|
||||
LIBSSH2_CHANNEL *
|
||||
libssh2_scp_send(LIBSSH2_SESSION *session, const char *path, int mode, size_t size);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +17,4 @@ See \fIlibssh2_scp_send_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_scp_send_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_scp_send_ex(3)\fP
|
||||
.BR libssh2_scp_send_ex(3)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
.\"
|
||||
.TH libssh2_session_block_directions 3 "1 Oct 2008" "libssh2 1.0" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_session_block_directions - get directions that socket should wait for before calling libssh2 function again
|
||||
libssh2_session_block_directions - get directions to wait for
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
@@ -26,6 +26,6 @@ LIBSSH2_SESSION_BLOCK_OUTBOUND: Outbound direction blocked.
|
||||
Application should wait for data to be available for socket prior to calling a
|
||||
libssh2 function again. If \fBLIBSSH2_SESSION_BLOCK_INBOUND\fP is set select
|
||||
should contain the session socket in readfds set. Correspondingly in case of
|
||||
\fBLIBSSH2_SESSION_BLOCK_INBOUND\fP writefds set should contain the socket.
|
||||
\fBLIBSSH2_SESSION_BLOCK_OUTBOUND\fP writefds set should contain the socket.
|
||||
.SH AVAILABILITY
|
||||
Added in 1.0
|
||||
|
@@ -33,6 +33,12 @@ Called when a mismatched MAC has been detected in the transport layer. If the
|
||||
function returns 0, the packet will be accepted nonetheless.
|
||||
.IP LIBSSH2_CALLBACK_X11
|
||||
Called when an X11 connection has been accepted
|
||||
.IP LIBSSH2_CALLBACK_SEND
|
||||
Called when libssh2 wants to send some data on the connection.
|
||||
Can be set to a custom function to handle I/O your own way.
|
||||
.IP LIBSSH2_CALLBACK_RECV
|
||||
Called when libssh2 wants to receive some data from the connection.
|
||||
Can be set to a custom function to handle I/O your own way.
|
||||
.SH RETURN VALUE
|
||||
Pointer to previous callback handler. Returns NULL if no prior callback
|
||||
handler was set or the callback type was unknown.
|
||||
|
@@ -6,7 +6,7 @@ libssh2_session_disconnect - convenience macro for \fIlibssh2_session_disconnect
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_session_disconnect(arguments)
|
||||
int libssh2_session_disconnect(LIBSSH2_SESSION *session, const char *description);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_session_disconnect_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_session_disconnect_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_session_disconnect_ex(3)\fP
|
||||
.BR libssh2_session_disconnect_ex(3)
|
||||
|
19
docs/libssh2_session_get_timeout.3
Normal file
19
docs/libssh2_session_get_timeout.3
Normal file
@@ -0,0 +1,19 @@
|
||||
.TH libssh2_session_get_timeout 3 "4 May 2011" "libssh2 1.2.9" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_session_get_timeout - get the timeout for blocking functions
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
.nf
|
||||
long libssh2_session_get_timeout(LIBSSH2_SESSION *session);
|
||||
.SH DESCRIPTION
|
||||
Returns the \fBtimeout\fP (in milliseconds) for how long a blocking the
|
||||
libssh2 function calls may wait until they consider the situation an error and
|
||||
return LIBSSH2_ERROR_TIMEOUT.
|
||||
|
||||
By default libssh2 has no timeout (zero) for blocking functions.
|
||||
.SH RETURN VALUE
|
||||
The value of the timeout setting.
|
||||
.SH AVAILABILITY
|
||||
Added in 1.2.9
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_set_timeout(3)
|
@@ -6,7 +6,8 @@ libssh2_session_init - convenience macro for \fIlibssh2_session_init_ex(3)\fP ca
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_session_init(arguments)
|
||||
LIBSSH2_SESSION *
|
||||
libssh2_session_init(void);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +17,4 @@ See \fIlibssh2_session_init_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_session_init_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_session_init_ex(3)\fP
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
20
docs/libssh2_session_set_timeout.3
Normal file
20
docs/libssh2_session_set_timeout.3
Normal file
@@ -0,0 +1,20 @@
|
||||
.TH libssh2_session_set_timeout 3 "4 May 2011" "libssh2 1.2.9" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_session_set_timeout - set timeout for blocking functions
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
.nf
|
||||
void libssh2_session_set_timeout(LIBSSH2_SESSION *session, long timeout);
|
||||
.SH DESCRIPTION
|
||||
Set the \fBtimeout\fP in milliseconds for how long a blocking the libssh2
|
||||
function calls may wait until they consider the situation an error and return
|
||||
LIBSSH2_ERROR_TIMEOUT.
|
||||
|
||||
By default or if you set the timeout to zero, libssh2 has no timeout for
|
||||
blocking functions.
|
||||
.SH RETURN VALUE
|
||||
Nothing
|
||||
.SH AVAILABILITY
|
||||
Added in 1.2.9
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_get_timeout(3)
|
@@ -6,7 +6,7 @@ libssh2_sftp_close - convenience macro for \fIlibssh2_sftp_close_handle(3)\fP ca
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_close(arguments)
|
||||
int libssh2_sftp_close(LIBSSH2_SFTP_HANDLE *handle);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_close_handle(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_close_handle(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_close_handle(3)\fP
|
||||
.BR libssh2_sftp_close_handle(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_closedir - convenience macro for \fIlibssh2_sftp_close_handle(3)\fP
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_closedir(arguments)
|
||||
int libssh2_sftp_closedir(LIBSSH2_SFTP_HANDLE *handle)
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_close_handle(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_close_handle(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_close_handle(3)\fP
|
||||
.BR libssh2_sftp_close_handle(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_fsetstat - convenience macro for \fIlibssh2_sftp_fstat_ex(3)\fP cal
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_fsetstat(arguments)
|
||||
int libssh2_sftp_fsetstat(LIBSSH2_SFTP_HANDLE *handle, LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_fstat_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_fstat_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_fstat_ex(3)\fP
|
||||
.BR libssh2_sftp_fstat_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_fstat - convenience macro for \fIlibssh2_sftp_fstat_ex(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_fstat(arguments)
|
||||
int libssh2_sftp_fstat(LIBSSH2_SFTP_HANDLE *handle, LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_fstat_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_fstat_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_fstat_ex(3)\fP
|
||||
.BR libssh2_sftp_fstat_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_lstat - convenience macro for \fIlibssh2_sftp_stat_ex(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_lstat(arguments)
|
||||
int libssh2_sftp_lstat(LIBSSH2_SFTP *sftp, const char *path, LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_stat_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_stat_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_stat_ex(3)\fP
|
||||
.BR libssh2_sftp_stat_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_mkdir - convenience macro for \fIlibssh2_sftp_mkdir_ex(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_mkdir(arguments)
|
||||
int libssh2_sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path, long mode);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_mkdir_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_mkdir_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_mkdir_ex(3)\fP
|
||||
.BR libssh2_sftp_mkdir_ex(3)
|
||||
|
@@ -6,7 +6,8 @@ libssh2_sftp_open - convenience macro for \fIlibssh2_sftp_open_ex(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_open(arguments)
|
||||
LIBSSH2_SFTP_HANDLE *
|
||||
libssh2_sftp_open(LIBSSH2_SFTP *sftp, const char *path, unsigned long flags, long mode);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +17,4 @@ See \fIlibssh2_sftp_open_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_open_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_open_ex(3)\fP
|
||||
.BR libssh2_sftp_open_ex(3)
|
||||
|
@@ -6,7 +6,8 @@ libssh2_sftp_opendir - convenience macro for \fIlibssh2_sftp_open_ex(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_opendir(arguments)
|
||||
LIBSSH2_SFTP_HANDLE *
|
||||
libssh2_sftp_opendir(LIBSSH2_SFTP *sftp, const char *path);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +17,4 @@ See \fIlibssh2_sftp_open_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_open_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_open_ex(3)\fP
|
||||
.BR libssh2_sftp_open_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_readdir - convenience macro for \fIlibssh2_sftp_readdir_ex(3)\fP ca
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_readdir(arguments)
|
||||
int libssh2_sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer, size_t buffer_maxlen, LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_readdir_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_readdir_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_readdir_ex(3)\fP
|
||||
.BR libssh2_sftp_readdir_ex(3)
|
||||
|
@@ -18,4 +18,4 @@ See \fIlibssh2_sftp_symlink_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_symlink_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_symlink_ex(3)\fP
|
||||
.BR libssh2_sftp_symlink_ex(3)
|
||||
|
@@ -18,4 +18,4 @@ See \fIlibssh2_sftp_symlink_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_symlink_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_symlink_ex(3)\fP
|
||||
.BR libssh2_sftp_symlink_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_rename - convenience macro for \fIlibssh2_sftp_rename_ex(3)\fP call
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_rename(arguments)
|
||||
int libssh2_sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename, const char *destination_filename);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_rename_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_rename_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_rename_ex(3)\fP
|
||||
.BR libssh2_sftp_rename_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_rewind - convenience macro for \fIlibssh2_sftp_seek64(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_rewind(arguments)
|
||||
int libssh2_sftp_rewind(LINBSSH2_SFTP_HANDLE *handle);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_seek64(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_seek64(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_seek64(3)\fP
|
||||
.BR libssh2_sftp_seek64(3)
|
||||
|
@@ -17,4 +17,4 @@ See \fIlibssh2_sftp_rmdir_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_rmdir_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_rmdir_ex(3)\fP
|
||||
.BR libssh2_sftp_rmdir_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_setstat - convenience macro for \fIlibssh2_sftp_stat_ex(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_setstat(arguments)
|
||||
int libssh2_sftp_setstat(LIBSSH2_SFTP *sftp, const char *path, LIBSSH2_SFTP_ATTRIBUTES *attr);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_stat_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_stat_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_stat_ex(3)\fP
|
||||
.BR libssh2_sftp_stat_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_stat - convenience macro for \fIlibssh2_sftp_fstat_ex(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_stat(arguments)
|
||||
int libssh2_sftp_stat(LIBSSH2_SFTP *sftp, const char *path, LIBSSH2_STFP_ATTRIBUTES *attrs);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_fstat_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_fstat_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_fstat_ex(3)\fP
|
||||
.BR libssh2_sftp_fstat_ex(3)
|
||||
|
@@ -18,4 +18,4 @@ See \fIlibssh2_sftp_symlink_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_symlink_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_symlink_ex(3)\fP
|
||||
.BR libssh2_sftp_symlink_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_sftp_unlink - convenience macro for \fIlibssh2_sftp_unlink_ex(3)\fP call
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_sftp_unlink(arguments)
|
||||
int libssh2_sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_sftp_unlink_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_sftp_unlink_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_sftp_unlink_ex(3)\fP
|
||||
.BR libssh2_sftp_unlink_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_userauth_hostbased_fromfile - convenience macro for \fIlibssh2_userauth_
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_userauth_hostbased_fromfile(arguments)
|
||||
int libssh2_userauth_hostbased_fromfile(LIBSSH2_SESSION *session, const char *username, const char *publickey, const char *privatekey, const char *passphrase, const char *hostname);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +16,4 @@ See \fIlibssh2_userauth_hostbased_fromfile_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_userauth_hostbased_fromfile_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_userauth_hostbased_fromfile_ex(3)\fP
|
||||
.BR libssh2_userauth_hostbased_fromfile_ex(3)
|
||||
|
@@ -6,7 +6,11 @@ libssh2_userauth_keyboard_interactive - convenience macro for \fIlibssh2_useraut
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_userauth_keyboard_interactive(arguments)
|
||||
int
|
||||
libssh2_userauth_keyboard_interactive(LIBSSH2_SESSION* session,
|
||||
const char *username,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*response_callback)));
|
||||
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +20,4 @@ See \fIlibssh2_userauth_keyboard_interactive_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_userauth_keyboard_interactive_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_userauth_keyboard_interactive_ex(3)\fP
|
||||
.BR libssh2_userauth_keyboard_interactive_ex(3)
|
||||
|
@@ -2,44 +2,59 @@
|
||||
.\"
|
||||
.TH libssh2_userauth_keyboard_interactive_ex 3 "8 Mar 2008" "libssh2 0.19" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_userauth_keyboard_interactive_ex - authenticate a session using a challenge-response authentication
|
||||
libssh2_userauth_keyboard_interactive_ex - authenticate a session using
|
||||
keyboard-interactive authentication
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <libssh2.h>
|
||||
|
||||
int
|
||||
libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION *session, const char *username, unsigned int username_len, LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(*response_callback));
|
||||
|
||||
int
|
||||
libssh2_userauth_keyboard_interactive(LIBSSH2_SESSION *session, const char *username, LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(*response_callback));
|
||||
|
||||
libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
unsigned int username_len,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(*response_callback));
|
||||
.SH DESCRIPTION
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
\fIsession\fP - Session instance as returned by
|
||||
\fIlibssh2_session_init_ex(3)\fP.
|
||||
|
||||
\fIusername\fP - Name of user to attempt plain password authentication for.
|
||||
\fIusername\fP - Name of user to attempt keyboard-interactive authentication
|
||||
for.
|
||||
|
||||
\fIusername_len\fP - Length of username parameter.
|
||||
|
||||
\fIresponse_callback\fP - As authentication proceeds, host issues several (1 or more) challenges and requires responses. This callback will be called at this moment. Callback is responsible to obtain responses for the challenges, fill the provided data structure and then return control. Responses will be sent to the host. String values will be free(3)ed by the library.
|
||||
\fIresponse_callback\fP - As authentication proceeds, the host issues several
|
||||
(1 or more) challenges and requires responses. This callback will be called at
|
||||
this moment. The callback is responsible to obtain responses for the
|
||||
challenges, fill the provided data structure and then return
|
||||
control. Responses will be sent to the host. String values will be free(3)ed
|
||||
by the library. The callback prototype must match this:
|
||||
|
||||
.nf
|
||||
void response(const char *name,
|
||||
int name_len, const char *instruction,
|
||||
int instruction_len,
|
||||
int num_prompts,
|
||||
const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
|
||||
void **abstract);
|
||||
.fi
|
||||
|
||||
Attempts keyboard-interactive (challenge/response) authentication.
|
||||
|
||||
Note that many SSH servers will always issue single "password" challenge,
|
||||
requesting actual password as response, but it is not required by the protocol,
|
||||
and various authentication schemes, such as smartcard authentication may use
|
||||
keyboard-interactive authentication type too.
|
||||
|
||||
Note that many SSH servers will always issue a single "password" challenge,
|
||||
requesting actual password as response, but it is not required by the
|
||||
protocol, and various authentication schemes, such as smartcard authentication
|
||||
may use keyboard-interactive authentication type too.
|
||||
.SH RETURN VALUE
|
||||
Return 0 on success or negative on failure. It returns
|
||||
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
|
||||
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
|
||||
|
||||
Return 0 on success or negative on failure. It returns LIBSSH2_ERROR_EAGAIN
|
||||
when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is a negative
|
||||
number, it isn't really a failure per se.
|
||||
.SH ERRORS
|
||||
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
|
||||
|
||||
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
|
||||
|
||||
\fLIBSSH2_ERROR_AUTHENTICATION_FAILED\fP - failed, invalid username/password or public/private key.
|
||||
|
||||
\fLIBSSH2_ERROR_AUTHENTICATION_FAILED\fP - failed, invalid username/password
|
||||
or public/private key.
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
@@ -6,7 +6,9 @@ libssh2_userauth_password - convenience macro for \fIlibssh2_userauth_password_e
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_userauth_password(arguments)
|
||||
int libssh2_userauth_password(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
const char *password);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +18,4 @@ See \fIlibssh2_userauth_password_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_userauth_password_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_userauth_password_ex(3)\fP
|
||||
.BR libssh2_userauth_password_ex(3)
|
||||
|
@@ -6,7 +6,7 @@ libssh2_userauth_publickey - authenticate using a callback function
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
.NF
|
||||
.nf
|
||||
int libssh2_userauth_publickey(LIBSSH2_SESSION *session,
|
||||
const char *user,
|
||||
const unsigned char *pubkeydata,
|
||||
|
@@ -6,7 +6,12 @@ libssh2_userauth_publickey_fromfile - convenience macro for \fIlibssh2_userauth_
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
libssh2_userauth_publickey_fromfile(arguments)
|
||||
int
|
||||
libssh2_userauth_publickey_fromfile(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
const char *publickey,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
@@ -16,4 +21,4 @@ See \fIlibssh2_userauth_publickey_fromfile_ex(3)\fP
|
||||
.SH ERRORS
|
||||
See \fIlibssh2_userauth_publickey_fromfile_ex(3)\fP
|
||||
.SH SEE ALSO
|
||||
.BR \fIlibssh2_userauth_publickey_fromfile_ex(3)\fP
|
||||
.BR libssh2_userauth_publickey_fromfile_ex(3)
|
||||
|
9
example/.gitignore
vendored
9
example/.gitignore
vendored
@@ -23,3 +23,12 @@ ssh2_agent
|
||||
libssh2_config.h
|
||||
libssh2_config.h.in
|
||||
stamp-h2
|
||||
sftp_append
|
||||
ssh2_echo
|
||||
subsystem_netconf
|
||||
test-scp
|
||||
test-sftp_append
|
||||
test-sftp_nonblock
|
||||
test-sftp_write
|
||||
test-sftp_write_nonblock
|
||||
test-ssh2_echo
|
||||
|
@@ -6,7 +6,8 @@ EXTRA_DIST = libssh2_config.h.in
|
||||
noinst_PROGRAMS = direct_tcpip ssh2 scp scp_nonblock scp_write \
|
||||
scp_write_nonblock sftp sftp_nonblock sftp_write sftp_write_nonblock \
|
||||
sftp_mkdir sftp_mkdir_nonblock sftp_RW_nonblock sftpdir \
|
||||
sftpdir_nonblock ssh2_exec ssh2_agent ssh2_echo sftp_append
|
||||
sftpdir_nonblock ssh2_exec ssh2_agent ssh2_echo sftp_append \
|
||||
subsystem_netconf
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/example
|
||||
LDADD = $(top_builddir)/src/libssh2.la
|
||||
|
@@ -235,9 +235,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else {
|
||||
prev = nread;
|
||||
if(rc > nread) {
|
||||
fprintf(stderr, "MOO %d > %d\n", (int)rc, (int)nread);
|
||||
}
|
||||
|
||||
/* rc indicates how many bytes were written this time */
|
||||
nread -= rc;
|
||||
ptr += rc;
|
||||
|
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* $Id: sftp_write_nonblock.c,v 1.14 2009/04/28 10:35:30 bagder Exp $
|
||||
*
|
||||
* Sample showing how to do SFTP non-blocking write transfers.
|
||||
*
|
||||
* The sample code has default values for host name, user name, password
|
||||
@@ -237,7 +235,11 @@ int main(int argc, char *argv[])
|
||||
nread = fread(&mem[memuse], 1, sizeof(mem)-memuse, local);
|
||||
if (nread <= 0) {
|
||||
/* end of file */
|
||||
break;
|
||||
if (memuse > 0)
|
||||
/* the previous sending is not finished */
|
||||
nread = 0;
|
||||
else
|
||||
break;
|
||||
}
|
||||
memuse += nread;
|
||||
total += nread;
|
||||
@@ -245,19 +247,19 @@ int main(int argc, char *argv[])
|
||||
/* write data in a loop until we block */
|
||||
while ((rc = libssh2_sftp_write(sftp_handle, mem, memuse)) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if(rc < 0)
|
||||
break;
|
||||
break;
|
||||
|
||||
if(memuse - rc) {
|
||||
/* make room for more data at the end of the buffer */
|
||||
memmove(&mem[0], &mem[rc], memuse - rc);
|
||||
memuse -= rc;
|
||||
/* make room for more data at the end of the buffer */
|
||||
memmove(&mem[0], &mem[rc], memuse - rc);
|
||||
memuse -= rc;
|
||||
}
|
||||
else
|
||||
/* 'mem' was consumed fully */
|
||||
memuse = 0;
|
||||
/* 'mem' was consumed fully */
|
||||
memuse = 0;
|
||||
|
||||
} while (rc > 0);
|
||||
|
||||
|
271
example/subsystem_netconf.c
Normal file
271
example/subsystem_netconf.c
Normal file
@@ -0,0 +1,271 @@
|
||||
#include "libssh2_config.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE (in_addr_t)~0
|
||||
#endif
|
||||
|
||||
const char *keyfile1 = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *keyfile2 = "/home/username/.ssh/id_rsa";
|
||||
const char *username = "username";
|
||||
const char *password = "";
|
||||
|
||||
const char *server_ip = "127.0.0.1";
|
||||
|
||||
enum {
|
||||
AUTH_NONE = 0,
|
||||
AUTH_PASSWORD,
|
||||
AUTH_PUBLICKEY
|
||||
};
|
||||
|
||||
static int netconf_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t len)
|
||||
{
|
||||
int i;
|
||||
ssize_t wr = 0;
|
||||
|
||||
do {
|
||||
i = libssh2_channel_write(channel, buf, len);
|
||||
if (i < 0) {
|
||||
fprintf(stderr, "libssh2_channel_write: %d\n", i);
|
||||
return -1;
|
||||
}
|
||||
wr += i;
|
||||
} while (i > 0 && wr < (ssize_t)len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
|
||||
char *buf, size_t buflen)
|
||||
{
|
||||
ssize_t len, rd = 0;
|
||||
char *endreply, *specialsequence = NULL;
|
||||
|
||||
memset(buf, 0, buflen);
|
||||
|
||||
do {
|
||||
len = libssh2_channel_read(channel, buf + rd, buflen - rd);
|
||||
if (LIBSSH2_ERROR_EAGAIN == len)
|
||||
continue;
|
||||
else if (len < 0) {
|
||||
fprintf(stderr, "libssh2_channel_read: %d", (int)len);
|
||||
return -1;
|
||||
}
|
||||
rd += len;
|
||||
|
||||
/* read more data until we see a rpc-reply closing tag followed by
|
||||
* the special sequence ]]>]]> */
|
||||
|
||||
/* really, this MUST be replaced with proper XML parsing! */
|
||||
|
||||
endreply = strstr(buf, endtag);
|
||||
if (endreply)
|
||||
specialsequence = strstr(endreply, "]]>]]>");
|
||||
|
||||
} while (!endreply || !specialsequence);
|
||||
|
||||
/* discard the special sequence so that only XML is returned */
|
||||
rd = specialsequence - buf;
|
||||
buf[rd] = 0;
|
||||
|
||||
return rd;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int rc, sock = -1, i, auth = AUTH_NONE;
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
char *userauthlist;
|
||||
LIBSSH2_SESSION *session;
|
||||
LIBSSH2_CHANNEL *channel = NULL;
|
||||
char buf[1048576]; /* avoid any buffer reallocation for simplicity */
|
||||
ssize_t len;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
server_ip = argv[1];
|
||||
if (argc > 2)
|
||||
username = argv[2];
|
||||
if (argc > 3)
|
||||
password = argv[3];
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Connect to SSH server */
|
||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
fprintf(stderr, "inet_addr: Invalid IP address \"%s\"\n", server_ip);
|
||||
return -1;
|
||||
}
|
||||
sin.sin_port = htons(830);
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "Failed to connect to %s!\n", inet_ntoa(sin.sin_addr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create a session instance */
|
||||
session = libssh2_session_init();
|
||||
if(!session) {
|
||||
fprintf(stderr, "Could not initialize SSH session!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
rc = libssh2_session_startup(session, sock);
|
||||
if(rc) {
|
||||
fprintf(stderr, "Error when starting up SSH session: %d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* At this point we havn't yet authenticated. The first thing to do
|
||||
* is check the hostkey's fingerprint against our known hosts Your app
|
||||
* may have it hard coded, may go to a file, may present it to the
|
||||
* user, that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++)
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
printf("Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password"))
|
||||
auth |= AUTH_PASSWORD;
|
||||
if (strstr(userauthlist, "publickey"))
|
||||
auth |= AUTH_PUBLICKEY;
|
||||
|
||||
/* check for options */
|
||||
if(argc > 4) {
|
||||
if ((auth & AUTH_PASSWORD) && !strcasecmp(argv[4], "-p"))
|
||||
auth = AUTH_PASSWORD;
|
||||
if ((auth & AUTH_PUBLICKEY) && !strcasecmp(argv[4], "-k"))
|
||||
auth = AUTH_PUBLICKEY;
|
||||
}
|
||||
|
||||
if (auth & AUTH_PASSWORD) {
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
printf("Authentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
printf("Authentication by public key succeeded.\n");
|
||||
} else {
|
||||
printf("No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
/* open a channel */
|
||||
channel = libssh2_channel_open_session(session);
|
||||
if (!channel) {
|
||||
fprintf(stderr, "Could not open the channel!\n"
|
||||
"(Note that this can be a problem at the server!"
|
||||
" Please review the server logs.)\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
/* execute the subsystem on our channel */
|
||||
if (libssh2_channel_subsystem(channel, "netconf")) {
|
||||
fprintf(stderr, "Could not execute the \"netconf\" subsystem!\n"
|
||||
"(Note that this can be a problem at the server!"
|
||||
" Please review the server logs.)\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
/* NETCONF: http://tools.ietf.org/html/draft-ietf-netconf-ssh-06 */
|
||||
|
||||
printf("Sending NETCONF client <hello>\n");
|
||||
snprintf(buf, sizeof(buf),
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
"<hello>"
|
||||
"<capabilities>"
|
||||
"<capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability>"
|
||||
"</capabilities>"
|
||||
"</hello>\n"
|
||||
"]]>]]>\n%n", &len);
|
||||
if (-1 == netconf_write(channel, buf, len))
|
||||
goto shutdown;
|
||||
|
||||
printf("Reading NETCONF server <hello>\n");
|
||||
len = netconf_read_until(channel, "</hello>", buf, sizeof(buf));
|
||||
if (-1 == len)
|
||||
goto shutdown;
|
||||
|
||||
printf("Got %d bytes:\n----------------------\n%s", len, buf);
|
||||
|
||||
printf("Sending NETCONF <rpc>\n");
|
||||
snprintf(buf, sizeof(buf),
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
"<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
|
||||
"<get-interface-information><terse/></get-interface-information>"
|
||||
"</rpc>\n"
|
||||
"]]>]]>\n%n", &len);
|
||||
if (-1 == netconf_write(channel, buf, len))
|
||||
goto shutdown;
|
||||
|
||||
printf("Reading NETCONF <rpc-reply>\n");
|
||||
len = netconf_read_until(channel, "</rpc-reply>", buf, sizeof(buf));
|
||||
if (-1 == len)
|
||||
goto shutdown;
|
||||
|
||||
printf("Got %d bytes:\n----------------------\n%s", len, buf);
|
||||
|
||||
shutdown:
|
||||
if (channel)
|
||||
libssh2_channel_free(channel);
|
||||
libssh2_session_disconnect(session, "Client disconnecting normally");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
closesocket(sock);
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
return 0;
|
||||
}
|
@@ -408,14 +408,16 @@ main (int argc, char *argv[])
|
||||
current_node = NULL;
|
||||
|
||||
while (current_node != NULL) {
|
||||
struct chan_X11_list *next_node;
|
||||
rc = x11_send_receive(current_node->chan, current_node->sock);
|
||||
next_node = current_node->next;
|
||||
if (rc == -1){
|
||||
shutdown(current_node->sock,SHUT_RDWR);
|
||||
close(current_node->sock);
|
||||
remove_node(current_node);
|
||||
|
||||
}
|
||||
current_node = current_node->next;
|
||||
|
||||
current_node = next_node;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -40,19 +40,19 @@
|
||||
#ifndef LIBSSH2_H
|
||||
#define LIBSSH2_H 1
|
||||
|
||||
#define LIBSSH2_COPYRIGHT "2004-2010 The libssh2 project and its contributors."
|
||||
#define LIBSSH2_COPYRIGHT "2004-2011 The libssh2 project and its contributors."
|
||||
|
||||
/* We use underscore instead of dash when appending DEV in dev versions just
|
||||
to make the BANNER define (used by src/session.c) be a valid SSH
|
||||
banner. Release versions have no appended strings and may of course not
|
||||
have dashes either. */
|
||||
#define LIBSSH2_VERSION "1.2.8_DEV"
|
||||
#define LIBSSH2_VERSION "1.3.0_DEV"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBSSH2_VERSION_MAJOR 1
|
||||
#define LIBSSH2_VERSION_MINOR 2
|
||||
#define LIBSSH2_VERSION_PATCH 8
|
||||
#define LIBSSH2_VERSION_MINOR 3
|
||||
#define LIBSSH2_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libssh2 version number, meant for easier
|
||||
parsing and comparions by programs. The LIBSSH2_VERSION_NUM define will
|
||||
@@ -69,7 +69,7 @@
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
*/
|
||||
#define LIBSSH2_VERSION_NUM 0x010208
|
||||
#define LIBSSH2_VERSION_NUM 0x010300
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
@@ -87,7 +87,7 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN32
|
||||
# include <BaseTsd.h>
|
||||
# include <WinSock2.h>
|
||||
#endif
|
||||
@@ -237,12 +237,22 @@ typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE
|
||||
void name(LIBSSH2_SESSION *session, void **session_abstract, \
|
||||
LIBSSH2_CHANNEL *channel, void **channel_abstract)
|
||||
|
||||
/* I/O callbacks */
|
||||
#define LIBSSH2_RECV_FUNC(name) ssize_t name(int socket, \
|
||||
void *buffer, size_t length, \
|
||||
int flags, void **abstract)
|
||||
#define LIBSSH2_SEND_FUNC(name) ssize_t name(int socket, \
|
||||
const void *buffer, size_t length,\
|
||||
int flags, void **abstract)
|
||||
|
||||
/* libssh2_session_callback_set() constants */
|
||||
#define LIBSSH2_CALLBACK_IGNORE 0
|
||||
#define LIBSSH2_CALLBACK_DEBUG 1
|
||||
#define LIBSSH2_CALLBACK_DISCONNECT 2
|
||||
#define LIBSSH2_CALLBACK_MACERROR 3
|
||||
#define LIBSSH2_CALLBACK_X11 4
|
||||
#define LIBSSH2_CALLBACK_SEND 5
|
||||
#define LIBSSH2_CALLBACK_RECV 6
|
||||
|
||||
/* libssh2_session_method_pref() constants */
|
||||
#define LIBSSH2_METHOD_KEX 0
|
||||
@@ -705,6 +715,10 @@ LIBSSH2_API int libssh2_session_get_blocking(LIBSSH2_SESSION* session);
|
||||
LIBSSH2_API void libssh2_channel_set_blocking(LIBSSH2_CHANNEL *channel,
|
||||
int blocking);
|
||||
|
||||
LIBSSH2_API void libssh2_session_set_timeout(LIBSSH2_SESSION* session,
|
||||
long timeout);
|
||||
LIBSSH2_API long libssh2_session_get_timeout(LIBSSH2_SESSION* session);
|
||||
|
||||
/* libssh2_channel_handle_extended_data is DEPRECATED, do not use! */
|
||||
LIBSSH2_API void libssh2_channel_handle_extended_data(LIBSSH2_CHANNEL *channel,
|
||||
int ignore_mode);
|
||||
|
@@ -9,8 +9,8 @@ includedir=@includedir@
|
||||
|
||||
Name: libssh2
|
||||
URL: http://www.libssh2.org/
|
||||
Description: Library for SSH based connunication
|
||||
Version: @VERSION@
|
||||
Description: Library for SSH-based communication
|
||||
Version: @LIBSSH2VER@
|
||||
Libs: -L${libdir} -lssh2 @LDFLAGS@ @LIBS@
|
||||
Libs.private: @LIBS@
|
||||
Cflags: -I${includedir}
|
||||
|
2
maketgz
2
maketgz
@@ -68,7 +68,7 @@ fi
|
||||
# Generate the changelog
|
||||
#
|
||||
echo "generate NEWS"
|
||||
git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./log2changes.pl > NEWS.dist
|
||||
git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./git2news.pl > NEWS.dist
|
||||
|
||||
############################################################################
|
||||
#
|
||||
|
@@ -19,7 +19,7 @@ endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../openssl-0.9.8q
|
||||
OPENSSL_PATH = ../../openssl-0.9.8r
|
||||
endif
|
||||
|
||||
# Edit the path below to point to your Distribution folder.
|
||||
@@ -79,7 +79,7 @@ endif
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20070501.zip
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
# If you want to mark the target as MTSAFE you will need a tool for
|
||||
# generating the xdc data for the linker; here's a minimal tool:
|
||||
|
@@ -73,7 +73,7 @@ endif
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20070501.zip
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
# If you want to mark the target as MTSAFE you will need a tool for
|
||||
# generating the xdc data for the linker; here's a minimal tool:
|
||||
|
16
src/agent.c
16
src/agent.c
@@ -177,7 +177,7 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
|
||||
/* Send the length of the request */
|
||||
if (transctx->state == agent_NB_state_request_created) {
|
||||
_libssh2_htonu32(buf, transctx->request_len);
|
||||
rc = _libssh2_send(agent->fd, buf, sizeof buf, 0);
|
||||
rc = LIBSSH2_SEND_FD(agent->session, agent->fd, buf, sizeof buf, 0);
|
||||
if (rc == -EAGAIN)
|
||||
return LIBSSH2_ERROR_EAGAIN;
|
||||
else if (rc < 0)
|
||||
@@ -188,7 +188,7 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
|
||||
|
||||
/* Send the request body */
|
||||
if (transctx->state == agent_NB_state_request_length_sent) {
|
||||
rc = _libssh2_send(agent->fd, transctx->request,
|
||||
rc = LIBSSH2_SEND_FD(agent->session, agent->fd, transctx->request,
|
||||
transctx->request_len, 0);
|
||||
if (rc == -EAGAIN)
|
||||
return LIBSSH2_ERROR_EAGAIN;
|
||||
@@ -200,7 +200,7 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
|
||||
|
||||
/* Receive the length of a response */
|
||||
if (transctx->state == agent_NB_state_request_sent) {
|
||||
rc = _libssh2_recv(agent->fd, buf, sizeof buf, 0);
|
||||
rc = LIBSSH2_RECV_FD(agent->session, agent->fd, buf, sizeof buf, 0);
|
||||
if (rc < 0) {
|
||||
if (rc == -EAGAIN)
|
||||
return LIBSSH2_ERROR_EAGAIN;
|
||||
@@ -218,7 +218,7 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
|
||||
|
||||
/* Receive the response body */
|
||||
if (transctx->state == agent_NB_state_response_length_received) {
|
||||
rc = _libssh2_recv(agent->fd, transctx->response,
|
||||
rc = LIBSSH2_RECV_FD(agent->session, agent->fd, transctx->response,
|
||||
transctx->response_len, 0);
|
||||
if (rc < 0) {
|
||||
if (rc == -EAGAIN)
|
||||
@@ -486,13 +486,13 @@ agent_list_identities(LIBSSH2_AGENT *agent)
|
||||
ssize_t len, num_identities;
|
||||
unsigned char *s;
|
||||
int rc;
|
||||
unsigned char c = SSH2_AGENTC_REQUEST_IDENTITIES;
|
||||
|
||||
/* Create a request to list identities */
|
||||
if (transctx->state == agent_NB_state_init) {
|
||||
unsigned char c = SSH2_AGENTC_REQUEST_IDENTITIES;
|
||||
transctx->request = &c;
|
||||
transctx->request_len = 1;
|
||||
transctx->state = agent_NB_state_request_created;
|
||||
transctx->request = &c;
|
||||
transctx->request_len = 1;
|
||||
transctx->state = agent_NB_state_request_created;
|
||||
}
|
||||
|
||||
/* Make sure to be re-called as a result of EAGAIN. */
|
||||
|
@@ -2022,7 +2022,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
|
||||
|
||||
if(channel->local.window_size <= 0)
|
||||
/* there's no room for data so we stop */
|
||||
return 0;
|
||||
return (rc==LIBSSH2_ERROR_EAGAIN?rc:0);
|
||||
|
||||
channel->write_bufwrite = buflen;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2011 by Daniel Stenberg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -617,7 +617,7 @@ static int oldstyle_hostline(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
|
||||
if(name > host) {
|
||||
namelen = 0;
|
||||
--name; // skip comma
|
||||
--name; /* skip comma */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2008, 2010, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2009 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2011 by Daniel Stenberg
|
||||
* Copyright (c) 2010 Simon Josefsson
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -163,13 +163,31 @@ static inline int writev(int sock, struct iovec *iov, int nvecs)
|
||||
session->ssh_msg_debug((session), (always_display), (message), \
|
||||
(message_len), (language), (language_len), \
|
||||
&(session)->abstract)
|
||||
#define LIBSSH2_DISCONNECT(session, reason, message, message_len, language, language_len) \
|
||||
session->ssh_msg_disconnect((session), (reason), (message), (message_len), (language), (language_len), &(session)->abstract)
|
||||
#define LIBSSH2_DISCONNECT(session, reason, message, message_len, \
|
||||
language, language_len) \
|
||||
session->ssh_msg_disconnect((session), (reason), (message), \
|
||||
(message_len), (language), (language_len), \
|
||||
&(session)->abstract)
|
||||
|
||||
#define LIBSSH2_MACERROR(session, data, datalen) session->macerror((session), (data), (datalen), &(session)->abstract)
|
||||
#define LIBSSH2_X11_OPEN(channel, shost, sport) channel->session->x11(((channel)->session), (channel), (shost), (sport), (&(channel)->session->abstract))
|
||||
#define LIBSSH2_MACERROR(session, data, datalen) \
|
||||
session->macerror((session), (data), (datalen), &(session)->abstract)
|
||||
#define LIBSSH2_X11_OPEN(channel, shost, sport) \
|
||||
channel->session->x11(((channel)->session), (channel), \
|
||||
(shost), (sport), (&(channel)->session->abstract))
|
||||
|
||||
#define LIBSSH2_CHANNEL_CLOSE(session, channel) channel->close_cb((session), &(session)->abstract, (channel), &(channel)->abstract)
|
||||
#define LIBSSH2_CHANNEL_CLOSE(session, channel) \
|
||||
channel->close_cb((session), &(session)->abstract, \
|
||||
(channel), &(channel)->abstract)
|
||||
|
||||
#define LIBSSH2_SEND_FD(session, fd, buffer, length, flags) \
|
||||
session->send(fd, buffer, length, flags, &session->abstract)
|
||||
#define LIBSSH2_RECV_FD(session, fd, buffer, length, flags) \
|
||||
session->recv(fd, buffer, length, flags, &session->abstract)
|
||||
|
||||
#define LIBSSH2_SEND(session, buffer, length, flags) \
|
||||
LIBSSH2_SEND_FD(session, session->socket_fd, buffer, length, flags)
|
||||
#define LIBSSH2_RECV(session, buffer, length, flags) \
|
||||
LIBSSH2_RECV_FD(session, session->socket_fd, buffer, length, flags)
|
||||
|
||||
typedef struct _LIBSSH2_KEX_METHOD LIBSSH2_KEX_METHOD;
|
||||
typedef struct _LIBSSH2_HOSTKEY_METHOD LIBSSH2_HOSTKEY_METHOD;
|
||||
@@ -539,6 +557,8 @@ struct _LIBSSH2_SESSION
|
||||
LIBSSH2_DISCONNECT_FUNC((*ssh_msg_disconnect));
|
||||
LIBSSH2_MACERROR_FUNC((*macerror));
|
||||
LIBSSH2_X11_OPEN_FUNC((*x11));
|
||||
LIBSSH2_SEND_FUNC((*send));
|
||||
LIBSSH2_RECV_FUNC((*recv));
|
||||
|
||||
/* Method preferences -- NULL yields "load order" */
|
||||
char *kex_prefs;
|
||||
@@ -559,6 +579,9 @@ struct _LIBSSH2_SESSION
|
||||
/* this is set to TRUE if a blocking API behavior is requested */
|
||||
int api_block_mode;
|
||||
|
||||
/* Timeout used when blocking API behavior is active */
|
||||
long api_timeout;
|
||||
|
||||
/* Server's public key */
|
||||
const LIBSSH2_HOSTKEY_METHOD *hostkey;
|
||||
void *server_hostkey_abstract;
|
||||
@@ -791,8 +814,10 @@ struct _LIBSSH2_SESSION
|
||||
|
||||
/* session.flag helpers */
|
||||
#ifdef MSG_NOSIGNAL
|
||||
#define LIBSSH2_SOCKET_SEND_FLAGS(session) (((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#define LIBSSH2_SOCKET_RECV_FLAGS(session) (((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#define LIBSSH2_SOCKET_SEND_FLAGS(session) \
|
||||
(((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#define LIBSSH2_SOCKET_RECV_FLAGS(session) \
|
||||
(((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#else
|
||||
/* If MSG_NOSIGNAL isn't defined we're SOL on blocking SIGPIPE */
|
||||
#define LIBSSH2_SOCKET_SEND_FLAGS(session) 0
|
||||
@@ -969,9 +994,9 @@ _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...)
|
||||
#define SSH_OPEN_RESOURCE_SHORTAGE 4
|
||||
|
||||
ssize_t _libssh2_recv(libssh2_socket_t socket, void *buffer,
|
||||
size_t length, int flags);
|
||||
size_t length, int flags, void **abstract);
|
||||
ssize_t _libssh2_send(libssh2_socket_t socket, const void *buffer,
|
||||
size_t length, int flags);
|
||||
size_t length, int flags, void **abstract);
|
||||
|
||||
#define LIBSSH2_READ_TIMEOUT 60 /* generic timeout in seconds used when
|
||||
waiting for more data to arrive */
|
||||
|
27
src/misc.c
27
src/misc.c
@@ -94,7 +94,7 @@ static int wsa2errno(void)
|
||||
* Replacement for the standard recv, return -errno on failure.
|
||||
*/
|
||||
ssize_t
|
||||
_libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length, int flags)
|
||||
_libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length, int flags, void **abstract)
|
||||
{
|
||||
ssize_t rc = recv(sock, buffer, length, flags);
|
||||
#ifdef WIN32
|
||||
@@ -108,8 +108,14 @@ _libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length, int flags)
|
||||
return -errno;
|
||||
}
|
||||
#else
|
||||
if (rc < 0 )
|
||||
return -errno;
|
||||
if (rc < 0 ){
|
||||
/* Sometimes the first recv() function call sets errno to ENOENT on
|
||||
Solaris and HP-UX */
|
||||
if ( errno == ENOENT )
|
||||
return -EAGAIN;
|
||||
else
|
||||
return -errno;
|
||||
}
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
@@ -120,7 +126,7 @@ _libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length, int flags)
|
||||
*/
|
||||
ssize_t
|
||||
_libssh2_send(libssh2_socket_t sock, const void *buffer, size_t length,
|
||||
int flags)
|
||||
int flags, void **abstract)
|
||||
{
|
||||
ssize_t rc = send(sock, buffer, length, flags);
|
||||
#ifdef WIN32
|
||||
@@ -418,7 +424,7 @@ _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...)
|
||||
}
|
||||
}
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
_libssh2_gettimeofday(&now, NULL);
|
||||
if(!firstsec) {
|
||||
firstsec = now.tv_sec;
|
||||
}
|
||||
@@ -557,16 +563,15 @@ void _libssh2_list_insert(struct list_node *after, /* insert before this */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(LIBSSH2_WIN32) && !defined(__MINGW32__)
|
||||
/* this define is defined in misc.h for the correct platforms */
|
||||
#ifdef LIBSSH2_GETTIMEOFDAY_WIN32
|
||||
/*
|
||||
* gettimeofday
|
||||
* Implementation according to:
|
||||
* The Open Group Base Specifications Issue 6
|
||||
* IEEE Std 1003.1, 2004 Edition
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
@@ -585,9 +590,7 @@ void _libssh2_list_insert(struct list_node *after, /* insert before this */
|
||||
/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
|
||||
#define _W32_FT_OFFSET (116444736000000000)
|
||||
|
||||
|
||||
int __cdecl gettimeofday(struct timeval *tp,
|
||||
void *tzp)
|
||||
int __cdecl _libssh2_gettimeofday(struct timeval *tp, void *tzp)
|
||||
{
|
||||
union {
|
||||
unsigned __int64 ns100; /*time since 1 Jan 1601 in 100ns units */
|
||||
|
15
src/misc.h
15
src/misc.h
@@ -1,6 +1,6 @@
|
||||
#ifndef __LIBSSH2_MISC_H
|
||||
#define __LIBSSH2_MISC_H
|
||||
/* Copyright (c) 2009-2010 by Daniel Stenberg
|
||||
/* Copyright (c) 2009-2011 by Daniel Stenberg
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -78,4 +78,17 @@ void _libssh2_htonu32(unsigned char *buf, uint32_t val);
|
||||
void _libssh2_store_u32(unsigned char **buf, uint32_t value);
|
||||
void _libssh2_store_str(unsigned char **buf, const char *str, size_t len);
|
||||
|
||||
#if defined(LIBSSH2_WIN32) && !defined(__MINGW32__)
|
||||
/* provide a private one */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
int __cdecl _libssh2_gettimeofday(struct timeval *tp, void *tzp);
|
||||
#define HAVE_LIBSSH2_GETTIMEOFDAY
|
||||
#define LIBSSH2_GETTIMEOFDAY_WIN32 /* enable the win32 implementation */
|
||||
#else
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
#define _libssh2_gettimeofday(x,y) gettimeofday(x,y)
|
||||
#define HAVE_LIBSSH2_GETTIMEOFDAY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _LIBSSH2_MISC_H */
|
||||
|
@@ -257,7 +257,7 @@ aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
static int
|
||||
aes_ctr_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned int inl) /* encrypt/decrypt data */
|
||||
size_t inl) /* encrypt/decrypt data */
|
||||
{
|
||||
aes_ctr_ctx *c = EVP_CIPHER_CTX_get_app_data(ctx);
|
||||
unsigned char b1[AES_BLOCK_SIZE];
|
||||
|
@@ -706,6 +706,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
|
||||
"Remote sent more data than current "
|
||||
"window allows, truncating");
|
||||
datalen = channelp->remote.window_size + data_head;
|
||||
channelp->remote.window_size = 0;
|
||||
}
|
||||
else
|
||||
/* Now that we've received it, shrink our window */
|
||||
|
14
src/scp.c
14
src/scp.c
@@ -272,6 +272,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
{
|
||||
int cmd_len;
|
||||
int rc;
|
||||
int tmp_err_code;
|
||||
const char *tmp_err_msg;
|
||||
|
||||
if (session->scpRecv_state == libssh2_NB_state_idle) {
|
||||
session->scpRecv_mode = 0;
|
||||
@@ -741,8 +743,12 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
||||
return session->scpRecv_channel;
|
||||
/* fall-through */
|
||||
scp_recv_error:
|
||||
tmp_err_code = session->err_code;
|
||||
tmp_err_msg = session->err_msg;
|
||||
while (libssh2_channel_free(session->scpRecv_channel) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
session->err_code = tmp_err_code;
|
||||
session->err_msg = tmp_err_msg;
|
||||
session->scpRecv_channel = NULL;
|
||||
session->scpRecv_state = libssh2_NB_state_idle;
|
||||
return NULL;
|
||||
@@ -774,6 +780,8 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
{
|
||||
int cmd_len;
|
||||
int rc;
|
||||
int tmp_err_code;
|
||||
const char *tmp_err_msg;
|
||||
|
||||
if (session->scpSend_state == libssh2_NB_state_idle) {
|
||||
session->scpSend_command_len =
|
||||
@@ -881,7 +889,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
session->scpSend_response_len =
|
||||
snprintf((char *) session->scpSend_response,
|
||||
LIBSSH2_SCP_RESPONSE_BUFLEN, "T%ld 0 %ld 0\n",
|
||||
mtime, atime);
|
||||
(long)mtime, (long)atime);
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SCP, "Sent %s",
|
||||
session->scpSend_response);
|
||||
}
|
||||
@@ -1034,8 +1042,12 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
return session->scpSend_channel;
|
||||
/* fall-through */
|
||||
scp_send_error:
|
||||
tmp_err_code = session->err_code;
|
||||
tmp_err_msg = session->err_msg;
|
||||
while (libssh2_channel_free(session->scpSend_channel) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
session->err_code = tmp_err_code;
|
||||
session->err_msg = tmp_err_msg;
|
||||
session->scpSend_channel = NULL;
|
||||
session->scpSend_state = libssh2_NB_state_idle;
|
||||
return NULL;
|
||||
|
183
src/session.c
183
src/session.c
@@ -56,6 +56,7 @@
|
||||
#include "session.h"
|
||||
#include "channel.h"
|
||||
#include "mac.h"
|
||||
#include "misc.h"
|
||||
|
||||
/* libssh2_default_alloc
|
||||
*/
|
||||
@@ -114,7 +115,7 @@ banner_receive(LIBSSH2_SESSION * session)
|
||||
/* no incoming block yet! */
|
||||
session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_INBOUND;
|
||||
|
||||
ret = _libssh2_recv(session->socket_fd, &c, 1,
|
||||
ret = LIBSSH2_RECV(session, &c, 1,
|
||||
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
||||
if (ret < 0) {
|
||||
if(session->api_block_mode || (ret != -EAGAIN))
|
||||
@@ -226,7 +227,7 @@ banner_send(LIBSSH2_SESSION * session)
|
||||
/* no outgoing block yet! */
|
||||
session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_OUTBOUND;
|
||||
|
||||
ret = _libssh2_send(session->socket_fd,
|
||||
ret = LIBSSH2_SEND(session,
|
||||
banner + session->banner_TxRx_total_send,
|
||||
banner_len - session->banner_TxRx_total_send,
|
||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||
@@ -480,7 +481,10 @@ libssh2_session_init_ex(LIBSSH2_ALLOC_FUNC((*my_alloc)),
|
||||
session->alloc = local_alloc;
|
||||
session->free = local_free;
|
||||
session->realloc = local_realloc;
|
||||
session->send = _libssh2_send;
|
||||
session->recv = _libssh2_recv;
|
||||
session->abstract = abstract;
|
||||
session->api_timeout = 0; /* timeout-free API by default */
|
||||
session->api_block_mode = 1; /* blocking API by default */
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_TRANS,
|
||||
"New session resource allocated");
|
||||
@@ -530,6 +534,15 @@ libssh2_session_callback_set(LIBSSH2_SESSION * session,
|
||||
session->x11 = callback;
|
||||
return oldcb;
|
||||
|
||||
case LIBSSH2_CALLBACK_SEND:
|
||||
oldcb = session->send;
|
||||
session->send = callback;
|
||||
return oldcb;
|
||||
|
||||
case LIBSSH2_CALLBACK_RECV:
|
||||
oldcb = session->recv;
|
||||
session->recv = callback;
|
||||
return oldcb;
|
||||
}
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Setting Callback %d", cbtype);
|
||||
|
||||
@@ -542,11 +555,14 @@ libssh2_session_callback_set(LIBSSH2_SESSION * session,
|
||||
* Utility function that waits for action on the socket. Returns 0 when ready
|
||||
* to run again or error on timeout.
|
||||
*/
|
||||
int _libssh2_wait_socket(LIBSSH2_SESSION *session)
|
||||
int _libssh2_wait_socket(LIBSSH2_SESSION *session, time_t start_time)
|
||||
{
|
||||
int rc;
|
||||
int seconds_to_next;
|
||||
int dir;
|
||||
int has_timeout;
|
||||
long ms_to_next = 0;
|
||||
long elapsed_ms;
|
||||
|
||||
/* since libssh2 often sets EAGAIN internally before this function is
|
||||
called, we can decrease some amount of confusion in user programs by
|
||||
@@ -557,64 +573,82 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session)
|
||||
rc = libssh2_keepalive_send (session, &seconds_to_next);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
else {
|
||||
/* figure out what to wait for */
|
||||
dir = libssh2_session_block_directions(session);
|
||||
|
||||
if(!dir) {
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
||||
"Nothing to wait for in wait_socket");
|
||||
/* To avoid that we hang below just because there's nothing set to
|
||||
wait for, we timeout on 1 second to also avoid busy-looping
|
||||
during this condition */
|
||||
seconds_to_next = 1;
|
||||
}
|
||||
{
|
||||
#ifdef HAVE_POLL
|
||||
struct pollfd sockets[1];
|
||||
ms_to_next = seconds_to_next * 1000;
|
||||
|
||||
sockets[0].fd = session->socket_fd;
|
||||
sockets[0].events = 0;
|
||||
sockets[0].revents = 0;
|
||||
/* figure out what to wait for */
|
||||
dir = libssh2_session_block_directions(session);
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_INBOUND)
|
||||
sockets[0].events |= POLLIN;
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
|
||||
sockets[0].events |= POLLOUT;
|
||||
|
||||
rc = poll(sockets, 1, seconds_to_next ?
|
||||
seconds_to_next * 1000 : -1);
|
||||
#else
|
||||
fd_set rfd;
|
||||
fd_set wfd;
|
||||
fd_set *writefd = NULL;
|
||||
fd_set *readfd = NULL;
|
||||
struct timeval tv;
|
||||
|
||||
tv.tv_sec = seconds_to_next;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_INBOUND) {
|
||||
FD_ZERO(&rfd);
|
||||
FD_SET(session->socket_fd, &rfd);
|
||||
readfd = &rfd;
|
||||
}
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND) {
|
||||
FD_ZERO(&wfd);
|
||||
FD_SET(session->socket_fd, &wfd);
|
||||
writefd = &wfd;
|
||||
}
|
||||
|
||||
/* Note that this COULD be made to use a timeout that perhaps
|
||||
could be customizable by the app or something... */
|
||||
rc = select(session->socket_fd + 1, readfd, writefd, NULL,
|
||||
seconds_to_next ? &tv : NULL);
|
||||
#endif
|
||||
}
|
||||
if(!dir) {
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
||||
"Nothing to wait for in wait_socket");
|
||||
/* To avoid that we hang below just because there's nothing set to
|
||||
wait for, we timeout on 1 second to also avoid busy-looping
|
||||
during this condition */
|
||||
ms_to_next = 1000;
|
||||
}
|
||||
|
||||
if (session->api_timeout > 0 &&
|
||||
(seconds_to_next == 0 ||
|
||||
seconds_to_next > session->api_timeout)) {
|
||||
time_t now = time (NULL);
|
||||
elapsed_ms = (long)(1000*difftime(start_time, now));
|
||||
if (elapsed_ms > session->api_timeout) {
|
||||
session->err_code = LIBSSH2_ERROR_TIMEOUT;
|
||||
return LIBSSH2_ERROR_TIMEOUT;
|
||||
}
|
||||
ms_to_next = (session->api_timeout - elapsed_ms);
|
||||
has_timeout = 1;
|
||||
}
|
||||
else if (ms_to_next > 0) {
|
||||
has_timeout = 1;
|
||||
}
|
||||
else
|
||||
has_timeout = 0;
|
||||
|
||||
#ifdef HAVE_POLL
|
||||
{
|
||||
struct pollfd sockets[1];
|
||||
|
||||
sockets[0].fd = session->socket_fd;
|
||||
sockets[0].events = 0;
|
||||
sockets[0].revents = 0;
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_INBOUND)
|
||||
sockets[0].events |= POLLIN;
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
|
||||
sockets[0].events |= POLLOUT;
|
||||
|
||||
rc = poll(sockets, 1, has_timeout?ms_to_next: -1);
|
||||
}
|
||||
#else
|
||||
{
|
||||
fd_set rfd;
|
||||
fd_set wfd;
|
||||
fd_set *writefd = NULL;
|
||||
fd_set *readfd = NULL;
|
||||
struct timeval tv;
|
||||
|
||||
tv.tv_sec = ms_to_next / 1000;
|
||||
tv.tv_usec = (ms_to_next - tv.tv_sec*1000) * 1000;
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_INBOUND) {
|
||||
FD_ZERO(&rfd);
|
||||
FD_SET(session->socket_fd, &rfd);
|
||||
readfd = &rfd;
|
||||
}
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND) {
|
||||
FD_ZERO(&wfd);
|
||||
FD_SET(session->socket_fd, &wfd);
|
||||
writefd = &wfd;
|
||||
}
|
||||
|
||||
rc = select(session->socket_fd + 1, readfd, writefd, NULL,
|
||||
has_timeout ? &tv : NULL);
|
||||
}
|
||||
#endif
|
||||
if(rc <= 0) {
|
||||
/* timeout (or error), bail out with a timeout error */
|
||||
session->err_code = LIBSSH2_ERROR_TIMEOUT;
|
||||
@@ -657,12 +691,11 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
|
||||
"Failed sending banner");
|
||||
}
|
||||
session->startup_state = libssh2_NB_state_sent;
|
||||
session->banner_TxRx_state = libssh2_NB_state_idle;
|
||||
}
|
||||
|
||||
if (session->startup_state == libssh2_NB_state_sent) {
|
||||
do {
|
||||
session->banner_TxRx_state = libssh2_NB_state_idle;
|
||||
|
||||
rc = banner_receive(session);
|
||||
if (rc)
|
||||
return _libssh2_error(session, rc,
|
||||
@@ -1281,6 +1314,28 @@ libssh2_session_get_blocking(LIBSSH2_SESSION * session)
|
||||
return session->api_block_mode;
|
||||
}
|
||||
|
||||
|
||||
/* libssh2_session_set_timeout
|
||||
*
|
||||
* Set a session's timeout (in msec) for blocking mode,
|
||||
* or 0 to disable timeouts.
|
||||
*/
|
||||
LIBSSH2_API void
|
||||
libssh2_session_set_timeout(LIBSSH2_SESSION * session, long timeout)
|
||||
{
|
||||
session->api_timeout = timeout;
|
||||
}
|
||||
|
||||
/* libssh2_session_get_timeout
|
||||
*
|
||||
* Returns a session's timeout, or 0 if disabled
|
||||
*/
|
||||
LIBSSH2_API long
|
||||
libssh2_session_get_timeout(LIBSSH2_SESSION * session)
|
||||
{
|
||||
return session->api_timeout;
|
||||
}
|
||||
|
||||
/*
|
||||
* libssh2_poll_channel_read
|
||||
*
|
||||
@@ -1530,13 +1585,13 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout)
|
||||
}
|
||||
#ifdef HAVE_POLL
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
#ifdef HAVE_LIBSSH2_GETTIMEOFDAY
|
||||
{
|
||||
struct timeval tv_begin, tv_end;
|
||||
|
||||
gettimeofday((struct timeval *) &tv_begin, NULL);
|
||||
_libssh2_gettimeofday((struct timeval *) &tv_begin, NULL);
|
||||
sysret = poll(sockets, nfds, timeout_remaining);
|
||||
gettimeofday((struct timeval *) &tv_end, NULL);
|
||||
_libssh2_gettimeofday((struct timeval *) &tv_end, NULL);
|
||||
timeout_remaining -= (tv_end.tv_sec - tv_begin.tv_sec) * 1000;
|
||||
timeout_remaining -= (tv_end.tv_usec - tv_begin.tv_usec) / 1000;
|
||||
}
|
||||
@@ -1590,13 +1645,13 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout)
|
||||
#elif defined(HAVE_SELECT)
|
||||
tv.tv_sec = timeout_remaining / 1000;
|
||||
tv.tv_usec = (timeout_remaining % 1000) * 1000;
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
#ifdef HAVE_LIBSSH2_GETTIMEOFDAY
|
||||
{
|
||||
struct timeval tv_begin, tv_end;
|
||||
|
||||
gettimeofday((struct timeval *) &tv_begin, NULL);
|
||||
_libssh2_gettimeofday((struct timeval *) &tv_begin, NULL);
|
||||
sysret = select(maxfd+1, &rfds, &wfds, NULL, &tv);
|
||||
gettimeofday((struct timeval *) &tv_end, NULL);
|
||||
_libssh2_gettimeofday((struct timeval *) &tv_end, NULL);
|
||||
|
||||
timeout_remaining -= (tv_end.tv_sec - tv_begin.tv_sec) * 1000;
|
||||
timeout_remaining -= (tv_end.tv_usec - tv_begin.tv_usec) / 1000;
|
||||
|
@@ -53,15 +53,16 @@
|
||||
*/
|
||||
#define BLOCK_ADJUST(rc,sess,x) \
|
||||
do { \
|
||||
rc = x; \
|
||||
/* the order of the check below is important to properly deal with the
|
||||
case when the 'sess' is freed */ \
|
||||
if((rc != LIBSSH2_ERROR_EAGAIN) || !sess->api_block_mode) \
|
||||
break; \
|
||||
rc = _libssh2_wait_socket(sess); \
|
||||
if(rc) \
|
||||
break; \
|
||||
} while(1)
|
||||
time_t entry_time = time (NULL); \
|
||||
do { \
|
||||
rc = x; \
|
||||
/* the order of the check below is important to properly deal with \
|
||||
the case when the 'sess' is freed */ \
|
||||
if((rc != LIBSSH2_ERROR_EAGAIN) || !sess->api_block_mode) \
|
||||
break; \
|
||||
rc = _libssh2_wait_socket(sess, entry_time); \
|
||||
} while(!rc); \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* For functions that returns a pointer, we need to check if the API is
|
||||
@@ -69,21 +70,22 @@
|
||||
* immediately. If the API is blocking and we get a NULL we check the errno
|
||||
* and *only* if that is EAGAIN we loop and wait for socket action.
|
||||
*/
|
||||
#define BLOCK_ADJUST_ERRNO(ptr,sess,x) \
|
||||
#define BLOCK_ADJUST_ERRNO(ptr,sess,x) \
|
||||
do { \
|
||||
time_t entry_time = time (NULL); \
|
||||
int rc; \
|
||||
ptr = x; \
|
||||
if(!sess->api_block_mode || \
|
||||
(ptr != NULL) || \
|
||||
(libssh2_session_last_errno(sess) != LIBSSH2_ERROR_EAGAIN) ) \
|
||||
break; \
|
||||
rc = _libssh2_wait_socket(sess); \
|
||||
if(rc) \
|
||||
break; \
|
||||
} while(1)
|
||||
do { \
|
||||
ptr = x; \
|
||||
if(!sess->api_block_mode || \
|
||||
(ptr != NULL) || \
|
||||
(libssh2_session_last_errno(sess) != LIBSSH2_ERROR_EAGAIN) ) \
|
||||
break; \
|
||||
rc = _libssh2_wait_socket(sess, entry_time); \
|
||||
} while(!rc); \
|
||||
} while(0)
|
||||
|
||||
|
||||
int _libssh2_wait_socket(LIBSSH2_SESSION *session);
|
||||
int _libssh2_wait_socket(LIBSSH2_SESSION *session, time_t entry_time);
|
||||
|
||||
/* this is the lib-internal set blocking function */
|
||||
int _libssh2_session_set_blocking(LIBSSH2_SESSION * session, int blocking);
|
||||
|
42
src/sftp.c
42
src/sftp.c
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2004-2008, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
|
||||
* Copyright (c) 2009-2010 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2011 by Daniel Stenberg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -1098,6 +1098,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
|
||||
total_read += copy;
|
||||
filep->data_left -= copy;
|
||||
filep->offset += copy;
|
||||
|
||||
if(filep->data_left)
|
||||
return total_read;
|
||||
@@ -1241,9 +1242,12 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
"SFTP Protocol badness");
|
||||
|
||||
if(rc32 != chunk->len)
|
||||
/* a short read means this is the last read in the file */
|
||||
filep->eof = TRUE;
|
||||
if(rc32 != chunk->len) {
|
||||
/* a short read does not imply end of file, but we must adjust
|
||||
the offset_sent since it was advanced with a full
|
||||
chunk->len before */
|
||||
filep->offset_sent -= (chunk->len - rc32);
|
||||
}
|
||||
|
||||
if(total_read + rc32 > buffer_size) {
|
||||
/* figure out the overlap amount */
|
||||
@@ -1677,11 +1681,27 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
||||
|
||||
chunk = next;
|
||||
}
|
||||
else
|
||||
else {
|
||||
/* flush all pending packets from the outgoing list */
|
||||
sftp_packetlist_flush(handle);
|
||||
|
||||
/* since we return error now, the applicaton will not get any
|
||||
outstanding data acked, so we need to rewind the offset to
|
||||
where the application knows it has reached with acked data */
|
||||
handle->u.file.offset -= handle->u.file.acked;
|
||||
|
||||
/* then reset the offset_sent to be the same as the offset */
|
||||
handle->u.file.offset_sent = handle->u.file.offset;
|
||||
|
||||
/* clear the acked counter since we can have no pending data to
|
||||
ack after an error */
|
||||
handle->u.file.acked = 0;
|
||||
|
||||
/* the server returned an error for that written chunk, propagate
|
||||
this back to our parent function */
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
"FXP write failed");
|
||||
}
|
||||
}
|
||||
|
||||
/* if there were acked data in a previous call that wasn't returned then,
|
||||
@@ -1842,8 +1862,18 @@ libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *hnd,
|
||||
LIBSSH2_API void
|
||||
libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset)
|
||||
{
|
||||
if(handle)
|
||||
if(handle) {
|
||||
handle->u.file.offset = handle->u.file.offset_sent = offset;
|
||||
/* discard all pending requests and currently read data */
|
||||
sftp_packetlist_flush(handle);
|
||||
|
||||
/* free the left received buffered data */
|
||||
if (handle->u.file.data_left) {
|
||||
LIBSSH2_FREE(handle->sftp->channel->session, handle->u.file.data);
|
||||
handle->u.file.data_left = handle->u.file.data_len = 0;
|
||||
handle->u.file.data = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* libssh2_sftp_seek
|
||||
|
@@ -357,7 +357,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
||||
|
||||
/* now read a big chunk from the network into the temp buffer */
|
||||
nread =
|
||||
_libssh2_recv(session->socket_fd, &p->buf[remainbuf],
|
||||
LIBSSH2_RECV(session, &p->buf[remainbuf],
|
||||
PACKETBUFSIZE - remainbuf,
|
||||
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
||||
if (nread <= 0) {
|
||||
@@ -610,7 +610,7 @@ send_existing(LIBSSH2_SESSION *session, const unsigned char *data,
|
||||
/* number of bytes left to send */
|
||||
length = p->ototal_num - p->osent;
|
||||
|
||||
rc = _libssh2_send(session->socket_fd, &p->outbuf[p->osent], length,
|
||||
rc = LIBSSH2_SEND(session, &p->outbuf[p->osent], length,
|
||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||
if (rc < 0)
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
||||
@@ -823,7 +823,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
||||
|
||||
session->local.seqno++;
|
||||
|
||||
ret = _libssh2_send(session->socket_fd, p->outbuf, total_length,
|
||||
ret = LIBSSH2_SEND(session, p->outbuf, total_length,
|
||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||
if (ret < 0)
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
||||
|
166
src/userauth.c
166
src/userauth.c
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2004-2007, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2005 Mikhail Gusarov <dottedmag@dottedmag.net>
|
||||
* Copyright (c) 2009-2010 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2011 by Daniel Stenberg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -1447,44 +1447,50 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
|
||||
}
|
||||
|
||||
/* server requested PAM-like conversation */
|
||||
|
||||
s = session->userauth_kybd_data + 1;
|
||||
|
||||
/* string name (ISO-10646 UTF-8) */
|
||||
session->userauth_kybd_auth_name_len = _libssh2_ntohu32(s);
|
||||
s += 4;
|
||||
session->userauth_kybd_auth_name =
|
||||
LIBSSH2_ALLOC(session, session->userauth_kybd_auth_name_len);
|
||||
if (!session->userauth_kybd_auth_name) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for "
|
||||
"keyboard-interactive 'name' request field");
|
||||
goto cleanup;
|
||||
if(session->userauth_kybd_auth_name_len) {
|
||||
session->userauth_kybd_auth_name =
|
||||
LIBSSH2_ALLOC(session,
|
||||
session->userauth_kybd_auth_name_len);
|
||||
if (!session->userauth_kybd_auth_name) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for "
|
||||
"keyboard-interactive 'name' "
|
||||
"request field");
|
||||
goto cleanup;
|
||||
}
|
||||
memcpy(session->userauth_kybd_auth_name, s,
|
||||
session->userauth_kybd_auth_name_len);
|
||||
s += session->userauth_kybd_auth_name_len;
|
||||
}
|
||||
memcpy(session->userauth_kybd_auth_name, s,
|
||||
session->userauth_kybd_auth_name_len);
|
||||
s += session->userauth_kybd_auth_name_len;
|
||||
|
||||
/* string instruction (ISO-10646 UTF-8) */
|
||||
session->userauth_kybd_auth_instruction_len = _libssh2_ntohu32(s);
|
||||
s += 4;
|
||||
session->userauth_kybd_auth_instruction =
|
||||
LIBSSH2_ALLOC(session,
|
||||
session->userauth_kybd_auth_instruction_len);
|
||||
if (!session->userauth_kybd_auth_instruction) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for "
|
||||
"keyboard-interactive 'instruction' "
|
||||
"request field");
|
||||
goto cleanup;
|
||||
if(session->userauth_kybd_auth_instruction_len) {
|
||||
session->userauth_kybd_auth_instruction =
|
||||
LIBSSH2_ALLOC(session,
|
||||
session->userauth_kybd_auth_instruction_len);
|
||||
if (!session->userauth_kybd_auth_instruction) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for "
|
||||
"keyboard-interactive 'instruction' "
|
||||
"request field");
|
||||
goto cleanup;
|
||||
}
|
||||
memcpy(session->userauth_kybd_auth_instruction, s,
|
||||
session->userauth_kybd_auth_instruction_len);
|
||||
s += session->userauth_kybd_auth_instruction_len;
|
||||
}
|
||||
memcpy(session->userauth_kybd_auth_instruction, s,
|
||||
session->userauth_kybd_auth_instruction_len);
|
||||
s += session->userauth_kybd_auth_instruction_len;
|
||||
|
||||
/* string language tag (as defined in [RFC-3066]) */
|
||||
language_tag_len = _libssh2_ntohu32(s);
|
||||
s += 4;
|
||||
|
||||
/* ignoring this field as deprecated */
|
||||
s += language_tag_len;
|
||||
|
||||
@@ -1492,53 +1498,56 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
|
||||
session->userauth_kybd_num_prompts = _libssh2_ntohu32(s);
|
||||
s += 4;
|
||||
|
||||
session->userauth_kybd_prompts =
|
||||
LIBSSH2_ALLOC(session,
|
||||
sizeof(LIBSSH2_USERAUTH_KBDINT_PROMPT) *
|
||||
session->userauth_kybd_num_prompts);
|
||||
if (!session->userauth_kybd_prompts) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for "
|
||||
"keyboard-interactive prompts array");
|
||||
goto cleanup;
|
||||
}
|
||||
memset(session->userauth_kybd_prompts, 0,
|
||||
sizeof(LIBSSH2_USERAUTH_KBDINT_PROMPT) *
|
||||
session->userauth_kybd_num_prompts);
|
||||
|
||||
session->userauth_kybd_responses =
|
||||
LIBSSH2_ALLOC(session,
|
||||
sizeof(LIBSSH2_USERAUTH_KBDINT_RESPONSE) *
|
||||
session->userauth_kybd_num_prompts);
|
||||
if (!session->userauth_kybd_responses) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for "
|
||||
"keyboard-interactive responses array");
|
||||
goto cleanup;
|
||||
}
|
||||
memset(session->userauth_kybd_responses, 0,
|
||||
sizeof(LIBSSH2_USERAUTH_KBDINT_RESPONSE) *
|
||||
session->userauth_kybd_num_prompts);
|
||||
|
||||
for(i = 0; i != session->userauth_kybd_num_prompts; ++i) {
|
||||
/* string prompt[1] (ISO-10646 UTF-8) */
|
||||
session->userauth_kybd_prompts[i].length = _libssh2_ntohu32(s);
|
||||
s += 4;
|
||||
session->userauth_kybd_prompts[i].text =
|
||||
if(session->userauth_kybd_num_prompts) {
|
||||
session->userauth_kybd_prompts =
|
||||
LIBSSH2_ALLOC(session,
|
||||
session->userauth_kybd_prompts[i].length);
|
||||
if (!session->userauth_kybd_prompts[i].text) {
|
||||
sizeof(LIBSSH2_USERAUTH_KBDINT_PROMPT) *
|
||||
session->userauth_kybd_num_prompts);
|
||||
if (!session->userauth_kybd_prompts) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for "
|
||||
"keyboard-interactive prompt message");
|
||||
"keyboard-interactive prompts array");
|
||||
goto cleanup;
|
||||
}
|
||||
memcpy(session->userauth_kybd_prompts[i].text, s,
|
||||
session->userauth_kybd_prompts[i].length);
|
||||
s += session->userauth_kybd_prompts[i].length;
|
||||
memset(session->userauth_kybd_prompts, 0,
|
||||
sizeof(LIBSSH2_USERAUTH_KBDINT_PROMPT) *
|
||||
session->userauth_kybd_num_prompts);
|
||||
|
||||
/* boolean echo[1] */
|
||||
session->userauth_kybd_prompts[i].echo = *s++;
|
||||
session->userauth_kybd_responses =
|
||||
LIBSSH2_ALLOC(session,
|
||||
sizeof(LIBSSH2_USERAUTH_KBDINT_RESPONSE) *
|
||||
session->userauth_kybd_num_prompts);
|
||||
if (!session->userauth_kybd_responses) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for "
|
||||
"keyboard-interactive responses array");
|
||||
goto cleanup;
|
||||
}
|
||||
memset(session->userauth_kybd_responses, 0,
|
||||
sizeof(LIBSSH2_USERAUTH_KBDINT_RESPONSE) *
|
||||
session->userauth_kybd_num_prompts);
|
||||
|
||||
for(i = 0; i != session->userauth_kybd_num_prompts; ++i) {
|
||||
/* string prompt[1] (ISO-10646 UTF-8) */
|
||||
session->userauth_kybd_prompts[i].length =
|
||||
_libssh2_ntohu32(s);
|
||||
s += 4;
|
||||
session->userauth_kybd_prompts[i].text =
|
||||
LIBSSH2_ALLOC(session,
|
||||
session->userauth_kybd_prompts[i].length);
|
||||
if (!session->userauth_kybd_prompts[i].text) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate memory for "
|
||||
"keyboard-interactive prompt message");
|
||||
goto cleanup;
|
||||
}
|
||||
memcpy(session->userauth_kybd_prompts[i].text, s,
|
||||
session->userauth_kybd_prompts[i].length);
|
||||
s += session->userauth_kybd_prompts[i].length;
|
||||
|
||||
/* boolean echo[1] */
|
||||
session->userauth_kybd_prompts[i].echo = *s++;
|
||||
}
|
||||
}
|
||||
|
||||
response_callback(session->userauth_kybd_auth_name,
|
||||
@@ -1595,10 +1604,9 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
|
||||
rc = _libssh2_transport_send(session, session->userauth_kybd_data,
|
||||
session->userauth_kybd_packet_len,
|
||||
NULL, 0);
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN)
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block");
|
||||
}
|
||||
if (rc) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
|
||||
"Unable to send userauth-keyboard-interactive"
|
||||
@@ -1633,14 +1641,22 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
|
||||
}
|
||||
}
|
||||
|
||||
LIBSSH2_FREE(session, session->userauth_kybd_prompts);
|
||||
session->userauth_kybd_prompts = NULL;
|
||||
LIBSSH2_FREE(session, session->userauth_kybd_responses);
|
||||
session->userauth_kybd_responses = NULL;
|
||||
LIBSSH2_FREE(session, session->userauth_kybd_auth_name);
|
||||
session->userauth_kybd_auth_name = NULL;
|
||||
LIBSSH2_FREE(session, session->userauth_kybd_auth_instruction);
|
||||
session->userauth_kybd_auth_instruction = NULL;
|
||||
if(session->userauth_kybd_prompts) {
|
||||
LIBSSH2_FREE(session, session->userauth_kybd_prompts);
|
||||
session->userauth_kybd_prompts = NULL;
|
||||
}
|
||||
if(session->userauth_kybd_responses) {
|
||||
LIBSSH2_FREE(session, session->userauth_kybd_responses);
|
||||
session->userauth_kybd_responses = NULL;
|
||||
}
|
||||
if(session->userauth_kybd_auth_name) {
|
||||
LIBSSH2_FREE(session, session->userauth_kybd_auth_name);
|
||||
session->userauth_kybd_auth_name = NULL;
|
||||
}
|
||||
if(session->userauth_kybd_auth_instruction) {
|
||||
LIBSSH2_FREE(session, session->userauth_kybd_auth_instruction);
|
||||
session->userauth_kybd_auth_instruction = NULL;
|
||||
}
|
||||
|
||||
if (session->userauth_kybd_auth_failure) {
|
||||
session->userauth_kybd_state = libssh2_NB_state_idle;
|
||||
|
@@ -70,7 +70,7 @@ ZLIB_ROOT = ..\..\zlib-1.2.5
|
||||
!ifdef %openssl_root
|
||||
OPENSSL_ROOT = $(%openssl_root)
|
||||
!else
|
||||
OPENSSL_ROOT = ..\..\openssl-0.9.8q
|
||||
OPENSSL_ROOT = ..\..\openssl-0.9.8r
|
||||
!endif
|
||||
|
||||
#!ifdef %use_zlib
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#########################################################################
|
||||
#
|
||||
## Makefile for building libssh2 (Win32 version - gnu make)
|
||||
## Use: make -f Makefile.win32 [help|all|clean|dev|devclean|dist|distclean|dll|objclean]
|
||||
## Use: make -f Makefile.mingw [help|all|clean|dev|devclean|dist|distclean|dll|objclean]
|
||||
##
|
||||
## Comments to: Guenter Knauf http://www.gknw.net/phpbb
|
||||
#
|
||||
@@ -16,18 +16,23 @@ WITH_ZLIB = 1
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../openssl-0.9.8q
|
||||
OPENSSL_PATH = ../../openssl-0.9.8r
|
||||
endif
|
||||
|
||||
# Edit the var below to set to your architecture or set environment var.
|
||||
ifndef ARCH
|
||||
ARCH = w32
|
||||
endif
|
||||
|
||||
# Edit the path below to point to your Distribution folder.
|
||||
ifndef DISTDIR
|
||||
DISTDIR = libssh2-$(LIBSSH2_VERSION_STR)-bin-w32
|
||||
DISTDIR = libssh2-$(LIBSSH2_VERSION_STR)-bin-$(ARCH)
|
||||
endif
|
||||
DISTARC = $(DISTDIR).zip
|
||||
|
||||
# Edit the path below to point to your Development folder.
|
||||
ifndef DEVLDIR
|
||||
DEVLDIR = libssh2-$(LIBSSH2_VERSION_STR)-dev-w32
|
||||
DEVLDIR = libssh2-$(LIBSSH2_VERSION_STR)-dev-$(ARCH)
|
||||
endif
|
||||
DEVLARC = $(DEVLDIR).zip
|
||||
|
||||
@@ -57,22 +62,38 @@ endif
|
||||
# Include the version info retrieved from libssh2.h
|
||||
-include $(OBJDIR)/version.inc
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
MD = mkdir
|
||||
RD = rm -fr
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
CP = copy
|
||||
RM = del /q /f 2>NUL
|
||||
MD = md
|
||||
RD = rd /q /s 2>NUL
|
||||
XX =
|
||||
DS = $(XX)\$(XX)
|
||||
endif
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
ZIP = zip -qzr9
|
||||
|
||||
# The following line defines your compiler.
|
||||
ifdef METROWERKS
|
||||
CC = mwcc
|
||||
else
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
endif
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
MD = mkdir
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20070501.zip
|
||||
AWK = awk
|
||||
ZIP = zip -qzr9
|
||||
|
||||
# Global flags for all compilers
|
||||
CFLAGS = $(OPT) -D$(DB) -DWIN32 -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
endif
|
||||
|
||||
ifeq ($(CC),mwcc)
|
||||
LD = mwld
|
||||
@@ -120,14 +141,6 @@ endif
|
||||
|
||||
CFLAGS += $(INCLUDES)
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
XX =
|
||||
DS = $(XX)\$(XX)
|
||||
endif
|
||||
|
||||
vpath %.c . ../src
|
||||
|
||||
# include Makefile.inc to get CSOURCES define
|
||||
@@ -147,7 +160,7 @@ prebuild: $(OBJDIR) $(OBJDIR)/version.inc
|
||||
# libssh2_config.h
|
||||
|
||||
test: all
|
||||
$(MAKE) -C test -f Makefile.win32
|
||||
$(MAKE) -C test -f Makefile.mingw
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
# @echo Compiling $<
|
||||
@@ -158,38 +171,38 @@ $(OBJDIR)/version.inc: ../include/libssh2.h $(OBJDIR)
|
||||
@$(AWK) -f ../get_ver.awk $< > $@
|
||||
|
||||
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
||||
@-mkdir $(DISTDIR)$(DS)bin
|
||||
@-$(CP) ../INSTALL $(DISTDIR)
|
||||
@-$(CP) ../LICENSE $(DISTDIR)
|
||||
@-$(CP) ../README $(DISTDIR)
|
||||
@$(CP) $(TARGET).dll $(DISTDIR)/bin
|
||||
@-$(MD) $(DISTDIR)$(DS)bin
|
||||
@-$(CP) ..$(DS)INSTALL $(DISTDIR)
|
||||
@-$(CP) ..$(DS)LICENSE $(DISTDIR)
|
||||
@-$(CP) ..$(DS)README $(DISTDIR)
|
||||
@$(CP) $(TARGET).dll $(DISTDIR)$(DS)bin
|
||||
@echo Creating $(DISTARC)
|
||||
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
|
||||
|
||||
dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
|
||||
@-mkdir $(DEVLDIR)$(DS)bin
|
||||
@-mkdir $(DEVLDIR)$(DS)include
|
||||
@-mkdir $(DEVLDIR)$(DS)win32
|
||||
@-$(CP) ../INSTALL $(DEVLDIR)
|
||||
@-$(CP) ../LICENSE $(DEVLDIR)
|
||||
@-$(CP) ../README $(DEVLDIR)
|
||||
@$(CP) $(TARGET).dll $(DEVLDIR)/bin
|
||||
@$(CP) ../include/*.h $(DEVLDIR)/include
|
||||
@-$(MD) $(DEVLDIR)$(DS)bin
|
||||
@-$(MD)$(DEVLDIR)$(DS)include
|
||||
@-$(MD) $(DEVLDIR)$(DS)win32
|
||||
@-$(CP) ..$(DS)INSTALL $(DEVLDIR)
|
||||
@-$(CP) ..$(DS)LICENSE $(DEVLDIR)
|
||||
@-$(CP) ..$(DS)README $(DEVLDIR)
|
||||
@$(CP) $(TARGET).dll $(DEVLDIR)$(DS)bin
|
||||
@$(CP) ..$(DS)include$(DS)*.h $(DEVLDIR)$(DS)include
|
||||
@$(CP) libssh2_config.h $(DEVLDIR)/include
|
||||
@$(CP) *.$(LIBEXT) $(DEVLDIR)/win32
|
||||
@echo Creating $(DEVLARC)
|
||||
@$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
|
||||
|
||||
distclean: clean
|
||||
-$(RM) -r $(DISTDIR)
|
||||
-$(RD) $(DISTDIR)
|
||||
-$(RM) $(DISTARC)
|
||||
|
||||
devclean: clean
|
||||
-$(RM) -r $(DEVLDIR)
|
||||
-$(RD) $(DEVLDIR)
|
||||
-$(RM) $(DEVLARC)
|
||||
|
||||
objclean: all
|
||||
-$(RM) -r $(OBJDIR)
|
||||
-$(RD) $(OBJDIR)
|
||||
|
||||
testclean: clean
|
||||
$(MAKE) -C test -f Makefile.win32 clean
|
||||
@@ -197,7 +210,7 @@ testclean: clean
|
||||
clean:
|
||||
# -$(RM) libssh2_config.h
|
||||
-$(RM) $(TARGET).dll $(TARGET).$(LIBEXT) $(TARGET)dll.$(LIBEXT)
|
||||
-$(RM) -r $(OBJDIR)
|
||||
-$(RD) $(OBJDIR)
|
||||
|
||||
$(OBJDIR):
|
||||
@$(MD) $@
|
@@ -57,7 +57,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib ws2_32.lib libeay32.lib ssleay32.lib zlib.lib /nologo /dll /map /debug /machine:I386 /out:"Release_dll/libssh2.dll"
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib libeay32.lib zlib.lib /nologo /dll /map /debug /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 DLL Debug"
|
||||
|
||||
@@ -73,7 +73,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# SUBTRACT CPP /WX /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
@@ -84,7 +84,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib ws2_32.lib libeay32.lib ssleay32.lib zlib.lib /nologo /dll /incremental:no /map /debug /machine:I386 /out:"Debug_dll/libssh2.dll" /pdbtype:sept
|
||||
# ADD LINK32 gdi32.lib advapi32.lib user32.lib kernel32.lib ws2_32.lib libeay32.lib zlib.lib /nologo /dll /incremental:no /map /debug /machine:I386 /pdbtype:sept
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "libssh2 - Win32 LIB Release"
|
||||
@@ -124,7 +124,7 @@ LIB32=link.exe -lib
|
||||
# PROP Intermediate_Dir "Debug_lib"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#########################################################################
|
||||
#
|
||||
## Makefile for building libssh2 samples (Win32 version - gnu make)
|
||||
## Use: make -f Makefile.win32 [help]
|
||||
## Use: make -f Makefile.mingw [help]
|
||||
##
|
||||
## Comments to: Guenter Knauf http://www.gknw.net/phpbb
|
||||
#
|
||||
@@ -14,7 +14,12 @@ endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8q
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8r
|
||||
endif
|
||||
|
||||
# Edit the var below to set to your architecture or set environment var.
|
||||
ifndef ARCH
|
||||
ARCH = w32
|
||||
endif
|
||||
|
||||
# Edit the var below to enable static linking of libssh2 and libz
|
||||
@@ -23,7 +28,7 @@ LINK_STATIC = 1
|
||||
# Edit the vars below to change target settings.
|
||||
TARGETS = scp.exe sftp.exe sftpdir.exe ssh2.exe
|
||||
VERSION = $(LIBSSH2_VERSION)
|
||||
COPYR = (c) 2004-2010 The libssh2 project and its contributors.
|
||||
COPYR = (c) $(LIBSSH2_COPYRIGHT_STR)
|
||||
WWWURL = http://www.libssh2.org/
|
||||
DESCR = libssh2 $(subst .def,,$(notdir $@)) $(LIBSSH2_VERSION_STR)
|
||||
#STACK = 64000
|
||||
@@ -45,6 +50,26 @@ endif
|
||||
# Include the version info retrieved from libssh2.h
|
||||
-include $(OBJDIR)/version.inc
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
MD = mkdir
|
||||
RD = rm -fr
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
CP = copy
|
||||
RM = del /q /f 2>NUL
|
||||
MD = md
|
||||
RD = rd /q /s 2>NUL
|
||||
XX =
|
||||
DS = $(XX)\$(XX)
|
||||
endif
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
ZIP = zip -qzr9
|
||||
|
||||
# The following line defines your compiler.
|
||||
ifdef METROWERKS
|
||||
CC = mwcc
|
||||
@@ -60,6 +85,9 @@ ZIP = zip -qzr9
|
||||
|
||||
# Global flags for all compilers
|
||||
CFLAGS = $(OPT) -D$(DB) -DWIN32 -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
endif
|
||||
CFLAGS += -DWINSOCK_VERSION=MAKEWORD(2,0)
|
||||
|
||||
ifeq ($(CC),mwcc)
|
||||
@@ -115,13 +143,6 @@ endif
|
||||
|
||||
CFLAGS += $(INCLUDES)
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
DS = \\
|
||||
endif
|
||||
|
||||
vpath %.c ../../example
|
||||
|
||||
.PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.rc $(OBJDIR)/%.res
|
||||
@@ -140,13 +161,13 @@ $(OBJDIR)/version.inc: ../../include/libssh2.h $(OBJDIR)
|
||||
@$(AWK) -f ../../get_ver.awk $< > $@
|
||||
|
||||
objclean:
|
||||
-$(RM) -r $(OBJDIR)
|
||||
-$(RD) $(OBJDIR)
|
||||
|
||||
clean: objclean
|
||||
-$(RM) $(TARGETS)
|
||||
|
||||
$(OBJDIR):
|
||||
@mkdir $@
|
||||
$(MD) $@
|
||||
|
||||
%.exe: $(OBJDIR)/%.o $(OBJDIR)/%.res
|
||||
@echo Linking $@
|
Reference in New Issue
Block a user