Compare commits

...

1735 Commits

Author SHA1 Message Date
Daniel Stenberg
6d553a7bb9 web: the site is now HTTPS 2016-02-23 08:52:47 +01:00
Daniel Stenberg
da6676483b RELEASE-NOTES: 1.7.0 release 2016-02-23 08:25:01 +01:00
Daniel Stenberg
ca5222ea81 diffie_hellman_sha256: convert bytes to bits
As otherwise we get far too small numbers.

Reported-by: Andreas Schneider

CVE-2016-0787
2016-02-23 08:23:19 +01:00
Alexander Lamaison
d453f4ce3c Allow CI failures with VS 2008 x64.
Appveyor doesn't support this combination.
2016-02-18 21:56:04 +00:00
Viktor Szakats
1fcf849e15 GNUmakefile: list system libs after user libs
Otherwise some referenced WinSock functions will fail to
resolve when linking against LibreSSL 2.3.x static libraries
with mingw.

Closes #80
2016-02-16 00:11:32 +01:00
Viktor Szakats
65a4528d17 openssl: apply new HAVE_OPAQUE_STRUCTS macro
Closes #81
2016-02-16 00:08:43 +01:00
Viktor Szakats
0ffb3bfafe openssl: fix LibreSSL support after OpenSSL 1.1.0-pre1/2 support 2016-02-16 00:08:08 +01:00
Alexander Lamaison
30221cfe5d sftp.h: Fix non-C90 type.
uint64_t does not exist in C90.  Use libssh2_uint64_t instead.
2016-02-14 22:12:10 +00:00
Alexander Lamaison
fb2840bc9c Exclude sshd tests from AppVeyor.
They fail complaining that sshd wasn't invoked with an absolute path.
2016-02-14 21:38:12 +00:00
Alexander Lamaison
78043ff25d Test on more versions of Visual Studio. 2016-02-14 20:57:03 +00:00
Alexander Lamaison
5eac3edda5 Fix Appveyor builds. 2016-02-14 20:49:31 +00:00
Viktor Szakats
298f056fd6 openssl: add OpenSSL 1.1.0-pre3-dev compatibility
by using API instead of accessing an internal structure.

Closes #83
2016-02-14 10:56:37 +01:00
Daniel Stenberg
652ae4d134 RELEASE-NOTES: synced with 996b04ececdf 2016-02-12 16:19:26 +01:00
Daniel Stenberg
996b04ecec include/libssh2.h: next version is 1.7.0 2016-02-12 16:19:06 +01:00
Daniel Stenberg
8d568d6c3b configure: build "silent" if possible 2016-02-11 14:00:37 +01:00
Daniel Stenberg
ae484b426c sftp: re-indented some minor stuff 2016-02-11 13:57:14 +01:00
Jakob Egger
85dbd4c136 sftp.c: ensure minimum read packet size
For optimum performance we need to ensure we don't request tiny packets.
2016-02-11 13:57:14 +01:00
Jakob Egger
d7e25b4729 sftp.c: Explicit return values & sanity checks 2016-02-11 13:57:14 +01:00
Jakob Egger
e12fe71462 sftp.c: Check Read Packet File Offset
This commit adds a simple check to see if the offset of the read
request matches the expected file offset.

We could try to recover, from this condition at some point in the future.
Right now it is better to return an error instead of corrupted data.
2016-02-11 13:57:14 +01:00
Jakob Egger
992de2fbfa sftp.c: Don't return EAGAIN if data was written to buffer 2016-02-11 13:57:14 +01:00
Jakob Egger
77c48d4e26 sftp.c: Send at least one read request before reading
This commit ensures that we have sent at least one read request before
we try to read data in sftp_read().

Otherwise sftp_read() would return 0 bytes (indicating EOF) if the
socket is not ready for writing.
2016-02-11 13:57:09 +01:00
Jakob Egger
0d60964632 sftp.c: stop reading when buffer is full
Since we can only store data from a single chunk in filep,
we have to stop receiving data as soon as the buffer is full.

This adresses the following bug report:
https://github.com/libssh2/libssh2/issues/50
2016-02-11 13:54:10 +01:00
Salvador Fandiño
60874670ef agent_disconnect_unix: unset the agent fd after closing it
"agent_disconnect_unix", called by "libssh2_agent_disconnect", was
leaving the file descriptor in the agent structure unchanged. Later,
"libssh2_agent_free" would call again "libssh2_agent_disconnect" under
the hood and it would try to close again the same file descriptor. In
most cases that resulted in just a harmless error, but it is also
possible that the file descriptor had been reused between the two
calls resulting in the closing of an unrelated file descriptor.

This patch sets agent->fd to LIBSSH2_INVALID_SOCKET avoiding that
issue.

Signed-off-by: Salvador Fandiño <sfandino@yahoo.com>
2016-01-21 09:23:37 +01:00
Patrick Monnerat
77d825ac93 os400qc3: support encrypted private keys
PKCS#8 EncryptedPrivateKeyinfo structures are recognized and decoded to get
values accepted by the Qc3 crypto library.
2016-01-18 13:42:57 +01:00
Patrick Monnerat
b60fb64b17 os400qc3: New PKCS#5 decoder
The Qc3 library is not able to handle PKCS#8 EncryptedPrivateKeyInfo structures
by itself. It is only capable of decrypting the (encrypted) PrivateKeyInfo
part, providing a key encryption key and an encryption algorithm are given.
Since the encryption key and algorithm description part in a PKCS#8
EncryptedPrivateKeyInfo is a PKCS#5 structure, such a decoder is needed to
get the derived key method and hash, as well as encryption algorith and
initialisation vector.
2016-01-18 13:35:28 +01:00
Patrick Monnerat
0de1cba671 os400qc3: force continuous update on non-final hash/hmac computation 2016-01-18 13:35:28 +01:00
Patrick Monnerat
2ddcaf2db8 os400qc3: Be sure hmac keys have a minimum length
The Qc3 library requires a minimum key length depending on the target
hash algorithm. Append binary zeroes to the given key if not long enough.
This matches RFC 2104 specifications.
2016-01-18 13:35:28 +01:00
Patrick Monnerat
0f15724e72 os400qc3: Slave descriptor for key encryption key
The Qc3 library requires the key encryption key to exist as long as
the encrypted key is used. Its descriptor token is then kept as an
"encrypted key slave" for recursive release.
2016-01-18 13:35:28 +01:00
Patrick Monnerat
57692b6b10 os400qc3.c: comment PEM/DER decoding 2016-01-18 13:35:28 +01:00
Patrick Monnerat
92a3ac4673 os400qc3.c: improve ASN.1 header byte checks 2016-01-18 13:35:28 +01:00
Patrick Monnerat
72453b7367 os400qc3.c: improve OID matching 2016-01-18 13:35:28 +01:00
Patrick Monnerat
8b720f342f os400: os400qc3.c: replace malloc by LIBSSH2_ALLOC or alloca where possible 2016-01-18 13:35:28 +01:00
Patrick Monnerat
e2985f0a67 os400: asn1_new_from_bytes(): use data from a single element only 2016-01-18 13:35:28 +01:00
Patrick Monnerat
002db176b7 os400: fix an ILE/RPG prototype 2016-01-18 13:35:28 +01:00
Patrick Monnerat
7a37c33264 os400: implement character encoding conversion support 2016-01-18 13:35:28 +01:00
Patrick Monnerat
914157804f os400: do not miss some external prototypes
Build procedure extproto() did not strip braces from header files, thus
possibly prepended them to true prototypes. This prevented the prototype to
be recognized as such.
The solution implemented here is to map braces to semicolons, effectively
considering them as potential prototype delimiters.
2016-01-18 13:35:28 +01:00
Patrick Monnerat
4c4d6a8da4 os400: Really add specific README 2016-01-18 13:35:28 +01:00
Patrick Monnerat
c367e61294 os400: Add specific README and include new files in dist tarball 2016-01-18 13:35:28 +01:00
Patrick Monnerat
d900984b0a os400: add compilation scripts 2016-01-18 13:35:28 +01:00
Patrick Monnerat
4bd6d7ebf6 os400: include files for ILE/RPG
In addition, file os400/macros.h declares all procedures originally
defined as macros. It must not be used for real inclusion and is only
intended to be used as a `database' for macro wrapping procedures generation.
2016-01-18 13:35:28 +01:00
Patrick Monnerat
dac4b3bac3 os400: add supplementary header files/wrappers. Define configuration. 2016-01-18 13:35:28 +01:00
Patrick Monnerat
7dcf5ed6fb Protect callback function calls from macro substitution
Some structure fields holding callback addresses have the same name as the
underlying system function (connect, send, recv). Set parentheses around
their reference to suppress a possible macro substitution.

Use a macro for connect() on OS/400 to resolve a const/nonconst parameter
problem.
2016-01-18 13:35:28 +01:00
Patrick Monnerat
8ba6bf2aef Add interface for OS/400 crypto library QC3 2016-01-18 13:35:28 +01:00
Patrick Monnerat
0fba5cfda6 misc: include stdarg.h for debug code 2016-01-18 13:35:28 +01:00
Patrick Monnerat
72bedfe761 Document crypto library interface 2016-01-18 13:35:28 +01:00
Patrick Monnerat
f915a31a4d Feature an optional crypto-specific macro to rsa sign a data fragment vector
OS/400 crypto library is unable to sign a precomputed SHA1 hash: however
it does support a procedure that hashes data fragments and rsa signs.
If defined, the new macro _libssh2_rsa_sha1_signv() implements this function
and disables use of _libssh2_rsa_sha1_sign().

The function described above requires that the struct iovec unused slacks are
cleared: for this reason, macro libssh2_prepare_iovec() has been introduced.
It should be defined as empty for crypto backends that are not sensitive
to struct iovec unused slack values.
2016-01-18 13:35:28 +01:00
Patrick Monnerat
0fbf8f3c7e Fold long lines in include files 2016-01-18 13:35:28 +01:00
Viktor Szakats
e64260a117 kex.c: fix indentation
Closes #71
2016-01-17 17:11:58 +01:00
Viktor Szakats
ed2c3c8d28 add OpenSSL-1.1.0-pre2 compatibility
Closes #70
2016-01-17 17:10:45 +01:00
Viktor Szakats
73930e6577 add OpenSSL 1.1.0-pre1 compatibility
* close https://github.com/libssh2/libssh2/issues/69
* sync a declaration with the rest of similar ones
* handle EVP_MD_CTX_new() returning NULL with OpenSSL 1.1.0
* fix potential memory leak with OpenSSL 1.1.0 in
  _libssh2_*_init() functions, when EVP_MD_CTX_new() succeeds,
  but EVP_DigestInit() fails.
2016-01-17 17:10:32 +01:00
Marc Hoersken
cf544d0f4c wincng.c: fixed _libssh2_wincng_hash_final return value
_libssh2_wincng_hash_final was returning the internal BCRYPT
status code instead of a valid libssh2 return value (0 or -1).

This also means that _libssh2_wincng_hash never returned 0.
2015-12-22 13:38:10 +01:00
Marc Hoersken
d0ffeba72e wincng.c: fixed possible memory leak in _libssh2_wincng_hash
If _libssh2_wincng_hash_update failed _libssh2_wincng_hash_final
would never have been called before.

Reported by Zenju.
2015-12-22 13:36:56 +01:00
Paul Howarth
9bf32da607 libssh2.pc.in: fix the output of pkg-config --libs
... such that it does not include LDFLAGS used to build libssh2 itself.
There was a similar fix in the curl project long time ago:

https://github.com/bagder/curl/commit/curl-7_19_7-56-g4c8adc8

Bug: https://bugzilla.redhat.com/1279966
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
2015-12-15 10:57:50 +01:00
Marc Hoersken
95dc2a6a52 hostkey.c: align code path of ssh_rsa_init to ssh_dss_init 2015-12-06 21:35:09 +01:00
Marc Hoersken
036196b0b0 hostkey.c: fix invalid memory access if libssh2_dsa_new fails
Reported by dimmaq, fixes #66
2015-12-06 21:34:54 +01:00
Will Cosgrove
51dcded3eb gcrypt: define libssh2_sha256_ctx
Looks like it didn't make it into the latest commit for whatever reason.

Closes #58
2015-11-03 07:43:32 +01:00
Salvador Fandino
b83c3e056e libssh2_session_set_last_error: Add function
Net::SSH2, the Perl wrapping module for libssh2 implements several features*
on top of libssh2 that can fail and so need some mechanism to report the error
condition to the user.

Until now, besides the error state maintained internally by libssh2, another
error state was maintained at the Perl level for every session object and then
additional logic was used to merge both error states. That is a maintenance
nighmare, and actually there is no way to do it correctly and consistently.

In order to allow the high level language to add new features to the library
but still rely in its error reporting features the new function
libssh2_session_set_last_error (that just exposses _libssh2_error_flags) is
introduced.

*) For instance, connecting to a remote SSH service giving the hostname and
port.

Signed-off-by: Salvador Fandino <sfandino@yahoo.com>
Signed-off-by: Salvador Fandiño <sfandino@yahoo.com>
2015-11-02 14:50:15 +01:00
Salvador Fandino
ad23faaae6 _libssh2_error: Support allocating the error message
Before this patch "_libssh2_error" required the error message to be a
static string.

This patch adds a new function "_libssh2_error_flags" accepting an
additional "flags" argument and specifically the flag
"LIBSSH2_ERR_FLAG_DUP" indicating that the passed string must be
duplicated into the heap.

Then, the method "_libssh2_error" has been rewritten to use that new
function under the hood.

Signed-off-by: Salvador Fandino <sfandino@yahoo.com>
Signed-off-by: Salvador Fandiño <sfandino@yahoo.com>
2015-11-02 14:49:54 +01:00
Will Cosgrove
d441da3086 added engine.h include to fix warning 2015-10-05 10:52:52 +02:00
sune
ad26fd92cf kex.c: removed dupe entry from libssh2_kex_methods[]
Closes #51
2015-10-05 10:50:34 +02:00
Salvador Fandiño
4d97ed92b2 userauth: Fix off by one error when reading public key file
After reading the public key from file the size was incorrectly
decremented by one.

This was usually a harmless error as the last character on the public
key file is an unimportant EOL. But if due to some error the public key
file is empty, the public key size becomes (uint)(0 - 1), resulting in
an unrecoverable out of memory error later.

Signed-off-by: Salvador Fandi??o <sfandino-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2015-09-29 09:48:48 +02:00
Salvador Fandino
fb432f3f78 channel: Detect bad usage of libssh2_channel_process_startup
A common novice programmer error (at least among those using the
wrapping Perl module Net::SSH2), is to try to reuse channels.

This patchs detects that incorrect usage and fails with a
LIBSSH2_ERROR_BAD_USE error instead of hanging.

Signed-off-by: Salvador Fandino <sfandino-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
2015-09-29 09:48:36 +02:00
Will Cosgrove
fc4a969a05 kex: Added diffie-hellman-group-exchange-sha256 support
... and fixed HMAC_Init depricated usage

Closes #48
2015-09-29 09:43:30 +02:00
Alexander Lamaison
92fff06e27 Prefixed new #defines to prevent collisions.
Other libraries might have their own USE_WIN32_*FILES.
2015-09-21 18:44:48 +01:00
keith-daigle
a49f479b4c Update examples/scp.c to fix bug where large files on win32 would cause got to wrap and go negative 2015-09-21 18:01:24 +01:00
David Byron
6c84a426be add libssh2_scp_recv2 to support large (> 2GB) files on windows 2015-09-21 18:01:23 +01:00
sune
4961014033 WinCNG: support for SHA256/512 HMAC
Closes #47
2015-09-17 15:27:30 +02:00
brian m. carlson
a53cebba34 Add support for HMAC-SHA-256 and HMAC-SHA-512.
Implement support for these algorithms and wire them up to the libgcrypt
and OpenSSL backends.  Increase the maximum MAC buffer size to 64 bytes
to prevent buffer overflows.  Prefer HMAC-SHA-256 over HMAC-SHA-512, and
that over HMAC-SHA-1, as OpenSSH does.

Closes #40
2015-09-16 09:32:19 +02:00
Zenju
3768f8aeef kex: free server host key before allocating it (again)
Fixes a memory leak when Synology server requests key exchange

Closes #43
2015-09-12 12:30:13 +02:00
Viktor Szakats
3acca4ad15 GNUmakefile: up OpenSSL version
closes #23
2015-09-04 08:17:57 +02:00
Viktor Szakats
026ec0e881 GNUmakefile: add -m64 CFLAGS when targeting mingw64, add -m32/-m64 to LDFLAGS
libssh2 equivalent of curl patch d21b66835f

This allows to build for the non-default target when using a multi-target mingw distro.
Also bump default OpenSSL dependency path to 1.0.2c.
2015-09-04 08:17:51 +02:00
Viktor Szakats
a4d995af0d GNUmakefile: add support for LIBSSH2_LDFLAG_EXTRAS
It is similar to existing LIBSSH2_CFLAG_EXTRAS, but for
extra linker options.

Also delete some line/file ending whitespace.

closes #27
2015-08-07 00:38:40 +02:00
nasacj
9af7eb48dc hostkey.c: Fix compiling error when OPENSSL_NO_MD5 is defined
Closes #32
2015-08-07 00:36:23 +02:00
Mizunashi Mana
f4b5947d6d openssl.h: adjust the rsa/dsa includes
... to work when built without DSA support.

Closes #36
2015-08-07 00:34:36 +02:00
Alexander Lamaison
36f6d23572 Let CMake build work as a subproject.
Patch contributed by JasonHaslam.
2015-07-26 10:50:41 +01:00
Alexander Lamaison
af14462d53 Fix builds with Visual Studio 2015.
VS2015 moved stdio functions to the header files as inline function.  That means check_function_exists can't detect them because it doesn't use header files - just does a link check.  Instead we need to use check_symbol_exists with the correct headers.
2015-07-25 22:19:46 +01:00
Kamil Dudka
d48d7c3a87 cmake: include CMake files in the release tarballs
Despite we announced the CMake support in libssh2-1.6.0 release notes,
the files required by the CMake build system were not included in the
release tarballs.  Hence, the only way to use CMake for build was the
upstream git repository.

This commit makes CMake actually supported in the release tarballs.
2015-07-02 13:09:49 +02:00
Kamil Dudka
13f8addd1b tests/mansyntax.sh: fix 'make distcheck' with recent autotools
Do not create symbolic links off the build directory.  Recent autotools
verify that out-of-source build works even if the source directory tree
is not writable.
2015-07-02 12:42:55 +02:00
Kamil Dudka
418be878ad openssl: fix memleak in _libssh2_dsa_sha1_verify() 2015-06-12 12:05:27 +02:00
Daniel Stenberg
e9536edede openssl: make libssh2_sha1 return error code
- use the internal prefix _libssh2_ for non-exported functions

- removed libssh2_md5() since it wasn't used

Reported-by: Kamil Dudka
2015-06-12 10:53:18 +02:00
LarsNordin-LNdata
d754fee2f2 SFTP: Increase speed and datasize in SFTP read
The function sftp_read never return more then 2000 bytes (as it should
when I asked Daniel). I increased the MAX_SFTP_READ_SIZE to 30000 but
didn't get the same speed as a sftp read in SecureSSH. I analyzed the
code and found that a return always was dona when a chunk has been read.
I changed it to a sliding buffer and worked on all available chunks. I
got an increase in speed and non of the test I have done has failed
(both local net and over Internet). Please review and test. I think
30000 is still not the optimal MAX_SFTP_READ_SIZE, my next goal is to
make an API to enable changing this value (The SecureSSH sftp_read has
more complete filled packages when comparing the network traffic)
2015-06-12 09:15:47 +02:00
Daniel Stenberg
6c14cc003a bump: start working on 1.6.1 2015-06-12 09:15:47 +02:00
Daniel Stenberg
cbd5f72339 RELEASE-NOTES: synced with 858930cae5c6a 2015-06-05 17:05:58 +02:00
Marc Hoersken
858930cae5 wincng.c: fixed indentation 2015-05-19 23:12:43 +02:00
sbredahl
08fa27b628 wincng.c: fixed memleak in (block) cipher destructor 2015-05-19 22:59:16 +02:00
Jakob Egger
4383a39d83 libssh2_channel_open: more detailed error message
The error message returned by libssh2_channel_open in case of a server side channel open failure is now more detailed and includes the four standard error conditions in RFC 4254.
2015-05-06 11:28:27 +01:00
Hannes Domani
09c5e59933 kex: fix libgcrypt memory leaks of bignum
Fixes #168.
2015-04-03 17:39:15 +01:00
Marc Hoersken
5a88a86fef configure.ac: check for SecureZeroMemory for clear memory feature 2015-04-03 16:44:53 +02:00
Marc Hoersken
0340d4586e Revert "wincng.c: fix clear memory feature compilation with mingw"
This reverts commit 2d2744efdd0497b72b3e1ff6e732aa4c0037fc43.

Autobuilds show that this did not solve the issue.
And it seems like RtlFillMemory is defined to memset,
which would be optimized out by some compilers.
2015-04-03 15:02:39 +02:00
Marc Hoersken
2d2744efdd wincng.c: fix clear memory feature compilation with mingw 2015-04-03 14:48:34 +02:00
LarsNordin-LNdata
e113202098 Enable use of OpenSSL that doesn't have DSA.
Added #if LIBSSH2_DSA for all DSA functions.
2015-04-01 23:04:16 +01:00
LarsNordin-LNdata
983ceafe58 Use correct no-blowfish #define with OpenSSL.
The OpenSSL define is OPENSSL_NO_BF, not OPENSSL_NO_BLOWFISH.
2015-04-01 23:03:28 +01:00
Marc Hoersken
e160ba448e configure: error if explicitly enabled clear-memory is not supported
This takes 22bd8d81d8fab956085e2079bf8c29872455ce59 and
b8289b625e291bbb785ed4add31f4759241067f3 into account,
but still makes it enabled by default if it is supported
and error out in case it is unsupported and was requested.
2015-03-25 22:42:27 +01:00
Daniel Stenberg
b8289b625e configure: make clear-memory default but only WARN if backend unsupported
... instead of previous ERROR.
2015-03-25 09:57:44 +01:00
Marc Hoersken
5f4c249e42 wincng.h: fix warning about computed return value not being used 2015-03-24 21:46:10 +01:00
Marc Hoersken
6f95c2efd3 nonblocking examples: fix warning about unused tvdiff on Mac OS X 2015-03-24 21:42:10 +01:00
Daniel Stenberg
31a5986c6d openssl: fix compiler warnings 2015-03-24 08:40:43 +01:00
Daniel Stenberg
22bd8d81d8 cofigure: fix --disable-clear-memory check 2015-03-24 08:39:04 +01:00
Marc Hoersken
3d3347c062 scp.c: improved command length calculation
Reduced number of calls to strlen, because shell_quotearg already
returns the length of the resulting string (e.q. quoted path)
which we can add to the existing and known cmd_len.
Removed obsolete call to memset again, because we can put a final
NULL-byte at the end of the string using the calculated length.
2015-03-23 23:17:31 +01:00
Marc Hoersken
2d59b41daa scp.c: improved and streamlined formatting 2015-03-23 23:05:41 +01:00
Marc Hoersken
1e7988cb0d scp.c: fix that scp_recv may transmit not initialised memory 2015-03-23 23:04:24 +01:00
Marc Hoersken
b99204f289 scp.c: fix that scp_send may transmit not initialised memory
Fixes ticket 244. Thanks Torsten.
2015-03-23 22:47:46 +01:00
Marc Hoersken
7ca44fbd94 kex: do not ignore failure of libssh2_sha1_init()
Based upon 43b730ce56f010e9d33573fcb020df49798c1ed8.
Fixes ticket 290. Thanks for the suggestion, mstrsn.
2015-03-23 22:25:50 +01:00
Marc Hoersken
41b1cb6751 wincng.h: fix return code of libssh2_md5_init() 2015-03-23 22:23:41 +01:00
Marc Hoersken
84590bc78f openssl.c: fix possible segfault in case EVP_DigestInit fails 2015-03-23 22:07:39 +01:00
Marc Hoersken
864950cf16 wincng.c: fix possible use of uninitialized variables 2015-03-23 21:36:10 +01:00
Marc Hoersken
09a559433e wincng.c: fix unused argument warning if clear memory is not enabled 2015-03-23 21:33:24 +01:00
Marc Hoersken
57dea4df6d wincng: Added explicit clear memory feature to WinCNG backend
This re-introduces the original feature proposed during
the development of the WinCNG crypto backend. It still needs
to be added to libssh2 itself and probably other backends.

Memory is cleared using the function SecureZeroMemory which is
available on Windows systems, just like the WinCNG backend.
2015-03-22 16:52:35 +01:00
Marc Hoersken
77020c7961 wincng.c: fixed mixed line-endings 2015-03-22 16:52:31 +01:00
Marc Hoersken
e52f35d9f4 wincng.c: fixed use of invalid parameter types in a8d14c5dcf 2015-03-22 16:32:50 +01:00
Marc Hoersken
a8d14c5dcf wincng.c: only try to load keys corresponding to the algorithm 2015-03-22 16:29:53 +01:00
Marc Hoersken
0c90b8bd9b wincng.c: moved PEM headers into definitions 2015-03-22 16:22:15 +01:00
Marc Hoersken
3fc17cd69f wincng.h: fixed invalid parameter name 2015-03-22 15:58:22 +01:00
Marc Hoersken
aa4e649d94 wincng: fixed mismatch with declarations in crypto.h 2015-03-22 15:58:00 +01:00
Marc Hoersken
49ea2be885 userauth.c: fixed warning C6001: using uninitialized sig and sig_len 2015-03-22 15:56:48 +01:00
Marc Hoersken
247dfce5fb pem.c: fixed warning C6269: possible incorrect order of operations 2015-03-22 15:54:14 +01:00
Marc Hoersken
71d45d3df1 wincng: add support for authentication keys to be passed in memory
Based upon 18cfec8336e and daa2dfa2db.
2015-03-22 15:41:51 +01:00
Marc Hoersken
daa2dfa2db pem.c: add _libssh2_pem_parse_memory to parse PEM from memory
Requirement to implement 18cfec8336e for Libgcrypt and WinCNG.
2015-03-22 14:39:14 +01:00
Marc Hoersken
1429ad749d pem.c: fix copy and paste mistake from 55d030089b8 2015-03-22 13:58:09 +01:00
Marc Hoersken
4078da8d81 userauth.c: fix another possible dereference of a null pointer 2015-03-22 13:53:42 +01:00
Marc Hoersken
0930928810 userauth.c: fix possible dereference of a null pointer 2015-03-22 13:51:47 +01:00
Marc Hoersken
55d030089b pem.c: reduce number of calls to strlen in readline 2015-03-22 13:38:22 +01:00
Will Cosgrove
260410edf3 Initialise HMAC_CTX in more places.
Missed a couple more places we init ctx to avoid openssl threading crash.
2015-03-17 00:06:51 +00:00
Alexander Lamaison
1de36eb5b4 Build build breakage in WinCNG backend caused when adding libssh2_userauth_publickey_frommemory.
The new feature isn't implemented for the WinCNG backend currently, but the WinCNG backend didn't contain any implementation of the required backend functions - even ones that returns an error.  That caused link errors.

This change fixes the problem by providing an implementation of the backend functions that returns an error.
2015-03-16 23:39:30 +00:00
Alexander Lamaison
aa7f9a85f7 Fix breakage in WinCNG backend caused by introducing libssh2_hmac_ctx_init.
The macro was defined to nothing for the libgcrypt backend, but not for WinCNG.  This brings the latter into line with the former.
2015-03-16 23:15:33 +00:00
Daniel Stenberg
41d22ccf26 userauth_publickey_frommemory.3: add AVAILABILITY
... it will be added in 1.6.0
2015-03-15 12:04:10 +01:00
Daniel Stenberg
56f7c0e2a4 libssh2: next version will be called 1.6.0
... since we just added a new function.
2015-03-15 12:03:40 +01:00
Daniel Stenberg
1329dc5155 docs: add libssh2_userauth_publickey_frommemory.3 to dist
The function and man page were added in commit 18cfec8336e
2015-03-15 11:48:59 +01:00
Jakob Egger
a1e744bb5e direct_tcpip: Fixed channel write
There were 3 bugs in this loop:
1) Started from beginning after partial writes
2) Aborted when 0 bytes were sent
3) Ignored LIBSSH2_ERROR_EAGAIN

See also:
https://trac.libssh2.org/ticket/281
https://trac.libssh2.org/ticket/293
2015-03-15 11:20:17 +01:00
Will Cosgrove
14d9ee01bc Must init HMAC_CTX before using it.
Must init ctx before using it or openssl will reuse the hmac which is not thread safe and causes a crash.
Added libssh2_hmac_ctx_init macro.
2015-03-15 00:16:46 +00:00
Alexander Lamaison
fed47c34e4 Add continuous integration configurations.
Linux-based CI is done by Travis CI.  Windows-based CI is done by Appveyor.
2015-03-15 00:06:15 +00:00
David Calavera
18cfec8336 Allow authentication keys to be passed in memory.
All credits go to Joe Turpin, I'm just reaplying and cleaning his patch:
http://www.libssh2.org/mail/libssh2-devel-archive-2012-01/0015.shtml

* Use an unimplemented error for extracting keys from memory with libgcrypt.
2015-03-14 23:54:49 +00:00
Daniel Stenberg
74624c8ddf docs: include the renamed INSTALL* files in dist 2015-03-14 17:38:21 +01:00
Alexander Lamaison
bbbdf946a7 Prevent collisions between CMake and Autotools in examples/ and tests/. 2015-03-13 07:47:41 +00:00
Alexander Lamaison
042993b8eb Avoid clash between CMake build and Autotools.
Autotools expects a configuration template file at src/libssh2_config.h.in, which buildconf generates.  But the CMake build system has its CMake-specific version of the file at this path.  This means that, if you don't run buildconf, the Autotools build will fail because it configured the wrong header template.

See https://github.com/libssh2/libssh2/pull/8.
2015-03-13 00:21:04 +00:00
Alexander Lamaison
41ed2b71a2 Merge pull request #8 from alamaison/cmake
CMake build system.
2015-03-12 23:13:39 +00:00
Alexander Lamaison
6bf8983368 CMake build system.
Tested:
 - Windows:
    - Visual C++ 2005/2008/2010/2012/2013/MinGW-w64
    - static/shared
    - 32/64-bit
    - OpenSSL/WinCNG
    - Without zlib
 - Linux:
    - GCC 4.6.3/Clang 3.4
    - static/shared
    - 32/64-bit
    - OpenSSL/Libgcrypt
    - With/Without zlib
 - MacOS X
    - AppleClang 6.0.0
    - static
    - 64-bit
    - OpenSSL
    - Without zlib

Conflicts:
	README
2015-03-12 22:48:38 +00:00
Alexander Lamaison
523a552258 Man man syntax tests fail gracefully if man version is not suitable. 2015-03-12 22:11:47 +00:00
Alexander Lamaison
d73e0ec260 Return valid code from test fixture on failure.
The sshd test fixture was returning -1 if an error occurred, but negative error codes aren't technically valid (google it).  Bash on Windows converted them to 0 which made setup failure look as though all tests were passing.
2015-03-12 21:50:11 +00:00
Alexander Lamaison
1fa5fe6059 Let mansyntax.sh work regardless of where it is called from. 2015-03-12 21:48:59 +00:00
Viktor Szakáts
8f00a7471d mingw build: allow to pass custom CFLAGS
Allow to pass custom `CFLAGS` options via environment variable
`LIBSSH2_CFLAG_EXTRAS`. Default and automatically added options of
`GNUmakefile` have preference over custom ones. This addition is useful
for passing f.e. custom CPU tuning or LTO optimization (`-flto
-ffat-lto-objects`) options. The only current way to do this is to edit
`GNUmakefile`. This patch makes it unnecessary.

This is a mirror of similar libcurl patch:
https://github.com/bagder/curl/pull/136
2015-03-12 11:23:23 +01:00
Will Cosgrove
fe3e23022b userauth: Fixed prompt text no longer being copied to the prompts struct
Regression from 031566f9c
2015-03-11 23:11:28 +01:00
Daniel Stenberg
33e1013d7b README: update the git repo locations 2015-03-11 22:40:37 +01:00
Daniel Stenberg
20eb836f4e wait_socket: wrong use of difftime()
With reversed arguments it would always return a negative value...

Bug: https://github.com/bagder/libssh2/issues/1
2015-03-11 12:16:18 +01:00
Daniel Stenberg
6ada234c62 bump: start working toward 1.5.1 now 2015-03-11 08:21:09 +01:00
Daniel Stenberg
e16f638dca RELEASE-NOTES: 1.5.0 release 2015-03-11 08:07:45 +01:00
Mariusz Ziulek
7d94b69b80 kex: bail out on rubbish in the incoming packet
CVE-2015-1782

Bug: http://www.libssh2.org/adv_20150311.html
2015-03-07 11:57:04 +01:00
Daniel Stenberg
8bb6cf7f95 docs: move INSTALL, AUTHORS, HACKING and TODO to docs/
And with this, cleanup README to be shorter and mention the new source
code home.
2015-03-07 11:42:14 +01:00
Daniel Stenberg
5fcbb168b8 .gitignore: don't ignore INSTALL 2015-03-07 11:32:08 +01:00
Dan Fandrich
d811750645 examples/x11.c: include sys/select.h for improved portability 2015-03-04 22:57:25 +01:00
Daniel Stenberg
cfe94c715e RELEASE-NOTES: synced with a8473c819bc068
In preparation for the upcoming 1.5.0 release.
2015-03-04 09:38:17 +01:00
Guenter Knauf
a8473c819b NetWare build: added some missing exports. 2015-01-08 21:03:17 +01:00
Marc Hoersken
c71889017f knownhost.c: fix use of uninitialized argument variable wrote
Detected by clang scan in	line 1195, column 18.
2014-12-29 18:37:46 +01:00
Marc Hoersken
253d5922f2 examples/x11.c: fix result of operation is garbage or undefined
Fix use of uninitialized structure w_size_bck.
Detected by clang scan in	line 386, column 28.
2014-12-29 18:31:11 +01:00
Marc Hoersken
79d63df12d examples/x11.c: remove dead assigments of some return values
Detected by clang scan in line 212, column 9.
Detected by clang scan in line 222, column 13.
Detected by clang scan in	line 410, column 13.
2014-12-29 18:24:17 +01:00
Marc Hoersken
86552bf2bb examples/x11.c: fix possible memory leak if read fails
Detected by clang scan in line 224, column 21.
2014-12-27 14:00:48 +01:00
Marc Hoersken
477e609a84 examples/x11.c: fix invalid removal of first list element
Fix use of memory after it was being freed.
Detected by clang scan in line 56, column 12.
2014-12-27 13:48:51 +01:00
Marc Hoersken
3e47ca8a32 userauth.c: make sure that sp_len is positive and avoid overflows
... if the pointer subtraction of sp1 - pubkey - 1 resulted in a
negative or larger value than pubkey_len, memchr would fail.

Reported by Coverity CID 89846.
2014-12-26 14:08:35 +01:00
Marc Hoersken
6af0ee567b channel.c: remove logically dead code, host cannot be NULL here
... host cannot be NULL in line 525, because it is always
valid (e.g. at least set to "0.0.0.0") after lines 430 and 431.

Reported by Coverity CID 89807.
2014-12-26 13:51:27 +01:00
Marc Hoersken
c6d99bd3a4 session.c: check return value of session_nonblock during startup
Reported by Coverity CID 89803.
2014-12-26 13:45:59 +01:00
Marc Hoersken
d1eccb487a session.c: check return value of session_nonblock in debug mode
Reported by Coverity CID 89805.
2014-12-26 13:40:42 +01:00
Marc Hoersken
22204c4e2e pem.c: fix mixed line-endings introduced with 8670f5da24 2014-12-26 13:39:18 +01:00
Marc Hoersken
8670f5da24 pem.c: make sure there's a trailing zero and b64data is not NULL
... if there is no base64 data between PEM header and footer.
Reported by Coverity CID 89823.
2014-12-26 13:31:26 +01:00
Marc Hoersken
3835655f09 kex.c: make sure mlist is not set to NULL
... if the currently unsupported LANG methods are called.
Reported by Coverity CID 89834.
2014-12-26 13:20:14 +01:00
Marc Hoersken
dc199ed03a packet.c: i < 256 was always true and i would overflow to 0
Visualize that the 0-termination is intentional, because the array
is later passed to strlen within _libssh2_packet_askv.
2014-12-26 11:21:10 +01:00
Marc Hoersken
8f799f98d9 silence multiple data conversion warnings 2014-12-26 11:05:34 +01:00
Daniel Stenberg
637c90959b agent_connect_unix: make sure there's a trailing zero
... if the path name was too long. Reported by Coverity CID 89801.
2014-12-23 20:05:16 +01:00
Marc Hoersken
8a731d6217 examples on Windows: use native SOCKET-type instead of int
And check return values accordingly.
2014-12-22 17:03:42 +01:00
Marc Hoersken
d85f9a689f userauth.c: improve readability and clarity of for-loops 2014-12-22 16:18:36 +01:00
Daniel Stenberg
031566f9cc calloc: introduce LIBSSH2_CALLOC()
A simple function using LIBSSH2_ALLOC + memset, since this pattern was
used in multiple places and this simplies code in general.
2014-12-22 15:59:21 +01:00
Marc Hoersken
977a3b6a76 libssh2_priv.h: Ignore session, context and format parameters 2014-12-15 01:16:00 +01:00
Marc Hoersken
34dc1d61b4 x11 example: check return value of socket function 2014-12-15 01:10:29 +01:00
Marc Hoersken
be95032e29 examples: fixed mixed line-endings introduced with aedfba25b8 2014-12-15 01:09:13 +01:00
Marc Hoersken
c0bface8a7 wincng.c: explicitly ignore BCrypt*AlgorithmProvider return codes
Fixes VS2012 code analysis warning C6031:
return value ignored: <function> could return unexpected value
2014-12-15 01:00:52 +01:00
Marc Hoersken
f31c9fb221 wincng.c: fix possible invalid memory write access
Fixes VS2012 code analysis warning C6386:
buffer overrun: accessing 'pbOutput', the writable size is
'cbOutput' bytes, but '3' bytes may be written: libssh2 wincng.c 610
2014-12-15 01:00:48 +01:00
Marc Hoersken
f89bed9571 tests on Windows: check for WSAStartup return code
Fixes VS2012 code analysis warning C6031:
return value ignored: <function> could return unexpected value
2014-12-15 01:00:36 +01:00
Marc Hoersken
bc9d735664 wincng.c: fix possible NULL pointer de-reference of bignum
Fixes VS2012 code analysis warning C6011:
dereferencing NULL pointer 'bignum'. libssh2 wincng.c 1567
2014-12-15 00:59:11 +01:00
Marc Hoersken
06ff22f1a6 wincng.c: fix possible use of uninitialized memory
Fixes VS2012 code analysis warning C6001:
using uninitialized memory 'cbDecoded'. libssh2 wincng.c 553
2014-12-15 00:59:09 +01:00
Marc Hoersken
e57f29f8f6 packet.c: fix possible NULL pointer de-reference within listen_state
Fixes VS2012 code analysis warning C6011:
dereferencing NULL pointer 'listen_state->channel'. libssh2 packet.c 221
2014-12-15 00:59:05 +01:00
Marc Hoersken
1c1699545b kex.c: fix possible NULL pointer de-reference with session->kex
Fixes VS2012 code analysis warning C6011:
dereferencing NULL pointer 'session->kex'. libssh2 kex.c 1761
2014-12-15 00:59:03 +01:00
Marc Hoersken
abcc0d370f agent.c: check return code of MapViewOfFile
Fixes VS2012 code analysis warning C6387: 'p+4' may be '0':
this does not adhere to the specification for the function
'memcpy': libssh2 agent.c 330

Fixes VS2012 code analysis warning C6387: 'p' may be '0':
this does not adhere to the specification for the function
'UnmapViewOfFile': libssh2 agent.c 333
2014-12-15 00:59:00 +01:00
Marc Hoersken
977dbb7511 examples on Windows: check for socket return code
Fixes VS2012 code analysis warning C28193:
The variable holds a value that must be examined
2014-12-15 00:58:57 +01:00
Marc Hoersken
aedfba25b8 examples on Windows: check for WSAStartup return code
Fixes VS2012 code analysis warning C6031:
return value ignored: <function> could return unexpected value
2014-12-15 00:58:56 +01:00
Guenter Knauf
19f1402f1d wincng.c: silent some more gcc compiler warnings. 2014-12-11 21:39:47 +01:00
Guenter Knauf
df5c61dbca wincng.c: silent gcc compiler warnings. 2014-12-11 21:35:18 +01:00
Guenter Knauf
1689315fce Watcom build: added support for WinCNG build. 2014-12-08 02:56:34 +01:00
Guenter Knauf
7f7e65c54b build: updated dependencies in makefiles. 2014-12-07 16:16:21 +01:00
Daniel Stenberg
751e0087a8 configure: change LIBS not LDFLAGS when checking for libs
Closes #289

Patch-by: maurerpe
2014-12-04 22:45:30 +01:00
Guenter Knauf
600f26ce6e MinGW build: some more GNUMakefile tweaks.
test/GNUmakefile: added architecture autodetection; added switches to
CFLAGS and RCFLAGS to make sure that the right architecture is used.
Added support to build with WinCNG.
2014-12-03 16:24:35 +01:00
Guenter Knauf
3260beb07a sftpdir.c: added authentication method detection.
Stuff copied over from ssh2.c to make testing a bit easier.
2014-12-03 15:19:32 +01:00
Guenter Knauf
01a6210ab7 NMake build: fixed LIBS settings. 2014-12-01 13:21:50 +01:00
Guenter Knauf
6a3b5487cb NMake build: added support for WinCNG build. 2014-11-30 18:39:57 +01:00
Guenter Knauf
e4ba5fabec MinGW build: some GNUMakefile tweaks.
Added architecture autodetection; added switches to CFLAGS and
RCFLAGS to make sure that the right architecture is used.
Added support to build with WinCNG.
2014-11-30 16:19:01 +01:00
Guenter Knauf
46f017e751 MinGW build: Fixed redefine warnings. 2014-11-30 16:03:58 +01:00
Guenter Knauf
12adbc28b8 Updated copyright year. 2014-11-30 15:48:55 +01:00
Daniel Stenberg
424a27e007 COPYING: bump the copyright year 2014-08-31 00:41:58 +02:00
Dan Fandrich
1e4fb7ee9f docs: fixed a bunch of typos 2014-07-28 23:55:34 +02:00
Dan Fandrich
7b80a188dd docs: added missing libssh2_session_handshake.3 file 2014-07-28 23:54:55 +02:00
Marc Hoersken
9d50d43a83 wincng.c: specify the required libraries for dependencies using MSVC
Initially reported by Bob Kast as "for MS VS builds, specify the
libraries that are required so they don't need to go into all
project files that may use this library". Thanks a lot.
2014-05-19 20:45:14 +02:00
Bob Kast
c355d31ff9 windows build: do not export externals from static library
If you are building a DLL, then you need to explicitly export each
entry point. When building a static library, you should not.

libssh2 was exporting the entry points whether it was building a DLL or a
static library. To elaborate further, if libssh2 was used as a static
library, which was being linked into a DLL, the libssh2 API would be
exported from that separate DLL.
2014-05-19 19:17:30 +02:00
Mikhail Gusarov
18fe507324 Fix typos in manpages 2014-05-19 10:24:58 +02:00
Marc Hoersken
d63e32dd30 wincng.c: Fixed memory leak in case of an error during ASN.1 decoding 2014-05-18 14:58:21 +02:00
Marc Hoersken
c32e82e97b configure: Display individual crypto backends on separate lines
This avoids line-wrapping in between parameters and makes the
error message look like the following:

configure: error: No crypto library found!
Try --with-libssl-prefix=PATH
 or --with-libgcrypt-prefix=PATH
 or --with-wincng on Windows
2014-05-18 12:47:42 +02:00
Bob Kast
7d4b5a8e07 libssh2_priv.h: a 1 bit bit-field should be unsigned
some compilers may not like this
2014-05-18 12:25:56 +02:00
Marc Hoersken
200784c4e7 knownhost.c: Fixed warning that pointer targets differ in signedness 2014-05-18 11:51:19 +02:00
Marc Hoersken
b22b23703c wincng.c: Fixed warning about pointer targets differing in signedness 2014-05-18 11:39:22 +02:00
Marc Hoersken
0e4e14109a tcpip-forward.c: Fixed warning that pointer targets differ in signedness
libssh2_channel_forward_listen_ex uses ints instead of unsigned ints.
2014-05-18 11:35:19 +02:00
Marc Hoersken
5bcc2d4629 misc.c: Fixed warning about mixed declarations and code 2014-05-18 11:15:49 +02:00
Marc Hoersken
33df559967 libgcrypt.h: Fixed warning about pointer targets differing in signedness 2014-05-18 10:57:36 +02:00
Marc Hoersken
26f6d71885 wincng.h: Fixed warning about pointer targets differing in signedness 2014-05-18 10:57:17 +02:00
Marc Hoersken
62c91e2cd4 misc.c: Fixed warning about unused parameter abstract 2014-05-18 10:23:18 +02:00
Marc Hoersken
b9dc6112d7 tcpip-forward.c: Removed unused variables shost, sport and sockopt 2014-05-18 10:16:24 +02:00
Marc Hoersken
106bacdebc wincng.h: Added forward declarations for all WinCNG functions
Initially reported by Bob Kast as "Wincng - define function
prototypes for wincng routines". Thanks a lot.

Also replaced structure definitions with type definitions.
2014-05-18 00:51:31 +02:00
Bob Kast
23dec383f7 libssh2.h: on Windows, a socket is of type SOCKET, not int 2014-05-18 00:25:47 +02:00
Marc Hoersken
fc94046e6e win32: Added WinCNG targets to generated Visual Studio project
Inspired by Bob Kast's reports, this commit enables the compilation
of libssh2 with WinCNG using the generated Visual Studio project files.
This commit adds WinCNG support to parts of the existing Win32 build
infrastructure, until new build systems, like pre-defined VS project
files or CMake files may be added.

This commit and b20bfeb3e519119a48509a1099c06d65aa7da1d7 raise one
question: How to handle build systems, like VS project files, that
need to include all source files regardless of the desired target,
including all supported crypto backends? For now the mentioned commit
added a check for LIBSSH2_OPENSSL to openssl.c and with this commit
the supported crypto backends are hardcoded within Makefile.am.
2014-05-18 00:07:59 +02:00
Marc Hoersken
ee547fe90d libssh2_priv msvc: Removed redundant definition of inline keyword
Initially reported by Bob Kast as "Remove redundant 'inline' define".
Thanks a lot.
2014-05-17 23:47:20 +02:00
Marc Hoersken
a58b0dacb4 wincng: Made data parameter to hash update function constant
Initially reported by Bob Kast as "formal parameter must be const
since it is used in contexts where the actual parameter may be const".
Thanks a lot.
2014-05-17 23:35:11 +02:00
Marc Hoersken
6e710d7fb6 wincng: fix cross-compilation against the w64 mingw-runtime package 2014-04-25 14:20:08 +02:00
Marc Hoersken
b20bfeb3e5 openssl: Check for LIBSSH2_OPENSSL in order to compile with openssl 2014-04-25 13:40:44 +02:00
Marc Hoersken
aba11380a1 wincng: Fixed use of possible uninitialized variable pPaddingInfo
Reported by Bob Kast, thanks a lot.
2014-03-22 23:23:18 +01:00
Marc Hoersken
2c46c4bf95 wincng: Added cast for double to unsigned long conversion 2014-03-22 23:12:59 +01:00
Marc Hoersken
160776d218 wincng: Cleaned up includes and check NTSTATUS using macro
Removed header file combination that is not supported on a real
Windows platform and can only be compiled using MinGW. Replaced
custom NTSTATUS return code checks with BCRYPT_SUCCESS macro.
2014-03-22 23:08:14 +01:00
Daniel Stenberg
ee2d61a48b userauth_hostbased_fromfile: zero assign to avoid uninitialized use
Detected by clang-analyze
2014-03-16 23:09:08 +01:00
Daniel Stenberg
fcb601da7b channel_receive_window_adjust: store windows size always
Avoid it sometimes returning without storing it, leaving calling
functions with unknown content!

Detected by clang-analyzer
2014-03-16 20:02:37 +01:00
Daniel Stenberg
55bae8dd07 publickey_packet_receive: avoid junk in returned pointers
clang-analyzer found this risk it would return a non-initialized pointer
in a success case
2014-03-16 19:44:17 +01:00
Marc Hoersken
4440e05d48 Added Windows Cryptography API: Next Generation based backend 2014-03-16 17:01:16 +01:00
Marc Hoersken
378d0a6676 knownhost.c: fixed that 'key_type_len' may be used uninitialized
../src/knownhost.c: In function 'libssh2_knownhost_readline':
../src/knownhost.c:651:16: warning: 'key_type_len' may be used
uninitialized in this function [-Wmaybe-uninitialized]
             rc = knownhost_add(hosts, hostbuf, NULL,
                ^
../src/knownhost.c:745:12: note: 'key_type_len' was declared here
     size_t key_type_len;
            ^
2014-03-16 16:38:55 +01:00
Marc Hoersken
21cb7bfb36 pem.c: always compile pem.c independently of crypto backend 2014-03-16 16:38:55 +01:00
Peter Stuge
e1a5d1bc77 Fix non-autotools builds: Always define the LIBSSH2_OPENSSL CPP macro
Commit d512b25f69a1b6778881f6b4b5ff9cfc6023be42 introduced a crypto
library abstraction in the autotools build system, to allow us to more
easily support new crypto libraries. In that process it was found that
all other build system which we support are hard-coded to build with
OpenSSL. Commit f5c1a0d98bd51aeb24aca3d49c7c81dcf8bd858d fixes automake
introduced into non-autotools build systems but still overlooked the
CPP macro saying that we are using OpenSSL.

Thanks to Marc Hörsken for identifying this issue and proposing a fix
for win32/{GNUmakefile,config.mk}. This commit uses a slightly different
approach but the end result is the same.
2014-03-16 16:36:13 +01:00
Dan Fandrich
189cf86df0 channel_close: Close the channel even in the case of errors 2014-03-15 02:15:16 +01:00
Dan Fandrich
30e376773a sftp_close_handle: ensure the handle is always closed
Errors are reported on return, but otherwise the close path is
completed as much as possible and the handle is freed on exit.
2014-03-15 00:32:11 +01:00
Alexander Lamaison
38e210af0e knownhost: Restore behaviour of libssh2_knownhost_writeline with short buffer.
Commit 85c6627c changed the behaviour of `libssh2_knownhost_writeline` so that it stopped returning the number of bytes needed when the given buffer was too small.  Also, the function changed such that is might write to part of the buffer before realising it is too small.

This commit restores the original behaviour, whilst keeping the unknown-key-type functionality that 85c6627c.  Instead of writing to the buffer piecemeal, the length of the various parts is calculated up front and the buffer written only if there is enough space.  The calculated necessary size is output in `outlen` regardless of whether the buffer was written to.

The main use-case for the original behaviour that this commit restores is to allow passing in a NULL buffer to get the actual buffer size needed, before calling the function again with the buffer allocated to the exact size required.
2014-03-06 23:34:28 +00:00
Alexander Lamaison
d145e04443 knownhost: Fix DSS keys being detected as unknown.
I missing `else` meant ssh-dss format keys were being re-detected as unknown format.
2014-03-06 23:10:58 +00:00
Dan Fandrich
feab568a7a knownhosts: Abort if the hosts buffer is too small
This could otherwise cause a match on the wrong host
2014-03-06 14:08:56 +01:00
Dan Fandrich
08973a00a1 agent_list_identities: Fixed memory leak on OOM 2014-02-28 22:34:29 +01:00
Dan Fandrich
c00efa5f93 Fixed a few typos 2014-02-24 23:23:13 +01:00
Dan Fandrich
adc5db29e3 userauth: Fixed an attempt to free from stack on error 2014-02-24 23:23:13 +01:00
Dan Fandrich
92d686fe19 Fixed a few memory leaks in error paths 2014-02-24 23:23:13 +01:00
Dan Fandrich
5559ad8fe1 Fixed two potential use-after-frees of the payload buffer
The first might occur if _libssh2_packet_add returns an error, as
fullpacket_state wasn't reset to idle so if it were possible for
fullpacket to be called again, it would return to the same state
handler and re-use the freed p->packet buffer.

The second could occur if decrypt returned an error, as it freed the
packet buffer but did not clear total_num, meaning that freed buffer
could be written into again later.
2014-02-24 23:23:13 +01:00
Alexander Lamaison
88366b5ec2 Fix missing _libssh2_error in _libssh2_channel_write.
In one case, the error code from `_libssh2_transport_read` was being returned from `_libssh2_channel_write` without setting it as the last error by calling `_libssh2_error`.  This commit fixes that.

Found when using a session whose socket had been inadvertently destroyed.  The calling code got confused because via `libssh2_session_last_error` it appeared no error had occurred, despite one being returned from the previous function.
2013-11-28 23:37:05 +00:00
Mark McPherson
61df22c460 openssl: initialise the digest context before calling EVP_DigestInit()
When using the OpenSSL libraries in FIPS mode, the function call
EVP_DigestInit() is actually #defined to FIPS_digestinit().
Unfortunately wheres EVP_DigestInit() initialises the context and then
calls EVP_DigestInit_ex(), this function assumes that the context has
been pre-initialised and crashes when it isn't.

Bug: https://trac.libssh2.org/ticket/279

Fixes #279
2013-11-21 11:35:12 +01:00
Marc Hörsken
d808080daf .gitignore: Ignore files like src/libssh2_config.h.in~ 2013-11-20 14:24:34 +01:00
Peter Stuge
f5c1a0d98b Move automake conditionals added by commit d512b25f out of Makefile.inc
Commit d512b25f69a1b6778881f6b4b5ff9cfc6023be42 added automake
conditionals to Makefile.inc but since Makefile.inc is included
from Makefile for all other build systems that does not work.

This commit instead adds Makefile.OpenSSL.inc and Makefile.libgcrypt.inc
and moves the automake conditional to its proper place, src/Makefile.am.

The automake conditional includes the correct Makefile.$name.inc per
the crypto library selection/detection done by configure.

All non-autotools build system files in libssh2 are hardcoded to use
OpenSSL and do not get a conditional but at least there is some reuse
because they can all include the new Makefile.OpenSSL.inc.
2013-11-13 02:37:06 +01:00
Salvador Fandino
85a827d1bc Set default window size to 2MB
The default channel window size used until now was 256KB. This value is
too small and results on a bottleneck on real-life networks where
round-trip delays can easily reach 300ms.

The issue was not visible because the configured channel window size
was being ignored and a hard-coded value of ~22MB being used instead,
but that was fixed on a previous commit.

This patch just changes the default window size
(LIBSSH2_CHANNEL_WINDOW_DEFAULT) to 2MB. It is the same value used by
OpenSSH and in our opinion represents a good compromise between memory
used and transfer speed.

Performance tests were run to determine the optimum value. The details
and related discussion are available from the following thread on the
libssh2 mailing-list:

http://www.libssh2.org/mail/libssh2-devel-archive-2013-10/0018.shtml
http://article.gmane.org/gmane.network.ssh.libssh2.devel/6543

An excerpt follows:

"I have been running some transfer test and measuring their speed.

My setup was composed of a quad-core Linux machine running Ubuntu 13.10
x86_64 with a LXC container inside. The data transfers were performed
from the container to the host (never crossing through a physical
network device).

Network delays were simulated using the tc tool. And ping was used to
verify that they worked as intended during the tests.

The operation performed was the equivalent to the following ssh command:

  $ ssh container "dd bs=16K count=8K if=/dev/zero" >/dev/null

Though, establishment and closing of the SSH connection was excluded
from the timings.

I run the tests several times transferring files of sizes up to 128MB
and the results were consistent between runs.

The results corresponding to the 128MB transfer are available here:

https://docs.google.com/spreadsheet/ccc?key=0Ao1yRmX6PQQzdG5wSFlrZl9HRWNET3ZyN0hnaGo5ZFE&usp=sharing

It clearly shows that 256KB is too small as the default window size.
Moving to a 512MB generates a great improvement and after the 1MB mark
the returns rapidly diminish. Other factors (TCP window size, probably)
become more limiting than the channel window size

For comparison I also performed the same transfers using OpenSSH. Its
speed is usually on par with that of libssh2 using a window size of 1MB
(even if it uses a 2MB window, maybe it is less aggressive sending the
window adjust msgs)."

Signed-off-by: Salvador Fandino <sfandino@yahoo.com>
2013-10-27 13:50:20 +01:00
Salvador
1b3307dda0 _libssh2_channel_read: Honour window_size_initial
_libssh2_channel_read was using an arbitrary hard-coded limit to trigger
the window adjusting code. The adjustment used was also hard-coded and
arbitrary, 15MB actually, which would limit the usability of libssh2 on
systems with little RAM.

This patch, uses the window_size parameter passed to
libssh2_channel_open_ex (stored as remote.window_size_initial) plus the
buflen as the base for the trigger and the adjustment calculation.

The memory usage when using the default window size is reduced from 22MB
to 256KB per channel (actually, if compression is used, these numbers
should be incremented by ~50% to account for the errors between the
decompressed packet sizes and the predicted sizes).

My tests indicate that this change does not impact the performance of
transfers across localhost or a LAN, being it on par with that of
OpenSSH. On the other hand, it will probably slow down transfers on
networks with high bandwidth*delay when the default window size
(LIBSSH2_CHANNEL_WINDOW_DEFAULT=256KB) is used.

Signed-off-by: Salvador Fandino <sfandino@yahoo.com>
2013-10-27 13:49:33 +01:00
Salvador Fandino
85c6627c86 knownhosts: handle unknown key types
Store but don't use keys of unsupported types on the known_hosts file.

Currently, when libssh2 parses a known_host file containing keys of some
type it doesn't natively support, it stops reading the file and returns
an error.

That means, that the known_host file can not be safely shared with other
software supporting other key types (i.e. OpenSSH).

This patch adds support for handling keys of unknown type. It can read
and write them, even if they are never going to be matched.

At the source level the patch does the following things:

- add a new unknown key type LIBSSH2_KNOWNHOST_KEY_UNKNOWN

- add a new slot (key_type_name) on the known_host struct that is
used to store the key type in ascii form when it is not supported

- parse correctly known_hosts entries with unknown key types and
populate the key_type_name slot

- print correctly known_hosts entries of unknown type

- when checking a host key ignore keys that do not match the key

Fixes #276
2013-10-27 10:57:31 +01:00
Daniel Stenberg
c49cc8411f windows build: fix build errors
Fixes various link errors with VS2010

Reported-by: "kdekker"
Fixes #272
2013-10-16 23:23:26 +02:00
Daniel Stenberg
fa15fded72 man page: add missing function argument
for libssh2_userauth_publickey_fromfile_ex()

Reported-by: "pastey"

Fixes #262
2013-10-16 23:19:14 +02:00
Salvador
c2329aa09e Fix zlib deflate usage
Deflate may return Z_OK even when not all data has been compressed
if the output buffer becomes full.

In practice this is very unlikely to happen because the output buffer
size is always some KBs larger than the size of the data passed for
compression from the upper layers and I think that zlib never expands
the data so much, even on the worst cases.

Anyway, this patch plays on the safe side checking that the output
buffer is not exhausted.

Signed-off-by: Salvador <sfandino@yahoo.com>
2013-10-16 23:06:47 +02:00
Salvador
94077f7a58 comp_method_zlib_decomp: Improve buffer growing algorithm
The old algorithm was O(N^2), causing lots and lots of reallocations
when highly compressed data was transferred.

This patch implements a simpler one that just doubles the buffer size
everytime it is exhausted. It results in O(N) complexity.

Also a smaller inflate ratio is used to calculate the initial size (x4).

Signed-off-by: Salvador <sfandino@yahoo.com>
2013-10-16 23:05:40 +02:00
Salvador
55a8b10ad9 Fix zlib usage
Data may remain in zlib internal buffers when inflate() returns Z_OK
and avail_out == 0. In that case, inflate has to be called again.

Also, once all the data has been inflated, it returns Z_BUF_ERROR to
signal that the input buffer has been exhausted.

Until now, the way to detect that a packet payload had been completely
decompressed was to check that no data remained on the input buffer
but that didn't account for the case where data remained on the internal
zlib buffers.

That resulted in packets not being completely decompressed and the
missing data reappearing on the next packet, though the bug was masked
by the buffer allocation algorithm most of the time and only manifested
when transferring highly compressible data.

This patch fixes the zlib usage.

Signed-off-by: Salvador <sfandino@yahoo.com>
2013-10-16 22:55:29 +02:00
Salvador
27f9ac2549 _libssh2_channel_read: fix data drop when out of window
After filling the read buffer with data from the read queue, when the
window size was too small, "libssh2_channel_receive_window_adjust" was
called to increase it. In non-blocking mode that function could return
EAGAIN and, in that case, the EAGAIN was propagated upwards and the data
already read on the buffer lost.

The function was also moving between the two read states
"libssh2_NB_state_idle" and "libssh2_NB_state_created" both of which
behave in the same way (excepting a debug statment).

This commit modifies "_libssh2_channel_read" so that the
"libssh2_channel_receive_window_adjust" call is performed first (when
required) and if everything goes well, then it reads the data from the
queued packets into the read buffer.

It also removes the useless "libssh2_NB_state_created" read state.

Some rotted comments have also been updated.

Signed-off-by: Salvador <sfandino@yahoo.com>
2013-10-16 22:53:36 +02:00
Salvador Fandino
cdeef54967 window_size: redid window handling for flow control reasons
Until now, the window size (channel->remote.window_size) was being
updated just after receiving the packet from the transport layer.

That behaviour is wrong because the channel queue may grow uncontrolled
when data arrives from the network faster that the upper layer consumes
it.

This patch adds a new counter, read_avail, which keeps a count of the
bytes available from the packet queue for reading. Also, now the window
size is adjusted when the data is actually read by an upper layer.

That way, if the upper layer stops reading data, the window will
eventually fill and the remote host will stop sending data. When the
upper layers reads enough data, a window adjust packet is delivered and
the transfer resumes.

The read_avail counter is used to detect the situation when the remote
server tries to send data surpassing the window size. In that case, the
extra data is discarded.

Signed-off-by: Salvador <sfandino@yahoo.com>
2013-10-16 22:52:12 +02:00
Peter Stuge
42aefdba79 configure.ac: Call zlib zlib and not libz in text but keep option names 2013-09-15 21:13:27 +02:00
Peter Stuge
d41f5e40aa configure.ac: Reorder --with-* options in --help output 2013-09-15 21:13:03 +02:00
Peter Stuge
2df6cd6606 configure.ac: Rework crypto library detection
This further simplifies adding new crypto libraries.
2013-09-15 21:11:39 +02:00
Peter Stuge
d512b25f69 Clean up crypto library abstraction in build system and source code
libssh2 used to explicitly check for libgcrypt and default to OpenSSL.

Now all possible crypto libraries are checked for explicitly, making
the addition of further crypto libraries both simpler and cleaner.
2013-09-15 20:56:54 +02:00
Peter Stuge
b4f71fd25a configure.ac: Add zlib to Requires.private in libssh2.pc if using zlib 2013-09-15 20:36:58 +02:00
Peter Stuge
a5bf809b80 Revert "Added Windows Cryptography API: Next Generation based backend"
This reverts commit d385230e15715e67796f16f3e65fd899f21a638b.
2013-09-15 13:32:38 +02:00
Leif Salomonsson
2157e178a3 sftp_statvfs: fix for servers not supporting statfvs extension
Fixes issue arising when server does not support statfvs and or fstatvfs
extensions. sftp_statvfs() and sftp_fstatvfs() after this patch will
handle the case when SSH_FXP_STATUS is returned from server.
2013-09-07 23:11:54 +02:00
Marc Hoersken
d385230e15 Added Windows Cryptography API: Next Generation based backend 2013-09-07 22:38:14 +02:00
Kamil Dudka
61e40a32ff partially revert "window_size: explicit adjustments only"
This partially reverts commit 03ca9020756a4e16f0294e5b35e9826ee6af2364
in order to fix extreme slowdown when uploading to localhost via SFTP.

I was able to repeat the issue on RHEL-7 on localhost only.  It did not
occur when uploading via network and it did not occur on a RHEL-6 box
with the same version of libssh2.

The problem was that sftp_read() used a read-ahead logic to figure out
the window_size, but sftp_packet_read() called indirectly from
sftp_write() did not use any read-ahead logic.
2013-09-07 22:30:34 +02:00
Daniel Stenberg
e6c46cc249 _libssh2_channel_write: client spins on write when window full
When there's no window to "write to", there's no point in waiting for
the socket to become writable since it most likely just will continue to
be.

Patch-by: ncm
Fixes #258
2013-09-07 13:41:14 +02:00
Daniel Stenberg
9f1b89e99b _libssh2_channel_forward_cancel: avoid memory leaks on error
Fixes #257
2013-09-07 13:37:59 +02:00
Daniel Stenberg
8da30ea4d4 _libssh2_packet_add: avoid using uninitialized memory
In _libssh2_packet_add, called by _libssh2_packet_read, a call to
_libssh2_packet_send that is supposed to send a one-byte message
SSH_MSG_REQUEST_FAILURE would send an uninitialized byte upon re-entry
if its call to _send returns _EAGAIN.

Fixes #259
2013-09-07 13:36:51 +02:00
Daniel Stenberg
ff6c01e959 _libssh2_channel_forward_cancel: accessed struct after free
... and the assignment was pointless anyway since the struct was about
to be freed. Bug introduced in dde2b094.

Fixes #268
2013-09-05 19:57:47 +02:00
Marc Hoersken
c910cd382d Fixed compilation using mingw-w64 2013-06-02 19:15:58 +02:00
Marc Hoersken
edd42304a2 knownhost.c: use LIBSSH2_FREE macro instead of free
Use LIBSSH2_FREE instead of free since
_libssh2_base64_encode uses LIBSSH2_ALLOC
2013-05-19 00:17:00 +02:00
Matthias Kerestesch
1ad20ac7d3 libssh2_agent_init: init ->fd to LIBSSH2_INVALID_SOCKET
... previously it was left at 0 which is a valid file descriptor!

Bug: https://trac.libssh2.org/ticket/265

Fixes #265
2013-05-18 23:03:18 +02:00
Daniel Stenberg
d7f9cd57c5 userauth_password: pass on the underlying error code
_libssh2_packet_requirev() may return different errors and we pass that
to the parent instead of rewriting it.

Bug: http://libssh2.org/mail/libssh2-devel-archive-2013-04/0029.shtml
Reported by: Cosmin
2013-05-18 23:03:18 +02:00
Marc Hoersken
16ef83dd81 libcrypt.c: Fix typo in _libssh2_rsa_sha1_sign() parameter type 2013-05-09 22:13:14 +02:00
Kamil Dudka
951904418b configure.ac: replace AM_CONFIG_HEADER with AC_CONFIG_HEADERS
Reported by: Quintus
Bug: https://trac.libssh2.org/ticket/261
2013-05-04 22:52:41 +02:00
Guenter Knauf
80e5e20b00 Fixed copyright string for NetWare build. 2013-04-12 18:00:29 +02:00
Richard W.M. Jones
6e0d757f24 sftp: Add support for fsync (OpenSSH extension).
The new libssh2_sftp_fsync API causes data and metadata in the
currently open file to be committed to disk at the server.

This is an OpenSSH extension to the SFTP protocol.  See:

https://bugzilla.mindrot.org/show_bug.cgi?id=1798
2013-04-09 16:25:54 +02:00
Richard W.M. Jones
a12f3ffab5 sftp: statvfs: Along error path, reset the correct 'state' variable. 2013-04-08 22:11:15 +02:00
Richard W.M. Jones
486bb37621 sftp: seek: Don't flush buffers on same offset
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2013-03-27 15:46:51 +01:00
Guenter Knauf
fe347a702f Updated dependency libs. 2013-02-09 01:38:53 +01:00
Guenter Knauf
07615610ba Fixed tool macro names. 2012-12-04 11:52:08 +01:00
Seth Willits
5aa7b29758 compiler warnings: typecast strlen in macros
... in macro parameters to avoid compiler warnings about lost precision.

Several macros in libssh2.h call strlen and pass the result directly to
unsigned int parameters of other functions, which warns about precision
loss because strlen returns size_t which is unsigned long on at least
some platforms (such as OS X). The fix is to simply typecast the
strlen() result to unsigned int.
2012-11-29 20:30:04 +01:00
Daniel Stenberg
a67ff056e6 libssh2.h: bump version to 1.4.4-DEV 2012-11-27 23:03:45 +01:00
Daniel Stenberg
f1cfa55b60 RELEASE-NOTES: fixed for 1.4.3 2012-11-27 22:44:09 +01:00
Daniel Stenberg
437a3b75ec sftp_read: return error if a too large package arrives 2012-11-20 08:23:39 +01:00
Peter Stuge
a3ad635db4 Only define _libssh2_dsa_*() functions when building with DSA support 2012-11-13 00:11:47 +01:00
Guenter Knauf
e5c5408564 Added .def file to output. 2012-11-08 18:57:14 +01:00
Kamil Dudka
fe8f3deb48 libssh2_hostkey_hash.3: update the description of return value
The function returns NULL also if the hash algorithm is not available.
2012-11-01 15:04:07 +01:00
Guenter Knauf
d49b8f303a Fixed mode acciedently committed. 2012-10-24 03:41:10 +02:00
Guenter Knauf
6f8777505f Ignore generated file. 2012-10-24 03:29:50 +02:00
Guenter Knauf
52b8da7dfa Added hack to make use of Makefile.inc.
This should avoid further maintainance of the objects list.
2012-10-24 03:22:07 +02:00
Guenter Knauf
de7b5d3bc0 Fixed MSVC NMakefile.
Added missing source files; added resource for DLL.
2012-10-24 02:37:55 +02:00
Kamil Dudka
b31e35aba6 examples: use stderr for messages, stdout for data
Reported by: Karel Srot
Bug: https://bugzilla.redhat.com/867462
2012-10-22 13:39:58 +02:00
Kamil Dudka
e2bb780d77 openssl: do not leak memory when handling errors
,.. in aes_ctr_init().  Detected by Coverity.
2012-10-08 14:30:40 +02:00
Kamil Dudka
a8cfc708c5 channel: fix possible NULL dereference
... in libssh2_channel_get_exit_signal().  Detected by Coverity.
2012-10-08 14:19:23 +02:00
Kamil Dudka
9f6fd5af82 Revert "aes: the init function fails when OpenSSL has AES support"
This partially reverts commit f4f2298ef3635acd031cc2ee0e71026cdcda5864.

We need to use the EVP_aes_???_ctr() functions in FIPS mode.
2012-09-17 09:48:07 +02:00
Kamil Dudka
5d567faecc crypt: use hard-wired cipher block sizes consistently 2012-09-17 09:48:07 +02:00
Kamil Dudka
bfbb5a4dc7 openssl: do not ignore failure of EVP_CipherInit() 2012-09-17 09:48:07 +02:00
Kamil Dudka
43b730ce56 kex: do not ignore failure of libssh2_md5_init()
The MD5 algorithm is disabled when running in FIPS mode.
2012-09-17 09:48:05 +02:00
Peter Krempa
6af85b6053 known_hosts: Fail when parsing unknown keys in known_hosts file.
libssh2_knownhost_readfile() silently ignored problems when reading keys
in unsupported formats from the known hosts file. When the file is
written again from the internal structures of libssh2 it gets truntcated
to the point where the first unknown key was located.

 * src/knownhost.c:libssh2_knownhost_readfile() - return error if key
                                                  parsing fails
2012-08-21 20:27:28 +02:00
Daniel Stenberg
05641218bc AUTHORS: synced with 42fec44c8a4
31 recent authors added
2012-08-19 23:34:53 +02:00
Dave Hayden
42fec44c8a compression: add support for zlib@openssh.com
Add a "use_in_auth" flag to the LIBSSH2_COMP_METHOD struct and a
separate "zlib@openssh.com" method, along with checking session->state
for LIBSSH2_STATE_AUTHENTICATED. Appears to work on the OpenSSH servers
I've tried against, and it should work as before with normal zlib
compression.
2012-08-19 13:47:50 +02:00
Dmitry Smirnov
e470738a0c configure: gcrypt doesn't come with pkg-config support
... so use plain old -lgcrypt to the linker to link with it.

Fixes #225
2012-08-13 23:35:50 +02:00
Daniel Stenberg
62cc59cd06 sftp_read: Value stored to 'next' is never read
Detected by clang-analyzer
2012-08-08 15:18:43 +02:00
Daniel Stenberg
1abf2057de publickey_init: errors are negative, fix check
Detected by clang-analyzer.
2012-08-08 15:15:30 +02:00
Maxime Larocque
6c27922ac1 session_free: wrong variable used for keeping state
If libssh2_session_free is called without the channel being freed
previously by libssh2_channel_free a memory leak could occur.

A mismatch of states variables in session_free() prevent the call to
libssh2_channel_free function. session->state member is used instead of
session->free_state.

It causes a leak of around 600 bytes on every connection on my systems
(Linux, x64 and PPC).

(Debugging done under contract for Accedian Networks)

Fixes #246
2012-07-25 01:08:03 +02:00
Guenter Knauf
112845df0b Small NetWare makefile tweak. 2012-06-29 17:20:56 +02:00
Guenter Knauf
499b22ca36 Some small Win32 makefile fixes. 2012-06-20 18:08:01 +02:00
Daniel Stenberg
6403519fcf libssh2_userauth_publickey_fromfile_ex.3: mention publickey == NULL 2012-06-19 22:08:45 +02:00
Daniel Stenberg
6f8dd9baff comp_method_zlib_decomp: handle Z_BUF_ERROR when inflating
When using libssh2 to perform an SFTP file transfer from the "JSCAPE MFT
Server" (http://www.jscape.com) the transfer failed. The default JSCAPE
configuration is to enforce zlib compression on SSH2 sessions so the
session was compressed. The relevant part of the debug trace contained:

 [libssh2] 1.052750 Transport: unhandled zlib error -5
 [libssh2] 1.052750 Failure Event: -29 - decompression failure

The trace comes from comp_method_zlib_decomp() in comp.c. The "unhandled
zlib error -5" is the status returned from the zlib function
inflate(). The -5 status corresponds to "Z_BUF_ERROR".

The inflate() function takes a pointer to a z_stream structure and
"inflates" (decompresses) as much as it can. The relevant fields of the
z_stream structure are:

  next_in - pointer to the input buffer containing compressed data
  avail_in - the number of bytes available at next_in
  next_out - pointer to the output buffer to be filled with uncompressed
             data
  avail_out - how much space available at next_out

To decompress data you set up a z_stream struct with the relevant fields
filled in and pass it to inflate(). On return the fields will have been
updated so next_in and avail_in show how much compressed data is yet to
be processed and next_out and avail_out show how much space is left in
the output buffer.

If the supplied output buffer is too small then on return there will be
compressed data yet to be processed (avail_in != 0) and inflate() will
return Z_OK. In this case the output buffer must be grown, avail_out
updated and inflate() called again.

If the supplied output buffer was big enough then on return the
compressed data will have been exhausted (avail_in == 0) and inflate()
will return Z_OK, so the data has all been uncompressed.

There is a corner case where inflate() makes no progress. That is, there
may be unprocessed compressed data and space available in the output
buffer and yet the function does nothing. In this case inflate() will
return Z_BUF_ERROR. From the zlib documentation and the source code it
is not clear under what circumstances this happens. It could be that it
needs to write multiple bytes (all in one go) from its internal state to
the output buffer before processing the next chunk of input but but
can't because there is not enough space (though my guesses as to the
cause are not really relevant). Recovery from Z_BUF_ERROR is pretty
simple - just grow the output buffer, update avail_out and call
inflate() again.

The comp_method_zlib_decomp() function does not handle the case when
inflate() returns Z_BUF_ERROR. It treats it as a non-recoverable error
and basically aborts the session.

Fixes #240
2012-06-14 16:11:48 +02:00
Guenter Knauf
a1c0d97ff9 MinGW makefile tweaks.
Use GNU tools when compiling on Linux.
Fixed dist and dev targets.
2012-06-12 01:03:14 +02:00
Guenter Knauf
5c065bf1ff NetWare makefile tweaks.
Changed to use Windows commandline tools instead of
GNU tools when compiling on Windows. Fixed dist and
dev targets. Enabled nlmconv error for unresolved
symbols.
2012-06-12 00:34:18 +02:00
Daniel Stenberg
5237177daf Revert "config.rpath: generated file, no need to keep in git"
This reverts commit 1ac7bd09cc685755577fb2c8829adcd081e7ab3c.

This file still used by lib/*m4 functions so we need to keep the file
around.
2012-06-11 14:52:31 +02:00
Daniel Stenberg
bd627d38a1 BINDINGS: added PySsh2, a Python-ctypes binding 2012-06-09 00:14:17 +02:00
Guenter Knauf
c55b0b0425 Fixed MinGW debug build. 2012-06-08 08:03:24 +02:00
Daniel Stenberg
38efbe8243 BINDINGS: Added the Cocoa/Objective-C one
... and sorted the bindings after the languages, alphabetically

Reported by: Mike Abdullah
2012-06-05 15:43:50 +02:00
Daniel Stenberg
34ecc09a3c BINDINGS: document the bindings we know of 2012-06-05 11:40:51 +02:00
Guenter Knauf
d6cf1c7df0 Fixed LIBSSH2_INT64_T_FORMAT macro.
Usually a format macro should hold the whole format, otherwise
it should be named a prefix. Also fixed usage of this macro in
scp.c for a signed var where it was used as prefix for unsigned.
2012-06-04 22:54:25 +02:00
Guenter Knauf
a40c160cff Removed obsolete define from makefiles. 2012-06-04 17:01:27 +02:00
Guenter Knauf
29e256e817 Renamed NetWare makefiles. 2012-06-04 15:27:02 +02:00
Guenter Knauf
137342a41d Renamed NetWare makefiles. 2012-06-04 15:24:39 +02:00
Guenter Knauf
79a7ca3085 Synced MinGW makefiles with 56c64a6..39e438f.
Also synced MinGW test makefile with b092696..f8cb874.
2012-06-04 15:17:22 +02:00
Peter Stuge
50e37bdadc Revert "sftp: Don't send attrs.permissions on read-only SSH_FXP_OPEN"
This reverts commit 04e79e0c798674a0796be8a55f63dd92e6877790.
2012-05-30 17:50:37 +02:00
Peter Stuge
04e79e0c79 sftp: Don't send attrs.permissions on read-only SSH_FXP_OPEN
This works around a protocol violation in the ProFTPD 1.3.4 mod_sftp
server, as reported by Will Cosgrove in:

http://libssh2.org/mail/libssh2-devel-archive-2012-05/0079.shtml

Based on a suggested fix by TJ Saunders in:

http://libssh2.org/mail/libssh2-devel-archive-2012-05/0104.shtml
2012-05-30 15:29:25 +02:00
Guenter Knauf
9a36065b52 Try to detect OpenSSL build type automatically.
Also fixed recently added libgdi32 linkage which is only
required when OpenSSL libs are linked statically.
2012-05-28 12:53:15 +02:00
Daniel Stenberg
1ac7bd09cc config.rpath: generated file, no need to keep in git 2012-05-25 09:07:18 +02:00
Guenter Knauf
9a7311ba57 Updated dependency libary versions. 2012-05-22 04:10:52 +02:00
Daniel Stenberg
e07b11b7df 1.4.3: towards the future 2012-05-18 23:44:07 +02:00
Daniel Stenberg
e885300b18 RELEASE-NOTES: synced with 92a9f952794 2012-05-18 23:30:04 +02:00
Alexander Lamaison
92a9f95279 win32/libssh2_config.h: Remove hardcoded #define LIBSSH2_HAVE_ZLIB.
Rationale: Everything else in this file states a fact about the win32
platform that is unconditional for that platform.  There is nothing
unconditional about the presence of zlib.  It is neither included with
Windows nor with the platform SDK.  Therefore, this is not an appropriate
place to assert its presence.  Especially as, once asserted, it cannot be
overridden using a compiler flag.

In contrast, if it is omitted, then it can easily be reasserted by adding
a compiler flag defining LIBSSH2_HAVE_ZLIB.
2012-05-15 17:32:06 +01:00
Daniel Stenberg
e91d4c9790 RELEASE-NOTES: synced with 69a3354467c 2012-05-14 22:49:53 +02:00
Daniel Stenberg
69a3354467 _libssh2_packet_add: SSH_MSG_CHANNEL_REQUEST default to want_reply
RFC4254 says the default 'want_reply' is TRUE but the code defaulted to
FALSE. Now changed.

Fixes #233
2012-05-14 22:42:42 +02:00
Daniel Stenberg
3ede6e280e gettimeofday: no need for a replacement under cygwin
Fixes #224
2012-05-14 22:32:36 +02:00
Alexander Lamaison
b583311a93 Prevent sftp_packet_read accessing freed memory.
sftp_packet_add takes ownership of the packet passed to it and (now that we
handle zombies) might free the packet.  sftp_packet_read uses the packet type
byte as its return code but by this point sftp_packet_add might have freed
it.  This change fixes the problem by caching the packet type before calling
sftp_packet_add.

I don't understand why sftp_packet_read uses the packet type as its return
code.  A future change might get rid of this entirely.
2012-05-13 15:56:54 +01:00
Daniel Stenberg
27ac5aa40d sftp_packet_flush: flush zombies too
As this function is called when the SFTP session is closed, it needs to
also kill all zombies left in the SFTP session to avoid leaking memory
just in case some zombie would still be in there.
2012-05-12 22:42:40 +02:00
Daniel Stenberg
a123051200 sftp_packetlist_flush: zombies must not have responses already
When flushing the packetlist, we must only add the request as a zombie
if no response has already been received. Otherwise we could wrongly
make it a zombie even though the response was already received and then
we'd get a zombie stuck there "forever"...
2012-05-12 22:37:20 +02:00
Daniel Stenberg
62901253a4 sftp_read: on EOF remove packet before flush
Since the sftp_packetlist_flush() function will move all the existing
FXP_READ requests in this handle to the zombie list we must first remove
this just received packet as it is clearly not a zombie.
2012-05-10 23:11:07 +02:00
Daniel Stenberg
7c5ee0fa66 sftp_packet_require: sftp_packet_read() returning 0 is not an error
Exactly as the comment in the code said, checking the return code from
sftp_packet_read() with <= was wrong and it should be < 0. With the new
filtering on incoming packets that are "zombies" we can now see this
getting zero returned.
2012-05-10 23:09:37 +02:00
Daniel Stenberg
1e15075a8e sftp_packetlist_flush: only make it zombie if it was sent
The list of outgoing packets may also contain packets that never were
sent off and we better not make them zombies too.
2012-05-10 23:08:23 +02:00
Alexander Lamaison
ad63fc2df6 Mark outstanding read requests after EOF as zombies.
In order to be fast, sftp_read sends many read requests at once.  With a small
file, this can mean that when EOF is received back, many of these requests are
still outstanding.  Responses arriving after we close the file and abandon the
file handle are queued in the SFTP packet queue and never collected.  This
causes transfer speed to drop as a progressively longer queue must be searched
for every packet.

This change introduces a zombie request-ID list in the SFTP session that is
used to recognise these outstanding requests and prevent them being added to
the queue.
2012-05-10 19:35:25 +02:00
Rafael Kitover
d46185eaa5 Update win32/GNUmakefile to use OpenSSL 1.0.1a
libcrypto on win32 now depends on gdi32.dll, so move the OpenSSL LDLIBS
block to before the compiler definitions, so that libcrypto gets added
first, and then add -lgdi32 into the following common LDLIBS for gcc.
2012-04-23 20:04:41 +02:00
Guenter Knauf
9c4b380dd6 Changed 'Requires' to 'Requires.private'.
Only static builds need to link against the crypto libs.
2012-04-23 12:33:08 +02:00
Guenter Knauf
e887a8bd0f Fixed 'Requires:' names.
The 'Requires:' line lists the names of the .pc files.
2012-04-23 01:11:22 +02:00
Guenter Knauf
04692445d4 Added 'Requires:' line to libssh2.pc.
This is necessary so that other libs which lookup libssh2 info
via pkg-config can add the right crypto lib dependencies.
2012-04-23 00:35:03 +02:00
Guenter Knauf
a955f8428b Updated dependency lib versions. 2012-04-20 13:50:06 +02:00
Peter Stuge
ededdfa9c2 configure.ac: Add option to disable build of the example applications
Examples are built by default. Any of the following options on the
configure command line will skip building them:

  --disable-examples-build
  --enable-examples-build=no
  --enable-examples-build=false
2012-04-18 16:35:05 +02:00
Peter Stuge
11f9dce3d7 userauth.c: fread() from public key file to correctly detect any errors
If the filename parameter for file_read_publickey() was the name of a
directory instead of a file then libssh2 would spin trying to fgetc()
from the FILE * for the opened directory when trying to determine the
length of the encoded public key, since fgetc() can't report errors.

Use fread() instead to correctly detect this error condition along
with many others.

This fixes the problem reported in
http://www.libssh2.org/mail/libssh2-devel-archive-2012-04/0021.shtml

Reported-by: Oleksiy Zagorskyi <zalex_ua@i.ua>
2012-04-18 12:23:04 +02:00
Peter Stuge
6bbebcf36c Return LIBSSH2_ERROR_SOCKET_DISCONNECT on EOF when reading banner 2012-04-18 12:23:04 +02:00
Guenter Knauf
7a87bba02a Fixed copyright year. 2012-04-17 17:29:49 +02:00
Guenter Knauf
c8374cdc10 Updated dependency lib versions in static makefiles. 2012-04-12 22:01:45 +02:00
Daniel Stenberg
9b2bed22fc version: bump to 1.4.2
We're on the 1.4.2 track now (at least)
2012-04-06 15:28:18 +02:00
Daniel Stenberg
c8cc30c996 RELEASE-NOTES: updated for 1.4.1 release 2012-04-04 22:43:11 +02:00
Daniel Stenberg
acd9bd6104 always do "forced" window updates
When calling _libssh2_channel_receive_window_adjust() internally, we now
always use the 'force' option to prevent libssh2 to avoid sending the
update if the update isn't big enough.

It isn't fully analyzed but we have seen corner cases which made a
necessary window update not get send due to this and then the other side
doesn't send data our side then sits waiting for forever.
2012-04-03 22:36:19 +02:00
Daniel Stenberg
2ea40e63e8 channel_read: force window adjusts!
if there's not enough room to receive the data that's being requested,
the window adjustment needs to be sent to the remote and thus the force
option has to be used. _libssh2_channel_receive_window_adjust() would
otherwise "queue" small window adjustments for a later packet but that
is really terribly for the small buffer read that for example is the
final little piece of a very large file as then there is no logical next
packet!

Reported by: Armen Babakhanian
Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0130.shtml
2012-03-19 22:34:04 +01:00
Paul Howarth
f4f2298ef3 aes: the init function fails when OpenSSL has AES support
The internal init function only worked fine when the configure script
didn't detect the OpenSSL AES_CTR function!

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0111.shtml
Reported by: Paul Howarth
2012-03-18 15:24:35 +01:00
Matthew Booth
cc4f9d5679 transport_send: Finish in-progress key exchange before sending data
_libssh2_channel_write() first reads outstanding packets before writing
new data. If it reads a key exchange request, it will immediately start
key re-exchange, which will require sending a response. If the output
socket is full, this will result in a return from
_libssh2_transport_read() of LIBSSH2_ERROR_EAGAIN. In order not to block
a write because there is no data to read, this error is explicitly
ignored and the code continues marshalling a packet for sending. When it
is sent, the remote end immediately drops the connection because it was
expecting a continuation of the key exchange, but got a data packet.

This change adds the same check for key exchange to
_libssh2_transport_send() that is in _libssh2_transport_read(). This
ensures that key exchange is completed before any data packet is sent.
2012-03-16 16:40:04 +01:00
Daniel Stenberg
fed0759720 channel_write: acknowledge transport errors
When draining data off the socket with _libssh2_transport_read() (which
in turn has to be done so that we can be sure to have read any possible
window-increasing packets), this code previously ignored errors which
could lead to nasty loops. Now all error codes except EAGAIN will cause
the error to be returned at once.

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0068.shtml
Reported by: Matthew Booth
2012-03-15 13:03:08 +01:00
Steven Dake
a46ef85a56 In examples/x11.c, Make sure sizeof passed to read operation is correct
sizeof(buf) expands to 8 or 4 (since its a pointer).  This variable may
have been static in the past, leading to this error.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-13 22:19:54 +01:00
Steven Dake
626f91da07 Fix suspicious sizeof usage in examples/x11.c
In the x11 example, sizeof(buf) = 8UL (on x86_64), when this should
probably represent the buffer size available.  I am not sure how to
test that this change is actually correct, however.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-13 22:19:18 +01:00
Daniel Stenberg
bf097e37b0 sftp_packet_read: follow-up fix for EAGAIN/window adjust
The commit in 7194a9bd7ba45 wasn't complete. This change makes sure
variables are initialized properly before used in the EAGAIN and window
adjust cases.
2012-03-13 22:02:14 +01:00
Daniel Stenberg
a1c996cef1 sftp_packet_add: use named error code instead of number 2012-03-13 22:01:33 +01:00
Daniel Stenberg
8fc16beda9 sftp_packet_add: verify the packet before accepting it
In order to bail out as quickly as possible when things are wrong and
out of sync, make sure the SFTP message is one we understand.
2012-03-13 21:59:59 +01:00
Daniel Stenberg
9a42fac055 SFTP: preserve the original error code more
Lots of places in the code translated the original error into the more
generic LIBSSH2_ERROR_SOCKET_TIMEOUT but this turns out to distort the
original error reason a lot and makes tracking down the real origin of a
problem really hard. This change makes the original error code be
preserved to a larger extent when return up to the parent function.
2012-03-12 22:52:49 +01:00
Daniel Stenberg
7194a9bd7b sftp_packet_read: adjust window size as necessary
Commit 03ca9020756 tried to simplify the window sizing logic but broke
SFTP readdir as there was no window sizing code left there so large
directory listings no longer worked.

This change introduces window sizing logic to the sftp_packet_read()
function so that it now tells the remote about the local size having a
window size that suffice when it is about to ask for directory data.

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0069.shtml
Reported by: Eric
2012-03-12 22:49:25 +01:00
Steven Dake
7e53949e66 Tell C compiler we don't care about return code of libssh2_init
The call of libssh2_init returns a return code, but nothing could be done
within the _libssh2_init_if_needed execution path.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-11 23:22:05 +01:00
Steven Dake
5672e8f4cf Add comment indicating a resource leak is not really a resource leak
While possibly obvious to those investigating the code, coverity complains
about this out of scope leak.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-06 23:25:46 +01:00
Steven Dake
4449905ea5 Use safer snprintf rather then sprintf in scp_send()
Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-06 23:24:32 +01:00
Steven Dake
8e0cddd01f Use safer snprintf rather then sprintf in scp_recv()
While the buffer is indeed allocated to a safe length, better safe then sorry.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-06 23:23:21 +01:00
Steven Dake
796a5195d3 use snprintf in knownhost_writeline() rather then sprintf
Although the function checks the length, if the code was in error, there
could potentially be a buffer overrun with the use of sprintf.  Instead replace
with snprintf.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-06 23:21:59 +01:00
Steven Dake
15aadb930d Add tracing to print packets left on session at libssh2_session_free
Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-05 20:04:57 +01:00
Peter Stuge
f28264c6a3 Define and use LIBSSH2_INVALID_SOCKET instead of INVALID_SOCKET
INVALID_SOCKET is a special value in Windows representing a
non-valid socket identifier. We were #defining this to -1 on
non-Windows platforms, causing unneccessary namespace pollution.
Let's have our own identifier instead.

Thanks to Matt Lawson for pointing this out.
2012-03-02 17:36:52 +01:00
Peter Stuge
179d2197dd nw/Makefile.netware: Fix project name typo to avoid needless confusion 2012-02-29 22:31:28 +01:00
Peter Stuge
aa8f2cbf33 example/x11: Set raw terminal mode manually instead of with cfmakeraw()
OpenSolaris has no cfmakeraw() so to make the example more portable
we simply do the equivalent operations on struct termios ourselves.

Thanks to Tom Weber for reporting this problem, and finding a solution.
2012-02-29 22:27:18 +01:00
Daniel Stenberg
e07342443f sftp_write: cannot return acked data *and* EAGAIN
Whenever we have acked data and is about to call a function that *MAY*
return EAGAIN we must return the number now and wait to get called
again. Our API only allows data *or* EAGAIN and we must never try to get
both.
2012-02-17 16:06:21 +01:00
Peter Stuge
4774d500e7 example/x11: Build only when sys/un.h is found by configure
The example can't be built on systems without AF_UNIX sockets.
2012-02-13 00:40:24 +01:00
Alexander Lamaison
1403847429 Simplified sftp_read.
Removed the total_read variable that originally must have tracked how
much data had been written to the buffer.  With non-blocking reads, we
must return straight away once we have read data into the buffer so this
variable served not purpose.

I think it was still hanging around in case the initial processing of
'leftover' data meant we wrote to the buffer but this case, like the
others, must return immediately.  Now that it does, the last remaining
need for the variable is gone.
2012-02-10 16:31:38 +01:00
Alexander Lamaison
0d824e5702 Cleaned up sftp_read and added more explanation.
Replaced the gotos which were implementing the state machine with
a switch statement which makes the states more explicit.
2012-02-10 16:31:38 +01:00
Daniel Stenberg
9836b0889f sftp_read: avoid data *and* EAGAIN
Whenever we have data and is about to call a function that *MAY* return
EAGAIN we must return the data now and wait to get called again. Our API
only allows data *or* EAGAIN and we must never try to get both.
2012-02-10 16:31:38 +01:00
Peter Stuge
e394987911 Add a tcpip-forward example which demonstrates remote port forwarding 2012-02-02 17:25:45 +01:00
Peter Stuge
e95c7de453 libssh2.h: Add missing prototype for libssh2_session_banner_set() 2012-02-01 11:35:05 +01:00
Peter Stuge
effbb72192 example/subsystem_netconf.c: Return error when read buffer is too small
Also remove a little redundancy in the read loop condition.
2012-02-01 11:35:05 +01:00
Peter Stuge
0ebe6f44bd example/subsystem_netconf.c: Add a missing newline in an error message 2012-02-01 11:35:00 +01:00
Peter Stuge
b3ade9a63e Fix undefined reference to _libssh_error in libgcrypt backend
Commit 209de22299b4b58e582891dfba70f57e1e0492db introduced a function
call to a non-existing function, and since then the libgcrypt backend
has not been buildable.
2012-02-01 09:53:44 +01:00
Daniel Stenberg
388920cf3c RELEASE-NOTES: synced with 6bd584d29 for 1.4.0 2012-01-31 23:23:04 +01:00
Daniel Stenberg
6bd584d293 s/1.3.1/1.4.0
We're bumping the minor number
2012-01-31 23:22:30 +01:00
Jernej Kovacic
e68c895fc4 libssh2_session_supported_algs: fix compiler warning 2012-01-31 23:07:21 +01:00
Jernej Kovacic
511a972a95 session_supported_algs docs: added an example 2012-01-31 23:05:03 +01:00
Gellule Xg
3401b374c9 sftp-seek: clear EOF flag
Set the EOF flag to False when calling seek64 to be able to get some
data back on a following read
2012-01-27 11:03:31 +01:00
Peter Krempa
209de22299 userauth: Provide more informations if ssh pub key extraction fails
If the function that extracts/computes the public key from a private key
fails the errors it reports were masked by the function calling it. This
patch modifies the key extraction function to return errors using
_libssh_error() function.  The error messages are tweaked to contain
reference to the failed operaton in addition to the reason.

 * AUTHORS: - add my name
 * libgcrypt.c: _libssh2_pub_priv_keyfile(): - return a more verbose
                                               error using
                                               _libssh2_error() func.
 * openssl.c: - modify call graph of _libssh2_pub_priv_keyfile() to use
                _libssh2_error for error reporting();
 * userauth.c: - tweak functions calling _libssh2_pub_priv_keyfile() not
                 to shadow error messages
2011-12-19 23:18:46 +01:00
Daniel Stenberg
b8dd697796 TODO: remove issues we (sort of) did already 2011-12-09 14:21:36 +01:00
Daniel Stenberg
09139ef065 ssh2_exec: skip error outputs for EAGAIN
Since the example uses non-blocking mode, it will just flood the output
with this "nonsense" error.
2011-12-08 10:54:46 +01:00
Guenter Knauf
d903b81c64 Some NetWare makefile tweaks. 2011-11-30 17:52:06 +01:00
Daniel Stenberg
4f61824908 LIBSSH2_SFTP_PACKET_MAXLEN: increase to 80000
Some SFTP servers send SFTP packets larger than 40000. Since the limit
is only present to avoid insane sizes anyway, we can easily bump it.

The define was formerly in the public header libssh2_sftp.h but served
no external purpose and was moved into the source dir.

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2011-11/0004.shtml
Reported by: Michael Harris
2011-11-18 23:36:52 +01:00
Peter Krempa
fed94fa85d knownhost_check(): Don't dereference ext if NULL is passed
Documentation for libssh2_knownhost_checkp() and related functions
states that the last argument is filled with data if non-NULL.

"knownhost if set to non-NULL, it must be a pointer to a 'struct
libssh2_knownhost' pointer that gets filled in to point to info about a
known host that matches or partially matches."

In this function ext is dereferenced even if set to NULL, causing
segfault in applications not needing the extra data.
2011-11-18 16:11:19 +00:00
Peter Krempa
378311fe5b knownhost_add: Avoid dereferencing uninitialized memory on error path.
In function knownhost_add, memory is alocated for a new entry. If normal
alocation is used, memory is not initialized to 0 right after, but a
check is done to verify if correct key type is passed. This test is done
BEFORE setting the memory to null, and on the error path function
free_host() is called, that tries to dereference unititialized memory,
resulting into a glibc abort().

 * knownhost.c - knownhost_add(): - move typemask check before alloc
2011-11-11 21:52:46 +01:00
Daniel Stenberg
139278b79f windows build: add define to avoid compiler warning
A recent mingw compiler has started to complain on "#warning Please
include winsock2.h before windows.h" unless the magic define is set
first.

Reported by: Vincent Torri
Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2011-10/0064.shtml
2011-11-01 22:45:49 +01:00
Vincent Torri
a0e13cc828 Correct Windows include file name case, simplifying cross-compilation
When cross compiling to Windows, libssh2.h include Windows header files
with upper case filenames : BaseTsd.h and WinSock2.h.

These files have lowercase names with mingw-w64 (iirc, it's the same with
mingw). And as on Windows, being lowercase or uppercase does not matter.
2011-10-31 11:32:52 +01:00
Jernej Kovacic
f4e5ca2f14 libssh2_session_supported_algs: added 2011-10-25 23:50:44 +02:00
Kamil Dudka
c0974e5ca3 example/sftp_RW_nonblock: do not ignore LIBSSH2_ERROR_EAGAIN
Bug: https://bugzilla.redhat.com/745420
2011-10-24 22:22:57 +02:00
Peter Stuge
c292378327 example/ssh2_agent: Print host key fingerprint before authentication
Also moves the comment about not being authenticated to before the
agent authentication takes place, so that it better matches the code.
2011-10-05 16:55:58 +02:00
Daniel Stenberg
ee07785a1e OpenSSL EVP: fix threaded use of structs
Make sure we don't clear or reset static structs after first init so
that they work fine even when used from multiple threads. Init the
structs in the global init.

Help and assistance by: John Engstrom

Fixes #229 (again)
2011-09-29 22:42:16 +02:00
Daniel Stenberg
24afd0fc72 openssl: don't init static structs differently
make_ctr_evp() is changed to take a struct pointer, and then each
_libssh2_EVP_aes_[keylen]_ctr function is made to pass in their own
static struct

Reported by: John Engstrom
Fixes #229
2011-09-28 22:26:47 +02:00
Guenter Knauf
abd00727ef Removed obsolete include path. 2011-09-27 16:04:11 +02:00
Daniel Stenberg
4b77724b3b read_state: clear the state variable better
Set read_state back to idle before trying to send anything so that if
the state somehow is wrongly set.

Also, avoid such a case of confusion by resetting the read_state when an
sftp handle is closed.
2011-09-21 16:16:27 +02:00
Daniel Stenberg
33865b8936 sftp_read: remove leftover fprintf
Reported by: Alexander Lamaison
2011-09-17 00:20:14 +02:00
Daniel Stenberg
16dd675f4d sftp.h: fix the #ifdef to prevent multiple inclusions 2011-09-16 22:08:55 +02:00
Daniel Stenberg
30e28817f2 sftp_read: use a state variable to avoid bad writes
When a channel_write call has gotten an EAGAIN back, we try harder to
continue the same write in the subsequent invoke.
2011-09-13 20:16:59 +02:00
Daniel Stenberg
03ca902075 window_size: explicit adjustments only
Removed the automatic window_size adjustments from
_libssh2_channel_read() and instead all channel readers must now make
sure to enlarge the window sizes properly themselves.

libssh2_channel_read_ex() - the public function, now grows the window
size according to the requested buffer size. Applications can still opt
to grow the window more on demand. Larger windows tend to give higher
performance.

sftp_read() now uses the read-ahead logic to figure out a window_size.
2011-09-13 11:21:23 +02:00
Daniel Stenberg
7d58994571 libssh2.h: bump the default window size to 256K 2011-09-13 11:21:23 +02:00
Daniel Stenberg
6d9d44a550 libssh2_userauth_keyboard_interactive.3: fix man warning
It seemed to occur due to the excessive line length
2011-09-12 15:41:28 +02:00
Mikhail Gusarov
d343e3405a Add missing .gitignore entries 2011-09-12 15:38:03 +02:00
Mikhail Gusarov
8d3709f57a Add manpage syntax checker to 'check' target
In virtually every libssh2 release Debian's lintian catches syntax errors in
manpages. Prevent it by checking manpages as a part of testsuite.
2011-09-12 15:38:00 +02:00
Daniel Stenberg
d2dc600be7 libssh2_banner_set.3: fix nroff syntax mistake 2011-09-11 19:25:03 +02:00
Guenter Knauf
0f9e81c6f3 Use predefined resource compiler macro. 2011-09-10 16:53:47 +02:00
Guenter Knauf
46792a9fca Added casts to silent compiler warnings. 2011-09-10 16:38:51 +02:00
Guenter Knauf
b5cd8fe120 Fixed uint64_t printf. 2011-09-10 16:29:29 +02:00
Guenter Knauf
8faefc0a8a Fixed macro function signatures. 2011-09-10 15:57:46 +02:00
Guenter Knauf
f9afe854d3 NetWare makefile tweaks. 2011-09-10 15:31:25 +02:00
Guenter Knauf
26a9aca598 Removed unused var. 2011-09-10 15:24:08 +02:00
Guenter Knauf
bff91fe2a0 Added 2 samples not mentioned. 2011-09-10 15:20:06 +02:00
Guenter Knauf
e0e8d3b0b7 Dont build x11 sample with MinGW. 2011-09-10 15:09:38 +02:00
Guenter Knauf
52d24bc9d2 Fixed executable file description. 2011-09-10 14:51:35 +02:00
Guenter Knauf
e399a852b9 Removed unused var. 2011-09-10 14:48:06 +02:00
Guenter Knauf
3fb3ba571b Kill stupid gcc 3.x uninitialized warning. 2011-09-10 14:22:08 +02:00
Guenter Knauf
1f2c1f9e09 Build all examples. 2011-09-10 14:21:05 +02:00
Guenter Knauf
c75ae587c0 More MinGW makefile tweaks.
Renamed *.mingw makefiles to GNUmakefile since GNU make picks these
up automatically, and therefore win32/Makefile removed.
2011-09-10 14:10:45 +02:00
Guenter Knauf
2e12cfaa23 Removed forgotten WINSOCK_VERSION defines. 2011-09-10 13:40:27 +02:00
Daniel Stenberg
7ed53e21fd libssh2_session_startup(3) => libssh2_session_handshake(3)
Propagate for the current function in docs and examples.
libssh2_session_startup() is deprecated.
2011-09-09 23:17:04 +02:00
Daniel Stenberg
7229d989e7 libssh2_banner_set => libssh2_session_banner_get
Marked the old function as deprecated. Added the new name in the correct
name space with the same arguments and functionality.
2011-09-09 23:11:42 +02:00
Daniel Stenberg
f2c21f6f84 new function: libssh2_session_banner_get
Returns the banner from the server handshake

Fixes #226
2011-09-09 23:00:05 +02:00
Daniel Stenberg
a6ebc6f9fd libssh2.h: bump version to 1.4.0 for new function(s) 2011-09-09 22:49:35 +02:00
Daniel Stenberg
87f79f177f remove embedded CVS/svn tags 2011-09-09 16:12:04 +02:00
liuzl
30ac056cb0 API add:libssh2_sftp_get_channel
Return the channel of sftp, then caller can
control the channel's behavior.

Signed-off-by: liuzl <xieepp@gmail.com>
2011-09-09 16:00:11 +02:00
Daniel Stenberg
c45de9176b _libssh2_channel_read: react on errors from receive_window_adjust
Previously the function would ignore all errors except for EAGAIN.
2011-09-09 10:30:43 +02:00
Daniel Stenberg
ff40c58743 sftp_read: extend and clarify the documentation 2011-09-08 23:02:58 +02:00
Daniel Stenberg
10b66cef08 sftp_read: cap the read ahead maximum amount
Now we only go up to LIBSSH2_CHANNEL_WINDOW_DEFAULT*30 bytes SFTP read
ahead, which currently equals 64K*30 == 1966080 bytes.
2011-09-08 22:47:38 +02:00
Daniel Stenberg
81bdcf61f3 _libssh2_channel_read: fix non-blocking window adjusting
If EAGAIN is returned when adjusting the receive window, we must not
read from the transport directly until we've finished the adjusting.
2011-09-08 14:25:25 +02:00
Guenter Knauf
50d451e307 Fix for systems which need sys/select.h. 2011-09-08 13:53:05 +02:00
Guenter Knauf
3f2b1dea5e The files were not gone but renamed ... 2011-09-08 11:59:49 +02:00
Daniel Stenberg
7c9b84d1d1 sftp_read: added documenting comment
Taken from some recent email conversations I added some descriptions of
the logic in sftp_read() to aid readers.
2011-09-06 23:31:07 +02:00
Daniel Stenberg
1ba42ea847 1.3.1: start the work 2011-09-06 23:27:50 +02:00
Daniel Stenberg
507d5f96cf Makefile.am: the Makefile.win32 files are gone 2011-09-06 22:56:06 +02:00
Daniel Stenberg
84d8728835 RELEASE-NOTES: updated for 1.3.0 2011-09-06 22:47:34 +02:00
Daniel Stenberg
296d57bb2c sftp_read: a short read is not end of file
A returned READ packet that is short will now only reduce the
offset.

This is a temporary fix as it is slightly better than the previous
approach but still not very good.
2011-09-06 22:43:26 +02:00
liuzl
9e79031ad7 _libssh2_packet_add: adjust window size when truncating
When receiving more data than what the window size allows on a
particular channel, make sure that the window size is adjusted in that
case too. Previously it would only adjust the window in the non-error
case.
2011-08-31 10:45:12 +02:00
Guenter Knauf
689fc5c596 Silent compiler warning with MinGW64. 2011-08-29 15:30:18 +02:00
Guenter Knauf
31a9e8860d Fixed link to native Win32 awk tool. 2011-08-29 14:05:15 +02:00
Guenter Knauf
b26c3e7cce Renamed MinGW makefiles. 2011-08-29 13:59:43 +02:00
Guenter Knauf
e4eeb85f01 Some MinGW makefile tweaks.
Enable build without GNU tools and with MinGW64 compiler.
2011-08-29 13:54:51 +02:00
Guenter Knauf
7de77e94bf Fixed aes_ctr_do_cipher() signature. 2011-08-29 13:27:46 +02:00
liuzl
8c0294db66 libssh2_sftp_seek64: flush packetlist and buffered data
When seeking to a new position, flush the packetlist and buffered data
to prevent already received or pending data to wrongly get used when
sftp-reading from the new offset within the file.
2011-08-26 13:47:35 +02:00
Daniel Stenberg
900c90ccbe sftp_read: advance offset correctly for buffered copies
In the case where a read packet has been received from the server, but
the entire contents couldn't be copied to the user-buffer, the data is
instead buffered and copied to the user's buffer in the next invocation
of sftp_read(). When that "extra" copy is made, the 'offset' pointer was
not advanced accordingly.

The biggest impact of this flaw was that the 'already' variable at the
top of the function that figures out how much data "ahead" that has
already been asked for would slowly go more and more out of sync, which
could lead to the file not being read all the way to the end.

This problem was most noticable in cases where the application would
only try to read the exact file size amount, like curl does. In the
examples libssh2 provides the sftp read function is most often called
with a fixed size large buffer and then the bug would not appear as
easily.

This bug was introduced in the SFTP rewrite in 1.2.8.

Bug: http://curl.haxx.se/mail/lib-2011-08/0305.html
     http://www.libssh2.org/mail/libssh2-devel-archive-2011-08/0085.shtml
2011-08-26 11:45:48 +02:00
Daniel Stenberg
d5eec4aad9 wrap some long lines < 80 columns 2011-08-25 22:41:17 +02:00
Daniel Stenberg
19864f0f64 LIBSSH2_RECV: fix typo, use the RECV_FD macro 2011-08-25 22:38:46 +02:00
Daniel Stenberg
420f0b7793 subsystem_netconf.c: fix compiler warnings 2011-08-21 15:24:55 +02:00
Henrik Nordstrom
7aa4bfc671 Custom callbacks for performing low level socket I/O 2011-08-21 15:19:44 +02:00
Daniel Stenberg
462996b064 version bump: start working towards 1.3.0 2011-08-16 23:03:52 +02:00
Daniel Stenberg
07d7a85bdb RELEASE-NOTES: synced with 95d69d3a81261 2011-08-16 10:30:13 +02:00
Henrik Nordstrom
95d69d3a81 Document prototypes for macro defined functions 2011-08-16 10:29:07 +02:00
Henrik Nordstrom
2fe1770d9f Avoid reuse after free when closing X11 channels 2011-08-16 10:27:49 +02:00
Daniel Stenberg
3c71ad4fce _libssh2_channel_write: handle window_size == 0 better
When about to send data on the channel and the window size is 0, we must
not just return 0 if the transport_read() function returned EAGAIN as it
then causes a busy-loop.

Bug: http://libssh2.org/mail/libssh2-devel-archive-2011-08/0011.shtml
2011-08-11 14:36:05 +02:00
Daniel Stenberg
79f48e4881 gettimeofday: fix name space pollution
For systems without its own gettimeofday() implementation, we still must
not provide one outside our namespace.

Reported by: Bill Segall
2011-08-05 23:50:22 +02:00
Dan Fandrich
49453c9ae2 libssh2.pc.in: Fixed spelling in pkgconfig file 2011-08-05 14:33:26 -07:00
Peter Stuge
b232eeb598 example/subsystem_netconf.c: Add missing #include <string.h> 2011-07-17 08:04:52 +02:00
Peter Stuge
f922df9e1b example/subsystem_netconf.c: Discard ]]>]]> and return only XML response 2011-07-17 08:00:48 +02:00
Peter Stuge
7e47bd6640 example/subsystem_netconf.c: Fix uninitialized variable bug 2011-07-17 07:18:39 +02:00
Peter Stuge
4ae907cdef example: Add subsystem_netconf.c
This example demonstrates how to use libssh2 to send a request to
the NETCONF subsystem available e.g. in JunOS.

See also http://tools.ietf.org/html/draft-ietf-netconf-ssh-06
2011-07-17 07:08:48 +02:00
Daniel Stenberg
01d199180a man page cleanups: non-existing functions need no man pages 2011-07-16 00:22:00 +02:00
Daniel Stenberg
7e18862eae libssh2_new_host_entry.3: removed
This is just junk leftovers.
2011-07-16 00:17:12 +02:00
Daniel Stenberg
45ffdcfe3c userauth_keyboard_interactive: fix buffer overflow
Partly reverse 566894494b4972ae12 which was simplifying the code far too
much and ended up overflowing a buffer within the LIBSSH2_SESSION
struct. Back to allocating the buffer properly like it used to do.

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2011-06/0032.shtml
Reported by: Alfred Gebert
2011-06-29 21:32:50 +02:00
Daniel Stenberg
dadc05fdfd keyboard-interactive man page: cleaned up 2011-06-29 20:49:35 +02:00
Alfred Gebert
733bf877f8 _libssh2_recv(): handle ENOENT error as EAGAIN
A sftp session failed with error "failure establishing ssh session" on
Solaris and HP-UX. Sometimes the first recv() function call sets errno
to ENOENT. In the man pages for recv of Solaris and HP-UX the error
ENOENT is not documented.

I tested Solaris SPARC and x86, HP-UX i64, AIX, Windows and Linux.
2011-06-28 22:43:50 +02:00
Daniel Stenberg
2db7d9c655 agent_list_identities: fix out of scope access
An auto variable out of scope was being referenced and used.

fixes #220
2011-06-20 00:08:51 +02:00
Daniel Stenberg
9a24b03402 _libssh2_wait_socket: fix timeouts for poll() uses 2011-06-20 00:08:51 +02:00
Daniel Stenberg
81d53de4dc windows: inclusion fix
include winsock2.h for all windows compilers
2011-06-04 22:24:41 +02:00
Daniel Stenberg
5b004a4b67 keyb-interactive: add the fixed buffer
Belongs to commit 5668944
2011-05-31 23:35:49 +02:00
Daniel Stenberg
da64618c9a code cleanup: don't use C99/c++ comments
We aim for C89 compliance
2011-05-31 23:35:06 +02:00
Daniel Stenberg
566894494b keyb-interactive: allow zero length fields
Allow zero length fields so they don't cause malloc(0) calls

Avoid free()ing NULL pointers

Avoid a malloc of a fixed 5 byte buffer.
2011-05-31 23:33:56 +02:00
Daniel Stenberg
0723dab4d7 libssh2_channel_process_startup.3: clean up
Remove the references to the macro-fied shortcuts as they have their own
individual man pages.

Made the prototype different and more readable.
2011-05-30 09:28:31 +02:00
Daniel Stenberg
67ba8713a6 man page: fix .BR lines
We don't use \fI etc on .BR lines
2011-05-30 09:26:34 +02:00
Daniel Stenberg
dade304c47 userauth_keyboard_interactive: skip code on zero length auth 2011-05-25 22:39:25 +02:00
Daniel Stenberg
6e8229a221 libssh2_channel_forward_accept.3: mention how to get error
Since this returns a pointer, libssh2_session_last_errno() must be used
to get the actual error code and it wasn't that clear before.
2011-05-17 19:32:56 +02:00
Daniel Stenberg
821fb6ca71 timeout docs: mention they're added in 1.2.9 2011-05-13 22:47:22 +02:00
Daniel Stenberg
59673a111e sftp_write_sliding.c: indent fix
Use the standard indenting and removed CVS leftover comment
2011-05-10 10:17:32 +02:00
zl liu
5b66a5f38d sftp_write_sliding: send the complete file
When reaching the end of file there can still be data left not sent.
2011-05-10 10:16:05 +02:00
Douglas Masterson
ce8f0b29a4 session_startup: init state properly
libssh2_session_startup() didn't set the state correctly so it could get
confused.

Fixes #218
2011-05-05 23:24:40 +02:00
Daniel Stenberg
26dad4590b timeout: added man pages 2011-05-04 23:26:26 +02:00
Daniel Stenberg
4ed1e9d96b BLOCK_ADJUST_ERRNO: move rc to right level
We can't declare the variable within the block and use it in the final
do-while() expression to be properly portable C89.
2011-05-04 23:06:13 +02:00
Matt Lilley
c5ec167881 adds a timeout to blocking calls
Fixes bug #160 as per Daniel's suggestion

Adds libssh2_session_set_timeout() and libssh2_session_get_timeout()
2011-05-04 22:58:21 +02:00
Daniel Stenberg
e652b4c7b8 SCP: fix incorrect error code
After an error occurs in libssh2_scp_recv() or libssh2_scp_send(), the
function libssh2_session_last_error() would return
LIBSSH2_ERROR_SOCKET_NONE on error.

Bug: http://trac.libssh2.org/ticket/216
Patch by: "littlesavage"

Fixes #216
2011-05-02 22:27:29 +02:00
Guenter Knauf
cc84d875eb Updated default (recommended) dependency versions. 2011-04-19 14:21:49 +02:00
Daniel Stenberg
c01737e679 libssh2_session_block_directions: fix mistake
The last LIBSSH2_SESSION_BLOCK_INBOUND should be
LIBSSH2_SESSION_BLOCK_OUTBOUND

And I shortened the short description

Reported by: "drswinghead"
2011-04-17 12:40:43 +02:00
Daniel Stenberg
4825171919 msvcproj: added libs and debug stuff
Added libraries needed to link whether using openssl dynamically or
statically

Added LIBSSH2DEBUG define to debug versions to enable tracing

URL: http://trac.libssh2.org/ticket/215
Patch by: Mark Smith
2011-04-15 14:29:30 +02:00
Daniel Stenberg
d881e7e8ef sftp_write: clean offsets on error
When an error has occurred on FXP_WRITE, we must make sure that the
offset, sent offset and acked counter are reset properly.
2011-04-13 13:59:50 +02:00
Daniel Stenberg
5dc5c80a39 example/.gitignore: ignore built binaries 2011-04-13 11:29:08 +02:00
Daniel Stenberg
9f477073bc sftp_write: flush the packetlist on error
When an error occurs during write, flush the entire list of pending
outgoing SFTP packets.
2011-04-13 10:30:30 +02:00
Daniel Stenberg
78498e0588 keepalive: add first basic man pages
Someone on IRC pointed out that we don't have these documented so I
wrote up a first set based on the information in the wiki:
http://trac.libssh2.org/wiki/KeepAlive
2011-04-13 00:11:41 +02:00
Daniel Stenberg
0b0aa209f6 scp_write_nonblock.c: remove pointless check
libssh2_channel_write() cannot return a value that is larger than the
input length value
2011-04-12 10:46:47 +02:00
Mikhail Gusarov
aa07cdee9a s/\.NF/.nf/ to fix wrong macro name caught by man --warnings 2011-04-09 16:25:19 +02:00
Daniel Stenberg
274fb2169c version: bump to 1.2.9_dev
Also update the copyright year range to include 2011
2011-04-06 12:06:22 +02:00
Daniel Stenberg
f0a37bdadc configure: fix $VERSION
Stop using the $VERSION variable as it seems to be magically used by
autoconfig itself and thus gets set to the value set in AC_INIT()
without us wanting that. $LIBSSH2VER is now the libssh2 version as
detected.

Reported by: Paul Howarth
Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2011-04/0008.shtml
2011-04-06 12:03:11 +02:00
Daniel Stenberg
1249dd2272 maketgz: use git2news.pl by the correct name 2011-04-05 19:19:49 +02:00
Daniel Stenberg
5633bb4a3b RELEASE-NOTES: synced with fabf1a45ee 2011-04-04 13:32:58 +02:00
Daniel Stenberg
fabf1a45ee NEWS: auto-generated from git
Starting now, the NEWS file is generated from git using the git2news.pl
script. This makes it always accurate and up-to-date, even for daily
snapshots etc.
2011-04-04 13:31:33 +02:00
Daniel Stenberg
2e352d3085 sftp_write: handle FXP_WRITE errors
When an sftp server returns an error back on write, make sure the
function bails out and returns the proper error.
2011-03-30 11:35:37 +02:00
Daniel Stenberg
8c9571b7ba configure: stop using the deprecated AM_INIT_AUTOMAKE syntax 2011-03-15 11:34:41 +01:00
Alexander Lamaison
527c1b2def Support unlimited number of host names in a single line of the known_hosts file.
Previously the code assumed either a single host name or a hostname,ip-address pair.  However, according to the spec [1], there can be any number of comma separated host names or IP addresses.

[1] http://www.openbsd.org/cgi-bin/man.cgi?query=sshd&sektion=8
2011-03-13 00:29:39 +00:00
Daniel Stenberg
ec934f6dab libssh2_knownhost_readfile.3: clarify return value
This function returns the number of parsed hosts on success, not just
zero as previously documented.
2011-02-26 10:57:56 +01:00
Peter Stuge
516fa7fdd9 Don't save allocated packet size until it has actually been allocated
The allocated packet size is internal state which needs to match reality
in order to avoid problems. This commit fixes #211.
2011-02-26 05:21:01 +01:00
Alfred Gebert
3ce2628140 session_startup: manage server data before server identification
Fix the bug that libssh2 could not connect if the sftp server
sends data before sending the version string.

http://tools.ietf.org/html/rfc4253#section-4.2

"The server MAY send other lines of data before sending the version
string.  Each line SHOULD be terminated by a Carriage Return and Line
Feed.  Such lines MUST NOT begin with "SSH-", and SHOULD be encoded
in ISO-10646 UTF-8 [RFC3629] (language is not specified).  Clients
MUST be able to process such lines."
2011-02-21 23:19:27 +01:00
Alfred Gebert
ad88325b3f fullpacket: decompression only after init
The buffer for the decompression (remote.comp_abstract) is initialised
in time when it is needed.  With this fix decompression is disabled when
the buffer (remote.comp_abstract) is not initialised.

Bug: http://trac.libssh2.org/ticket/200
2011-02-16 13:57:58 +01:00
Daniel Stenberg
2db4863e6e _libssh2_channel_read: store last error
When the transport layer returns EAGAIN this function didn't call
_libssh2_error() which made the last_error not get set.
2011-02-15 23:21:38 +01:00
Daniel Stenberg
691cabc048 sftp_write: clarified the comment header 2011-01-20 09:01:59 +01:00
Daniel Stenberg
90b4b4073f sftp_read: avoid wrapping counter to insanity
As pointed out in bug #206, if a second invoke of libssh2_sftp_read()
would shrink the buffer size, libssh2 would go nuts and send out read
requests like crazy. This was due to an unsigned variable turning
"negative" by some wrong math, and that value would be the amount of
data attempt to pre-buffer!

Bug: http://trac.libssh2.org/ticket/206
2011-01-17 22:39:47 +01:00
Daniel Stenberg
8ce9a66ccf sftp_packet_read: use 32bit variables for 32bit data 2011-01-09 00:34:09 +01:00
Daniel Stenberg
7015488150 libssh2_sftp_stat_ex.3: cleaned up, extended
Removed the macros from it as they have their own man pages.

Added the LIBSSH2_SFTP_ATTRIBUTES struct in here for easier reference.
2011-01-06 00:30:32 +01:00
Daniel Stenberg
164838c7dd sftp_readdir: return error if buffer is too small
If asked to read data into a buffer and the buffer is too small to hold
the data, this function now returns an error instead of as previously
just copy as much as fits.
2011-01-04 14:30:04 +01:00
Daniel Stenberg
f9b1b95059 sftp_symlink: return error if receive buffer too small
and clean up some variable type mismatches

Discussion: http://www.libssh2.org/mail/libssh2-devel-archive-2011-01/0001.shtml
2011-01-04 14:15:57 +01:00
Daniel Stenberg
59207291fc docs: clarify what happens with a too small buffer
This flaw is subject to change, but I figured it might be valuable to
users of existing code to know how it works.
2011-01-03 00:07:44 +01:00
Daniel Stenberg
0da37e0924 channel_request_pty_size: fix reqPTY_state
The state variable isn't properly set so every other call to the
function fails!

Bug: http://libssh2.org/mail/libssh2-devel-archive-2010-12/0096.shtml
Reported by: Steve Legg
2011-01-01 16:16:32 +01:00
Daniel Stenberg
4552c73cd5 data size: cleanup
Fix 64bit warnings by using (s)size_t and dedicated uint32_t types more.
2010-12-30 00:09:53 +01:00
Pierre Joye
306929ee80 ssize_t: proper typedef with MSVC compilers
As discussed on the mailing list, it was wrong for win64 and using the
VC-provided type is the safest approach instead of second- guessing
which one it should be.
2010-12-29 23:22:00 +01:00
Guenter Knauf
326f741a52 Updated OpenSSL version. 2010-12-22 14:39:59 +01:00
Guenter Knauf
aa4f861643 Expanded tabs to spaces. 2010-12-22 14:27:55 +01:00
Joey Degges
fd691deb17 _libssh2_ntohu64: fix conversion from network bytes to uint64
Cast individual bytes to uint64 to avoid overflow in arithmetic.
2010-12-21 13:15:42 +01:00
Daniel Stenberg
20da09932e libssh2_userauth_list: language fix
"faily" is not a good English word, and I also cleaned up some other minor
mistakes
2010-12-20 14:22:07 +01:00
Daniel Stenberg
3ab7af095a crypto: unify the generic functions
Added crypto.h that is the unified header to include when using crypto
functionality. It should be the only header that needs to adapt to the
underlying crypto library in use. It provides the set of prototypes that
are library agnostic.
2010-12-19 00:00:50 +01:00
Mark Smith
5b1a7ec2f1 userauth: derive publickey from private
Pass a NULL pointer for the publickey parameter of
libssh2_userauth_publickey_fromfile and
libssh2_userauth_hostbased_fromfile functions.  In this case, the
functions recompute the public key from the private key file data.

This is work done by Jean-Louis CHARTON
<Jean-Louis.CHARTON@oikialog.com>, then adapted by Mark Smith and
slightly edited further by me Daniel.

WARNING: this does leave the feature NOT WORKING when libssh2 is built
to use libgcrypt instead of OpenSSL simply due to lack of
implementation.
2010-12-18 23:38:08 +01:00
Daniel Stenberg
5ee38702a0 ssh2_echo: Value stored to 'exitcode' is never read 2010-12-15 21:58:43 +01:00
Daniel Stenberg
2165ceacd3 _libssh2_packet_add: fix SSH_MSG_DEBUG weirdness
I believe I may have caused this weird typo style error when I cleaned
up this function a while ago. Corrected now.
2010-12-15 21:57:06 +01:00
Daniel Stenberg
121237ce2f uint32: more longs converted to proper types
I also moved the MAC struct over to the mac.h header file and made sure
that the users of that struct include that file.
2010-12-15 09:52:18 +01:00
Daniel Stenberg
b3e832172b SFTP: more types to uint32_t
The 'num_names' field in the SSH_FXP_NAME response is an unsigned 32bit
value so we make sure to treat it like that.
2010-12-15 09:31:37 +01:00
Daniel Stenberg
3faa8bc940 SFTP: request_ids are uint32_t
I went over the code and made sure we use uint32_t all over for the
request_id data. It is an unsigned 32bit value on the wire.
2010-12-15 09:27:00 +01:00
Daniel Stenberg
2f0c0cef76 SFTP: store request_id separately in packets
By using a new separate struct for incoming SFTP packets and not sharing
the generic packet struct, we can get rid of an unused field and add a
new one dedicated for holding the request_id for the incoming
package. As sftp_packet_ask() is called fairly often, a "mere" integer
comparison is MUCH faster than the previous memcmp() of (typically) 5
bytes.
2010-12-14 23:49:51 +01:00
Daniel Stenberg
75909e05a9 libssh2_sftp_open_ex: man page extended and cleaned up
I added the missing documentation for the 'flags' argument.
2010-12-14 15:06:04 +01:00
Daniel Stenberg
47b4e62780 SFTP: unify the READ/WRITE chunk structs 2010-12-14 13:29:41 +01:00
Daniel Stenberg
1b1ff333e4 SFTP: fix memory leaks
Make sure that we cleanup remainders when the handle is closed and when
the subsystem is shutdown.

Existing flaw: if a single handle sends packets that haven't been
replied to yet at the time when the handle is closed, those packets will
arrive later and end up in the generic packet brigade queue and they
will remain in there until flushed. They will use unnecessary memory,
make things slower and they will ruin the SFTP handling if the
request_id counter ever wraps (highly unlikely to every happen).
2010-12-14 11:46:53 +01:00
Daniel Stenberg
c1683ae92c sftp_close_handle: packet list is generic
Fix comment, simplify the loop logic
2010-12-14 09:33:58 +01:00
Daniel Stenberg
1b65c6ae26 sftp_read: pipeline reads
The SFTP read function now does transfers the same way the SFTP write
function was made to recently: it creates a list of many outgoing
FXP_READ packets that each asks for a small data chunk. The code then
tries to keep sending read request while collecting the acks for the
previous requests and returns the received data.
2010-12-14 09:30:25 +01:00
Daniel Stenberg
92ea3bda60 sftp_write: removed unused variable 2010-12-13 19:02:19 +01:00
Daniel Stenberg
811cce09b5 _libssh2_channel_close: don't call transport read if disconnected
The loop that waits for remote.close to get set may end up looping
forever since session->socket_state gets set to
LIBSSH2_SOCKET_DISCONNECTED by the packet_add() function called from the
transport_read() function and after having been set to
LIBSSH2_SOCKET_DISCONNECTED, the transport_read() function will only
return 0.

Bug: http://trac.libssh2.org/ticket/198
2010-12-11 22:43:22 +01:00
Daniel Stenberg
6875285b71 libssh2_sftp_seek64: new man page
Split off libssh2_sftp_seek64 from the libssh2_sftp_seek man page, and
mentioned that we consider the latter deprecated. Also added a mention
about the dangers of doing seek during writing or reading.
2010-12-11 00:03:42 +01:00
Daniel Stenberg
0cc14be09d sftp_seek: fix
The new SFTP write code caused a regression as the seek function no
longer worked as it didn't set the write position properly.

It should be noted that seeking is STRONGLY PROHIBITED during upload, as
the upload magic uses two different offset positions and the multiple
outstanding packets etc make them sensitive to change in the midst of
operations.

This functionality was just verified with the new example code
sftp_append. This bug was filed as bug #202:

Bug: http://trac.libssh2.org/ticket/202
2010-12-10 23:51:20 +01:00
Daniel Stenberg
499b989d46 sftp_append: new example doing SFTP append 2010-12-10 23:49:16 +01:00
Daniel Stenberg
fa07d9fefc MAX_SFTP_OUTGOING_SIZE: 30000
I ran SFTP upload tests against localhost. It showed that to make the
app reach really good speeds, I needed to do a little code tweak and
change MAX_SFTP_OUTGOING_SIZE from 4000 to 30000. The tests I did before
with the high latency tests didn't show any real difference whatever I
had that size set to.

This number is the size in bytes that libssh2 cuts off the large input
buffer and sends off as an individual sftp packet.
2010-12-06 21:10:10 +01:00
Daniel Stenberg
b0c32a85fc sftp_write_sliding.c: new example
This is an example that is very similar to sftp_write_nonblock.c, with
the exception that this uses

1 - a larger upload buffer

2 - a sliding buffer mechnism to allow the app to keep sending lots of
data to libssh2 without having to first drain the buffer.

These are two key issues to make libssh2 SFTP uploads really perform
well at this point in time.
2010-12-05 00:06:39 +01:00
Daniel Stenberg
7ed7dad3b4 cpp: s/#elsif/#elif
This looks like a typo as #elsif is not really C...
2010-12-02 12:40:59 +01:00
Daniel Stenberg
b215ec0af5 _libssh2_channel_write: revert channel_write() use
The attempts made to have _libssh2_channel_write() accept larger pieces
of data and split up the data by itself into 32700 byte chunks and pass
them on to channel_write() in a loop as a way to do faster operations on
larger data blocks was a failed attempt.

The reason why it is difficult:

The API only allows EAGAIN or a length to be returned. When looping over
multiple blocks to get sent, one block can get sent and the next might
not. And yet: when transport_send() has returned EAGAIN we must not call
it again with new data until it has returned OK on the existing data it
is still working on. This makes it a mess and we do get a much easier
job by simply returning the bytes or EAGAIN at once, as in the EAGAIN
case we can assume that we will be called with the same arguments again
and transport_send() will be happy.

Unfortunately, I think we take a small performance hit by not being able
to do this.
2010-11-13 23:13:21 +01:00
Daniel Stenberg
ac6d0fb706 ssh2_echo: new example
This is a new example snippet. The code is largely based on ssh2_exec,
and is written by Tommy Lindgren. I edited it into C90 compliance and to
conform to libssh2 indent style and some more.
2010-11-13 23:11:39 +01:00
Daniel Stenberg
e87293d480 send_existing: return after send_existing
When a piece of data is sent from the send_existing() function we must
make the parent function return afterwards. Otherwise we risk that the
parent function tries to send more data and ends up getting an EGAIN for
that more data and since it can only return one return code it doesn't
return info for the successfully sent data.

As this change is a regression I now added a larger comment explaining
why it has to work like this.
2010-11-13 12:25:06 +01:00
Daniel Stenberg
a3ce1073c4 _libssh2_channel_write: count resent data as written
In the logic that resends data that was kept for that purpose due to a
previous EAGAIN, the data was not counted as sent causing badness.
2010-11-13 12:23:23 +01:00
Peter Stuge
97a1881749 Use fprintf(stderr, ) instead of write(2, ) for debugging 2010-11-13 02:06:41 +01:00
Peter Stuge
80f7508d55 session/transport: Correctly handle when _libssh2_send() returns -EAGAIN 2010-11-13 01:53:39 +01:00
Peter Stuge
e8c44e789f src/agent.c: Simplify _libssh2_send() error checking ever so slightly 2010-11-13 01:50:24 +01:00
Daniel Stenberg
ca2e81eb1f send/recv: use _libssh2_recv and _libssh2_send now
Starting now, we unconditionally use the internal replacement functions
for send() and recv() - creatively named _libssh2_recv() and
_libssh2_send().

On errors, these functions return the negative 'errno' value instead of
the traditional -1. This design allows systems that have no "natural"
errno support to not have to invent it. It also means that no code
outside of these two transfer functions should use the errno variable.
2010-11-12 21:53:35 +01:00
Daniel Stenberg
aff9c825c8 channel_write: move some logic to _libssh2_channel_write
Some checks are better done in _libssh2_channel_write just once per
write instead of in channel_write() since the looping will call the
latter function multiple times per _libssh2_channel_write() invoke.
2010-11-12 15:15:46 +01:00
Daniel Stenberg
7899d28ecb sftp_write: handle "left over" acked data
The SFTP handle struct now buffers number of acked bytes that haven't
yet been returned. The way this is used is as following:

1. sftp_write() gets called with a buffer of let say size 32000. We
split 32000 into 8 smaller packets and send them off one by one. One of
them gets acked before the function returns so 4000 is returned.

2. sftp_write() gets called again a short while after the previous one,
now with a much smaller size passed in to the function. Lets say 8000.
In the mean-time, all of the remaining packets from the previous call
have been acked (7*4000 = 28000). This function then returns 8000 as all
data passed in are already sent and it can't return any more than what
it got passed in. But we have 28000 bytes acked. We now store the
remaining 20000 in the handle->u.file.acked struct field to add up in
the next call.

3. sftp_write() gets called again, and now there's a backlogged 20000
bytes to return as fine and that will get skipped from the beginning
of the buffer that is passed in.
2010-11-11 11:57:35 +01:00
Daniel Stenberg
2f5a2ff8e6 sftp_write: polished and simplified
Removed unnecessary struct fields and state changes within the function.

Made the loop that checks for ACKs only check chunks that were fully
sent.
2010-11-10 23:29:16 +01:00
Daniel Stenberg
160453cee4 SCP: on failure, show the numerical error reason
By calling libssh2_session_last_errno()
2010-11-10 17:26:38 +01:00
Daniel Stenberg
82fa5d2167 SFTP: provide the numerical error reason on failure 2010-11-10 17:26:02 +01:00
Daniel Stenberg
1c3e1c4d25 SCP: clean up failure treatment
When SCP send or recv fails, it gets a special message from the server
with a warning or error message included. We have no current API to
expose that message but the foundation is there. Removed unnecessary use
of session struct fields.
2010-11-10 17:17:32 +01:00
Daniel Stenberg
1d2a5b8456 sftp_write: enlarge buffer to perform better 2010-11-10 15:00:55 +01:00
Daniel Stenberg
1d11d02aa9 packets: code cleanup
I added size checks in several places. I fixed the code flow to be easier
to read in some places.

I removed unnecessary zeroing of structs. I removed unused struct fields.
2010-11-10 14:56:14 +01:00
Daniel Stenberg
f4ad3e0120 LIBSSH2_CALLBACK_MACERROR: clarify return code use 2010-11-10 14:41:56 +01:00
Daniel Stenberg
772564650d _libssh2_userauth_publickey: avoid shadowing 2010-11-10 13:28:33 +01:00
Daniel Stenberg
05ba8db8aa packet: avoid shadowing global symbols 2010-11-10 13:06:39 +01:00
Daniel Stenberg
1964ccb557 sftp_readdir: avoid shadowing 2010-11-10 13:05:08 +01:00
Daniel Stenberg
bef0ce5392 shadowing: don't shadow the global compress 2010-11-10 13:04:30 +01:00
Daniel Stenberg
fb6afd01a1 _libssh2_packet_add: turn ifs into a single switch 2010-11-10 12:21:48 +01:00
Daniel Stenberg
a302428335 _libssh2_packet_add: check SSH_MSG_GLOBAL_REQUEST packet 2010-11-09 19:59:18 +01:00
Daniel Stenberg
7ad152a6b2 _libssh2_packet_add: SSH_MSG_DEBUG length checks
Verify lengths before using them. Read always_display from the correct
index. Don't copy stuff around just to provide zero-termination of the
strings.
2010-11-09 15:07:32 +01:00
Daniel Stenberg
075ff19574 _libssh2_packet_add: SSH_MSG_IGNORE skip memmove
There's no promise of a zero termination of the data in the callback so
no longer perform ugly operation in order to provide it.
2010-11-09 14:57:36 +01:00
Daniel Stenberg
16f46c1cfc _libssh2_packet_add: SSH_MSG_DISCONNECT length checks
Verify lengths before trying to read data.
2010-11-09 14:53:44 +01:00
Daniel Stenberg
aa2fdb3e7e indent: break lines at 80 columns 2010-11-09 14:32:02 +01:00
Daniel Stenberg
8f10da89c5 SSH_MSG_CHANNEL_OPEN_FAILURE: used defined values
We don't like magic numbers in the code. Now the acceptable failure
codes sent in the SSH_MSG_CHANNEL_OPEN_FAILURE message are added as
defined values in the private header file.
2010-11-09 14:28:29 +01:00
Daniel Stenberg
2dfa5d38cb sftp_write: don't return EAGAIN if no EAGAIN was received
This function now only returns EAGAIN if a lower layer actually returned
EAGAIN to it. If nothing was acked and no EAGAIN was received, it will
now instead return 0.
2010-11-09 13:09:08 +01:00
Daniel Stenberg
095e9e7b3e _libssh2_wait_socket: detect nothing-to-wait-for
If _libssh2_wait_socket() gets called but there's no direction set to
wait for, this causes a "hang". This code now detects this situation,
set a 1 second timeout instead and outputs a debug output about it.
2010-11-09 13:07:15 +01:00
Daniel Stenberg
588c8946fc decomp: remove the free_dest argument
Since the decompress function ALWAYS returns allocated memory we get a
lot simpler code by removing the ability to return data unallocated.
2010-11-03 15:03:57 +01:00
Daniel Stenberg
a6fc9aeec9 decomp: cleaned off old compression stuff
I cleared off legacy code from when the compression and decompression
functions were a single unified function. Makes the code easier to read
too.
2010-11-03 14:52:42 +01:00
TJ Saunders
7603c0f854 decomp: increase decompression buffer sizes 2010-11-03 14:45:52 +01:00
TJ Saunders
8974dc05ae zlib: Add debug tracing of zlib errors 2010-11-03 14:42:44 +01:00
Daniel Stenberg
6395a738fd sftp_packet_read: handle partial reads of the length field
SFTP packets come as [32 bit length][payload] and the code didn't
previously handle that the initial 32 bit field was read only partially
when it was read.
2010-11-02 19:14:33 +01:00
Jasmeet Bagga
73be9fab04 kex_agree_hostkey: fix NULL pointer derefence
While setting up the session, ssh tries to determine the type of
encryption method it can use for the session. This requires looking at
the keys offered by the remote host and comparing these with the methods
supported by libssh2 (rsa & dss). To do this there is an iteration over
the array containing the methods supported by libssh2.

If there is no agreement on the type of encryption we come to the 3rd
entry of the hostkeyp array. Here hostkeyp is valid but *hostkep is
NULL. Thus when we dereference that in (*hostkeyp)->name there is a
crash
2010-11-02 00:02:25 +01:00
Daniel Stenberg
753e55ef23 _libssh2_transport_send: remove dead assignment
'data' isn't accessed beyond this point so there's no need to assign it.
2010-11-01 23:00:07 +01:00
Daniel Stenberg
4760e4d051 scp_recv: remove dead assignment
Instead of assigning a variable we won't read, we now use the more
explicit (void) prefix.
2010-11-01 22:59:15 +01:00
Daniel Stenberg
57af0da9f7 sftp_write: removed superfluous assignment 2010-11-01 22:58:47 +01:00
Daniel Stenberg
024b5d29f5 bugfix: avoid use of uninitialized value 2010-11-01 22:58:12 +01:00
Daniel Stenberg
a0dd0c5992 sftp_packet_require: propagate error codes better
There were some chances that they would cause -1 to get returned by
public functions and as we're hunting down all such occurances and since
the underlying functions do return valuable information the code now
passes back proper return codes better.
2010-11-01 09:33:36 +01:00
Alfred Gebert
92d308c157 fix memory leaks (two times cipher_data) for each sftp session 2010-10-27 23:17:16 +02:00
Daniel Stenberg
4ae71b4838 libssh2_userauth_authenticated: make it work as documented
The man page clearly says it returns 1 for "already authenticated" but
the code said non-zero. I changed the code to use 1 now, as that is also
non-zero but it gets the benefit that it now matches the documentation.

Using 1 instead of non-zero is better for two reasons:

1. We have the opportunity to introduce other return codes in the future for
   things like error and what not.
2. We don't expose the internal bitmask variable value.
2010-10-27 22:59:32 +02:00
Daniel Stenberg
ba190d34c6 userauth_keyboard_interactive: fix indent 2010-10-27 22:58:39 +02:00
Alfred Gebert
b84f69c960 fix memory leak in userauth_keyboard_interactive()
First I wanted to free the memory in session_free() but then
I had still memory leaks because in my test case the function
userauth_keyboard_interactive() is called twice. It is called
twice perhaps because the server has this authentication
methods available: publickey,gssapi-with-mic,keyboard-interactive
The keyboard-interactive method is successful.
2010-10-27 22:47:34 +02:00
Daniel Stenberg
a7aee34522 dist: include sftp.h in dist archives 2010-10-27 14:51:25 +02:00
Simon Josefsson
1dc366109d Update header to match new function prototype, see c48840ba88. 2010-10-27 11:45:07 +02:00
Daniel Stenberg
e1ea2eb7c2 bugfixes: the transport rearrange left some subtle flaws now gone 2010-10-26 00:14:31 +02:00
Daniel Stenberg
610a8ab919 libssh2_userauth_publickey_fromfile_ex.3: cleaned up looks 2010-10-25 23:44:39 +02:00
Daniel Stenberg
8ec21e0afe libssh2_userauth_publickey: add man page
I found an undocumented public function and we can't have it like
that. The description here is incomplete, but should serve as a template
to allow filling in...
2010-10-25 23:18:50 +02:00
Daniel Stenberg
8e0983347b libssh2_sftp_write.3: added blurb about the "write ahead"
Documented the new SFTP write concept
2010-10-25 16:38:37 +02:00
Daniel Stenberg
95db6cc62c sftp_close_handle: free any trailing write chunks 2010-10-25 16:30:09 +02:00
Daniel Stenberg
727043074a _libssh2_channel_write: fix warnings 2010-10-25 16:07:46 +02:00
Daniel Stenberg
5b4ed2717b SFTP: bufgix, move more sftp stuff to sftp.h
The sftp_write function shouldn't assume that the buffer pointer will be
the same in subsequent calls, even if it assumes that the data already
passed in before haven't changed.

The sftp structs are now moved to sftp.h (which I forgot to add before)
2010-10-25 16:05:53 +02:00
Daniel Stenberg
59f74de157 SFTP: use multiple outgoing packets when writing
sftp_write was rewritten to split up outgoing data into multiple packets
and deal with the acks in a more asynchronous manner. This is meant to
help overcome latency and round-trip problems with the SFTP protocol.
2010-10-25 01:43:54 +02:00
Daniel Stenberg
d87562976a TODO: implemented a lot of the ideas now 2010-10-24 23:38:26 +02:00
Daniel Stenberg
a94886f157 _libssh2_channel_write: removed 32500 size limit
Neither _libssh2_channel_write nor sftp_write now have the 32500 size
limit anymore and instead the channel writing function now has its own
logic to send data in multiple calls until everything is sent.
2010-10-23 01:16:12 +02:00
Daniel Stenberg
dec0ea9e70 send_existing: don't tell parent to return when drained
That will just cause unnecessary code execution.
2010-10-23 00:47:51 +02:00
Daniel Stenberg
030b2d9b60 _libssh2_channel_write: general code cleanup
simplified the function and removed some unused struct fields
2010-10-23 00:35:10 +02:00
Daniel Stenberg
c48840ba88 _libssh2_transport_send: replaces _libssh2_transport_write
The new function takes two data areas, combines them and sends them as a
single SSH packet. This allows several functions to allocate and copy
less data.

I also found and fixed a mixed up use of the compression function
arguments that I introduced in my rewrite in a recent commit.
2010-10-23 00:11:59 +02:00
Daniel Stenberg
d9cdd8c0a7 scp_write_nonblock: use select() instead of busyloop
Make this example nicer by not busylooping.
2010-10-22 13:37:14 +02:00
Daniel Stenberg
c49061e708 send_existing: clear olen when the data is sent off 2010-10-22 13:37:14 +02:00
Daniel Stenberg
d674b1a09a _libssh2_transport_write: allow 256 extra bytes around the packet 2010-10-22 13:37:13 +02:00
Daniel Stenberg
5ede32a826 _libssh2_transport_write: remade to send without malloc 2010-10-22 13:37:13 +02:00
Daniel Stenberg
3a391f6cf2 compress: compression disabled by default
We now allow libssh2_session_flag() to enable compression with a new
flag and I added documentation for the previous LIBSSH2_FLAG_SIGPIPE
flag which I wasn't really aware of!
2010-10-22 13:37:13 +02:00
Daniel Stenberg
64063d5f0b comp: split the compress function
It is now made into two separate compress and decompress functions. In
preparation for upcoming further modficications.
2010-10-22 13:37:13 +02:00
Dan Fandrich
784db8e987 Added header file to allow compiling in older environments 2010-10-20 22:19:38 -07:00
Daniel Stenberg
84efbf788f TODO: add a possible new API for SFTP transfers 2010-10-20 23:16:26 +02:00
Daniel Stenberg
f805c2db2a TODO: "New Transport API" added 2010-10-20 23:16:26 +02:00
Daniel Stenberg
08ce6425f6 TODO: add buffering plans 2010-10-20 23:16:26 +02:00
Simon Josefsson
fac9412a74 Mention libssh2_channel_get_exit_signal and give kudos. 2010-10-13 15:33:13 +02:00
Tommy Lindgren
4d15e0c9d1 Add libssh2_channel_get_exit_signal man page.
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2010-10-13 15:31:53 +02:00
Tommy Lindgren
6140ec2de3 Add libssh2_channel_get_exit_signal.
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2010-10-13 15:31:06 +02:00
Simon Josefsson
70d6bd6c6f Add libssh2_free man page and fix typo. 2010-10-13 15:24:18 +02:00
Simon Josefsson
98e38c4f3a Add libssh2_free. 2010-10-13 15:19:12 +02:00
Daniel Stenberg
cd6d41b806 scp_recv: improved treatment of channel_read() returning zero
As a zero return code from channel_read() is not an error we must make
sure that the SCP functions deal with that properly. channel_read()
always returns 0 if the channel is EOFed already so we check for EOF
after 0-reads to be able to return error properly.
2010-10-11 22:54:24 +02:00
Daniel Stenberg
c36f379b88 libssh2_session_methods.3: detail what can be asked for 2010-10-10 23:51:22 +02:00
Daniel Stenberg
77a9335515 compression: send zlib before none
As the list of algorithms in a preferred order we should send zlib
before none to increase the chances that the server will let us do
compression.
2010-10-08 17:06:55 +02:00
Daniel Stenberg
59636cc11e compress: faster check, better return codes
In the transport functions we avoid a strcmp() now and just check a
boolean instead.

The compress/decompress function's return code is now acknowledged and
used as actual return code in case of failures.
2010-10-08 16:26:50 +02:00
Daniel Stenberg
0d58af6aec libssh2_session_handshake: replaces libssh2_session_startup()
The function libssh2_session_startup() is now considered deprecated due
to the portability issue with the socket argument.
libssh2_session_handshake() is the name of the replacement.
2010-10-07 19:56:12 +02:00
Daniel Stenberg
c34e1d8735 libssh2_socket_t: now externally visible
In preparation for upcominig changes, the libssh2_socket_t type is now
typedef'ed in the public header.
2010-10-07 15:33:24 +02:00
Daniel Stenberg
861fc75fa3 _libssh2_transport_drain: removed
This function proved not to be used nor useful.
2010-10-07 13:30:05 +02:00
Daniel Stenberg
f4d302fdfe _libssh2_channel_write: don't iterate over transport writes
When a call to _libssh2_transport_write() succeeds, we must return from
_libssh2_channel_write() to allow the caller to provide the next chunk
of data.

We cannot move on to send the next piece of data that may already have
been provided in this same function call, as we risk getting EAGAIN for
that and we can't return information both about sent data as well as
EAGAIN. So, by returning short now, the caller will call this function
again with new data to send.
2010-10-07 13:28:49 +02:00
Daniel Stenberg
4faf67d3e9 _libssh2_transport_write: updated documentation blurb 2010-10-07 13:17:28 +02:00
Daniel Stenberg
76a30f2c6f _libssh2_transport_write: remove fprintf remainder
Mistake from previous debugging
2010-10-07 12:57:08 +02:00
Daniel Stenberg
bcd7eee1d2 session: improved errors
Replaced -1/SOCKET_NONE errors with appropriate error defines instead.

Made the verbose trace output during banner receiving less annoying for
non-blocking sessions.
2010-10-07 11:21:56 +02:00
Daniel Stenberg
046ad88d88 crypt_init: use correct error define 2010-10-07 11:21:20 +02:00
Daniel Stenberg
9887c01103 _libssh2_error: hide EAGAIN for non-blocking sessions
In an attempt to make the trace output less cluttered for non-blocking
sessions the error function now avoids calling the debug function if the
error is the EAGAIN and the session is non-blocking.
2010-10-07 11:19:51 +02:00
Daniel Stenberg
822f9e8689 agent: use better error defines 2010-10-07 11:19:35 +02:00
Daniel Stenberg
3ee2aabd7a comp_method_zlib_init: use correct error defines 2010-10-07 11:19:15 +02:00
Daniel Stenberg
7c49c8be58 transport: better error codes
LIBSSH2_SOCKET_NONE (-1) should no longer be used as error code as it is
(too) generic and we should instead use specific and dedicated error
codes to better describe the error.
2010-10-07 11:18:14 +02:00
Daniel Stenberg
665d9ee885 channel: return code and _libssh2_error cleanup
Made sure that all transport_write() call failures get _libssh2_error
called.
2010-10-07 11:16:49 +02:00
Daniel Stenberg
b3d6c6567d _libssh2_channel_write: limit to 32700 bytes
The well known and used ssh server Dropbear has a maximum SSH packet
length at 32768 by default. Since the libssh2 design current have a
fixed one-to-one mapping from channel_write() to the packet size created
by transport_write() the previous limit of 32768 in the channel layer
caused the transport layer to create larger packets than 32768 at times
which Dropbear rejected forcibly (by closing the connection).

The long term fix is of course to remove the hard relation between the
outgoing SSH packet size and what the input length argument is in the
transport_write() function call.
2010-10-07 11:11:59 +02:00
Daniel Stenberg
7dd574c353 libssh.h: add more dedicated error codes 2010-10-07 11:10:28 +02:00
Daniel Stenberg
018602cb34 SCP: allow file names with bytes > 126
When parsing the SCP protocol and verifying that the data looks like a
valid file name, byte values over 126 must not be consider illegal since
UTF-8 file names will use such codes.

Reported by: Uli Zappe
Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2010-08/0112.shtml
2010-08-31 19:56:00 +02:00
Dan Fandrich
eec7f2fb63 Document the three sftp stat constants 2010-08-25 17:10:06 -07:00
Guenter Knauf
c32b0d164e Fixed Win32 makefile which was now broken at resource build. 2010-08-18 17:22:33 +02:00
Guenter Knauf
835c03e076 It is sufficient to pipe stderr to NUL to get rid of the nasty messages. 2010-08-18 16:59:21 +02:00
Author: Guenter Knauf
6c6c43f92c Removed Win32 ifdef completely for sys/uio.h.
No idea why we had this ifdef at all but MSVC, MingW32, Watcom
and Borland all have no sys/uio.h header; so if there's another
Win32 compiler which needs it then it should be added explicitely
instead of this negative list.
2010-08-18 16:40:03 +02:00
Guenter Knauf
5af87e8c80 New files should also be added to Makefile.am.
Otherwise they will never be included with release and snapshot tarballs ...
2010-08-18 14:59:03 +02:00
Daniel Stenberg
10a65fda01 version: bump to 1.2.8_DEV 2010-08-18 00:20:10 +02:00
Daniel Stenberg
8d9d3e0d7a release: updated to hold 1.2.7 info 2010-08-17 23:10:54 +02:00
Guenter Knauf
c46abb2663 Use the new libssh2.rc file. 2010-08-17 01:58:39 +02:00
Guenter Knauf
0a34fa79f0 Added resource file for libssh2.dll (shamelessly stolen from libcurl). 2010-08-17 01:54:20 +02:00
Guenter Knauf
43001570d6 Updated Win32 MSVC dependencies versions. 2010-08-17 01:35:55 +02:00
Guenter Knauf
4b878e7cf8 Added include for sys/select.h to get fd.set on some platforms. 2010-08-17 01:34:32 +02:00
Guenter Knauf
ac709e0d4f Added Watcom makefile borrowed from libcurl.
This makefile compiles already all files fine for static lib, but needs
final touch when I have OpenSSL fully working with shared libs and Watcom.
2010-08-16 16:10:07 +02:00
Guenter Knauf
56d0877f07 Added copyright define to libssh2.h and use it for binary builds. 2010-08-15 04:09:01 +02:00
Guenter Knauf
51a8335486 Moved version defines up in order to include from .rc file.
Blocked rest of header with ifndef so its possible to let
the rc compiler only use the version defines.
2010-08-15 03:38:49 +02:00
Guenter Knauf
2bd9418ac7 Some minor makefile tweaks. 2010-08-14 21:56:37 +02:00
Daniel Stenberg
4b8013a8a7 example: treat the libssh2_channel_read() return code properly
A short read is not an error. Only negative values are errors!
2010-08-02 00:20:24 +02:00
Daniel Stenberg
697b4e8ed7 libssh2_wait_socket: reset error code to "leak" EAGAIN less
Since libssh2 often sets LIBSSH2_ERROR_EAGAIN internally before
_libssh2_wait_socket is called, we can decrease some amount of
confusion in user programs by resetting the error code in this function
to reduce the risk of EAGAIN being stored as error when a blocking
function returns.
2010-07-18 19:47:21 +02:00
Daniel Stenberg
2afa5b2dc2 _libssh2_wait_socket: poll needs milliseconds
As reported on the mailing list, the code path using poll() should
multiple seconds with 1000 to get milliseconds, not divide!

Reported by: Jan Van Boghout
2010-07-17 19:20:20 +02:00
Daniel Stenberg
992aff7aca typedef: make ssize_t get typedef without LIBSSH2_WIN32
The condition around the ssize_t typedef depended on both LIBSSH2_WIN32
*and* _MSC_VER being defined when it should be enough to depend on
_MSC_VER only. It also makes it nicer so libssh2-using code builds fine
without having custom defines.
2010-07-06 16:17:59 +02:00
John Little
ef4c8718c2 session_free: free more data to avoid memory leaks 2010-07-01 19:56:06 +02:00
Daniel Stenberg
c375e5e5ad channel_free: ignore problems with channel_close()
As was pointed out in bug #182, we must not return failure from
_libssh2_channel_free() when _libssh2_channel_close() returns an error
that isn't EAGAIN. It can effectively cause the function to never go
through, like it did now in the case where the socket was actually
closed but socket_state still said LIBSSH2_SOCKET_CONNECTED.

I consider this fix the right thing as it now also survives other
errors, even if making sure socket_state isn't lying is also a good
idea.
2010-06-30 22:47:22 +02:00
Daniel Stenberg
46be03f92b publickey_list_free: no return value from a void function
Fixed a compiler warning I introduced previously when checking input
arguments more. I also added a check for the other pointer to avoid NULL
pointer dereferences.
2010-06-30 15:43:31 +02:00
Lars Nordin
1d83b520b4 openssl: make use of the EVP interface
Make use of the EVP interface for the AES-funktion. Using this method
supports the use of different ENGINES in OpenSSL for the AES function
(and the direct call to the AES_encrypt should not be used according to
openssl.org)
2010-06-27 22:23:50 +02:00
Tor Arntsen
f9c0a4a95a Don't overflow MD5 server hostkey
Use SHA_DIGEST_LENGTH and MD5_DIGEST_LENGTH in memcpy instead of hardcoded
values. An incorrect value was used for MD5.
2010-06-23 11:31:04 +02:00
Peter Stuge
7861ae8e4e Fix message length bugs in libssh2_debug()
There was a buffer overflow waiting to happen when a debug message was
longer than 1536 bytes.

Thanks to Daniel who spotted that there was a problem with the message
length passed to a trace handler also after commit
0f0652a3093111fc7dac0205fdcf8d02bf16e89f.
2010-06-23 11:16:02 +02:00
Peter Stuge
0f0652a309 Make libssh2_debug() create a correctly terminated string
Also use FILE *stderr rather than fd 2, which can very well be something
completely different.
2010-06-23 10:48:29 +02:00
TJ Saunders
2cc4a629ac handshake: Compression enabled at the wrong time
In KEXINIT messages, the client and server agree on, among other
things, whether to use compression. This method agreement occurs
in src/kex.c's kex_agree_methods() function. However, if
compression is enabled (either client->server, server->client, or
both), then the compression layer is initialized in
kex_agree_methods() -- before NEWKEYS has been received.

Instead, the initialization of the compression layer should
happen after NEWKEYS has been received. This looks to occur
insrc/kex.c's diffie_hellman_sha1(), which even has the comment:

    /* The first key exchange has been performed,

        switch to active crypt/comp/mac mode */

There, after NEWKEYS is received, the cipher and mac algorithms
are initialized, and that is where the compression should be
initialized as well.

The current implementation fails if server->client compression is
enabled because most server implementations follow OpenSSH's
lead, where compression is initialized after NEWKEYS. Since the
server initializes compression after NEWKEYS, but libssh2
initializes compression after KEXINIT (i.e. before NEWKEYS), they
are out of sync.

Reported in bug report #180
2010-06-23 00:03:31 +02:00
TJ Saunders
04f90b2265 userauth_hostbased_fromfile: packet length too short
The packet length calculated in src/userauth.c's
userauth_hostbased_fromfile() function is too short by 4 bytes;
it forgets to add four bytes for the length of the hostname.
This causes hostbased authentication to fail, since the server
will read junk data.

verified against proftpd's mod_sftp module
2010-06-22 23:34:21 +02:00
Daniel Stenberg
7dc2bfac94 _libssh2_userauth_publickey: reject method names longer than the data
This functions get the method length by looking at the first 32
bit of data, and I now made it not accept method lengths that are
longer than the whole data set is, as given in the dedicated
function argument.

This was detected when the function was given bogus public key
data as an ascii string, which caused the first 32bits to create
a HUGE number.
2010-06-20 00:23:28 +02:00
Daniel Stenberg
35cf08e130 NULL resistance: make more public functions survive NULL pointer input
Sending in NULL as the primary pointer is now dealt with by more
public functions. I also narrowed the userauth.c code somewhat to
stay within 80 columns better.
2010-06-18 20:25:03 +02:00
Daniel Stenberg
32bd0df992 agent: make libssh2_agent_userauth() work blocking properly
previously it would always work in a non-blocking manner
2010-06-18 20:13:08 +02:00
Peter Stuge
38940f45d2 Fix underscore typo for 64-bit printf format specifiers on Windows
Commit 49ddf447ff4bd80285f926eac0115f4e595f9425 was missing underscores.
2010-06-17 12:23:25 +02:00
Daniel Stenberg
537a00ee4b libssh2_session_callback_set: extended the man page 2010-06-16 00:12:24 +02:00
John
6ddcc493e8 LIBSSH2_DEBUG: macro uses incorrect function variable
The LIBSSH2_DEBUG macro, defined in libssh2_priv.h, incorrectly uses the
function variable ssh_msg_disconnect when it should use ssh_msg_debug.

This shows that the LIBSSH2_CALLBACK_DEBUG callback never has worked...
2010-06-16 00:04:25 +02:00
Daniel Stenberg
3496e1c2a2 warning: fix a compiler warning 'pointer differs in signedness'
As reported in bug #177
2010-06-15 19:51:26 +02:00
Daniel Stenberg
49ddf447ff portability: introduce LIBSSH2_INT64_T_FORMAT for 64bit printf()s
As pointed out in bug #177, some of the Windows compilers use
%I64 to output 64 bit variables with the printf family.
2010-06-15 19:47:31 +02:00
Daniel Stenberg
04d4bbb66b debug: avoid sending NULL to sprintf %s
Via the _libssh2_debug() macro/function. Pointed out by john in bug report
2010-06-15 17:00:02 +02:00
Daniel Stenberg
897f8463d8 sftp docs: show macro on macro page, only function on function page
The individual man pages for macros now show the full convenience
macro as defined, and then the man page for the actual function
only shows the function.
2010-06-14 20:04:29 +02:00
Daniel Stenberg
2fd044fdf5 code police: make the code use less than 80 columns 2010-06-14 17:23:00 +02:00
Daniel Stenberg
20e969d2e0 libssh2_channel_write_ex: remove macros, added wording on buffer size 2010-06-13 17:00:43 +02:00
Daniel Stenberg
33e2bc8785 libssh2_sftp_write: document buffer size and changed some ordering 2010-06-13 17:00:14 +02:00
Daniel Stenberg
d7e6f9cf27 libssh2_channel_write_stderr: show how the macro is defined 2010-06-13 16:59:40 +02:00
Daniel Stenberg
be7cee1b3e libssh2_channel_write: show how the macro is defined 2010-06-13 16:59:18 +02:00
Daniel Stenberg
518d25eba1 SFTP: limit write() to not produce overly large packets
sftp_write() now limits how much data it gets at a time even more
than before. Since this function creates a complete outgoing
packet based on what gets passed to it, it is crucial that it
doesn't create too large packets.

With this method, there's also no longer any problem to use very
large buffers in your application and feed that to libssh2. I've
done numerous tests now with uploading data over SFTP using 100K
buffers and I've had no problems with that.
2010-06-11 16:07:30 +02:00
Daniel Stenberg
1785d0d6f3 scp_write_nonblock: add transfer time info
Using the same timing logic and output format as
sftp_write_nonblock allows us to very easily run benchmarks on
SCP vs SFTP uploads using libssh2.
2010-06-11 16:05:22 +02:00
Daniel Stenberg
31d71a94f2 sftp_write_nonblock: select() on socket, use *BIG* buffer, time transfer
The select() is just to make it nicer so that it doesn't
crazy-loop on EAGAIN. The buffer size thing is mostly to verify
that this really work as supposed.

Transfer timing is just a minor thing, but it can just as well be
there and help us time and work on performance easier using out
of the box examples.
2010-06-11 16:03:33 +02:00
Daniel Stenberg
22a2de7347 agent: use _libssh2_error() when returning errors
As pointed out in bug report #173, this module basically never
used _libssh2_error() which made it work inconstently with other
parts of the libssh2 code base. This is my first take at making
this code more in line with the rest.
2010-06-11 13:32:41 +02:00
Daniel Stenberg
4cf935abab inputchecks: make lots of API functions check for NULL pointers
If an application accidentally provides a NULL handle pointer to
the channel or sftp public functions, they now return an error
instead of segfaulting.
2010-06-11 13:05:55 +02:00
Daniel Stenberg
cce6ebbee7 libssh2_channel_eof: clarify that it returns negative on errors 2010-06-11 13:02:00 +02:00
Daniel Stenberg
18605cb81f SFTP: keep the sftp error code as 32 bit
'last_errno' holds to the error code from the SFTP protocol and
since that is 32 bits on the wire there's no point in using a
long for this internally which is larger on some platforms.
2010-06-11 13:00:31 +02:00
Daniel Stenberg
3490b3fe10 agent: make the code better deal with unexpected code flows
agent->ops gets initialized by the libssh2_agent_connect() call
but we need to make sure that we don't segfault even if a bad
sequence of function calls is used.
2010-06-11 11:13:46 +02:00
Alexander Lamaison
c87a48ae4c Better handling of invalid key files.
Passing an invalid public key to libssh2_userauth_publickey_fromfile_ex
triggered an assertion.  Replaced this with a runtime check that rejects
obviously invalid key data.
2010-06-10 12:25:26 +01:00
Daniel Stenberg
ab8ee8abf3 version: we start working on 1.2.7 now 2010-06-10 10:31:18 +02:00
Daniel Stenberg
6e40af7bea NEWS: add the 1.2.6 release details 2010-06-10 10:19:31 +02:00
Daniel Stenberg
5e46c864dc RELEASE-NOTES: 1.2.6 details added 2010-06-10 10:15:46 +02:00
Guenter Knauf
a4fdf0de01 fixed libssh2.dsw to use the generated libssh2.dsp; removed old *.dsp files. 2010-06-10 02:43:49 +02:00
Guenter Knauf
2c1c751ad1 moved MSVC strdup define to libssh2_config.h which we include already. 2010-06-10 02:31:48 +02:00
Guenter Knauf
f682684fdd added missing source files to src/NMakefile. 2010-06-10 02:28:47 +02:00
Daniel Stenberg
0ad1a52a09 libssh2_poll: refer to poll(3) and select(3) instead 2010-06-08 08:37:37 +02:00
Daniel Stenberg
4e10882e06 example: fix strdup() for MSVC compiles
MSVC has a _strdup() that we better use. This was reported in bug
2010-06-07 13:36:12 +02:00
Daniel Stenberg
eeeebd02e7 SFTP: fail init SFTP if session isn't authenticated
Alexander Lamaison filed bug #172
(http://trac.libssh2.org/ticket/172), and pointed out that SFTP
init would do bad if the session isn't yet authenticated at the
time of the call, so we now check for this situation and returns
an error if detected. Calling sftp_init() at this point is bad
usage to start with.
2010-06-07 13:10:51 +02:00
Daniel Stenberg
f285438022 direct_tcpip: bring back inclusion of libssh2_config.h
In order to increase portability of this example, I'm bringing
the inclusion of libssh2_config.h back, and I also added an
require that header for this example to compile.

I also made all code lines fit within 80 columns.
2010-06-03 13:55:54 +02:00
Guenter Knauf
81912f67e7 cast away a warning. 2010-06-03 05:21:02 +02:00
Guenter Knauf
2996e02482 moved CRT_SECURE_NO_DEPRECATE define up so its defined before the winsock headers are included. 2010-06-03 03:12:20 +02:00
Guenter Knauf
2683fddcca fixed platform detection for MingW32 test makefile. 2010-06-01 21:19:14 +02:00
Guenter Knauf
fa5d6c705d MingW32 has gettimeofday() implemented, so proper ifdef this function here. 2010-06-01 21:09:08 +02:00
Guenter Knauf
b6c6470e7e removed MSVC ifdef since seems we can use __int64 still with latest headers. 2010-06-01 20:24:05 +02:00
Guenter Knauf
dceb3d1452 changed copyright notice for MinW32 and NetWare binaries. 2010-06-01 20:17:05 +02:00
Guenter Knauf
86c935317c cleaned up MSVC ifdefs which where spreaded over 3 places. 2010-06-01 19:32:11 +02:00
Guenter Knauf
aad74b7fa6 added uint8_t typedef for NetWare CLIB platform. 2010-06-01 19:08:19 +02:00
Guenter Knauf
0b593c8a9d if the function declaration gets changed the header should be changed too. 2010-06-01 17:28:46 +02:00
Guenter Knauf
8ff3f62786 this is MSVC specific and doesnt apply for all Win32 compilers;
the uint8_t typedef clashes with MingW32 headers.
2010-06-01 17:15:46 +02:00
Guenter Knauf
4d7b2950d9 updated MingW32 makefiles for latest dependency lib versions. 2010-06-01 16:58:40 +02:00
Guenter Knauf
18569d76de updated NetWare makefiles for latest dependency lib versions. 2010-06-01 16:44:17 +02:00
Dan Fandrich
7a088a8ab7 Fixed compiling with libgcrypt
A change of parameter types from unsigned long to size_t was
missed in the prototype in libgcrypt.h
2010-05-30 22:53:53 -07:00
Daniel Stenberg
d15663477b statvfs: use libssh2_sftp_statvfs only, no "_ex"
As the long-term goal is to get rid of the extensive set of
macros from the API we can just as well start small by not adding
new macros when we add new functions. Therefore we let the
function be libssh2_sftp_statvfs() plainly without using an _ex
suffix.

I also made it use size_t instead of unsigned int for the string
length as that too is a long-term goal for the API.
2010-05-28 17:25:42 +02:00
Grubsky Grigory
8145f9e79c DSP: output lib name typo 2010-05-25 23:28:01 +02:00
Grubsky Grigory
dc747fb221 win32: provide a uint8_t typedef for better building on windows 2010-05-25 23:22:39 +02:00
Daniel Stenberg
76fd96e63e agent: win32: fix bad _libssh2_store_str call
As pointed out by Grubsky Grigory <g.grubsky@securitycode.ru>, I
made a mistake when I added the _libssh2_store_str() call before
and I made a slightly different patch than what he suggested.
Based purely on taste.
2010-05-25 23:19:46 +02:00
Joey Degges
ed526a0e24 Add libssh2_sftp_statvfs() and libssh2_sftp_fstatvfs()
These can be used to get file system statistics from servers that
support the statvfs@openssh.com and fstatvfs@openssh.com extensions.
2010-05-24 07:05:23 +02:00
Jose Baars
667f4acda6 VMS specific: make sure final release can be installed over daily build 2010-05-22 11:06:08 +01:00
Jose Baars
f3208b99ca VMS: small improvement to the man2help utilities 2010-05-22 11:05:29 +01:00
Joey Degges
b702441242 libssh2_exit and libssh2_sftp_readdir man page fixes 2010-05-22 08:30:42 +02:00
Daniel Stenberg
396dcedc56 spelling: s/sue/use 2010-05-21 23:37:43 +02:00
Alexander Lamaison
798a808a2b Change magic port number for generic knownhost check.
libssh2_knownhost_checkp took 0 as a magic port number that indicated
a 'generic' check should be performed.  However, 0 is a valid port
number in its own right so this commit changes the magic value to any
negative int.
2010-05-21 00:01:57 +01:00
Mikhail Gusarov
c8df661129 Add re-discovered copyright holders to COPYING 2010-05-05 15:45:17 +07:00
Mikhail Gusarov
b3ed8e064a Restoring copyright statements from pre-git era
Eli Fant has contributed fragmenting SFTP requests
2010-05-05 15:44:15 +07:00
Mikhail Gusarov
ffb55aa2a3 Restoring my copyright statements from pre-git era
keyboard_interactive, 'exit-status' information packet, non-atomic read/write
under FreeBSD, multi-channel operation bugfixes.
2010-05-05 15:41:19 +07:00
Daniel Stenberg
9251642ef3 pedantic: make the code C90 clean 2010-05-03 22:16:01 +02:00
Peter Stuge
79b97c67c7 Do proper keyboard-interactive user dialog in the sftp.c example 2010-05-03 15:36:16 +02:00
Daniel Stenberg
b23ae2bf22 added to tarball: libssh2_knownhost_checkp.3 2010-05-03 09:45:53 +02:00
Daniel Stenberg
a3f3347c12 knownhost: support [host]:port in knownhost file
OpenSSH has ways to add hosts to the knownhosts file that include
a specific port number which makes the key associated with only
that specific host+port pair. libssh2 previously did not support
this, and I was forced to add a new function to the API to
properly expose this ability to applications:
libssh2_knownhost_checkp()

To *add* such hosts to the knownhosts file, you make sure to pass
on the host name in that manner to the libssh2_knownhost_addc()
function.
2010-05-02 16:56:31 +02:00
Daniel Stenberg
5184aec461 init/exit: mention these were added in 1.2.5 2010-05-01 23:49:45 +02:00
Daniel Stenberg
358aa3e24b libssh2_knownhost_check docs: correct the prototype 2010-05-01 23:35:16 +02:00
Daniel Stenberg
7bbefe0660 examples: avoid use of uninitialized variable 'sock' 2010-04-30 12:30:24 +02:00
Daniel Stenberg
204100e636 KEX: stop pretending we negotiate language
There was some stub-like parts of an implementation for
implementing kex language negotiation that caused clang-analyzer
to warn and as it did nothing I've now removed the dead code.
2010-04-29 23:57:47 +02:00
Daniel Stenberg
6c85370428 Uninitialized argument 2010-04-29 22:01:32 +02:00
Daniel Stenberg
23f02aad11 sftpdir: removed dead assignment 2010-04-29 22:00:05 +02:00
Daniel Stenberg
eb7581e72e Makefile.am: include the VMS-specific config header as well 2010-04-29 20:28:56 +02:00
Jose Baars
a16d67e250 Add VMS specific libssh2_config.h 2010-04-29 20:28:02 +02:00
Daniel Stenberg
ab81b75a8e fix Value stored to 's' is never read warning
and moved variable declaration of s to be more local
2010-04-28 23:28:26 +02:00
Daniel Stenberg
0c918ef72a kexinit: simplify the code and avoid scan-build warning
Previously it would say "Value stored to 's' is never read" due
fourth increment of 's'.
2010-04-28 23:28:26 +02:00
Alexander Lamaison
6c3f2ec815 Removed unecessary brackets. 2010-04-28 17:41:17 +01:00
Alexander Lamaison
f1df0b7fbc Changed sftp_attrsize macro to a static function. 2010-04-28 17:38:00 +01:00
Daniel Stenberg
6f895e3298 release: include the VMS-specific files 2010-04-28 13:28:54 +02:00
Daniel Stenberg
45210d8376 sftp_attrsize: protect the macro argument with proper parentheses 2010-04-28 10:23:40 +02:00
Daniel Stenberg
6a44eff0b5 ssh2_agent: avoid using 'session' uninitialized on failures 2010-04-28 09:13:22 +02:00
Daniel Stenberg
0862a1a39a examples: remove assignments of variable rc that's never used 2010-04-28 09:05:19 +02:00
Daniel Stenberg
514f4d9305 publickey_init: remove useless variable increment 2010-04-28 08:59:17 +02:00
Daniel Stenberg
d5d80d296a hostkey_method_ssh_rsa_init: remove useless variable increment 2010-04-28 08:57:56 +02:00
Daniel Stenberg
568060d266 packet_x11_open: removed useless variable increment
and made the declaration of a variable more local
2010-04-28 08:48:50 +02:00
Daniel Stenberg
6e2a0e603a packet_queue_listener: removed useless variable increment
and made the declaration of a variable more local
2010-04-28 08:47:30 +02:00
Daniel Stenberg
d811478071 sftp_read: move a read_responses array to where its used
I find that this increases readability since the array is used
only in the function call just immediately below and nowhere
else.
2010-04-28 00:39:23 +02:00
Daniel Stenberg
b979af1eee sftp_readdir: turn a small array static const and move it 2010-04-28 00:38:22 +02:00
Daniel Stenberg
37624b61e3 sftp_attrsize: converted function to a macro
This way, the macro can evaluate a static number at compile time
for two out of four uses, and it probably runs faster for the
other two cases too.
2010-04-28 00:23:09 +02:00
Daniel Stenberg
4c26a46362 sftp_open: deal with short channel_write calls
This was an old TODO that just wasn't done before. If
channel_write returns short, that is not an error.
2010-04-28 00:12:47 +02:00
Daniel Stenberg
77efca961d sftp_open: clean up, better check of input data
The clang-analyzer report made it look into this function and
I've went through it to remove a potential use of an
uninitialized variable and I also added some validation of input
data received from the server.

In general, lots of more code in this file need to validate the
input before assuming it is correct: there are servers out there
that have bugs or just have another idea of how to do the SFTP
protocol.
2010-04-27 23:59:55 +02:00
Daniel Stenberg
c28fa65424 bugfix: avoid using the socket if it failed to create one 2010-04-27 15:18:40 +02:00
Daniel Stenberg
03815483be bugfix: potential use of NULL pointer 2010-04-27 15:10:48 +02:00
Daniel Stenberg
67de62d650 libssh2_userauth_password_ex: clarify errors somewhat
The errors mentioned in this man page are possible return codes
but not necessarily the only return codes that this can return.

Also reformatted the typ prototypes somewhat.
2010-04-26 22:28:36 +02:00
Daniel Stenberg
cb42be1a9c examples: fixed and made them more similar
The channel read/write functions can return 0 in legitimate cases
without it being an error, and we need to loop properly if they
return short.
2010-04-26 16:49:30 +02:00
Jose Baars
c511177d39 VMS port of libssh2; changes in the libssh2 common code 2010-04-25 19:57:45 +02:00
Daniel Stenberg
d4edb0b9c3 Makefile: added the two news headers userauth.h and session.h 2010-04-25 19:52:36 +02:00
Daniel Stenberg
71fb9cc93e cleanup: prefer the internal functions
To get the blocking vs non-blocking to work as smooth as possible
and behave better internally, we avoid using the external
interfaces when calling functions internally.

Renamed a few internal functions to use _libssh2 prefix when not
being private within a file, and removed the libssh2_ for one
that was private within the file.
2010-04-25 19:35:43 +02:00
Daniel Stenberg
5163e4ecb8 session_free: remove dead code 2010-04-25 19:35:43 +02:00
Daniel Stenberg
000b0f73d0 libssh2_publickey_init: fixed to work better non-blocking
This was triggered by a clang-analyzer complaint that turned out
to be valid, and it made me dig deeper and fix some generic non-
blocking problems I disovered in the code.

While cleaning this up, I moved session-specific stuff over to a
new session.h header from the libssh2_priv.h header.
2010-04-25 19:35:43 +02:00
Daniel Stenberg
c5602fac58 channel: reduce duplicated free and returns
Simplified the code by trying to free data and return on a single
spot.
2010-04-25 19:35:43 +02:00
Daniel Stenberg
046ff03c3f channel: make variables more local
By making 'data' and 'data_len' more local in several places in
this file it will be easier to spot how they are used and we'll
get less risks to accidentally do bad things with them.
2010-04-25 19:35:43 +02:00
Mikhail Gusarov
d06f983c9c Fix typos in manpages, catched by Lintian 2010-04-24 23:43:07 +07:00
Daniel Stenberg
8620cc03f8 channel_request_pty: simplify the code
clang-analyzer pointed out how 'data' could be accessed as a NULL
pointer if the wrong state was set, and while I don't see that
happen in real-life the code flow is easier to read and follow by
moving the LIBSSH2_FREE() call into the block that is supposed to
deal with the data pointer anyway.
2010-04-24 13:14:12 +02:00
Daniel Stenberg
21f55d0006 libssh2_channel_process_startup: simplify the code
clang-analyzer pointed out how 'data' could be accessed as a NULL
pointer if the wrong state was set, and while I don't see that
happen in real-life the code flow is easier to read and follow by
moving the LIBSSH2_FREE() call into the block that is supposed to
deal with the data pointer anyway.
2010-04-24 13:11:05 +02:00
Daniel Stenberg
88ac2dd43c sftp_close_handle: add precation to not access NULL pointer
clang-analyzer pointed this out as a "Pass-by-value argument in
function call is undefined" but while I can't see exactly how
this can ever happen in reality I think a little check for safety
isn't such a bad thing here.
2010-04-24 13:03:27 +02:00
Daniel Stenberg
26d1698320 scp_write_nonblock: Value stored to 'nread' is never read 2010-04-24 12:58:34 +02:00
Daniel Stenberg
7dfeadef97 scp_write: Value stored to 'ptr' is never read 2010-04-24 12:57:32 +02:00
Daniel Stenberg
5804444936 scp_write_nonblock: Value stored to 'ptr' is never read 2010-04-24 12:56:53 +02:00
Daniel Stenberg
ee5dd3561d sftp_mkdir: less silly output but show failures 2010-04-24 12:56:13 +02:00
Jose Baars
ad1ec1c9e4 VMS port of libssh2 including VMS specific build procedures 2010-04-24 10:11:27 +02:00
Daniel Stenberg
28ef62be20 two variable types changes, made lines less than 80 columns
The two variable type changes are only to match type variable
fields actually read from the binary protocol.
2010-04-20 22:49:32 +02:00
Daniel Stenberg
1acca6e3ee remove check for negative padding_length
It was silly, since it is read as an unsigned char...
2010-04-20 22:48:40 +02:00
Daniel Stenberg
d3a0f2932b hostkey_method_ssh_dss_init: Value stored to 's' is never read 2010-04-18 15:31:46 +02:00
Daniel Stenberg
7adc23a628 libssh2_banner_set: avoid unnecessary increment and explain code 2010-04-18 15:30:03 +02:00
Daniel Stenberg
fca949ea55 agent_transact_unix: remove unused variable 2010-04-18 15:27:47 +02:00
Daniel Stenberg
f8b42cab86 remove two unnecessary increments 2010-04-18 15:26:41 +02:00
Daniel Stenberg
fea133f8d6 more code converted to use _libssh2_store_*() 2010-04-18 15:24:13 +02:00
Daniel Stenberg
9ba30d888e libssh2_publickey_list_fetch: removed unused variables 2010-04-18 15:20:29 +02:00
Daniel Stenberg
5d37cd44aa libssh2_publickey_init: remove unused variables 2010-04-18 15:18:18 +02:00
Daniel Stenberg
be9ee7095e libssh2_scp_send64: added to API to provide large file transfers
The previously existing libssh2_scp_send_ex() function has no way
to send files that are larger than 'size_t' which on 32bit
systems mean 4GB. This new API uses a libssh2_int64_t type and
should thus on most modern systems be able to send enormous
files.
2010-04-17 19:47:50 +02:00
Daniel Stenberg
9209309bc3 sftp_init: remove unused variables and assignments 2010-04-17 19:05:53 +02:00
Daniel Stenberg
2a069503be libssh2_knownhost_check: Value stored to 'keylen' is never read 2010-04-17 19:02:44 +02:00
Daniel Stenberg
182108ac91 hostkey: fix compiler warning 2010-04-17 13:38:20 +02:00
Daniel Stenberg
21a01c96f8 remove unused variable 2010-04-17 13:38:07 +02:00
Daniel Stenberg
100059989f data types: convert more to use size_t and uint32_t 2010-04-17 13:34:44 +02:00
Daniel Stenberg
13caffa00e channel: variable type cleanups 2010-04-17 13:27:17 +02:00
Daniel Stenberg
c3bcdd88a4 cleanups: better binary packet gen, size_t fixes and PACKET_* removal
I'll introduce a new internal function set named

 _libssh2_store_u32
 _libssh2_store_u64
 _libssh2_store_str

That can be used all through the library to build binary outgoing
packets.  Using these instead of the current approach removes
hundreds of lines from the library while at the same time greatly
enhances readability. I've not yet fully converted everything to
use these functions.

I've converted LOTS of 'unsigned long' to 'size_t' where
data/string lengths are dealt with internally. This is The Right
Thing and it will help us make the transition to our
size_t-polished API later on as well.

I'm removing the PACKET_* error codes. They were originally
introduced as a set of separate error codes from the transport
layer, but having its own set of errors turned out to be very
awkward and they were then converted into a set of #defines that
simply maps them to the global libssh2 error codes instead. Now,
I'l take the next logical step and simply replace the PACKET_*
defines with the actual LIBSSH2_ERROR_* defines. It will increase
readability and decrease confusion.

I also separated packet stuff into its own packet.h header file.
2010-04-17 13:18:15 +02:00
Daniel Stenberg
81e63b3657 clarified the return code 2010-04-17 09:55:24 +02:00
Daniel Stenberg
1adcb5234f rename libssh2_error to the correct _libssh2_error
We reserve ^libssh2_ for public symbols and we use _libssh2 as
prefix for internal ones. I fixed the intendation of all these
edits with emacs afterwards, which then changed it slightly more
than just _libssh2_error() expressions but I didn't see any
obvious problems.
2010-04-16 00:18:51 +02:00
Daniel Stenberg
9cc824e27b data type cleanup: made lots of code use size_t etc
A lot of code used 'unsigned long' and the likes when it should
rather just use plain 'int' or use size_t for data lengths.
2010-04-15 20:37:46 +02:00
Daniel Stenberg
2f9c105ec2 wait_socket: make c89 compliant and use two fd_sets for select() 2010-04-15 11:02:41 +02:00
Daniel Stenberg
8ab009c0b0 sftp_readdir: always zero terminate, detail the return code
I also added a description for the 'longentry' field which was
previously undocumented!
2010-04-15 01:16:02 +02:00
Daniel Stenberg
e22cdcea77 sftp_readdir: simplified and bugfixed
This function no longer has any special purpose code for the
single entry case, as it was pointless.

The previous code would overflow the buffers with an off-by-one
in case the file name or longentry data fields received from the
server were exactly as long as the buffer provided to
libssh2_sftp_readdir_ex.

We now make sure that libssh2_sftp_readdir_ex() ALWAYS zero
terminate the buffers it fills in.

The function no longer calls the libssh2_* function again, but
properly uses the internal sftp_* instead.
2010-04-15 01:15:35 +02:00
Daniel Stenberg
7f740368f4 channel/transport: we now drain the outgoing send buffer when we ignore EAGAIN
When we ignore the EAGAIN from the transport layer within channel_write, we
now drain the outgoing transport layer buffer so that remainders in that
won't cause any problems in the next invoke of _libssh2_transport_write()
2010-04-15 01:12:22 +02:00
Daniel Stenberg
8b63dc9e59 channel_write: if data has been sent, don't return EAGAIN
When sending data in a loop, we must not return EAGAIN if we
managed to send data in an earlier round. This was reported in
bug #126 => http://libssh2.stuge.se/ticket/126
2010-04-14 23:35:40 +02:00
Simon Josefsson
77fa740674 Fix OpenSSL AES-128-CTR detection.
Patch from Paul Howarth <paul@city-fan.org>.
2010-04-14 14:04:45 +02:00
Daniel Stenberg
32cf14b512 version in header file now says 1.2.6-DEV 2010-04-13 23:39:39 +02:00
Daniel Stenberg
44cd934fa2 1.2.6: clean the RELEASE-NOTES for next release round 2010-04-13 23:38:21 +02:00
Daniel Stenberg
339ad5ccd3 NEWS: add the stuff from the version 1.2.5 RELEASE-NOTES 2010-04-13 23:37:47 +02:00
Daniel Stenberg
0ecd0eb37c channel_close: no longer wait for the SSH_MSG_CHANNEL_CLOSE message
As the packet may simply not arrive we cannot have the close
function wait for it unconditionally.
2010-04-13 22:59:52 +02:00
Daniel Stenberg
f514bcac53 less code duplication in the poll vs select code flows
libssh2_keepalive_send and libssh2_session_block_directions are
now used outside of the #ifdef blocks.
2010-04-13 10:45:01 +02:00
Daniel Stenberg
79ee2f339e make it C90 compliant 2010-04-12 22:09:38 +02:00
Daniel Stenberg
12fd204ae4 updated with all changes and bugs since 1.2.4 2010-04-11 14:58:19 +02:00
Daniel Stenberg
2386a5a21c Added LIBSSH2_SFTP_S_IS***() macros and updated docs
libssh2_sftp_fstat_ex.3 is now extended quite a lot to describe a
lot of the struct and the bits it uses and how to test for them.
2010-04-11 11:26:16 +02:00
Daniel Stenberg
8b7e22cb33 sftp_init() deal with _libssh2_channel_write() returns short
When _libssh2_channel_write() is asked to send off 9 bytes, the
code needs to deal with the situation where less than 9 bytes
were sent off and prepare to send the remaining piece at a later
time.
2010-04-01 20:25:49 +02:00
Daniel Stenberg
1d49f1bc21 handle a NULL password as if it was ""
libssh2_userauth_publickey_fromfile_ex() takes a "passphrase"
but didn't deal with it being set to NULL.
2010-03-29 17:19:58 +02:00
Daniel Stenberg
1711917c2c Reduce used window sizes by factor 10
As reported in bug report #166 http://libssh2.stuge.se/ticket/166
by 'ptjm', the maximum window size must be less crazy for libssh2
to do better with more server implementations. I did not do any
testing to see how this changes raw SCP performance, but the
maximum window size is still almost 4MB. This also has the upside
that libssh2 will use less memory.
2010-03-28 15:36:58 +02:00
Peter Stuge
b6ed60d2cc Correctly clear blocking flag after sending multipart packet
commit 7317edab61d2179febc38a2c2c4da0b951d74cbc cleared the outbound
blocking bit when send_existing() returned PACKET_NONE and *ret=0, as
opposed to before even calling send_existing(), but because *ret=1 when
sending parts 2..n of an existing packet, the bit would only be cleared
when calling libssh2_transport_write() for a new packet.

Clear the direction flag after the final part of a packet has been sent.
2010-03-28 01:35:55 +01:00
Daniel Stenberg
79acf60ae6 Added man page for libssh2_knownhost_addc()
Added mention in libssh2_knownhost_add() docs that
libssh2_knownhost_addc() is the preferred function now.
2010-03-24 15:39:46 +01:00
Daniel Stenberg
7810656564 at next soname bump remove libssh2_knownhost_add() 2010-03-24 15:39:13 +01:00
Daniel Stenberg
4bc10aa728 ignore TAGS ("make tags" makes them) 2010-03-24 15:38:44 +01:00
Daniel Stenberg
5512d0d593 fix memory leak
we must not assign the pointer a NULL since it keeps allocated
data and at least parts of an error string
2010-03-23 23:16:08 +01:00
Daniel Stenberg
05f9fb878e fixed the pattern for avoiding the poll check
added some comments about known problems with poll on darwin
2010-03-23 22:50:53 +01:00
Daniel Stenberg
f314f3b5fd avoid checking for poll on some systems
darwin and interix are known to have broken poll implementations
so we skip the check on those and thus have them use select
unconditionally
2010-03-23 22:00:31 +01:00
Daniel Stenberg
eb4407975c ignore libssh2.dsp 2010-03-23 21:59:12 +01:00
Simon Josefsson
6d253324be Fix logic in "on-the-fly" crypto init. 2010-03-23 21:09:32 +01:00
Simon Josefsson
aebcc45a37 Make sure keepalive is working even when poll is used. 2010-03-23 21:08:47 +01:00
Paul Querna
1decccbb52 Use poll when available on blocking API.
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2010-03-23 20:48:58 +01:00
Peter Stuge
4c09324b02 Fix speling 2010-03-20 02:45:46 +01:00
Daniel Stenberg
6d4b1bbb45 fix NULL dereference when window adjusting a non-existing channel
Suyog Jadhav pointed out that when receiving a window adjust to
a channel not found, the code would reference a NULL pointer.
Now it will instead output a message about that fact.
2010-03-19 14:58:05 +01:00
Simon Josefsson
5456163507 Fix build problem. 2010-03-19 09:40:50 +01:00
Simon Josefsson
7301036421 Eat our own dog food, call libssh2_init and libssh2_exit in the examples. 2010-03-19 09:35:00 +01:00
Simon Josefsson
fa4017c613 Fix init/exit logic. Add self-test of it. 2010-03-19 09:27:19 +01:00
Daniel Stenberg
2e3f380ff2 fix typo 2010-03-19 09:23:47 +01:00
Simon Josefsson
6c3c3e1b49 Add man page for libssh2_init and libssh2_exit. Fix libssh2_exit prototype. 2010-03-19 09:21:48 +01:00
Simon Josefsson
55ede3b41b Shorten constant a bit. More documentation. 2010-03-19 09:17:42 +01:00
Simon Josefsson
d00283927f Fix namespace pollution. 2010-03-19 09:14:21 +01:00
Simon Josefsson
9ea5b0625e Add global init/exit points, to do crypto initialization in one place.
By Lars Nordin.
2010-03-19 09:05:52 +01:00
Daniel Stenberg
1b1b4ac387 libssh2 is released under the Modifed BSD license, not GPL 2010-03-14 23:30:46 +01:00
Alexander Lamaison
9abf81de97 Add libssh2_knownhost_addc to handle comments.
Comments in known_hosts file were not handle properly.  They were parsed as
part of the key causing key matching to return a mismatch if the entry had a
comment.  This adds a new API function that takes an optional comment and
changes libssh2_knownhost_readline to parse the comment as pass it to the
new function.

Fixes #164.
2010-03-14 19:52:00 +00:00
Alexander Lamaison
c585828d2b Fix gettimeofday to compile with Visual C++ 6.
Reported by Steven Van Ingelgem.
2010-03-12 11:29:31 +00:00
Simon Josefsson
e54786cf2e Add. 2010-03-10 18:50:29 +01:00
Simon Josefsson
4cfeade243 keepalive.c: Fix libssh2_error usage. 2010-03-10 13:16:32 +01:00
Simon Josefsson
60ff0a2ade Fix typo in last commit. 2010-03-10 13:13:48 +01:00
Simon Josefsson
64c97765a5 Tidy up build option notice. 2010-03-10 13:13:19 +01:00
Simon Josefsson
ab66ff488b Add entry about keep alive stuff. 2010-03-10 13:10:57 +01:00
Simon Josefsson
0d331aade1 Add keep-alive support. 2010-03-10 13:08:42 +01:00
Alexander Lamaison
69520e1564 Untabify. 2010-03-07 17:12:56 +00:00
Alexander Lamaison
f87f4ab836 Fix memory leak in libssh2_knownhost_add. 2010-03-07 16:20:07 +00:00
Daniel Stenberg
b3556c2e0c change 'int' to 'libssh2_socket_t' in the public API for sockets 2010-03-06 19:51:58 +01:00
Daniel Stenberg
1f406feaa4 reduce code duplication and return underlying error better 2010-03-03 23:57:22 +01:00
Daniel Stenberg
c0436fc602 acknowledge when _libssh2_packet_requirev() returns error
when _libssh2_packet_requirev() returns an error when waiting for
SSH_MSG_USERAUTH_SUCCESS or SSH_MSG_USERAUTH_FAILURE, it is an
error and it should be treated as such
2010-03-03 23:44:54 +01:00
Daniel Stenberg
0034a83e4c wrap long lines 2010-03-03 23:44:24 +01:00
Daniel Stenberg
f0f4ba92f0 polished the phrasing in two error strings 2010-03-03 23:37:58 +01:00
Daniel Stenberg
c29ba827e4 silence picky compiler warnings 2010-03-03 23:33:25 +01:00
Daniel Stenberg
a03e1b0457 silence picky compiler warnings 2010-03-03 23:32:56 +01:00
Daniel Stenberg
d4a768af4e removed libssh2_error()'s forth argument
libssh2_error() no longer allocates a string and only accepts a const
error string. I also made a lot of functions use the construct of
return libssh2_error(...) instead of having one call to
libssh2_error() and then a separate return call. In several of those
cases I then also changed the former -1 return code to a more
detailed one - something that I think will not change behaviors
anywhere but it's worth keeping an eye open for any such.
2010-03-03 23:04:05 +01:00
Daniel Stenberg
d377c3065a repaired --enable-debug 2010-03-03 22:51:15 +01:00
Simon Josefsson
51fcb11d60 Make ./configure output a summary of build options. 2010-03-01 17:01:47 +01:00
Daniel Stenberg
8bbc109e52 let the err_msg in the session struct be const too 2010-03-01 13:16:19 +01:00
Simon Josefsson
0ef84144ac Revert #ifdef change that pulled in AES-CTR code when explicitly disabled. 2010-03-01 13:09:18 +01:00
Daniel Stenberg
ef27023eb9 fix #ifdefs 2010-03-01 11:42:38 +01:00
Daniel Stenberg
a9621548f8 make function match the new proto 2010-03-01 11:42:04 +01:00
Simon Josefsson
a925bdd5bb Improve AES-CTR check. 2010-03-01 11:38:50 +01:00
Daniel Stenberg
3420e9858c use const to silence a bazillion warnings 2010-03-01 11:05:40 +01:00
Simon Josefsson
2de339b2f7 Use AES-CTR from OpenSSL when available.
Reported by Lars Nordin <Lars.Nordin@SDlabs.se>.
2010-03-01 10:34:00 +01:00
Simon Josefsson
c46cbd46e2 Make it possible to disable DSA.
Patch from Lars Nordin <Lars.Nordin@SDlabs.se>.
2010-03-01 10:30:22 +01:00
Peter Stuge
16af813b81 Send and receive channel EOF before sending SSH_MSG_CHANNEL_CLOSE
Sending SSH_MSG_CHANNEL_CLOSE without channel EOF is explicitly allowed
in RFC 4254, but some non-conforming servers will hang or time out when
the channel is closed before EOF.

Other common clients send and receive EOF before closing, there are no
drawbacks, and some servers need it to work correctly.
2010-03-01 06:43:53 +01:00
Alexander Lamaison
a2157c8391 Style improvements to knownhost error handling.
Made improvements as suggested by Peter Stuge: http://www.libssh2.org/mail/libssh2-devel-archive-2010-02/0161.shtml.
2010-02-26 18:47:54 +00:00
Alexander Lamaison
942a40b482 Call libssh2_error for every knownhost API failure.
The libssh2 API calls should set the last error code and a message when
returning a failure by calling libssh2_error.  This changeset adds these
calls to the libssh2_knownhost_* API as well as libssh2_base64_decode.

This change also makes libssh2_error into a function rather than a macro.
Its implementation is moved to misc.c.  This function returns the error
code passed to it allowing callers to return the error value directly
without duplicating the error code.
2010-02-24 13:45:00 +00:00
Alexander Lamaison
ef096220ce Fix LIBSSH2_ALLOC checks.
These appear to be cut-and paste errors where the wrong variable is checked
for NULLness after calling LIBSSH2_ALLOC.
2010-02-23 22:00:40 +00:00
Simon Josefsson
e4232e531b Silence compiler warning. 2010-02-23 15:49:47 +01:00
Simon Josefsson
cdc1366b2c Make it portable; test uses = for string comparison (not ==). Indent. 2010-02-23 15:27:18 +01:00
Alexander Lamaison
3e1a95392e libssh2_knownhost_del: fix write to freed memory.
When removing a known host, libssh2_knownhost_del would remove the node from the linked list, free its memory and then overwrite the struct parameter (which indicated which node to remove) with 0.  However, this struct is actually allocated within the just-freed node meaning we're writing to freed memory.  This made Windows very upset.

The fix is simply to overwrite the struct first before freeing the memory.
2010-02-22 14:50:08 +00:00
Daniel Stenberg
b4f12e153a show more verbose error when SCP send fails 2010-02-21 19:29:23 +01:00
Daniel Stenberg
bd5519c7a2 libssh2_socket_t is done, a library-free function is needed 2010-02-21 19:20:07 +01:00
Daniel Stenberg
05b1bb3cd3 clarify that this frees all data associated with a session 2010-02-21 19:16:30 +01:00
Daniel Stenberg
dea503df73 improved error handling 2010-02-21 19:08:14 +01:00
Daniel Stenberg
c5609acb17 add missing libssh2_error() calls
To make sure the public API is functional and that the
BLOCK_ADJUST_ERRNO() macro works correctly we MUST make sure to
call libssh2_error() when we return errors.
2010-02-18 13:20:11 +01:00
Daniel Stenberg
37c08983a3 fix memory leak in userauth_keyboard_interactive()
Mr anonymous in bug #125 pointed out that the userauth_keyboard_interactive()
function does in fact assign the same pointer a second time to a new allocated
buffer without properly freeing the previous one, which caused a memory leak.
2010-02-18 13:04:29 +01:00
Daniel Stenberg
72ae0866cb added missing error codes
To allow the libssh2_session_last_error() function to work as
documented, userauth_password() now better makes sure to call
libssh2_error() everywhere before it returns error.

Pointed out by mr anonymous in bug #128
2010-02-18 00:01:33 +01:00
Peter Stuge
2149244cfe Fix resource and memory leaks in examples as reported by cppcheck
Thanks to Ettl Martin for the report and patch. This fixes #132
2010-02-16 13:21:57 +01:00
Daniel Stenberg
a491017f5a mention the new man pages for macros 2010-02-15 14:29:04 +01:00
Daniel Stenberg
ec699ef684 added man pages for API macros
all #defined macros in the public headers are considered to be part
of the API and I've generated individual man pages for each of them
to A) make it easier to figure out what each function/macro actually
is for so that automated lookups work better and for B) make sure we
have all public functions document (both macros and functions) to
make it easier for us to work away from all the macros in a future
release.
2010-02-15 14:24:40 +01:00
Daniel Stenberg
514104b37d Committed the patch by Yoichi Iwaki in bug #2929647
Committed the patch by Yoichi Iwaki in bug #2929647, which fixed a memory
leak when an 'outbuf' was still allocated when a session was freed.
2010-02-15 00:15:30 +01:00
Daniel Stenberg
4d13c6e59b free "outbuf" when killing a session
Fix memoary leak: if there was an "output" still allocated when a
session was torn down it needs to be freed in session_free()

Patch by Yoichi Iwaki in bug #2929647
2010-02-15 00:12:10 +01:00
Daniel Stenberg
72a28f6b16 the working version name is now 1.2.5_DEV 2010-02-13 17:18:55 +01:00
Daniel Stenberg
c889058cb3 updated info for 1.2.4 2010-02-13 17:10:30 +01:00
Dan Fandrich
69c876e210 Allow compiling with OpenSSL when AES isn't available. 2010-02-10 14:49:17 -08:00
Dave McCaldon
10f5c70ac0 Fix Tru64 socklen_t compile issue with example/direct_tcpip.c
Building libssh2-1.2.3 on Tru64 fails at line 48 and 166 because socklen_t
isn't defined on Tru64 unless _POSIX_PII_SOCKET is defined.

This patch updates configure.ac to add -D_POSIX_PII_SOCKET when building
on Tru64 platform(s).
2010-02-09 11:45:40 +01:00
Dave McCaldon
ea914c8b72 Resolve compile issues on Solaris x64 and UltraSPARC
Solaris builds of libssh2-1.2.3 failed on both x64 and UltraSPARC
platforms because of two problems:

1) src/agent.c:145 sun is a reserved word when using the SUNWspro compiler
2) example/direct_tcpip.c:84 INADDR_NONE is not defined
2010-02-09 11:19:52 +01:00
Daniel Stenberg
64a6c255ec towards 1.2.4 now 2010-02-03 19:36:19 +01:00
Daniel Stenberg
e09d6ac653 Version 1.2.3 (February 3, 2010) 2010-02-03 19:23:28 +01:00
Daniel Stenberg
91841731af fix building out of source tree by proving better include path
when building out of source tree, we provide -I$(top_builddir)/example
since the libssh2_config.h gets generated in that dir
2010-02-03 19:21:12 +01:00
Sofian Brabez
a190437c4a Replace : in hexdump with " " (two spaces) 2010-02-01 16:30:47 +01:00
Peter Stuge
68a900d27a Detect when the forwarded connection is closed in example/direct_tcpip.c 2010-01-30 00:45:56 +01:00
Peter Stuge
e4b7baa885 Fix example/direct_tcpip.c to work also on WIN32
read() and write() are no good for WIN32 sockets, use recv() and send().
2010-01-30 00:35:05 +01:00
Peter Stuge
2622bbaf33 Ignore libssh2_config.h.in and stamp-h2 in example/ and remove .cvsignore 2010-01-30 00:25:46 +01:00
Peter Stuge
d3dbe4c81e Simplify WIN32 ifdefs in example/direct_tcpip.c to allow standalone compile 2010-01-30 00:01:51 +01:00
Peter Stuge
095ccbf825 Always #define INVALID_SOCKET -1 in libssh2_priv.h when not on win32
Fix broken builds since commit abd9bd0bbe631efeada1f54552c70b54e1c490c1
for all non-win32 platforms.
2010-01-29 23:51:38 +01:00
Peter Stuge
8eafded280 Include hmac-md5 and hmac-md5-96 only if crypto backend supports MD5 2010-01-29 23:22:56 +01:00
Peter Stuge
6df87e64b7 Use LIBSSH2_HOSTKEY_HASH_SHA1 instead of _MD5 in examples and tests
MD5 support is optional and may not always be available, while SHA1 is both
required and recommended.
2010-01-29 23:06:31 +01:00
Peter Stuge
3ddac8ac66 Update mailing list address in configure.ac to @cool.haxx.se 2010-01-29 22:31:40 +01:00
Peter Stuge
6c543545fe Make example/direct_tcpip.c compile for win32
One warning from FD_SET() remains, it is also in some other examples.
2010-01-29 20:35:24 +01:00
Peter Stuge
abd9bd0bbe Correctly check for an invalid socket in session_startup() 2010-01-29 20:29:01 +01:00
Peter Stuge
5dd4005ace Small documentation fix after Dave's _USERAUTH_FAILURE improvement 2010-01-29 09:16:39 +01:00
Dave McCaldon
8f102b8f56 Handle SSH_MSG_USERAUTH_FAILURE for password and kbd-int authentication
Neither libssh2_userauth_password_ex() nor
libssh2_userauth_keyboard_interactive_ex() would return a login failure
error if the server responded with a SSH_MSG_USERAUTH_FAILURE, instead
you would see whatever previous error had occurred, typically
LIBSSH2_ERROR_EAGAIN.

This patch changes error code -18 to LIBSSH2_ERROR_AUTHENTICATION_FAILED
and makes LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED an alias for
LIBSSH2_ERROR_AUTHENTICATION_FAILED.  In addition, new logic in
userauth_password() properly handles SSH_MSG_USERAUTH_FAILURE and both
this function and userauth_keyboard_interactive() now properly return
LIBSSH2_ERROR_AUTHENTICATION_FAILED.
2010-01-29 09:14:11 +01:00
Simon Josefsson
7d71f92a9c Fix. 2010-01-28 15:06:40 +01:00
Simon Josefsson
f6fab0d9ea Also deal with GLOBAL_REQUEST keep-alives. 2010-01-28 15:03:24 +01:00
Simon Josefsson
cc7f90f1d4 Make OpenSSH-style keepalive work against libssh2 clients. 2010-01-28 14:30:25 +01:00
Daniel Stenberg
6d55714ab5 clarified 2010-01-27 14:57:12 +01:00
Dave McCaldon
6b23f640f8 Fix trace context lookup in libssh2_debug()
The trace context is actually a bitmask so that tracing output can be
controlled by setting a bitmask using libssh2_trace().  However, the logic
in libssh2_debug() that converted the context to a string was using the
context value as an array index.  Because the code used a bounds check on
the array, there was never a danger of a crash, but you would certainly
either get the wrong string, or "unknown".

This patch adds a lookup that iterates over the context strings and uses
it's index to check for the corresponding bit in the context.
2010-01-26 17:33:25 +01:00
Peter Stuge
2cb8866f0a Fix typo in RELEASE-NOTES 2010-01-21 20:55:53 +01:00
Daniel Stenberg
3b3e13366e updated for 1.2.3 with all the stuff I found in the log 2010-01-20 19:57:42 +01:00
Daniel Stenberg
9f4292433a ignore more generated files 2010-01-20 19:46:36 +01:00
Dave McCaldon
f077984394 Pass user context through libssh2_trace_sethandler() to callback
The libssh2_trace_sethandler() call allows the user to handle the output of libssh2 rather than having it written to stderr.  This patch updates libssh2_trace_sethandler() to allow a user-defined void* context value to be passed back to the output handler.
2010-01-20 19:42:09 +01:00
Dave McCaldon
44eba0c993 Add libssh2_trace_sethandler() to the API (even more) 2010-01-15 22:58:44 +01:00
Dave McCaldon
474e38119b Add libssh2_trace_sethandler() to the API 2010-01-15 22:57:20 +01:00
Daniel Stenberg
7f27b0822d cleanup includes
We now produce a local libssh2_config.h file in this dir for the
examples to use so I cleaned up the include path at the same time.
2010-01-13 22:21:09 +01:00
Daniel Stenberg
e3d8c1cfed generate a libssh2_config.h in the example dir
buildconf copies the template to example/ and configure makes sure
to generate a proper file from it and the direct_tcpip.c example
is the first one to use it - to make sure it builds fine on more
paltforms
2010-01-13 13:46:56 +01:00
Simon Josefsson
11a114ee7c Remove redundant #includes and reorder sys/types.h include. 2010-01-13 11:03:26 +01:00
Daniel Stenberg
e48907ee05 avoid a free(NULL) 2010-01-10 00:00:31 +01:00
Simon Josefsson
3f6bc287f9 Make it simpler to get more debug info. 2010-01-07 19:43:40 +01:00
Daiki Ueno
e84fe88526 Simplify the commit 63457dfa using type cast from size_t * to ulong *. 2010-01-01 17:51:42 +09:00
Alexander Lamaison
73e37b3b49 Fixed memory leak in userauth_publickey().
userauth_publickey_fromfile() reads the key from a
file using file_read_publickey() which returns two
allocated strings, the decoded key and the key
method (such as "ssh-dss").  The latter can be
derived from the former but returning both avoids a
later allocation while doing so.

Older versions of userauth_publickey_fromfile() used
this method string directly but when
userauth_publickey() was factored out of
userauth_publickey_fromfile() it derived the method
from the key itself.  This resulted in the method
being allocated twice.

This fix, which maintains the optimisation that
avoids an extra allocation, changes
userauth_publickey() so it doesn't allocate and
derive the method when userauth_pblc_method already
has a value.

Signed-off-by: Alexander Lamaison <awl03@doc.ic.ac.uk>
2009-12-30 04:18:36 +00:00
Daiki Ueno
7926c9cfaa Fix the return value description of libssh2_knownhost_free(). 2009-12-25 10:26:51 +09:00
Daiki Ueno
63457dfa6c Fix compiler warnings for size_t pointers on 32-bit Windows. 2009-12-25 10:21:15 +09:00
Daiki Ueno
d00e97a7f1 Define INVALID_SOCKET and use it instead of SOCKET_BAD.
Revert the part of previous commit that defines SOCKET_BAD library wide.
2009-12-25 10:04:34 +09:00
Daiki Ueno
8436e45ea6 Use libssh2_socket_t in the ssh-agent stuff.
Define a portability macro SOCKET_BAD which means "invalid socket".
2009-12-24 19:45:57 +09:00
Daiki Ueno
0b6e37872d Mark/unmark connection to Pageant is open/close. 2009-12-24 17:57:15 +09:00
Daiki Ueno
1b3b7b2214 Add test to check if the socket is connected. 2009-12-24 16:49:28 +09:00
Peter Stuge
6a249d7b6c Add libssh2.pc to top-level .gitignore 2009-12-24 02:18:40 +01:00
Peter Stuge
87e32272f9 Fix publickey authentication regression
Commit 70b199f47659a74b8778c528beccf893843e5ecb introduced a parsing
bug in file_read_publickey() which made the algorithm name contain an
extra trailing space character, breaking all publickey authentication.
2009-12-24 02:18:40 +01:00
Peter Stuge
bd0505d6b9 Add a direct-tcpip example which shows local port forwarding 2009-12-24 02:18:39 +01:00
Peter Stuge
f70dbfa3e6 Add session parameter and LIBSSH2_TRACE_SOCKET to libssh2_trace(3) man page 2009-12-24 02:18:39 +01:00
Peter Stuge
a2452d7eee Add TODO: Expose error messages sent by the server 2009-12-24 02:18:39 +01:00
Daiki Ueno
bbb2f29037 Fix doc comments. 2009-12-23 09:12:31 +09:00
Daiki Ueno
3138b5891f Add man pages for ssh-agent API. 2009-12-23 09:12:02 +09:00
Daiki Ueno
c573af83de Don't request userauthlist after authentication. 2009-12-23 07:59:37 +09:00
Simon Josefsson
ea8babf6d1 Add. 2009-12-21 12:30:17 +01:00
Daiki Ueno
db26c4eace Add an example to use ssh-agent API.
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2009-12-21 12:19:33 +01:00
Daiki Ueno
7b351eed36 Add ssh-agent API.
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2009-12-21 12:19:20 +01:00
Daiki Ueno
58abc7e30b Add callback-based API for publickey auth.
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2009-12-21 12:15:33 +01:00
Simon Josefsson
0a3b350012 Move examples from example/simple to example/. 2009-12-19 10:56:03 +01:00
Simon Josefsson
b5e358618b Move examples from example/simple to example/. 2009-12-19 10:54:45 +01:00
Daniel Stenberg
dd81bda112 _libssh2_list_insert() fixed to work
While this is code not currently in use, it is part of the generic linked
list code and since I found the error I thought I'd better fix it since we
might bring in this function into the code one day.
2009-12-17 11:35:54 +01:00
Simon Josefsson
12433b4511 Silence compiler warnings.
Based on patch by Kamil Dudka <kdudka@redhat.com> in
<http://www.mail-archive.com/libssh2-devel@cool.haxx.se/msg00796.html>.
2009-12-16 16:14:55 +01:00
Kamil Dudka
39cbd17e19 libgcrypt: simplify code of _libssh2_dsa_sha1_sign
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2009-12-16 16:08:25 +01:00
Kamil Dudka
1f91ab049f libgcrypt: follow-up for ssh-dss padding fix
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2009-12-16 16:08:21 +01:00
Dan Fandrich
f2e5b49904 Check for the right environment variable in the test app 2009-12-15 15:21:06 -08:00
Simon Josefsson
b4c0821332 Silence warning about unused function parameter.
Reported by Steven Van Ingelgem <steven@vaningelgem.be>.
2009-12-14 15:50:41 +01:00
Daniel Stenberg
70b199f476 avoid returning data to memory already freed
In case of failure we must make sure that the data we return
doesn't point to a memory area already freed. Reported anonymously
in the bug report #2910103.
2009-12-10 23:40:44 +01:00
Peter Stuge
d142f385da Use LIBSSH2_TRACE_* internally and remove redundant LIBSSH2_DBG_* 2009-12-08 08:52:03 +01:00
Peter Stuge
1a491c6f00 Add LIBSSH2_TRACE_SOCKET context for tracing send() and recv()
Helpful in debugging the -39 errors.
2009-12-08 08:40:30 +01:00
Peter Stuge
1256c61815 Another transport layer fix for bogus -39 (LIBSSH2_ERROR_BAD_USE) errors
Commit 683aa0f6b52fb1014873c961709102b5006372fc made send_existing() send
more than just the second part of a packet when the kernel did not accept
the full packet, but the function still overlooked the SSH protocol
overhead in each packet, often 48 bytes.

If only the last few bytes of a packet remained, then the packet would
erroneously be considered completely sent, and the next call to write
more data in the session would return a -39 error.
2009-12-08 07:33:05 +01:00
Daniel Stenberg
95f559a926 move local variable to be more localized 2009-12-06 19:14:36 +01:00
Daniel Stenberg
052a68db30 fixed some indent mistakes 2009-12-06 19:14:36 +01:00
Peter Stuge
1aba38cd7d Fix padding in ssh-dss signature blob encoding
DSA signatures consist of two 160-bit integers called r and s. In ssh-dss
signature blobs r and s are stored directly after each other in binary
representation, making up a 320-bit (40 byte) string. (See RFC4253 p14.)

The crypto wrappers in libssh2 would either pack r and s incorrectly, or
fail, when at least one integer was small enough to be stored in 19 bytes
or less.

The patch ensures that r and s are always stored as two 160 bit numbers.
2009-12-06 08:07:40 +01:00
Peter Stuge
7317edab61 Don't always clear write direction blocking flag
When libssh2_transport_write() is called to continue sending a
partially sent packet the write direction flag must not be cleared
until the previous packet has been completely sent, or the app would
hang if the packet still isn't sent completely, since select() gets
called by the internal blocking emulation layer in libssh2 but would
then not be watching the socket for writability.

Clear the flag only once processing of previous packet data is
complete and a new packet is about to be prepared.
2009-11-27 07:52:26 +01:00
Alexander Lamaison
e642e2c202 Detabify. 2009-11-24 14:54:10 +00:00
Daniel Stenberg
f07cf3afd3 Fixed memory leak in sftp_fstat(). 2009-11-24 14:45:46 +00:00
Simon Josefsson
1e350754f6 Mark date of 1.2.2 release. 2009-11-17 09:51:12 +01:00
Simon Josefsson
55031fa320 Merge branch 'master' of ssh://git.stuge.se/var/lib/git/libssh2 2009-11-17 09:50:12 +01:00
Daniel Stenberg
355fbf4d5b prepared for 1.2.2 2009-11-16 22:43:55 +01:00
Simon Josefsson
74c63852d7 Improve NEWS items. 2009-11-16 16:24:36 +01:00
Simon Josefsson
ebbd7c879b Support AES-Counter ciphers. 2009-11-16 16:04:00 +01:00
Simon Josefsson
b78f854d8b Silence compiler warning.
Reported by Steven Van Ingelgem <steven@vaningelgem.be>
in <http://thread.gmane.org/gmane.network.ssh.libssh2.devel/2566>.
2009-11-04 14:47:00 +01:00
Simon Josefsson
1f0d47fa92 Mention libssh2-style.el. 2009-10-29 10:39:15 +01:00
Simon Josefsson
463e09e55f Use memmove instead of memcpy on overlapping memory areas.
Reported by Bob Alexander <balexander@expressor-software.com> in
<http://thread.gmane.org/gmane.network.ssh.libssh2.devel/2530>.
2009-10-28 15:31:00 +01:00
Simon Josefsson
82bf39dbfa Add. 2009-10-28 15:29:36 +01:00
Simon Josefsson
e5f170bae2 Protect against crash on too small SSH_MSG_IGNORE packets.
Reported by Bob Alexander <balexander@expressor-software.com>
in <http://thread.gmane.org/gmane.network.ssh.libssh2.devel/2530>.
2009-10-28 15:27:11 +01:00
Simon Josefsson
fc60563840 add copyright line 2009-10-27 20:32:24 +01:00
Simon Josefsson
b38b4fb859 support arcfour128 cipher per RFC 4345 2009-10-27 20:03:30 +01:00
Cristian Rodríguez
3182045c2d add support for GCC visibility features 2009-10-21 17:02:12 +02:00
Simon Josefsson
60d73d5663 less hard coding of cipher mode in libgcrypt backend 2009-10-19 17:36:50 +02:00
Juzna
1e80194b97 libssh2_channel_forward_accept() and listening fixes
The forward accepting was not done right before, and the
packet_queue_listener function didn't assign a necessary
variable. All fixed by Juzna. I (Daniel) modified the
forward_accept() change somewhat.
2009-10-18 03:41:25 +02:00
Daniel Stenberg
0c13f7beda added man page for libssh2_knownhost_free 2009-10-18 03:03:55 +02:00
Daniel Stenberg
b859f4d9d2 more CVS => DEV conversions 2009-10-17 21:36:57 +02:00
Daniel Stenberg
13092c5a5e remove references to "CVS" 2009-10-17 21:36:05 +02:00
Daniel Stenberg
22b73235d3 we are on the 1.2.2 track nowadays 2009-10-17 21:34:49 +02:00
Peter Stuge
55034294e8 Ensure that win32/libssh2.dsp will be generated with CRLF line endings
First, win32/msvcproj.{head,foot} are now committed with CRLF line endings,
and .gitattributes specifies that these should not be changed on checkout or
commit. These are win32 files so it makes sense to store them with native
line endings.

Second, the rules for generating libssh2.dsp and libssh2.vcproj are changed
so that the full file contents passes through awk, which strips all CR and
then prints each line with one CRLF line ending. Stripping CR is important
to avoid CRCRLF in case the input already comes with CRLF.
2009-10-17 02:58:53 +02:00
Dan Fandrich
5e80055d22 Make sure permissions on the private host key file is tight enough that
sshd doesn't complain. Quote $srcdir to try to cope with embedded spaces.
2009-09-29 15:27:17 -07:00
Peter Stuge
11ca8d5583 Clarify the scp_write examples slightly and use an octal mask for the mode 2009-09-30 00:12:23 +02:00
Daniel Stenberg
9162fd7e61 1.2.1 preparations 2009-09-29 13:20:32 +02:00
Daniel Stenberg
7208e8d0d9 remove ChangeLog and win32/libssh2.dsp only at make distclean 2009-09-28 14:21:56 +02:00
Simon Josefsson
e1bb074287 Fix shell usage. 2009-09-23 09:39:47 +02:00
Daniel Stenberg
e887ffca4c clarify that the paths are the remote ones 2009-09-22 23:54:10 +02:00
Daniel Stenberg
65d1cb8107 let hpux systems build with _REENTRANT defined as well 2009-09-22 23:46:45 +02:00
Daniel Stenberg
4ed82f0e78 updated to match reality
I went over the commit log and added what I believe is all notable
changes and bugfixes since the 1.2 release
2009-09-20 20:14:23 +02:00
Peter Stuge
3cc2f143c1 Fix scp examples to loop correctly over libssh2_channel_write() 2009-09-20 01:35:19 +02:00
Peter Stuge
683aa0f6b5 Fix transport layer bug causing invalid -39 (LIBSSH2_ERROR_BAD_USE) errors
The channel layer sends packets using the transport layer, possibly
calling _libssh2_transport_write() many times for each packet.

The transport layer uses the send_existing() helper to send out any
remaining parts of previous packets before a new packet is started.

The bug made send_existing() consider the entire packet sent as soon as it
successfully sent the second part of a packet, even if the packet was not
completely done yet.
2009-09-20 00:30:42 +02:00
Neil Gierman
7a9d36903a Added gettimeofday() function for win32
Neil Gierman's patch adds a gettimeofday() function for win32
for the libssh2_trace() functionality. The code originates from
cygwin and was put in the public domain by the author
Danny Smith <dannysmith@users.sourceforge.net>
2009-09-19 22:39:50 +02:00
Daniel Stenberg
c2375dbfa4 libssh2_channel_read_ex() must return 0 when closed
If the channel is already at EOF or even closed at the end of the
libssh2_channel_read_ex() function and there's no data to return,
we need to signal that back. We may have gotten that info while
draining the incoming transport layer until EAGAIN so we must not
be fooled by that return code.
2009-09-16 23:46:30 +02:00
Dan Fandrich
906a7d8866 Ignore tags file 2009-09-16 07:49:32 -07:00
Dan Fandrich
1418993a0f Some platforms need sys/socket.h included before netinet/in.h.
Fixed an unused variable compiler warning.
2009-09-16 07:49:32 -07:00
Daniel Stenberg
c4b7f0394b libssh2_channel_wait_closed() could hang
libssh2_channel_wait_closed() had a bad loop waiting for the
channel to close, as it could easily miss the info and then if
the socket would be silent from that moment the funtion would
hang if in blocking-mode or just return EAGAIN wrongly to the
app. The drain-transport loop now correctly checks if the close
has arrived.
2009-09-16 13:49:04 +02:00
Daniel Stenberg
9e84b999a5 make libssh2_scp_send/recv do blocking mode correctly
Somehow I had completely missed to make the libssh2_scp_send/recv
functions support the blocking mode the correct way so when I
cleaned up things the other day blocking mode broke for them...
Fixed now.
2009-09-15 23:29:46 +02:00
Guenter Knauf
3fda91d725 changed NetWare test makefile static link order 2009-09-08 01:32:45 +02:00
Guenter Knauf
7c32c84d0e removed conditional sources from Makefile.inc
added ifdef blocks to libgcrypt.c, pem.c, openssl.c
2009-09-07 18:10:49 +02:00
Simon Josefsson
766127ad57 Fix compilation errors. 2009-09-07 14:14:10 +02:00
Guenter Knauf
a9e7f87e31 some more NetWare build fixes. 2009-09-06 06:57:55 +02:00
Guenter Knauf
a04a0b6c69 some more NetWare makefile fixes. 2009-09-06 06:31:59 +02:00
Guenter Knauf
1f8d58a4ce added sys/select.h include to samples for fd_set on NetWare. 2009-09-06 06:15:29 +02:00
Guenter Knauf
4b482eddbe accept CFLAGS from environment. 2009-09-06 04:36:51 +02:00
Guenter Knauf
05eb612f8e some more .cvsignore / .gitignore fixes. 2009-09-04 02:23:28 +02:00
Guenter Knauf
d48ee98ecf renamed .cvsignore to .gitignore. 2009-09-04 02:12:50 +02:00
Guenter Knauf
536443246e changed conditional into make language. 2009-09-04 01:24:38 +02:00
Guenter Knauf
b728b1018f changed NetWare and MingW32 makefile to use Makefile.inc. 2009-09-03 22:06:59 +02:00
Daniel Stenberg
3f5a6662d0 CVS leftovers removed 2009-09-02 22:41:47 +02:00
Daniel Stenberg
33f4e0f250 libssh2_version() exists since 1.1 2009-09-02 22:39:48 +02:00
Hacki
8dabb1c5eb added knownhost.c to makefiles. 2009-09-02 20:03:27 +02:00
Alexander Lamaison
0d6aaa1f56 Pass private-key to OpenSSL as a filename with BIO_new_file().
This keeps all FILE* handling on the OpenSSL side of the DLL boundary avoiding crashes on Windows while removing the need for libssh2 to read the private key file into memory.  This is now done by OpenSSL which is likely to do a better job of it.
2009-09-02 14:59:40 +01:00
Daniel Stenberg
00fac145ba generate and install libssh2.pc
oh these are necessary libssh2.pc changes too
2009-09-01 10:04:13 +02:00
Daniel Stenberg
f65f71a156 first take at producing and installing a pkg-config file 2009-09-01 09:55:25 +02:00
Daniel Stenberg
3142e8df7e renamed to .ac 2009-09-01 09:51:14 +02:00
Daniel Stenberg
bffefb12ea renamed to the modern name "configure.ac" 2009-09-01 09:48:14 +02:00
Daniel Stenberg
feadd5f321 always braces and else and brace on the same line removed
I don't follow those particular guidelines myself so I think I'd
rather remove them here and keep my style than the opposite. As
I am the most frequent writer of code for the moment.
2009-09-01 09:42:33 +02:00
Daniel Stenberg
7c139633a1 _libssh2_channel_write() only sends the 32K first bytes
In theory we could split larger buffers into several smaller
packets to pass to transport_write(), but for now we instead only
deal with the first 32K in this call and assume the app will call
this function again with the rest!  The 32K size is a
conservative limit based on the text in RFC4253 section 6.1.
2009-08-30 23:52:11 +02:00
Daniel Stenberg
692401633a document _libssh2_channel_write's return code 2009-08-30 19:46:42 +02:00
Daniel Stenberg
5bb1fb5cbc s/libssh2_channel_write_ex/_libssh2_channel_write internally 2009-08-30 19:31:07 +02:00
Daniel Stenberg
5e5ead00b4 call libssh2_error() when transport_write() returns EAGAIN
_libssh2_channel_write() should never return error without
libssh2_error() getting called
2009-08-30 19:28:43 +02:00
Daniel Stenberg
06278728e2 clarify that zero can be returned without meaning error 2009-08-30 17:07:50 +02:00
Daniel Stenberg
0357befa42 remove debug leftovers 2009-08-30 17:06:57 +02:00
Daniel Stenberg
85198c1cdb channel_read() was changed to _libssh2_channel_read() as lots of
internal code was changed to use that instead of wrongly using
libssh2_channel_read_ex(). Some files now need to include
channel.h to get this proto.

channel_read() calls libssh2_error() properly on transport_read()
failures

channel_read() was adjusted to not "invent" EAGAIN return code in
case the transport_read() didn't return it

channel_close() now returns 0 or error code, as
documented. Previously it would return number of bytes read in
the last read, which was confusing (and useless).
2009-08-30 17:00:49 +02:00
Daniel Stenberg
face4750ca changed all return EAGAIN to return the variable instead
I made this change just to easier grep for "return .*EAGAIN" cases
as they should be very rare or done wrongly. Already worked to find
a flaw, marked with "TODO FIXME THIS IS WRONG" in channel.c. I also
fixed a few cases to become more general returns now when we have
more unified return codes internally.
2009-08-25 00:54:47 +02:00
Daniel Stenberg
a1365916c7 _libssh2_channel_write() must not invent EAGAIN situations
it is important that only the transport layer can generate EAGAIN
error codes so that we limit where we need to set direction bits
and more. When the local window is too small to send data we simply
stop trying to send and (risk) returning zero in
_libssh2_channel_write()
2009-08-25 00:25:08 +02:00
Daniel Stenberg
f64a84a909 error code cleanup 2009-08-25 00:23:34 +02:00
Daniel Stenberg
fba3877ed8 remove all libssh2pack_t leftovers 2009-08-24 23:57:15 +02:00
Daniel Stenberg
f1e010f5d4 removed the libssh2pack_t type
and a minor _libssh2_transport_read() simplification
2009-08-24 23:50:53 +02:00
Daniel Stenberg
9e96acf86e fix return codes, shortened a very long function name 2009-08-24 23:49:58 +02:00
Daniel Stenberg
1a157d27cc remove use of libssh2_channel_receive_window_adjust
_libssh2_channel_receive_window_adjust is the new replacement that
is both the correct internal version instead of the external API one,
and it has the return code flaw fixed. I also fixed more return
codes to pass long the correct error found.
2009-08-24 23:24:35 +02:00
Daniel Stenberg
b3418bb1eb more proper return codes, added a missing libssh2_error() call 2009-08-24 23:23:46 +02:00
Daniel Stenberg
08be841b4d clear socket_block_directions bits before send/recv
These two places are the only places where send and recv are called
outside of transport.c so make sure they clear/set the bits correctly.
2009-08-24 23:22:39 +02:00
Daniel Stenberg
e39128df52 simplified fullpacket, clarified _libssh2_transport_write() comment 2009-08-24 23:13:14 +02:00
Daniel Stenberg
5c6b8166c7 cleaned up _libssh2_packet_add()
removed some code duplication, changed a few return -1 to return
error codes instead and added a missing libssh2_error() invoke
2009-08-24 23:03:08 +02:00
Daniel Stenberg
dcb9625473 convert return -1 instances to return [proper error code] 2009-08-24 22:50:46 +02:00
Daniel Stenberg
c1b687c9e4 simplify code by removing code duplication 2009-08-24 22:44:22 +02:00
Daniel Stenberg
13e920d4ef fix several return -1 to return a proper error code
On many places in the code there have been laziness return -1
statements lying around that should be fixed to return sensible
error codes. Here's a take at fixing a few offenders.
2009-08-24 22:28:27 +02:00
Daniel Stenberg
314e61e545 change transport to use unified error codes
I added three new public error codes, and then modified the return
codes we use in the transport layer to use the generic error codes
so that there won't be any risk of internal confusions due to
different error code sets.
2009-08-24 22:27:11 +02:00
Daniel Stenberg
13c16db3bc changes from int to libssh2_socket_t for sokcets
modified two functions to use libssh2_socket_t instead of int
when referring to a socket descriptor
2009-08-24 14:13:00 +02:00
Daniel Stenberg
82c3f0ba72 introducing libssh2_socket_t type and fixed iovec for windows
Steven Van Ingelgem introduces libssh2_socket_t as a generic socket
type to use internally to avoid compiler warnings and mistakes. Also,
the private struct iovec declaration for windows is now made to look
like the POSIX struct does.
2009-08-24 14:07:05 +02:00
Daniel Stenberg
9e099fb88a linked list changes and minor bug fixes 2009-08-20 01:03:40 +02:00
Daniel Stenberg
415efe10ac linked list code is now converted to new functions 2009-08-20 01:00:54 +02:00
Daniel Stenberg
4b1cb4e95e remove superfluous braces and re-indent somewhat 2009-08-20 00:59:23 +02:00
Daniel Stenberg
d8b6f3c7b8 move over lots of code to the _libssh2_list_* functions
and I fixed a few minor bugs at the same time
2009-08-20 00:56:54 +02:00
Daniel Stenberg
a871f0b214 converted listeners to the linked list functions 2009-08-20 00:56:54 +02:00
Daniel Stenberg
08cad8e14c moved the handling of SFTP handles to new linked list code
Each SFTP file handle is now handled by the "mother-struct"
using the generic linked list functions. The goal is to move
all custom linked list code to use this set of functions.

I also moved the list declarations to the misc.h where they
belong and made misc.h no longer include libssh2_priv.h itself
since now libssh2_priv.h needs misc.h...

In misc.c I added a #if 0'ed _libssh2_list_insert() function
because I ended up writing one, and I believe we may need it here
too once we move over more stuff to use the _libssh2_list* family.
2009-08-20 00:56:54 +02:00
Daniel Stenberg
46178378f2 correct the comment for _libssh2_list_add()
it adds the new node to the _end_ of the list
2009-08-20 00:56:54 +02:00
Steven Van Ingelgem
28b179ecf2 Suppress signed/unsigned comparison warning. 2009-08-16 23:14:20 +01:00
Daniel Stenberg
7b4d6b2868 added contributors from the 1.2 release notes 2009-08-11 10:11:11 +02:00
Simon Josefsson
fbe4737719 Need to use $(EXEEXT) on programs in TESTS to fix mingw cross-compiles. 2009-08-11 02:46:45 +02:00
Daniel Stenberg
ce4ad0d086 start working on 1.2.1 2009-08-10 22:58:15 +02:00
Daniel Stenberg
291ac7d433 Version 1.2 (August 10, 2009) 2009-08-10 20:07:17 +02:00
Daniel Stenberg
cccaa868f5 revert parts of the b95fe985af3c80a2babcaaaf7da69a15b1237c49 commit
Alexander Lamaison tracked down that my previous commit broke SFTP
reads in some aspects. The reversion now gets back to always recv()
until EAGAIN is returned so that the code no longer treats a short
read as an indication that it is "enough for now".

The bad commit in particular had another independent change included,
which is to clear the direction-bits first in the transport read
and write functions, but this reversion does not revert that change.
Clearing those bits first is a good thing.
2009-08-07 11:33:59 +02:00
Daniel Stenberg
08b0183d8e Fix some nroff formatting
Patch by Sofian Brabez
2009-08-06 15:56:27 +02:00
Alexander Lamaison
231a97a95f Replaced calls to OpenSSL FILE-pointer functions.
Passing a FILE* argument across a DLL boundary causes problems on Windows.  Instead the keys are read into memory by libssh2 and passed to the OpenSSL functions as BIO* arguments.
2009-08-02 23:20:20 +01:00
Daniel Stenberg
6c46bb4719 Add missing names
I went over the NEWS and git log outputs and added all mentioned
contributors through the project's history. I want us to make an
effort to give credit to everyone who contributes, big or small.
2009-07-31 16:07:33 +02:00
Daniel Stenberg
8a0ba6f5f6 fix the C99 variadic macro use for _libssh2_debug()
George Neill pointed out that the C99 vararg marcro use was
wrong, and I edited his suggested patch slightly and unified
both prec99-GCC and C99 into the same macro.
2009-07-29 22:03:40 +02:00
Daniel Stenberg
143720e922 Include RELEASE-NOTES in the release package 2009-07-29 14:38:06 +02:00
Daniel Stenberg
0cad4c08e9 Release notes for the pending release
I hope to maintain this file during development so that we also add
changes and bugfixes to it when we change things. Makes the daily
snapshots better and makes less of a hurdle when the release day
comes.
2009-07-29 14:35:42 +02:00
Daniel Stenberg
dd38d0a929 bad debugdump() causes SIGSEGV, partial sends not done right
The anonymous bug report #2822910 pointed out that debugdump() was
stupidly called within the send_existing() function. At closer
inspection was the report not only right, but it also revealed
another problem to me: when the _libssh2_send() function returns
after sending only a part of the buffer, it would then misbehave.
This probably is very rare though, which must be the reason we
haven't seen a bigger problem with this.
2009-07-28 19:57:02 +02:00
Simon Josefsson
ba57d5ae3c Silcen compiler warnings. 2009-07-28 13:27:43 +02:00
Daniel Stenberg
5ac67d1268 added two new issues to fix: socket type and better windowing
* make sure the windowing code adapts better to slow situations so that it
  doesn't then use as much memory as today

* Introduce a 'libssh2_socket_t' type for sockets in internal code
2009-07-27 23:58:06 +02:00
Daniel Stenberg
6f4463e81f remove superfluous check for large packets
as we're already doing the correct check further down anyway there's no point
in doing the (wrong) check further up as well. Paul Veldkamp pointed this out.
2009-07-27 22:54:18 +02:00
Simon Josefsson
690c3d42db Fix make distcheck problems. 2009-07-22 23:34:31 +02:00
Daniel Stenberg
2b780fa02d parts of the previous VS project files commit 2009-07-18 00:35:38 +02:00
Daniel Stenberg
b363c84366 From: Neil Gierman <ngierman@roadrunn.com>
Makefile changes to generate MSVS project files

- I integrated the libssh2_lib.dsp and libssh2_dll.dsp into a single
libssh2.dsp with different targets for lib vs dll
- Since I run Visual Studio 2008 with VC++9 I did not do vcproj files since
I would have newer vc8proj.head|foot than what others will be running
- My patch only has changes to Makefile.am's. I noticed that Makefile.in's
are included in the daily snapshots but they should be generated from the
.am's
- The 3 new files are msvcproj.head and msvcproj.foot for the beginning and
ending of the dsp file, and a new Makefile.inc that will have the source and
header file names. NOTE: All new source files will need to be added to
Makefile.inc and NOT Makefile.am now.
- I moved the win32 dir before the include dir
- I modified the dsw file so it points to the new libssh2.dsp project file
2009-07-18 00:23:25 +02:00
Daniel Stenberg
35a9d4bc62 From: Alexander Lamaison <swish@lammy.co.uk>
Make the public headers includable on their own
2009-07-17 23:40:32 +02:00
Daniel Stenberg
686db51284 From: Steven Van Ingelgem <steven@vaningelgem.be>
check first for libtoolize, and then for glibtoolize

Mac OS X (and others?) needs this
2009-07-17 23:38:41 +02:00
Daniel Stenberg
2361f50e9a Fix knownhost checking of non-hashed hosts
From: Ben Kibbey <bjk@luxsci.net>
2009-07-12 07:05:00 +02:00
Daniel Stenberg
e5d76b5468 Fix the functionality again with hashed host names again.
The breakage came with commit 8b46528c0476af50a43b6e619f2db318a0cad194.
2009-07-12 00:03:37 +02:00
Peter Stuge
7eead1461b Update mailing list URL to new address 2009-07-10 20:11:29 +02:00
Daniel Stenberg
c0d032a45c const'ify two arguments to libssh2_knownhost_check() 2009-07-10 00:54:59 +02:00
Daniel Stenberg
0751067c2f Fix compiler warnings appearing with VS2008. Based on Steven Van Ingelgem's
patch in #2787839 with a bunch of additional edits by yours truly.
2009-07-07 13:44:17 +02:00
Daniel Stenberg
acbdbb8914 Applied Francois Dupoux's extra checks for weird packet or padding length in
incoming packets. We really need to bail out this way on weird input.
bug report #2814613
2009-07-07 13:26:42 +02:00
Daniel Stenberg
bea1beb4fd Mark McPherson posted bug report #2815836 pointing out that the custom memory
functions were not given the correct data as argument. This is now fixed even
if I personally don't quite grasp why abstract is passed as a pointer to
pointer all over libssh2...
2009-07-07 13:09:11 +02:00
Daniel Stenberg
5b599fbf40 Ben Kibbey added a type parameter to the libssh2_session_hostkey() function,
which hasn't yet been in a public release so changing the API is fine!
2009-07-07 00:25:17 +02:00
Daniel Stenberg
75bec57c94 Guenter Knauf fixed this example to build on win32 2009-07-02 11:46:51 +02:00
Daniel Stenberg
b9b5e5fea5 corrected (again) 2009-07-02 11:44:54 +02:00
Daniel Stenberg
91bca481b5 clarify 2009-07-02 00:11:33 +02:00
Daniel Stenberg
9a6ce012cc Neil Gierman pointed out in bug report #2809163 that these two files cannot
include the public libssh2.h header as it breaks the compile on window. I'll
adapt to this now, but in the long run I think we should rather fix the
includes so that we _can_ include the public headers properly.
2009-06-26 20:43:56 +02:00
Daniel Stenberg
a4c3f0d0a3 fixed the length check in knownhost_writeline() since <= is actually good
enough when the size includes the trailing zero
2009-06-14 14:29:15 +02:00
Daniel Stenberg
320450201a After a mention from Ben Kibbey we now let knownhost_writeline() return the
length of the actual data it returns, excluding the trailing zero. I also
updated the man page for libssh2_knownhost_writeline() accordingly.
2009-06-14 14:27:15 +02:00
Daniel Stenberg
9f5c1caa81 empty line removed 2009-06-14 14:26:27 +02:00
Daniel Stenberg
8b46528c04 Ben Kibbey fixed the hostline() when parsing lines using only one hostname 2009-06-10 20:46:11 +02:00
Daniel Stenberg
aeaf07576e Merge branch 'master' of ssh://bagder@git.stuge.se/var/lib/git/libssh2 2009-06-09 00:00:26 +02:00
Daniel Stenberg
c01e147a40 Provide a libssh2_scp_send() API for files larger than 4GB (32bit size) 2009-06-08 16:10:37 +02:00
Daniel Stenberg
32080def94 Olivier Hervieu provided this x11 forwarding example. This is the version
after my initial cleanup that I posted to the list on May 26th 2009. It still
has a few ugly spots that should be cleaned up, but until then it's will at
least be found in the repo. For this reason I don't add this to the makefile.
2009-06-05 09:04:24 +02:00
Daniel Stenberg
da1230b35b New man page for libssh2_session_hostkey(3). We probably need to improve this
to also return the type of the key.
2009-06-05 09:02:56 +02:00
Daniel Stenberg
d440995a80 Add check for and use of the _REENTRANT define for Solaris so that libssh2
is then properly thread-safe on that OS. These autuconf macros are straight
from the cURL project and were mostly written by Yang Tse. They were only
very slightly edited by me when imported to here.
2009-06-04 20:23:23 +02:00
Tor Arntsen
2a142a6524 Ignore generated files 2009-06-04 18:20:29 +02:00
Daniel Stenberg
afcf63b433 use the correct #if condition for strtoll(), pointed out in bug report 2009-06-04 00:36:34 +02:00
Daniel Stenberg
bc4c258842 define the HAVE_LIBSSH2_KNOWNHOST_API to the version number 1.1.1 to make apps
know that when this define exists, the API exists. And the version number can
be used for run-time checks. 1.1.1 is not likely to be the release version as
I think we'll go with 1.2 instead but 1.1.1 OR LATER should still work.
2009-05-29 23:04:52 +02:00
Daniel Stenberg
e52a1057fd libssh2_knownhost_add() got an additional argument: 'store' so that an
application can get a pointer back to the internal representation of the host
it just added. Useful for example when the app wants to add a host, and then
convert that exact same host to a line for storing in a known host file.
'store' can also be set to NULL to simple not care.
2009-05-29 18:40:29 +02:00
Daniel Stenberg
517909d37a Added a call to libssh2_knownhost_writefile()
Updated to the slightly modified libssh2_knownhost_check() proto
2009-05-29 14:10:54 +02:00
Daniel Stenberg
8cd76af353 "struct libssh2_knownhost" is now part of the internal struct for each known
host so we now only return pointers to structs instead of having the app
allocate a full struct

I moved the private struct definition into knownhosts.c instead of exposing it
wider in libssh2_priv.h

I thus modified the proto for two functions that previously used 'struct
libssh2_knownhost *' to receive data.
2009-05-29 14:08:24 +02:00
Daniel Stenberg
1d31dadc1e when a host is added, we must make sure the app also provides a key *type* even
though we don't use the type in this function
2009-05-29 13:58:04 +02:00
Daniel Stenberg
2e990194ab Added man pages for the two newest members of the knownhosts API family:
libssh2_knownhost_readline() and libssh2_knownhost_writeline()
2009-05-29 10:12:22 +02:00
Daniel Stenberg
1afbbf4507 introducing libssh2_knownhost_writeline() and some cleanups to use more
defined error codes instead of the simplified -1 previously used a little too
much here
2009-05-29 10:00:45 +02:00
Daniel Stenberg
82bdd12a8b I think *readline() makes a better name 2009-05-29 00:19:02 +02:00
Daniel Stenberg
4df48aef41 clarify that the key "string" needs to be zero terminated too 2009-05-29 00:14:41 +02:00
Daniel Stenberg
bc28d0146d introducing libssh2_knownhost_read() that makes libssh2 read a single given
line
const'ified a few args to libssh2_knownhost_add() as well
2009-05-29 00:08:00 +02:00
Daniel Stenberg
8b1ec197b2 fix a warning for a comparison mixing signed and unsigned types 2009-05-28 22:54:37 +02:00
Daniel Stenberg
2436a4de60 After review/feedback/discussions on the mailing list. Rename two functions:
s/libssh2_knownhost_parsefile/libssh2_knownhost_readfile
s/libssh2_knownhost_dumpfile/libssh2_knownhost_writefile
2009-05-28 19:57:54 +02:00
Daniel Stenberg
22014f074b define removed 2009-05-28 16:12:24 +02:00
Daniel Stenberg
f35dbff3c4 LIBSSH2_KNOWNHOST_TYPE_DEFAULT is not a good idea, scrap it 2009-05-28 14:36:16 +02:00
Daniel Stenberg
703fbd9d11 Added the initial man pages for the 7 new functions for known host handling 2009-05-28 14:35:13 +02:00
Daniel Stenberg
5207690edf first shot at implementing libssh2_knownhost_dumpfile() and some minor
cleanups
2009-05-28 13:14:32 +02:00
Daniel Stenberg
eaa95e0331 introducing libssh2_knownhost_get() to the public API 2009-05-27 16:00:52 +02:00
Daniel Stenberg
d965dda027 clarified a comment 2009-05-26 11:18:29 +02:00
Daniel Stenberg
bf884488ae slighty better behavior and comments 2009-05-26 11:18:00 +02:00
Daniel Stenberg
28b08e0b4d remove include since we don't use struct iovec in this file 2009-05-26 11:14:07 +02:00
Daniel Stenberg
1ffa2cb519 These examples no longer need to explictly set the socket to non-blocking state
as libssh2 itself will always do that by itself.
2009-05-26 09:41:13 +02:00
Daniel Stenberg
279d6dd82a add myself as copyright owner 2009-05-25 11:35:06 +02:00
Daniel Stenberg
49192598d2 mention conversion of code to the new linked list code 2009-05-25 11:29:39 +02:00
Daniel Stenberg
6b7c19ec26 remove #if 0'ed code 2009-05-25 11:23:06 +02:00
Daniel Stenberg
160e5aa763 clarify the fix, as it wasn't a leak 2009-05-25 11:03:24 +02:00
Daniel Stenberg
42e9f02025 spell fix a comment 2009-05-25 10:58:13 +02:00
Daniel Stenberg
5a162ad9f8 Added some clarifying comments on how the 'sftpInit_sftp' and
'sftpInit_channel' struct fields within the session struct are used. And made
sure to clear them both correctly when sftp_init() returns instead of at
shutdown time, as it must not touch them at shutdown time. This should make it
possible to properly make more than one SFTP handle.
2009-05-25 10:50:49 +02:00
Daniel Stenberg
6ff83eab1b no need for LIBSSH2_ERROR_MEMORY when LIBSSH2_ERROR_ALLOC already exist!
added my own copyright line too now
2009-05-25 10:41:07 +02:00
Daniel Stenberg
8df3222d91 use LIBSSH2_ERROR_ALLOC instead of introducing a new error code 2009-05-25 10:40:36 +02:00
Daniel Stenberg
0357ce6c48 clear session->sftpInit_sftp unconditionally 2009-05-24 23:51:59 +02:00
Daniel Stenberg
c5f335ad4f Fix my recent session->sftpInit_sftp fix which wasn't correct. The memory area
does not need to be freed (it already gets freed) but clearing the pointer is
a good idea. And it should be done _after_ the channel_free() call.
2009-05-24 23:44:52 +02:00
Daniel Stenberg
fdc043e7b1 add an assert to help debugging 2009-05-24 23:44:23 +02:00
Daniel Stenberg
fdaa5ad5b4 Without CVS we must not use cvs tools to generate the changelog. I'm not
confident enough with git to attempt to make one so I'll just make a dummy for
now.
2009-05-23 23:03:31 +02:00
Daniel Stenberg
f1f49c3cce - Anonymous bug report #2795816 revealed that libssh2_sftp_shutdown() did not
properly free/cleanup the SFTP handle so libssh2 leaked memory and caused
   an assert() on subsequent libssh2_sftp_init() calls on the same session.
2009-05-23 22:30:43 +02:00
Daniel Stenberg
ad13de92d4 Fix _libssh2_channel_write(): fixed the write loop to also read from the
transport layer better, to avoid draining the window size when sending large
packets. I also fixed the return code for it to return the number of bytes
handled in this single invoke (and not the cumulative amount).
2009-05-20 14:34:30 +02:00
Daniel Stenberg
b755f3eb10 First, only try to send max packet size *4 to channel write, as trying to send
much larger packages only cause internal problems and much larger allocations.

Also fix sftp_write() when _libssh2_channel_write() returns that a packet was
only partially sent as that is not an error.

Fixed a few error messages to more accurately point out the problem
2009-05-20 14:31:46 +02:00
Daniel Stenberg
b95fe985af If recv() returns something less than the full buffer we know we're done for
now, so skip looping and doing another read that then simply will cause an
EAGAIN as it may trick the user into believing things that aren't true.
2009-05-20 14:30:05 +02:00
daniel
035cb24fa0 remove the old style as it makes little sense to mention here anymore 2009-05-14 17:01:54 +02:00
Daniel Stenberg
18e03739be typo 2009-05-12 10:10:55 +00:00
Daniel Stenberg
e367e1ad4e comment typo and some indent fixes 2009-05-12 10:07:30 +00:00
Daniel Stenberg
f7149d1830 Partial fix based on the patch and discussions in #2788319 2009-05-12 09:33:22 +00:00
Daniel Stenberg
042b545247 clear the passed in struct when the entry has been removed to help prevent
mistakes due to re-use
2009-05-12 09:32:51 +00:00
Daniel Stenberg
4490c6b434 use a better example file name for the known_hosts file 2009-05-07 20:30:22 +00:00
Daniel Stenberg
d3542e6f7d split out the knownhost code from hostkey.c into its own separate source file
now: knownhost.c
2009-05-07 17:21:56 +00:00
Daniel Stenberg
0cee15dc0c this was never supposed to be added for real 2009-05-07 17:21:14 +00:00
Daniel Stenberg
4b991b232d My knownhost work as of right now. It works at least partly. More tests and
tweaks will come.
2009-05-07 13:09:48 +00:00
Daniel Stenberg
4bc1b8a1d7 get host, user, password and command from the command line 2009-05-05 12:30:19 +00:00
Daniel Stenberg
755e213ae6 Added ssh2_exec as a new example, showing how to run a command remotely with
libssh2
2009-05-05 12:27:02 +00:00
Daniel Stenberg
9412588373 bug #2785173 pointed out that we really must call _libssh2_transport_read()
in loops until it returns < 0 when we call it, as if we just call it once we
may drain the socket for data and then leave unused in-memory data that we
won't detect because the socket is back to idle...
2009-05-01 19:07:20 +00:00
Daniel Stenberg
9f104cd883 Markus posted a bug report about a bad 0-return from libssh2_channel_read:
http://libssh2.haxx.se/mail/libssh2-devel-archive-2009-04/0076.shtml

  And it was indeed a bad loop that terminated too early due to a receveived
  close packet.
2009-04-30 10:30:26 +00:00
Daniel Stenberg
6409bb53ba remove pointless sleeps 2009-04-28 10:35:30 +00:00
Daniel Stenberg
c306119dd6 edited 2009-04-14 21:43:39 +00:00
Daniel Stenberg
2b8038e175 libssh2_poll() and libssh2_poll_channel_read() are now considered and
documented deprecated and they will be removed at next soname bump. It also
  saves us from fixing some rather quirky bugs in libssh2_poll()...
2009-04-14 21:38:36 +00:00
Guenter Knauf
2a39b32b1a some minor Makefile tweaks; mainly for crosscompiling. 2009-04-09 03:13:51 +00:00
Daniel Stenberg
e63cbd907f Jussi Mononen pointed out we used an unsigned variable to store negative
values in, when a plain int is much better anyway since it matches the return
type.
2009-04-06 14:50:29 +00:00
Daniel Stenberg
cb66b7b94f and we're now on the 1.1.1 track 2009-04-02 09:35:02 +00:00
Daniel Stenberg
98b0afdab8 release 1.1 2009-04-02 08:49:29 +00:00
Daniel Stenberg
5a3da233ec Sofian Brabez removed duplicate calls to libssh2_session_set_blocking() 2009-03-31 12:20:36 +00:00
Daniel Stenberg
74f4b7817b Uh, it is important that we don't set the local state 'local.close' to TRUE
until _after_ we're done as otherwise we might not get called again properly
to clean the entire thing since the close state is checked in
libssh2_channel_free
2009-03-31 08:52:25 +00:00
Daniel Stenberg
9ba11a374c Removed the trace output that said "May block until packet of type..." since
it simply wasn't true for non-blocking operations.
2009-03-30 09:19:49 +00:00
Daniel Stenberg
117b95e6e3 made sure the SFTP code makes more use of internal non-blocking functions
instead of the external API entries
2009-03-29 22:09:29 +00:00
Daniel Stenberg
60ee30b6c9 Fixed the memory leak in in libssh2_userauth_hostbased_fromfile_ex() that
Jean-Louis Charton found. Additional minor indent and comment edits.
2009-03-28 21:31:53 +00:00
Daniel Stenberg
55744f8f34 indent changes and removed libssh2_ prefix from static function 2009-03-28 21:22:16 +00:00
Yang Tse
8f78a935ca include libssh2_priv.h instead of libssh2.h in order to get
LIBSSH2_API properly defined on LIBSSH2_WIN32 build targets
2009-03-28 12:50:34 +00:00
Daniel Stenberg
75d5830490 Additional non-blocking fixes. 2009-03-27 22:24:09 +00:00
Daniel Stenberg
103a6e9e0b Me and my long fingers couldn't resist "merging" these statements in a previous
commit but of course that broke functionality and this is a revert of that
change.
2009-03-27 21:52:49 +00:00
Daniel Stenberg
76dab196b1 Dump to stderr simply because the other tracing functions in misc.c already
use stderr and mixing output "channels" causes too much confusion for me!
2009-03-27 21:51:43 +00:00
Daniel Stenberg
4353711127 fixed sftp_shutdown() for the blockiness and fixed libssh2_channel_close()
to work properly non-blocking
2009-03-27 20:20:48 +00:00
Daniel Stenberg
ad8b49b208 Fixed the order of the check in the BLOCK_ADJUST() macro so that it also works
for libssh2_session_free()
2009-03-27 12:48:03 +00:00
Daniel Stenberg
1d2bd301d3 kill warnings 2009-03-27 09:52:19 +00:00
Daniel Stenberg
5936d9ce4e Fix the BLOCK_ADJUST_ERRNO() macro to behave properly in blocking mode. 2009-03-27 09:37:48 +00:00
Simon Josefsson
de0c4159bf Add AC_CONFIG_MACRO_DIR to avoid warnings with libtool v2.2.x. 2009-03-27 08:54:15 +00:00
Daniel Stenberg
f390c8e02d fix comments, moved to htonu64 function to sftp.c and made it static 2009-03-27 07:03:00 +00:00
Daniel Stenberg
9df891e412 More cleaning up converting libssh2_ to _libssh2_ for internal functions and
removing libssh2_ from static functions. Added mac.h.
2009-03-26 22:25:23 +00:00
Daniel Stenberg
fc28f33384 comp.c only as a single _libssh2_ function, no external one 2009-03-26 22:09:35 +00:00
Daniel Stenberg
eabe072496 * Renamed the functions in src/transport.c to be _libssh2_transport_ prefixed
and introduced a transport.h header.

* Fixed the blocking mode to only change behavior not the actual underlying
  socket mode so we now always work with non-blocking sockets. This also
  introduces a new rule of thumb in libssh2 code: we don't call the
  external function calls internally. We use the internal (non-blocking)
  ones!

* libssh2_channel_receive_window_adjust2 was added and
  libssh2_channel_receive_window_adjust is now deprecated

* Introduced "local" header files with prototypes etc for different parts
  instead of cramming everything into libssh2_priv.h. channel.h is the
  first.
2009-03-26 15:41:14 +00:00
Daniel Stenberg
239bdffb59 avoid some busy-looping 2009-03-25 22:52:32 +00:00
Daniel Stenberg
bab3a30220 one function to remove, one proto to correct 2009-03-23 13:54:16 +00:00
Daniel Stenberg
2e548c1ca0 Updated comments and removed "libssh2_" prefixes from static functions 2009-03-23 13:35:20 +00:00
Daniel Stenberg
1e1ba6219e added basic docs 2009-03-23 13:20:48 +00:00
Daniel Stenberg
27d74a7bd5 quite possibly one of the most pointless functions in the libssh2 API...a 2009-03-23 13:17:49 +00:00
Daniel Stenberg
3d97a87669 ENOTCONN obviously doesn't exist in win32 so don't try to map that 2009-03-23 13:08:17 +00:00
Daniel Stenberg
022cac8510 [no comment] 2009-03-23 12:53:50 +00:00
Daniel Stenberg
d187a0fdb6 EEK revert the part of the previous commit that was just my non-functional
attempts to make things work with blocking sockets.
2009-03-23 12:51:53 +00:00
Daniel Stenberg
1936d167d1 I cut out the poll_socket argument from the protos for_libssh2_packet_askv()
and _libssh2_packet_ask() since they are internal and nothing in the code base
uses that functionality == simplicity with no drawbacks!
2009-03-23 12:43:59 +00:00
Daniel Stenberg
26b65e06b1 pass in unsigned ints for u32 values and not longs 2009-03-19 12:54:58 +00:00
Daniel Stenberg
468272d648 - (Mar 19 2009) Daniel Stenberg: based on a patch by "E L" we now use errno
properly after recv() and send() calls (that internally are now known as
  _libssh2_recv() and _libssh2_send()) so that the API and more works fine on
  windows too!
2009-03-19 12:45:59 +00:00
Daniel Stenberg
563f627647 I'm upgrading myself! 2009-03-18 13:11:28 +00:00
Simon Josefsson
872a6e28dc Add StrictModes=no to work around cygwin problem.
Reported by Yang Tse <yangsita@gmail.com>.
2009-03-17 19:07:35 +00:00
Simon Josefsson
fa5509d9f2 Add UsePrivilegeSeparation=no for cygwin.
Reported by Yang Tse <yangsita@gmail.com>
2009-03-17 17:25:42 +00:00
Daniel Stenberg
53ad07633e re-indented for clarity 2009-03-17 14:58:24 +00:00
Daniel Stenberg
0b7f20566c re-indented _libssh2_channel_packet_data_len() somewhat to make the huge
condition somewhat easier on the eye
2009-03-17 14:44:38 +00:00
Daniel Stenberg
cc5e952fa0 A cleanup effort: libssh2_ prefixes only on external APIs. Use _libssh2_ prefix
for library-wide internal functions. Don't use any of those on static functions.
I also did some comments and whitespace changes.
2009-03-17 13:48:35 +00:00
Daniel Stenberg
f2fa02c575 bump packet default size to 32768 2009-03-17 12:09:53 +00:00
Daniel Stenberg
0dbc6ed8b6 Refer to the exact symbol name, which also is the exact file name of the man
page file.
2009-03-17 10:34:27 +00:00
Simon Josefsson
c7a1d30590 Use libtool -export-symbols-regex to reduce numer of exported symbols. 2009-03-17 10:19:54 +00:00
Daniel Stenberg
8096b459d4 cleanup round 2009-03-16 23:25:14 +00:00
Daniel Stenberg
7ef3406b57 Added (templates for) the 13 missing man pages 2009-03-16 15:00:45 +00:00
Daniel Stenberg
d870042496 two more renaming of man pages to the actual function name 2009-03-16 14:40:37 +00:00
Daniel Stenberg
27355c740f rename the man page to use the same name as the actual function 2009-03-16 14:28:37 +00:00
Daniel Stenberg
f8ad00e6ae mention the basic changes in my previous few commits 2009-03-16 08:23:54 +00:00
Daniel Stenberg
94090cf55c Patch from bug report #1960894 by "Heiner" applied, and edited by me. It makes
SCP recv and send deal with file names containing spaces (and other
shell-special letters) by quoting them before they are passed to the remote
server.
2009-03-15 23:28:25 +00:00
Daniel Stenberg
ce9d44a3ff fixed some wrong comments and did a minor code edit and some further
whitespace changes
2009-03-15 23:07:09 +00:00
Daniel Stenberg
a678dbac06 added three more public functions I found lacking man pages 2009-03-15 22:59:46 +00:00
Daniel Stenberg
0812744424 fix a compiler warning 2009-03-15 22:40:11 +00:00
Daniel Stenberg
f56b8ef605 simplified how the "scp" command line is created in the libssh2_scp_recv()
function
2009-03-15 22:38:47 +00:00
Daniel Stenberg
1a630c5c09 Simplified libssh2_channel_read_ex() and made it send window adjustments less
frequent, use a few less struct fields in the channel struct and improved
reading from the network with libssh2_packet_read(). I also modified the
windowing algorithm and now use a much larger window. This greatly enhances
SSH/SCP performance. I also increased the size of the buffer the transport
layer uses from 4k to 16K.
2009-03-15 22:29:23 +00:00
Daniel Stenberg
3793b6768d oops, use %06d for the microseconds! 2009-03-14 23:04:25 +00:00
Daniel Stenberg
269bd5e9a4 re-indented and other whitespace edits 2009-03-14 22:29:48 +00:00
Daniel Stenberg
d7566e5065 improved trace logs with time stamps 2009-03-14 22:29:28 +00:00
Daniel Stenberg
bdd005a5e5 fixed to work quite similar to the sftp_nonblock example so that it waits
for the socket correctly and measures the transfer speed fine
2009-03-14 09:40:57 +00:00
Daniel Stenberg
a52f5d3b7e Cleanups, that do seem to have boosted SFTP download performance up to 300% in
some tests:

  * cut off "_ex" from several internal function names

  * corrected some log outputs

  * simplified libssh2_channel_read_ex() and made it much faster in the process

  * cut out {{{ and }}} comments that were incorrect anyway

  * fixed sftp_packet_ask() to return the correct packet by using memcmp() and
    not strncmp()

  * fixed mkdir()'s wait for packet to use the correct request_id - it
    semi-worked previously because strncmp() in sftp_packet_ask() made it
    match far too easily.

  * took away the polling functionality from sftp_packet_ask() since it wasn't
    used
2009-03-13 22:15:27 +00:00
Daniel Stenberg
d89782d99f improved non-blocking behavior for some of the initing stuff before the actual
data transfer begins
2009-03-13 22:14:47 +00:00
Daniel Stenberg
2ba8db9168 wait for socket action accordingly, and do some measurements on the transfer
to make this better to use for speed tests
2009-03-13 12:35:13 +00:00
Daniel Stenberg
5f32304805 - (Mar 7 2009) Olivier Hervieu pointed out a flaw in the
libssh2_channel_x11_req_ex() function that made it produce a crappy random
  chunk of data. Peter Stuge improved the fix to not do out-of-boundary
  writes. I (Daniel Stenberg) replaced the snprintf() with a plain sprintf()
  since the size argument wasn't adding anything anyway.
2009-03-07 22:08:05 +00:00
Guenter Knauf
16941e1fcf some minor Makefile tweaks. 2009-03-06 07:25:37 +00:00
Daniel Stenberg
663da93b42 - Added libssh2_version() 2009-02-23 16:22:46 +00:00
Daniel Stenberg
1addcbbf53 - (Feb 20 2009) libssh2_channel_direct_tcpip_ex() bug #1902169 fixed, which
caused it to fail when called a second time.
2009-02-20 16:14:45 +00:00
Mikhail Gusarov
d722e09196 Fixed dash-as-minus warning in libssh2_base64_decode.3 manpage 2009-02-17 16:22:51 +00:00
Mikhail Gusarov
317740415a Fixed syntax error in libssh2_banner_set.3 manpage 2009-02-17 16:22:17 +00:00
Simon Josefsson
558de5e103 Bump ABI revision from 1.0.0 to 1.0.1 due to code changes. 2009-02-16 21:49:31 +00:00
Simon Josefsson
74aad1869d Fix typo. 2009-02-16 21:48:22 +00:00
Simon Josefsson
b9de72732b Add date for v1.0 release. 2009-02-16 21:46:40 +00:00
Daniel Stenberg
c672b837f8 - (Feb 12 2009) Romain Bondue extended Markus Moeller fix from Feb 8, based on
a previous (uncommitted) patch by Erik Brossler. It improves
  libssh2_channel_write_ex in blocking situations when the socket is set non-
  blocking.
2009-02-12 11:46:28 +00:00
Daniel Stenberg
c547e07caa Markus Moeller fixed a flaw in libssh2_channel_write_ex() that would occur
on EAGAIN situations.
2009-02-08 12:09:20 +00:00
Daniel Stenberg
6a78a6b358 I want to remove all those macros from the official API at next soname bump 2009-01-01 22:52:46 +00:00
Daniel Stenberg
369fcddb24 fixed compiler warnings, and stripped off "libssh2_" from static functions
as that makes shorter function names and then making the code look fine within
80 columns is easier!
2009-01-01 22:47:06 +00:00
Daniel Stenberg
97fbb77da5 made the three public headers use (mostly) lines shorter than 80 columns as
HACKING says - it makes them much more readable to my old tired eyes...
2009-01-01 22:27:08 +00:00
Daniel Stenberg
acc2c5dfb9 we're actually working on the 1.0.1 version now (or should it be 1.1?) 2008-12-28 21:01:36 +00:00
Daniel Stenberg
27197bcff3 Added 'TODO' file (again) with some fresh things I could think of right now 2008-12-26 07:54:08 +00:00
Daniel Stenberg
64b3e5e3f6 Added libssh2_trace man page 2008-12-26 07:46:45 +00:00
Daniel Stenberg
ba79d6b52d libssh2_base64_decode is deprecated and subject for removal in a future
version (like on the next soname bump)
2008-12-26 07:37:55 +00:00
Daniel Stenberg
6b38e21fa7 wrote up a first libssh2_base64_decode man page, added a few missing man
pages to the tarball
2008-12-23 13:23:45 +00:00
Daniel Stenberg
11330ee6da based on Heiner Steven's report, fix the name and description of these man
pages!
2008-12-23 12:34:17 +00:00
Daniel Stenberg
b3649e86a8 briefly mention my recent sftp-related fixes 2008-12-22 23:40:27 +00:00
Daniel Stenberg
2f32080772 mention web site and mailing list, as I think they're not mentioned anywhere
else in the package!
2008-12-22 23:39:46 +00:00
Daniel Stenberg
7aac082782 removed obviously superfluous comments 2008-12-22 22:43:05 +00:00
Daniel Stenberg
5a35edcb9a use a single >>32 instead of "(value / 65536) / 65536", just make sure that
the shift is done on a 64bit type
2008-12-22 22:33:03 +00:00
Daniel Stenberg
079d20aca8 remove unused #ifndef, and two whitespace changes 2008-12-22 22:31:51 +00:00
Daniel Stenberg
b357379923 style/indent changes only to enforce < 80 column lines more strict 2008-12-22 22:10:47 +00:00
Daniel Stenberg
62769b438f libssh2_sftp_seek64() it is now for the 64bit seek function too as the seek2
name has never been used in a release and it makes the naming consistent
2008-12-22 13:18:36 +00:00
Daniel Stenberg
d602478e87 0.19 is now 1.0 2008-12-22 12:51:27 +00:00
Daniel Stenberg
8eba2961ac Based on Alexander Lamaison's patch, there's now a new
function called libssh2_sftp_tell64() that returns the 64 bit file offset,
as the existing libssh2_sftp_tell() only returns a size_t.
2008-12-22 12:46:45 +00:00
Daniel Stenberg
962a41e4ec first conversion of a malloc => buffer in the sftp handle struct 2008-12-22 12:38:41 +00:00
Daniel Stenberg
31841e7c74 helper script for emacs users to get the code style done libssh2-style
automatically
2008-12-20 12:36:50 +00:00
Daniel Stenberg
70f844e57c - Markus Moeller fixed the issue also reported by Alexander Lamaison which
caused SFTP reads with large buffers to fail.
2008-12-19 22:21:36 +00:00
Simon Josefsson
942a81c8d5 Sshd is slow to start on some systems. 2008-12-17 16:22:37 +00:00
Daniel Stenberg
e26956be72 Avoid one malloc by putting the entire handle buffer in the handle struct
at once, use a define for the maximum size length of the handle instead of
'256' in the code.
2008-12-17 10:45:20 +00:00
Daniel Stenberg
2535c5c2ee removed some more libssh2_ prefixes from private functions
Made the libssh2_sftp_open_ex() deal with servers that first responds with
STATUS OK and then sends the actual HANDLE. It seems openssh does this at
times and it screwed things up. To me it seems like a spec violation...
2008-12-16 15:35:33 +00:00
Daniel Stenberg
197a26ef8c removed unused code, intended the code somewhat 2008-12-16 15:32:20 +00:00
Daniel Stenberg
f1dae83d5e Nothing used libssh2_sftp_packet_read's flush argument anymore so I removed
it and simplified the code somewhat thanks to that. I then renamed the function
to sftp_packet_read() only since it is private in this file anyway.
2008-12-16 12:31:58 +00:00
Daniel Stenberg
bcad67636b renamed libssh2_sftp_packet_requirev to plain sftp_packet_requirev since it
is private in this file only and a shorter name is nicer

Removed a "flush" of the data in sftp_packet_requirev() that now seems to have
made SFTP operations a lot more reliable. It didn't make much sense to have it
there but if someone can present a reason for one I figure we should carefully
investigate one and only do it conditionally where/when needed.
2008-12-15 22:58:07 +00:00
Daniel Stenberg
fbb25c7ad0 Clarify that this is only fine to use after an actual SFTP protocol error
return code.
2008-12-15 18:48:09 +00:00
Simon Josefsson
e47bedf17c Support EXEEXT in self-test. 2008-11-27 16:00:07 +00:00
Simon Josefsson
19f78244de Cygwin needs -lcrypto for -lssl.
Reported by "Yang Tse" <yangsita@gmail.com>.
2008-11-27 15:47:05 +00:00
Daniel Stenberg
9d5ba0dee2 oops, add missing file 2008-11-27 12:19:43 +00:00
Yang Tse
0934c4b39d fix again cygwin build failure unreleased regression 2008-11-26 18:15:09 +00:00
Dan Fandrich
cc3a7d8e83 Fixed a potential use of an uninitialized variable, the result of which lead
to an unneeded but harmless realloc.
Reduced the scope of some automatic variables.
2008-11-25 07:01:47 +00:00
Dan Fandrich
8f860e249e Fixed some typos in log messages 2008-11-25 06:49:04 +00:00
Daniel Stenberg
160f89f42e - Vlad Grachov brought the new function called
libssh2_session_block_directions() which returns a bitmask for what
  directions the connection blocks. It is to be used applications that use
  non-blocking sockets and when a libssh2 function returns
  LIBSSH2_ERROR_EAGAIN this function can be used to figure out in which
  direction the socket would block and thus it can wait for the socket to
  again be ready for communication in that direction before it calls libssh2
  again.
2008-11-24 13:31:00 +00:00
Simon Josefsson
881b01e522 Add a more realistic self-test of libssh2. 2008-11-21 15:00:18 +00:00
Simon Josefsson
74d33d50ba Ignore coverage/. 2008-11-21 14:51:43 +00:00
Simon Josefsson
fcaa810350 Add rules to generate a code coverage report. 2008-11-21 14:51:28 +00:00
Simon Josefsson
1f015d72b1 Use AM_CPPFLAGS instead of deprecated INCLUDES. 2008-11-21 14:34:03 +00:00
Simon Josefsson
8c8ba3bc20 Add self-test of base64 decode. 2008-11-21 08:36:38 +00:00
Simon Josefsson
9d433d4f80 Add gcov files. 2008-11-21 08:23:54 +00:00
Dan Fandrich
50a3255dde Use only C89-style comments 2008-11-21 02:25:38 +00:00
Dan Fandrich
482072939a Check LIBSSH2_HMAC_RIPEMD consistently 2008-11-21 01:07:08 +00:00
Simon Josefsson
f2253aeee9 Fix compiler warnings. 2008-11-20 10:29:01 +00:00
Simon Josefsson
2b5becfe85 Move pem.c to libgcrypt section, it is not needed for OpenSSL. 2008-11-20 10:09:43 +00:00
Simon Josefsson
8b25820589 Drop pkg-config test, not needed now. 2008-11-19 11:17:53 +00:00
Simon Josefsson
fd0bffdb2e Rewrite OpenSSL+libz detection logic. 2008-11-19 11:10:48 +00:00
Simon Josefsson
86eaae7886 Add more. 2008-11-18 17:00:57 +00:00
Daniel Stenberg
8e8dc43b0c fix the include path to also point out the build dir's src/ dir for the cases
where we build the lot outside of the source dir
2008-11-11 22:33:26 +00:00
Daniel Stenberg
e45bddb9fd avoid duplicate function declarations on windows 2008-11-11 22:32:33 +00:00
Daniel Stenberg
e5a36fb1cf WINSOCK_VERSION is no longer used (Richard W.M. Jones fixed) 2008-11-10 21:26:14 +00:00
Daniel Stenberg
5438cffd9a Richard W.M. Jones' 5 patches that enables libssh2 to get cross-compiled with
mingw
2008-11-10 16:48:41 +00:00
Paul Thomas
95b73812e7 Fixes a problem that the last code change apparently didn't fix. Verified
that this works correctly with another user.
2008-11-09 17:54:23 +00:00
Paul Thomas
85b953d0dd Fixed an issue with a patch that I submitted where the channel_read_ex()
could get stuck in a busy read loop.
2008-11-01 17:28:30 +00:00
Yang Tse
c3447ea29f fix cygwin build failure unreleased regression 2008-10-25 01:43:08 +00:00
Paul Thomas
8896b675f8 Reformatted the code, updated line endings to match original file,
fixed the build problem, removed tabs and replaced with spaces
 and removed C89 unfriendly comments.
2008-10-03 01:14:46 +00:00
Daniel Stenberg
b2334b227d mention libssh2_channel_request_pty_size_ex() 2008-10-02 09:44:38 +00:00
Daniel Stenberg
88d0ef1f3f two new committers! 2008-10-02 09:42:09 +00:00
Paul Thomas
006f233361 This fix addresses bug# 2141548. Channel reads would fail despite
libssh2_poll() detecting that there was data ready to be read on
the socket. This is seen when small amounts of data are ready to
be read, typically 1-4 chars worth.
2008-10-02 02:26:49 +00:00
Paul Thomas
fa620b2a7b Committed changes to add in support for pty resizing. Credit for this
patch goes to Vincent Jaulin.
2008-10-01 01:47:48 +00:00
Paul Thomas
b228f132f7 Fixed an issue with the libssh2_poll_channel_read function not
reading both normal and extended data when a non-zero value
is passed in as the 2nd parameter. This now matches the functionallity
described in the documentation.
2008-10-01 01:31:15 +00:00
Daniel Stenberg
8c43bc52b1 Carlo Bramini fixed the build for msys+mingw. Bug #1943976. 2008-09-30 21:54:20 +00:00
Daniel Stenberg
d26a330483 Carlo Bramini's fixes for the nonblocking examples for msys/mingw 2008-09-30 08:55:35 +00:00
Daniel Stenberg
b4b8c51b32 Neil Gierman provided improved Visual Studio 2008 code in bug #1946268 2008-09-29 18:59:40 +00:00
Daniel Stenberg
818e9edfb1 - Bug #1862727 fixed libssh2_poll() to work on windows (by defining HAVE_SELECT). 2008-09-29 14:16:19 +00:00
Daniel Stenberg
61fda23340 - Based on bug #1815692, we introduce libssh2_sftp_seek2() that allows seeking
beyond the 2GB margin even on 32bit machines.
2008-09-29 14:11:29 +00:00
Daniel Stenberg
93ae080bbc - Based on a patch in bug #1878059 by Steven Ayre libssh2 now parses >2GB file
sizes when downloading SCP files.
2008-09-29 14:04:01 +00:00
Daniel Stenberg
bd3dfed7e8 Adhere to RFC4253 better and don't use dash in the banner string. Bug #2064371 2008-09-29 13:42:41 +00:00
Daniel Stenberg
99afc66665 Sean Peterson's key re-exchange fix. See his long explanation on:
http://daniel.haxx.se/projects/libssh2/mail/libssh2-devel-archive-2008-06/0002.shtml
2008-07-03 16:26:55 +00:00
Daniel Stenberg
903307113e minor language updates 2008-07-03 10:58:53 +00:00
Daniel Stenberg
9b31ca67ac Gah, I broke Sebastian's patch when I left out the parentheses his patch
did contain. Added properly now.
2008-06-24 22:33:25 +00:00
Daniel Stenberg
3f0d30d1d6 |sftp.c:1470: warning: cast to pointer from integer of different size Another
reason why macros are evil: The string (which is allready char *) should be
cast into char * not the integer.

Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
2008-06-23 22:20:00 +00:00
Mikhail Gusarov
d4aa801f6f Added manpage for libssh2_userauth_keyboard_interactive_ex(3) 2008-03-08 18:26:32 +00:00
Daniel Stenberg
f56daac7fe - Mike Protts filed the bug report #1908724 that identified and fixed a problem
with SFTP stat on files >4GB in size. Previously it used 32bit math only.
2008-03-07 11:55:07 +00:00
Dan Fandrich
a55e6c10c9 Removed a stderr debug message that was accidentally left in (bug #1863153) 2008-01-03 19:12:50 +00:00
Daniel Stenberg
2fcaa00e3a as mentioned in bug #1841442, select wants maxfd+1 in its first argument! 2008-01-02 14:48:48 +00:00
Daniel Stenberg
0242a3b6af corrected wrong comment and made libssh2_channel_wait_closed() return 0 as
documented!
2007-11-29 11:32:34 +00:00
Daniel Stenberg
b310cc3465 oops 2007-11-29 10:04:16 +00:00
Daniel Stenberg
092e5f4b44 added libssh2_channel_wait_closed man page 2007-11-29 10:02:58 +00:00
Daniel Stenberg
c1a83abff9 remove trailing junk character 2007-11-29 09:57:22 +00:00
Mikhail Gusarov
f3c344da22 Fix syntax errors in libssh2_sftp_init and libssh2_sftp_open_ex manpages. 2007-11-21 14:07:32 +00:00
Guenter Knauf
4600d108ed fixed 'uninitialized' compiler warnings. 2007-11-18 20:57:13 +00:00
Daniel Stenberg
76e8e81402 valgrind was friendly enough to point out that doing memcpy() on overlapping
memory areas is a very bad idea so I changed this to memmove()
2007-11-12 23:09:45 +00:00
Daniel Stenberg
d27dd927cd add 0.18 release date 2007-11-12 09:22:32 +00:00
Daniel Stenberg
63d863241a 0.19 in progress 2007-11-12 09:21:46 +00:00
Daniel Stenberg
dbbd9eafc6 mention Dan Fandrich and Guenter Knauf 2007-11-10 23:36:41 +00:00
Daniel Stenberg
c92465930d fix three compiler warnings on comparison between signed and unsigned 2007-11-08 15:53:04 +00:00
Daniel Stenberg
34d5c9a4b1 Added a note about recent changes in a summarized way, added dates to the three
most recent releases and made many lines < 80 columns.
2007-11-08 15:42:09 +00:00
Daniel Stenberg
e8bb993437 include specified files from the win32 dir, not everything within it since
that gives us CVS files too etc
2007-11-08 15:14:13 +00:00
Daniel Stenberg
030b670e2a Moved the check that the amount of data is larger than the blocksize to
only get done on the first block. Based on the bug report #1826989
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1826989&group_id=125852
2007-11-08 13:51:23 +00:00
Daniel Stenberg
371a795443 fix transfer stall bug with non-blocking transfers, by Gavrie Philipson 2007-11-08 13:46:54 +00:00
Dan Fandrich
2d773f9322 Stop shadowing a global declaration 2007-09-28 18:29:40 +00:00
Daniel Stenberg
80f6c7c6d1 Immanuel Gregoire made libssh2_packet_read() properly deal with blocks when
in non-blocking state. Until this fix, libssh2 just couldn't work properly
on Windows while non-blocking.
2007-09-24 20:49:43 +00:00
Daniel Stenberg
46f26d3d0e oops, that was debugging code that wasn't supposed to be committed! 2007-09-24 12:15:45 +00:00
Daniel Stenberg
5d91d286f1 fix by Immanuel Gregoire, sizeof != strlen! 2007-09-24 12:14:18 +00:00
Guenter Knauf
5a854cfb26 fixed ssize_t typedef; added a define to detect already defined ssize_t. 2007-09-18 18:13:18 +00:00
Guenter Knauf
e905b206ed fix line endings to crlf and flag binary to avoid nasty conversions. 2007-09-15 15:26:37 +00:00
Dan Fandrich
fe7a6f967d Mention the const change in libssh2_channel_setenv_ex since it's a (minor)
change to the API.
2007-08-20 23:26:58 +00:00
Guenter Knauf
5879a0245b added link to native Win32 awk. 2007-08-18 18:53:26 +00:00
Daniel Stenberg
d90d8bdae7 The libssh2_channel_receive_window_adjust() function failed to set the state
variables at times and thus this function would misbehave on repeated invokes.
2007-08-12 21:53:32 +00:00
Daniel Stenberg
f216b36328 When we have less than blocksize data left we MUST (attempt to) read more
since we can't decrypt anything in that situation.
2007-08-10 22:22:45 +00:00
Dan Fandrich
c4630d1ffb Removed unnecessary casts and added const where necessary. 2007-08-09 01:10:11 +00:00
Dan Fandrich
17173aab0e Added const to varname parameter of libssh2_channel_setenv_ex 2007-08-09 01:09:09 +00:00
Dan Fandrich
f8d4de78e9 Fixed the samples to build outside the source tree.
Removed redundant _SOURCES lines.
2007-08-09 00:42:05 +00:00
Daniel Stenberg
e32ff531a3 Satish Mittal and David J Sullivan fixed an infinit recv() loop in
libssh2_banner_receive()
2007-08-08 21:43:12 +00:00
Guenter Knauf
a227554c26 fixed test makefile to generate config.h. 2007-08-08 16:32:42 +00:00
Daniel Stenberg
9f27d176f8 we work on 0.18 now, although it might be 1.0 - who knows? 2007-08-06 20:59:08 +00:00
Daniel Stenberg
bcc4fd6e82 0.17 re-indent 2007-08-06 20:50:22 +00:00
Daniel Stenberg
210459db4b re-indented the source code with this script:
indent \
--braces-on-if-line \
--braces-after-struct-decl-line \
--space-after-cast \
--line-length 79 \
--comment-line-length 79 \
--cuddle-else \
--no-tabs \
--tab-size 8 \
--indent-level 4 \
--no-space-after-for \
--space-after-if \
--space-after-while \
--no-space-after-function-call-names \
*.[ch]
2007-08-06 20:48:04 +00:00
Daniel Stenberg
4c3dd3ea9f 0.16 news 2007-08-06 15:00:48 +00:00
James Housley
0d78e69016 libssh2_userauth_list() requires the lenght of the username to be passed,
and not the sizeof() the array holding it.
2007-08-03 15:08:28 +00:00
Daniel Stenberg
02e5b3b423 LIBSSH2_APINO is now gone, the sooner the better. This is gonna cause some
pains in apps relying on it, but it is broken by design and we should not
rely on it at all. Go for the LIBSSH2_VERSION_* defines instead if you need
to check for versions.
2007-08-03 08:05:36 +00:00
Daniel Stenberg
9399ef83c4 this is generated, no need to commit it 2007-08-03 08:04:15 +00:00
Daniel Stenberg
68c86e2c4c The examples no longer have an include path pointing to the private source dir
but instead uses its own config.h file, that now is included first to make
large file magic have an effect.
2007-07-31 11:00:29 +00:00
Daniel Stenberg
15e0f56d01 add large file magic checks, and make sure we update the config.h file in the
example/simple subdir as well
2007-07-31 10:04:57 +00:00
Daniel Stenberg
d2ef367552 create a private config.h file for the examples 2007-07-31 10:04:24 +00:00
Daniel Stenberg
3167f054ff Peter O'Gorman pointed out (and fixed) that the non-blocking check in
configure made libssh2 use blocking sockets on AIX 4 and 5, while that
wasn't the intention.
2007-07-30 22:55:43 +00:00
Daniel Stenberg
209d06d6c9 libssh2_poll() no longer relies on C99 features but instead uses alloca()
on systems that have it - and uses a fixed-size array on those that don't.
session.c was also cleaned from a large amount of trailing whitespace.
2007-07-23 21:18:43 +00:00
Guenter Knauf
2b7856ad32 ooups - forgotten var added. 2007-07-22 02:15:31 +00:00
Guenter Knauf
9a1ce06e31 added keyboard-interactive auth method;
added 5. argument to specify auth method.
2007-07-22 02:07:55 +00:00
Guenter Knauf
c9413c628d changed prelude file for gcc build. 2007-07-22 00:47:21 +00:00
Guenter Knauf
327c31a634 added var to specify cross compiler prefix. 2007-07-21 22:59:24 +00:00
Guenter Knauf
4ace76b30d added some defines for MSVC and other non-gcc compilers. 2007-07-20 09:52:02 +00:00
Guenter Knauf
2127c5967e moved the inclusion of libssh2_config.h to the top. 2007-07-20 09:51:05 +00:00
Guenter Knauf
242475c42a added keyboard-interactive auth method;
added 4. argument to specify auth method.
2007-07-20 01:23:10 +00:00
Guenter Knauf
854dffe0a4 moved blocks to make keyboard-interactive second choice (if implemented). 2007-07-19 17:08:54 +00:00
Guenter Knauf
278219fc0a few cosmetic changes; added block for future implementation of keyboard-interactive method. 2007-07-19 15:43:48 +00:00
Guenter Knauf
16be3fc778 removed obsolete line. 2007-07-19 15:29:06 +00:00
Guenter Knauf
edcfab905a added selection of authentication method based on what libssh2_userauth_list() returns; added vars for the key files. 2007-07-19 15:25:46 +00:00
James Housley
46f59112d9 * After setting the error to the error string from in the packet, set
the pointer to NULL so it can't be double freed.
* On session cleanup be sure to free the last error if it needs to be
2007-07-19 15:02:37 +00:00
James Housley
05c1164a67 The test after the memory allocation was backwards, so keyboard-interactive
would always fail due to a memory problem.
2007-07-18 19:54:51 +00:00
Guenter Knauf
3fc4caf42f fixed call to libssh2_userauth_list() since NULL isnt supported for the username. 2007-07-18 19:31:15 +00:00
Guenter Knauf
1a9fee074b added check for available authentication methods. 2007-07-18 11:46:25 +00:00
Guenter Knauf
8f62c7322f added NMakefile to Makefile.am so that it gets included with releases and daily snapshots. 2007-07-17 13:22:55 +00:00
Guenter Knauf
839be89a49 added test success messages. 2007-07-16 22:16:21 +00:00
Guenter Knauf
669e69966a another trial to fix the typedefs. 2007-07-16 22:05:30 +00:00
Guenter Knauf
138b1b3830 fixed MSVC project files to build static lib and dll in separate direcories. 2007-07-15 23:46:30 +00:00
Daniel Stenberg
4088283465 support --enable-maintainer-mode 2007-07-15 22:21:46 +00:00
Guenter Knauf
402978bd1b fixed MSVC project files. 2007-07-15 22:11:12 +00:00
Daniel Stenberg
387a1fdf4b add maketgz to release archives 2007-07-15 21:47:27 +00:00
Daniel Stenberg
d574d7dea0 Added LIBSSH2_TIMESTAMP to the public header and it contains the timestamp of
the making of the release archive.

Added 'maketgz' as a script to build release archives with, including automated
snapshots or whatever. It updates the defines in include/libssh2.h.

configure now extracts the version number from the include/libssh2.h header in
the source tree instead of using it fixed set in the script (to remove the
need for regenerating the configure script when we run maketgz).

Makefile.am now has a dist-hook that puts ".dist" files in the release tree
instead of the file without the .dist extension, so that we can easily add
modified files in release archives. Like maketgz.
2007-07-15 21:36:29 +00:00
Guenter Knauf
b2df0b26f7 fixed test makefile to build all samples. 2007-07-15 20:34:33 +00:00
Guenter Knauf
bb76ed34a0 fixed NMakefile stuff to build at least the DLL again. 2007-07-15 20:06:19 +00:00
Simon Josefsson
153e1959f4 Fix make distcheck. Noted by Daniel. 2007-07-15 08:22:00 +00:00
Daniel Stenberg
a3155d5d12 I'm fine with just name 2007-07-14 23:33:21 +00:00
Guenter Knauf
8485ee6fd5 introduced some more version defines. 2007-07-14 22:18:32 +00:00
Daniel Stenberg
4f76c2b80c Metion the current code style in the new file called HACKING. In this, we
could also add descriptions on how to send us patches and bug reports etc...
2007-07-14 21:28:02 +00:00
Daniel Stenberg
accd865aff converted to 4-level space indents, no trailing whitespace 2007-07-14 21:24:38 +00:00
Guenter Knauf
84e16944b4 some more NetWare makefile fixes. 2007-07-14 21:04:32 +00:00
Daniel Stenberg
e0254f3936 removed compiler warnings, narrowed some source lines, killed trailing
whitespace
2007-07-14 20:54:47 +00:00
James Housley
14881b2370 For now make LIBSSH2_APINO a long, some compilers make constants an int it
seems.
2007-07-14 16:21:50 +00:00
Guenter Knauf
4ec68bdc04 added build for older CLIB version. 2007-07-09 22:47:24 +00:00
James Housley
a87fdff9e9 The variable "packet" needs to be in LIBSSH2_SFTP_HANDLE for re-entry when
blocking in libssh2_sftp_close_handle()
2007-07-09 15:11:37 +00:00
James Housley
50fd6590f0 While the previous commit seemed to correct a problem, it actually exposed
another problem.  Commit this until a proper fix is found
2007-07-08 17:14:19 +00:00
James Housley
2b1c979d7e Remove a blocking while loop that wasn't removed when the code to
return PACKET_EAGAIN was added, but should have been.
2007-07-08 15:37:44 +00:00
James Housley
6ac790a477 * Since the packet as already had data read from it, it can't retrun
PACKET_EAGAIN while reading the rest of it.
* Get the error message in libssh2_scp_recv() in the same manner as it
  was gotten in libssh2_scp_send_ex()
2007-07-05 15:31:19 +00:00
Guenter Knauf
b53db3d3a9 fix bug #1701782 - for now we only define for the compiler versions where we know for sure - if later versions still need those defines please report to the list. 2007-07-05 12:52:30 +00:00
Guenter Knauf
83d77f3878 enter next round after release. 2007-07-05 12:46:42 +00:00
James Housley
530e57d4ac Gavrie Philipson sumitted a patch to get the actual text of the error
on scp upload.
2007-07-05 11:08:17 +00:00
James Housley
a9fc3bdb4e Change the wording of the return value to match the rest of the man pages 2007-07-04 10:44:40 +00:00
Mikhail Gusarov
e2c88f6ae3 Fixed manpage syntax (catched by Debian's lintian) 2007-07-04 09:42:08 +00:00
Daniel Stenberg
cf9ed016e7 as mentioned in bug #1655429, the CRLF pair was stripped off in the wrong
order!
2007-06-28 20:53:32 +00:00
Daniel Stenberg
1901324122 added missing files (in 0.15) to the release tarball 2007-06-25 20:48:07 +00:00
James Housley
74b12c3c7a * Eberhard Mattes submitted a patch "According to RFC 4251,
a boolean value of true is encoded as 1, not as 0xff".  Servers
should accept any non-zero value.

Bug:	1703472
2007-06-23 22:20:30 +00:00
James Housley
25adcc150e Guenter Knauf submitted code to detect on windows if the socket is
blocking or not
2007-06-22 16:46:36 +00:00
Guenter Knauf
639b29631a update export list for recent changes 2007-06-20 23:44:58 +00:00
James Housley
7808cab1e4 libssh2_channel_read_ex() needed more changes to fully support
non-blocking IO
2007-06-18 22:39:30 +00:00
James Housley
9dfd71121e Small fixes:
* libssh2_sftp_packet_read() - use the right variable for the
        number of bytes returned by libssh2_channel_read_ex()
* libssh2_sftp_packet_requirev - only call libssh2_waitsocket() when
        in blocking IO mode
2007-06-18 22:38:32 +00:00
Simon Josefsson
e555510008 Fix distcheck. 2007-06-18 11:55:41 +00:00
James Housley
ba728148a9 Make libssh2_channel_receive_window_adjust() properly support non-blocking 2007-06-17 23:35:07 +00:00
James Housley
019cd1abc0 Clean up and standardization of code 2007-06-17 23:34:35 +00:00
James Housley
0742a972c1 Created libssh2_sftp_readdir_ex() and updated LIBSSH2_APINO to 200706151200 2007-06-15 17:22:49 +00:00
James Housley
ca616cea36 Add missing back-slash, so now they can actually be installed 2007-06-15 11:01:22 +00:00
James Housley
8accb43cd6 Add libssh2_channel_get_exit_status() 2007-06-15 10:53:04 +00:00
James Housley
bc6ab7e0cb Add me 2007-06-15 10:08:33 +00:00
James Housley
363f5a690d Another bug pointed out by Troy Gutjahr. The free and nulling for two
pointers were crossed
2007-06-15 10:07:49 +00:00
James Housley
8223acec0a Don't use memory after it has been freed, pointed out by Troy Gutjahr 2007-06-15 01:41:58 +00:00
James Housley
136b2bfcdc Some older BSD systems, OS X 10.3.9 for example, need <stdio.h> before
<sys/select.h>.  And <uio.h> is needed for iovec
2007-06-14 22:50:32 +00:00
James Housley
bc179b6e87 Update libssh2_channel_set_blocking.3 and add
libssh2_session_set_blocking.3
2007-06-14 17:23:13 +00:00
James Housley
d4648be5a6 Add libssh2_userauth_authenticated.3, libssh2_userauth_list.3,
libssh2_userauth_password_ex.3 and libssh2_userauth_publickey_fromfile.3
2007-06-14 17:15:32 +00:00
James Housley
f71b59c900 Add libssh2_sftp_unlink_ex.3 and libssh2_sftp_write.3 2007-06-14 16:46:14 +00:00
James Housley
fbf9d7cebd Add libssh2_sftp_shutdown.3, libssh2_sftp_stat_ex.3,
libssh2_sftp_symlink_ex.3 and libssh2_sftp_tell.3
2007-06-14 16:33:38 +00:00
James Housley
82d59f90e1 Add libssh2_sftp_last_error.3, libssh2_sftp_rename_ex.3,
libssh2_sftp_rmdir_ex.3 and libssh2_sftp_seek.3
2007-06-14 16:08:43 +00:00
James Housley
cd077c350f Add libssh2_sftp_close_handle.3 and libssh2_sftp_fstat_ex.3 2007-06-14 15:45:03 +00:00
James Housley
49fef5e598 Add libssh2_session_abstract.3, libssh2_session_callback_set.3,
libssh2_session_method_pref.3 and libssh2_session_methods.3
2007-06-14 15:26:58 +00:00
James Housley
c5ba20a2c0 Add libssh2_hostkey_hash.3, libssh2_scp_recv.3 and libssh2_scp_send_ex.3 2007-06-14 14:56:32 +00:00
James Housley
6546a010a4 Updated to include the most recent entries from ChangeLog 2007-06-14 10:34:10 +00:00
Guenter Knauf
e34baff2ca update export list for recent changes - take 2 2007-06-14 09:41:07 +00:00
Guenter Knauf
ddb935af3d non-gcc compilers break with var declarations in the middle of the code. 2007-06-14 00:38:35 +00:00
James Housley
12d6b04c80 Add libssh2_session_last_errno.3 and libssh2_session_last_error.3 2007-06-13 23:02:08 +00:00
Guenter Knauf
bc0578a34d update export list for recent changes 2007-06-13 22:28:49 +00:00
Guenter Knauf
94585bf852 fixed space detection 2007-06-13 22:20:13 +00:00
James Housley
9002319fc3 Add libssh2_channel_setenv_ex.3 and libssh2_channel_x11_req_ex.3 2007-06-13 21:30:15 +00:00
James Housley
e7e94c4079 Add libssh2_channel_request_pty_ex.3 and libssh2_channel_send_eof.3 2007-06-13 21:07:59 +00:00
James Housley
e7fdf3654c Add libssh2_channel_open_ex.3 and libssh2_channel_process_startup.3 2007-06-13 20:54:25 +00:00
James Housley
5aa467cf54 Add libssh2_channel_free.3, libssh2_channel_handle_extended_data.3
and libssh2_channel_handle_extended_data2.3
2007-06-13 20:09:15 +00:00
James Housley
f599ec2b86 Add libssh2_channel_flush_ex.3 and libssh2_channel_forward_cancel.3 2007-06-13 19:53:09 +00:00
James Housley
d89e102b23 Add libssh2_channel_direct_tcpip_ex.3 and libssh2_channel_eof.3 2007-06-13 17:22:15 +00:00
James Housley
e6daab80fa Add libssh2_banner_set.3 and libssh2_channel_close.3 2007-06-13 17:03:38 +00:00
James Housley
2003dc1546 The month should be the 3-letter abbreviation instead of spelled out. 2007-06-13 16:41:33 +00:00
James Housley
94a2585e9e Update to match current code and add errors 2007-06-13 15:45:18 +00:00
James Housley
61932dc560 Update to match current code and add errors 2007-06-13 15:27:54 +00:00
James Housley
0dff967017 Fix date 2007-06-13 15:17:25 +00:00
James Housley
f74a3fecc9 Update to match current code and add errors 2007-06-13 15:16:12 +00:00
James Housley
70ea2c776e Update to match current code and add errors 2007-06-13 15:10:45 +00:00
James Housley
72c8408a40 Update to match current code and add errors 2007-06-13 14:23:46 +00:00
James Housley
3fbdf1a644 Remove extraneous character 2007-06-13 14:21:44 +00:00
James Housley
2bb177d3e0 Update to match current code and add errors 2007-06-13 14:07:12 +00:00
James Housley
8bc4fdc3b0 Update to match current code and add errors 2007-06-13 13:57:53 +00:00
James Housley
eac8fcdd77 Update to match current code and add errors 2007-06-13 13:50:34 +00:00
James Housley
fa0c6996ef Update to match current code and add errors 2007-06-13 13:41:46 +00:00
James Housley
45e4ec255c Update to match current code and add errors 2007-06-13 13:15:57 +00:00
James Housley
084500e9ca Update to match current code and add errors 2007-06-13 13:06:48 +00:00
James Housley
3e0cc45d10 Update to match current code and add errors 2007-06-13 12:58:58 +00:00
James Housley
3dece58b29 Fix spacing issue 2007-06-13 12:58:42 +00:00
James Housley
e4ec1c9aa9 Change "SEE ALSO" to SEE ALSO 2007-06-13 12:51:10 +00:00
James Housley
607e5c55e0 Update to reflect the current code and add possible error values 2007-06-13 12:50:35 +00:00
James Housley
dde2b09496 libssh2_channel_free() actually can return PACKET_EAGAIN. Update all
calling functions to support that with the following API notes:

* libssh2_publickey_shutdown(), libssh2_session_free() changed
  to return an "int" to allow signaling of LIBSSH2_ERROR_EAGAIN.

* libssh2_scp_recv(), libssh2_scp_send_ex() and libssh2_sftp_init()
  will loop in on libssh2_channel_free() when there is an error.
  It is not possible to return LIBSSH2_ERROR_EAGAIN in this condition
  in these 3 functions and not lose the original error code.
2007-06-12 18:27:37 +00:00
James Housley
f35ab0d070 Update for the libssh2_userauth_list() change 2007-06-12 13:34:20 +00:00
James Housley
041786732d The function no longer exists 2007-06-10 21:59:36 +00:00
Daniel Stenberg
d073a4ea52 include sys/types.h since the compile breaks on Linux otherwise - we need
ssize_t from there
2007-06-10 21:26:58 +00:00
James Housley
a5109ee5ba Sharing state vairables between the userauth functions was a nice idea,
but libssh2_userauth_list() can't share with the others.  So to be safe
don't have any share.
2007-06-10 13:59:05 +00:00
James Housley
b12a16f89c Add a define for vsnprintf, similar to snprintf that is already there.
Bug:	1702156
2007-06-10 11:16:36 +00:00
James Housley
8b4df6a9ab Fix misspelling in trace
Bug:	1703464
2007-06-10 11:09:39 +00:00
James Housley
8466a826f1 Since uint32_t is used, inttypes.h should be included. 2007-06-09 01:34:21 +00:00
James Housley
c39c618c62 * Convert all the code to properly work with a socket in
non-blocking mode.  All functions either return
LIBSSH2_ERROR_EAGAIN or return NULL and set the error code
to be LIBSSH2_ERROR_EAGAIN instead of blocking, when in
non-blocking mode.
2007-06-09 01:30:33 +00:00
James Housley
bdde6c3d60 In the code rewrite
libssh2_kex_method_diffie_hellman_group14_sha1_key_exchange() lost two
initializer routines, restore them.
2007-06-08 15:57:46 +00:00
James Housley
cf8f4d1818 To simplify the user's error interface always use LIBSSH2_ERROR_EAGAIN.
LIBSSH2CHANNEL_EAGAIN and LIBSSH2SFTP_EAGAIN are still valid, but are
defined as LIBSSH2_ERROR_EAGAIN.
2007-06-08 13:33:08 +00:00
James Housley
281283d252 libssh2_session_disconnect_ex() should be returning PACKET_EAGAIN instead
of LIBSSH2_ERROR_EAGAIN, so it matches the other functions return values.
2007-06-08 12:07:09 +00:00
James Housley
b2f3582a59 When shutting down sub-systems and closing the channel try our best
to free any memory still allocated in the state variables
2007-06-07 16:43:20 +00:00
James Housley
bb32d080fa Remove 2 last files 2007-06-07 16:07:09 +00:00
James Housley
eb39c0c091 Remove the removed files 2007-06-07 16:02:57 +00:00
James Housley
7d57222912 Finish making SFTP fully non-blocking capable.
Functions that return an "int", and friends, return LIBSSH2SFTP_EAGAIN.
Functions that return a structure return NULL and set the error to
LIBSSH2_ERROR_EAGAIN
2007-06-07 16:01:12 +00:00
James Housley
d141ba49f3 Make libssh2_sftp_write() be fully non-blocking. The state of the socket
is fully honored.  LIBSSH2SFTP_EAGAIN is returned when the call would
block.
2007-06-06 19:52:11 +00:00
James Housley
4b8db8c1ab Modify the code to truely support non-blocking. Propogate the EAGAIN error
all the way up to the user interface.  All code modules bug sftp.c have
been completed.

Functions that return an "int", or similar return LIBSSH2CHANNEL_EAGAIN to
indicate some part of the call would block, in non-blocking mode.

Functions that return a structure, like "LIBSSH2_CHANNEL *", return NULL
and set the libssh2 error.  The error can be obtained with either
libssh2_session_last_error() or libssh2_session_last_errno().  Either of
these will return the error code of LIBSSH2_ERROR_EAGAIN if the
call would block, in non-blocking mode.

The current state of a function and some variable are keep in the
structures so that on the next call the operation that would block can
be retried again with the same data.
2007-06-06 12:34:06 +00:00
James Housley
9896c291e4 libssh2_packet_read() was checking the "errno" even when recv() didn't
return an error.  "errno" should have been zero by the recv() call but
doesn't seem to be on all systems.  Only check when recv() says there
is an error.

Bug:		1703467
Patch:		1703468
2007-06-06 10:13:30 +00:00
James Housley
412b25d971 Initially the libssh2 code was indented with tabs of 4 spaces. Some of
the recent commits converted the tabs to 4 spaces, which matched the
initial indent size.  Other commits converted the tabs to 8 spaces, this
didn't match.

All the code has been converted to 4 space indents.  No changes to line
lengths or actual code was performed.  This is in preperation to my up
coming non-blocking work so my commits should only be code changes and
line lengths in the code I am working on.
2007-05-28 17:56:08 +00:00
Daniel Stenberg
355c9c634b Eberhard Mattes' fix for libssh2_packet_read() for when reading very small
chunks at a time.
2007-05-08 19:20:05 +00:00
Dan Fandrich
62f77b1e4b Fix building out of the source tree. 2007-05-01 20:07:08 +00:00
Guenter Knauf
145bbabb96 include libssh_config.h to get the configure vars in. 2007-04-26 23:59:14 +00:00
Guenter Knauf
40970adb53 changed to configure defines to control inclusion of headers from libssh2_config.h. 2007-04-26 22:59:29 +00:00
James Housley
34bcc69a1a Add more of the new programs to be ignored 2007-04-22 19:53:58 +00:00
James Housley
046edb478f Test programs for libssh2_sftp_mkdir_ex() and libssh2_sftp_mkdirnb_ex() 2007-04-22 19:52:51 +00:00
James Housley
54e6528822 Document libssh2_sftp_mkdir_ex() and libssh2_sftp_mkdirnb_ex() 2007-04-22 19:51:53 +00:00
James Housley
a66885c51c Make _libssh2_sftp_mkdir_ex() fully non-blocking safe. This makes
libssh2_sftp_mkdirnb_ex() non-blocking safe and libssh2_sftp_mkdir_ex()
blocking safe
2007-04-22 19:51:24 +00:00
James Housley
510df9bf52 libssh2_sftp.h is needed for all of these functions 2007-04-22 17:18:03 +00:00
James Housley
61807e8d4d Fix a couple of locations where read should have been readdir 2007-04-22 17:09:23 +00:00
James Housley
9ff217b6d2 libssh2_sftp_seek() and libssh2_sftp_tell() are NB-SAFE, since they
only set variables
2007-04-22 16:42:54 +00:00
James Housley
c43c390a7d Create two sample programs, similar to sftp.c and sftp_nonblock.c, that
will test blocking and non-blocking write SFTP transfers
2007-04-22 15:57:52 +00:00
James Housley
7eccfc7fbc Make _libssh2_sftp_write() fully non-blocking safe. This makes
libssh2_sftp_writenb() non-blocking safe and libssh2_sftp_write() blocking
safe
2007-04-22 15:56:06 +00:00
James Housley
d79939fc3a Commit the version that actually uses the non-blocking code 2007-04-22 15:05:06 +00:00
James Housley
c5fb9d8f1a Commit the version that actually uses the non-blocking read 2007-04-22 14:51:21 +00:00
James Housley
e85a2199b6 Update comment 2007-04-22 14:47:27 +00:00
James Housley
3bd3eb35b3 Make sftp_nonblock.c a non-blocking version of sftp.c, just like sftpdir.c 2007-04-22 14:16:26 +00:00
James Housley
08fd7e259b Move sftp_nonblock.c to sftp_RW_nonblock.c, since it isn't just a
non-blocking version of sftp.c.  It has different command line parameters
and tries to do more
2007-04-22 14:15:47 +00:00
James Housley
42f0f69a35 Make _libssh2_sftp_read() fully non-blocking safe. This makes
libssh2_sftp_readnb() non-blocking safe and libssh2_sftp_read() blocking
safe
2007-04-22 13:13:51 +00:00
James Housley
75ac861c7a * Explicity set blocking 2007-04-22 13:10:48 +00:00
James Housley
04e975b6c7 Unless we tell libssh2 that we are blocking, which we are because didn't
set the socket to non-blocking it will think we are in non-blocking mode
in a lot of places
2007-04-22 11:01:54 +00:00
James Housley
f14aa01bb8 Add comment about setting non-blocking 2007-04-22 11:00:02 +00:00
Guenter Knauf
ab7c3fb2d4 fixed ARFLAGS for CodeWarrior build. 2007-04-21 23:36:51 +00:00
Guenter Knauf
1ebe0a64b3 some more makefile fixes. 2007-04-21 21:26:54 +00:00
Guenter Knauf
6cd1c7528e fixed debug option. 2007-04-21 20:15:33 +00:00
Guenter Knauf
91c8715da4 fixed ARFLAGS for CodeWarrior build;
added libssh2_sftp_writenb to export list.
2007-04-21 18:46:30 +00:00
James Housley
2dc313d365 Non-blocking work
* The following low level packet routines now fully support non-blocking:
    libssh2_sftp_packet_read()
    libssh2_sftp_packet_ask()
    libssh2_sftp_packet_require()
    libssh2_sftp_packet_requirev()

* libssh2_sftp_readdirnb() functions completely in non-blocking mode

* The rest of the routines which call the libssh2_sftp_packet_* routine
  loop on a return code of PACKET_EAGAIN.  This maintains the current
  functionality until they fully support non-blocking

* The state of all function are labeled with either NB-SAFE or NB-UNSAFE,
  for those that are know.  NB-UNSAFE?? for those that haven't been
  examined.
2007-04-21 18:16:23 +00:00
James Housley
f8fe38e3a5 Create a simple test for sftp readdir with non-blocking 2007-04-21 18:08:00 +00:00
James Housley
bda32b6bbf Document libssh2_sftp_readdir() and libssh2_sftp_readdirnb() 2007-04-21 18:07:17 +00:00
Dan Fandrich
09deb228f1 Added some consts to struct members 2007-04-19 19:40:45 +00:00
Dan Fandrich
1a6e00cfef Fixed some compiler warnings and made some more tables 'const'. 2007-04-18 21:03:42 +00:00
Dan Fandrich
9b81a01376 Made some function parameters in the API const. This is an API change,
but correctly-written applications should see no source or binary
compatibility issues.  Also fixed a few compiler warnings.
2007-04-18 18:51:03 +00:00
Dan Fandrich
4c6bfdd5b2 Bail out on a short kex packet. 2007-04-17 18:30:05 +00:00
Dan Fandrich
5dd66e604f Made most internal tables 'static const'. 2007-04-17 18:12:41 +00:00
Guenter Knauf
d45d509a09 added ranlib when library is created with ar. 2007-04-16 20:56:08 +00:00
Guenter Knauf
d44e222b75 added sftpdir target; fixed linking. 2007-04-14 21:26:03 +00:00
Dan Fandrich
197764afcc Properly propagate out of memory errors. 2007-04-13 18:28:10 +00:00
Simon Josefsson
d79f906b52 Add. 2007-04-13 06:09:12 +00:00
Simon Josefsson
08cf9fd7de Add. 2007-04-13 06:08:25 +00:00
Simon Josefsson
7edad3046e Make ChangeLog a phony target. 2007-04-13 06:06:15 +00:00
Guenter Knauf
f33375bc03 changed to configure defines to control inclusion of headers from libssh2_config.h. 2007-04-12 22:20:18 +00:00
Guenter Knauf
159c351d05 Win32 has no ENOTCONN - checked MSVC6, MingW32, Borland C++ 5.5, OpenWatcom 1.6; all have this define in winsock2.h but blocked with '#if 0';
changed to configure defines to control inclusion of headers from libssh2_config.h
2007-04-12 22:18:27 +00:00
Guenter Knauf
8371fa7b87 updated Makefile.netware to add more exports; fixed linking;
updated OpenSSL version to have users use latest.
2007-04-12 22:15:12 +00:00
Guenter Knauf
0eefd06af0 removed HAVE_IOCTLSOCKET define;
updated OpenSSL version to have users use latest.
2007-04-12 22:13:14 +00:00
Guenter Knauf
86ca80028b blocked unistd.h inclusion for Win32 builds. 2007-04-12 22:10:12 +00:00
Guenter Knauf
0c060e1ccb added two more typedefs but blocked them so they are only used with MSVC6 or lower (dont know if later MSVC versions still need them). 2007-04-12 22:08:42 +00:00
Guenter Knauf
51e49f5a1e fixed wrong type and sync with usage. 2007-04-12 22:03:27 +00:00
Guenter Knauf
93e36271a6 check for sys/time.h 2007-04-12 22:00:55 +00:00
Dan Fandrich
6dfb2e3009 Better handle out of memory situations. 2007-04-12 21:51:57 +00:00
Daniel Stenberg
a84d2ca430 added --enable-debug 2007-04-12 21:40:22 +00:00
Guenter Knauf
3026c46109 removed ENOTCONN define, added HAVE_IOCTLSOCKET define;
added the new defines for inclusion of headers.
2007-04-12 21:37:09 +00:00
Dan Fandrich
4e920fe2be Fixed some spelling mistakes in documentation. 2007-04-12 21:30:03 +00:00
Dan Fandrich
164c6e9fc5 libssh2_channel_close now waits for a SSH_MSG_CHANNEL_CLOSE message
from the server as mandated by the RFC.  Not doing so causes an OpenSSH
server to occasionally corrupt (truncate) short files uploaded by scp
(which manifests itself as a failure of test603 in the curl regression
test suite).
2007-04-12 21:24:36 +00:00
Simon Josefsson
0cf3845302 Replace #if !WIN32 with #if HAVE_SYS_SOCKET_H and HAVE_SYS_IOCTL_H
(AIX needs sys/ioctl.h).  Reported by Michael Augustin
<maugustin-hi6Y0CQ0nG0@public.gmane.org>.
2007-04-11 07:22:33 +00:00
Simon Josefsson
149af707de Use _libssh2_* namespace. Suggested by Guenter Knauf
<eflash-hi6Y0CQ0nG0@public.gmane.org>.
2007-04-05 20:36:17 +00:00
Simon Josefsson
e1bc0adcb1 Use Bruno's M4 macros to search for libgcrypt. 2007-04-05 10:23:54 +00:00
Simon Josefsson
2f207bdad5 *** empty log message *** 2007-04-05 10:21:09 +00:00
Simon Josefsson
7972822465 Remove generated files. 2007-04-05 10:00:26 +00:00
Simon Josefsson
b370b89eeb Moved to README. 2007-04-05 09:59:48 +00:00
Simon Josefsson
01d7396160 Need sys/ioctl.h for FIONBIO, tiny patch from Michael Augustin
<maugustin@gmx.net>.
2007-04-05 09:58:25 +00:00
Simon Josefsson
43e377c08e Fix AIX problem, based on patch from Michael Augustin <maugustin@gmx.net>. 2007-04-05 09:31:38 +00:00
Simon Josefsson
348b914ab7 Protect #include of zlib.h if we build without zlib. 2007-04-04 14:44:50 +00:00
Mikhail Gusarov
e7b3a2efc5 Enabled fragmenting SFTP requests to LIBSSH2_SFTP_PACKET_MAXLEN.
(Thanks to elifantu@mail.ru for the patch)
2007-04-01 08:04:32 +00:00
Mikhail Gusarov
56608a799f Missing brace added 2007-04-01 07:40:49 +00:00
Mikhail Gusarov
f29f85f482 libssh2_sftp_read should not return error if it receives SSH_FX_EOF code in
SSH_FXP_STATUS packet.

(Thanks to elifantu@mail.ru for the patch)
2007-04-01 06:23:49 +00:00
Daniel Stenberg
2a48f54937 Callers should be using libssh2_packet_require_ex instead of
libssh2_packet_ask_ex. The purpose of these calls is to clear out any packets
that may have arrived already, so there's no need to poll for more.
(Dan Fandrich)
2007-03-31 20:28:29 +00:00
Simon Josefsson
4c7ecad34d Don't use CPP symbol _MSC_VER unless it is defined, because undefined
CPP symbols means 0.  Tiny patch from "Yang Tse" <yangsita@gmail.com>.
2007-03-29 08:11:51 +00:00
Simon Josefsson
53d6597569 Need -no-undefined for AIX/cygwin/mingw32 etc. Reported by "Yang Tse"
<yangsita@gmail.com>.
2007-03-29 08:10:22 +00:00
Simon Josefsson
af12b96a80 Add comment. 2007-03-27 15:57:23 +00:00
Simon Josefsson
e854459839 Set $SHLIB_SUFFIX_NAME properly, tiny patch from Daniel Johnson
<daniel@daniel-johnson.org>.
2007-03-27 15:56:08 +00:00
Simon Josefsson
af00ce242e Remove -no-install since it breaks Darwin builds (probably a libtool
bug), report from Daniel Johnson <daniel@daniel-johnson.org>.
2007-03-27 15:35:37 +00:00
Simon Josefsson
fa1d8da7a3 Generated. 2007-03-27 13:33:18 +00:00
Simon Josefsson
2d7f1ad47c fix 2007-03-27 13:32:57 +00:00
Simon Josefsson
0ace54f5b6 Add. 2007-03-27 13:27:13 +00:00
Simon Josefsson
7ebafd3999 Add. 2007-03-27 13:24:01 +00:00
Simon Josefsson
86cdc614c8 Add -lsocket/-lnsl. End sentences with '.'. 2007-03-27 13:21:24 +00:00
Simon Josefsson
15d9b50be4 Add. Start sentences with uppercase. 2007-03-27 13:20:18 +00:00
Simon Josefsson
ebc55b5d75 Use AC_SEARCH_LIBS on socket() for -lsocket, so we don't link with
-lsocket unless it is necessary.
Remove SHLIB_LDFLAGS, it was never used by anything.
2007-03-27 13:11:19 +00:00
Simon Josefsson
cf9ffc053a Add jehousley. 2007-03-27 13:07:20 +00:00
Simon Josefsson
25a810bbc8 Fix typo. 2007-03-27 13:05:35 +00:00
Simon Josefsson
db2a895ecf (libssh2_poll_channel_write, libssh2_poll_listener_queued): Mark as
static.  Remove unneeded prototypes.  Break Solaris 10 builds
according to "Heiko Jansen" <jansen@hbz-nrw.de>.
2007-03-27 13:03:46 +00:00
Simon Josefsson
94a71fe995 (libssh2_packet_x11_open, libssh2_packet_queue_listener): Mark as
static functions.  Remove unnecessary prototypes.  Breaks Solaris 10
builds according to "Heiko Jansen" <jansen@hbz-nrw.de>.
2007-03-27 13:02:01 +00:00
Simon Josefsson
0eabcb386e Search -lnsl for inet_addr, suggested by "Heiko Jansen"
<jansen@hbz-nrw.de>.
2007-03-27 12:59:00 +00:00
Simon Josefsson
93dc3f565e Fix typo, reported by "Heiko Jansen" <jansen@hbz-nrw.de>. 2007-03-27 12:52:16 +00:00
Simon Josefsson
48410937b2 Dist buildconf, suggested by "Heiko Jansen" <jansen@hbz-nrw.de>. 2007-03-27 12:50:09 +00:00
Simon Josefsson
864ceec7bd Add 'dist_' to make sure man pages are included in the release. 2007-03-27 12:48:53 +00:00
Simon Josefsson
8ac3f7e485 Add rule to generate ChangeLog.
No need for foreign or nostdinc (correct me if I'm wrong?).
2007-03-27 12:44:44 +00:00
Simon Josefsson
2e20808f8c Add, needed by cvs2cl. 2007-03-27 12:32:56 +00:00
Simon Josefsson
53fb8b1969 Add. 2007-03-27 12:28:18 +00:00
Simon Josefsson
7dfbbf9c1c Remove. 2007-03-27 12:24:56 +00:00
Simon Josefsson
d131f6457c Add, from LICENSE. 2007-03-27 12:24:35 +00:00
Simon Josefsson
a3a9b0385e Rewrite, based on INSTALL. 2007-03-27 12:22:22 +00:00
Simon Josefsson
20297b51bd Add, from README. 2007-03-27 12:10:25 +00:00
Daniel Stenberg
ba9f0b2ce6 Dan Fandrich fixed another memory leak, this time in the OpenSSL interface
code:

It's not clear to me whether all the BN_news in _libssh2_rsa_new need to
be cleaned up, too.  The OpenSSL docs for RSA_free implies that you don't
need to, and valgrind doesn't complain, so it's probably OK as is.
2007-03-15 21:37:43 +00:00
Daniel Stenberg
56f606a98e give credit to those who made the changes 2007-03-15 20:57:11 +00:00
Daniel Stenberg
b553f1087e fixed a memory leak in the packet handling (Dan Fandrich) 2007-03-15 20:56:45 +00:00
Daniel Stenberg
75ceed5776 Dan Fandrich patch:
1 - let libssh2 compile with OpenSSL 0.9.6b.  This is due to 'crypt' is found
in one of its header files and EVP_MAX_BLOCK_LENGTH not being found.

2 - The EXEEXT patch is because automake 1.7 doesn't support it, and recent
automakes add it automatically
2007-03-14 21:59:12 +00:00
Daniel Stenberg
689c394c57 Added sftpdir, a sample doing an SFTP directory listing 2007-02-23 11:18:41 +00:00
Daniel Stenberg
de60096af1 nicer look 2007-02-23 10:38:14 +00:00
Daniel Stenberg
9aa460b55b more/updated man pages 2007-02-23 10:20:56 +00:00
Daniel Stenberg
7c115d350c Lucas Newman found and fixed a problem where libssh2_packet_read() could "lose"
bytes when it read data from the network that was an unaligned number of bytes
compared to the blocksize.
2007-02-14 20:50:43 +00:00
Daniel Stenberg
1ce26ef4a2 add include to fix compiler warning 2007-02-08 14:50:33 +00:00
Daniel Stenberg
92c75854fb Guenter Knauf added support for another IP and I changed the order of the
arguments and updated some comments.
2007-02-08 14:44:32 +00:00
Daniel Stenberg
f015b10b02 Guenter Knauf's Netware+Win32 updates after my recent changes 2007-02-08 14:34:41 +00:00
Daniel Stenberg
972d6d8bd4 removed unused variable 2007-02-07 21:42:45 +00:00
Daniel Stenberg
fee0239211 setting sockets non-blocking using more portable code and configure macros
from the libcurl project (written by me)
2007-02-07 21:39:17 +00:00
Daniel Stenberg
e7181a8c36 Netware and Windows fixes by Guenter Knauf 2007-02-07 21:21:06 +00:00
Daniel Stenberg
b88eb6a096 let's call the current version 0.15-CVS 2007-02-06 14:19:59 +00:00
Simon Josefsson
f6e26916ac Remove unused uses of -lm and math.h. 2007-02-04 13:16:17 +00:00
Simon Josefsson
39876b2ee3 Fix. 2007-02-04 13:10:46 +00:00
Daniel Stenberg
4f1cfb20a9 1 - new public function libssh2_trace() that enables tracing/debug output on
various stuff if libssh2 was built with debug. If built without debug, the
 function does nothing.
2 - configure --enable-debug is now enough to build a debug version (including
picky compiler options)
3 - internally, we no longer need/use #ifdef/#endif around all uses of the
_libssh2_debug() function/macro.

The scp.c example is the first application to test this new debug logging.
2007-02-02 23:23:36 +00:00
Daniel Stenberg
6304383c91 non-blocking and man pages 2007-02-02 22:28:48 +00:00
Daniel Stenberg
bd1980ea1c Include man pages in distro tarball and make install. Note that this is still
(by far) an incomplete set of man pages.
2007-02-02 22:27:06 +00:00
Daniel Stenberg
be4c3f59d4 bump the version-info due to the changes in the API we're working on and due
to the fact that there's release of the previous CVS-state shipped in Debian
(and possibly others distros).
2007-02-02 22:09:30 +00:00
Daniel Stenberg
9d55db6501 Adding src/transport.c for the SECSH transport layer read/write in a non-
blocking way. The channel code is now responsible for enabling/disabling
blocking status and to work with it.

I've also modified indenting and fixed compiler warnings at places, and
added a bunch of new examples in example/simple that I've used to verify that
the code still runs like before.

libssh2_channel_{read|write}nb_ex() and libssh2_sftp_{read|write}nb() are the
four new functions that supposedly work non-blocking.
2007-02-02 16:21:20 +00:00
Daniel Stenberg
c63ef86075 non-blocking stuff removed, see *readnb_ex() 2007-02-02 16:11:55 +00:00
Daniel Stenberg
1b733d1196 more docs, including a template.3 for new man pages 2007-02-02 16:09:12 +00:00
Simon Josefsson
3c61a44224 Libgcrypt stuff works. 2007-02-02 11:22:39 +00:00
Simon Josefsson
20527d9688 Mind your p's and q's! RSA authentication now works. 2007-02-02 11:18:34 +00:00
Daniel Stenberg
09ee2d4086 Chris Nystrom helped me realize I must count the received bytes myself to
know when the transfer is complete
2007-02-01 22:39:45 +00:00
Daniel Stenberg
5859642888 oops, it shouldn't be non-blocking when doing blocking transfers... 2007-01-30 11:10:26 +00:00
Daniel Stenberg
ba1eb9f8fc simple (blocking) SCP transfer 2007-01-30 11:07:14 +00:00
Daniel Stenberg
e2f6518d95 two simple samples 2007-01-24 14:15:36 +00:00
Daniel Stenberg
a139ab0b45 fix compiler warnings 2007-01-23 21:36:40 +00:00
Simon Josefsson
f1e7eb7ae8 Fix RSA private key reading (still not working). 2007-01-23 15:12:41 +00:00
Simon Josefsson
b790cabf6a Fix warnings. 2007-01-23 13:55:11 +00:00
Simon Josefsson
d2be40421a Fix warnings. 2007-01-23 12:44:14 +00:00
Simon Josefsson
b1d855d1ac Fix warnings. 2007-01-23 12:44:14 +00:00
Simon Josefsson
1826e7365d Fix warnings. 2007-01-23 12:32:06 +00:00
Simon Josefsson
7f9ea39a5d Fix mem leak. 2007-01-23 12:26:36 +00:00
Simon Josefsson
6cf4420264 Fix mem leak. 2007-01-23 12:18:50 +00:00
Simon Josefsson
bfb71f3075 Need more #include's. 2007-01-23 11:53:27 +00:00
Simon Josefsson
1f232d69ed Fix warnings. 2007-01-23 11:52:23 +00:00
Simon Josefsson
f252d350ec Fix warnings. 2007-01-23 11:52:08 +00:00
Simon Josefsson
4c2c468b08 Remove OpenSSL #include. 2007-01-23 11:29:13 +00:00
Simon Josefsson
a86a4e0cfc Fix mem leak. 2007-01-23 11:28:05 +00:00
Simon Josefsson
b1f8bafb64 If --with-libgcrypt is specified, don't check for OpenSSL. 2007-01-23 10:37:14 +00:00
Simon Josefsson
c9d40afa14 Abstract bignum API. 2007-01-23 10:29:55 +00:00
Simon Josefsson
51b9ff0f16 Abstract RSA/DSA private key file reading and RSA/DSA signing, and
implement them in openssl/libgcrypt layer.
2007-01-23 08:22:54 +00:00
Simon Josefsson
0d9a7e3c2e Add prototypes for pem.c functions. 2007-01-23 08:14:14 +00:00
Simon Josefsson
75115045ae Add pem.c. 2007-01-23 08:13:32 +00:00
Simon Josefsson
be984707e2 Add. Functions for reading PEM files and decoding ASN.1. 2007-01-23 08:13:10 +00:00
Daniel Stenberg
2afd706ca1 please picky compiler 2007-01-22 21:40:44 +00:00
Simon Josefsson
fe979040a2 Remove non-iovec based RSA/DSA signing (not used, and DSA code even buggy). 2007-01-22 14:15:38 +00:00
Daniel Stenberg
0fab9e9614 fix warning for memcpy() 2007-01-19 21:32:31 +00:00
Simon Josefsson
576d37dafd Indent.
Fix mem leak on errors.
2007-01-18 11:37:32 +00:00
Simon Josefsson
a0eda7365e Remove openssl #include.
Protect use of 3DES.
Reorder definitions to match preference order.
2007-01-18 11:32:20 +00:00
Simon Josefsson
1f79c7da95 Remove debug code. 2007-01-18 11:30:23 +00:00
Simon Josefsson
6ede32c5e2 Use new generic crypto APIs. 2007-01-18 11:22:10 +00:00
Simon Josefsson
10efccbb83 Align with new _LIBSSH2_CRYPT_METHOD API, for libgcrypt support. 2007-01-18 11:21:39 +00:00
Simon Josefsson
2e8d9217b4 Fix _LIBSSH2_CRYPT_METHOD for libgcrypt support. 2007-01-18 11:21:12 +00:00
Simon Josefsson
d3c334c3d6 Implement new _libssh2_cipher_* API. 2007-01-18 11:20:17 +00:00
Simon Josefsson
e1bebf979b Support DSA verifications. 2007-01-18 07:51:41 +00:00
Simon Josefsson
50d587e2bc Check return value.
Fix SHA1_Final.
2007-01-18 07:47:54 +00:00
Simon Josefsson
e0fe196e45 Add. 2007-01-17 20:22:12 +00:00
Simon Josefsson
dc994f64a9 Add more files. 2007-01-17 20:21:47 +00:00
Simon Josefsson
46cd4f42d8 Add more files. 2007-01-17 20:20:49 +00:00
Simon Josefsson
19690441cd Fix 3DES check. 2007-01-17 15:09:04 +00:00
Simon Josefsson
dc7cdb8cb0 Use libssh2_sha1 instead of SHA1. 2007-01-17 15:07:54 +00:00
Simon Josefsson
be4461e4cd Fix last commit. 2007-01-17 15:06:53 +00:00
Simon Josefsson
23d772867e Use libssh2_* wrappers for SHA-1. 2007-01-17 15:05:57 +00:00
Simon Josefsson
c090ac7ed1 Use LIBSSH2_* instead of OPENSSL_NO_* (should ultimately be possible
to chose by ./configure?).
2007-01-17 15:01:29 +00:00
Simon Josefsson
6873ada0b7 Use LIBSSH2_* instead of OPENSSL_NO_* (should ultimately be possible
to chose by ./configure?).
2007-01-17 14:41:06 +00:00
Simon Josefsson
5c904b112e Unconditionally use SHA-1. 2007-01-17 14:35:40 +00:00
Simon Josefsson
b4d7a4eede Add. 2007-01-16 15:51:31 +00:00
Simon Josefsson
22225099bc Add. 2007-01-16 15:36:43 +00:00
Simon Josefsson
2d8ee8b37c Begin to abstract RSA operations. 2007-01-16 15:33:09 +00:00
Simon Josefsson
219fa19a5f Also build openssl.c or libgcrypt.c. 2007-01-16 15:32:17 +00:00
Simon Josefsson
5443c76c8e Define an automake conditional iff libgcrypt is used. 2007-01-16 15:13:50 +00:00
Simon Josefsson
79761a6455 Use generic APIs for (HMAC-)MD5/SHA1 and RNG, and implement them via OpenSSL/libgcrypt. 2007-01-15 21:12:00 +00:00
Simon Josefsson
362d3466cf Add, for libgcrypt. 2007-01-15 18:16:27 +00:00
Simon Josefsson
6d65428511 Look for libgcrypt if --with-libgcrypt is given to ./configure.
Note that until the libgcrypt work is complete, libssh2 also link to OpenSSL.
2007-01-15 18:16:07 +00:00
Simon Josefsson
677005375b Remove unfinished OPENSSL_NO_SHA ifdef stuff, since SHA-1 is required for libssh2 to work. 2007-01-10 17:29:46 +00:00
Simon Josefsson
8a2421bad1 Add basic self test. 2007-01-09 09:49:15 +00:00
Mikhail Gusarov
5cd3efc297 --copy added to automake --add-missing to avoid symlinks in bootstrapped CVS snapshot tarballs 2007-01-03 09:56:31 +00:00
Mikhail Gusarov
f527a88095 Minus sign escaped to not be treated as emdash in man pages. 2007-01-02 05:47:00 +00:00
Daniel Stenberg
fd2368d2b1 fix compiler warnings (and some indent changes) 2006-12-21 14:21:38 +00:00
Daniel Stenberg
036bb51421 fix compiler warnings 2006-12-21 14:20:20 +00:00
Daniel Stenberg
c92d1a5a23 fix compiler warnings, minor re-indenting 2006-12-21 14:19:42 +00:00
Daniel Stenberg
862a758026 Added an initial set of man pages. 2006-12-21 14:09:12 +00:00
Daniel Stenberg
f7f897df07 fix warnings and allow passing user name and password on the command line 2006-12-21 14:06:49 +00:00
Daniel Stenberg
ef8d1a2af8 Added the configure option --enable-debug-build which not only enables a
debug build (using -g and disabling all -O options), but also sets a whole
range of picky/strict compiler options depending on what compiler and version
that is used. This function is ripped right off the curl configure script,
written by yours truly. I left it using the same name as in the curl script
to 1) make it obvious where it comes from, so that 2) it will be easier to
update and keep it in sync with future modifications.

Now, this shows MAAAAAAAAANY warnings...
2006-12-13 08:45:49 +00:00
Daniel Stenberg
556cafc457 Removed use of ceil() since that is a math lib function and getting the
exact accuracy of the microsecond to millisecond conversion simply cannot
be that important. We don't even explicitly link with -lm...
2006-12-13 08:42:54 +00:00
Simon Josefsson
75b5e06773 Fix indentation. 2006-12-09 09:06:06 +00:00
Simon Josefsson
91e496ff41 Add. 2006-12-07 16:12:44 +00:00
Simon Josefsson
6b1dc88b14 Add autobuild.m4, to make it easier to use http://autobuild.josefsson.org/. 2006-12-07 15:53:01 +00:00
Simon Josefsson
14b9deef24 Move symmetric OpenSSL EVP crypto calls to crypt.c. 2006-12-07 15:44:07 +00:00
Mikhail Gusarov
82d762cae5 Improve detection of closed channel. Eleminates lock-ups on
multi-channel operation.
2006-11-27 07:37:40 +00:00
Mikhail Gusarov
1c1c74479e Reading bigger blocks from network before decryption.
Significantly increases performance.
2006-11-27 07:31:28 +00:00
Mikhail Gusarov
3a33680e14 write(2) may write only part of passed data under FreeBSD.
Make sure whole buffer is written.
2006-11-27 07:24:18 +00:00
Daniel Stenberg
38fea1973d mention a few recent changes 2006-11-24 10:14:31 +00:00
Daniel Stenberg
c63a212559 Add builddir/src to the include path, for the generated config header when
building out of the source tree.
2006-11-20 22:21:01 +00:00
Daniel Stenberg
a8451f58df ssh2_sample now gets the right include path to the current include directory 2006-11-20 22:19:40 +00:00
Daniel Stenberg
1dbe8ff365 check for inline in configure 2006-11-20 22:10:56 +00:00
Daniel Stenberg
82424d6735 Starting now, we use automake and libtool for the build. 2006-11-20 08:58:29 +00:00
Daniel Stenberg
3b1b45e644 Moved the private include files libssh2_priv.h and libssh2_config.h.in from
include/ into the src/ directory. The include/ dir is now strictly for public
headers.

Also, I removed the special win32 source package creation target in the
makefile and I modified the contact email address in configure.in to point out
the libssh2-devel list.
2006-11-20 08:41:04 +00:00
Daniel Stenberg
84f10fca87 kill compiler warnings 2006-11-19 13:39:01 +00:00
Daniel Stenberg
077ba3efd5 until we automake, let 'make' build all by default 2006-11-19 13:28:03 +00:00
Daniel Stenberg
ab26693769 kill warnings 2006-11-19 13:26:19 +00:00
Daniel Stenberg
1854b4536f Use pkg-config --cflags-only-I when getting the include files necessary to
build with OpenSSL. Previous approach caused a bad compiler option get set.
2006-11-17 10:26:11 +00:00
James Housley
1baaa31792 Patch from Daniel Stenberg
1 - #include <inttypes.h> and uses uint32_t (this is not very portable and
    need attention as I mentioned in my separate mail)

2 - changes libssh2_blocking_read() to return ssize_t and all code that uses
    this function explicitly checks its return code (better).

3 - I fixed a bunch of compiler warnings where functions got called with
    unsigned char * when they expect char *. I strongly suggest we patch away
    all warnings - now.
2006-11-14 01:30:39 +00:00
James Housley
7058b7fc2a Reproduce most of the POSIX permission/file type defines from sys/stat.h
so that if compiled with a non-POSIX compiler these are still available
for client software.
2006-11-13 22:35:02 +00:00
James Housley
1e889ca947 As pointed out, feof() will always fail after a rewind 2006-11-13 15:10:38 +00:00
James Housley
bebd14a011 Bug: [ 1592645 ] Public key can not be readed from file
While posting a public key file to a remote server via cut-n-paste it
is possible that the key won't have the proper ending.  It might not have
the standard carriage return or line feed.  It might even have extra
spaces.  This patch is based on the originators original patch, but is
more extensive.  If reading the file ends in EOF, remove that character.
Then if there are spaces at the end of the file remove them also.

This does not fix the posibility of the same error in a multi-key file, but
it is a start.
2006-11-13 11:33:03 +00:00
James Housley
7063d24724 /* RFC4253 section 6.1 Maximum Packet Length says:
*
 * "All implementations MUST be able to process packets with
 * uncompressed payload length of 32768 bytes or less and
 * total packet size of 35000 bytes or less (including length,
 * padding length, payload, padding, and MAC.)."
 */
Protect against an improper packet from producing unreasonable values.
Credit goes to Daniel Stenberg
2006-11-10 13:47:13 +00:00
James Housley
8069fa6f9a libssh2_sftp_readdir() wasn't null terminating the filename. If there is
enough room in the buffer, all a null to the end.
2006-11-10 12:16:24 +00:00
James Housley
1961e07287 The public *_ex() API functions, most of them, used "int" for length values.
The convience functions pass in the return from strlen() which is "size_t",
usually an "unsigned long".  This created the possiblility of passing in
a value that could look negative.

All "int" lengths were converted to "unsigned int".  Ideally they should
all become "size_t", but that is a bigger change.  This is a good start.
2006-11-04 19:30:31 +00:00
Sara Golemon
ace0c8f00b Bump for release 2006-06-22 18:50:26 +00:00
Sara Golemon
adee5e5653 Don't wait for KEX_INIT prior to sending our own packet.
Watch out for bad KEX_INIT guesses and burn packets if necessary.
2006-06-22 18:45:29 +00:00
Sara Golemon
5f85317efa Swap ordering of packet_add/packet-inspection to avoid inspect after free. Fix OpenSSL detection using pkg-config. 2006-05-26 22:36:48 +00:00
Sara Golemon
09b93e4bb6 Map Win32 errno values 2006-04-17 02:49:44 +00:00
Sara Golemon
19cad102f4 autoconf already handles -g for us 2006-04-07 20:44:26 +00:00
Sara Golemon
4d7726c551 Plug leaks caused by not using OpenSSL's EVP interface correctly 2006-04-06 21:50:37 +00:00
Sara Golemon
37307a8778 Map win32 error codes 2006-04-05 05:36:53 +00:00
Sara Golemon
fbcdff2161 Allow socket_fd == 0 in libssh2_session_startup() 2006-03-08 19:10:53 +00:00
Sara Golemon
c45992da55 Bump copyright year 2006-03-02 01:10:52 +00:00
Sara Golemon
2207b99afb Bump version number 2006-03-02 01:10:06 +00:00
Sara Golemon
1d7522bc06 BugFix#1436593: Apply build options for HPUX targets 2006-02-23 23:14:35 +00:00
Mikhail Gusarov
a4e61c265b Fixed errorneous flushing packets for unrelated channels when one is closed
(thanks to Alexander Holyapin)
2006-02-20 08:39:54 +00:00
Sara Golemon
502a48afa1 Fix make install on MacOSX 2006-01-06 17:34:03 +00:00
Sara Golemon
efc3841fd2 Add terminating NULL to readlin/realpath results 2005-11-17 23:20:32 +00:00
Sara Golemon
f9d65b0984 Fix miscellaneous bugs in src/channel.c and src/packet.c
Courtessy David Robins
2005-11-02 00:26:24 +00:00
Sara Golemon
edcdf43264 Prep for release 2005-11-01 23:11:50 +00:00
Mikhail Gusarov
722470994a Added missing '#ifdef __cplusplus extern "C" {}' stanza 2005-10-04 04:25:24 +00:00
Sara Golemon
14f00247a8 Explicitly include sha.h and md5.h from openssl 2005-08-25 20:50:37 +00:00
Sara Golemon
78048973c5 Fix x11_req. Multiple packet_len issues and error handling logic. (Simon Hart) 2005-08-10 21:37:44 +00:00
Sara Golemon
e15f5d97a0 Add publickey subsystem support 2005-07-21 20:28:07 +00:00
Sara Golemon
01de39e585 Fix generation of 'e' portion of Diffie-Hellman keyset. 2005-07-11 15:56:09 +00:00
Sara Golemon
6cc50263e2 Fix rename op -- Take 2 2005-07-06 17:50:53 +00:00
Sara Golemon
beca3742a2 Correct ancient typos in error messages 2005-07-06 16:27:54 +00:00
Sara Golemon
d6cfa7c6b9 bump for release -- 0.11 2005-07-05 01:42:11 +00:00
Sara Golemon
ae17fbcd2c BFN 2005-07-05 01:38:41 +00:00
Mikhail Gusarov
0c53895bc0 libssh2_poll_channel_read made external 2005-06-24 11:22:10 +00:00
Mikhail Gusarov
dc446eff08 Debug output slightly fixed 2005-06-24 11:18:20 +00:00
Mikhail Gusarov
aa6e9c6eca Added libssh2_channel_wait_close() 2005-06-24 11:17:50 +00:00
Mikhail Gusarov
2e097c7760 Memory leak liquidated - free the SSH_MSG_CHANNEL_REQUEST packet data
after processing 'exit-status' message
2005-06-23 08:22:04 +00:00
Mikhail Gusarov
77bd3c1215 'exit-status' information packet handling added 2005-06-23 05:55:01 +00:00
Mikhail Gusarov
0e5eb4d9c5 Added extern "C" declaration for C++ compatibility 2005-06-20 05:17:51 +00:00
Mikhail Gusarov
8ee79a5118 Fixed keyboard-interactive authentication, debug output added 2005-06-18 12:18:07 +00:00
Mikhail Gusarov
0ad861d74c libssh2_userauth_list should return char*, not the const char* 2005-06-18 11:30:31 +00:00
Mikhail Gusarov
b6d13ebe8a Strictening function prototypes: char* -> const char* where applicable 2005-06-18 10:41:59 +00:00
Sara Golemon
06e1136ea0 Don't send flags for rename op if the sftp version is too low 2005-06-17 17:18:25 +00:00
Sara Golemon
2a6c49a73a Add abstract pointer to keyboard-interactive callback 2005-06-16 17:14:31 +00:00
Sara Golemon
da653774aa Add keyboard interactive authentication.
Implementation contributed by Mikhail Gusarov.
2005-06-11 19:18:06 +00:00
Sara Golemon
9203a62789 Late commit -- This is for release 0.10 2005-05-24 14:01:38 +00:00
Sara Golemon
6de7ed8a7b Drop these old references to initial window size, they were a mistake 2005-05-18 17:12:40 +00:00
Sara Golemon
8937980044 BFN 2005-05-18 17:10:27 +00:00
Sara Golemon
cc7703092f Save up multiple small refunds in order to cut down on unnecessary WINDOW_ADJUST packets 2005-05-18 17:08:29 +00:00
Sara Golemon
7502920c7f Remove /test/* 2005-05-17 19:30:59 +00:00
Sara Golemon
ff6f2dbe52 Typo: ALWAYS TEST FIRST 2005-05-17 17:18:48 +00:00
Sara Golemon
e5ee4a5be3 Fix sftp packet queueing mechanism 2005-05-17 05:22:41 +00:00
Sara Golemon
30bb7db0d1 Reduce busy-looping of libssh2_sftp_packet_requirev() 2005-05-16 23:12:09 +00:00
Sara Golemon
8d90bbfc28 Fix segfault when client/host can't agree on hostkey/crypt/mac/comp 2005-05-16 17:16:25 +00:00
Sara Golemon
e9b0710b4b Fix format specifiers 2005-05-11 05:26:12 +00:00
Sara Golemon
379e510c87 Whoops 2005-05-11 05:16:32 +00:00
Sara Golemon
ebfbd22e59 Add debugging hooks for development diagnostics 2005-05-11 05:11:31 +00:00
Sara Golemon
9a0ba35457 Ignore extended data in the SFTP layer. 2005-05-10 04:57:34 +00:00
Sara Golemon
023c54d95d One last (better be last) fix for FXP_INIT 2005-05-10 04:49:43 +00:00
Sara Golemon
ba2f21eb85 More fixes for channel_write() 2005-05-06 18:30:43 +00:00
Sara Golemon
3ea661a574 Bump for release 2005-05-05 18:48:51 +00:00
Sara Golemon
30755999c5 Check for and link against libm and libsocket 2005-05-05 18:45:42 +00:00
Sara Golemon
8e0e6d81dd Block means block 2005-05-04 19:01:48 +00:00
Sara Golemon
cba673de6f Make blocking_read's polling loop less arbitrary 2005-05-04 18:48:47 +00:00
Sara Golemon
11b27e52c3 Put filetype into open/diropen/mkdir attributes 2005-05-04 18:06:07 +00:00
Sara Golemon
f289bcdd54 Fix constant from last patch 2005-05-04 17:52:32 +00:00
Sara Golemon
66e7462f01 Late BFN 2005-05-03 18:35:40 +00:00
Sara Golemon
ed88c32368 FXP_INIT packet should not have had a request_id component and sftp_packet_require shouldn't expect FXP_VERSION to have one when coming back. Thanks puudeli! 2005-05-03 13:57:40 +00:00
Sara Golemon
83b95eb13e Fixed SFTP to be properly BC with version 1 and 2 servers 2005-04-07 21:53:55 +00:00
Sara Golemon
ba420fc7bf Block means block. 2005-04-05 23:08:41 +00:00
Sara Golemon
ae9ad1ef6f break; fallthroughs in win32 code 2005-04-02 05:43:17 +00:00
Sara Golemon
d3f854c21b Phase II of packet loop migration: Clean code is good code 2005-04-01 20:17:09 +00:00
Sara Golemon
5d9c0d50f3 Another typo 2005-04-01 15:34:14 +00:00
Sara Golemon
35a3e7a6c0 typo 2005-04-01 06:55:44 +00:00
Sara Golemon
15b8489046 Phase 1 of the Great Timeout Cleanup 2005-04-01 06:11:34 +00:00
Sara Golemon
dce388e9c5 Nix unused variable 2005-03-28 23:03:41 +00:00
Sara Golemon
0138e36352 Add libssh2_channel_window_(read|write)_ex() 2005-03-28 22:59:35 +00:00
Sara Golemon
d6039f39e4 Nix the memset loop
Speaking of which: Why wasn't it JUST a memset() call?

The encrypted version of packet_write fills in this data with OpenSSL
RAND_bytes() data, and as far as the unencrypted version goes?
Well, it's unencrypted, randomness doesn't help at that point.
2005-03-26 05:31:31 +00:00
Sara Golemon
0e0ed2aff4 Don't let a dead session leave poll() hanging 2005-03-26 01:26:14 +00:00
Sara Golemon
7c64e21df6 Bump for release 2005-03-23 00:30:05 +00:00
Sara Golemon
c67bb667aa Add libssh2_poll() 2005-03-23 00:21:26 +00:00
Sara Golemon
141ac5b856 Add sys/uio.h for FBSD builds and remove old stdio references 2005-03-21 21:26:08 +00:00
Sara Golemon
9f64f34dfe Swap compression mode preferences, prefer none over zlib by default 2005-03-17 19:20:32 +00:00
Sara Golemon
a1b87a952c Late news 2005-03-17 19:09:45 +00:00
Sara Golemon
7db9aeecf8 Possible fix for compatability with OpenSSL < 0.9.7 2005-03-02 01:55:51 +00:00
Sara Golemon
99e5547442 strm->next_out doesn't *stay* == out, only free out 2005-02-28 17:02:39 +00:00
368 changed files with 58593 additions and 12016 deletions

View File

@ -1,9 +0,0 @@
*.lib
*.pdb
*.dll
*.exe
*.obj
.*.swp
Debug
Release
*.exp

2
.gitattribute Normal file
View File

@ -0,0 +1,2 @@
win32/msvcproj.head -crlf
win32/msvcproj.foot -crlf

35
.gitignore vendored Normal file
View File

@ -0,0 +1,35 @@
.deps
.libs
*.lib
*.pdb
*.dll
*.exe
*.obj
.*.swp
Debug
Release
*.exp
Makefile
Makefile.in
aclocal.m4
autom4te.cache
config.guess
config.log
config.status
config.sub
configure
depcomp
libtool
ltmain.sh
missing
ssh2_sample
libssh2-*.tar.gz
install-sh
*.o
*.lo
*.la
mkinstalldirs
tags
libssh2.pc
TAGS
*~

75
.travis.yml Normal file
View File

@ -0,0 +1,75 @@
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# Neither the name of the copyright holder nor the names
# of any other contributors may be used to endorse or
# promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
language: c
compiler:
- gcc
- clang
env:
matrix:
- ADDRESS_SIZE=64 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=OFF
- ADDRESS_SIZE=64 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=OFF
- ADDRESS_SIZE=64 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=ON
- ADDRESS_SIZE=64 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=ON
- ADDRESS_SIZE=64 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=OFF
- ADDRESS_SIZE=64 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=OFF
- ADDRESS_SIZE=64 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=ON
- ADDRESS_SIZE=64 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=ON
- ADDRESS_SIZE=32 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=OFF
- ADDRESS_SIZE=32 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=OFF
- ADDRESS_SIZE=32 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=ON
- ADDRESS_SIZE=32 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=ON
- ADDRESS_SIZE=32 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=OFF
- ADDRESS_SIZE=32 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=OFF
- ADDRESS_SIZE=32 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=ON
- ADDRESS_SIZE=32 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=ON
before_install:
- sudo add-apt-repository --yes ppa:kalakris/cmake
- sudo apt-get update
- sudo apt-get -y install cmake
- if [ $ADDRESS_SIZE = '64' ]; then sudo apt-get install -y libgcrypt11-dev libssl-dev zlib1g-dev; fi
- if [ $ADDRESS_SIZE = '32' ]; then sudo apt-get install -y linux-libc-dev linux-libc-dev:i386; fi
- if [ $ADDRESS_SIZE = '32' ]; then sudo apt-get install -y gcc-multilib libgcrypt11-dev:i386 libssl-dev:i386 zlib1g-dev:i386; fi
- if [ $ADDRESS_SIZE = '32' ]; then export TOOLCHAIN_OPTION="-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-Linux-32.cmake"; fi
install:
- mkdir bin
- cd bin
script:
- cmake $TOOLCHAIN_OPTION -DCRYPTO_BACKEND=$CRYPTO_BACKEND -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION .. && cmake --build . && CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test && cmake --build . --target package

101
CMakeLists.txt Normal file
View File

@ -0,0 +1,101 @@
# Copyright (c) 2014, 2015 Alexander Lamaison <alexander.lamaison@gmail.com>
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# Neither the name of the copyright holder nor the names
# of any other contributors may be used to endorse or
# promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
cmake_minimum_required(VERSION 2.8.11)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
project(libssh2 C)
set(PROJECT_URL "https://www.libssh2.org/")
set(PROJECT_DESCRIPTION "The SSH library")
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
# Parse version
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/include/libssh2.h _HEADER_CONTENTS)
string(
REGEX REPLACE ".*#define LIBSSH2_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
LIBSSH2_VERSION "${_HEADER_CONTENTS}")
string(
REGEX REPLACE ".*#define LIBSSH2_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1"
LIBSSH2_VERSION_MAJOR "${_HEADER_CONTENTS}")
string(
REGEX REPLACE ".*#define LIBSSH2_VERSION_MINOR[ \t]+([0-9]+).*" "\\1"
LIBSSH2_VERSION_MINOR "${_HEADER_CONTENTS}")
string(
REGEX REPLACE ".*#define LIBSSH2_VERSION_PATCH[ \t]+([0-9]+).*" "\\1"
LIBSSH2_VERSION_PATCH "${_HEADER_CONTENTS}")
if(NOT LIBSSH2_VERSION OR
NOT LIBSSH2_VERSION_MAJOR MATCHES "^[0-9]+$" OR
NOT LIBSSH2_VERSION_MINOR MATCHES "^[0-9]+$" OR
NOT LIBSSH2_VERSION_PATCH MATCHES "^[0-9]+$")
message(
FATAL_ERROR
"Unable to parse version from"
"${CMAKE_CURRENT_SOURCE_DIR}/include/libssh2.h")
endif()
include(GNUInstallDirs)
install(
FILES docs/AUTHORS COPYING docs/HACKING README RELEASE-NOTES NEWS
DESTINATION ${CMAKE_INSTALL_DOCDIR})
include(max_warnings)
include(FeatureSummary)
add_subdirectory(src)
option(BUILD_EXAMPLES "Build libssh2 examples" ON)
if(BUILD_EXAMPLES)
add_subdirectory(example)
endif()
option(BUILD_TESTING "Build libssh2 test suite" ON)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
add_subdirectory(docs)
feature_summary(WHAT ALL)
set(CPACK_PACKAGE_VERSION_MAJOR ${LIBSSH2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${LIBSSH2_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${LIBSSH2_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${LIBSSH2_VERSION})
include(CPack)

42
COPYING Normal file
View File

@ -0,0 +1,42 @@
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
* Copyright (c) 2005,2006 Mikhail Gusarov <dottedmag@dottedmag.net>
* Copyright (c) 2006-2007 The Written Word, Inc.
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
* Copyright (c) 2009-2014 Daniel Stenberg
* Copyright (C) 2008, 2009 Simon Josefsson
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the copyright holder nor the names
* of any other contributors may be used to endorse or
* promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/

60
INSTALL
View File

@ -1,60 +0,0 @@
Installing libssh2
==================
* Untar this tarball (which, if you're reading this, you've already done)
* Run: ./configure (passing additional options as desired)
In addition the the standard set of ./configure options (e.g. --prefix)
there are five switches which you may wish to pay attention to:
* --with-openssl=[DIR]
libssh2 requires the OpenSSL library (http://www.openssl.org) for
cipher and hash method implementations.
./configure will attempt to locate OpenSSL in a number of default locations:
/usr/local/ssl /usr/local /usr /usr/local/openssl
If your installation of OpenSSL is in another location, specify it here.
* --with-zlib=[DIR]
If present, libssh2 will attempt to use the zlib (http://www.zlib.org)
for payload compression, however zlib is not required.
./configure will attempt to location a zlib installation in a number of default locations:
/usr/local /usr /usr/local/libz /usr/libz /usr/local/zlib /usr/zlib
If your installation of zlib is in another location, you may specify it here.
* --enable-crypt-none
The SSH2 Transport allows for unencrypted data transmission using the "none" cipher.
Because this is such a huge security hole, it is typically disabled on
SSH2 implementations and is diabled in libssh2 by default as well.
Enabling this option will allow for "none" as a negotiable method,
however it still requires that the method be advertized by the remote end
and that no more-prefferable methods are available.
* --enable-mac-none
The SSH2 Transport also allows implementations to forego a message authentication code.
While this is less of a security risk than using a "none" cipher, it is still not
recommended as disabling MAC hashes removes a layer of security.
Enabling this option will allow for "none" as a negotiable method,
however it still requires that the method be advertized by the remote end
and that no more-prefferable methods are available.
* --disable-gex-new
The diffie-hellman-group-exchange-sha1 (dh-gex) key exchange method originally defined
an exchange negotiation using packet type 30 to request a generation pair based
on a single target value. Later refinement of dh-gex provided for range and target
values. By default libssh2 will use the newer range method.
If you experience trouble connecting to an old SSH server using dh-gex,
try this option to fallback on the older more reliable method.
* Run: make all install

2
Makefile.OpenSSL.inc Normal file
View File

@ -0,0 +1,2 @@
CRYPTO_CSOURCES = openssl.c
CRYPTO_HHEADERS = openssl.h

2
Makefile.WinCNG.inc Normal file
View File

@ -0,0 +1,2 @@
CRYPTO_CSOURCES = wincng.c
CRYPTO_HHEADERS = wincng.h

149
Makefile.am Normal file
View File

@ -0,0 +1,149 @@
AUTOMAKE_OPTIONS = foreign nostdinc
SUBDIRS = src tests docs
if BUILD_EXAMPLES
SUBDIRS += example
endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libssh2.pc
include_HEADERS = \
include/libssh2.h \
include/libssh2_publickey.h \
include/libssh2_sftp.h
NETWAREFILES = nw/keepscreen.c \
nw/nwlib.c \
nw/GNUmakefile \
nw/test/GNUmakefile
DSP = win32/libssh2.dsp
VCPROJ = win32/libssh2.vcproj
DISTCLEANFILES = $(DSP)
VMSFILES = vms/libssh2_make_example.dcl vms/libssh2_make_help.dcl \
vms/libssh2_make_kit.dcl vms/libssh2_make_lib.dcl vms/man2help.c \
vms/readme.vms vms/libssh2_config.h
WIN32FILES = win32/GNUmakefile win32/test/GNUmakefile \
win32/libssh2_config.h win32/config.mk win32/rules.mk \
win32/Makefile.Watcom win32/libssh2.dsw win32/tests.dsp $(DSP) \
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc
OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \
os400/make-src.sh os400/make-rpg.sh os400/make-include.sh \
os400/os400sys.c os400/ccsid.c \
os400/libssh2_config.h os400/macros.h os400/libssh2_ccsid.h \
os400/include/alloca.h os400/include/sys/socket.h os400/include/stdio.h \
os400/libssh2rpg/libssh2.rpgle.in \
os400/libssh2rpg/libssh2_ccsid.rpgle.in \
os400/libssh2rpg/libssh2_publickey.rpgle \
os400/libssh2rpg/libssh2_sftp.rpgle \
Makefile.os400qc3.inc
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk \
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath \
CMakeLists.txt cmake $(OS400FILES)
ACLOCAL_AMFLAGS = -I m4
.PHONY: ChangeLog
ChangeLog:
echo "see NEWS" > ./ChangeLog
DISTCLEANFILES += ChangeLog
dist-hook:
rm -rf $(top_builddir)/tests/log
find $(distdir) -name "*.dist" -exec rm {} \;
(distit=`find $(srcdir) -name "*.dist"`; \
for file in $$distit; do \
strip=`echo $$file | sed -e s/^$(srcdir)// -e s/\.dist//`; \
cp $$file $(distdir)$$strip; \
done)
# Code Coverage
init-coverage:
make clean
lcov --directory . --zerocounters
COVERAGE_CCOPTS ?= "-g --coverage"
COVERAGE_OUT ?= docs/coverage
build-coverage:
make CFLAGS=$(COVERAGE_CCOPTS) check
mkdir -p $(COVERAGE_OUT)
lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \
--capture
gen-coverage:
genhtml --output-directory $(COVERAGE_OUT) \
$(COVERAGE_OUT)/$(PACKAGE).info \
--highlight --frames --legend \
--title "$(PACKAGE_NAME)"
coverage: init-coverage build-coverage gen-coverage
# DSP/VCPROJ generation adapted from libcurl
# only OpenSSL and WinCNG are supported with this build system
CRYPTO_CSOURCES = openssl.c wincng.c
CRYPTO_HHEADERS = openssl.h wincng.h
# Makefile.inc provides the CSOURCES and HHEADERS defines
include Makefile.inc
WIN32SOURCES = $(CSOURCES)
WIN32HEADERS = $(HHEADERS) libssh2_config.h
$(DSP): win32/msvcproj.head win32/msvcproj.foot Makefile.am
echo "creating $(DSP)"
@( (cat $(srcdir)/win32/msvcproj.head; \
echo "# Begin Group \"Source Files\""; \
echo ""; \
echo "# PROP Default_Filter \"cpp;c;cxx\""; \
win32_srcs='$(WIN32SOURCES)'; \
sorted_srcs=`for file in $$win32_srcs; do echo $$file; done | sort`; \
for file in $$sorted_srcs; do \
echo "# Begin Source File"; \
echo ""; \
echo "SOURCE=..\\src\\"$$file; \
echo "# End Source File"; \
done; \
echo "# End Group"; \
echo "# Begin Group \"Header Files\""; \
echo ""; \
echo "# PROP Default_Filter \"h;hpp;hxx\""; \
win32_hdrs='$(WIN32HEADERS)'; \
sorted_hdrs=`for file in $$win32_hdrs; do echo $$file; done | sort`; \
for file in $$sorted_hdrs; do \
echo "# Begin Source File"; \
echo ""; \
if [ "$$file" == "libssh2_config.h" ]; \
then \
echo "SOURCE=.\\"$$file; \
else \
echo "SOURCE=..\\src\\"$$file; \
fi; \
echo "# End Source File"; \
done; \
echo "# End Group"; \
cat $(srcdir)/win32/msvcproj.foot) | \
awk '{printf("%s\r\n", gensub("\r", "", "g"))}' > $@ )
$(VCPROJ): win32/vc8proj.head win32/vc8proj.foot Makefile.am
echo "creating $(VCPROJ)"
@( (cat $(srcdir)/vc8proj.head; \
win32_srcs='$(WIN32SOURCES)'; \
sorted_srcs=`for file in $$win32_srcs; do echo $$file; done | sort`; \
for file in $$sorted_srcs; do \
echo "<File RelativePath=\""..\src\$$file"\"></File>"; \
done; \
echo "</Filter><Filter Name=\"Header Files\">"; \
win32_hdrs='$(WIN32HEADERS)'; \
sorted_hdrs=`for file in $$win32_hdrs; do echo $$file; done | sort`; \
for file in $$sorted_hdrs; do \
echo "<File RelativePath=\""..\src\$$file"\"></File>"; \
done; \
cat $(srcdir)/vc8proj.foot) | \
awk '{printf("%s\r\n", gensub("\r", "", "g"))}' > $@ )

View File

@ -1,64 +0,0 @@
subdirs = src/
top_srcdir = @top_srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @exec_prefix@/lib
incldir = @prefix@/include
distdir = @top_srcdir@/dist
CC = @CC@
CFLAGS = -c @CFLAGS@ -Iinclude/ -Wall -g
LIBS = -lssh2 -Lsrc/
INSTALL = @INSTALL@
VERSION=@PACKAGE_VERSION@
DISTLIB=libssh2-$(VERSION)
all:
@for dir in ${subdirs}; do \
(cd $$dir && $(MAKE) all) \
|| case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
$(CC) -o ssh2_sample.o ssh2_sample.c $(CFLAGS)
$(CC) -o ssh2_sample ssh2_sample.o $(LIBS)
install:
$(top_srcdir)/mkinstalldirs $(DESTDIR)$(incldir)
$(top_srcdir)/mkinstalldirs $(DESTDIR)$(libdir)
@for dir in ${subdirs}; do \
(cd $$dir && $(MAKE) install) \
|| case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
$(INSTALL) -m 644 include/libssh2.h $(DESTDIR)$(incldir)/
$(INSTALL) -m 644 include/libssh2_sftp.h $(DESTDIR)$(incldir)/
clean:
@for dir in ${subdirs}; do \
(cd $$dir && $(MAKE) clean) \
|| case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
rm -f ssh2_sample.o ssh2_sample
dist:
autoheader
autoconf
rm -f $(DISTLIB)
ln -s . $(DISTLIB)
tar -zcf $(DISTLIB).tar.gz \
$(DISTLIB)/configure $(DISTLIB)/Makefile.in $(DISTLIB)/ssh2_sample.c \
$(DISTLIB)/LICENSE $(DISTLIB)/README $(DISTLIB)/INSTALL \
$(DISTLIB)/mkinstalldirs $(DISTLIB)/install-sh $(DISTLIB)/config.sub $(DISTLIB)/config.guess \
$(DISTLIB)/src/*.c $(DISTLIB)/src/Makefile.in \
$(DISTLIB)/include/libssh2.h $(DISTLIB)/include/libssh2_priv.h $(DISTLIB)/include/libssh2_sftp.h \
$(DISTLIB)/include/libssh2_config.h.in \
$(DISTLIB)/win32/config.mk $(DISTLIB)/win32/libssh2_config.h $(DISTLIB)/win32/rules.mk \
$(DISTLIB)/win32/libssh2.dsp $(DISTLIB)/win32/libssh2.dsw $(DISTLIB)/win32/ssh2_sample.dsp
rm -f $(DISTLIB)
dist_nmake:
autoheader
autoconf
rm -f $(DISTLIB)
ln -s . $(DISTLIB)
tar -zcf $(DISTLIB)-win32.tar.gz \
$(DISTLIB)/NMakefile $(DISTLIB)/ssh2_sample.c $(DISTLIB)/src/*.c \
$(DISTLIB)/LICENSE $(DISTLIB)/README $(DISTLIB)/TODO $(DISTLIB)/INSTALL \
$(DISTLIB)/include/libssh2.h $(DISTLIB)/include/libssh2_priv.h $(DISTLIB)/include/libssh2_sftp.h \
$(DISTLIB)/win32/config.mk $(DISTLIB)/win32/libssh2_config.h $(DISTLIB)/win32/rules.mk
rm -f $(DISTLIB)

6
Makefile.inc Normal file
View File

@ -0,0 +1,6 @@
CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \
packet.c publickey.c scp.c session.c sftp.c userauth.c transport.c \
version.c knownhost.c agent.c $(CRYPTO_CSOURCES) pem.c keepalive.c global.c
HHEADERS = libssh2_priv.h $(CRYPTO_HHEADERS) transport.h channel.h comp.h \
mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h

2
Makefile.libgcrypt.inc Normal file
View File

@ -0,0 +1,2 @@
CRYPTO_CSOURCES = libgcrypt.c
CRYPTO_HHEADERS = libgcrypt.h

2
Makefile.os400qc3.inc Normal file
View File

@ -0,0 +1,2 @@
CRYPTO_CSOURCES = os400qc3.c
CRYPTO_HHEADERS = os400qc3.h

3
NEWS Normal file
View File

@ -0,0 +1,3 @@
The old NEWS file.
NEWS is now generated from git and put into the release tarballs.

View File

@ -1,16 +1,33 @@
!include "win32/config.mk"
!if "$(WITH_WINCNG)" == "1"
!include "Makefile.WinCNG.inc"
!else
!include "Makefile.OpenSSL.inc"
!endif
!include "Makefile.inc"
OBJECTS=$(CSOURCES:.c=.obj)
# SUBDIRS=src example
SUBDIRS=src
all: all-sub ssh2_sample.exe
ssh2_sample.exe: ssh2_sample.c
$(CC) $(CFLAGS) -DWIN32 -o ssh2_sample.exe ssh2_sample.c libssh2$(SUFFIX).lib $(LIBS)
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)
-del 2>NUL win32\objects.mk
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
win32\objects.mk: Makefile.inc
@echo OBJECTS = \>$@
@for %O in ($(OBJECTS)) do @echo $$(INTDIR)\%O \>>$@
@echo $$(EOL)>>$@

125
README
View File

@ -1,124 +1,19 @@
libssh2 - SSH2 library
======================
Version 0.7
-----------
libssh2 is a library implementing the SSH2 protocol, available under
the revised BSD license.
Added libssh2_userauth_hostbased_fromfile_ex() for authenticating from hostkey.
Web site: http://www.libssh2.org/
Added configure recognition for MacOSX (Darwin) (Thanks Gabe)
Mailing list: http://cool.haxx.se/mailman/listinfo/libssh2-devel
Fixed extended data identification in libssh2_channel_read().
License: see COPYING
Fixed window adjust code. Hadn't acknowledged adjustments correctly.
Source code: https://github.com/libssh2/libssh2
Removed initial_window_size requirement for sending window adjust packet.
Web site source code: https://github.com/libssh2/www
Version 0.6
-----------
Added LIBSSH2_FLAG_SIGPIPE to enable/disable SIGPIPE generated by send()/recv() calls. Default off.
Added libssh2_session_flag() to set optional session flags.
Collapsed exchanging_keys/newkeys/authenticated flags into single state attribute.
Fix zlib compression issue when internal buffer state misses partial sync.
Fix segfault when libssh2_session_methods() is called prior to session_startup().
Fixed client to server channel windowing. Pervent send queue overruns.
Swapped banner send/receive order (send first, then wait for response).
Version 0.5
-----------
*** BC Break ***
Reimplemented libssh2_session_methods() to match libssh2_session_method_pref() style
Fixed libssh2_attr2bin() (effects any setstat style call).
Fixed authenticating with encrypted private key.
Fixed authenticating via ssh-dss public key.
Fixed KEX_INIT cookie and packet padding to use actual random data
Added DESTDIR support to makefiles (Adam Go³êbiowski -- I hope that character set translates right)
Added libssh2_channel_forward_listen_ex(), libssh2_channel_forward_cancel(), and libssh2_channel_forward_accept().
Added ./configure option '--disable-gex-new' to allow using the older group-exchange format
Added MAC methods hmac-md5 and hmac-md5-96.
Version 0.4
-----------
Fixed crash when trying to free sftp_dirhandle data from a filehandle struct.
Fixed leak in sftp_open_ex(), handle->handle not freed in handle_close().
Fixed leak in sftp_symlink_ex(), result for READLINK and REALPATH not freed unless there was an error.
Added libssh2_banner_set(), specify an arbitrary banner to send on introduction.
Version 0.3
-----------
Fixed libssh2_channel_read_ex(). Packet loop initialized BEFORE transport polled for new packets (should have been after).
Fixed blocking issues in scp_send()/scp_recv().
Fixed degree of indirection in macerror callback.
Changed packet read mechanism to use a fixed buffer and avoid unnecessary alloc/free calls. (especially while non-block looping)
Added channel close callback.
Added SFTP support (Using its own header file: libssh2_sftp.h)
Version 0.2
-----------
Changed extended data ignorance mechanism:
libssh2_channel_ignore_extended_data() changed to libssh2_channel_handle_extended_data()
Macro introduced for backward compatability during beta phase.
*** THE LIBSSH2_CHANNEL_IGNORE_EXTENDED_DATA() MACRO WILL BE REMOVED PRIOR TO 1.0 RELEASE ***
libssh2_channel_handle_extended_data() may be passed one of three "ignore_mode" constants
LIBSSH2_CHANNEL_EXTENDED_DATA_NONE Default behavior, queue ED packets and return them with read_ex
LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE Equivalent to libssh2_channel_ignore_extended_data()
IGNORE will implicitly flush the extended data stream(s)
LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE Calls to channel_read() will check both the standard data stream
and the extended data stream(s) for the first available packet
Changed libssh2_session_disconnect_ex() to return an error code when alloc fails
Added libssh2_channel_flush_ex() and basic macros: ..._flush() ..._flush_stderr()
flush_ex accepts either the streamid (0 for standard data, 1 for stderr) or one of the two following constants:
LIBSSH2_CHANNEL_FLUSH_ALL Flush all streams
LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA Flush all streams EXCEPT the standard data stream
Added libssh2_session_callback_set() for setting ignore/debug/disconnect/macerror callbacks
Added libssh2_session_method_pref() to selectively set methods and method preferences.
Added libssh2_session_methods() to determine what methods were negotiated.
Added libssh2_session_abstract() for retreiving &session->abstract
Added libssh2_session_last_error() for retreiving error codes/messages
Version 0.1
-----------
Initial Release:
KEX methods: diffie-hellman-group14-sha1, diffie-hellman-group-exchange-sha1, diffie-hellman-group1-sha1
Hostkey methods: ssh-rsa, ssh-dss
Cipher methods: aes256-cbc, rijndael-cbc@lysator.liu.se, aes192-cbc, aes128-cbc, blowfish-cbc, arcfour, cast128-cbc, 3des-cbc, none*
Compression methods: zlib, none
MAC methods: hmac-sha1, hmac-sha1-96, hmac-ripemd160, hmac-ripemd160@openssh.com none*
*Cipher/MAC "none" is disabled by default for security purposes,
Use --enable-crypt-none and/or --enable-mac-none with ./configure to enable
Installation instructions are in:
- docs/INSTALL_CMAKE for CMake
- docs/INSTALL_AUTOTOOLS for Autotools

56
RELEASE-NOTES Normal file
View File

@ -0,0 +1,56 @@
libssh2 1.7.0
This release includes the following changes:
o libssh2_session_set_last_error: Add function
o mac: Add support for HMAC-SHA-256 and HMAC-SHA-512
o WinCNG: support for SHA256/512 HMAC
o kex: Added diffie-hellman-group-exchange-sha256 support
o OS/400 crypto library QC3 support
This release includes the following security advisory:
o diffie_hellman_sha256: convert bytes to bits
CVE-2016-0787: http://www.libssh2.org/adv_20160223.html
This release includes the following bugfixes:
o SFTP: Increase speed and datasize in SFTP read
o openssl: make libssh2_sha1 return error code
o openssl: fix memleak in _libssh2_dsa_sha1_verify()
o cmake: include CMake files in the release tarballs
o Fix builds with Visual Studio 2015
o hostkey.c: Fix compiling error when OPENSSL_NO_MD5 is defined
o GNUmakefile: add support for LIBSSH2_LDFLAG_EXTRAS
o GNUmakefile: add -m64 CFLAGS when targeting mingw64
o kex: free server host key before allocating it (again)
o SCP: add libssh2_scp_recv2 to support large (> 2GB) files on windows
o channel: Detect bad usage of libssh2_channel_process_startup
o userauth: Fix off by one error when reading public key file
o kex: removed dupe entry from libssh2_kex_methods
o _libssh2_error: Support allocating the error message
o hostkey: fix invalid memory access if libssh2_dsa_new fails
o hostkey: align code path of ssh_rsa_init to ssh_dss_init
o libssh2.pc.in: fix the output of pkg-config --libs
o wincng: fixed possible memory leak in _libssh2_wincng_hash
o wincng: fixed _libssh2_wincng_hash_final return value
o add OpenSSL 1.1.0-pre2 compatibility
o agent_disconnect_unix: unset the agent fd after closing it
o sftp: stop reading when buffer is full
o sftp: Send at least one read request before reading
o sftp: Don't return EAGAIN if data was written to buffer
o sftp: Check read packet file offset
o configure: build "silent" if possible
o openssl: add OpenSSL 1.1.0-pre3-dev compatibility
o GNUmakefile: list system libs after user libs
This release would not have looked like this without help, code, reports and
advice from friends like these:
Alexander Lamaison, Andreas Schneider, brian m. carlson, Daniel Stenberg,
David Byron, Jakob Egger, Kamil Dudka, Marc Hoersken, Mizunashi Mana,
Patrick Monnerat, Paul Howarth, Salvador Fandino, Salvador Fandiño,
Salvador Fandiño, Viktor Szakats, Will Cosgrove,
(16 contributors)
Thanks! (and sorry if I forgot to mention someone)

384
acinclude.m4 Normal file
View File

@ -0,0 +1,384 @@
dnl **********************************************************************
dnl CURL_DETECT_ICC ([ACTION-IF-YES])
dnl
dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
dnl sets the $ICC variable to "yes" or "no"
dnl **********************************************************************
AC_DEFUN([CURL_DETECT_ICC],
[
ICC="no"
AC_MSG_CHECKING([for icc in use])
if test "$GCC" = "yes"; then
dnl check if this is icc acting as gcc in disguise
AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
dnl action if the text is found, this it has not been replaced by the
dnl cpp
ICC="no",
dnl the text was not found, it was replaced by the cpp
ICC="yes"
AC_MSG_RESULT([yes])
[$1]
)
fi
if test "$ICC" = "no"; then
# this is not ICC
AC_MSG_RESULT([no])
fi
])
dnl We create a function for detecting which compiler we use and then set as
dnl pendantic compiler options as possible for that particular compiler. The
dnl options are only used for debug-builds.
AC_DEFUN([CURL_CC_DEBUG_OPTS],
[
if test "z$ICC" = "z"; then
CURL_DETECT_ICC
fi
if test "$GCC" = "yes"; then
dnl figure out gcc version!
AC_MSG_CHECKING([gcc version])
gccver=`$CC -dumpversion`
num1=`echo $gccver | cut -d . -f1`
num2=`echo $gccver | cut -d . -f2`
gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
AC_MSG_RESULT($gccver)
if test "$ICC" = "yes"; then
dnl this is icc, not gcc.
dnl ICC warnings we ignore:
dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
dnl "invalid format string conversion"
dnl * 279 warns on static conditions in while expressions
dnl * 981 warns on "operands are evaluated in unspecified order"
dnl * 1418 "external definition with no prior declaration"
dnl * 1419 warns on "external declaration in primary source file"
dnl which we know and do on purpose.
WARN="-wd279,269,981,1418,1419"
if test "$gccnum" -gt "600"; then
dnl icc 6.0 and older doesn't have the -Wall flag
WARN="-Wall $WARN"
fi
else dnl $ICC = yes
dnl this is a set of options we believe *ALL* gcc versions support:
WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
if test "$gccnum" -ge "207"; then
dnl gcc 2.7 or later
WARN="$WARN -Wmissing-declarations"
fi
if test "$gccnum" -gt "295"; then
dnl only if the compiler is newer than 2.95 since we got lots of
dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
dnl gcc 2.95.4 on FreeBSD 4.9!
WARN="$WARN -Wundef -Wno-long-long -Wsign-compare"
fi
if test "$gccnum" -ge "296"; then
dnl gcc 2.96 or later
WARN="$WARN -Wfloat-equal"
fi
if test "$gccnum" -gt "296"; then
dnl this option does not exist in 2.96
WARN="$WARN -Wno-format-nonliteral"
fi
dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
dnl on i686-Linux as it gives us heaps with false positives.
dnl Also, on gcc 4.0.X it is totally unbearable and complains all
dnl over making it unusable for generic purposes. Let's not use it.
if test "$gccnum" -ge "303"; then
dnl gcc 3.3 and later
WARN="$WARN -Wendif-labels -Wstrict-prototypes"
fi
if test "$gccnum" -ge "304"; then
# try these on gcc 3.4
WARN="$WARN -Wdeclaration-after-statement"
fi
for flag in $CPPFLAGS; do
case "$flag" in
-I*)
dnl Include path, provide a -isystem option for the same dir
dnl to prevent warnings in those dirs. The -isystem was not very
dnl reliable on earlier gcc versions.
add=`echo $flag | sed 's/^-I/-isystem /g'`
WARN="$WARN $add"
;;
esac
done
fi dnl $ICC = no
CFLAGS="$CFLAGS $WARN"
AC_MSG_NOTICE([Added this set of compiler options: $WARN])
else dnl $GCC = yes
AC_MSG_NOTICE([Added no extra compiler options])
fi dnl $GCC = yes
dnl strip off optimizer flags
NEWFLAGS=""
for flag in $CFLAGS; do
case "$flag" in
-O*)
dnl echo "cut off $flag"
;;
*)
NEWFLAGS="$NEWFLAGS $flag"
;;
esac
done
CFLAGS=$NEWFLAGS
]) dnl end of AC_DEFUN()
dnl CURL_CHECK_NONBLOCKING_SOCKET
dnl -------------------------------------------------
dnl Check for how to set a socket to non-blocking state. There seems to exist
dnl four known different ways, with the one used almost everywhere being POSIX
dnl and XPG3, while the other different ways for different systems (old BSD,
dnl Windows and Amiga).
dnl
dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
dnl O_NONBLOCK define is found but does not work. This condition is attempted
dnl to get caught in this script by using an excessive number of #ifdefs...
dnl
AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
[
AC_MSG_CHECKING([non-blocking sockets style])
AC_TRY_COMPILE([
/* headers for O_NONBLOCK test */
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
],[
/* try to compile O_NONBLOCK */
#if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# if defined(__SVR4) || defined(__srv4__)
# define PLATFORM_SOLARIS
# else
# define PLATFORM_SUNOS4
# endif
#endif
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
# define PLATFORM_AIX_V3
#endif
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
#error "O_NONBLOCK does not work on this platform"
#endif
int socket;
int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
],[
dnl the O_NONBLOCK test was fine
nonblock="O_NONBLOCK"
AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
],[
dnl the code was bad, try a different program now, test 2
AC_TRY_COMPILE([
/* headers for FIONBIO test */
#include <unistd.h>
#include <stropts.h>
],[
/* FIONBIO source test (old-style unix) */
int socket;
int flags = ioctl(socket, FIONBIO, &flags);
],[
dnl FIONBIO test was good
nonblock="FIONBIO"
AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
],[
dnl FIONBIO test was also bad
dnl the code was bad, try a different program now, test 3
AC_TRY_COMPILE([
/* headers for ioctlsocket test (Windows) */
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#else
#ifdef HAVE_WINSOCK_H
#include <winsock.h>
#endif
#endif
#endif
],[
/* ioctlsocket source code */
SOCKET sd;
unsigned long flags = 0;
sd = socket(0, 0, 0);
ioctlsocket(sd, FIONBIO, &flags);
],[
dnl ioctlsocket test was good
nonblock="ioctlsocket"
AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
],[
dnl ioctlsocket didnt compile!, go to test 4
AC_TRY_LINK([
/* headers for IoctlSocket test (Amiga?) */
#include <sys/ioctl.h>
],[
/* IoctlSocket source code */
int socket;
int flags = IoctlSocket(socket, FIONBIO, (long)1);
],[
dnl ioctlsocket test was good
nonblock="IoctlSocket"
AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
],[
dnl Ioctlsocket didnt compile, do test 5!
AC_TRY_COMPILE([
/* headers for SO_NONBLOCK test (BeOS) */
#include <socket.h>
],[
/* SO_NONBLOCK source code */
long b = 1;
int socket;
int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
],[
dnl the SO_NONBLOCK test was good
nonblock="SO_NONBLOCK"
AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
],[
dnl test 5 didnt compile!
nonblock="nada"
AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
])
dnl end of fifth test
])
dnl end of forth test
])
dnl end of third test
])
dnl end of second test
])
dnl end of non-blocking try-compile test
AC_MSG_RESULT($nonblock)
if test "$nonblock" = "nada"; then
AC_MSG_WARN([non-block sockets disabled])
fi
])
dnl CURL_CHECK_NEED_REENTRANT_SYSTEM
dnl -------------------------------------------------
dnl Checks if the preprocessor _REENTRANT definition
dnl must be unconditionally done for this platform.
dnl Internal macro for CURL_CONFIGURE_REENTRANT.
AC_DEFUN([CURL_CHECK_NEED_REENTRANT_SYSTEM], [
case $host in
*-*-solaris* | *-*-hpux*)
tmp_need_reentrant="yes"
;;
*)
tmp_need_reentrant="no"
;;
esac
])
dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
dnl -------------------------------------------------
dnl This macro ensures that configuration tests done
dnl after this will execute with preprocessor symbol
dnl _REENTRANT defined. This macro also ensures that
dnl the generated config file defines NEED_REENTRANT
dnl and that in turn setup.h will define _REENTRANT.
dnl Internal macro for CURL_CONFIGURE_REENTRANT.
AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [
AC_DEFINE(NEED_REENTRANT, 1,
[Define to 1 if _REENTRANT preprocessor symbol must be defined.])
cat >>confdefs.h <<_EOF
#ifndef _REENTRANT
# define _REENTRANT
#endif
_EOF
])
dnl CURL_CONFIGURE_REENTRANT
dnl -------------------------------------------------
dnl This first checks if the preprocessor _REENTRANT
dnl symbol is already defined. If it isn't currently
dnl defined a set of checks are performed to verify
dnl if its definition is required to make visible to
dnl the compiler a set of *_r functions. Finally, if
dnl _REENTRANT is already defined or needed it takes
dnl care of making adjustments necessary to ensure
dnl that it is defined equally for further configure
dnl tests and generated config file.
AC_DEFUN([CURL_CONFIGURE_REENTRANT], [
AC_PREREQ([2.50])dnl
#
AC_MSG_CHECKING([if _REENTRANT is already defined])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
]],[[
#ifdef _REENTRANT
int dummy=1;
#else
force compilation error
#endif
]])
],[
AC_MSG_RESULT([yes])
tmp_reentrant_initially_defined="yes"
],[
AC_MSG_RESULT([no])
tmp_reentrant_initially_defined="no"
])
#
if test "$tmp_reentrant_initially_defined" = "no"; then
AC_MSG_CHECKING([if _REENTRANT is actually needed])
CURL_CHECK_NEED_REENTRANT_SYSTEM
if test "$tmp_need_reentrant" = "yes"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
#
AC_MSG_CHECKING([if _REENTRANT is onwards defined])
if test "$tmp_reentrant_initially_defined" = "yes" ||
test "$tmp_need_reentrant" = "yes"; then
CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
#
])

84
appveyor.yml Normal file
View File

@ -0,0 +1,84 @@
# Copyright (c) 2014, Ruslan Baratov
# Copyright (c) 2014, 2016 Alexander Lamaison
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
os: Visual Studio 2015
environment:
matrix:
- GENERATOR: "Visual Studio 14 2015"
BUILD_SHARED_LIBS: ON
- GENERATOR: "Visual Studio 14 2015"
BUILD_SHARED_LIBS: OFF
- GENERATOR: "Visual Studio 12 2013"
BUILD_SHARED_LIBS: ON
- GENERATOR: "Visual Studio 12 2013"
BUILD_SHARED_LIBS: OFF
- GENERATOR: "Visual Studio 11 2012"
BUILD_SHARED_LIBS: ON
- GENERATOR: "Visual Studio 11 2012"
BUILD_SHARED_LIBS: OFF
- GENERATOR: "Visual Studio 10 2010"
BUILD_SHARED_LIBS: ON
- GENERATOR: "Visual Studio 10 2010"
BUILD_SHARED_LIBS: OFF
- GENERATOR: "Visual Studio 9 2008"
BUILD_SHARED_LIBS: ON
- GENERATOR: "Visual Studio 9 2008"
BUILD_SHARED_LIBS: OFF
platform:
- x86
- x64
configuration:
# - Debug
- Release
matrix:
allow_failures:
- GENERATOR: "Visual Studio 9 2008"
platform: x64
build_script:
- ps: if($env:PLATFORM -eq "x64") { $env:CMAKE_GEN_SUFFIX=" Win64" }
- cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% -H. -B_builds
- cmake --build _builds --config "%CONFIGURATION%"
test_script:
- ps: cd _builds
- ctest -VV -C "%CONFIGURATION%" -E ssh2 --output-on-failure
on_failure:
- ps: if (Test-Path _builds/CMakeFiles/CMakeOutput.log) { cat _builds/CMakeFiles/CMakeOutput.log }
- ps: if (Test-Path _builds/CMakeFiles/CMakeError.log) { cat _builds/CMakeFiles/CMakeError.log }

22
buildconf Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
LIBTOOLIZE="libtoolize"
if [ "x`which $LIBTOOLIZE`" = "x" ]; then
LIBTOOLIZE="glibtoolize"
fi
if [ "x`which $LIBTOOLIZE`" = "x" ]; then
echo "Neither libtoolize nor glibtoolize could be found!"
exit 1
fi
${LIBTOOLIZE} --copy --automake --force
${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS
${AUTOHEADER:-autoheader}
# copy the private libssh2_config.h.in to the examples dir so that
# it can be included without pointing the include path to the private
# source dir
cp src/libssh2_config.h.in example/libssh2_config.h.in
${AUTOCONF:-autoconf}
${AUTOMAKE:-automake} --add-missing --copy

View File

@ -0,0 +1,81 @@
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# Neither the name of the copyright holder nor the names
# of any other contributors may be used to endorse or
# promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
# - check_function_exists_maybe_need_library(<function> <var> [lib1 ... libn])
#
# Check if function is available for linking, first without extra libraries, and
# then, if not found that way, linking in each optional library as well. This
# function is similar to autotools AC_SEARCH_LIBS.
#
# If the function if found, this will define <var>.
#
# If the function was only found by linking in an additional library, this
# will define NEED_LIB_LIBX, where LIBX is the one of lib1 to libn that
# makes the function available, in uppercase.
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#
include(CheckFunctionExists)
include(CheckLibraryExists)
function(check_function_exists_may_need_library function variable)
check_function_exists(${function} ${variable})
if(NOT ${variable})
foreach(lib ${ARGN})
string(TOUPPER ${lib} UP_LIB)
# Use new variable to prevent cache from previous step shortcircuiting
# new test
check_library_exists(${lib} ${function} "" HAVE_${function}_IN_${lib})
if(HAVE_${function}_IN_${lib})
set(${variable} 1 CACHE INTERNAL
"Function ${function} found in library ${lib}")
set(NEED_LIB_${UP_LIB} 1 CACHE INTERNAL
"Need to link ${lib}")
break()
endif()
endforeach()
endif()
endfunction()

View File

@ -0,0 +1,119 @@
include(CheckCSourceCompiles)
# - check_nonblocking_socket_support()
#
# Check for how to set a socket to non-blocking state. There seems to exist
# four known different ways, with the one used almost everywhere being POSIX
# and XPG3, while the other different ways for different systems (old BSD,
# Windows and Amiga).
#
# One of the following variables will be set indicating the supported
# method (if any):
# HAVE_O_NONBLOCK
# HAVE_FIONBIO
# HAVE_IOCTLSOCKET
# HAVE_IOCTLSOCKET_CASE
# HAVE_SO_NONBLOCK
# HAVE_DISABLED_NONBLOCKING
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#
macro(check_nonblocking_socket_support)
# There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
# O_NONBLOCK define is found but does not work.
check_c_source_compiles("
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# if defined(__SVR4) || defined(__srv4__)
# define PLATFORM_SOLARIS
# else
# define PLATFORM_SUNOS4
# endif
#endif
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
# define PLATFORM_AIX_V3
#endif
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
#error \"O_NONBLOCK does not work on this platform\"
#endif
int main()
{
int socket;
int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
}"
HAVE_O_NONBLOCK)
if(NOT HAVE_O_NONBLOCK)
check_c_source_compiles("/* FIONBIO test (old-style unix) */
#include <unistd.h>
#include <stropts.h>
int main()
{
int socket;
int flags = ioctl(socket, FIONBIO, &flags);
}"
HAVE_FIONBIO)
if(NOT HAVE_FIONBIO)
check_c_source_compiles("/* ioctlsocket test (Windows) */
#undef inline
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
int main()
{
SOCKET sd;
unsigned long flags = 0;
sd = socket(0, 0, 0);
ioctlsocket(sd, FIONBIO, &flags);
}"
HAVE_IOCTLSOCKET)
if(NOT HAVE_IOCTLSOCKET)
check_c_source_compiles("/* IoctlSocket test (Amiga?) */
#include <sys/ioctl.h>
int main()
{
int socket;
int flags = IoctlSocket(socket, FIONBIO, (long)1);
}"
HAVE_IOCTLSOCKET_CASE)
if(NOT HAVE_IOCTLSOCKET_CASE)
check_c_source_compiles("/* SO_NONBLOCK test (BeOS) */
#include <socket.h>
int main()
{
long b = 1;
int socket;
int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
}"
HAVE_SO_NONBLOCK)
if(NOT HAVE_SO_NONBLOCK)
# No non-blocking socket method found
set(HAVE_DISABLED_NONBLOCKING 1)
endif()
endif()
endif()
endif()
endif()
endmacro()

View File

@ -0,0 +1,72 @@
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# Neither the name of the copyright holder nor the names
# of any other contributors may be used to endorse or
# promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
include(CMakeParseArguments)
function(ADD_TARGET_TO_COPY_DEPENDENCIES)
set(options)
set(oneValueArgs TARGET)
set(multiValueArgs DEPENDENCIES BEFORE_TARGETS)
cmake_parse_arguments(COPY
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT COPY_DEPENDENCIES)
return()
endif()
# Using a custom target to drive custom commands stops multiple
# parallel builds trying to kick off the commands at the same time
add_custom_target(${COPY_TARGET})
foreach(target ${COPY_BEFORE_TARGETS})
add_dependencies(${target} ${COPY_TARGET})
endforeach()
foreach(dependency ${COPY_DEPENDENCIES})
add_custom_command(
TARGET ${COPY_TARGET}
DEPENDS ${dependency}
# Make directory first otherwise file is copied in place of
# directory instead of into it
COMMAND ${CMAKE_COMMAND}
ARGS -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
COMMAND ${CMAKE_COMMAND}
ARGS -E copy ${dependency} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
VERBATIM)
endforeach()
endfunction()

53
cmake/FindLibgcrypt.cmake Normal file
View File

@ -0,0 +1,53 @@
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# Neither the name of the copyright holder nor the names
# of any other contributors may be used to endorse or
# promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
# - Try to find Libgcrypt
# This will define all or none of:
# LIBGCRYPT_FOUND - if Libgcrypt headers and library was found
# LIBGCRYPT_INCLUDE_DIRS - The Libgcrypt include directories
# LIBGCRYPT_LIBRARIES - The libraries needed to use Libgcrypt
find_path(LIBGCRYPT_INCLUDE_DIR gcrypt.h)
find_library(LIBGCRYPT_LIBRARY NAMES gcrypt libgcrypt)
set(LIBGCRYPT_LIBRARIES ${LIBGCRYPT_LIBRARY})
set(LIBGCRYPT_INCLUDE_DIRS ${LIBGCRYPT_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libgcrypt DEFAULT_MSG
LIBGCRYPT_LIBRARY LIBGCRYPT_INCLUDE_DIR)
mark_as_advanced(LIBGCRYPT_INCLUDE_DIR LIBGCRYPT_LIBRARY)

View File

@ -0,0 +1,64 @@
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# Neither the name of the copyright holder nor the names
# of any other contributors may be used to endorse or
# promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
# Some systems have their socket functions in a library.
# (Solaris -lsocket/-lnsl, Windows -lws2_32). This macro appends those
# libraries to the given list
macro(append_needed_socket_libraries LIBRARIES_LIST)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
# x86 Windows uses STDCALL for these functions, so their names are mangled,
# meaning the platform checks don't work. Hardcoding these until we get
# a better solution.
set(HAVE_SOCKET 1)
set(HAVE_SELECT 1)
set(HAVE_INET_ADDR 1)
set(NEED_LIB_WS2_32 1)
else()
check_function_exists_may_need_library(socket HAVE_SOCKET socket ws2_32)
check_function_exists_may_need_library(select HAVE_SELECT ws2_32)
check_function_exists_may_need_library(inet_addr HAVE_INET_ADDR nsl ws2_32)
endif()
if(NEED_LIB_SOCKET)
list(APPEND ${LIBRARIES_LIST} socket)
endif()
if(NEED_LIB_NSL)
list(APPEND ${LIBRARIES_LIST} nsl)
endif()
if(NEED_LIB_WS2_32)
list(APPEND ${LIBRARIES_LIST} ws2_32)
endif()
endmacro()

View File

@ -0,0 +1,42 @@
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# Neither the name of the copyright holder nor the names
# of any other contributors may be used to endorse or
# promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
# Cross-compile 32-bit binary on 64-bit linux host
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "i386")
set(CMAKE_CXX_COMPILER_ARG1 "-m32")
set(CMAKE_C_COMPILER_ARG1 "-m32")

23
cmake/max_warnings.cmake Normal file
View File

@ -0,0 +1,23 @@
if(MSVC)
# Use the highest warning level for visual studio.
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif()
# Disable broken warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
if(NOT CMAKE_C_FLAGS MATCHES "-Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
endif()
endif()

1415
config.guess vendored

File diff suppressed because it is too large Load Diff

660
config.rpath Executable file
View File

@ -0,0 +1,660 @@
#! /bin/sh
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2006 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
# should be set by the caller.
#
# The set of defined variables is at the end of this script.
# Known limitations:
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
# than 256 bytes, otherwise the compiler driver will dump core. The only
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a `.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
shrext=.so
host="$1"
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
# Code taken from libtool.m4's _LT_CC_BASENAME.
for cc_temp in $CC""; do
case $cc_temp in
compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
\-*) ;;
*) break;;
esac
done
cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
wl=
if test "$GCC" = yes; then
wl='-Wl,'
else
case "$host_os" in
aix*)
wl='-Wl,'
;;
darwin*)
case $cc_basename in
xlc*)
wl='-Wl,'
;;
esac
;;
mingw* | pw32* | os2*)
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
;;
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
newsos6)
;;
linux*)
case $cc_basename in
icc* | ecc*)
wl='-Wl,'
;;
pgcc | pgf77 | pgf90)
wl='-Wl,'
;;
ccc*)
wl='-Wl,'
;;
como)
wl='-lopt='
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*)
wl='-Wl,'
;;
esac
;;
esac
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
sco3.2v5*)
;;
solaris*)
wl='-Wl,'
;;
sunos4*)
wl='-Qoption ld '
;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
wl='-Wl,'
;;
sysv4*MP*)
;;
unicos*)
wl='-Wl,'
;;
uts4*)
;;
esac
fi
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
case "$host_os" in
cygwin* | mingw* | pw32*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
interix*)
# we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes
;;
openbsd*)
with_gnu_ld=no
;;
esac
ld_shlibs=yes
if test "$with_gnu_ld" = yes; then
# Set some defaults for GNU ld with shared library support. These
# are reset later if shared libraries are not supported. Putting them
# here allows them to be overridden if necessary.
# Unlike libtool, we use -rpath here, not --rpath, since the documented
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
case "$host_os" in
aix3* | aix4* | aix5*)
# On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then
ld_shlibs=no
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
# that the semantics of dynamic libraries on AmigaOS, at least up
# to version 4, is to share data among multiple programs linked
# with the same dynamic library. Since this doesn't match the
# behavior of shared libraries on other platforms, we cannot use
# them.
ld_shlibs=no
;;
beos*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
cygwin* | mingw* | pw32*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
interix3*)
hardcode_direct=no
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
linux*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
netbsd*)
;;
solaris*)
if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
case `$LD -v 2>&1` in
*\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
ld_shlibs=no
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
else
ld_shlibs=no
fi
;;
esac
;;
sunos4*)
hardcode_direct=yes
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
esac
if test "$ld_shlibs" = no; then
hardcode_libdir_flag_spec=
fi
else
case "$host_os" in
aix3*)
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
hardcode_minus_L=yes
if test "$GCC" = yes; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
hardcode_direct=unsupported
fi
;;
aix4* | aix5*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix5*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
;;
esac
fi
hardcode_direct=yes
hardcode_libdir_separator=':'
if test "$GCC" = yes; then
case $host_os in aix4.[012]|aix4.[012].*)
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" && \
strings "$collect2name" | grep resolve_lib_name >/dev/null
then
# We have reworked collect2
hardcode_direct=yes
else
# We have old collect2
hardcode_direct=unsupported
hardcode_minus_L=yes
hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator=
fi
;;
esac
fi
# Begin _LT_AC_SYS_LIBPATH_AIX.
echo 'int main () { return 0; }' > conftest.c
${CC} ${LDFLAGS} conftest.c -o conftest
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
if test -z "$aix_libpath"; then
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
fi
if test -z "$aix_libpath"; then
aix_libpath="/usr/lib:/lib"
fi
rm -f conftest.c conftest
# End _LT_AC_SYS_LIBPATH_AIX.
if test "$aix_use_runtimelinking" = yes; then
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
else
if test "$host_cpu" = ia64; then
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
else
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
fi
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# see comment about different semantics on the GNU ld section
ld_shlibs=no
;;
bsdi[45]*)
;;
cygwin* | mingw* | pw32*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec=' '
libext=lib
;;
darwin* | rhapsody*)
hardcode_direct=no
if test "$GCC" = yes ; then
:
else
case $cc_basename in
xlc*)
;;
*)
ld_shlibs=no
;;
esac
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd1*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd* | kfreebsd*-gnu | dragonfly*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
hpux9*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
hpux10*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
fi
;;
hpux11*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
case $host_cpu in
hppa*64*|ia64*)
hardcode_direct=no
;;
*)
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
esac
fi
;;
irix5* | irix6* | nonstopux*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
netbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
newsos6)
hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
openbsd*)
hardcode_direct=yes
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
;;
os2*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
osf3*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
osf4* | osf5*)
if test "$GCC" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
else
# Both cc and cxx compiler support -rpath directly
hardcode_libdir_flag_spec='-rpath $libdir'
fi
hardcode_libdir_separator=:
;;
solaris*)
hardcode_libdir_flag_spec='-R$libdir'
;;
sunos4*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=yes
hardcode_minus_L=yes
;;
sysv4)
case $host_vendor in
sni)
hardcode_direct=yes # is this really true???
;;
siemens)
hardcode_direct=no
;;
motorola)
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
;;
esac
;;
sysv4.3*)
;;
sysv4*MP*)
if test -d /usr/nec; then
ld_shlibs=yes
fi
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
;;
sysv5* | sco3.2v5* | sco5v6*)
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
hardcode_libdir_separator=':'
;;
uts4*)
hardcode_libdir_flag_spec='-L$libdir'
;;
*)
ld_shlibs=no
;;
esac
fi
# Check dynamic linker characteristics
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
# Unlike libtool.m4, here we don't care about _all_ names of the library, but
# only about the one the linker finds when passed -lNAME. This is the last
# element of library_names_spec in libtool.m4, or possibly two of them if the
# linker has special search rules.
library_names_spec= # the last element of library_names_spec in libtool.m4
libname_spec='lib$name'
case "$host_os" in
aix3*)
library_names_spec='$libname.a'
;;
aix4* | aix5*)
library_names_spec='$libname$shrext'
;;
amigaos*)
library_names_spec='$libname.a'
;;
beos*)
library_names_spec='$libname$shrext'
;;
bsdi[45]*)
library_names_spec='$libname$shrext'
;;
cygwin* | mingw* | pw32*)
shrext=.dll
library_names_spec='$libname.dll.a $libname.lib'
;;
darwin* | rhapsody*)
shrext=.dylib
library_names_spec='$libname$shrext'
;;
dgux*)
library_names_spec='$libname$shrext'
;;
freebsd1*)
;;
kfreebsd*-gnu)
library_names_spec='$libname$shrext'
;;
freebsd* | dragonfly*)
case "$host_os" in
freebsd[123]*)
library_names_spec='$libname$shrext$versuffix' ;;
*)
library_names_spec='$libname$shrext' ;;
esac
;;
gnu*)
library_names_spec='$libname$shrext'
;;
hpux9* | hpux10* | hpux11*)
case $host_cpu in
ia64*)
shrext=.so
;;
hppa*64*)
shrext=.sl
;;
*)
shrext=.sl
;;
esac
library_names_spec='$libname$shrext'
;;
interix3*)
library_names_spec='$libname$shrext'
;;
irix5* | irix6* | nonstopux*)
library_names_spec='$libname$shrext'
case "$host_os" in
irix5* | nonstopux*)
libsuff= shlibsuff=
;;
*)
case $LD in
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
*) libsuff= shlibsuff= ;;
esac
;;
esac
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux*)
library_names_spec='$libname$shrext'
;;
knetbsd*-gnu)
library_names_spec='$libname$shrext'
;;
netbsd*)
library_names_spec='$libname$shrext'
;;
newsos6)
library_names_spec='$libname$shrext'
;;
nto-qnx*)
library_names_spec='$libname$shrext'
;;
openbsd*)
library_names_spec='$libname$shrext$versuffix'
;;
os2*)
libname_spec='$name'
shrext=.dll
library_names_spec='$libname.a'
;;
osf3* | osf4* | osf5*)
library_names_spec='$libname$shrext'
;;
solaris*)
library_names_spec='$libname$shrext'
;;
sunos4*)
library_names_spec='$libname$shrext$versuffix'
;;
sysv4 | sysv4.3*)
library_names_spec='$libname$shrext'
;;
sysv4*MP*)
library_names_spec='$libname$shrext'
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
library_names_spec='$libname$shrext'
;;
uts4*)
library_names_spec='$libname$shrext'
;;
esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
# How to pass a linker flag through the compiler.
wl="$escaped_wl"
# Static library suffix (normally "a").
libext="$libext"
# Shared library suffix (normally "so").
shlibext="$shlibext"
# Format of library name prefix.
libname_spec="$escaped_libname_spec"
# Library names that the linker finds when passed -lNAME.
library_names_spec="$escaped_library_names_spec"
# Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist.
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
# Whether we need a single -rpath flag with a separated argument.
hardcode_libdir_separator="$hardcode_libdir_separator"
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
# resulting binary.
hardcode_direct="$hardcode_direct"
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
# resulting binary.
hardcode_minus_L="$hardcode_minus_L"
EOF

1510
config.sub vendored

File diff suppressed because it is too large Load Diff

404
configure.ac Normal file
View File

@ -0,0 +1,404 @@
# AC_PREREQ(2.57)
AC_INIT(libssh2, [-], libssh2-devel@cool.haxx.se)
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADERS([src/libssh2_config.h example/libssh2_config.h])
AM_MAINTAINER_MODE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl SED is needed by some of the tools
AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
$PATH:/usr/bin:/usr/local/bin)
AC_SUBST(SED)
if test "x$SED" = "xsed-was-not-found-by-configure"; then
AC_MSG_WARN([sed was not found, this may ruin your chances to build fine])
fi
dnl figure out the libssh2 version
LIBSSH2VER=`$SED -ne 's/^#define LIBSSH2_VERSION *"\(.*\)"/\1/p' ${srcdir}/include/libssh2.h`
AM_INIT_AUTOMAKE
AC_MSG_CHECKING([libssh2 version])
AC_MSG_RESULT($LIBSSH2VER)
AC_SUBST(LIBSSH2VER)
AB_VERSION=$LIBSSH2VER
AB_INIT
# Check for the OS.
# Daniel's note: this should not be necessary and we need to work to
# get this removed.
AC_CANONICAL_HOST
case "$host" in
*-mingw*)
CFLAGS="$CFLAGS -DLIBSSH2_WIN32"
LIBS="$LIBS -lws2_32"
;;
*-cygwin)
CFLAGS="$CFLAGS -DLIBSSH2_WIN32"
;;
*darwin*)
CFLAGS="$CFLAGS -DLIBSSH2_DARWIN"
;;
*hpux*)
;;
*osf*)
CFLAGS="$CFLAGS -D_POSIX_PII_SOCKET"
;;
*)
;;
esac
AC_CHECK_TYPE(long long,
[AC_DEFINE(HAVE_LONGLONG, 1,
[Define to 1 if the compiler supports the 'long long' data type.])]
longlong="yes"
)
dnl Our configure and build reentrant settings
CURL_CONFIGURE_REENTRANT
# Some systems (Solaris?) have socket() in -lsocket.
AC_SEARCH_LIBS(socket, socket)
# Solaris has inet_addr() in -lnsl.
AC_SEARCH_LIBS(inet_addr, nsl)
AC_SUBST(LIBS)
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PATH_PROGS(SSHD, [sshd], [],
[$PATH$PATH_SEPARATOR/usr/libexec$PATH_SEPARATOR]dnl
[/usr/sbin$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/etc])
AM_CONDITIONAL(SSHD, test -n "$SSHD")
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_C_BIGENDIAN
dnl check for how to do large files
AC_SYS_LARGEFILE
# Configure parameters
AC_ARG_WITH(openssl,
AC_HELP_STRING([--with-openssl],[Use OpenSSL for crypto]),
use_openssl=$withval,use_openssl=auto)
AC_ARG_WITH(libgcrypt,
AC_HELP_STRING([--with-libgcrypt],[Use libgcrypt for crypto]),
use_libgcrypt=$withval,use_libgcrypt=auto)
AC_ARG_WITH(wincng,
AC_HELP_STRING([--with-wincng],[Use Windows CNG for crypto]),
use_wincng=$withval,use_wincng=auto)
AC_ARG_WITH(libz,
AC_HELP_STRING([--with-libz],[Use zlib for compression]),
use_libz=$withval,use_libz=auto)
found_crypto=none
support_clear_memory=no
# Look for OpenSSL
if test "$found_crypto" = "none" && test "$use_openssl" != "no"; then
AC_LIB_HAVE_LINKFLAGS([ssl], [crypto], [#include <openssl/ssl.h>])
fi
if test "$ac_cv_libssl" = "yes"; then
AC_DEFINE(LIBSSH2_OPENSSL, 1, [Use OpenSSL])
LIBSREQUIRED=libssl,libcrypto
# Not all OpenSSL have AES-CTR functions.
save_LIBS="$LIBS"
LIBS="$LIBS $LIBSSL"
AC_CHECK_FUNCS(EVP_aes_128_ctr)
LIBS="$save_LIBS"
found_crypto="OpenSSL (AES-CTR: ${ac_cv_func_EVP_aes_128_ctr:-N/A})"
fi
AM_CONDITIONAL(OPENSSL, test "$ac_cv_libssl" = "yes")
# Look for libgcrypt
if test "$found_crypto" = "none" && test "$use_libgcrypt" != "no"; then
AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
fi
if test "$ac_cv_libgcrypt" = "yes"; then
AC_DEFINE(LIBSSH2_LIBGCRYPT, 1, [Use libgcrypt])
LIBSREQUIRED= # libgcrypt doesn't provide a .pc file. sad face.
LIBS="$LIBS -lgcrypt"
found_crypto=libgcrypt
fi
AM_CONDITIONAL(LIBGCRYPT, test "$ac_cv_libgcrypt" = "yes")
# Look for Windows Cryptography API: Next Generation
if test "$found_crypto" = "none" && test "$use_wincng" != "no"; then
AC_LIB_HAVE_LINKFLAGS([bcrypt], [], [
#include <windows.h>
#include <bcrypt.h>
])
AC_LIB_HAVE_LINKFLAGS([crypt32], [], [
#include <windows.h>
#include <wincrypt.h>
])
AC_CHECK_HEADERS([ntdef.h ntstatus.h], [], [], [
#include <windows.h>
])
AC_CHECK_DECLS([SecureZeroMemory], [], [], [
#include <windows.h>
])
fi
if test "$ac_cv_libbcrypt" = "yes"; then
AC_DEFINE(LIBSSH2_WINCNG, 1, [Use Windows CNG])
LIBSREQUIRED= # wincng doesn't provide a .pc file. sad face.
LIBS="$LIBS -lbcrypt"
if test "$ac_cv_libcrypt32" = "yes"; then
LIBS="$LIBS -lcrypt32"
fi
found_crypto="Windows Cryptography API: Next Generation"
if test "$ac_cv_have_decl_SecureZeroMemory" = "yes"; then
support_clear_memory=yes
fi
fi
AM_CONDITIONAL(WINCNG, test "$ac_cv_libbcrypt" = "yes")
AM_CONDITIONAL(OS400QC3, false)
# Check if crypto library was found
if test "$found_crypto" = "none"; then
AC_MSG_ERROR([No crypto library found!
Try --with-libssl-prefix=PATH
or --with-libgcrypt-prefix=PATH
or --with-wincng on Windows\
])
fi
# Look for Libz
if test "$use_libz" != "no"; then
AC_LIB_HAVE_LINKFLAGS([z], [], [#include <zlib.h>])
if test "$ac_cv_libz" != yes; then
AC_MSG_NOTICE([Cannot find zlib, disabling compression])
AC_MSG_NOTICE([Try --with-libz-prefix=PATH if you know you have it])
else
AC_DEFINE(LIBSSH2_HAVE_ZLIB, 1, [Compile in zlib support])
if test "${LIBSREQUIRED}" != ""; then
LIBSREQUIRED="${LIBSREQUIRED},"
fi
LIBSREQUIRED="${LIBSREQUIRED}zlib"
fi
fi
AC_SUBST(LIBSREQUIRED)
#
# Optional Settings
#
AC_ARG_ENABLE(crypt-none,
AC_HELP_STRING([--enable-crypt-none],[Permit "none" cipher -- NOT RECOMMENDED]),
[AC_DEFINE(LIBSSH2_CRYPT_NONE, 1, [Enable "none" cipher -- NOT RECOMMENDED])])
AC_ARG_ENABLE(mac-none,
AC_HELP_STRING([--enable-mac-none],[Permit "none" MAC -- NOT RECOMMENDED]),
[AC_DEFINE(LIBSSH2_MAC_NONE, 1, [Enable "none" MAC -- NOT RECOMMENDED])])
AC_ARG_ENABLE(gex-new,
AC_HELP_STRING([--disable-gex-new],[Disable "new" diffie-hellman-group-exchange-sha1 method]),
[GEX_NEW=$enableval])
if test "$GEX_NEW" != "no"; then
AC_DEFINE(LIBSSH2_DH_GEX_NEW, 1, [Enable newer diffie-hellman-group-exchange-sha1 syntax])
fi
AC_ARG_ENABLE(clear-memory,
AC_HELP_STRING([--disable-clear-memory],[Disable clearing of memory before being freed]),
[CLEAR_MEMORY=$enableval])
if test "$CLEAR_MEMORY" != "no"; then
if test "$support_clear_memory" = "yes"; then
AC_DEFINE(LIBSSH2_CLEAR_MEMORY, 1, [Enable clearing of memory before being freed])
enable_clear_memory=yes
else
if test "$CLEAR_MEMORY" = "yes"; then
AC_MSG_ERROR([secure clearing/zeroing of memory is not supported by the selected crypto backend])
else
AC_MSG_WARN([secure clearing/zeroing of memory is not supported by the selected crypto backend])
fi
enable_clear_memory=unsupported
fi
else
if test "$support_clear_memory" = "yes"; then
enable_clear_memory=no
else
AC_MSG_WARN([secure clearing/zeroing of memory is not supported by the selected crypto backend])
enable_clear_memory=unsupported
fi
fi
dnl ************************************************************
dnl option to switch on compiler debug options
dnl
AC_MSG_CHECKING([whether to enable pedantic and debug compiler options])
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug],[Enable pedantic and debug options])
AC_HELP_STRING([--disable-debug],[Disable debug options]),
[ case "$enable_debug" in
no)
AC_MSG_RESULT(no)
;;
*) AC_MSG_RESULT(yes)
enable_debug=yes
CPPFLAGS="$CPPFLAGS -DLIBSSH2DEBUG"
CFLAGS="$CFLAGS -g"
dnl set compiler "debug" options to become more picky, and remove
dnl optimize options from CFLAGS
CURL_CC_DEBUG_OPTS
;;
esac
],
enable_debug=no
AC_MSG_RESULT(no)
)
dnl ************************************************************
dnl Enable hiding of internal symbols in library to reduce its size and
dnl speed dynamic linking of applications. This currently is only supported
dnl on gcc >= 4.0 and SunPro C.
dnl
AC_MSG_CHECKING([whether to enable hidden symbols in the library])
AC_ARG_ENABLE(hidden-symbols,
AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library])
AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]),
[ case "$enableval" in
no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_CHECKING([whether $CC supports it])
if test "$GCC" = yes ; then
if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
AC_MSG_RESULT(yes)
AC_DEFINE(LIBSSH2_API, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
CFLAGS="$CFLAGS -fvisibility=hidden"
else
AC_MSG_RESULT(no)
fi
else
dnl Test for SunPro cc
if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
AC_MSG_RESULT(yes)
AC_DEFINE(LIBSSH2_API, [__global], [to make a symbol visible])
CFLAGS="$CFLAGS -xldscope=hidden"
else
AC_MSG_RESULT(no)
fi
fi
;;
esac ],
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])
AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/ioctl.h sys/time.h])
AC_CHECK_HEADERS([arpa/inet.h netinet/in.h])
AC_CHECK_HEADERS([sys/un.h], [have_sys_un_h=yes], [have_sys_un_h=no])
AM_CONDITIONAL([HAVE_SYS_UN_H], test "x$have_sys_un_h" = xyes)
case $host in
*-*-cygwin* | *-*-cegcc*)
# These are POSIX-like systems using BSD-like sockets API.
;;
*)
AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h])
;;
esac
case $host in
*darwin*|*interix*)
dnl poll() does not work on these platforms
dnl Interix: "does provide poll(), but the implementing developer must
dnl have been in a bad mood, because poll() only works on the /proc
dnl filesystem here"
dnl Mac OS X's poll has funny behaviors, like:
dnl not being able to do poll on no fildescriptors (10.3?)
dnl not being able to poll on some files (like anything in /dev)
dnl not having reliable timeout support
dnl inconsistent return of POLLHUP where other implementations give POLLIN
AC_MSG_NOTICE([poll use is disabled on this platform])
;;
*)
AC_CHECK_FUNCS(poll)
;;
esac
AC_CHECK_FUNCS(gettimeofday select strtoll)
dnl Check for select() into ws2_32 for Msys/Mingw
if test "$ac_cv_func_select" != "yes"; then
AC_MSG_CHECKING([for select in ws2_32])
AC_TRY_LINK([
#ifdef HAVE_WINSOCK2_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#endif
],[
select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL);
],[
AC_MSG_RESULT([yes])
HAVE_SELECT="1"
AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
[Define to 1 if you have the select function.])
],[
AC_MSG_RESULT([no])
])
fi
AC_FUNC_ALLOCA
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
CURL_CHECK_NONBLOCKING_SOCKET
AC_CONFIG_FILES([Makefile
src/Makefile
tests/Makefile
example/Makefile
docs/Makefile
libssh2.pc])
AC_OUTPUT
AC_MSG_NOTICE([summary of build options:
version: ${LIBSSH2VER}
Host type: ${host}
Install prefix: ${prefix}
Compiler: ${CC}
Compiler flags: ${CFLAGS}
Library types: Shared=${enable_shared}, Static=${enable_static}
Crypto library: ${found_crypto}
Clear memory: $enable_clear_memory
Debug build: $enable_debug
Build examples: $build_examples
Path to sshd: $ac_cv_path_SSHD (only for self-tests)
zlib compression: $ac_cv_libz
])

View File

@ -1,172 +0,0 @@
# AC_PREREQ(2.57)
AC_INIT(libssh2,0.7,sarag@libssh2.org)
AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADER([include/libssh2_config.h])
# Check for the OS.
AC_CANONICAL_HOST
case "$host" in
*-cygwin)
SHLIB_SUFFIX_NAME="dll"
SHLIB_LDFLAGS="-shared"
CFLAGS="$CFLAGS -DLIBSSH2_WIN32"
;;
*darwin*)
SHLIB_SUFFIX_NAME="dylib"
SHLIB_LDFLAGS="-dynamiclib -flat_namespace"
CFLAGS="$CFLAGS -DLIBSSH2_DARWIN"
;;
*)
SHLIB_SUFFIX_NAME="so"
SHLIB_LDFLAGS="-shared"
;;
esac
AC_SUBST(SHLIB_SUFFIX_NAME)
AC_SUBST(SHLIB_LDFLAGS)
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_C_BIGENDIAN
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
#
# Look for OpenSSL
#
AC_ARG_WITH(openssl,
AC_HELP_STRING([--with-openssl=DIR],[Look for OpenSSL in PATH]),
[LIBSSH2_OPENSSL_DIR=$withval],[LIBSSH2_OPENSSL_DIR=yes])
if test "$LIBSSH2_OPENSSL_DIR" = "no" || test "$LIBSSH2_OPENSSL_DIR" = "yes"; then
unset LIBSSH2_OPENSSL_DIR
fi
found_openssl=no
unset OPENSSL_INCDIR
unset OPENSSL_LIBDIR
AC_MSG_CHECKING([for OpenSSL])
# Explicit path given, use it rather than pkg-config
if test ! -z "$LIBSSH2_OPENSSL_DIR"; then
found_openssl=yes
OPENSSL_LIBDIR=$LIBSSH2_OPENSSL_DIR/lib
OPENSSL_INCDIR=$LIBSSH2_OPENSSL_DIR/include
AC_MSG_RESULT([Using explicit path $LIBSSH2_OPENSSL_DIR])
fi
# If pkg-config is found try using it
if test "$found_openssl" = "no" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
found_openssl=yes
OPENSSL_LIBDIR=`$PKG_CONFIG --libs openssl`
OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
AC_MSG_RESULT([Using paths from pkg-config])
fi
# Elsewise, search for OpenSSL wherever it might be
if test "$found_openssl" = "no"; then
OPENSSL_SEARCH_PATH="/usr/local/ssl /usr/local /usr /usr/local/openssl"
for i in $OPENSSL_SEARCH_PATH; do
if test -r $i/include/openssl/evp.h; then
OPENSSL_INCDIR=$i/include
fi
if test -r $i/include/openssl/hmac.h; then
OPENSSL_INCDIR=$i/include
fi
if test -r $i/lib/libcrypto.a -o -r $i/lib/libcrypto.$SHLIB_SUFFIX_NAME; then
OPENSSL_LIBDIR=$i/lib
fi
test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
done
if test -z "$OPENSSL_INCDIR"; then
AC_MSG_ERROR([Cannot find OpenSSL's <evp.h> or <hmac.h>])
fi
if test -z "$OPENSSL_LIBDIR"; then
AC_MSG_ERROR([Cannot find OpenSSL's libcrypto])
fi
AC_MSG_RESULT([$OPENSSL_INCDIR $OPENSSL_LIBDIR])
fi
#
# Confirm required OpenSSL libs
#
if test ! -r $OPENSSL_INCDIR/openssl/bn.h || test ! -r $OPENSSL_INCDIR/openssl/evp.h || \
test ! -r $OPENSSL_INCDIR/openssl/hmac.h || test ! -r $OPENSSL_INCDIR/openssl/pem.h || \
test ! -r $OPENSSL_INCDIR/openssl/sha.h; then
AC_MSG_ERROR([Missing one or more of <openssl/bn.h>, <openssl/evp.h>, <openssl/hmac.h>, <openssl/pem.h>, <openssl/sha.h>])
fi
CFLAGS="$CFLAGS -I$OPENSSL_INCDIR"
LDFLAGS="$LDFLAGS -L$OPENSSL_LIBDIR -lcrypto"
#
# zlib
#
AC_ARG_WITH(libz,
AC_HELP_STRING([--with-libz=PATH],[Look for libz in PATH]),
[LIBSSH2_LIBZ_DIR=$withval],[LIBSSH2_LIBZ_DIR="/usr/local /usr /usr/local/libz /usr/libz /usr/local/zlib /usr/zlib"])
if test "$LIBSSH2_LIBZ_DIR" = "no" || test "$LIBSSH2_LIBZ_DIR" = "yes"; then
unset LIBSSH2_LIBZ_DIR
fi
unset LIBZ_INCDIR
unset LIBZ_LIBDIR
AC_MSG_CHECKING([for libz])
for i in $LIBSSH2_LIBZ_DIR; do
if test -r $i/include/zlib.h; then
LIBZ_INCDIR=$i/include
fi
if test -r $i/lib/libz.a -o -r $i/lib/libz.$SHLIB_SUFFIX_NAME; then
LIBZ_LIBDIR=$i/lib
fi
test -n "$LIBZ_INCDIR" && test -n "$LIBZ_LIBDIR" && break
done
if test -n "$LIBZ_INCDIR" && test -n "$LIBZ_LIBDIR"; then
AC_MSG_RESULT([Found in $LIBZ_INCDIR $LIBZ_LIBDIR])
CFLAGS="$CFLAGS -I$LIBZ_INCDIR"
LDFLAGS="$LDFLAGS -L$LIBZ_LIBDIR -lz"
AC_DEFINE(LIBSSH2_HAVE_ZLIB, 1, [Compile in zlib support])
else
AC_MSG_RESULT([Cannot find libz's <zlib.h>])
fi
#
# Optional Settings
#
AC_ARG_ENABLE(crypt-none,
AC_HELP_STRING([--enable-crypt-none],[Permit "none" cipher -- NOT RECOMMENDED]),
[AC_DEFINE(LIBSSH2_CRYPT_NONE, 1, [Enable "none" cipher -- NOT RECOMMENDED])])
AC_ARG_ENABLE(mac-none,
AC_HELP_STRING([--enable-mac-none],[Permit "none" MAC -- NOT RECOMMENDED]),
[AC_DEFINE(LIBSSH2_MAC_NONE, 1, [Enable "none" MAC -- NOT RECOMMENDED])])
AC_ARG_ENABLE(gex-new,
AC_HELP_STRING([--disable-gex-new],[Disable "new" diffie-hellman-group-exchange-sha1 method]),
[GEX_NEW=$enableval])
if test "$GEX_NEW" != "no"; then
AC_DEFINE(LIBSSH2_DH_GEX_NEW, 1, [Enable newer diffie-hellman-group-exchange-sha1 syntax])
fi
# Checks for header files.
# AC_HEADER_STDC
AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT

3
docs/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
Makefile
Makefile.in
coverage

79
docs/AUTHORS Normal file
View File

@ -0,0 +1,79 @@
libssh2 is the result of many friendly people. This list is an attempt to
mention all contributors. If we've missed anyone, tell us!
This list of names is a-z sorted.
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
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

29
docs/BINDINGS Normal file
View 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

206
docs/CMakeLists.txt Normal file
View File

@ -0,0 +1,206 @@
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
#
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#
# Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# Neither the name of the copyright holder nor the names
# of any other contributors may be used to endorse or
# promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
# OF SUCH DAMAGE.
set(MAN_PAGES
libssh2_agent_connect.3
libssh2_agent_disconnect.3
libssh2_agent_free.3
libssh2_agent_get_identity.3
libssh2_agent_init.3
libssh2_agent_list_identities.3
libssh2_agent_userauth.3
libssh2_banner_set.3
libssh2_base64_decode.3
libssh2_channel_close.3
libssh2_channel_direct_tcpip.3
libssh2_channel_direct_tcpip_ex.3
libssh2_channel_eof.3
libssh2_channel_exec.3
libssh2_channel_flush.3
libssh2_channel_flush_ex.3
libssh2_channel_flush_stderr.3
libssh2_channel_forward_accept.3
libssh2_channel_forward_cancel.3
libssh2_channel_forward_listen.3
libssh2_channel_forward_listen_ex.3
libssh2_channel_free.3
libssh2_channel_get_exit_signal.3
libssh2_channel_get_exit_status.3
libssh2_channel_handle_extended_data.3
libssh2_channel_handle_extended_data2.3
libssh2_channel_ignore_extended_data.3
libssh2_channel_open_ex.3
libssh2_channel_open_session.3
libssh2_channel_process_startup.3
libssh2_channel_read.3
libssh2_channel_read_ex.3
libssh2_channel_read_stderr.3
libssh2_channel_receive_window_adjust.3
libssh2_channel_receive_window_adjust2.3
libssh2_channel_request_pty.3
libssh2_channel_request_pty_ex.3
libssh2_channel_request_pty_size.3
libssh2_channel_request_pty_size_ex.3
libssh2_channel_send_eof.3
libssh2_channel_set_blocking.3
libssh2_channel_setenv.3
libssh2_channel_setenv_ex.3
libssh2_channel_shell.3
libssh2_channel_subsystem.3
libssh2_channel_wait_closed.3
libssh2_channel_wait_eof.3
libssh2_channel_window_read.3
libssh2_channel_window_read_ex.3
libssh2_channel_window_write.3
libssh2_channel_window_write_ex.3
libssh2_channel_write.3
libssh2_channel_write_ex.3
libssh2_channel_write_stderr.3
libssh2_channel_x11_req.3
libssh2_channel_x11_req_ex.3
libssh2_exit.3
libssh2_free.3
libssh2_hostkey_hash.3
libssh2_init.3
libssh2_keepalive_config.3
libssh2_keepalive_send.3
libssh2_knownhost_add.3
libssh2_knownhost_addc.3
libssh2_knownhost_check.3
libssh2_knownhost_checkp.3
libssh2_knownhost_del.3
libssh2_knownhost_free.3
libssh2_knownhost_get.3
libssh2_knownhost_init.3
libssh2_knownhost_readfile.3
libssh2_knownhost_readline.3
libssh2_knownhost_writefile.3
libssh2_knownhost_writeline.3
libssh2_poll.3
libssh2_poll_channel_read.3
libssh2_publickey_add.3
libssh2_publickey_add_ex.3
libssh2_publickey_init.3
libssh2_publickey_list_fetch.3
libssh2_publickey_list_free.3
libssh2_publickey_remove.3
libssh2_publickey_remove_ex.3
libssh2_publickey_shutdown.3
libssh2_scp_recv.3
libssh2_scp_recv2.3
libssh2_scp_send.3
libssh2_scp_send64.3
libssh2_scp_send_ex.3
libssh2_session_abstract.3
libssh2_session_banner_get.3
libssh2_session_banner_set.3
libssh2_session_block_directions.3
libssh2_session_callback_set.3
libssh2_session_disconnect.3
libssh2_session_disconnect_ex.3
libssh2_session_flag.3
libssh2_session_free.3
libssh2_session_get_blocking.3
libssh2_session_get_timeout.3
libssh2_session_hostkey.3
libssh2_session_init.3
libssh2_session_init_ex.3
libssh2_session_last_errno.3
libssh2_session_last_error.3
libssh2_session_set_last_error.3
libssh2_session_method_pref.3
libssh2_session_methods.3
libssh2_session_set_blocking.3
libssh2_session_set_timeout.3
libssh2_session_startup.3
libssh2_session_supported_algs.3
libssh2_sftp_close.3
libssh2_sftp_close_handle.3
libssh2_sftp_closedir.3
libssh2_sftp_fsetstat.3
libssh2_sftp_fstat.3
libssh2_sftp_fstat_ex.3
libssh2_sftp_fstatvfs.3
libssh2_sftp_fsync.3
libssh2_sftp_get_channel.3
libssh2_sftp_init.3
libssh2_sftp_last_error.3
libssh2_sftp_lstat.3
libssh2_sftp_mkdir.3
libssh2_sftp_mkdir_ex.3
libssh2_sftp_open.3
libssh2_sftp_open_ex.3
libssh2_sftp_opendir.3
libssh2_sftp_read.3
libssh2_sftp_readdir.3
libssh2_sftp_readdir_ex.3
libssh2_sftp_readlink.3
libssh2_sftp_realpath.3
libssh2_sftp_rename.3
libssh2_sftp_rename_ex.3
libssh2_sftp_rewind.3
libssh2_sftp_rmdir.3
libssh2_sftp_rmdir_ex.3
libssh2_sftp_seek.3
libssh2_sftp_seek64.3
libssh2_sftp_setstat.3
libssh2_sftp_shutdown.3
libssh2_sftp_stat.3
libssh2_sftp_stat_ex.3
libssh2_sftp_statvfs.3
libssh2_sftp_symlink.3
libssh2_sftp_symlink_ex.3
libssh2_sftp_tell.3
libssh2_sftp_tell64.3
libssh2_sftp_unlink.3
libssh2_sftp_unlink_ex.3
libssh2_sftp_write.3
libssh2_trace.3
libssh2_trace_sethandler.3
libssh2_userauth_authenticated.3
libssh2_userauth_hostbased_fromfile.3
libssh2_userauth_hostbased_fromfile_ex.3
libssh2_userauth_keyboard_interactive.3
libssh2_userauth_keyboard_interactive_ex.3
libssh2_userauth_list.3
libssh2_userauth_password.3
libssh2_userauth_password_ex.3
libssh2_userauth_publickey.3
libssh2_userauth_publickey_fromfile.3
libssh2_userauth_publickey_fromfile_ex.3
libssh2_version.3)
include(GNUInstallDirs)
install(FILES ${MAN_PAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)

13
docs/HACKING Normal file
View File

@ -0,0 +1,13 @@
libssh2 source code style guide:
- 4 level indent
- spaces-only (no tabs)
- open braces on the if/for line:
if (banana) {
go_nuts();
}
- keep source lines shorter than 80 columns
- See libssh2-style.el for how to achieve this within Emacs

593
docs/HACKING.CRYPTO Normal file
View File

@ -0,0 +1,593 @@
Definitions needed to implement a specific crypto library
This document offers some hints about implementing a new crypto library
interface.
A crypto library interface consists of at least a header file, defining
entities referenced from the libssh2 core modules.
Real code implementation (if needed), is left at the implementor's choice.
This document lists the entities that must/may be defined in the header file.
Procedures listed as "void" may indeed have a result type: the void indication
indicates the libssh2 core modules never use the function result.
1) Crypto library initialization/termination.
void libssh2_crypto_init(void);
Initializes the crypto library. May be an empty macro if not needed.
void libssh2_crypto_exit(void);
Terminates the crypto library use. May be an empty macro if not needed.
2) HMAC
libssh2_hmac_ctx
Type of an HMAC computation context. Generally a struct.
Used for all hash algorithms.
void libssh2_hmac_ctx_init(libssh2_hmac_ctx ctx);
Initializes the HMAC computation context ctx.
Called before setting-up the hash algorithm.
Note: if the ctx parameter is modified by the underlying code,
this procedure must be implemented as a macro to map ctx --> &ctx.
void libssh2_hmac_update(libssh2_hmac_ctx ctx,
const unsigned char *data,
int datalen);
Continue computation of an HMAC on datalen bytes at data using context ctx.
Note: if the ctx parameter is modified by the underlying code,
this procedure must be implemented as a macro to map ctx --> &ctx.
void libssh2_hmac_final(libssh2_hmac_ctx ctx,
unsigned char output[]);
Get the computed HMAC from context ctx into the output buffer. The
minimum data buffer size depends on the HMAC hash algorithm.
Note: if the ctx parameter is modified by the underlying code,
this procedure must be implemented as a macro to map ctx --> &ctx.
void libssh2_hmac_cleanup(libssh2_hmac_ctx *ctx);
Releases the HMAC computation context at ctx.
3) Hash algorithms.
3.1) SHA-1
Must always be implemented.
SHA_DIGEST_LENGTH
#define to 20, the SHA-1 digest length.
libssh2_sha1_ctx
Type of an SHA1 computation context. Generally a struct.
int libssh2_sha1_init(libssh2_sha1_ctx *x);
Initializes the SHA-1 computation context at x.
Returns 1 for success and 0 for failure
void libssh2_sha1_update(libssh2_sha1_ctx ctx,
const unsigned char *data,
size_t len);
Continue computation of SHA-1 on len bytes at data using context ctx.
Note: if the ctx parameter is modified by the underlying code,
this procedure must be implemented as a macro to map ctx --> &ctx.
void libssh2_sha1_final(libssh2_sha1_ctx ctx,
unsigned char output[SHA1_DIGEST_LEN]);
Get the computed SHA-1 signature from context ctx and store it into the
output buffer.
Release the context.
Note: if the ctx parameter is modified by the underlying code,
this procedure must be implemented as a macro to map ctx --> &ctx.
void libssh2_hmac_sha1_init(libssh2_hmac_ctx *ctx,
const void *key,
int keylen);
Setup the HMAC computation context ctx for an HMAC-SHA-1 computation using the
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
3.2) SHA-256
Must always be implemented.
SHA256_DIGEST_LENGTH
#define to 32, the SHA-256 digest length.
libssh2_sha256_ctx
Type of an SHA-256 computation context. Generally a struct.
int libssh2_sha256_init(libssh2_sha256_ctx *x);
Initializes the SHA-256 computation context at x.
Returns 1 for success and 0 for failure
void libssh2_sha256_update(libssh2_sha256_ctx ctx,
const unsigned char *data,
size_t len);
Continue computation of SHA-256 on len bytes at data using context ctx.
Note: if the ctx parameter is modified by the underlying code,
this procedure must be implemented as a macro to map ctx --> &ctx.
void libssh2_sha256_final(libssh2_sha256_ctx ctx,
unsigned char output[SHA256_DIGEST_LENGTH]);
Gets the computed SHA-256 signature from context ctx into the output buffer.
Release the context.
Note: if the ctx parameter is modified by the underlying code,
this procedure must be implemented as a macro to map ctx --> &ctx.
int libssh2_sha256(const unsigned char *message,
unsigned long len,
unsigned char output[SHA256_DIGEST_LENGTH]);
Computes the SHA-256 signature over the given message of length len and
store the result into the output buffer.
Return 1 if error, else 0.
Note: Seems unused in current code, but defined in each crypto library backend.
LIBSSH2_HMAC_SHA256
#define as 1 if the crypto library supports HMAC-SHA-256, else 0.
If defined as 0, the rest of this section can be omitted.
void libssh2_hmac_sha256_init(libssh2_hmac_ctx *ctx,
const void *key,
int keylen);
Setup the HMAC computation context ctx for an HMAC-256 computation using the
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
3.3) SHA-512
LIBSSH2_HMAC_SHA512
#define as 1 if the crypto library supports HMAC-SHA-512, else 0.
If defined as 0, the rest of this section can be omitted.
SHA512_DIGEST_LENGTH
#define to 64, the SHA-512 digest length.
void libssh2_hmac_sha512_init(libssh2_hmac_ctx *ctx,
const void *key,
int keylen);
Setup the HMAC computation context ctx for an HMAC-512 computation using the
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
3.4) MD5
LIBSSH2_MD5
#define to 1 if the crypto library supports MD5, else 0.
If defined as 0, the rest of this section can be omitted.
MD5_DIGEST_LENGTH
#define to 16, the MD5 digest length.
libssh2_md5_ctx
Type of an MD5 computation context. Generally a struct.
int libssh2_md5_init(libssh2_md5_ctx *x);
Initializes the MD5 computation context at x.
Returns 1 for success and 0 for failure
void libssh2_md5_update(libssh2_md5_ctx ctx,
const unsigned char *data,
size_t len);
Continues computation of MD5 on len bytes at data using context ctx.
Returns 1 for success and 0 for failure.
Note: if the ctx parameter is modified by the underlying code,
this procedure must be implemented as a macro to map ctx --> &ctx.
void libssh2_md5_final(libssh2_md5_ctx ctx,
unsigned char output[MD5_DIGEST_LENGTH]);
Gets the computed MD5 signature from context ctx into the output buffer.
Release the context.
Note: if the ctx parameter is modified by the underlying code,
this procedure must be implemented as a macro to map ctx --> &ctx.
void libssh2_hmac_md5_init(libssh2_hmac_ctx *ctx,
const void *key,
int keylen);
Setup the HMAC computation context ctx for an HMAC-MD5 computation using the
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
3.5) RIPEMD-160
LIBSSH2_HMAC_RIPEMD
#define as 1 if the crypto library supports HMAC-RIPEMD-160, else 0.
If defined as 0, the rest of this section can be omitted.
void libssh2_hmac_ripemd160_init(libssh2_hmac_ctx *ctx,
const void *key,
int keylen);
Setup the HMAC computation context ctx for an HMAC-RIPEMD-160 computation using
the keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
Returns 1 for success and 0 for failure.
4) Bidirectional Key ciphers.
_libssh2_cipher_ctx
Type of a cipher computation context.
_libssh2_cipher_type(name);
Macro defining name as storage identifying a cipher algorithm for
the crypto library interface. No trailing semicolon.
int _libssh2_cipher_init(_libssh2_cipher_ctx *h,
_libssh2_cipher_type(algo),
unsigned char *iv,
unsigned char *secret,
int encrypt);
Creates a cipher context for the given algorithm with the initialization vector
iv and the secret key secret. Prepare for encryption or decryption depending on
encrypt.
Return 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
int _libssh2_cipher_crypt(_libssh2_cipher_ctx *ctx,
_libssh2_cipher_type(algo),
int encrypt,
unsigned char *block,
size_t blocksize);
Encrypt or decrypt in-place data at (block, blocksize) using the given
context and/or algorithm.
Return 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
void _libssh2_cipher_dtor(_libssh2_cipher_ctx *ctx);
Release cipher context at ctx.
4.1) AES
4.1.1) AES in CBC block mode.
LIBSSH2_AES
#define as 1 if the crypto library supports AES in CBC mode, else 0.
If defined as 0, the rest of this section can be omitted.
_libssh2_cipher_aes128
AES-128-CBC algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
_libssh2_cipher_aes192
AES-192-CBC algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
_libssh2_cipher_aes256
AES-256-CBC algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
4.1.2) AES in CTR block mode.
LIBSSH2_AES_CTR
#define as 1 if the crypto library supports AES in CTR mode, else 0.
If defined as 0, the rest of this section can be omitted.
void _libssh2_init_aes_ctr(void);
Initialize static AES CTR ciphers.
This procedure is already prototyped in crypto.h.
_libssh2_cipher_aes128ctr
AES-128-CTR algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
_libssh2_cipher_aes192ctr
AES-192-CTR algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
_libssh2_cipher_aes256ctr
AES-256-CTR algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
4.2) Blowfish in CBC block mode.
LIBSSH2_BLOWFISH
#define as 1 if the crypto library supports blowfish in CBC mode, else 0.
If defined as 0, the rest of this section can be omitted.
_libssh2_cipher_blowfish
Blowfish-CBC algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
4.3) RC4.
LIBSSH2_RC4
#define as 1 if the crypto library supports RC4 (arcfour), else 0.
If defined as 0, the rest of this section can be omitted.
_libssh2_cipher_arcfour
RC4 algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
4.4) CAST5 in CBC block mode.
LIBSSH2_CAST
#define 1 if the crypto library supports cast, else 0.
If defined as 0, the rest of this section can be omitted.
_libssh2_cipher_cast5
CAST5-CBC algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
4.5) Tripple DES in CBC block mode.
LIBSSH2_3DES
#define as 1 if the crypto library supports TripleDES in CBC mode, else 0.
If defined as 0, the rest of this section can be omitted.
_libssh2_cipher_3des
TripleDES-CBC algorithm identifier initializer.
#define with constant value of type _libssh2_cipher_type().
5) Big numbers.
Positive multi-byte integers support is sufficient.
5.1) Computation contexts.
This has a real meaning if the big numbers computations need some context
storage. If not, use a dummy type and functions (macros).
_libssh2_bn_ctx
Type of multiple precision computation context. May not be empty. if not used,
#define as char, for example.
libssh2_bn_ctx _libssh2_bn_ctx_new(void);
Returns a new multiple precision computation context.
void _libssh2_bn_ctx_free(_libssh2_bn_ctx ctx);
Releases a multiple precision computation context.
5.2) Computation support.
_libssh2_bn
Type of multiple precision numbers (aka bignumbers or huge integers) for the
crypto library.
_libssh2_bn * _libssh2_bn_init(void);
Creates a multiple precision number (preset to zero).
_libssh2_bn * _libssh2_bn_init_from_bin(void);
Create a multiple precision number intended to be set by the
_libssh2_bn_from_bin() function (see below). Unlike _libssh2_bn_init(), this
code may be a dummy initializer if the _libssh2_bn_from_bin() actually
allocates the number. Returns a value of type _libssh2_bn *.
void _libssh2_bn_free(_libssh2_bn *bn);
Destroys the multiple precision number at bn.
unsigned long _libssh2_bn_bytes(libssh2_bn *bn);
Get the number of bytes needed to store the bits of the multiple precision
number at bn.
unsigned long _libssh2_bn_bits(_libssh2_bn *bn);
Returns the number of bits of multiple precision number at bn.
int _libssh2_bn_set_word(_libssh2_bn *bn, unsigned long val);
Sets the value of bn to val.
Returns 1 on success, 0 otherwise.
_libssh2_bn * _libssh2_bn_from_bin(_libssh2_bn *bn, int len,
const unsigned char *val);
Converts the positive integer in big-endian form of length len at val
into a _libssh2_bn and place it in bn. If bn is NULL, a new _libssh2_bn is
created.
Returns a pointer to target _libssh2_bn or NULL if error.
int _libssh2_bn_to_bin(_libssh2_bn *bn, unsigned char *val);
Converts the absolute value of bn into big-endian form and store it at
val. val must point to _libssh2_bn_bytes(bn) bytes of memory.
Returns the length of the big-endian number.
void _libssh2_bn_rand(_libssh2_bn *bn, int bits, int top, int bottom);
Generates a cryptographically strong pseudo-random number of bits in
length and stores it in bn. If top is -1, the most significant bit of the
random number can be zero. If top is 0, it is set to 1, and if top is 1, the
two most significant bits of the number will be set to 1, so that the product
of two such random numbers will always have 2*bits length. If bottom is true,
the number will be odd.
void _libssh2_bn_mod_exp(_libssh2_bn *r, _libssh2_bn *a,
_libssh2_bn *p, _libssh2_bn *m,
_libssh2_bn_ctx *ctx);
Computes a to the p-th power modulo m and stores the result into r (r=a^p % m).
May use the given context.
6) Private key algorithms.
Format of an RSA public key:
a) "ssh-rsa".
b) RSA exponent, MSB first, with high order bit = 0.
c) RSA modulus, MSB first, with high order bit = 0.
Each item is preceded by its 32-bit byte length, MSB first.
Format of a DSA public key:
a) "ssh-dss".
b) p, MSB first, with high order bit = 0.
c) q, MSB first, with high order bit = 0.
d) g, MSB first, with high order bit = 0.
e) pub_key, MSB first, with high order bit = 0.
Each item is preceded by its 32-bit byte length, MSB first.
int _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
unsigned char **method,
size_t *method_len,
unsigned char **pubkeydata,
size_t *pubkeydata_len,
const char *privatekey,
const char *passphrase);
Reads a private key from file privatekey and extract the public key -->
(pubkeydata, pubkeydata_len). Store the associated method (ssh-rsa or ssh-dss)
into (method, method_len).
Both buffers have to be allocated using LIBSSH2_ALLOC().
Returns 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
int _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
unsigned char **method,
size_t *method_len,
unsigned char **pubkeydata,
size_t *pubkeydata_len,
const char *privatekeydata,
size_t privatekeydata_len,
const char *passphrase);
Gets a private key from bytes at (privatekeydata, privatekeydata_len) and
extract the public key --> (pubkeydata, pubkeydata_len). Store the associated
method (ssh-rsa or ssh-dss) into (method, method_len).
Both buffers have to be allocated using LIBSSH2_ALLOC().
Returns 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
6.1) RSA
LIBSSH2_RSA
#define as 1 if the crypto library supports RSA, else 0.
If defined as 0, the rest of this section can be omitted.
libssh2_rsa_ctx
Type of an RSA computation context. Generally a struct.
int _libssh2_rsa_new(libssh2_rsa_ctx **rsa,
const unsigned char *edata,
unsigned long elen,
const unsigned char *ndata,
unsigned long nlen,
const unsigned char *ddata,
unsigned long dlen,
const unsigned char *pdata,
unsigned long plen,
const unsigned char *qdata,
unsigned long qlen,
const unsigned char *e1data,
unsigned long e1len,
const unsigned char *e2data,
unsigned long e2len,
const unsigned char *coeffdata, unsigned long coefflen);
Creates a new context for RSA computations from key source values:
pdata, plen Prime number p. Only used if private key known (ddata).
qdata, qlen Prime number q. Only used if private key known (ddata).
ndata, nlen Modulus n.
edata, elen Exponent e.
ddata, dlen e^-1 % phi(n) = private key. May be NULL if unknown.
e1data, e1len dp = d % (p-1). Only used if private key known (dtata).
e2data, e2len dq = d % (q-1). Only used if private key known (dtata).
coeffdata, coefflen q^-1 % p. Only used if private key known.
Returns 0 if OK.
This procedure is already prototyped in crypto.h.
Note: the current generic code only calls this function with e and n (public
key parameters): unless used internally by the backend, it is not needed to
support the private key and the other parameters here.
int _libssh2_rsa_new_private(libssh2_rsa_ctx **rsa,
LIBSSH2_SESSION *session,
const char *filename,
unsigned const char *passphrase);
Reads an RSA private key from file filename into a new RSA context.
Must call _libssh2_init_if_needed().
Return 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
int _libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa,
LIBSSH2_SESSION *session,
const char *data,
size_t data_len,
unsigned const char *passphrase);
Gets an RSA private key from data into a new RSA context.
Must call _libssh2_init_if_needed().
Return 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
int _libssh2_rsa_sha1_verify(libssh2_rsa_ctx *rsa,
const unsigned char *sig,
unsigned long sig_len,
const unsigned char *m, unsigned long m_len);
Verify (sig, siglen) signature of (m, m_len) using an SHA-1 hash and the
RSA context.
Return 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
int _libssh2_rsa_sha1_signv(LIBSSH2_SESSION *session,
unsigned char **sig, size_t *siglen,
int count, const struct iovec vector[],
libssh2_rsa_ctx *ctx);
RSA signs the SHA-1 hash computed over the count data chunks in vector.
Signature is stored at (sig, siglen).
Signature buffer must be allocated from the given session.
Returns 0 if OK, else -1.
Note: this procedure is optional: if provided, it MUST be defined as a macro.
int _libssh2_rsa_sha1_sign(LIBSSH2_SESSION *session,
libssh2_rsa_ctx *rsactx,
const unsigned char *hash,
size_t hash_len,
unsigned char **signature,
size_t *signature_len);
RSA signs the (hash, hashlen) SHA-1 hash bytes and stores the allocated
signature at (signature, signature_len).
Signature buffer must be allocated from the given session.
Returns 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
Note: this procedure is not used if macro _libssh2_rsa_sha1_signv() is defined.
void _libssh2_rsa_free(libssh2_rsa_ctx *rsactx);
Releases the RSA computation context at rsactx.
6.2) DSA
LIBSSH2_DSA
#define as 1 if the crypto library supports DSA, else 0.
If defined as 0, the rest of this section can be omitted.
libssh2_dsa_ctx
Type of a DSA computation context. Generally a struct.
int _libssh2_dsa_new(libssh2_dsa_ctx **dsa,
const unsigned char *pdata,
unsigned long plen,
const unsigned char *qdata,
unsigned long qlen,
const unsigned char *gdata,
unsigned long glen,
const unsigned char *ydata,
unsigned long ylen,
const unsigned char *x, unsigned long x_len);
Creates a new context for DSA computations from source key values:
pdata, plen Prime number p. Only used if private key known (ddata).
qdata, qlen Prime number q. Only used if private key known (ddata).
gdata, glen G number.
ydata, ylen Public key.
xdata, xlen Private key. Only taken if xlen non-zero.
Returns 0 if OK.
This procedure is already prototyped in crypto.h.
int _libssh2_dsa_new_private(libssh2_dsa_ctx **dsa,
LIBSSH2_SESSION *session,
const char *filename,
unsigned const char *passphrase);
Gets a DSA private key from file filename into a new DSA context.
Must call _libssh2_init_if_needed().
Return 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
int _libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx **dsa,
LIBSSH2_SESSION *session,
const char *data,
size_t data_len,
unsigned const char *passphrase);
Gets a DSA private key from the data_len-bytes data into a new DSA context.
Must call _libssh2_init_if_needed().
Returns 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx *dsactx,
const unsigned char *sig,
const unsigned char *m, unsigned long m_len);
Verify (sig, siglen) signature of (m, m_len) using an SHA1 hash and the
DSA context.
Returns 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
int _libssh2_dsa_sha1_sign(libssh2_dsa_ctx *dsactx,
const unsigned char *hash,
unsigned long hash_len, unsigned char *sig);
DSA signs the (hash, hash_len) data using SHA-1 and store the signature at sig.
Returns 0 if OK, else -1.
This procedure is already prototyped in crypto.h.
void _libssh2_dsa_free(libssh2_dsa_ctx *dsactx);
Releases the DSA computation context at dsactx.
7) Miscellaneous
void libssh2_prepare_iovec(struct iovec *vector, unsigned int len);
Prepare len consecutive iovec slots before using them.
In example, this is needed to preset unused structure slacks on platforms
requiring it.
If this is not needed, it should be defined as an empty macro.
void _libssh2_random(unsigned char *buf, int len);
Store len random bytes at buf.

325
docs/INSTALL_AUTOTOOLS Normal file
View File

@ -0,0 +1,325 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script). Here is a another example:
/bin/bash ./configure CONFIG_SHELL=/bin/bash
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
configuration-related scripts to be executed by `/bin/bash'.
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
More configure options
======================
Some ./configure options deserve additional comments:
* --enable-crypt-none
The SSH2 Transport allows for unencrypted data
transmission using the "none" cipher. Because this is
such a huge security hole, it is typically disabled on
SSH2 implementations and is disabled in libssh2 by
default as well.
Enabling this option will allow for "none" as a
negotiable method, however it still requires that the
method be advertized by the remote end and that no
more-preferable methods are available.
* --enable-mac-none
The SSH2 Transport also allows implementations to
forego a message authentication code. While this is
less of a security risk than using a "none" cipher, it
is still not recommended as disabling MAC hashes
removes a layer of security.
Enabling this option will allow for "none" as a
negotiable method, however it still requires that the
method be advertized by the remote end and that no
more-preferable methods are available.
* --disable-gex-new
The diffie-hellman-group-exchange-sha1 (dh-gex) key
exchange method originally defined an exchange
negotiation using packet type 30 to request a
generation pair based on a single target value. Later
refinement of dh-gex provided for range and target
values. By default libssh2 will use the newer range
method.
If you experience trouble connecting to an old SSH
server using dh-gex, try this option to fallback on
the older more reliable method.
* --with-libgcrypt
* --without-libgcrypt
* --with-libgcrypt-prefix=DIR
libssh2 can use the Libgcrypt library
(http://www.gnupg.org/) for cryptographic operations.
Either Libgcrypt or OpenSSL is required.
Configure will attempt to locate Libgcrypt
automatically.
If your installation of Libgcrypt is in another
location, specify it using --with-libgcrypt-prefix.
* --with-openssl
* --without-openssl
* --with-libssl-prefix=[DIR]
libssh2 can use the OpenSSL library
(http://www.openssl.org) for cryptographic operations.
Either Libgcrypt or OpenSSL is required.
Configure will attempt to locate OpenSSL in the
default location.
If your installation of OpenSSL is in another
location, specify it using --with-libssl-prefix.
* --with-libz
* --without-libz
* --with-libz-prefix=[DIR]
If present, libssh2 will attempt to use the zlib
(http://www.zlib.org) for payload compression, however
zlib is not required.
If your installation of Libz is in another location,
specify it using --with-libz-prefix.
* --enable-debug
Will make the build use more pedantic and strict compiler
options as well as enable the libssh2_trace() function (for
showing debug traces).

174
docs/INSTALL_CMAKE Normal file
View File

@ -0,0 +1,174 @@
License: see COPYING
Source code: https://github.com/libssh2/libssh2
Web site source code: https://github.com/libssh2/www
Installation instructions are in docs/INSTALL
=======
To build libssh2 you will need CMake v2.8 or later [1] and one of the
following cryptography libraries:
* OpenSSL
* Libgcrypt
* WinCNG
Getting started
---------------
If you are happy with the default options, make a new build directory,
change to it, configure the build environment and build the project:
mkdir bin
cd bin
cmake ..
cmake --build .
libssh2 will be built as a static library and will use any
cryptography library available. The library binary will be put in
`bin/src`, with the examples in `bin/example` and the tests in
`bin/tests`.
Customising the build
---------------------
Of course, you might want to customise the build options. You can
pass the options to CMake on the command line:
cmake -D<option>=<value> ..
The following options are available:
* `BUILD_SHARED_LIBS=OFF`
Determines whether libssh2 is built as a static library or as a
shared library (.dll/.so). Can be `ON` or `OFF`.
* `CRYPTO_BACKEND=`
Chooses a specific cryptography library to use for cryptographic
operations. Can be `OpenSSL` (http://www.openssl.org),
`Libgcrypt` (http://www.gnupg.org/), `WinCNG` (Windows Vista+) or
blank to use any library available.
CMake will attempt to locate the libraries automatically. See [2]
for more information.
* `ENABLE_ZLIB_COMPRESSION=OFF`
Will use zlib (http://www.zlib.org) for payload compression. Can
be `ON` or `OFF`.
* `ENABLE_CRYPT_NONE=OFF`
The SSH2 Transport allows for unencrypted data transmission using
the "none" cipher. Because this is such a huge security hole, it
is typically disabled on SSH2 implementations and is disabled in
libssh2 by default as well.
Enabling this option will allow for "none" as a negotiable method,
however it still requires that the method be advertized by the
remote end and that no more-preferable methods are available.
* `ENABLE_MAC_NONE=OFF`
The SSH2 Transport also allows implementations to forego a message
authentication code. While this is less of a security risk than
using a "none" cipher, it is still not recommended as disabling
MAC hashes removes a layer of security.
Enabling this option will allow for "none" as a negotiable method,
however it still requires that the method be advertized by the
remote end and that no more-preferable methods are available.
* `ENABLE_GEX_NEW=ON`
The diffie-hellman-group-exchange-sha1 (dh-gex) key exchange
method originally defined an exchange negotiation using packet
type 30 to request a generation pair based on a single target
value. Later refinement of dh-gex provided for range and target
values. By default libssh2 will use the newer range method.
If you experience trouble connecting to an old SSH server using
dh-gex, try this option to fallback on the older more reliable
method.
* `ENABLE_DEBUG_LOGGING=ON` in Debug, `=OFF` in Release
Will enable the libssh2_trace() function for showing debug traces.
Build tools
-----------
The previous examples used CMake to start the build using:
cmake --build .
Alternatively, once CMake has configured your project, you can just
use your own build tool, e.g GNU make, Visual Studio, etc., from that
point onwards.
Tests
-----
To test the build, run the appropriate test target for your build
system. For example:
cmake --build . --target test
or
cmake --build . --target RUN_TESTS
How do I use libssh2 in my project if my project doesn't use CMake?
-------------------------------------------------------------------
If you are not using CMake for your own project, install libssh2
cmake <libssh2 source location>
cmake --build .
cmake --build . --target install
or
cmake --build . --target INSTALL
and then specify the install location to your project in the normal
way for your build environment. If you don't like the default install
location, add `-DCMAKE_INSTALL_PREFIX=<chosen prefix>` when initially
configuring the project.
How can I use libssh2 in my project if it also uses CMake?
----------------------------------------------------------
If your own project also uses CMake, you don't need to worry about
setting it up with libssh2's location. Just add just the following
lines and CMake will find libssh2 on your system, set up the necessary
paths and link the library with your binary.
find_package(Libssh2 REQUIRED CONFIG)
target_link_libraries(my_project_target Libssh2::libssh2)
Of course, you still have to make libssh2 available on your system
first. You can install it in the traditional way shown above, but you
don't have to. Instead you can just build it, which will export its
location to the user package registry [3] where `find_package` will
find it.
You can even combine the two steps using a so-called 'superbuild'
project [4] that downloads, builds and exports libssh2, and then
builds your project:
include(ExternalProject)
ExternalProject_Add(
Libssh2
URL <libssh2 download location>
URL_HASH SHA1=<libssh2 archive SHA1>
INSTALL_COMMAND "")
ExternalProject_Add(
MyProject DEPENDS Libssh2
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src
INSTALL_COMMAND "")
[1] http://www.cmake.org/cmake/resources/software.html
[2] http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html
[3] http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#package-registry
[4] http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html

175
docs/Makefile.am Normal file
View File

@ -0,0 +1,175 @@
# $Id: Makefile.am,v 1.37 2009/03/26 15:41:15 bagder Exp $
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE HACKING TODO \
AUTHORS CMakeLists.txt HACKING.CRYPTO
dist_man_MANS = \
libssh2_agent_connect.3 \
libssh2_agent_disconnect.3 \
libssh2_agent_free.3 \
libssh2_agent_get_identity.3 \
libssh2_agent_init.3 \
libssh2_agent_list_identities.3 \
libssh2_agent_userauth.3 \
libssh2_banner_set.3 \
libssh2_base64_decode.3 \
libssh2_channel_close.3 \
libssh2_channel_direct_tcpip.3 \
libssh2_channel_direct_tcpip_ex.3 \
libssh2_channel_eof.3 \
libssh2_channel_exec.3 \
libssh2_channel_flush.3 \
libssh2_channel_flush_ex.3 \
libssh2_channel_flush_stderr.3 \
libssh2_channel_forward_accept.3 \
libssh2_channel_forward_cancel.3 \
libssh2_channel_forward_listen.3 \
libssh2_channel_forward_listen_ex.3 \
libssh2_channel_free.3 \
libssh2_channel_get_exit_signal.3 \
libssh2_channel_get_exit_status.3 \
libssh2_channel_handle_extended_data.3 \
libssh2_channel_handle_extended_data2.3 \
libssh2_channel_ignore_extended_data.3 \
libssh2_channel_open_ex.3 \
libssh2_channel_open_session.3 \
libssh2_channel_process_startup.3 \
libssh2_channel_read.3 \
libssh2_channel_read_ex.3 \
libssh2_channel_read_stderr.3 \
libssh2_channel_receive_window_adjust.3 \
libssh2_channel_receive_window_adjust2.3 \
libssh2_channel_request_pty.3 \
libssh2_channel_request_pty_ex.3 \
libssh2_channel_request_pty_size.3 \
libssh2_channel_request_pty_size_ex.3 \
libssh2_channel_send_eof.3 \
libssh2_channel_set_blocking.3 \
libssh2_channel_setenv.3 \
libssh2_channel_setenv_ex.3 \
libssh2_channel_shell.3 \
libssh2_channel_subsystem.3 \
libssh2_channel_wait_closed.3 \
libssh2_channel_wait_eof.3 \
libssh2_channel_window_read.3 \
libssh2_channel_window_read_ex.3 \
libssh2_channel_window_write.3 \
libssh2_channel_window_write_ex.3 \
libssh2_channel_write.3 \
libssh2_channel_write_ex.3 \
libssh2_channel_write_stderr.3 \
libssh2_channel_x11_req.3 \
libssh2_channel_x11_req_ex.3 \
libssh2_exit.3 \
libssh2_free.3 \
libssh2_hostkey_hash.3 \
libssh2_init.3 \
libssh2_keepalive_config.3 \
libssh2_keepalive_send.3 \
libssh2_knownhost_add.3 \
libssh2_knownhost_addc.3 \
libssh2_knownhost_check.3 \
libssh2_knownhost_checkp.3 \
libssh2_knownhost_del.3 \
libssh2_knownhost_free.3 \
libssh2_knownhost_get.3 \
libssh2_knownhost_init.3 \
libssh2_knownhost_readfile.3 \
libssh2_knownhost_readline.3 \
libssh2_knownhost_writefile.3 \
libssh2_knownhost_writeline.3 \
libssh2_poll.3 \
libssh2_poll_channel_read.3 \
libssh2_publickey_add.3 \
libssh2_publickey_add_ex.3 \
libssh2_publickey_init.3 \
libssh2_publickey_list_fetch.3 \
libssh2_publickey_list_free.3 \
libssh2_publickey_remove.3 \
libssh2_publickey_remove_ex.3 \
libssh2_publickey_shutdown.3 \
libssh2_scp_recv.3 \
libssh2_scp_recv2.3 \
libssh2_scp_send.3 \
libssh2_scp_send64.3 \
libssh2_scp_send_ex.3 \
libssh2_session_abstract.3 \
libssh2_session_banner_get.3 \
libssh2_session_banner_set.3 \
libssh2_session_block_directions.3 \
libssh2_session_callback_set.3 \
libssh2_session_disconnect.3 \
libssh2_session_disconnect_ex.3 \
libssh2_session_flag.3 \
libssh2_session_free.3 \
libssh2_session_get_blocking.3 \
libssh2_session_get_timeout.3 \
libssh2_session_handshake.3 \
libssh2_session_hostkey.3 \
libssh2_session_init.3 \
libssh2_session_init_ex.3 \
libssh2_session_last_errno.3 \
libssh2_session_last_error.3 \
libssh2_session_set_last_error.3 \
libssh2_session_method_pref.3 \
libssh2_session_methods.3 \
libssh2_session_set_blocking.3 \
libssh2_session_set_timeout.3 \
libssh2_session_startup.3 \
libssh2_session_supported_algs.3 \
libssh2_sftp_close.3 \
libssh2_sftp_close_handle.3 \
libssh2_sftp_closedir.3 \
libssh2_sftp_fsetstat.3 \
libssh2_sftp_fstat.3 \
libssh2_sftp_fstat_ex.3 \
libssh2_sftp_fstatvfs.3 \
libssh2_sftp_fsync.3 \
libssh2_sftp_get_channel.3 \
libssh2_sftp_init.3 \
libssh2_sftp_last_error.3 \
libssh2_sftp_lstat.3 \
libssh2_sftp_mkdir.3 \
libssh2_sftp_mkdir_ex.3 \
libssh2_sftp_open.3 \
libssh2_sftp_open_ex.3 \
libssh2_sftp_opendir.3 \
libssh2_sftp_read.3 \
libssh2_sftp_readdir.3 \
libssh2_sftp_readdir_ex.3 \
libssh2_sftp_readlink.3 \
libssh2_sftp_realpath.3 \
libssh2_sftp_rename.3 \
libssh2_sftp_rename_ex.3 \
libssh2_sftp_rewind.3 \
libssh2_sftp_rmdir.3 \
libssh2_sftp_rmdir_ex.3 \
libssh2_sftp_seek.3 \
libssh2_sftp_seek64.3 \
libssh2_sftp_setstat.3 \
libssh2_sftp_shutdown.3 \
libssh2_sftp_stat.3 \
libssh2_sftp_stat_ex.3 \
libssh2_sftp_statvfs.3 \
libssh2_sftp_symlink.3 \
libssh2_sftp_symlink_ex.3 \
libssh2_sftp_tell.3 \
libssh2_sftp_tell64.3 \
libssh2_sftp_unlink.3 \
libssh2_sftp_unlink_ex.3 \
libssh2_sftp_write.3 \
libssh2_trace.3 \
libssh2_trace_sethandler.3 \
libssh2_userauth_authenticated.3 \
libssh2_userauth_hostbased_fromfile.3 \
libssh2_userauth_hostbased_fromfile_ex.3 \
libssh2_userauth_keyboard_interactive.3 \
libssh2_userauth_keyboard_interactive_ex.3 \
libssh2_userauth_list.3 \
libssh2_userauth_password.3 \
libssh2_userauth_password_ex.3 \
libssh2_userauth_publickey.3 \
libssh2_userauth_publickey_fromfile.3 \
libssh2_userauth_publickey_fromfile_ex.3 \
libssh2_userauth_publickey_frommemory.3 \
libssh2_version.3

174
docs/TODO Normal file
View File

@ -0,0 +1,174 @@
Things TODO
===========
* Fix the numerous malloc+copy operations for sending data, see "Buffering
Improvements" below for details
* make sure the windowing code adapts better to slow situations so that it
doesn't then use as much memory as today. Possibly by an app-controllable
"Window mode"?
* Decrease the number of mallocs. Everywhere. Will get easier once the
buffering improvements have been done.
* Use SO_NOSIGPIPE for Mac OS/BSD systems where MSG_NOSIGNAL doesn't
exist/work
* Extend the test suite to actually test lots of aspects of libssh2
* Fix all compiler warnings (some can't be done without API changes)
* Expose error messages sent by the server
* select() is troublesome with libssh2 when using multiple channels over
the same session. See "New Transport API" below for more details.
At next SONAME bump
===================
* stop using #defined macros as part of the official API. The macros should
either be turned into real functions or discarded from the API.
* fix the parts of the API where object pointers and function pointers are
mixed like libssh2_session_callback_set()
* remove the following functions from the API/ABI
libssh2_base64_decode()
libssh2_session_flag()
libssh2_channel_handle_extended_data()
libssh2_channel_receive_window_adjust()
libssh2_poll()
libssh2_poll_channel_read()
libssh2_session_startup() (libssh2_session_handshake() is the replacement)
libssh2_banner_set() (libssh2_session_banner_set() is the repacement)
* Rename a few function:
libssh2_hostkey_hash => libssh2_session_hostkey_hash
libssh2_banner_set => libssh2_session_banner_set
* change 'int' to 'libssh2_socket_t' in the public API for sockets.
* Use 'size_t' for string lengths in all functions.
* Add a comment field to struct libssh2_knownhost.
* remove the existing libssh2_knownhost_add() function and rename
libssh2_knownhost_addc to become the new libssh2_knownhost_add instead
* remove the existing libssh2_scp_send_ex() function and rename
libssh2_scp_send64 to become the new libssh2_scp_send instead.
* remove the existing libssh2_knownhost_check() functin and rename
libssh2_knownhost_checkp() to become the new libssh2_knownhost_check instead
Buffering Improvements
======================
transport_write
- If this function gets called with a total packet size that is larger than
32K, it should create more than one SSH packet so that it keeps the largest
one below 32K
sftp_write
- should not copy/allocate anything for the data, only create a header chunk
and pass on the payload data to channel_write "pointed to"
New Transport API
=================
THE PROBLEM
The problem in a nutshell is that when an application opens up multiple
channels over a single session, those are all using the same socket. If the
application is then using select() to wait for traffic (like any sensible app
does) and wants to act on the data when select() tells there is something to
for example read, what does an application do?
With our current API, you have to loop over all the channels and read from
them to see if they have data. This effectively makes blocking reads
impossible. If the app has many channels in a setup like this, it even becomes
slow. (The original API had the libssh2_poll_channel_read() and libssh2_poll()
to somewhat overcome this hurdle, but they too have pretty much the same
problems plus a few others.)
Traffic in the other direction is similarly limited: the app has to try
sending to all channels, even though some of them may very well not accept any
data at that point.
A SOLUTION
I suggest we introduce two new helper functions:
libssh2_transport_read()
- Read "a bunch" of data from the given socket and returns information to the
app about what channels that are now readable (ie they will not block when
read from). The function can be called over and over and it will repeatedly
return info about what channels that are readable at that moment.
libssh2_transport_write()
- Returns information about what channels that are writable, in the sense
that they have windows set from the remote side that allows data to get
sent. Writing to one of those channels will not block. Of course, the
underlying socket may only accept a certain amount of data, so at the first
short return, nothing more should be attempted to get sent until select()
(or equivalent) has been used on the master socket again.
I haven't yet figured out a sensible API for how these functions should return
that info, but if we agree on the general principles I guess we can work that
out.
VOLUNTARY
I wanted to mention that these two helper functions would not be mandatory
in any way. They would just be there for those who want them, and existing
programs can remain using the old functions only if they prefer to.
New SFTP API
============
PURPOSE
Provide API functions that explicitly tells at once that a (full) SFTP file
transfer is wanted, to allow libssh2 to leverage on that knowledge to speed
up things internally. It can for example do read ahead, buffer writes (merge
small writes into larger chunks), better tune the SSH window and more. This
sort of API is already provided for SCP transfers.
API
New functions:
LIBSSH2_SFTP_HANDLE *libssh2_sftp_send(SFTP_SESSION *sftp,
uint64_t filesize,
char *remote_path,
size_t remote_path_len,
long mode);
Tell libssh2 that a local file with a given size is about to get sent to
the SFTP server.
LIBSSH2_SFTP_HANDLE *libssh2_sftp_recv();
Tell libssh2 that a remote file is requested to get downloaded from the SFTP
server.
Only the setup of the file transfer is different from an application's point
of view. Depending on direction of the transfer(s), the following already
existing functions should then be used until the transfer is complete:
libssh2_sftp_read()
libssh2_sftp_write()
HOW TO USE
1. Setup the transfer using one of the two new functions.
2. Loop through the reading or writing of data.
3. Cleanup the transfer

View File

@ -0,0 +1,23 @@
.\"
.\" Copyright (c) 2009 by Daiki Ueno
.\"
.TH libssh2_agent_connect 3 "23 Dec 2009" "libssh2 1.2" "libssh2 manual"
.SH NAME
libssh2_agent_connect - connect to an ssh-agent
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_agent_connect(LIBSSH2_AGENT *agent);
.SH DESCRIPTION
Connect to an ssh-agent running on the system.
Call \fBlibssh2_agent_disconnect(3)\fP to close the connection after
you're doing using it.
.SH RETURN VALUE
Returns 0 if succeeded, or a negative value for error.
.SH AVAILABILITY
Added in libssh2 1.2
.SH SEE ALSO
.BR libssh2_agent_init(3)
.BR libssh2_agent_disconnect(3)

View File

@ -0,0 +1,20 @@
.\"
.\" Copyright (c) 2009 by Daiki Ueno
.\"
.TH libssh2_agent_disconnect 3 "23 Dec 2009" "libssh2 1.2" "libssh2 manual"
.SH NAME
libssh2_agent_disconnect - close a connection to an ssh-agent
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_agent_disconnect(LIBSSH2_AGENT *agent);
.SH DESCRIPTION
Close a connection to an ssh-agent.
.SH RETURN VALUE
Returns 0 if succeeded, or a negative value for error.
.SH AVAILABILITY
Added in libssh2 1.2
.SH SEE ALSO
.BR libssh2_agent_connect(3)
.BR libssh2_agent_free(3)

20
docs/libssh2_agent_free.3 Normal file
View File

@ -0,0 +1,20 @@
.\"
.\" Copyright (c) 2009 by Daiki Ueno
.\"
.TH libssh2_agent_free 3 "28 May 2009" "libssh2 1.2" "libssh2 manual"
.SH NAME
libssh2_agent_free - free an ssh-agent handle
.SH SYNOPSIS
#include <libssh2.h>
void libssh2_agent_free(LIBSSH2_AGENT *agent);
.SH DESCRIPTION
Free an ssh-agent handle. This function also frees the internal
collection of public keys.
.SH RETURN VALUE
None.
.SH AVAILABILITY
Added in libssh2 1.2
.SH SEE ALSO
.BR libssh2_agent_init(3)
.BR libssh2_agent_disconnect(3)

View File

@ -0,0 +1,34 @@
.\"
.\" Copyright (c) 2009 by Daiki Ueno
.\"
.TH libssh2_agent_get_identity 3 "23 Dec 2009" "libssh2 1.2" "libssh2 manual"
.SH NAME
libssh2_agent_get_identity - get a public key off the collection of public keys managed by ssh-agent
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_agent_get_identity(LIBSSH2_AGENT *agent,
struct libssh2_agent_publickey **store,
struct libssh2_agent_publickey *prev);
.SH DESCRIPTION
\fIlibssh2_agent_get_identity(3)\fP allows an application to iterate
over all public keys in the collection managed by ssh-agent.
\fIstore\fP should point to a pointer that gets filled in to point to the
public key data.
\fIprev\fP is a pointer to a previous 'struct libssh2_agent_publickey'
as returned by a previous invoke of this function, or NULL to get the
first entry in the internal collection.
.SH RETURN VALUE
Returns 0 if everything is fine and information about a host was stored in
the \fIstore\fP struct.
Returns 1 if it reached the end of public keys.
Returns negative values for error
.SH AVAILABILITY
Added in libssh2 1.2
.SH SEE ALSO
.BR libssh2_agent_list_identities(3)
.BR libssh2_agent_userauth(3)

26
docs/libssh2_agent_init.3 Normal file
View File

@ -0,0 +1,26 @@
.\"
.\" Copyright (c) 2009 by Daiki Ueno
.\"
.TH libssh2_agent_init 3 "23 Dec 2009" "libssh2 1.2" "libssh2 manual"
.SH NAME
libssh2_agent_init - init an ssh-agent handle
.SH SYNOPSIS
#include <libssh2.h>
LIBSSH2_AGENT *libssh2_agent_init(LIBSSH2_SESSION *session);
.SH DESCRIPTION
Init an ssh-agent handle. Returns the handle to an internal
representation of an ssh-agent connection. After the successful
initialization, an application can call \fBlibssh2_agent_connect(3)\fP
to connect to a running ssh-agent.
Call \fBlibssh2_agent_free(3)\fP to free the handle again after you're
doing using it.
.SH RETURN VALUE
Returns a handle pointer or NULL if something went wrong. The returned handle
is used as input to all other ssh-agent related functions libssh2 provides.
.SH AVAILABILITY
Added in libssh2 1.2
.SH SEE ALSO
.BR libssh2_agent_connect(3)
.BR libssh2_agent_free(3)

View File

@ -0,0 +1,24 @@
.\"
.\" Copyright (c) 2009 by Daiki Ueno
.\"
.TH libssh2_agent_list_identities 3 "23 Dec 2009" "libssh2 1.2" "libssh2 manual"
.SH NAME
libssh2_agent_list_identities - request an ssh-agent to list of public keys.
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_agent_list_identities(LIBSSH2_AGENT *agent);
.SH DESCRIPTION
Request an ssh-agent to list of public keys, and stores them in the
internal collection of the handle. Call
\fIlibssh2_agent_get_identity(3)\fP to get a public key off the
collection.
.SH RETURN VALUE
Returns 0 if succeeded, or a negative value for error.
.SH AVAILABILITY
Added in libssh2 1.2
.SH SEE ALSO
.BR libssh2_agent_connect(3)
.BR libssh2_agent_get_identity(3)

View File

@ -0,0 +1,29 @@
.\"
.\" Copyright (c) 2009 by Daiki Ueno
.\"
.TH libssh2_agent_userauth 3 "23 Dec 2009" "libssh2 1.2" "libssh2 manual"
.SH NAME
libssh2_agent_userauth - authenticate a session with a public key, with the help of ssh-agent
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_agent_userauth(LIBSSH2_AGENT *agent,
const char *username,
struct libssh2_agent_publickey *identity);
.SH DESCRIPTION
\fIagent\fP - ssh-agent handle as returned by
.BR libssh2_agent_init(3)
\fIusername\fP - Remote user name to authenticate as.
\fIidentity\fP - Public key to authenticate with, as returned by
.BR libssh2_agent_get_identity(3)
Attempt public key authentication with the help of ssh-agent.
.SH RETURN VALUE
Returns 0 if succeeded, or a negative value for error.
.SH AVAILABILITY
Added in libssh2 1.2
.SH SEE ALSO
.BR libssh2_agent_init(3)
.BR libssh2_agent_get_identity(3)

32
docs/libssh2_banner_set.3 Normal file
View File

@ -0,0 +1,32 @@
.TH libssh2_banner_set 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_banner_set - set the SSH protocol banner for the local client
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_banner_set(LIBSSH2_SESSION *session, const char *banner);
.SH DESCRIPTION
This function is \fBDEPRECATED\fP. Use \fIlibssh2_session_banner_set(3)\fP
instead!
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init_ex(3)
\fIbanner\fP - A pointer to a user defined banner
Set the banner that will be sent to the remote host when the SSH session is
started with
.BR libssh2_session_handshake(3)
This is optional; a banner corresponding to the protocol and libssh2 version will be sent by default.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH AVAILABILITY
Marked as deprecated since 1.4.0
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
.SH SEE ALSO
.BR libssh2_session_handshake(3)

View File

@ -0,0 +1,25 @@
.TH libssh2_base64_decode 3 "23 Dec 2008" "libssh2 1.0" "libssh2 manual"
.SH NAME
libssh2_base64_decode - decode a base64 encoded string
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_base64_decode(LIBSSH2_SESSION *session, char **dest,
unsigned int *dest_len, const char *src,
unsigned int src_len);
.SH DESCRIPTION
This function is deemed DEPRECATED and will be removed from libssh2 in a
future version. Don't use it!
Decode a base64 chunk and store it into a newly allocated buffer. 'dest_len'
will be set to hold the length of the returned buffer that '*dest' will point
to.
The returned buffer is allocated by this function, but it is not clear how to
free that memory!
.SH BUGS
The memory that *dest points to is allocated by the malloc function libssh2
uses, but there's no way for an application to free this data in a safe and
reliable way!
.SH RETURN VALUE
0 if successful, \-1 if any error occurred.

View File

@ -0,0 +1,29 @@
.TH libssh2_channel_close 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_close - close a channel
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_close(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
\fIchannel\fP - active channel stream to set closed status on.
Close an active data channel. In practice this means sending an SSH_MSG_CLOSE
packet to the remote host which serves as instruction that no further data
will be sent to it. The remote host may still send data back until it sends
its own close message in response. To wait for the remote end to close its
connection as well, follow this command with
.BR libssh2_channel_wait_closed(3)
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH ERRORS
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
.SH SEE ALSO
.BR libssh2_channel_open_ex(3)

View File

@ -0,0 +1,18 @@
.TH libssh2_channel_direct_tcpip 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_direct_tcpip - convenience macro for \fIlibssh2_channel_direct_tcpip_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
LIBSSH2_CHANNEL *
libssh2_channel_direct_tcpip(LIBSSH2_SESSION *session, const char *host, int port);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_direct_tcpip_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_direct_tcpip_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_direct_tcpip_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_direct_tcpip_ex(3)

View File

@ -0,0 +1,35 @@
.TH libssh2_channel_direct_tcpip_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_direct_tcpip_ex - Tunnel a TCP connection through an SSH session
.SH SYNOPSIS
#include <libssh2.h>
LIBSSH2_CHANNEL *
libssh2_channel_direct_tcpip_ex(LIBSSH2_SESSION *session, const char *host, int port, const char *shost, int sport);
LIBSSH2_CHANNEL *
libssh2_channel_direct_tcpip(LIBSSH2_SESSION *session, const char *host, int port);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init_ex(3)
\fIhost\fP - Third party host to connect to using the SSH host as a proxy.
\fIport\fP - Port on third party host to connect to.
\fIshost\fP - Host to tell the SSH server the connection originated on.
\fIsport\fP - Port to tell the SSH server the connection originated from.
Tunnel a TCP/IP connection through the SSH transport via the remote host to
a third party. Communication from the client to the SSH server remains
encrypted, communication from the server to the 3rd party host travels
in cleartext.
.SH RETURN VALUE
Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors.
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
.SH SEE ALSO
.BR libssh2_session_init_ex(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_eof 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_eof - check a channel's EOF status
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_eof(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
\fIchannel\fP - active channel stream to set closed status on.
Check if the remote host has sent an EOF status for the selected stream.
.SH RETURN VALUE
Returns 1 if the remote host has sent EOF, otherwise 0. Negative on
failure.
.SH SEE ALSO
.BR libssh2_channel_close(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_exec 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_exec - convenience macro for \fIlibssh2_channel_process_startup(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_exec(LIBSSH2_CHANNEL *channel, const char *command);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_process_startup(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_process_startup(3)\fP
.SH ERRORS
See \fIlibssh2_channel_process_startup(3)\fP
.SH SEE ALSO
.BR libssh2_channel_process_startup(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_flush 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_flush - convenience macro for \fIlibssh2_channel_flush_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_flush(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_flush_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_flush_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_flush_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_flush_ex(3)

View File

@ -0,0 +1,32 @@
.TH libssh2_channel_flush_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_flush_ex - flush a channel
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_flush_ex(LIBSSH2_CHANNEL *channel, int streamid);
int
libssh2_channel_flush(LIBSSH2_CHANNEL *channel);
int
libssh2_channel_flush_stderr(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
\fIchannel\fP - Active channel stream to flush.
\fIstreamid\fP - Specific substream number to flush. Groups of substreams may
be flushed by passing on of the following Constants.
.br
\fBLIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA\fP: Flush all extended data substreams
.br
\fBLIBSSH2_CHANNEL_FLUSH_ALL\fP: Flush all substreams
Flush the read buffer for a given channel instance. Individual substreams may
be flushed by number or using one of the provided macros.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_flush_stderr 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_flush_stderr - convenience macro for \fIlibssh2_channel_flush_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_flush_stderr(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_flush_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_flush_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_flush_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_flush_ex(3)

View File

@ -0,0 +1,20 @@
.TH libssh2_channel_forward_accept 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_forward_accept - accept a queued connection
.SH SYNOPSIS
#include <libssh2.h>
LIBSSH2_CHANNEL *
libssh2_channel_forward_accept(LIBSSH2_LISTENER *listener);
.SH DESCRIPTION
\fIlistener\fP is a forwarding listener instance as returned by
\fBlibssh2_channel_forward_listen_ex(3)\fP.
.SH RETURN VALUE
A newly allocated channel instance or NULL on failure.
.SH ERRORS
When this function returns NULL use \fIlibssh2_session_last_errno(3)\fP to
extract the error code. If that code is \fILIBSSH2_ERROR_EAGAIN\fP, the
session is set to do non-blocking I/O but the call would block.
.SH SEE ALSO
.BR libssh2_channel_forward_listen_ex(3)

View File

@ -0,0 +1,27 @@
.TH libssh2_channel_forward_cancel 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_forward_cancel - cancel a forwarded TCP port
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_forward_cancel(LIBSSH2_LISTENER *listener);
.SH DESCRIPTION
\fIlistener\fP - Forwarding listener instance as returned by
.BR libssh2_channel_forward_listen_ex(3)
Instruct the remote host to stop listening for new connections on a previously requested host/port.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
.SH SEE ALSO
.BR libssh2_channel_forward_listen_ex(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_forward_listen 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_forward_listen - convenience macro for \fIlibssh2_channel_forward_listen_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_forward_listen(LIBSSH2_SESSION *session, int port);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_forward_listen_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_forward_listen_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_forward_listen_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_forward_listen_ex(3)

View File

@ -0,0 +1,46 @@
.TH libssh2_channel_forward_listen_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_forward_listen_ex - listen to inbound connections
.SH SYNOPSIS
#include <libssh2.h>
LIBSSH2_LISTENER *
libssh2_channel_forward_listen_ex(LIBSSH2_SESSION *session, char *host, int port, int *bound_port, int queue_maxsize);
LIBSSH2_LISTENER *
libssh2_channel_forward_listen(LIBSSH2_SESSION *session, int port);
.SH DESCRIPTION
Instruct the remote SSH server to begin listening for inbound TCP/IP
connections. New connections will be queued by the library until accepted by
\fIlibssh2_channel_forward_accept(3)\fP.
\fIsession\fP - instance as returned by libssh2_session_init().
\fIhost\fP - specific address to bind to on the remote host. Binding to
0.0.0.0 (default when NULL is passed) will bind to all available addresses.
\fIport\fP - port to bind to on the remote host. When 0 is passed, the remote
host will select the first available dynamic port.
\fIbound_port\fP - Populated with the actual port bound on the remote
host. Useful when requesting dynamic port numbers.
\fIqueue_maxsize\fP - Maximum number of pending connections to queue before
rejecting further attempts.
\fIlibssh2_channel_forward_listen(3)\fP is a macro.
.SH RETURN VALUE
A newly allocated LIBSSH2_LISTENER instance or NULL on failure.
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
\fILIBSSH2_ERROR_PROTO\fP - An invalid SSH protocol response was received on the socket.
\fILIBSSH2_ERROR_REQUEST_DENIED\fP - The remote server refused the request.
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would block.
.SH SEE ALSO
.BR libssh2_channel_forward_accept(3)

View File

@ -0,0 +1,25 @@
.TH libssh2_channel_free 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_free - free all resources associated with a channel
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_free(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
\fIchannel\fP - Channel stream to free.
Release all resources associated with a channel stream. If the channel has
not yet been closed with
.BR libssh2_channel_close(3)
, it will be called automatically so that the remote end may know that it
can safely free its own resources.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH SEE ALSO
.BR libssh2_channel_close(3)

View File

@ -0,0 +1,34 @@
.TH libssh2_channel_get_exit_signal 3 "4 Oct 2010" "libssh2 1.2.8" "libssh2 manual"
.SH NAME
libssh2_channel_get_exit_signal - get the remote exit signal
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_get_exit_signal(LIBSSH2_CHANNEL *channel, char **exitsignal, size_t *exitsignal_len, char **errmsg, size_t *errmsg_len, char **langtag, size_t *langtag_len);
.SH DESCRIPTION
\fIchannel\fP - Closed channel stream to retrieve exit signal from.
\fIexitsignal\fP - If not NULL, is populated by reference with the exit signal
(without leading "SIG"). Note that the string is stored in a newly allocated
buffer. If the remote program exited cleanly, the referenced string pointer
will be set to NULL.
\fIexitsignal_len\fP - If not NULL, is populated by reference with the length
of exitsignal.
\fIerrmsg\fP - If not NULL, is populated by reference with the error message
(if provided by remote server, if not it will be set to NULL). Note that the
string is stored in a newly allocated buffer.
\fIerrmsg_len\fP - If not NULL, is populated by reference with the length of errmsg.
\fIlangtag\fP - If not NULL, is populated by reference with the language tag
(if provided by remote server, if not it will be set to NULL). Note that the
string is stored in a newly allocated buffer.
\fIlangtag_len\fP - If not NULL, is populated by reference with the length of langtag.
.SH RETURN VALUE
Numeric error code corresponding to the the Error Code constants.

View File

@ -0,0 +1,18 @@
.TH libssh2_channel_get_exit_status 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_get_exit_status - get the remote exit code
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_get_exit_status(LIBSSH2_CHANNEL* channel)
.SH DESCRIPTION
\fIchannel\fP - Closed channel stream to retrieve exit status from.
Returns the exit code raised by the process running on the remote host at
the other end of the named channel. Note that the exit status may not be
available if the remote end has not yet set its status to closed.
.SH RETURN VALUE
Returns 0 on failure, otherwise the \fIExit Status\fP reported by remote host

View File

@ -0,0 +1,35 @@
.TH libssh2_channel_handle_extended_data 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_handle_extended_data - set extended data handling mode
.SH SYNOPSIS
#include <libssh2.h>
void
libssh2_channel_handle_extended_data(LIBSSH2_CHANNEL *channel, int ignore_mode);
.SH DESCRIPTION
This function is deprecated. Use the
\fIlibssh2_channel_handle_extended_data2(3)\fP function instead!
\fIchannel\fP - Active channel stream to change extended data handling on.
\fIignore_mode\fP - One of the three LIBSSH2_CHANNEL_EXTENDED_DATA_* Constants.
.br
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL\fP: Queue extended data for eventual
reading
.br
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_MERGE\fP: Treat extended data and ordinary
data the same. Merge all substreams such that calls to
\fIlibssh2_channel_read(3)\fP will pull from all substreams on a
first-in/first-out basis.
.br
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE\fP: Discard all extended data as it
arrives.
Change how a channel deals with extended data packets. By default all extended
data is queued until read by \fIlibssh2_channel_read_ex(3)\fP
.SH RETURN VALUE
None.
.SH SEE ALSO
.BR libssh2_channel_handle_extended_data2(3)
.BR libssh2_channel_read_ex(3)

View File

@ -0,0 +1,35 @@
.TH libssh2_channel_handle_extended_data2 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_handle_extended_data2 - set extended data handling mode
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_handle_extended_data2(LIBSSH2_CHANNEL *channel, int ignore_mode);
.SH DESCRIPTION
\fIchannel\fP - Active channel stream to change extended data handling on.
\fIignore_mode\fP - One of the three LIBSSH2_CHANNEL_EXTENDED_DATA_* Constants.
.br
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL\fP: Queue extended data for eventual
reading
.br
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_MERGE\fP: Treat extended data and ordinary
data the same. Merge all substreams such that calls to
.BR libssh2_channel_read(3)
will pull from all substreams on a first-in/first-out basis.
.br
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE\fP: Discard all extended data as it
arrives.
Change how a channel deals with extended data packets. By default all
extended data is queued until read by
.BR libssh2_channel_read_ex(3)
.SH RETURN VALUE
Return 0 on success or LIBSSH2_ERROR_EAGAIN when it would otherwise block.
.SH SEE ALSO
.BR libssh2_channel_handle_extended_data(3)
.BR libssh2_channel_read_ex(3)

View File

@ -0,0 +1,20 @@
.TH libssh2_channel_ignore_extended_data 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_ignore_extended_data - convenience macro for \fIlibssh2_channel_handle_extended_data(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
libssh2_channel_ignore_extended_data(arguments)
.SH DESCRIPTION
This function is deprecated. Use the
\fIlibssh2_channel_handle_extended_data2(3)\fP function instead!
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_handle_extended_data(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_handle_extended_data(3)\fP
.SH ERRORS
See \fIlibssh2_channel_handle_extended_data(3)\fP
.SH SEE ALSO
.BR libssh2_channel_handle_extended_data(3)

View File

@ -0,0 +1,54 @@
.TH libssh2_channel_open_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_open_ex - establish a generic session channel
.SH SYNOPSIS
#include <libssh2.h>
LIBSSH2_CHANNEL *
libssh2_channel_open_ex(LIBSSH2_SESSION *session, const char *channel_type, unsigned int channel_type_len, unsigned int window_size, unsigned int packet_size, const char *message, unsigned int message_len);
LIBSSH2_CHANNEL *
libssh2_channel_open_session(session);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init_ex(3)
\fIchannel_type\fP - Channel type to open. Typically one of session,
direct-tcpip, or tcpip-forward. The SSH2 protocol allowed for additional
types including local, custom channel types.
\fIchannel_type_len\fP - Length of channel_type
\fIwindow_size\fP - Maximum amount of unacknowledged data remote host is
allowed to send before receiving an SSH_MSG_CHANNEL_WINDOW_ADJUST packet.
\fIpacket_size\fP - Maximum number of bytes remote host is allowed to send
in a single SSH_MSG_CHANNEL_DATA or SSG_MSG_CHANNEL_EXTENDED_DATA packet.
\fImessage\fP - Additional data as required by the selected channel_type.
\fImessage_len\fP - Length of message parameter.
Allocate a new channel for exchanging data with the server. This method is
typically called through its macroized form:
.BR libssh2_channel_open_session(3)
or via
.BR libssh2_channel_direct_tcpip(3)
or
.BR libssh2_channel_forward_listen(3)
.SH RETURN VALUE
Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors.
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
\fILIBSSH2_ERROR_CHANNEL_FAILURE\fP -
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would block.
.SH SEE ALSO
Add related functions

View File

@ -0,0 +1,18 @@
.TH libssh2_channel_open_session 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_open_session - convenience macro for \fIlibssh2_channel_open_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
LIBSSH2_CHANNEL *
libssh2_channel_open_session(LIBSSH2_SESSION *session);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_open_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_open_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_open_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_open_ex(3)

View File

@ -0,0 +1,38 @@
.TH libssh2_channel_process_startup 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_process_startup - request a shell on a channel
.SH SYNOPSIS
.nf
#include <libssh2.h>
int libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
const char *request,
unsigned int request_len,
const char *message,
unsigned int message_len);
.SH DESCRIPTION
\fIchannel\fP - Active session channel instance.
\fIrequest\fP - Type of process to startup. The SSH2 protocol currently
defines shell, exec, and subsystem as standard process services.
\fIrequest_len\fP - Length of request parameter.
\fImessage\fP - Request specific message data to include.
\fImessage_len\fP - Length of message parameter.
Initiate a request on a session type channel such as returned by
.BR libssh2_channel_open_ex(3)
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
\fILIBSSH2_ERROR_CHANNEL_REQUEST_DENIED\fP -
.SH SEE ALSO
.BR libssh2_channel_open_ex(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_read 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_read - convenience macro for \fIlibssh2_channel_read_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
ssize_t libssh2_channel_read(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_read_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_read_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_read_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_read_ex(3)

View File

@ -0,0 +1,45 @@
.TH libssh2_channel_read_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_read_ex - read data from a channel stream
.SH SYNOPSIS
#include <libssh2.h>
ssize_t
libssh2_channel_read_ex(LIBSSH2_CHANNEL *channel, int stream_id, char *buf, size_t buflen);
ssize_t
libssh2_channel_read(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen);
ssize_t
libssh2_channel_read_stderr(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen);
.SH DESCRIPTION
Attempt to read data from an active channel stream. All channel streams have
one standard I/O substream (stream_id == 0), and may have up to 2^32 extended
data streams as identified by the selected \fIstream_id\fP. The SSH2 protocol
currently defines a stream ID of 1 to be the stderr substream.
\fIchannel\fP - active channel stream to read from.
\fIstream_id\fP - substream ID number (e.g. 0 or SSH_EXTENDED_DATA_STDERR)
\fIbuf\fP - pointer to storage buffer to read data into
\fIbuflen\fP - size of the buf storage
\fIlibssh2_channel_read(3)\fP and \fIlibssh2_channel_read_stderr(3)\fP are
macros.
.SH RETURN VALUE
Actual number of bytes read or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
Note that a return value of zero (0) can in fact be a legitimate value and
only signals that no payload data was read. It is not an error.
.SH ERRORS
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
\fILIBSSH2_ERROR_CHANNEL_CLOSED\fP - The channel has been closed.
.SH SEE ALSO
.BR libssh2_poll_channel_read(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_read_stderr 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_read_stderr - convenience macro for \fIlibssh2_channel_read_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
ssize_t libssh2_channel_read_stderr(LIBSSH2_CHANNEL *channel, char *buf, size_t buflen);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_read_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_read_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_read_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_read_ex(3)

View File

@ -0,0 +1,29 @@
.TH libssh2_channel_receive_window_adjust 3 "15 Mar 2009" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_receive_window_adjust - adjust the channel window
.SH SYNOPSIS
#include <libssh2.h>
unsigned long
libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel,
unsigned long adjustment,
unsigned char force);
.SH DESCRIPTION
This function is deprecated in 1.1. Use
\fIlibssh2_channel_receive_window_adjust2(3)\fP!
Adjust the receive window for a channel by adjustment bytes. If the amount to
be adjusted is less than LIBSSH2_CHANNEL_MINADJUST and force is 0 the
adjustment amount will be queued for a later packet.
.SH RETURN VALUE
Returns the new size of the receive window (as understood by remote end). Note
that the window value sent over the wire is strictly 32bit, but this API is
made to return a 'long' which may not be 32 bit on all platforms.
.SH ERRORS
In 1.0 and earlier, this function returns LIBSSH2_ERROR_EAGAIN for
non-blocking channels where it would otherwise block. However, that is a
negative number and this function only returns an unsigned value and this then
leads to a very strange value being returned.
.SH SEE ALSO
.BR libssh2_channel_window_read_ex(3)

View File

@ -0,0 +1,27 @@
.TH libssh2_channel_receive_window_adjust2 3 "26 Mar 2009" "libssh2 1.1" "libssh2 manual"
.SH NAME
libssh2_channel_receive_window_adjust2 - adjust the channel window
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_receive_window_adjust2(LIBSSH2_CHANNEL * channel,
unsigned long adjustment,
unsigned char force,
unsigned int *window);
.SH DESCRIPTION
Adjust the receive window for a channel by adjustment bytes. If the amount to
be adjusted is less than LIBSSH2_CHANNEL_MINADJUST and force is 0 the
adjustment amount will be queued for a later packet.
This function stores the new size of the receive window (as understood by
remote end) in the variable 'window' points to.
.SH RETURN VALUE
Return 0 on success and a negative value on error. If used in non-blocking
mode it will return LIBSSH2_ERROR_EAGAIN when it would otherwise block.
.SH ERRORS
.SH AVAILABILITY
Added in libssh2 1.1 since the previous API has deficiencies.
.SH SEE ALSO
.BR libssh2_channel_window_read_ex(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_request_pty 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_request_pty - convenience macro for \fIlibssh2_channel_request_pty_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_request_pty(LIBSSH2_SESSION *session, const char *term);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_request_pty_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_request_pty_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_request_pty_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_request_pty_ex(3)

View File

@ -0,0 +1,47 @@
.TH libssh2_channel_request_pty_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_request_pty_ex - short function description
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_request_pty_ex(LIBSSH2_CHANNEL *channel, const char *term, unsigned int term_len, const char *modes, unsigned int modes_len, int width, int height, int width_px, int height_px);
int
libssh2_channel_request_pty(LIBSSH2_CHANNEL *channel, char *term);
.SH DESCRIPTION
\fIchannel\fP - Previously opened channel instance such as returned by
.BR libssh2_channel_open_ex(3)
\fIterm\fP - Terminal emulation (e.g. vt102, ansi, etc...)
\fIterm_len\fP - Length of term parameter
\fImodes\fP - Terminal mode modifier values
\fImodes_len\fP - Length of modes parameter.
\fIwidth\fP - Width of pty in characters
\fIheight\fP - Height of pty in characters
\fIwidth_px\fP - Width of pty in pixels
\fIheight_px\fP - Height of pty in pixels
Request a PTY on an established channel. Note that this does not make sense
for all channel types and may be ignored by the server despite returning
success.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
\fILIBSSH2_ERROR_CHANNEL_REQUEST_DENIED\fP -
.SH SEE ALSO
.BR libssh2_channel_open_ex(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_request_pty_size 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_request_pty_size - convenience macro for \fIlibssh2_channel_request_pty_size_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_request_pty_size(LIBSSH2_CHANNEL *channel, int width, int height);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_request_pty_size_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_request_pty_size_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_request_pty_size_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_request_pty_size_ex(3)

View File

@ -0,0 +1,12 @@
.TH libssh2_channel_request_pty_size_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_request_pty_size_ex - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@ -0,0 +1,24 @@
.TH libssh2_channel_send_eof 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_send_eof - send EOF to remote server
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_send_eof(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
Tell the remote host that no further data will be sent on the specified
channel. Processes typically interpret this as a closed stdin descriptor.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH ERRORS
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
.SH SEE ALSO
.BR libssh2_channel_wait_eof(3)
.BR libssh2_channel_eof(3)

View File

@ -0,0 +1,23 @@
.TH libssh2_channel_set_blocking 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_set_blocking - set or clear blocking mode on channel
.SH SYNOPSIS
#include <libssh2.h>
void
libssh2_channel_set_blocking(LIBSSH2_CHANNEL *channel, int blocking);
.SH DESCRIPTION
\fIchannel\fP - channel stream to set or clean blocking status on.
\fIblocking\fP - Set to a non-zero value to make the channel block, or zero to
make it non-blocking.
Currently this is just a short cut call to
.BR libssh2_session_set_blocking(3)
and therefore will affect the session and all channels.
.SH RETURN VALUE
None
.SH SEE ALSO
.BR libssh2_session_set_blocking(3)
.BR libssh2_channel_read_ex(3)
.BR libssh2_channel_write_ex(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_setenv 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_setenv - convenience macro for \fIlibssh2_channel_setenv_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_setenv(LIBSSH2_CHANNEL *channel, const char *varname, const char *value);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_setenv_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_setenv_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_setenv_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_setenv_ex(3)

View File

@ -0,0 +1,41 @@
.TH libssh2_channel_setenv_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_setenv_ex - set an environment variable on the channel
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_setenv_ex(LIBSSH2_CHANNEL *channel, char *varname, unsigned int varname_len, const char *value, unsigned int value_len);
int
libssh2_channel_setenv(LIBSSH2_CHANNEL *channel, char *varname, const char *value);
.SH DESCRIPTION
\fIchannel\fP - Previously opened channel instance such as returned by
.BR libssh2_channel_open_ex(3)
\fIvarname\fP - Name of environment variable to set on the remote
channel instance.
\fIvarname_len\fP - Length of passed varname parameter.
\fIvalue\fP - Value to set varname to.
\fIvalue_len\fP - Length of value parameter.
Set an environment variable in the remote channel's process space. Note that
this does not make sense for all channel types and may be ignored by the
server despite returning success.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
\fILIBSSH2_ERROR_CHANNEL_REQUEST_DENIED\fP -
.SH SEE ALSO
.BR libssh2_channel_open_ex(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_shell 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_shell - convenience macro for \fIlibssh2_channel_process_startup(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_shell(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_process_startup(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_process_startup(3)\fP
.SH ERRORS
See \fIlibssh2_channel_process_startup(3)\fP
.SH SEE ALSO
.BR libssh2_channel_process_startup(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_subsystem 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_subsystem - convenience macro for \fIlibssh2_channel_process_startup(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_subsystem(LIBSSH2_CHANNEL *channel, const char *subsystem);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_process_startup(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_process_startup(3)\fP
.SH ERRORS
See \fIlibssh2_channel_process_startup(3)\fP
.SH SEE ALSO
.BR libssh2_channel_process_startup(3)

View File

@ -0,0 +1,22 @@
.TH libssh2_channel_wait_closed 3 "29 Nov 2007" "libssh2 0.19" "libssh2 manual"
.SH NAME
libssh2_channel_wait_closed - wait for the remote to close the channel
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_wait_closed(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
Enter a temporary blocking state until the remote host closes the named
channel. Typically sent after \fIlibssh2_channel_close(3)\fP in order to
examine the exit status.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns LIBSSH2_ERROR_EAGAIN
when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is a negative
number, it isn't really a failure per se.
.SH SEE ALSO
.BR libssh2_channel_send_eof(3)
.BR libssh2_channel_eof(3)
.BR libssh2_channel_wait_eof(3)

View File

@ -0,0 +1,19 @@
.TH libssh2_channel_wait_eof 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_wait_eof - wait for the remote to reply to an EOF request
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_wait_eof(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
Wait for the remote end to acknowledge an EOF request.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH SEE ALSO
.BR libssh2_channel_send_eof(3)
.BR libssh2_channel_eof(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_window_read 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_window_read - convenience macro for \fIlibssh2_channel_window_read_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
unsigned long libssh2_channel_window_read(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_window_read_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_window_read_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_window_read_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_window_read_ex(3)

View File

@ -0,0 +1,24 @@
.TH libssh2_channel_window_read_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_window_read_ex - Check the status of the read window
.SH SYNOPSIS
#include <libssh2.h>
unsigned long
libssh2_channel_window_read_ex(LIBSSH2_CHANNEL *channel,
unsigned long *read_avail,
unsigned long *window_size_initial)
.SH DESCRIPTION
Check the status of the read window. Returns the number of bytes which the
remote end may send without overflowing the window limit read_avail (if
passed) will be populated with the number of bytes actually available to be
read window_size_initial (if passed) will be populated with the
window_size_initial as defined by the channel_open request
.SH RETURN VALUE
The number of bytes which the remote end may send without overflowing the
window limit
.SH ERRORS
.SH SEE ALSO
.BR libssh2_channel_receive_window_adjust(3),
.BR libssh2_channel_window_write_ex(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_window_write 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_window_write - convenience macro for \fIlibssh2_channel_window_write_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
unsigned long libssh2_channel_window_write(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_window_write_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_window_write_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_window_write_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_window_write_ex(3)

View File

@ -0,0 +1,21 @@
.TH libssh2_channel_window_write_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_window_write_ex - Check the status of the write window
.SH SYNOPSIS
#include <libssh2.h>
unsigned long
libssh2_channel_window_write_ex(LIBSSH2_CHANNEL *channel,
unsigned long *window_size_initial)
.SH DESCRIPTION
Check the status of the write window Returns the number of bytes which may be
safely written on the channel without blocking. 'window_size_initial' (if
passed) will be populated with the size of the initial window as defined by
the channel_open request
.SH RETURN VALUE
Number of bytes which may be safely written on the channel without blocking.
.SH ERRORS
.SH SEE ALSO
.BR libssh2_channel_window_read_ex(3),
.BR libssh2_channel_receive_window_adjust(3)

View File

@ -0,0 +1,18 @@
.TH libssh2_channel_write 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_write - convenience macro for \fIlibssh2_channel_write_ex(3)\fP
.SH SYNOPSIS
.nf
#include <libssh2.h>
ssize_t libssh2_channel_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t buflen);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_write_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_write_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_write_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_write_ex(3)

View File

@ -0,0 +1,47 @@
.TH libssh2_channel_write_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_write_ex - write data to a channel stream blocking
.SH SYNOPSIS
.nf
#include <libssh2.h>
ssize_t libssh2_channel_write_ex(LIBSSH2_CHANNEL *channel,
int stream_id, char *buf,
size_t buflen);
.SH DESCRIPTION
Write data to a channel stream. All channel streams have one standard I/O
substream (stream_id == 0), and may have up to 2^32 extended data streams as
identified by the selected \fIstream_id\fP. The SSH2 protocol currently
defines a stream ID of 1 to be the stderr substream.
\fIchannel\fP - active channel stream to write to.
\fIstream_id\fP - substream ID number (e.g. 0 or SSH_EXTENDED_DATA_STDERR)
\fIbuf\fP - pointer to buffer to write
\fIbuflen\fP - size of the data to write
\fIlibssh2_channel_write(3)\fP and \fIlibssh2_channel_write_stderr(3)\fP are
convenience macros for this function.
\fIlibssh2_channel_write_ex(3)\fP will use as much as possible of the buffer
and put it into a single SSH protocol packet. This means that to get maximum
performance when sending larger files, you should try to always pass in at
least 32K of data to this function.
.SH RETURN VALUE
Actual number of bytes written or negative on failure.
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
\fILIBSSH2_ERROR_CHANNEL_CLOSED\fP - The channel has been closed.
\fILIBSSH2_ERROR_CHANNEL_EOF_SENT\fP - The channel has been requested to be
closed.
.SH SEE ALSO
.BR libssh2_channel_open_ex(3)
.BR libssh2_channel_read_ex(3)

View File

@ -0,0 +1,18 @@
.TH libssh2_channel_write_stderr 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_write_stderr - convenience macro for \fIlibssh2_channel_write_ex(3)\fP
.SH SYNOPSIS
.nf
#include <libssh2.h>
ssize_t libssh2_channel_write_stderr(LIBSSH2_CHANNEL *channel, const char *buf, size_t buflen);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_write_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_write_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_write_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_write_ex(3)

View File

@ -0,0 +1,17 @@
.TH libssh2_channel_x11_req 3 "20 Feb 2010" "libssh2 1.2.4" "libssh2 manual"
.SH NAME
libssh2_channel_x11_req - convenience macro for \fIlibssh2_channel_x11_req_ex(3)\fP calls
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_channel_x11_req(LIBSSH2_CHANNEL *channel, int screen_number);
.SH DESCRIPTION
This is a macro defined in a public libssh2 header file that is using the
underlying function \fIlibssh2_channel_x11_req_ex(3)\fP.
.SH RETURN VALUE
See \fIlibssh2_channel_x11_req_ex(3)\fP
.SH ERRORS
See \fIlibssh2_channel_x11_req_ex(3)\fP
.SH SEE ALSO
.BR libssh2_channel_x11_req_ex(3)

View File

@ -0,0 +1,44 @@
.TH libssh2_channel_x11_req_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_x11_req_ex - request an X11 forwarding channel
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_x11_req_ex(LIBSSH2_CHANNEL *channel, int single_connection, const char *auth_proto, const char *auth_cookie, int screen_number);
int
libssh2_channel_x11_req(LIBSSH2_CHANNEL *channel, int screen_number);
.SH DESCRIPTION
\fIchannel\fP - Previously opened channel instance such as returned by
.BR libssh2_channel_open_ex(3)
\fIsingle_connection\fP - non-zero to only forward a single connection.
\fIauth_proto\fP - X11 authentication protocol to use
\fIauth_cookie\fP - the cookie (hexadecimal encoded).
\fIscreen_number\fP - the XLL screen to forward
Request an X11 forwarding on \fIchannel\fP. To use X11 forwarding,
.BR libssh2_session_callback_set(3)
must first be called to set \fBLIBSSH2_CALLBACK_X11\fP. This callback will be
invoked when the remote host accepts the X11 forwarding.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH ERRORS
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
\fILIBSSH2_ERROR_CHANNEL_REQUEST_DENIED\fP -
.SH SEE ALSO
.BR libssh2_channel_open_ex(3)
.BR libssh2_session_callback_set(3)

14
docs/libssh2_exit.3 Normal file
View File

@ -0,0 +1,14 @@
.TH libssh2_exit 3 "19 Mar 2010" "libssh2 1.2.5" "libssh2 manual"
.SH NAME
libssh2_exit - global library deinitialization
.SH SYNOPSIS
#include <libssh2.h>
void
libssh2_exit(void);
.SH DESCRIPTION
Exit the libssh2 functions and free's all memory used internal.
.SH AVAILABILITY
Added in libssh2 1.2.5
.SH SEE ALSO
.BR libssh2_init(3)

Some files were not shown because too many files have changed in this diff Show More