Compare commits
68 Commits
libssh2-1.
...
libssh2-1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f1cfa55b60 | ||
![]() |
437a3b75ec | ||
![]() |
a3ad635db4 | ||
![]() |
e5c5408564 | ||
![]() |
fe8f3deb48 | ||
![]() |
d49b8f303a | ||
![]() |
6f8777505f | ||
![]() |
52b8da7dfa | ||
![]() |
de7b5d3bc0 | ||
![]() |
b31e35aba6 | ||
![]() |
e2bb780d77 | ||
![]() |
a8cfc708c5 | ||
![]() |
9f6fd5af82 | ||
![]() |
5d567faecc | ||
![]() |
bfbb5a4dc7 | ||
![]() |
43b730ce56 | ||
![]() |
6af85b6053 | ||
![]() |
05641218bc | ||
![]() |
42fec44c8a | ||
![]() |
e470738a0c | ||
![]() |
62cc59cd06 | ||
![]() |
1abf2057de | ||
![]() |
6c27922ac1 | ||
![]() |
112845df0b | ||
![]() |
499b22ca36 | ||
![]() |
6403519fcf | ||
![]() |
6f8dd9baff | ||
![]() |
a1c0d97ff9 | ||
![]() |
5c065bf1ff | ||
![]() |
5237177daf | ||
![]() |
bd627d38a1 | ||
![]() |
c55b0b0425 | ||
![]() |
38efbe8243 | ||
![]() |
34ecc09a3c | ||
![]() |
d6cf1c7df0 | ||
![]() |
a40c160cff | ||
![]() |
29e256e817 | ||
![]() |
137342a41d | ||
![]() |
79a7ca3085 | ||
![]() |
50e37bdadc | ||
![]() |
04e79e0c79 | ||
![]() |
9a36065b52 | ||
![]() |
1ac7bd09cc | ||
![]() |
9a7311ba57 | ||
![]() |
e07b11b7df | ||
![]() |
e885300b18 | ||
![]() |
92a9f95279 | ||
![]() |
e91d4c9790 | ||
![]() |
69a3354467 | ||
![]() |
3ede6e280e | ||
![]() |
b583311a93 | ||
![]() |
27ac5aa40d | ||
![]() |
a123051200 | ||
![]() |
62901253a4 | ||
![]() |
7c5ee0fa66 | ||
![]() |
1e15075a8e | ||
![]() |
ad63fc2df6 | ||
![]() |
d46185eaa5 | ||
![]() |
9c4b380dd6 | ||
![]() |
e887a8bd0f | ||
![]() |
04692445d4 | ||
![]() |
a955f8428b | ||
![]() |
ededdfa9c2 | ||
![]() |
11f9dce3d7 | ||
![]() |
6bbebcf36c | ||
![]() |
7a87bba02a | ||
![]() |
c8374cdc10 | ||
![]() |
9b2bed22fc |
31
AUTHORS
31
AUTHORS
@@ -6,32 +6,57 @@
|
||||
Adam Gobiowski
|
||||
Alexander Holyapin
|
||||
Alexander Lamaison
|
||||
Alfred Gebert
|
||||
Ben Kibbey
|
||||
Bjorn Stenborg
|
||||
Carlo Bramini
|
||||
Cristian Rodríguez
|
||||
Daiki Ueno
|
||||
Dan Casey
|
||||
Dan Fandrich
|
||||
Daniel Stenberg
|
||||
Dave Hayden
|
||||
Dave McCaldon
|
||||
David J Sullivan
|
||||
David Robins
|
||||
Dmitry Smirnov
|
||||
Douglas Masterson
|
||||
Edink Kadribasic
|
||||
Erik Brossler
|
||||
Francois Dupoux
|
||||
Gellule Xg
|
||||
Grubsky Grigory
|
||||
Guenter Knauf
|
||||
Heiner Steven
|
||||
Henrik Nordstrom
|
||||
James Housleys
|
||||
Jasmeet Bagga
|
||||
Jean-Louis Charton
|
||||
Jernej Kovacic
|
||||
Joey Degges
|
||||
John Little
|
||||
Jose Baars
|
||||
Jussi Mononen
|
||||
Kamil Dudka
|
||||
Lars Nordin
|
||||
Mark McPherson
|
||||
Mark Smith
|
||||
Markus Moeller
|
||||
Matt Lilley
|
||||
Matthew Booth
|
||||
Maxime Larocque
|
||||
Mike Protts
|
||||
Mikhail Gusarov
|
||||
Neil Gierman
|
||||
Olivier Hervieu
|
||||
Paul Howarth
|
||||
Paul Querna
|
||||
Paul Veldkamp
|
||||
Peter Krempa
|
||||
Peter O'Gorman
|
||||
Peter Stuge
|
||||
Pierre Joye
|
||||
Rafael Kitover
|
||||
Romain Bondue
|
||||
Sara Golemon
|
||||
Satish Mittal
|
||||
@@ -39,10 +64,16 @@ Sean Peterson
|
||||
Selcuk Gueney
|
||||
Simon Hart
|
||||
Simon Josefsson
|
||||
Sofian Brabez
|
||||
Steven Ayre
|
||||
Steven Dake
|
||||
Steven Van Ingelgem
|
||||
TJ Saunders
|
||||
Tommy Lindgren
|
||||
Tor Arntsen
|
||||
Vincent Jaulin
|
||||
Vincent Torri
|
||||
Vlad Grachov
|
||||
Wez Furlong
|
||||
Yang Tse
|
||||
Zl Liu
|
||||
|
14
Makefile.am
14
Makefile.am
@@ -1,6 +1,9 @@
|
||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||
|
||||
SUBDIRS = src example tests docs
|
||||
SUBDIRS = src tests docs
|
||||
if BUILD_EXAMPLES
|
||||
SUBDIRS += example
|
||||
endif
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libssh2.pc
|
||||
@@ -11,10 +14,9 @@ include_HEADERS = \
|
||||
include/libssh2_sftp.h
|
||||
|
||||
NETWAREFILES = nw/keepscreen.c \
|
||||
nw/Makefile \
|
||||
nw/Makefile.netware \
|
||||
nw/nwlib.c \
|
||||
nw/test/Makefile.netware
|
||||
nw/nwlib.c \
|
||||
nw/GNUmakefile \
|
||||
nw/test/GNUmakefile
|
||||
|
||||
DSP = win32/libssh2.dsp
|
||||
VCPROJ = win32/libssh2.vcproj
|
||||
@@ -31,7 +33,7 @@ win32/Makefile.Watcom win32/libssh2.dsw win32/tests.dsp $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk HACKING \
|
||||
maketgz NMakefile TODO RELEASE-NOTES libssh2.pc.in $(VMSFILES)
|
||||
maketgz NMakefile TODO RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
|
25
NMakefile
25
NMakefile
@@ -1,19 +1,28 @@
|
||||
!include "win32/config.mk"
|
||||
|
||||
!include "Makefile.inc"
|
||||
|
||||
OBJECTS=$(CSOURCES:.c=.obj)
|
||||
|
||||
# SUBDIRS=src example
|
||||
SUBDIRS=src
|
||||
|
||||
all-sub:
|
||||
all-sub: win32\objects.mk
|
||||
-for %D in ($(SUBDIRS)) do $(MAKE) /nologo /f %D/NMakefile BUILD=$(BUILD) SUBDIR=%D all-sub
|
||||
|
||||
clean:
|
||||
-rmdir /s/q $(TARGET)
|
||||
-rmdir 2>NUL /s/q $(TARGET)
|
||||
|
||||
real-clean: clean
|
||||
-del libssh2.dll
|
||||
-del libssh2.exp
|
||||
-del libssh2.ilk
|
||||
-del libssh2.lib
|
||||
-del *.pdb
|
||||
real-clean vclean: clean
|
||||
-del 2>NUL libssh2.dll
|
||||
-del 2>NUL libssh2.exp
|
||||
-del 2>NUL libssh2.ilk
|
||||
-del 2>NUL libssh2.lib
|
||||
-del 2>NUL *.pdb
|
||||
-del 2>NUL win32\objects.mk
|
||||
|
||||
win32\objects.mk: Makefile.inc
|
||||
@echo OBJECTS = \>$@
|
||||
@for %O in ($(OBJECTS)) do @echo $$(INTDIR)\%O \>>$@
|
||||
@echo $$(EOL)>>$@
|
||||
|
||||
|
@@ -1,28 +1,28 @@
|
||||
libssh2 1.4.1
|
||||
libssh2 1.4.3
|
||||
|
||||
This release includes the following changes:
|
||||
|
||||
o compression: add support for zlib@openssh.com
|
||||
|
||||
This release includes the following bugfixes:
|
||||
|
||||
o build error with gcrypt backend
|
||||
o always do "forced" window updates to avoid corner case stalls
|
||||
o aes: the init function fails when OpenSSL has AES support
|
||||
o transport_send: Finish in-progress key exchange before sending data
|
||||
o channel_write: acknowledge transport errors
|
||||
o examples/x11.c: Make sure sizeof passed to read operation is correct
|
||||
o examples/x11.c:,Fix suspicious sizeof usage
|
||||
o sftp_packet_add: verify the packet before accepting it
|
||||
o SFTP: preserve the original error code more
|
||||
o sftp_packet_read: adjust window size as necessary
|
||||
o Use safer snprintf rather then sprintf in several places
|
||||
o Define and use LIBSSH2_INVALID_SOCKET instead of INVALID_SOCKET
|
||||
o sftp_write: cannot return acked data *and* EAGAIN
|
||||
o sftp_read: avoid data *and* EAGAIN
|
||||
o libssh2.h: Add missing prototype for libssh2_session_banner_set()
|
||||
o sftp_read: return error if a too large package arrives
|
||||
o libssh2_hostkey_hash.3: update the description of return value
|
||||
o Fixed MSVC NMakefile
|
||||
o examples: use stderr for messages, stdout for data
|
||||
o openssl: do not leak memory when handling errors
|
||||
o improved handling of disabled MD5 algorithm in OpenSSL
|
||||
o known_hosts: Fail when parsing unknown keys in known_hosts file
|
||||
o configure: gcrypt doesn't come with pkg-config support
|
||||
o session_free: wrong variable used for keeping state
|
||||
o libssh2_userauth_publickey_fromfile_ex.3: mention publickey == NULL
|
||||
o comp_method_zlib_decomp: handle Z_BUF_ERROR when inflating
|
||||
|
||||
This release would not have looked like this without help, code, reports and
|
||||
advice from friends like these:
|
||||
|
||||
Armen Babakhanian, Paul Howarth, Matthew Booth, Steven Dake, Peter Stuge,
|
||||
Matt Lawson, Tom Weber, Alexander Lamaison
|
||||
Guenter Knauf, Peter Stuge, TJ Saunders, Mike Abdullah, Maxime Larocque,
|
||||
Dmitry Smirnov, Dave Hayden, Peter Krempa, Kamil Dudka
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
|
||||
|
21
configure.ac
21
configure.ac
@@ -96,13 +96,17 @@ AC_ARG_WITH(libz,
|
||||
# Look for OpenSSL (default)
|
||||
if test "$use_openssl" != "no" && test "$use_libgcrypt" != "yes"; then
|
||||
AC_LIB_HAVE_LINKFLAGS([ssl], [crypto], [#include <openssl/ssl.h>])
|
||||
LIBSREQUIRED=libssl,libcrypto
|
||||
fi
|
||||
|
||||
# Look for libgcrypt
|
||||
if test "$ac_cv_libssl" != "yes" && test "$use_libgcrypt" != "no"; then
|
||||
AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
|
||||
LIBS="$LIBS -lgcrypt"
|
||||
fi
|
||||
|
||||
AC_SUBST(LIBSREQUIRED)
|
||||
|
||||
if test "$ac_cv_libssl" != "yes" && test "$ac_cv_libgcrypt" != "yes"; then
|
||||
AC_MSG_ERROR([cannot find OpenSSL or Libgcrypt,
|
||||
try --with-libssl-prefix=PATH or --with-libgcrypt-prefix=PATH])
|
||||
@@ -215,6 +219,22 @@ AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibi
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
|
||||
# Build example applications?
|
||||
AC_MSG_CHECKING([whether to build example applications])
|
||||
AC_ARG_ENABLE([examples-build],
|
||||
AC_HELP_STRING([--enable-examples-build], [Build example applications (this is the default)])
|
||||
AC_HELP_STRING([--disable-examples-build], [Do not build example applications]),
|
||||
[case "$enableval" in
|
||||
no | false)
|
||||
build_examples='no'
|
||||
;;
|
||||
*)
|
||||
build_examples='yes'
|
||||
;;
|
||||
esac], [build_examples='yes'])
|
||||
AC_MSG_RESULT($build_examples)
|
||||
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
|
||||
|
||||
# Checks for header files.
|
||||
# AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h])
|
||||
@@ -300,6 +320,7 @@ AC_MSG_NOTICE([summary of build options:
|
||||
Library types: Shared=${enable_shared}, Static=${enable_static}
|
||||
Crypto library: openssl: ${ac_cv_libssl:-no} (AES-CTR: ${ac_cv_func_EVP_aes_128_ctr:-N/A}) libgcrypt: ${ac_cv_libgcrypt:-no}
|
||||
Debug build: $enable_debug
|
||||
Build examples: $build_examples
|
||||
Path to sshd: $ac_cv_path_SSHD (only for self-tests)
|
||||
libz compression: $ac_cv_libz
|
||||
])
|
||||
|
29
docs/BINDINGS
Normal file
29
docs/BINDINGS
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
Creative people have written bindings or interfaces for various environments
|
||||
and programming languages. Using one of these bindings allows you to take
|
||||
advantage of libssh2 directly from within your favourite language.
|
||||
|
||||
The bindings listed below are not part of the libssh2 distribution archives,
|
||||
but must be downloaded and installed separately.
|
||||
|
||||
Cocoa/Objective-C
|
||||
https://github.com/karelia/libssh2_sftp-Cocoa-wrapper
|
||||
|
||||
Haskell
|
||||
FFI bindings - http://hackage.haskell.org/package/libssh2
|
||||
|
||||
Perl
|
||||
Net::SSH2 - http://search.cpan.org/~rkitover/Net-SSH2-0.45/lib/Net/SSH2.pm
|
||||
|
||||
PHP
|
||||
ssh2 - http://pecl.php.net/package/ssh2
|
||||
|
||||
Python
|
||||
pylibssh2 - http://www.wallix.org/pylibssh2-project/
|
||||
|
||||
Python-ctypes
|
||||
|
||||
PySsh2 - https://github.com/gellule/PySsh2
|
||||
|
||||
Ruby
|
||||
libssh2-ruby - https://github.com/mitchellh/libssh2-ruby
|
@@ -1,6 +1,6 @@
|
||||
# $Id: Makefile.am,v 1.37 2009/03/26 15:41:15 bagder Exp $
|
||||
|
||||
EXTRA_DIST = template.3
|
||||
EXTRA_DIST = template.3 BINDINGS
|
||||
|
||||
dist_man_MANS = \
|
||||
libssh2_agent_connect.3 \
|
||||
|
@@ -18,8 +18,9 @@ Returns the computed digest of the remote system's hostkey. The length of
|
||||
the returned string is hash_type specific (e.g. 16 bytes for MD5,
|
||||
20 bytes for SHA1).
|
||||
.SH RETURN VALUE
|
||||
Computed hostkey hash value. or NULL if the session has not yet been started
|
||||
up. (The hash consists of raw binary bytes, not hex digits, so is not
|
||||
directly printable.)
|
||||
Computed hostkey hash value, or NULL if the information is not available
|
||||
(either the session has not yet been started up, or the requested hash
|
||||
algorithm was not available). The hash consists of raw binary bytes, not hex
|
||||
digits, so it is not directly printable.
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
@@ -11,20 +11,23 @@ int libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION *session,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
.SH DESCRIPTION
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
\fIsession\fP - Session instance as returned by
|
||||
\fBlibssh2_session_init_ex(3)\fP
|
||||
|
||||
\fIusername\fP - Remote user name to authenticate as.
|
||||
\fIusername\fP - Pointer to user name to authenticate as.
|
||||
|
||||
\fIusername_len\fP - Length of username.
|
||||
\fIusername_len\fP - Length of \fIusername\fP.
|
||||
|
||||
\fIpublickey\fP - Path and name of public key file. (e.g. /etc/ssh/hostkey.pub)
|
||||
\fIpublickey\fP - Path name of the public key file.
|
||||
(e.g. /etc/ssh/hostkey.pub). If libssh2 is built against OpenSSL, this option
|
||||
can be set to NULL.
|
||||
|
||||
\fIprivatekey\fP - Path and name of private key file. (e.g. /etc/ssh/hostkey)
|
||||
\fIprivatekey\fP - Path name of the private key file. (e.g. /etc/ssh/hostkey)
|
||||
|
||||
\fIpassphrase\fP - Passphrase to use when decoding private key file.
|
||||
\fIpassphrase\fP - Passphrase to use when decoding \fIprivatekey\fP.
|
||||
|
||||
Attempt public key authentication using a PEM encoded private key file stored on disk
|
||||
Attempt public key authentication using a PEM encoded private key file stored
|
||||
on disk
|
||||
|
||||
.SH RETURN VALUE
|
||||
Return 0 on success or negative on failure. It returns
|
||||
|
@@ -135,7 +135,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
printf("Authentication methods: %s\n", userauthlist);
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password"))
|
||||
auth |= AUTH_PASSWORD;
|
||||
if (strstr(userauthlist, "publickey"))
|
||||
@@ -157,12 +157,12 @@ int main(int argc, char *argv[])
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
printf("\tAuthentication by public key failed!\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
printf("\tAuthentication by public key succeeded.\n");
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
} else {
|
||||
printf("No supported authentication methods found!\n");
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
printf("Waiting for TCP connection on %s:%d...\n",
|
||||
fprintf(stderr, "Waiting for TCP connection on %s:%d...\n",
|
||||
inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
|
||||
forwardsock = accept(listensock, (struct sockaddr *)&sin, &sinlen);
|
||||
@@ -197,8 +197,8 @@ int main(int argc, char *argv[])
|
||||
shost = inet_ntoa(sin.sin_addr);
|
||||
sport = ntohs(sin.sin_port);
|
||||
|
||||
printf("Forwarding connection from %s:%d here to remote %s:%d\n", shost,
|
||||
sport, remote_desthost, remote_destport);
|
||||
fprintf(stderr, "Forwarding connection from %s:%d here to remote %s:%d\n",
|
||||
shost, sport, remote_desthost, remote_destport);
|
||||
|
||||
channel = libssh2_channel_direct_tcpip_ex(session, remote_desthost,
|
||||
remote_destport, shost, sport);
|
||||
@@ -228,7 +228,8 @@ int main(int argc, char *argv[])
|
||||
perror("read");
|
||||
goto shutdown;
|
||||
} else if (0 == len) {
|
||||
printf("The client at %s:%d disconnected!\n", shost, sport);
|
||||
fprintf(stderr, "The client at %s:%d disconnected!\n", shost,
|
||||
sport);
|
||||
goto shutdown;
|
||||
}
|
||||
wr = 0;
|
||||
@@ -259,7 +260,7 @@ int main(int argc, char *argv[])
|
||||
wr += i;
|
||||
}
|
||||
if (libssh2_channel_eof(channel)) {
|
||||
printf("The server at %s:%d disconnected!\n",
|
||||
fprintf(stderr, "The server at %s:%d disconnected!\n",
|
||||
remote_desthost, remote_destport);
|
||||
goto shutdown;
|
||||
}
|
||||
|
@@ -250,7 +250,7 @@ int main(int argc, char *argv[])
|
||||
gettimeofday(&end, NULL);
|
||||
|
||||
time_ms = tvdiff(end, start);
|
||||
printf("Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin );
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
|
@@ -243,7 +243,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
duration = (int)(time(NULL)-start);
|
||||
|
||||
printf("%ld bytes in %d seconds makes %.1f bytes/sec\n",
|
||||
fprintf(stderr, "%ld bytes in %d seconds makes %.1f bytes/sec\n",
|
||||
total, duration, total/(double)duration);
|
||||
|
||||
fprintf(stderr, "Sending EOF\n");
|
||||
|
@@ -55,24 +55,24 @@ static void kbd_callback(const char *name, int name_len,
|
||||
char buf[1024];
|
||||
(void)abstract;
|
||||
|
||||
printf("Performing keyboard-interactive authentication.\n");
|
||||
fprintf(stderr, "Performing keyboard-interactive authentication.\n");
|
||||
|
||||
printf("Authentication name: '");
|
||||
fwrite(name, 1, name_len, stdout);
|
||||
printf("'\n");
|
||||
fprintf(stderr, "Authentication name: '");
|
||||
fwrite(name, 1, name_len, stderr);
|
||||
fprintf(stderr, "'\n");
|
||||
|
||||
printf("Authentication instruction: '");
|
||||
fwrite(instruction, 1, instruction_len, stdout);
|
||||
printf("'\n");
|
||||
fprintf(stderr, "Authentication instruction: '");
|
||||
fwrite(instruction, 1, instruction_len, stderr);
|
||||
fprintf(stderr, "'\n");
|
||||
|
||||
printf("Number of prompts: %d\n\n", num_prompts);
|
||||
fprintf(stderr, "Number of prompts: %d\n\n", num_prompts);
|
||||
|
||||
for (i = 0; i < num_prompts; i++) {
|
||||
printf("Prompt %d from server: '", i);
|
||||
fwrite(prompts[i].text, 1, prompts[i].length, stdout);
|
||||
printf("'\n");
|
||||
fprintf(stderr, "Prompt %d from server: '", i);
|
||||
fwrite(prompts[i].text, 1, prompts[i].length, stderr);
|
||||
fprintf(stderr, "'\n");
|
||||
|
||||
printf("Please type response: ");
|
||||
fprintf(stderr, "Please type response: ");
|
||||
fgets(buf, sizeof(buf), stdin);
|
||||
n = strlen(buf);
|
||||
while (n > 0 && strchr("\r\n", buf[n - 1]))
|
||||
@@ -82,12 +82,13 @@ static void kbd_callback(const char *name, int name_len,
|
||||
responses[i].text = strdup(buf);
|
||||
responses[i].length = n;
|
||||
|
||||
printf("Response %d from user is '", i);
|
||||
fwrite(responses[i].text, 1, responses[i].length, stdout);
|
||||
printf("'\n\n");
|
||||
fprintf(stderr, "Response %d from user is '", i);
|
||||
fwrite(responses[i].text, 1, responses[i].length, stderr);
|
||||
fprintf(stderr, "'\n\n");
|
||||
}
|
||||
|
||||
printf("Done. Sending keyboard-interactive responses to server now.\n");
|
||||
fprintf(stderr,
|
||||
"Done. Sending keyboard-interactive responses to server now.\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +128,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -178,7 +179,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
printf("Authentication methods: %s\n", userauthlist);
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password") != NULL) {
|
||||
auth_pw |= 1;
|
||||
}
|
||||
@@ -211,21 +212,23 @@ int main(int argc, char *argv[])
|
||||
} else if (auth_pw & 2) {
|
||||
/* Or via keyboard-interactive */
|
||||
if (libssh2_userauth_keyboard_interactive(session, username, &kbd_callback) ) {
|
||||
printf("\tAuthentication by keyboard-interactive failed!\n");
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
printf("\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 4) {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1, keyfile2, password)) {
|
||||
printf("\tAuthentication by public key failed!\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
printf("\tAuthentication by public key succeeded.\n");
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
}
|
||||
} else {
|
||||
printf("No supported authentication methods found!\n");
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
|
@@ -141,11 +141,11 @@ int main(int argc, char *argv[])
|
||||
* user, that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if(argc > 1) {
|
||||
username = argv[1];
|
||||
@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
tempstorage = fopen(STORAGE, "wb");
|
||||
if(!tempstorage) {
|
||||
printf("Can't open temp storage file %s\n", STORAGE);
|
||||
fprintf(stderr, "Can't open temp storage file %s\n", STORAGE);
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
|
||||
while ((rc = libssh2_userauth_password(session, username, password))
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
printf("Authentication by password failed.\n");
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
@@ -185,7 +185,7 @@ int main(int argc, char *argv[])
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
printf("\tAuthentication by public key failed\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (tempstorage)
|
||||
fclose(tempstorage);
|
||||
printf("all done\n");
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
printf("Can't local file %s\n", loclfile);
|
||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -129,16 +129,16 @@ int main(int argc, char *argv[])
|
||||
* user, that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
printf("Authentication by password failed.\n");
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
printf("\tAuthentication by public key failed\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
@@ -174,12 +174,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if(libssh2_sftp_fstat_ex(sftp_handle, &attrs, 0) < 0) {
|
||||
printf("libssh2_sftp_fstat_ex failed\n");
|
||||
fprintf(stderr, "libssh2_sftp_fstat_ex failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
else
|
||||
libssh2_sftp_seek64(sftp_handle, attrs.filesize);
|
||||
printf("Did a seek to position %ld\n", (long) attrs.filesize);
|
||||
fprintf(stderr, "Did a seek to position %ld\n", (long) attrs.filesize);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open() a handle for APPEND\n");
|
||||
|
||||
@@ -222,7 +222,7 @@ shutdown:
|
||||
#endif
|
||||
if (local)
|
||||
fclose(local);
|
||||
printf("all done\n");
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -110,16 +110,16 @@ int main(int argc, char *argv[])
|
||||
* user, that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
printf("Authentication by password failed.\n");
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
@@ -128,7 +128,7 @@ int main(int argc, char *argv[])
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
printf("\tAuthentication by public key failed\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
printf("all done\n");
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -110,16 +110,16 @@ int main(int argc, char *argv[])
|
||||
* user, that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
printf("Authentication by password failed.\n");
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
@@ -128,7 +128,7 @@ int main(int argc, char *argv[])
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
printf("\tAuthentication by public key failed\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
printf("all done\n");
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -251,7 +251,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
gettimeofday(&end, NULL);
|
||||
time_ms = tvdiff(end, start);
|
||||
printf("Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin );
|
||||
|
||||
libssh2_sftp_close(sftp_handle);
|
||||
@@ -259,7 +259,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
printf("libssh2_session_disconnect\n");
|
||||
fprintf(stderr, "libssh2_session_disconnect\n");
|
||||
while (libssh2_session_disconnect(session,
|
||||
"Normal Shutdown, Thank you") ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
|
@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
printf("Can't local file %s\n", loclfile);
|
||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -128,16 +128,16 @@ int main(int argc, char *argv[])
|
||||
* user, that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
printf("Authentication by password failed.\n");
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
@@ -146,7 +146,7 @@ int main(int argc, char *argv[])
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
printf("\tAuthentication by public key failed\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ shutdown:
|
||||
#endif
|
||||
if (local)
|
||||
fclose(local);
|
||||
printf("all done\n");
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
printf("Can't local file %s\n", loclfile);
|
||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -169,18 +169,18 @@ int main(int argc, char *argv[])
|
||||
* that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
printf("Authentication by password failed.\n");
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
printf("\tAuthentication by public key failed\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
duration = (int)(time(NULL)-start);
|
||||
|
||||
printf("%ld bytes in %d seconds makes %.1f bytes/sec\n",
|
||||
fprintf(stderr, "%ld bytes in %d seconds makes %.1f bytes/sec\n",
|
||||
total, duration, total/(double)duration);
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ shutdown:
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
printf("all done\n");
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
printf("Can't local file %s\n", loclfile);
|
||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -169,18 +169,18 @@ int main(int argc, char *argv[])
|
||||
* that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
printf("Authentication by password failed.\n");
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
printf("\tAuthentication by public key failed\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +262,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
duration = (int)(time(NULL)-start);
|
||||
|
||||
printf("%ld bytes in %d seconds makes %.1f bytes/sec\n",
|
||||
fprintf(stderr, "%ld bytes in %d seconds makes %.1f bytes/sec\n",
|
||||
total, duration, total/(double)duration);
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ shutdown:
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
printf("all done\n");
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -130,16 +130,16 @@ int main(int argc, char *argv[])
|
||||
* user, that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
printf("Authentication by password failed.\n");
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
printf("\tAuthentication by public key failed\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
@@ -229,7 +229,7 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
printf("all done\n");
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -134,11 +134,11 @@ int main(int argc, char *argv[])
|
||||
* user, that's your call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
@@ -239,7 +239,7 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
printf("all done\n");
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -126,15 +126,15 @@ int main(int argc, char *argv[])
|
||||
* call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
printf("Authentication methods: %s\n", userauthlist);
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password") != NULL) {
|
||||
auth_pw |= 1;
|
||||
}
|
||||
@@ -161,31 +161,33 @@ int main(int argc, char *argv[])
|
||||
if (auth_pw & 1) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
printf("\tAuthentication by password failed!\n");
|
||||
fprintf(stderr, "\tAuthentication by password failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
printf("\tAuthentication by password succeeded.\n");
|
||||
fprintf(stderr, "\tAuthentication by password succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 2) {
|
||||
/* Or via keyboard-interactive */
|
||||
if (libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
printf("\tAuthentication by keyboard-interactive failed!\n");
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
printf("\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 4) {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
printf("\tAuthentication by public key failed!\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
printf("\tAuthentication by public key succeeded.\n");
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
}
|
||||
} else {
|
||||
printf("No supported authentication methods found!\n");
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
@@ -250,7 +252,7 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
printf("all done!\n");
|
||||
fprintf(stderr, "all done!\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -105,15 +105,15 @@ int main(int argc, char *argv[])
|
||||
* call
|
||||
*/
|
||||
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
|
||||
printf("Fingerprint: ");
|
||||
fprintf(stderr, "Fingerprint: ");
|
||||
for(i = 0; i < 20; i++) {
|
||||
printf("%02X ", (unsigned char)fingerprint[i]);
|
||||
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
printf("Authentication methods: %s\n", userauthlist);
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "publickey") == NULL) {
|
||||
fprintf(stderr, "\"publickey\" authentication is not supported\n");
|
||||
goto shutdown;
|
||||
@@ -147,11 +147,11 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
if (libssh2_agent_userauth(agent, username, identity)) {
|
||||
printf("\tAuthentication with username %s and "
|
||||
fprintf(stderr, "\tAuthentication with username %s and "
|
||||
"public key %s failed!\n",
|
||||
username, identity->comment);
|
||||
} else {
|
||||
printf("\tAuthentication with username %s and "
|
||||
fprintf(stderr, "\tAuthentication with username %s and "
|
||||
"public key %s succeeded!\n",
|
||||
username, identity->comment);
|
||||
break;
|
||||
@@ -234,7 +234,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
}
|
||||
|
||||
printf("all done!\n");
|
||||
fprintf(stderr, "all done!\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
|
@@ -327,7 +327,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (exitsignal)
|
||||
printf("\nGot signal: %s\n", exitsignal);
|
||||
fprintf(stderr, "\nGot signal: %s\n", exitsignal);
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
channel = NULL;
|
||||
|
@@ -292,9 +292,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (exitsignal)
|
||||
printf("\nGot signal: %s\n", exitsignal);
|
||||
fprintf(stderr, "\nGot signal: %s\n", exitsignal);
|
||||
else
|
||||
printf("\nEXIT: %d bytecount: %d\n", exitcode, bytecount);
|
||||
fprintf(stderr, "\nEXIT: %d bytecount: %d\n", exitcode, bytecount);
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
channel = NULL;
|
||||
|
@@ -173,7 +173,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
printf("Authentication methods: %s\n", userauthlist);
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password"))
|
||||
auth |= AUTH_PASSWORD;
|
||||
if (strstr(userauthlist, "publickey"))
|
||||
@@ -195,12 +195,12 @@ int main(int argc, char *argv[])
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
printf("Authentication by public key failed!\n");
|
||||
fprintf(stderr, "Authentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
printf("Authentication by public key succeeded.\n");
|
||||
fprintf(stderr, "Authentication by public key succeeded.\n");
|
||||
} else {
|
||||
printf("No supported authentication methods found!\n");
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* NETCONF: http://tools.ietf.org/html/draft-ietf-netconf-ssh-06 */
|
||||
|
||||
printf("Sending NETCONF client <hello>\n");
|
||||
fprintf(stderr, "Sending NETCONF client <hello>\n");
|
||||
snprintf(buf, sizeof(buf),
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
"<hello>"
|
||||
@@ -235,14 +235,14 @@ int main(int argc, char *argv[])
|
||||
if (-1 == netconf_write(channel, buf, len))
|
||||
goto shutdown;
|
||||
|
||||
printf("Reading NETCONF server <hello>\n");
|
||||
fprintf(stderr, "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", (int)len, buf);
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s", (int)len, buf);
|
||||
|
||||
printf("Sending NETCONF <rpc>\n");
|
||||
fprintf(stderr, "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\">"
|
||||
@@ -252,12 +252,12 @@ int main(int argc, char *argv[])
|
||||
if (-1 == netconf_write(channel, buf, len))
|
||||
goto shutdown;
|
||||
|
||||
printf("Reading NETCONF <rpc-reply>\n");
|
||||
fprintf(stderr, "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", (int)len, buf);
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s", (int)len, buf);
|
||||
|
||||
shutdown:
|
||||
if (channel)
|
||||
|
@@ -137,7 +137,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
printf("Authentication methods: %s\n", userauthlist);
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password"))
|
||||
auth |= AUTH_PASSWORD;
|
||||
if (strstr(userauthlist, "publickey"))
|
||||
@@ -159,17 +159,17 @@ int main(int argc, char *argv[])
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
printf("\tAuthentication by public key failed!\n");
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
printf("\tAuthentication by public key succeeded.\n");
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
} else {
|
||||
printf("No supported authentication methods found!\n");
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
printf("Asking server to listen on remote %s:%d\n", remote_listenhost,
|
||||
remote_wantport);
|
||||
fprintf(stderr, "Asking server to listen on remote %s:%d\n",
|
||||
remote_listenhost, remote_wantport);
|
||||
|
||||
listener = libssh2_channel_forward_listen_ex(session, remote_listenhost,
|
||||
remote_wantport, &remote_listenport, 1);
|
||||
@@ -180,10 +180,10 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
printf("Server is listening on %s:%d\n", remote_listenhost,
|
||||
fprintf(stderr, "Server is listening on %s:%d\n", remote_listenhost,
|
||||
remote_listenport);
|
||||
|
||||
printf("Waiting for remote connection\n");
|
||||
fprintf(stderr, "Waiting for remote connection\n");
|
||||
channel = libssh2_channel_forward_accept(listener);
|
||||
if (!channel) {
|
||||
fprintf(stderr, "Could not accept connection!\n"
|
||||
@@ -192,7 +192,8 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
printf("Accepted remote connection. Connecting to local server %s:%d\n",
|
||||
fprintf(stderr,
|
||||
"Accepted remote connection. Connecting to local server %s:%d\n",
|
||||
local_destip, local_destport);
|
||||
forwardsock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
sin.sin_family = AF_INET;
|
||||
@@ -206,7 +207,7 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
printf("Forwarding connection from remote %s:%d to local %s:%d\n",
|
||||
fprintf(stderr, "Forwarding connection from remote %s:%d to local %s:%d\n",
|
||||
remote_listenhost, remote_listenport, local_destip, local_destport);
|
||||
|
||||
/* Must use non-blocking IO hereafter due to the current libssh2 API */
|
||||
@@ -228,7 +229,7 @@ int main(int argc, char *argv[])
|
||||
perror("read");
|
||||
goto shutdown;
|
||||
} else if (0 == len) {
|
||||
printf("The local server at %s:%d disconnected!\n",
|
||||
fprintf(stderr, "The local server at %s:%d disconnected!\n",
|
||||
local_destip, local_destport);
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -260,7 +261,7 @@ int main(int argc, char *argv[])
|
||||
wr += i;
|
||||
}
|
||||
if (libssh2_channel_eof(channel)) {
|
||||
printf("The remote client at %s:%d disconnected!\n",
|
||||
fprintf(stderr, "The remote client at %s:%d disconnected!\n",
|
||||
remote_listenhost, remote_listenport);
|
||||
goto shutdown;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2009, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2009-2010 Daniel Stenberg
|
||||
* Copyright (c) 2009-2012 Daniel Stenberg
|
||||
* Copyright (c) 2010 Simon Josefsson <simon@josefsson.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -40,19 +40,19 @@
|
||||
#ifndef LIBSSH2_H
|
||||
#define LIBSSH2_H 1
|
||||
|
||||
#define LIBSSH2_COPYRIGHT "2004-2011 The libssh2 project and its contributors."
|
||||
#define LIBSSH2_COPYRIGHT "2004-2012 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.4.0_DEV"
|
||||
#define LIBSSH2_VERSION "1.4.3_DEV"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBSSH2_VERSION_MAJOR 1
|
||||
#define LIBSSH2_VERSION_MINOR 4
|
||||
#define LIBSSH2_VERSION_PATCH 0
|
||||
#define LIBSSH2_VERSION_PATCH 3
|
||||
|
||||
/* 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 0x010400
|
||||
#define LIBSSH2_VERSION_NUM 0x010403
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
@@ -405,6 +405,7 @@ typedef struct _LIBSSH2_POLLFD {
|
||||
#define LIBSSH2_ERROR_SOCKET_RECV -43
|
||||
#define LIBSSH2_ERROR_ENCRYPT -44
|
||||
#define LIBSSH2_ERROR_BAD_SOCKET -45
|
||||
#define LIBSSH2_ERROR_KNOWN_HOSTS -46
|
||||
|
||||
/* this is a define to provide the old (<= 1.2.7) name */
|
||||
#define LIBSSH2_ERROR_BANNER_NONE LIBSSH2_ERROR_BANNER_RECV
|
||||
|
@@ -11,6 +11,7 @@ Name: libssh2
|
||||
URL: http://www.libssh2.org/
|
||||
Description: Library for SSH-based communication
|
||||
Version: @LIBSSH2VER@
|
||||
Requires.private: @LIBSREQUIRED@
|
||||
Libs: -L${libdir} -lssh2 @LDFLAGS@ @LIBS@
|
||||
Libs.private: @LIBS@
|
||||
Cflags: -I${includedir}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#########################################################################
|
||||
#
|
||||
## Makefile for building libssh2 (NetWare version - gnu make)
|
||||
## Use: make -f Makefile.netware [help|all|clean|dev|devclean|dist|distclean|lib|nlm|objclean]
|
||||
## Use: make [help|all|clean|dev|devclean|dist|distclean|lib|nlm|objclean]
|
||||
##
|
||||
## Hacked by: Guenter Knauf
|
||||
#
|
||||
@@ -14,12 +14,12 @@ endif
|
||||
|
||||
# Edit the path below to point to the base of your Zlib sources.
|
||||
ifndef ZLIB_PATH
|
||||
ZLIB_PATH = ../../zlib-1.2.5
|
||||
ZLIB_PATH = ../../zlib-1.2.7
|
||||
endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../openssl-0.9.8r
|
||||
OPENSSL_PATH = ../../openssl-0.9.8x
|
||||
endif
|
||||
|
||||
# Edit the path below to point to your Distribution folder.
|
||||
@@ -76,10 +76,7 @@ ifdef METROWERKS
|
||||
else
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
endif
|
||||
CP = cp -afv
|
||||
MD = mkdir
|
||||
RD = rm -fr
|
||||
# RM = rm -f
|
||||
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
@@ -89,6 +86,34 @@ AWK = awk
|
||||
MPKXDC = mkxdc
|
||||
ZIP = zip -qzr9
|
||||
|
||||
# Platform-dependent helper tool macros
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DEL = rm -f $1
|
||||
RMDIR = rm -fr $1
|
||||
MKDIR = mkdir -p $1
|
||||
COPY = -cp -afv $1 $2
|
||||
#COPYR = -cp -afr $1/* $2
|
||||
COPYR = -rsync -aC $1/* $2
|
||||
TOUCH = touch $1
|
||||
CAT = cat
|
||||
ECHONL = echo ""
|
||||
DL = '
|
||||
else
|
||||
ifeq "$(OS)" "Windows_NT"
|
||||
DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
||||
RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
|
||||
else
|
||||
DEL = -del 2>NUL $(subst /,\,$1)
|
||||
RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
|
||||
endif
|
||||
MKDIR = -md 2>NUL $(subst /,\,$1)
|
||||
COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
|
||||
COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
|
||||
TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
|
||||
CAT = type
|
||||
ECHONL = $(ComSpec) /c echo.
|
||||
endif
|
||||
|
||||
# LIBARCH_U = $(shell $(AWK) 'BEGIN {print toupper(ARGV[1])}' $(LIBARCH))
|
||||
LIBARCH_L = $(shell $(AWK) 'BEGIN {print tolower(ARGV[1])}' $(LIBARCH))
|
||||
|
||||
@@ -120,13 +145,14 @@ else
|
||||
endif
|
||||
else
|
||||
LD = $(CROSSPREFIX)nlmconv
|
||||
LDFLAGS = -T
|
||||
LDFLAGS = -UT
|
||||
AR = $(CROSSPREFIX)ar
|
||||
ARFLAGS = -cq
|
||||
LIBEXT = a
|
||||
RANLIB = $(CROSSPREFIX)ranlib
|
||||
CFLAGS += -m32
|
||||
CFLAGS += -fno-builtin -fpcc-struct-return -fno-strict-aliasing
|
||||
CFLAGS += -m32
|
||||
CFLAGS += -fno-builtin -fpcc-struct-return
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
CFLAGS += -Wall # -pedantic
|
||||
#CFLAGS += -Wno-pointer-sign
|
||||
ifeq ($(LIBARCH),LIBC)
|
||||
@@ -185,13 +211,6 @@ ifdef XDCOPT
|
||||
XDCDATA = $(OBJDIR)/$(TARGET).xdc
|
||||
endif
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
DS = \\
|
||||
endif
|
||||
|
||||
vpath %.c . ../src
|
||||
|
||||
# include Makefile.inc to get CSOURCES define
|
||||
@@ -217,69 +236,74 @@ lib: prebuild $(TARGET).$(LIBEXT)
|
||||
prebuild: $(OBJDIR) $(OBJDIR)/version.inc libssh2_config.h
|
||||
|
||||
test: all
|
||||
$(MAKE) -C test -f Makefile.netware
|
||||
$(MAKE) -C test
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
# @echo Compiling $<
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/version.inc: ../include/libssh2.h $(OBJDIR)
|
||||
$(OBJDIR)/version.inc: ../get_ver.awk ../include/libssh2.h $(OBJDIR)
|
||||
@echo Creating $@
|
||||
@$(AWK) -f ../get_ver.awk $< > $@
|
||||
@$(AWK) -f $^ > $@
|
||||
|
||||
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
||||
@-$(MD) $(DISTDIR)$(DS)bin
|
||||
@-$(CP) ../COPYING $(DISTDIR)
|
||||
@-$(CP) ../INSTALL $(DISTDIR)
|
||||
@-$(CP) ../README $(DISTDIR)
|
||||
@$(CP) $(TARGET).nlm $(DISTDIR)/bin
|
||||
@$(call MD, $(DISTDIR)/bin)
|
||||
@$(call CP, ../AUTHORS, $(DISTDIR))
|
||||
@$(call CP, ../COPYING, $(DISTDIR))
|
||||
@$(call CP, ../INSTALL, $(DISTDIR))
|
||||
@$(call CP, ../README, $(DISTDIR))
|
||||
@$(call CP, ../RELEASE-NOTES, $(DISTDIR))
|
||||
@$(call CP, $(TARGET).nlm, $(DISTDIR)/bin)
|
||||
@echo Creating $(DISTARC)
|
||||
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
|
||||
|
||||
dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
|
||||
@-$(MD) $(DEVLDIR)$(DS)bin
|
||||
@-$(MD) $(DEVLDIR)$(DS)include
|
||||
@-$(MD) $(DEVLDIR)$(DS)nw
|
||||
@-$(CP) ../COPYING $(DISTDIR)
|
||||
@-$(CP) ../INSTALL $(DEVLDIR)
|
||||
@-$(CP) ../README $(DEVLDIR)
|
||||
@$(CP) $(TARGET).nlm $(DEVLDIR)/bin
|
||||
@$(CP) ../include/*.h $(DEVLDIR)/include
|
||||
@$(CP) libssh2_config.h $(DEVLDIR)/include
|
||||
@$(CP) $(TARGET).$(LIBEXT) $(DEVLDIR)/nw
|
||||
@$(call MD, $(DEVLDIR)/bin)
|
||||
@$(call MD, $(DEVLDIR)/include)
|
||||
@$(call MD, $(DEVLDIR)/nw)
|
||||
@$(call CP, ../AUTHORS, $(DEVLDIR))
|
||||
@$(call CP, ../COPYING, $(DEVLDIR))
|
||||
@$(call CP, ../INSTALL, $(DEVLDIR))
|
||||
@$(call CP, ../README, $(DEVLDIR))
|
||||
@$(call CP, ../RELEASE-NOTES, $(DEVLDIR))
|
||||
@$(call CP, ../include/*.h, $(DEVLDIR)/include)
|
||||
@$(call CP, libssh2_config.h, $(DEVLDIR)/include)
|
||||
@$(call CP, $(TARGET).nlm, $(DEVLDIR)/bin)
|
||||
@$(call CP, $(TARGET).imp, $(DEVLDIR)/nw)
|
||||
@$(call CP, $(TARGET).$(LIBEXT), $(DEVLDIR)/nw)
|
||||
@echo Creating $(DEVLARC)
|
||||
@$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
|
||||
|
||||
distclean: clean
|
||||
-$(RD) $(DISTDIR)
|
||||
-$(RM) $(DISTARC)
|
||||
$(call RMDIR, $(DISTDIR))
|
||||
$(call DEL, $(DISTARC))
|
||||
|
||||
devclean: clean
|
||||
-$(RD) $(DEVLDIR)
|
||||
-$(RM) $(DEVLARC)
|
||||
$(call RMDIR, $(DEVLDIR))
|
||||
$(call DEL, $(DEVLARC))
|
||||
|
||||
objclean:
|
||||
-$(RD) $(OBJDIR)
|
||||
$(call RMDIR, $(OBJDIR))
|
||||
|
||||
testclean: clean
|
||||
$(MAKE) -C test -f Makefile.netware clean
|
||||
$(MAKE) -C test clean
|
||||
|
||||
clean: objclean
|
||||
-$(RM) libssh2_config.h
|
||||
-$(RM) $(TARGET).nlm $(TARGET).$(LIBEXT) $(TARGET).imp
|
||||
$(call DEL, libssh2_config.h)
|
||||
$(call DEL, $(TARGET).*)
|
||||
|
||||
$(OBJDIR):
|
||||
@$(MD) $@
|
||||
@$(call MKDIR, $@)
|
||||
|
||||
$(DISTDIR):
|
||||
@$(MD) $@
|
||||
@$(call MKDIR, $@)
|
||||
|
||||
$(DEVLDIR):
|
||||
@$(MD) $@
|
||||
@$(call MKDIR, $@)
|
||||
|
||||
$(TARGET).$(LIBEXT): $(OBJS)
|
||||
@echo Creating $@
|
||||
@-$(RM) $@
|
||||
@$(call DEL, $@)
|
||||
@$(AR) $(ARFLAGS) $@ $^
|
||||
ifdef RANLIB
|
||||
@$(RANLIB) $@
|
||||
@@ -287,14 +311,14 @@ endif
|
||||
|
||||
$(TARGET).nlm: $(OBJDIR)/$(TARGET).def $(TARGET).imp $(OBJL) $(XDCDATA)
|
||||
@echo Linking $@
|
||||
@-$(RM) $@
|
||||
@$(call DEL, $@)
|
||||
@$(LD) $(LDFLAGS) $<
|
||||
|
||||
$(OBJDIR)/%.xdc: Makefile.netware
|
||||
$(OBJDIR)/%.xdc: GNUmakefile
|
||||
@echo Creating $@
|
||||
@$(MPKXDC) $(XDCOPT) $@
|
||||
|
||||
$(OBJDIR)/%.def: Makefile.netware
|
||||
$(OBJDIR)/%.def: GNUmakefile
|
||||
@echo $(DL)# DEF file for linking with $(LD)$(DL) > $@
|
||||
@echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
|
||||
@echo $(DL)# All your changes will be lost!!$(DL) >> $@
|
||||
@@ -353,7 +377,7 @@ ifeq ($(LD),nlmconv)
|
||||
@echo $(DL)output $(TARGET).nlm$(DL) >> $@
|
||||
endif
|
||||
|
||||
libssh2_config.h: Makefile.netware
|
||||
libssh2_config.h: GNUmakefile
|
||||
@echo Creating $@
|
||||
@echo $(DL)/* $@ for NetWare target.$(DL) > $@
|
||||
@echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
|
||||
@@ -479,7 +503,7 @@ ifeq ($(DB),DEBUG)
|
||||
@echo $(DL)#define LIBSSH2_DEBUG_USERAUTH 1$(DL) >> $@
|
||||
endif
|
||||
|
||||
libssh2.imp: Makefile.netware
|
||||
libssh2.imp: GNUmakefile
|
||||
@echo Creating $@
|
||||
@echo $(DL)# $@ for NetWare target.$(DL) > $@
|
||||
@echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
|
||||
@@ -554,7 +578,7 @@ endif
|
||||
@echo $(DL) libssh2_userauth_password_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_userauth_publickey_fromfile_ex$(DL) >> $@
|
||||
|
||||
$(DISTDIR)/readme.txt: Makefile.netware
|
||||
$(DISTDIR)/readme.txt: GNUmakefile
|
||||
@echo Creating $@
|
||||
@echo $(DL)This is a binary distribution for NetWare platform.$(DL) > $@
|
||||
@echo $(DL)libssh2 version $(LIBSSH2_VERSION_STR)$(DL) >> $@
|
||||
@@ -562,7 +586,7 @@ $(DISTDIR)/readme.txt: Makefile.netware
|
||||
@echo $(DL)any further documentation:$(DL) >> $@
|
||||
@echo $(DL)$(WWWURL)$(DL) >> $@
|
||||
|
||||
$(DEVLDIR)/readme.txt: Makefile.netware
|
||||
$(DEVLDIR)/readme.txt: GNUmakefile
|
||||
@echo Creating $@
|
||||
@echo $(DL)This is a development distribution for NetWare platform.$(DL) > $@
|
||||
@echo $(DL)libssh2 version $(LIBSSH2_VERSION_STR)$(DL) >> $@
|
@@ -1,2 +0,0 @@
|
||||
include Makefile.netware
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#########################################################################
|
||||
#
|
||||
## Makefile for building libssh2 (NetWare version - gnu make)
|
||||
## Use: make -f Makefile.netware
|
||||
##
|
||||
## Hacked by: Guenter Knauf
|
||||
#
|
||||
@@ -14,12 +13,12 @@ endif
|
||||
|
||||
# Edit the path below to point to the base of your Zlib sources.
|
||||
ifndef ZLIB_PATH
|
||||
ZLIB_PATH = ../../../zlib-1.2.5
|
||||
ZLIB_PATH = ../../../zlib-1.2.7
|
||||
endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8r
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8x
|
||||
endif
|
||||
|
||||
# Edit the var below to enable static linking of libssh2 and libz
|
||||
@@ -70,10 +69,7 @@ ifdef METROWERKS
|
||||
else
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
endif
|
||||
CP = cp -afv
|
||||
MD = mkdir
|
||||
RD = rm -fr
|
||||
# RM = rm -f
|
||||
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
@@ -82,6 +78,34 @@ AWK = awk
|
||||
# http://www.gknw.net/development/prgtools/mkxdc.zip
|
||||
MPKXDC = mkxdc
|
||||
|
||||
# Platform-dependent helper tool macros
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DEL = rm -f $1
|
||||
RMDIR = rm -fr $1
|
||||
MKDIR = mkdir -p $1
|
||||
COPY = -cp -afv $1 $2
|
||||
#COPYR = -cp -afr $1/* $2
|
||||
COPYR = -rsync -aC $1/* $2
|
||||
TOUCH = touch $1
|
||||
CAT = cat
|
||||
ECHONL = echo ""
|
||||
DL = '
|
||||
else
|
||||
ifeq "$(OS)" "Windows_NT"
|
||||
DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
||||
RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
|
||||
else
|
||||
DEL = -del 2>NUL $(subst /,\,$1)
|
||||
RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
|
||||
endif
|
||||
MKDIR = -md 2>NUL $(subst /,\,$1)
|
||||
COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
|
||||
COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
|
||||
TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
|
||||
CAT = type
|
||||
ECHONL = $(ComSpec) /c echo.
|
||||
endif
|
||||
|
||||
# LIBARCH_U = $(shell $(AWK) 'BEGIN {print toupper(ARGV[1])}' $(LIBARCH))
|
||||
LIBARCH_L = $(shell $(AWK) 'BEGIN {print tolower(ARGV[1])}' $(LIBARCH))
|
||||
|
||||
@@ -112,12 +136,13 @@ else
|
||||
endif
|
||||
else
|
||||
LD = nlmconv
|
||||
LDFLAGS = -T
|
||||
LDFLAGS = -UT
|
||||
AR = ar
|
||||
ARFLAGS = -cq
|
||||
LIBEXT = a
|
||||
CFLAGS += -m32
|
||||
CFLAGS += -fno-builtin -fpcc-struct-return -fno-strict-aliasing
|
||||
CFLAGS += -fno-builtin -fpcc-struct-return
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
CFLAGS += -Wall # -pedantic
|
||||
ifeq ($(LIBARCH),LIBC)
|
||||
PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o
|
||||
@@ -181,13 +206,6 @@ ifeq ($(MTSAFE),NO)
|
||||
XDCOPT = -u
|
||||
endif
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
DS = \\
|
||||
endif
|
||||
|
||||
vpath %.c $(SAMPLES)
|
||||
|
||||
.PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.def $(OBJDIR)/%.xdc
|
||||
@@ -201,29 +219,29 @@ $(OBJDIR)/%.o: %.c
|
||||
# @echo Compiling $<
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/version.inc: ../../include/libssh2.h $(OBJDIR)
|
||||
$(OBJDIR)/version.inc: ../../get_ver.awk ../../include/libssh2.h $(OBJDIR)
|
||||
@echo Creating $@
|
||||
@$(AWK) -f ../../get_ver.awk $< > $@
|
||||
@$(AWK) -f $^ > $@
|
||||
|
||||
objclean:
|
||||
-$(RD) $(OBJDIR)
|
||||
$(call RMDIR, $(OBJDIR))
|
||||
|
||||
clean: objclean
|
||||
-$(RM) $(TARGETS)
|
||||
$(foreach f, $(TARGETS), $(call DEL, $(f)))
|
||||
|
||||
$(OBJDIR):
|
||||
@$(MD) $@
|
||||
@$(call MKDIR, $@)
|
||||
|
||||
%.nlm: $(OBJDIR)/%.def $(OBJDIR)/%.o $(OBJDIR)/%.xdc
|
||||
@echo Linking $@
|
||||
@-$(RM) $@
|
||||
@$(call DEL, $@)
|
||||
@$(LD) $(LDFLAGS) $<
|
||||
|
||||
$(OBJDIR)/%.xdc: Makefile.netware
|
||||
$(OBJDIR)/%.xdc: GNUmakefile
|
||||
@echo Creating $@
|
||||
@$(MPKXDC) $(XDCOPT) $@
|
||||
|
||||
$(OBJDIR)/%.def: Makefile.netware
|
||||
$(OBJDIR)/%.def: GNUmakefile
|
||||
@echo $(DL)# DEF file for linking with $(LD)$(DL) > $@
|
||||
@echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
|
||||
@echo $(DL)# All your changes will be lost!!$(DL) >> $@
|
@@ -1,33 +1,20 @@
|
||||
!include "win32/config.mk"
|
||||
|
||||
!include "win32/objects.mk"
|
||||
|
||||
CFLAGS=$(CFLAGS)
|
||||
|
||||
OBJECTS = \
|
||||
$(INTDIR)\channel.obj \
|
||||
$(INTDIR)\comp.obj \
|
||||
$(INTDIR)\crypt.obj \
|
||||
$(INTDIR)\global.obj \
|
||||
$(INTDIR)\hostkey.obj \
|
||||
$(INTDIR)\keepalive.obj \
|
||||
$(INTDIR)\kex.obj \
|
||||
$(INTDIR)\mac.obj \
|
||||
$(INTDIR)\misc.obj \
|
||||
$(INTDIR)\openssl.obj \
|
||||
$(INTDIR)\packet.obj \
|
||||
$(INTDIR)\pem.obj \
|
||||
$(INTDIR)\publickey.obj \
|
||||
$(INTDIR)\scp.obj \
|
||||
$(INTDIR)\session.obj \
|
||||
$(INTDIR)\sftp.obj \
|
||||
$(INTDIR)\transport.obj \
|
||||
$(INTDIR)\userauth.obj
|
||||
RESOURCE=$(INTDIR)\libssh2.res
|
||||
|
||||
DLL=libssh2$(SUFFIX).dll
|
||||
|
||||
$(DLL): $(OBJECTS)
|
||||
$(CC) -o $(DLL) $(DLLFLAGS) $(OBJECTS) $(LIBS)
|
||||
|
||||
all: $(DLL)
|
||||
|
||||
$(DLL): $(OBJECTS) $(RESOURCE)
|
||||
$(CC) -o $(DLL) $(DLLFLAGS) $(OBJECTS) $(RESOURCE) $(LIBS)
|
||||
|
||||
$(RESOURCE): win32\libssh2.rc
|
||||
$(RC) $(RCFLAGS) /Fo"$@" $?
|
||||
|
||||
!include "win32/rules.mk"
|
||||
|
||||
|
@@ -1483,10 +1483,11 @@ libssh2_channel_get_exit_signal(LIBSSH2_CHANNEL *channel,
|
||||
char **langtag,
|
||||
size_t *langtag_len)
|
||||
{
|
||||
LIBSSH2_SESSION *session = channel->session;
|
||||
size_t namelen = 0;
|
||||
|
||||
if (channel) {
|
||||
LIBSSH2_SESSION *session = channel->session;
|
||||
|
||||
if (channel->exit_signal) {
|
||||
namelen = strlen(channel->exit_signal);
|
||||
if (exitsignal) {
|
||||
|
116
src/comp.c
116
src/comp.c
@@ -96,6 +96,7 @@ comp_method_none_decomp(LIBSSH2_SESSION * session,
|
||||
static const LIBSSH2_COMP_METHOD comp_method_none = {
|
||||
"none",
|
||||
0, /* not really compressing */
|
||||
0, /* isn't used in userauth, go figure */
|
||||
NULL,
|
||||
comp_method_none_comp,
|
||||
comp_method_none_decomp,
|
||||
@@ -248,83 +249,56 @@ comp_method_zlib_decomp(LIBSSH2_SESSION * session,
|
||||
if (!strm->next_out)
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to allocate decompression buffer");
|
||||
while (strm->avail_in) {
|
||||
int status;
|
||||
|
||||
/* Loop until it's all inflated or hit error */
|
||||
for (;;) {
|
||||
int status, grow_size;
|
||||
size_t out_ofs;
|
||||
char *newout;
|
||||
|
||||
status = inflate(strm, Z_PARTIAL_FLUSH);
|
||||
|
||||
if (status != Z_OK) {
|
||||
if (status == Z_OK) {
|
||||
if (! strm->avail_in) {
|
||||
/* status is OK and input all used so we're done */
|
||||
break;
|
||||
}
|
||||
} else if (status == Z_BUF_ERROR) {
|
||||
/* This is OK, just drop through to grow the buffer */
|
||||
} else {
|
||||
/* error state */
|
||||
LIBSSH2_FREE(session, out);
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_TRANS,
|
||||
"unhandled zlib error %d", status);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ZLIB,
|
||||
"decompression failure");
|
||||
}
|
||||
|
||||
/* If we get here we need to grow the output buffer and try again */
|
||||
out_ofs = out_maxlen - strm->avail_out;
|
||||
if (strm->avail_in) {
|
||||
size_t out_ofs = out_maxlen - strm->avail_out;
|
||||
char *newout;
|
||||
grow_size = strm->avail_in * 8;
|
||||
} else {
|
||||
/* Not sure how much to grow by */
|
||||
grow_size = 32;
|
||||
}
|
||||
out_maxlen += grow_size;
|
||||
|
||||
out_maxlen += 8 * strm->avail_in;
|
||||
if ((out_maxlen > (int) payload_limit) && limiter++) {
|
||||
LIBSSH2_FREE(session, out);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ZLIB,
|
||||
"Excessive growth in decompression phase");
|
||||
}
|
||||
|
||||
if ((out_maxlen > (int) payload_limit) && limiter++) {
|
||||
LIBSSH2_FREE(session, out);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ZLIB,
|
||||
"Excessive growth in decompression phase");
|
||||
}
|
||||
|
||||
newout = LIBSSH2_REALLOC(session, out, out_maxlen);
|
||||
if (!newout) {
|
||||
LIBSSH2_FREE(session, out);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to expand decompression buffer");
|
||||
}
|
||||
out = newout;
|
||||
strm->next_out = (unsigned char *) out + out_ofs;
|
||||
strm->avail_out += 8 * strm->avail_in;
|
||||
} else
|
||||
while (!strm->avail_out) {
|
||||
/* Done with input, might be a byte or two in internal buffer
|
||||
* during compress. Or potentially many bytes if it's a
|
||||
* decompress
|
||||
*/
|
||||
int grow_size = 2048;
|
||||
char *newout;
|
||||
|
||||
if (out_maxlen >= (int) payload_limit) {
|
||||
LIBSSH2_FREE(session, out);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ZLIB,
|
||||
"Excessive growth in decompression "
|
||||
"phase");
|
||||
}
|
||||
|
||||
if (grow_size > (int) (payload_limit - out_maxlen)) {
|
||||
grow_size = payload_limit - out_maxlen;
|
||||
}
|
||||
|
||||
out_maxlen += grow_size;
|
||||
strm->avail_out = grow_size;
|
||||
|
||||
newout = LIBSSH2_REALLOC(session, out, out_maxlen);
|
||||
if (!newout) {
|
||||
LIBSSH2_FREE(session, out);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to expand final "
|
||||
"decompress buffer");
|
||||
}
|
||||
out = newout;
|
||||
strm->next_out = (unsigned char *) out + out_maxlen -
|
||||
grow_size;
|
||||
|
||||
status = inflate(strm, Z_PARTIAL_FLUSH);
|
||||
|
||||
if (status != Z_OK) {
|
||||
LIBSSH2_FREE(session, out);
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_TRANS,
|
||||
"unhandled zlib error %d", status);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ZLIB,
|
||||
"decompression failure");
|
||||
}
|
||||
}
|
||||
newout = LIBSSH2_REALLOC(session, out, out_maxlen);
|
||||
if (!newout) {
|
||||
LIBSSH2_FREE(session, out);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"Unable to expand decompression buffer");
|
||||
}
|
||||
out = newout;
|
||||
strm->next_out = (unsigned char *) out + out_ofs;
|
||||
strm->avail_out += grow_size;
|
||||
}
|
||||
|
||||
*dest = (unsigned char *) out;
|
||||
@@ -357,6 +331,17 @@ comp_method_zlib_dtor(LIBSSH2_SESSION *session, int compr, void **abstract)
|
||||
static const LIBSSH2_COMP_METHOD comp_method_zlib = {
|
||||
"zlib",
|
||||
1, /* yes, this compresses */
|
||||
1, /* do compression during userauth */
|
||||
comp_method_zlib_init,
|
||||
comp_method_zlib_comp,
|
||||
comp_method_zlib_decomp,
|
||||
comp_method_zlib_dtor,
|
||||
};
|
||||
|
||||
static const LIBSSH2_COMP_METHOD comp_method_zlib_openssh = {
|
||||
"zlib@openssh.com",
|
||||
1, /* yes, this compresses */
|
||||
0, /* don't use compression during userauth */
|
||||
comp_method_zlib_init,
|
||||
comp_method_zlib_comp,
|
||||
comp_method_zlib_decomp,
|
||||
@@ -369,6 +354,7 @@ static const LIBSSH2_COMP_METHOD comp_method_zlib = {
|
||||
static const LIBSSH2_COMP_METHOD *comp_methods[] = {
|
||||
#ifdef LIBSSH2_HAVE_ZLIB
|
||||
&comp_method_zlib,
|
||||
&comp_method_zlib_openssh,
|
||||
#endif /* LIBSSH2_HAVE_ZLIB */
|
||||
&comp_method_none,
|
||||
NULL
|
||||
|
@@ -96,11 +96,12 @@ crypt_init(LIBSSH2_SESSION * session,
|
||||
|
||||
static int
|
||||
crypt_encrypt(LIBSSH2_SESSION * session, unsigned char *block,
|
||||
void **abstract)
|
||||
size_t blocksize, void **abstract)
|
||||
{
|
||||
struct crypt_ctx *cctx = *(struct crypt_ctx **) abstract;
|
||||
(void) session;
|
||||
return _libssh2_cipher_crypt(&cctx->h, cctx->algo, cctx->encrypt, block);
|
||||
return _libssh2_cipher_crypt(&cctx->h, cctx->algo, cctx->encrypt, block,
|
||||
blocksize);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -248,7 +249,8 @@ crypt_init_arcfour128(LIBSSH2_SESSION * session,
|
||||
unsigned char block[8];
|
||||
size_t discard = 1536;
|
||||
for (; discard; discard -= 8)
|
||||
_libssh2_cipher_crypt(&cctx->h, cctx->algo, cctx->encrypt, block);
|
||||
_libssh2_cipher_crypt(&cctx->h, cctx->algo, cctx->encrypt, block,
|
||||
method->blocksize);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@@ -75,6 +75,7 @@ int _libssh2_rsa_sha1_sign(LIBSSH2_SESSION * session,
|
||||
unsigned char **signature,
|
||||
size_t *signature_len);
|
||||
|
||||
#if LIBSSH2_DSA
|
||||
int _libssh2_dsa_new(libssh2_dsa_ctx ** dsa,
|
||||
const unsigned char *pdata,
|
||||
unsigned long plen,
|
||||
@@ -95,6 +96,7 @@ int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx * dsactx,
|
||||
int _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
||||
const unsigned char *hash,
|
||||
unsigned long hash_len, unsigned char *sig);
|
||||
#endif
|
||||
|
||||
int _libssh2_cipher_init(_libssh2_cipher_ctx * h,
|
||||
_libssh2_cipher_type(algo),
|
||||
@@ -103,7 +105,7 @@ int _libssh2_cipher_init(_libssh2_cipher_ctx * h,
|
||||
|
||||
int _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
|
||||
_libssh2_cipher_type(algo),
|
||||
int encrypt, unsigned char *block);
|
||||
int encrypt, unsigned char *block, size_t blocksize);
|
||||
|
||||
int _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
|
@@ -429,7 +429,9 @@ libssh2_hostkey_hash(LIBSSH2_SESSION * session, int hash_type)
|
||||
switch (hash_type) {
|
||||
#if LIBSSH2_MD5
|
||||
case LIBSSH2_HOSTKEY_HASH_MD5:
|
||||
return (char *) session->server_hostkey_md5;
|
||||
return (session->server_hostkey_md5_valid)
|
||||
? (char *) session->server_hostkey_md5
|
||||
: NULL;
|
||||
break;
|
||||
#endif /* LIBSSH2_MD5 */
|
||||
case LIBSSH2_HOSTKEY_HASH_SHA1:
|
||||
|
13
src/kex.c
13
src/kex.c
@@ -218,10 +218,15 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session,
|
||||
{
|
||||
libssh2_md5_ctx fingerprint_ctx;
|
||||
|
||||
libssh2_md5_init(&fingerprint_ctx);
|
||||
libssh2_md5_update(fingerprint_ctx, session->server_hostkey,
|
||||
session->server_hostkey_len);
|
||||
libssh2_md5_final(fingerprint_ctx, session->server_hostkey_md5);
|
||||
if (libssh2_md5_init(&fingerprint_ctx)) {
|
||||
libssh2_md5_update(fingerprint_ctx, session->server_hostkey,
|
||||
session->server_hostkey_len);
|
||||
libssh2_md5_final(fingerprint_ctx, session->server_hostkey_md5);
|
||||
session->server_hostkey_md5_valid = TRUE;
|
||||
}
|
||||
else {
|
||||
session->server_hostkey_md5_valid = FALSE;
|
||||
}
|
||||
}
|
||||
#ifdef LIBSSH2DEBUG
|
||||
{
|
||||
|
@@ -910,8 +910,11 @@ libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
file = fopen(filename, "r");
|
||||
if(file) {
|
||||
while(fgets(buf, sizeof(buf), file)) {
|
||||
if(libssh2_knownhost_readline(hosts, buf, strlen(buf), type))
|
||||
if(libssh2_knownhost_readline(hosts, buf, strlen(buf), type)) {
|
||||
num = _libssh2_error(hosts->session, LIBSSH2_ERROR_KNOWN_HOSTS,
|
||||
"Failed to parse known hosts file");
|
||||
break;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
fclose(file);
|
||||
|
@@ -553,17 +553,11 @@ _libssh2_cipher_init(_libssh2_cipher_ctx * h,
|
||||
int
|
||||
_libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
|
||||
_libssh2_cipher_type(algo),
|
||||
int encrypt, unsigned char *block)
|
||||
int encrypt, unsigned char *block, size_t blklen)
|
||||
{
|
||||
int cipher = _libssh2_gcry_cipher (algo);
|
||||
size_t blklen = gcry_cipher_get_algo_blklen(cipher);
|
||||
int ret;
|
||||
|
||||
if (blklen == 1) {
|
||||
/* Hack for arcfour. */
|
||||
blklen = 8;
|
||||
}
|
||||
|
||||
if (encrypt) {
|
||||
ret = gcry_cipher_encrypt(*ctx, block, blklen, block, blklen);
|
||||
} else {
|
||||
|
@@ -68,7 +68,11 @@
|
||||
gcry_md_hash_buffer (GCRY_MD_SHA1, out, message, len)
|
||||
|
||||
#define libssh2_md5_ctx gcry_md_hd_t
|
||||
#define libssh2_md5_init(ctx) gcry_md_open (ctx, GCRY_MD_MD5, 0);
|
||||
|
||||
/* returns 0 in case of failure */
|
||||
#define libssh2_md5_init(ctx) \
|
||||
(GPG_ERR_NO_ERROR == gcry_md_open (ctx, GCRY_MD_MD5, 0))
|
||||
|
||||
#define libssh2_md5_update(ctx, data, len) gcry_md_write (ctx, data, len)
|
||||
#define libssh2_md5_final(ctx, out) \
|
||||
memcpy (out, gcry_md_read (ctx, 0), MD5_DIGEST_LENGTH), gcry_md_close (ctx)
|
||||
|
@@ -597,6 +597,7 @@ struct _LIBSSH2_SESSION
|
||||
uint32_t server_hostkey_len;
|
||||
#if LIBSSH2_MD5
|
||||
unsigned char server_hostkey_md5[MD5_DIGEST_LENGTH];
|
||||
int server_hostkey_md5_valid;
|
||||
#endif /* ! LIBSSH2_MD5 */
|
||||
unsigned char server_hostkey_sha1[SHA_DIGEST_LENGTH];
|
||||
|
||||
@@ -882,7 +883,7 @@ struct _LIBSSH2_CRYPT_METHOD
|
||||
int *free_iv, unsigned char *secret, int *free_secret,
|
||||
int encrypt, void **abstract);
|
||||
int (*crypt) (LIBSSH2_SESSION * session, unsigned char *block,
|
||||
void **abstract);
|
||||
size_t blocksize, void **abstract);
|
||||
int (*dtor) (LIBSSH2_SESSION * session, void **abstract);
|
||||
|
||||
_libssh2_cipher_type(algo);
|
||||
@@ -892,6 +893,7 @@ struct _LIBSSH2_COMP_METHOD
|
||||
{
|
||||
const char *name;
|
||||
int compress; /* 1 if it does compress, 0 if it doesn't */
|
||||
int use_in_auth; /* 1 if compression should be used in userauth */
|
||||
int (*init) (LIBSSH2_SESSION *session, int compress, void **abstract);
|
||||
int (*comp) (LIBSSH2_SESSION *session,
|
||||
unsigned char *dest,
|
||||
@@ -1030,9 +1032,9 @@ void _libssh2_init_if_needed (void);
|
||||
|
||||
/* define to output the libssh2_int64_t type in a *printf() */
|
||||
#if defined( __BORLANDC__ ) || defined( _MSC_VER ) || defined( __MINGW32__ )
|
||||
#define LIBSSH2_INT64_T_FORMAT "I64"
|
||||
#define LIBSSH2_INT64_T_FORMAT "I64d"
|
||||
#else
|
||||
#define LIBSSH2_INT64_T_FORMAT "ll"
|
||||
#define LIBSSH2_INT64_T_FORMAT "lld"
|
||||
#endif
|
||||
|
||||
#endif /* LIBSSH2_H */
|
||||
|
@@ -78,7 +78,7 @@ 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__)
|
||||
#if defined(LIBSSH2_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
|
||||
/* provide a private one */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
int __cdecl _libssh2_gettimeofday(struct timeval *tp, void *tzp);
|
||||
|
@@ -175,25 +175,19 @@ _libssh2_cipher_init(_libssh2_cipher_ctx * h,
|
||||
unsigned char *iv, unsigned char *secret, int encrypt)
|
||||
{
|
||||
EVP_CIPHER_CTX_init(h);
|
||||
EVP_CipherInit(h, algo(), secret, iv, encrypt);
|
||||
return 0;
|
||||
return !EVP_CipherInit(h, algo(), secret, iv, encrypt);
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
|
||||
_libssh2_cipher_type(algo),
|
||||
int encrypt, unsigned char *block)
|
||||
int encrypt, unsigned char *block, size_t blocksize)
|
||||
{
|
||||
int blocksize = ctx->cipher->block_size;
|
||||
unsigned char buf[EVP_MAX_BLOCK_LENGTH];
|
||||
int ret;
|
||||
(void) algo;
|
||||
(void) encrypt;
|
||||
|
||||
if (blocksize == 1) {
|
||||
/* Hack for arcfour. */
|
||||
blocksize = 8;
|
||||
}
|
||||
ret = EVP_Cipher(ctx, buf, block, blocksize);
|
||||
if (ret == 1) {
|
||||
memcpy(block, buf, blocksize);
|
||||
@@ -221,13 +215,10 @@ aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
* variable "c" is leaked from this scope, but is later freed
|
||||
* in aes_ctr_cleanup
|
||||
*/
|
||||
aes_ctr_ctx *c = malloc(sizeof(*c));
|
||||
aes_ctr_ctx *c;
|
||||
const EVP_CIPHER *aes_cipher;
|
||||
(void) enc;
|
||||
|
||||
if (c == NULL)
|
||||
return 0;
|
||||
|
||||
switch (ctx->key_len) {
|
||||
case 16:
|
||||
aes_cipher = EVP_aes_128_ecb();
|
||||
@@ -241,11 +232,20 @@ aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
c->aes_ctx = malloc(sizeof(EVP_CIPHER_CTX));
|
||||
if (c->aes_ctx == NULL)
|
||||
|
||||
c = malloc(sizeof(*c));
|
||||
if (c == NULL)
|
||||
return 0;
|
||||
|
||||
c->aes_ctx = malloc(sizeof(EVP_CIPHER_CTX));
|
||||
if (c->aes_ctx == NULL) {
|
||||
free(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (EVP_EncryptInit(c->aes_ctx, aes_cipher, key, NULL) != 1) {
|
||||
free(c->aes_ctx);
|
||||
free(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -113,7 +113,10 @@
|
||||
void libssh2_sha1(const unsigned char *message, unsigned long len, unsigned char *out);
|
||||
|
||||
#define libssh2_md5_ctx EVP_MD_CTX
|
||||
|
||||
/* returns 0 in case of failure */
|
||||
#define libssh2_md5_init(ctx) EVP_DigestInit(ctx, EVP_get_digestbyname("md5"))
|
||||
|
||||
#define libssh2_md5_update(ctx, data, len) EVP_DigestUpdate(&(ctx), data, len)
|
||||
#define libssh2_md5_final(ctx, out) EVP_DigestFinal(&(ctx), out, NULL)
|
||||
void libssh2_md5(const unsigned char *message, unsigned long len, unsigned char *out);
|
||||
@@ -148,9 +151,15 @@ void libssh2_md5(const unsigned char *message, unsigned long len, unsigned char
|
||||
#define _libssh2_cipher_aes256 EVP_aes_256_cbc
|
||||
#define _libssh2_cipher_aes192 EVP_aes_192_cbc
|
||||
#define _libssh2_cipher_aes128 EVP_aes_128_cbc
|
||||
#ifdef HAVE_EVP_AES_128_CTR
|
||||
#define _libssh2_cipher_aes128ctr EVP_aes_128_ctr
|
||||
#define _libssh2_cipher_aes192ctr EVP_aes_192_ctr
|
||||
#define _libssh2_cipher_aes256ctr EVP_aes_256_ctr
|
||||
#else
|
||||
#define _libssh2_cipher_aes128ctr _libssh2_EVP_aes_128_ctr
|
||||
#define _libssh2_cipher_aes192ctr _libssh2_EVP_aes_192_ctr
|
||||
#define _libssh2_cipher_aes256ctr _libssh2_EVP_aes_256_ctr
|
||||
#endif
|
||||
#define _libssh2_cipher_blowfish EVP_bf_cbc
|
||||
#define _libssh2_cipher_arcfour EVP_rc4
|
||||
#define _libssh2_cipher_cast5 EVP_cast5_cbc
|
||||
|
@@ -751,7 +751,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
|
||||
if(datalen >= 9) {
|
||||
uint32_t channel = _libssh2_ntohu32(data + 1);
|
||||
uint32_t len = _libssh2_ntohu32(data + 5);
|
||||
unsigned char want_reply = 0;
|
||||
unsigned char want_reply = 1;
|
||||
|
||||
if(len < (datalen - 10))
|
||||
want_reply = data[9 + len];
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2007, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2010 by Daniel Stenberg
|
||||
* Copyright (c) 2010-2012 by Daniel Stenberg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -384,7 +384,7 @@ static LIBSSH2_PUBLICKEY *publickey_init(LIBSSH2_SESSION *session)
|
||||
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
|
||||
"Would block sending publickey version packet");
|
||||
return NULL;
|
||||
} else if (rc) {
|
||||
} else if (rc < 0) {
|
||||
_libssh2_error(session, rc,
|
||||
"Unable to send publickey version packet");
|
||||
goto err_exit;
|
||||
|
@@ -957,7 +957,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
session->scpSend_response_len =
|
||||
snprintf((char *) session->scpSend_response,
|
||||
LIBSSH2_SCP_RESPONSE_BUFLEN, "C0%o %"
|
||||
LIBSSH2_INT64_T_FORMAT "u %s\n", mode,
|
||||
LIBSSH2_INT64_T_FORMAT " %s\n", mode,
|
||||
size, base);
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SCP, "Sent %s",
|
||||
session->scpSend_response);
|
||||
|
@@ -143,7 +143,7 @@ banner_receive(LIBSSH2_SESSION * session)
|
||||
|
||||
if (ret == 0) {
|
||||
session->socket_state = LIBSSH2_SOCKET_DISCONNECTED;
|
||||
return LIBSSH2_ERROR_SOCKET_RECV;
|
||||
return LIBSSH2_ERROR_SOCKET_DISCONNECT;
|
||||
}
|
||||
|
||||
if (c == '\0') {
|
||||
@@ -834,7 +834,7 @@ session_free(LIBSSH2_SESSION *session)
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Freeing session resource",
|
||||
session->remote.banner);
|
||||
|
||||
session->state = libssh2_NB_state_created;
|
||||
session->free_state = libssh2_NB_state_created;
|
||||
}
|
||||
|
||||
if (session->free_state == libssh2_NB_state_created) {
|
||||
@@ -845,17 +845,17 @@ session_free(LIBSSH2_SESSION *session)
|
||||
return rc;
|
||||
}
|
||||
|
||||
session->state = libssh2_NB_state_sent;
|
||||
session->free_state = libssh2_NB_state_sent;
|
||||
}
|
||||
|
||||
if (session->state == libssh2_NB_state_sent) {
|
||||
if (session->free_state == libssh2_NB_state_sent) {
|
||||
while ((l = _libssh2_list_first(&session->listeners))) {
|
||||
rc = _libssh2_channel_forward_cancel(l);
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN)
|
||||
return rc;
|
||||
}
|
||||
|
||||
session->state = libssh2_NB_state_sent1;
|
||||
session->free_state = libssh2_NB_state_sent1;
|
||||
}
|
||||
|
||||
if (session->state & LIBSSH2_STATE_NEWKEYS) {
|
||||
|
123
src/sftp.c
123
src/sftp.c
@@ -132,6 +132,66 @@ static void _libssh2_store_u64(unsigned char **ptr, libssh2_uint64_t value)
|
||||
*ptr += 8;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search list of zombied FXP_READ request IDs.
|
||||
*
|
||||
* Returns NULL if ID not in list.
|
||||
*/
|
||||
static struct sftp_zombie_requests *
|
||||
find_zombie_request(LIBSSH2_SFTP *sftp, uint32_t request_id)
|
||||
{
|
||||
struct sftp_zombie_requests *zombie =
|
||||
_libssh2_list_first(&sftp->zombie_requests);
|
||||
|
||||
while(zombie) {
|
||||
if(zombie->request_id == request_id)
|
||||
break;
|
||||
else
|
||||
zombie = _libssh2_list_next(&zombie->node);
|
||||
}
|
||||
|
||||
return zombie;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_zombie_request(LIBSSH2_SFTP *sftp, uint32_t request_id)
|
||||
{
|
||||
LIBSSH2_SESSION *session = sftp->channel->session;
|
||||
|
||||
struct sftp_zombie_requests *zombie = find_zombie_request(sftp,
|
||||
request_id);
|
||||
if(zombie) {
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP,
|
||||
"Removing request ID %ld from the list of zombie requests",
|
||||
request_id);
|
||||
|
||||
_libssh2_list_remove(&zombie->node);
|
||||
LIBSSH2_FREE(session, zombie);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
add_zombie_request(LIBSSH2_SFTP *sftp, uint32_t request_id)
|
||||
{
|
||||
LIBSSH2_SESSION *session = sftp->channel->session;
|
||||
|
||||
struct sftp_zombie_requests *zombie;
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP,
|
||||
"Marking request ID %ld as a zombie request", request_id);
|
||||
|
||||
zombie = LIBSSH2_ALLOC(sftp->channel->session,
|
||||
sizeof(struct sftp_zombie_requests));
|
||||
if (!zombie)
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
"malloc fail for zombie request ID");
|
||||
else {
|
||||
zombie->request_id = request_id;
|
||||
_libssh2_list_add(&sftp->zombie_requests, &zombie->node);
|
||||
return LIBSSH2_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* sftp_packet_add
|
||||
*
|
||||
@@ -143,6 +203,7 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
|
||||
{
|
||||
LIBSSH2_SESSION *session = sftp->channel->session;
|
||||
LIBSSH2_SFTP_PACKET *packet;
|
||||
uint32_t request_id;
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Received packet %d (len %d)",
|
||||
(int) data[0], data_len);
|
||||
@@ -188,6 +249,21 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
|
||||
"Out of sync with the world");
|
||||
}
|
||||
|
||||
request_id = _libssh2_ntohu32(&data[1]);
|
||||
|
||||
/* Don't add the packet if it answers a request we've given up on. */
|
||||
if((data[0] == SSH_FXP_STATUS || data[0] == SSH_FXP_DATA)
|
||||
&& find_zombie_request(sftp, request_id)) {
|
||||
|
||||
/* If we get here, the file ended before the response arrived. We
|
||||
are no longer interested in the request so we discard it */
|
||||
|
||||
LIBSSH2_FREE(session, data);
|
||||
|
||||
remove_zombie_request(sftp, request_id);
|
||||
return LIBSSH2_ERROR_NONE;
|
||||
}
|
||||
|
||||
packet = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_SFTP_PACKET));
|
||||
if (!packet) {
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
@@ -196,7 +272,7 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data,
|
||||
|
||||
packet->data = data;
|
||||
packet->data_len = data_len;
|
||||
packet->request_id = _libssh2_ntohu32(&data[1]);
|
||||
packet->request_id = request_id;
|
||||
|
||||
_libssh2_list_add(&sftp->packets, &packet->node);
|
||||
|
||||
@@ -216,6 +292,7 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
|
||||
unsigned char *packet = NULL;
|
||||
ssize_t rc;
|
||||
unsigned long recv_window;
|
||||
int packet_type;
|
||||
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "recv packet");
|
||||
|
||||
@@ -324,13 +401,17 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
|
||||
|
||||
sftp->partial_packet = NULL;
|
||||
|
||||
/* sftp_packet_add takes ownership of the packet and might free it
|
||||
so we take a copy of the packet type before we call it. */
|
||||
packet_type = packet[0];
|
||||
rc = sftp_packet_add(sftp, packet, sftp->partial_len);
|
||||
if (rc) {
|
||||
LIBSSH2_FREE(session, packet);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return packet[0];
|
||||
else {
|
||||
return packet_type;
|
||||
}
|
||||
}
|
||||
/* WON'T REACH */
|
||||
}
|
||||
@@ -363,6 +444,10 @@ static void sftp_packetlist_flush(LIBSSH2_SFTP_HANDLE *handle)
|
||||
if(!rc)
|
||||
/* we found a packet, free it */
|
||||
LIBSSH2_FREE(session, data);
|
||||
else if(chunk->sent)
|
||||
/* there was no incoming packet for this request, mark this
|
||||
request as a zombie if it ever sent the request */
|
||||
add_zombie_request(sftp, chunk->request_id);
|
||||
|
||||
_libssh2_list_remove(&chunk->node);
|
||||
LIBSSH2_FREE(session, chunk);
|
||||
@@ -433,10 +518,7 @@ sftp_packet_require(LIBSSH2_SFTP *sftp, unsigned char packet_type,
|
||||
|
||||
while (session->socket_state == LIBSSH2_SOCKET_CONNECTED) {
|
||||
rc = sftp_packet_read(sftp);
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN)
|
||||
return rc;
|
||||
else if (rc <= 0)
|
||||
/* TODO: isn't this supposed to be < 0 only? */
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
/* data was read, check the queue again */
|
||||
@@ -1377,6 +1459,11 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
|
||||
switch (data[0]) {
|
||||
case SSH_FXP_STATUS:
|
||||
/* remove the chunk we just processed */
|
||||
|
||||
_libssh2_list_remove(&chunk->node);
|
||||
LIBSSH2_FREE(session, chunk);
|
||||
|
||||
/* we must remove all outstanding READ requests, as either we
|
||||
got an error or we're at end of file */
|
||||
sftp_packetlist_flush(handle);
|
||||
@@ -1401,6 +1488,14 @@ 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 chunk larger than we requested was returned to us.
|
||||
This is a protocol violation and we don't know how to
|
||||
deal with it. Bail out! */
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
"FXP_READ response too big");
|
||||
}
|
||||
|
||||
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
|
||||
@@ -2091,13 +2186,15 @@ libssh2_sftp_tell64(LIBSSH2_SFTP_HANDLE *handle)
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush all remaining incoming SFTP packets.
|
||||
* Flush all remaining incoming SFTP packets and zombies.
|
||||
*/
|
||||
static void sftp_packet_flush(LIBSSH2_SFTP *sftp)
|
||||
{
|
||||
LIBSSH2_CHANNEL *channel = sftp->channel;
|
||||
LIBSSH2_SESSION *session = channel->session;
|
||||
LIBSSH2_SFTP_PACKET *packet = _libssh2_list_first(&sftp->packets);
|
||||
struct sftp_zombie_requests *zombie =
|
||||
_libssh2_list_first(&sftp->zombie_requests);
|
||||
|
||||
while(packet) {
|
||||
LIBSSH2_SFTP_PACKET *next;
|
||||
@@ -2111,6 +2208,16 @@ static void sftp_packet_flush(LIBSSH2_SFTP *sftp)
|
||||
packet = next;
|
||||
}
|
||||
|
||||
while(zombie) {
|
||||
/* figure out the next node */
|
||||
struct sftp_zombie_requests *next = _libssh2_list_next(&zombie->node);
|
||||
/* unlink the current one */
|
||||
_libssh2_list_remove(&zombie->node);
|
||||
/* free the memory */
|
||||
LIBSSH2_FREE(session, zombie);
|
||||
zombie = next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* sftp_close_handle
|
||||
|
@@ -60,6 +60,11 @@ struct sftp_pipeline_chunk {
|
||||
unsigned char packet[1]; /* data */
|
||||
};
|
||||
|
||||
struct sftp_zombie_requests {
|
||||
struct list_node node;
|
||||
uint32_t request_id;
|
||||
};
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#endif
|
||||
@@ -136,6 +141,9 @@ struct _LIBSSH2_SFTP
|
||||
|
||||
struct list_head packets;
|
||||
|
||||
/* List of FXP_READ responses to ignore because EOF already received. */
|
||||
struct list_head zombie_requests;
|
||||
|
||||
/* a list of _LIBSSH2_SFTP_HANDLE structs */
|
||||
struct list_head sftp_handles;
|
||||
|
||||
|
@@ -139,7 +139,7 @@ decrypt(LIBSSH2_SESSION * session, unsigned char *source,
|
||||
assert((len % blocksize) == 0);
|
||||
|
||||
while (len >= blocksize) {
|
||||
if (session->remote.crypt->crypt(session, source,
|
||||
if (session->remote.crypt->crypt(session, source, blocksize,
|
||||
&session->remote.crypt_abstract)) {
|
||||
LIBSSH2_FREE(session, p->payload);
|
||||
return LIBSSH2_ERROR_DECRYPT;
|
||||
@@ -167,6 +167,7 @@ fullpacket(LIBSSH2_SESSION * session, int encrypted /* 1 or 0 */ )
|
||||
unsigned char macbuf[MAX_MACSIZE];
|
||||
struct transportpacket *p = &session->packet;
|
||||
int rc;
|
||||
int compressed;
|
||||
|
||||
if (session->fullpacket_state == libssh2_NB_state_idle) {
|
||||
session->fullpacket_macstate = LIBSSH2_MAC_CONFIRMED;
|
||||
@@ -199,9 +200,13 @@ fullpacket(LIBSSH2_SESSION * session, int encrypted /* 1 or 0 */ )
|
||||
session->fullpacket_payload_len -= p->padding_length;
|
||||
|
||||
/* Check for and deal with decompression */
|
||||
if (session->remote.comp &&
|
||||
session->remote.comp->compress &&
|
||||
session->remote.comp_abstract) {
|
||||
compressed =
|
||||
session->local.comp != NULL &&
|
||||
session->local.comp->compress &&
|
||||
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
||||
session->local.comp->use_in_auth);
|
||||
|
||||
if (compressed && session->remote.comp_abstract) {
|
||||
/*
|
||||
* The buffer for the decompression (remote.comp_abstract) is
|
||||
* initialised in time when it is needed so as long it is NULL we
|
||||
@@ -682,6 +687,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
||||
#endif
|
||||
struct transportpacket *p = &session->packet;
|
||||
int encrypted;
|
||||
int compressed;
|
||||
ssize_t ret;
|
||||
int rc;
|
||||
const unsigned char *orgdata = data;
|
||||
@@ -723,7 +729,13 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
||||
|
||||
encrypted = (session->state & LIBSSH2_STATE_NEWKEYS) ? 1 : 0;
|
||||
|
||||
if (encrypted && session->local.comp->compress) {
|
||||
compressed =
|
||||
session->local.comp != NULL &&
|
||||
session->local.comp->compress &&
|
||||
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
||||
session->local.comp->use_in_auth);
|
||||
|
||||
if (encrypted && compressed) {
|
||||
/* the idea here is that these function must fail if the output gets
|
||||
larger than what fits in the assigned buffer so thus they don't
|
||||
check the input size as we don't know how much it compresses */
|
||||
@@ -834,6 +846,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
||||
for(i = 0; i < packet_length; i += session->local.crypt->blocksize) {
|
||||
unsigned char *ptr = &p->outbuf[i];
|
||||
if (session->local.crypt->crypt(session, ptr,
|
||||
session->local.crypt->blocksize,
|
||||
&session->local.crypt_abstract))
|
||||
return LIBSSH2_ERROR_ENCRYPT; /* encryption failure */
|
||||
}
|
||||
|
@@ -472,7 +472,7 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
"Unable to open public key file");
|
||||
}
|
||||
while (!feof(fd) && (c = fgetc(fd)) != '\r' && c != '\n')
|
||||
while (!feof(fd) && 1 == fread(&c, 1, 1, fd) && c != '\r' && c != '\n')
|
||||
pubkey_len++;
|
||||
if (feof(fd)) {
|
||||
/* the last character was EOF */
|
||||
|
1
win32/.gitignore
vendored
1
win32/.gitignore
vendored
@@ -11,3 +11,4 @@ Release
|
||||
*.opt
|
||||
*.plg
|
||||
libssh2.dsp
|
||||
objects.mk
|
||||
|
@@ -9,14 +9,12 @@
|
||||
|
||||
# Edit the path below to point to the base of your Zlib sources.
|
||||
ifndef ZLIB_PATH
|
||||
ZLIB_PATH = ../../zlib-1.2.5
|
||||
ZLIB_PATH = ../../zlib-1.2.7
|
||||
endif
|
||||
# since currently always enabled in libssh2_config.h set here too!
|
||||
WITH_ZLIB = 1
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../openssl-0.9.8r
|
||||
OPENSSL_PATH = ../../openssl-0.9.8x
|
||||
endif
|
||||
|
||||
# Edit the var below to set to your architecture or set environment var.
|
||||
@@ -38,8 +36,6 @@ DEVLARC = $(DEVLDIR).zip
|
||||
|
||||
# Edit the vars below to change target settings.
|
||||
TARGET = libssh2
|
||||
VERSION = $(LIBSSH2_VERSION)
|
||||
COPYR = (c) $(LIBSSH2_COPYRIGHT_STR)
|
||||
WWWURL = http://www.libssh2.org/
|
||||
DESCR = libssh2 $(LIBSSH2_VERSION_STR)
|
||||
#STACK = 64000
|
||||
@@ -59,29 +55,39 @@ else
|
||||
OBJDIR = debug
|
||||
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
|
||||
|
||||
# Platform-dependent helper tool macros
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DEL = rm -f $1
|
||||
RMDIR = rm -fr $1
|
||||
MKDIR = mkdir -p $1
|
||||
COPY = -cp -afv $1 $2
|
||||
#COPYR = -cp -afr $1/* $2
|
||||
COPYR = -rsync -aC $1/* $2
|
||||
TOUCH = touch $1
|
||||
CAT = cat
|
||||
ECHONL = echo ""
|
||||
DL = '
|
||||
else
|
||||
ifeq "$(OS)" "Windows_NT"
|
||||
DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
||||
RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
|
||||
else
|
||||
DEL = -del 2>NUL $(subst /,\,$1)
|
||||
RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
|
||||
endif
|
||||
MKDIR = -md 2>NUL $(subst /,\,$1)
|
||||
COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
|
||||
COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
|
||||
TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
|
||||
CAT = type
|
||||
ECHONL = $(ComSpec) /c echo.
|
||||
endif
|
||||
|
||||
# The following line defines your compiler.
|
||||
ifdef METROWERKS
|
||||
CC = mwcc
|
||||
@@ -89,8 +95,11 @@ else
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
endif
|
||||
|
||||
# Include the version info retrieved from libssh2.h
|
||||
-include $(OBJDIR)/version.inc
|
||||
|
||||
# Global flags for all compilers
|
||||
CFLAGS = $(OPT) -D$(DB) -DWIN32 -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
endif
|
||||
@@ -113,7 +122,7 @@ CFLAGS += -w on,nounused,nounusedexpr # -ansi strict
|
||||
else
|
||||
LD = $(CROSSPREFIX)gcc
|
||||
RC = $(CROSSPREFIX)windres
|
||||
LDFLAGS = -s -shared -Wl,--out-implib,$(TARGET)dll.a
|
||||
LDFLAGS = -s -shared -Wl,--output-def,$(TARGET).def,--out-implib,$(TARGET)dll.a
|
||||
AR = $(CROSSPREFIX)ar
|
||||
ARFLAGS = -cq
|
||||
LIBEXT = a
|
||||
@@ -126,17 +135,44 @@ CFLAGS += -Wall # -pedantic
|
||||
endif
|
||||
|
||||
INCLUDES = -I. -I../include
|
||||
INCLUDES += -I$(OPENSSL_PATH)/outinc -I$(OPENSSL_PATH)/outinc/openssl
|
||||
|
||||
ifdef LINK_STATIC
|
||||
LDLIBS += $(OPENSSL_PATH)/out/libcrypto.$(LIBEXT) $(OPENSSL_PATH)/out/libssl.$(LIBEXT)
|
||||
ifndef OPENSSL_INCLUDE
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
|
||||
OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
|
||||
endif
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
|
||||
OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
|
||||
endif
|
||||
endif
|
||||
ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
|
||||
$(error Invalid OPENSSL_PATH: $(OPENSSL_PATH))
|
||||
endif
|
||||
INCLUDES += -I"$(OPENSSL_INCLUDE)"
|
||||
ifndef OPENSSL_LIBPATH
|
||||
OPENSSL_LIBS_STAT = crypto ssl
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
|
||||
OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
|
||||
OPENSSL_LIBS_DYN = eay32 ssl32
|
||||
endif
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
|
||||
OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
|
||||
OPENSSL_LIBS_DYN = crypto.dll ssl.dll
|
||||
endif
|
||||
endif
|
||||
ifdef LINK_OPENSSL_STATIC
|
||||
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_STAT)) -lgdi32
|
||||
else
|
||||
LDLIBS += $(OPENSSL_PATH)/out/libeay32.$(LIBEXT) $(OPENSSL_PATH)/out/libssl32.$(LIBEXT)
|
||||
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
|
||||
endif
|
||||
|
||||
ifdef WITH_ZLIB
|
||||
CFLAGS += -DLIBSSH2_HAVE_ZLIB
|
||||
INCLUDES += -I$(ZLIB_PATH)
|
||||
LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
|
||||
ifdef LINK_ZLIB_STATIC
|
||||
LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
|
||||
else
|
||||
LDLIBS += $(ZLIB_PATH)/libz.dll.$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
CFLAGS += $(INCLUDES)
|
||||
@@ -166,64 +202,68 @@ $(OBJDIR)/%.o: %.c
|
||||
# @echo Compiling $<
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/version.inc: ../include/libssh2.h $(OBJDIR)
|
||||
$(OBJDIR)/version.inc: ../get_ver.awk ../include/libssh2.h $(OBJDIR)
|
||||
@echo Creating $@
|
||||
@$(AWK) -f ../get_ver.awk $< > $@
|
||||
@$(AWK) -f $^ > $@
|
||||
|
||||
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
||||
@-$(MD) $(DISTDIR)$(DS)bin
|
||||
@-$(CP) ..$(DS)INSTALL $(DISTDIR)
|
||||
@-$(CP) ..$(DS)LICENSE $(DISTDIR)
|
||||
@-$(CP) ..$(DS)README $(DISTDIR)
|
||||
@$(CP) $(TARGET).dll $(DISTDIR)$(DS)bin
|
||||
@$(call MKDIR, $(DISTDIR)/bin)
|
||||
@$(call CP, ../AUTHORS, $(DISTDIR))
|
||||
@$(call CP, ../COPYING, $(DISTDIR))
|
||||
@$(call CP, ../INSTALL, $(DISTDIR))
|
||||
@$(call CP, ../README, $(DISTDIR))
|
||||
@$(call CP, ../RELEASE-NOTES, $(DISTDIR))
|
||||
@$(call CP, $(TARGET).dll, $(DISTDIR)/bin)
|
||||
@echo Creating $(DISTARC)
|
||||
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
|
||||
|
||||
dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
|
||||
@-$(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
|
||||
@$(call MKDIR, $(DEVLDIR)/bin)
|
||||
@$(call MKDIR,$(DEVLDIR)/include)
|
||||
@$(call MKDIR, $(DEVLDIR)/win32)
|
||||
@$(call CP, ../AUTHORS, $(DEVLDIR))
|
||||
@$(call CP, ../COPYING, $(DEVLDIR))
|
||||
@$(call CP, ../INSTALL, $(DEVLDIR))
|
||||
@$(call CP, ../README, $(DEVLDIR))
|
||||
@$(call CP, ../RELEASE-NOTES, $(DEVLDIR))
|
||||
@$(call CP, $(TARGET).dll, $(DEVLDIR)/bin)
|
||||
@$(call CP, ../include/*.h, $(DEVLDIR)/include)
|
||||
@$(call CP, libssh2_config.h, $(DEVLDIR)/include)
|
||||
@$(call CP, *.$(LIBEXT), $(DEVLDIR)/win32)
|
||||
@echo Creating $(DEVLARC)
|
||||
@$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
|
||||
|
||||
distclean: clean
|
||||
-$(RD) $(DISTDIR)
|
||||
-$(RM) $(DISTARC)
|
||||
$(call RMDIR, $(DISTDIR))
|
||||
$(call DEL, $(DISTARC))
|
||||
|
||||
devclean: clean
|
||||
-$(RD) $(DEVLDIR)
|
||||
-$(RM) $(DEVLARC)
|
||||
$(call RMDIR, $(DEVLDIR))
|
||||
$(call DEL, $(DEVLARC))
|
||||
|
||||
objclean: all
|
||||
-$(RD) $(OBJDIR)
|
||||
$(call RMDIR, $(OBJDIR))
|
||||
|
||||
testclean: clean
|
||||
$(MAKE) -C test -f GNUmakefile clean
|
||||
|
||||
clean:
|
||||
# -$(RM) libssh2_config.h
|
||||
-$(RM) $(TARGET).dll $(TARGET).$(LIBEXT) $(TARGET)dll.$(LIBEXT)
|
||||
-$(RD) $(OBJDIR)
|
||||
# $(call DEL, libssh2_config.h)
|
||||
$(call DEL, $(TARGET).dll $(TARGET).def $(TARGET).$(LIBEXT) $(TARGET)dll.$(LIBEXT))
|
||||
$(call RMDIR, $(OBJDIR))
|
||||
|
||||
$(OBJDIR):
|
||||
@$(MD) $@
|
||||
@$(call MKDIR, $@)
|
||||
|
||||
$(DISTDIR):
|
||||
@$(MD) $@
|
||||
@$(call MKDIR, $@)
|
||||
|
||||
$(DEVLDIR):
|
||||
@$(MD) $@
|
||||
@$(call MKDIR, $@)
|
||||
|
||||
$(TARGET).$(LIBEXT): $(OBJS)
|
||||
@echo Creating $@
|
||||
@-$(RM) $@
|
||||
@$(call DEL, $@)
|
||||
@$(AR) $(ARFLAGS) $@ $^
|
||||
ifdef RANLIB
|
||||
@$(RANLIB) $@
|
||||
@@ -231,7 +271,7 @@ endif
|
||||
|
||||
$(TARGET).dll $(TARGET)dll.a: $(OBJL)
|
||||
@echo Linking $@
|
||||
@-$(RM) $@
|
||||
@$(call DEL, $@)
|
||||
@$(LD) $(LDFLAGS) $^ -o $@ $(LIBPATH) $(LDLIBS)
|
||||
|
||||
|
||||
|
@@ -64,13 +64,13 @@ CFLAGS += -d_WIN32_WINNT=0x0501 -dENABLE_IPV6
|
||||
!ifdef %zlib_root
|
||||
ZLIB_ROOT = $(%zlib_root)
|
||||
!else
|
||||
ZLIB_ROOT = ..\..\zlib-1.2.5
|
||||
ZLIB_ROOT = ..\..\zlib-1.2.7
|
||||
!endif
|
||||
|
||||
!ifdef %openssl_root
|
||||
OPENSSL_ROOT = $(%openssl_root)
|
||||
!else
|
||||
OPENSSL_ROOT = ..\..\openssl-0.9.8r
|
||||
OPENSSL_ROOT = ..\..\openssl-0.9.8x
|
||||
!endif
|
||||
|
||||
#!ifdef %use_zlib
|
||||
|
@@ -1,10 +1,10 @@
|
||||
|
||||
# Tweak these for your system
|
||||
OPENSSLINC=..\openssl-0.9.8q\inc32
|
||||
OPENSSLLIB=..\openssl-0.9.8q\out32dll
|
||||
OPENSSLINC=..\openssl-0.9.8x\inc32
|
||||
OPENSSLLIB=..\openssl-0.9.8x\out32dll
|
||||
|
||||
ZLIBINC=-DLIBSSH2_HAVE_ZLIB=1 /I..\zlib-1.2.5
|
||||
ZLIBLIB=..\zlib-1.2.5
|
||||
ZLIBINC=-DLIBSSH2_HAVE_ZLIB=1 /I..\zlib-1.2.7
|
||||
ZLIBLIB=..\zlib-1.2.7
|
||||
|
||||
!if "$(TARGET)" == ""
|
||||
TARGET=Release
|
||||
@@ -21,8 +21,9 @@ DLLFLAGS=/DEBUG /LD
|
||||
|
||||
CPPFLAGS=/nologo /GL /Zi /EHsc $(CPPFLAGS) /Iwin32 /Iinclude /I$(OPENSSLINC) $(ZLIBINC) -DLIBSSH2_WIN32
|
||||
CFLAGS=$(CPPFLAGS)
|
||||
RCFLAGS=/Iinclude
|
||||
DLLFLAGS=$(CFLAGS) $(DLLFLAGS)
|
||||
LIBS=$(OPENSSLLIB)\libeay32.lib $(OPENSSLLIB)\ssleay32.lib ws2_32.lib $(ZLIBLIB)\zlib.lib
|
||||
LIBS=$(OPENSSLLIB)\libeay32.lib $(OPENSSLLIB)\ssleay32.lib ws2_32.lib user32.lib $(ZLIBLIB)\zlib.lib
|
||||
|
||||
INTDIR=$(TARGET)\$(SUBDIR)
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#define HAVE_UNISTD_H
|
||||
#define HAVE_INTTYPES_H
|
||||
#define HAVE_SYS_TIME_H
|
||||
#define HAVE_GETTIMEOFDAY
|
||||
#endif
|
||||
|
||||
#define HAVE_WINSOCK2_H
|
||||
@@ -34,9 +35,6 @@
|
||||
#define strcasecmp stricmp
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Compile in zlib support */
|
||||
#define LIBSSH2_HAVE_ZLIB 1
|
||||
|
||||
/* Enable newer diffie-hellman-group-exchange-sha1 syntax */
|
||||
#define LIBSSH2_DH_GEX_NEW 1
|
||||
|
||||
|
@@ -9,12 +9,12 @@
|
||||
|
||||
# Edit the path below to point to the base of your Zlib sources.
|
||||
ifndef ZLIB_PATH
|
||||
ZLIB_PATH = ../../../zlib-1.2.5
|
||||
ZLIB_PATH = ../../../zlib-1.2.7
|
||||
endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8r
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8x
|
||||
endif
|
||||
|
||||
# Edit the var below to set to your architecture or set environment var.
|
||||
@@ -28,8 +28,6 @@ LINK_STATIC = 1
|
||||
# Edit the vars below to change target settings.
|
||||
SAMPLES = ../../example
|
||||
TARGETS := $(filter-out x11.exe,$(patsubst $(SAMPLES)/%.c,%.exe,$(strip $(wildcard $(SAMPLES)/*.c))))
|
||||
VERSION = $(LIBSSH2_VERSION)
|
||||
COPYR = (c) $(LIBSSH2_COPYRIGHT_STR)
|
||||
WWWURL = http://www.libssh2.org/
|
||||
DESCR = libssh2 $(subst .rc,,$(notdir $@)) $(LIBSSH2_VERSION_STR)
|
||||
#STACK = 64000
|
||||
@@ -48,29 +46,39 @@ else
|
||||
OBJDIR = debug
|
||||
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
|
||||
|
||||
# Platform-dependent helper tool macros
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DEL = rm -f $1
|
||||
RMDIR = rm -fr $1
|
||||
MKDIR = mkdir -p $1
|
||||
COPY = -cp -afv $1 $2
|
||||
#COPYR = -cp -afr $1/* $2
|
||||
COPYR = -rsync -aC $1/* $2
|
||||
TOUCH = touch $1
|
||||
CAT = cat
|
||||
ECHONL = echo ""
|
||||
DL = '
|
||||
else
|
||||
ifeq "$(OS)" "Windows_NT"
|
||||
DEL = -del 2>NUL /q /f $(subst /,\,$1)
|
||||
RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
|
||||
else
|
||||
DEL = -del 2>NUL $(subst /,\,$1)
|
||||
RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
|
||||
endif
|
||||
MKDIR = -md 2>NUL $(subst /,\,$1)
|
||||
COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
|
||||
COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
|
||||
TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
|
||||
CAT = type
|
||||
ECHONL = $(ComSpec) /c echo.
|
||||
endif
|
||||
|
||||
# The following line defines your compiler.
|
||||
ifdef METROWERKS
|
||||
CC = mwcc
|
||||
@@ -78,8 +86,11 @@ else
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
endif
|
||||
|
||||
# Include the version info retrieved from libssh2.h
|
||||
-include $(OBJDIR)/version.inc
|
||||
|
||||
# Global flags for all compilers
|
||||
CFLAGS = $(OPT) -D$(DB) -DWIN32 -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
endif
|
||||
@@ -113,26 +124,53 @@ CFLAGS += -Wall #-Wno-unused #-pedantic
|
||||
endif
|
||||
|
||||
INCLUDES = -I.. -I../../include
|
||||
INCLUDES += -I$(OPENSSL_PATH)/outinc -I$(OPENSSL_PATH)/outinc/openssl
|
||||
#LIBPATH += -L$(OPENSSL_PATH)/out
|
||||
LIBPATH += -L..
|
||||
|
||||
ifdef LINK_STATIC
|
||||
LDLIBS += -llibssh2
|
||||
#LDLIBS += $(OPENSSL_PATH)/out/libcrypto.$(LIBEXT) $(OPENSSL_PATH)/out/libssl.$(LIBEXT)
|
||||
else
|
||||
LDLIBS += -llibssh2dll
|
||||
#LDLIBS += $(OPENSSL_PATH)/out/libeay32.$(LIBEXT) $(OPENSSL_PATH)/out/libssl32.$(LIBEXT)
|
||||
endif
|
||||
|
||||
ifndef OPENSSL_INCLUDE
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
|
||||
OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
|
||||
endif
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
|
||||
OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
|
||||
endif
|
||||
endif
|
||||
ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
|
||||
$(error Invalid OPENSSL_PATH: $(OPENSSL_PATH))
|
||||
endif
|
||||
INCLUDES += -I"$(OPENSSL_INCLUDE)"
|
||||
ifndef OPENSSL_LIBPATH
|
||||
OPENSSL_LIBS_STAT = crypto ssl
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
|
||||
OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
|
||||
OPENSSL_LIBS_DYN = eay32 ssl32
|
||||
endif
|
||||
ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
|
||||
OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
|
||||
OPENSSL_LIBS_DYN = crypto.dll ssl.dll
|
||||
endif
|
||||
endif
|
||||
ifdef LINK_STATIC
|
||||
ifdef LINK_OPENSSL_STATIC
|
||||
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_STAT)) -lgdi32
|
||||
else
|
||||
LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef WITH_ZLIB
|
||||
CFLAGS += -DLIBSSH2_HAVE_ZLIB
|
||||
INCLUDES += -I$(ZLIB_PATH)
|
||||
#LIBPATH = -L$(ZLIB_PATH)
|
||||
#ifdef LINK_STATIC
|
||||
# LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
|
||||
#else
|
||||
# LDLIBS += $(ZLIB_PATH)/libzdll.$(LIBEXT)
|
||||
#endif
|
||||
ifdef LINK_ZLIB_STATIC
|
||||
LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
|
||||
else
|
||||
LDLIBS += $(ZLIB_PATH)/libzdll.$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
CFLAGS += $(INCLUDES)
|
||||
@@ -155,17 +193,17 @@ $(OBJDIR)/version.inc: ../../include/libssh2.h $(OBJDIR)
|
||||
@$(AWK) -f ../../get_ver.awk $< > $@
|
||||
|
||||
objclean:
|
||||
-$(RD) $(OBJDIR)
|
||||
$(call RMDIR, $(OBJDIR))
|
||||
|
||||
clean: objclean
|
||||
-$(RM) $(TARGETS)
|
||||
$(call DEL, $(TARGETS))
|
||||
|
||||
$(OBJDIR):
|
||||
$(MD) $@
|
||||
$(call MKDIR, $@)
|
||||
|
||||
%.exe: $(OBJDIR)/%.o $(OBJDIR)/%.res
|
||||
@echo Linking $@
|
||||
@-$(RM) $@
|
||||
@$(call DEL, $@)
|
||||
$(LD) $(LDFLAGS) $^ -o $@ $(LIBPATH) $(LDLIBS)
|
||||
|
||||
$(OBJDIR)/%.res: $(OBJDIR)/%.rc
|
||||
@@ -186,7 +224,7 @@ $(OBJDIR)/%.rc: GNUmakefile $(OBJDIR)/version.inc
|
||||
@echo $(DL) BEGIN$(DL) >> $@
|
||||
@echo $(DL) BLOCK "040904E4"$(DL) >> $@
|
||||
@echo $(DL) BEGIN$(DL) >> $@
|
||||
@echo $(DL) VALUE "LegalCopyright","$(COPYR)\0"$(DL) >> $@
|
||||
@echo $(DL) VALUE "LegalCopyright","\xA9 $(LIBSSH2_COPYRIGHT_STR)\0"$(DL) >> $@
|
||||
ifdef COMPANY
|
||||
@echo $(DL) VALUE "CompanyName","$(COMPANY)\0"$(DL) >> $@
|
||||
endif
|
||||
|
Reference in New Issue
Block a user