Compare commits

...

1098 Commits

Author SHA1 Message Date
Andreas Schneider
c4d1d8b684 build: Increase version numbers. 2010-07-13 10:15:22 +02:00
Andreas Schneider
10e27f26be build: Updated ChangeLog. 2010-07-12 09:48:22 +02:00
Andreas Schneider
9791bc3eeb poll: Added poll constants for Windows.
WSAPoll uses different constanst values as the POSIX implementation,
what else ...
2010-07-09 09:46:57 +02:00
Andreas Schneider
4ad7828797 options: Added option to bind a client to an ip address.
Thanks to Donatello Boccaforno <donatello.boccaforno@gmail.com>.
2010-07-07 12:40:49 +02:00
Aris Adamantiadis
af8315b9ce Fixed ssh_socket_poll behaviour 2010-07-07 10:00:09 +02:00
Andreas Schneider
94fdcf7a2a socket: Fixed ssh_socket_poll().
If we don't have date to read or write, leave ssh_socket_poll().
2010-07-06 23:18:16 +02:00
Andreas Schneider
59a95fc3a7 poll: FD_SETSIZE is only for the count value of FD_SET on Windows. 2010-07-06 00:40:19 +02:00
Andreas Schneider
c1729c36d9 socket: Fixed a prototype. 2010-06-25 16:20:38 +02:00
Andreas Schneider
23efab0f8f socket: Fixed conflicting types. 2010-06-24 20:05:10 +02:00
Andreas Schneider
e50752a925 poll: Another attempt to get bsd_poll() working correctly. 2010-06-24 09:17:39 +02:00
Andreas Schneider
fd45c1b36b poll: Fixed building with poll-emulation on UNIX. 2010-06-24 09:16:58 +02:00
Andreas Schneider
5080671581 agent: Use the our poll typedef. 2010-06-24 09:14:07 +02:00
Andreas Schneider
e67fafd60f poll: Added a comment to the bsd_poll() implementation. 2010-06-22 14:45:08 +02:00
Andreas Schneider
a2a98fb5bc poll: Handle FD_SETSIZE in bsd_poll(). 2010-06-22 14:44:54 +02:00
Andreas Schneider
e2480fbaba poll: Fixed a comparsion. 2010-06-22 14:43:09 +02:00
Andreas Schneider
23e6b36209 poll: Fixed a typo. 2010-06-21 15:41:58 +02:00
Andreas Schneider
541b38b772 poll: Check if maxfd has been set. 2010-06-20 21:16:29 +02:00
Andreas Schneider
a85a4cc192 connect: Fixed some socket build warnings on windows. 2010-06-18 12:43:12 +02:00
Andreas Schneider
54ef77123a server: Fixed types and checks of fd's. 2010-06-17 13:36:14 +02:00
Andreas Schneider
4c679fd8a6 poll: Fixed type of the fd variables and use SSH_INVALID_SOCKET. 2010-06-17 13:35:40 +02:00
Andreas Schneider
21d918c68a client: Fixed fd type and checks. 2010-06-17 13:33:52 +02:00
Andreas Schneider
544fc28e6b channel: Fixed the type of the max fd variable in ssh_channel_select(). 2010-06-17 13:32:14 +02:00
Andreas Schneider
601081ebb6 agent: Use ssh_poll in agent code. 2010-06-17 13:31:35 +02:00
Andreas Schneider
22d975a24b socket: Fixed checks for max fd. 2010-06-17 13:18:23 +02:00
Andreas Schneider
aeb9f3e389 poll: Fixed brackets. 2010-06-17 12:02:06 +02:00
Andreas Schneider
d3a4e01137 poll: Fixed another wrong invalid fd check in bsd_poll. 2010-06-17 11:49:28 +02:00
Andreas Schneider
a1b9ae5048 poll: Some code cleanup for easier debugging. 2010-06-17 11:23:58 +02:00
Andreas Schneider
a375ebe29b poll: Fixed a malfunction with wrong max fd value check. 2010-06-17 11:23:50 +02:00
Andreas Schneider
b2f49a6a93 config: Use ssh log and error functions for problems. 2010-06-03 16:46:17 +02:00
Andreas Schneider
99fb5987ce socket: Fixed signed values which could be seen as an unary operator. 2010-06-02 10:14:53 +02:00
Andreas Schneider
be389dd644 socket: According to execle(2) environ shouldn't be const. 2010-06-01 21:47:15 +02:00
Andreas Schneider
a6a7922dbd Update Changelog. 2010-05-31 19:36:32 +02:00
Aris Adamantiadis
608e81bc00 Fix warning for snprintf 2010-05-31 11:52:36 +03:00
Aris Adamantiadis
7e17838c0b Fix unclean null termination in ~ expending 2010-05-31 11:50:52 +03:00
Andreas Schneider
84f6945a9c Increased version numbers. 2010-05-30 11:26:11 +02:00
Andreas Schneider
3ae187dbe7 misc: Make sure the expanded string is null-terminated. 2010-05-30 11:00:38 +02:00
Andreas Schneider
26989ab001 session: Fixed setting up default identity files. 2010-05-28 10:47:37 +02:00
Andreas Schneider
5b2e39cd79 options: Make sure that we have always have default options set. 2010-05-21 10:21:03 +02:00
Andreas Schneider
13af149ef9 options: Set the local username if still not set. 2010-05-21 10:19:06 +02:00
Andreas Schneider
3453cafd95 keyfiles: Fixed possible problem with known_hosts path. 2010-05-21 10:03:13 +02:00
Andreas Schneider
fa65fd3dd1 cmake: Fixed doxygen. 2010-05-18 00:32:43 +02:00
Andreas Schneider
ec5fa5cc06 doxygen: Fixed latex pdf generation. 2010-05-18 00:08:01 +02:00
Andreas Schneider
8577688174 Updated changelog file. 2010-05-17 23:41:15 +02:00
Andreas Schneider
31462a4d72 sftp: Fixed sftp_chown. 2010-05-17 23:38:21 +02:00
Aris Adamantiadis
fd2ff2d29c Fix sftp_rename on sftp3 2010-05-17 20:05:22 +02:00
Aris Adamantiadis
0b09bd900f Typos in last patch 2010-05-14 12:49:24 +02:00
Aris Adamantiadis
abc61fa1cc Fix build on VC7 2010-05-14 12:46:17 +02:00
Aris Adamantiadis
e94bff02ba Respond to keepalives/global requests 2010-05-12 21:58:09 +02:00
Andreas Schneider
3671c61023 build: Fixed build.
I've added a non-existent kex header, sorry.
2010-05-12 19:36:40 +02:00
Andreas Schneider
2702f3ea3f Fixed building libssh with DEBUG_CRYPTO. 2010-05-12 19:25:34 +02:00
Andreas Schneider
4abd0522b4 Increment version and soversion numbers. 2010-05-12 19:00:07 +02:00
Andreas Schneider
62b6eb4436 Updated ChangeLog entries for 0.4.3. 2010-05-12 18:59:29 +02:00
Andreas Schneider
4b7eba1eda Added runtime detection of WSAPoll().
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2010-05-12 18:44:09 +02:00
Andreas Schneider
9970b1fd7d Added the possibility to define _OPENSSL_DIR and _ZLIB_DIR. 2010-05-12 13:57:54 +02:00
Andreas Schneider
d703f51861 Fixed windows include files in pcap support. 2010-05-12 13:39:00 +02:00
Andreas Schneider
a009702cd6 Fixed Windows build warnings. 2010-05-12 13:11:33 +02:00
Andreas Schneider
ed268e5948 Fixed Windows build. 2010-05-12 13:11:33 +02:00
Andreas Schneider
10b4654ad5 Added a select(2) based poll-emulation if poll(2) is not available. 2010-05-12 13:11:33 +02:00
Andreas Schneider
9d7fc9d50b Use the new expand functions.
This implements escape chars for IdentityFile in ssh_config and reads
the system ssh_config.
2010-05-11 09:52:06 +02:00
Andreas Schneider
b8bc3a6582 Added a function to expand an escaped string. 2010-05-11 09:44:29 +02:00
Andreas Schneider
07e8d8f1f2 Added a function to expand the tilde from a path. 2010-05-11 09:44:13 +02:00
Aris Adamantiadis
34a927716a Added code to test proxycommand 2010-05-10 22:40:28 +02:00
Aris Adamantiadis
bae4090715 Backport of the proxycommand feature 2010-05-10 22:32:52 +02:00
Andreas Schneider
403ded1e97 Use configure checks to define vsnprintf and strncpy. 2010-05-10 15:53:57 +02:00
Andreas Schneider
6fd8de3376 Added configure checks for _vsnprintf_s and strncpy. 2010-05-10 15:53:46 +02:00
Andreas Schneider
5fe99f8b09 Fixed building libssh with VC9. 2010-05-10 14:41:20 +02:00
Patrick Spendrin
af155db080 Move ssh_hostport to a location which is global accessible.
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2010-05-10 10:48:13 +02:00
Patrick Spendrin
df5a94d445 The lower function doesn't have the prefix.
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2010-05-10 10:48:03 +02:00
Andreas Schneider
4bfe7f024c Added more defines to use secure VC functions. 2010-05-10 10:45:51 +02:00
Aris Adamantiadis
99ea177eea oops, this file was not intended to be commited 2010-05-07 13:03:35 +02:00
Aris Adamantiadis
476630841f Match hashed [host]:port format knownhosts 2010-05-07 13:02:28 +02:00
Aris Adamantiadis
7f59662cad knownhosts writing cherry-pick
Conflicts:

	libssh/keyfiles.c
	tests/unittests/CMakeLists.txt
2010-05-07 12:58:56 +02:00
Aris Adamantiadis
e9d6b15926 First implementation of known_hosts with port read
Conflicts:

	include/libssh/misc.h
	libssh/keyfiles.c
	libssh/misc.c
2010-05-07 12:55:33 +02:00
Aris Adamantiadis
6885d32c05 Added ssh_privatekey_type public function 2010-04-28 11:51:02 +02:00
Aris Adamantiadis
e5c2af6316 Fix doublefree happening after a negociation error 2010-04-14 20:56:22 +02:00
Aris Adamantiadis
08a1bebb58 Do not compile aes*-ctr with <=OpenSSL 0.9.7b 2010-04-14 20:43:06 +02:00
Aris Adamantiadis
6195b133bf Fix missing string_data() in crypto debug code 2010-04-14 18:24:23 +02:00
Aris Adamantiadis
6e65abbe63 Fix vsnprintf symbol on older VS2003 compiler 2010-04-06 22:58:43 +02:00
Aris Adamantiadis
bda836d744 Fix building on win32/vs7 2010-04-06 22:23:43 +02:00
Andreas Schneider
c8c2647555 Fixed a typo. 2010-04-04 15:55:49 +02:00
Andreas Schneider
4ad74765f6 Removed the unneeded dependency to doxygen. 2010-04-04 15:00:59 +02:00
Andreas Schneider
b1f93f600e Fixed documentation of ssh_bind_options_set. 2010-04-04 14:07:54 +02:00
Andreas Schneider
28edbe1ef5 Added an improved version of UseDoxygen.cmake which handles trac doc. 2010-04-04 14:07:43 +02:00
Andreas Schneider
75cf66a3ee Added a doxygen configuration for trac. 2010-04-04 14:04:38 +02:00
Andreas Schneider
5021ed3074 Fixed config parsing wich has overwritten user specified values. 2010-04-04 14:02:09 +02:00
Andreas Schneider
3773366a25 Fixed blocking bug in channel_poll.
This is a backport from 514ab6eed2.
2010-04-03 23:29:01 +02:00
Aris Adamantiadis
c6fab4bf84 Fix openssl detection in cmake 2010-03-29 23:06:20 +02:00
Aris Adamantiadis
7d1dcb0dff Fix file inclusion with VS2003 2010-03-29 22:23:47 +02:00
Aris Adamantiadis
d7c1384df0 Fix exec example which has broken read usage 2010-03-28 21:49:17 +02:00
Aris Adamantiadis
d2bb97c1c6 Fixes the broken algorithm choice for server 2010-03-28 21:43:13 +02:00
Aris Adamantiadis
3b6098597d Fix crash when no callback is defined 2010-03-28 21:19:12 +02:00
Andreas Schneider
964d8fdc11 Fixed build warnings on Windows. 2010-03-25 16:47:45 +01:00
Andreas Schneider
5d339aa9e2 Fixed a build warning in ssh_userauth_autopubkey. 2010-03-25 15:32:28 +01:00
Andreas Schneider
af7f69c515 Fixed spelling. 2010-03-25 13:55:50 +01:00
Andreas Schneider
ea92d5b230 Added comments to the so version to increment it correctly in future. 2010-03-25 13:24:59 +01:00
Andreas Schneider
f096e031ed Fixed a typo that we don't export all symbols. 2010-03-25 09:52:05 +01:00
Andreas Schneider
a8be476ea9 Build examples only on the Linux plattform. 2010-03-17 10:09:38 +01:00
Andreas Schneider
b9f65b5740 Added changelog entries for version 0.4.2. 2010-03-15 19:33:49 +01:00
Andreas Schneider
99a58eb325 Increase version number to 0.4.2. 2010-03-15 19:33:11 +01:00
Andreas Schneider
ed1cba705c Fixed a memory leak in ssh_try_publickey_from_file. 2010-03-13 15:00:19 +01:00
Andreas Schneider
0b13a6d265 Added missing SSH_OPTIONS_FD option. 2010-03-13 14:21:57 +01:00
Andreas Schneider
74c0201219 Remove support for SSHv1 Cipher variable. 2010-03-13 13:09:23 +01:00
Andreas Schneider
83c51d1c13 Fixed and added support for several identity files. 2010-03-06 12:33:27 +01:00
Andreas Schneider
c712d30311 Rename ssh_list_add to ssh_list_append. 2010-03-06 12:29:03 +01:00
Andreas Schneider
2144049c7d Added a prepend function for ssh_list. 2010-03-06 12:29:03 +01:00
Aris Adamantiadis
9dd86859e8 renamed ssh_list_get_head to ssh_list_pop_head 2010-03-06 12:28:56 +01:00
Andreas Schneider
810fbfb620 Fixed sftp_parse_longname() on Windows.
There is no strndup function on Windows.
2010-03-02 14:16:21 +01:00
Aris Adamantiadis
370d072eba Fix a race condition bug in ssh_scp_close() 2010-03-01 20:00:29 +01:00
Aris Adamantiadis
56dfa69fc9 Send back replies to openssh's keepalives 2010-03-01 18:41:59 +01:00
Aris Adamantiadis
672f8412f0 Fixed documentation in scp code 2010-02-26 18:49:15 +01:00
Andreas Schneider
83ff1ffcc3 Added printout of owner and group in the sftp example. 2010-02-24 00:26:20 +01:00
Andreas Schneider
fb35153b49 Fixed longname parsing, this only workings with readdir. 2010-02-24 00:25:38 +01:00
Andreas Schneider
7539200773 Added owner and group information in sftp attributes.
Parse the longname which is the output of 'ls -l' and set the owner and
group if we are talking to an openssh server.
2010-02-23 22:52:56 +01:00
Andreas Schneider
254a166c02 Don't add the tests directory to the build. 2010-02-13 13:13:20 +01:00
Andreas Schneider
3e938cb901 Added ChangeLog entries for 0.4.1. 2010-02-13 13:00:10 +01:00
Andreas Schneider
452b16ede2 Set CFLAGS correctly. 2010-02-13 13:00:10 +01:00
Aris Adamantiadis
bd47ff75ba Fix compilation of opensolaris 2010-02-12 10:08:22 +01:00
Andreas Schneider
0016ded7f9 Try zlib compression and fallback to none if not available. 2010-02-11 23:28:37 +01:00
Aris Adamantiadis
d725b31752 Use closesocket in server.c for win32
Resolves #56
2010-02-11 19:54:57 +01:00
Aris Adamantiadis
c2e86c876c aes128-ctr aes192-ctr aes256-ctr for libgcrypt 2010-02-09 22:43:37 +01:00
Aris Adamantiadis
028516ba6a aes192-ctr and aes256-ctr working on libcrypto 2010-02-09 22:43:27 +01:00
Aris Adamantiadis
344b27ac6c Added aes128-ctr support for libcrypto (openssl) 2010-02-09 22:43:13 +01:00
Aris Adamantiadis
a700259b01 KEX bug: client preference should be prioritary 2010-02-09 22:42:53 +01:00
Andreas Schneider
14da14db05 Respect known_hosts file set by the user.
Thanks to contact@leblanc-simon.eu for the patch.
2010-02-07 22:39:35 +01:00
Vic Lee
474d63f24e The ssh_message object needs to be freed after processing in channel_accept().
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2010-02-01 17:24:50 +01:00
Andreas Schneider
b3589fbf6c Increased version number. 2010-01-29 18:59:55 +01:00
Aris Adamantiadis
dd68bae776 Fix underflow when leave_function() are unbalanced 2010-01-29 18:54:48 +01:00
Vic Lee
4768cf3e85 In handle_channel_request_open(), variable type is freed too early and cause memory corruptions.
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2010-01-29 18:51:50 +01:00
Vic Lee
5a95681f01 File handle need to be closed in case of errors in privatekey_from_file
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-12-23 09:37:59 +01:00
Andreas Schneider
13a3619102 Added an example for exec. 2009-12-22 18:33:16 +01:00
Vic Lee
c7636edf84 Added private key type detection feature in privatekey_from_file
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-12-22 08:58:05 +01:00
Andreas Schneider
27e332b623 Fixed ssh_get_user_home_dir() to be thread safe. 2009-12-21 12:33:44 +01:00
Andreas Schneider
ebc8544c56 Improved doxygen output of ssh_options_set(). 2009-12-19 00:11:37 +01:00
Andreas Schneider
0f8e9b839c Disabled caller graphs as they are only of internal interest. 2009-12-18 23:55:17 +01:00
Andreas Schneider
0c02d6effe Updated the doxygen file. 2009-12-18 23:49:56 +01:00
Andreas Schneider
7199b196b0 Fixed documentation of buffer struct. 2009-12-18 23:45:34 +01:00
Andreas Schneider
ca83b66066 Fixed documentation of ssh_options_copy(). 2009-12-18 23:45:24 +01:00
Andreas Schneider
d978f9b58a Moved the doxygen mainpage to doc/mainpage.dox 2009-12-18 23:45:09 +01:00
Andreas Schneider
e539eaf9e0 Added a mainpage to doxygen. 2009-12-18 23:11:25 +01:00
Andreas Schneider
b728f44ce9 Fixed the doxygen documentation. 2009-12-18 23:05:03 +01:00
Andreas Schneider
2f0b671a61 Update version to 0.4.0. 2009-12-10 14:15:04 +01:00
Andreas Schneider
1fadec37d6 Don't install crypto.h which is an internal header file. 2009-12-10 13:55:07 +01:00
Andreas Schneider
2aabbd6245 Remove socklen_t definition.
Tthe problem is that winsock2.h defines socklen_t as a typedef, not as a
define, so depending on the order of includes you can get errors in
ws2tcpip.h with msvc.
2009-12-09 13:04:26 +01:00
Aris Adamantiadis
fd6823691b Fix stupid bug which stops log_verbosity working 2009-12-02 14:19:42 +01:00
Andreas Schneider
b174ad8ae4 Fixed indent. 2009-12-02 00:23:27 +01:00
Andreas Schneider
176778bb1c Added gettimeofday for Windows.
Thanks to Patrick Spendrin.
2009-12-02 00:23:20 +01:00
Andreas Schneider
e5bf645010 Fixed uint* to work on Windows.
Thanks to Patrick Spendrin.
2009-12-02 00:23:00 +01:00
Andreas Schneider
d1c6fa9261 Build the pcap source only if enabled. 2009-11-19 09:33:06 +01:00
Aris Adamantiadis
b00e2ad40e Fix compile bug introduced by another bugfix 2009-11-18 20:54:39 +01:00
Aris Adamantiadis
ca9f42a20f Fix another memleak
Use buffer_free instead of SAFE_FREE
2009-11-18 20:53:06 +01:00
Andreas Schneider
e939786836 Fixed possible doulbe free problem found by Bernhard R. Link. 2009-11-18 15:35:15 +01:00
Andreas Schneider
11cc5f5815 Added more error messages and checking to handle_channel_request. 2009-11-18 14:56:12 +01:00
Andreas Schneider
d60b1ec1a2 Fixed a memory leak in channel_new() if we have an error. 2009-11-18 10:30:01 +01:00
Aris Adamantiadis
ae11589205 Pcap: more cleanup and minimalist API 2009-11-16 23:20:16 +01:00
Aris Adamantiadis
70b9475449 Pcap: Fix bug with non-encrypted incoming packets 2009-11-16 22:53:22 +01:00
Aris Adamantiadis
02aecc1278 Improved pcap dumping support 2009-11-16 22:36:31 +01:00
Andreas Schneider
3e90a11599 Improve standard logging. 2009-11-12 12:52:05 +01:00
Andreas Schneider
b4095189d7 Fixed setting the timeout and ssh2 and ssh1 option. 2009-11-12 12:50:31 +01:00
Andreas Schneider
c0b4c4d60c Fixed setting the log verbosity. 2009-11-12 11:44:36 +01:00
Andreas Schneider
12da24c056 Added an option to set log verbosity as string. 2009-11-10 09:12:07 +01:00
Andreas Schneider
d821117033 Always use the poll-emulation on Windows.
Until we we have a solution to use WSAPoll only on Vista and newer.
2009-11-09 20:13:27 +01:00
Aris Adamantiadis
30266f7627 Added explanation in ssh_silent_disconnect doxygen 2009-11-09 13:24:47 +01:00
Aris Adamantiadis
10b625e180 First lines of experimental pcap output support
This will serve to debug packets right under wireshark !
2009-11-08 23:42:41 +01:00
Aris Adamantiadis
10f27457d3 Add an other (simplier ?) polling method to sample 2009-11-08 20:00:23 +01:00
Aris Adamantiadis
af1f431364 change buffer size in sample.c 2009-11-07 17:35:24 +01:00
Aris Adamantiadis
272a4d1e45 Refactorize sample.c 2009-11-07 17:23:06 +01:00
Aris Adamantiadis
3a95ecfe74 move authentication out of sampe.c 2009-11-07 03:45:27 +01:00
Aris Adamantiadis
14ae9a7f0c Moved sftp parts into a new example 2009-11-06 19:21:18 +01:00
Aris Adamantiadis
51f1918109 Update structures name to new convention
SSH_POLL* -> ssh_poll_handle,
SSH_POLL_CTX* -> ssh_poll_ctx
2009-11-06 18:52:49 +01:00
Andreas Schneider
fa27956daf Improve MSVC support. Better binary compatibility.
Patch by Patrick Spendrin from KDE.
2009-11-06 09:57:09 +01:00
Aris Adamantiadis
ab0d8a3828 A few test cases for benchmarks 2009-11-05 18:18:35 +01:00
Andreas Schneider
efded18724 Fixed compilation of samplesshd. 2009-11-05 16:38:05 +01:00
Andreas Schneider
f52bc064e9 Merge branch 'master' of git://git.libssh.org/projects/libssh/libssh 2009-11-05 16:08:49 +01:00
Aris Adamantiadis
75f066dfcd channel_read() won't block until count b. are read 2009-11-05 16:00:05 +01:00
Aris Adamantiadis
535ff07f0f Forgot to update config.h.cmake 2009-11-05 13:09:42 +01:00
Aris Adamantiadis
5e002635fc Fix compilation on freebsd 6.0 which lacks argp.h 2009-11-03 21:04:36 +01:00
Aris Adamantiadis
e71c28f6a0 Fix warnings on old gcc's
they don't like variable names having type names
2009-11-03 21:04:07 +01:00
Aris Adamantiadis
c0e091a52f Fix openssl header inclusion
caused cbc_encrypt to be redefined by an openssl
macro
2009-11-03 21:03:22 +01:00
Andreas Schneider
8ab0f8e51f Increase package version. 2009-10-29 20:22:05 +01:00
Andreas Schneider
cce34a6176 Fixed setting knownhosts in ssh_is_server_known(). 2009-10-29 12:10:44 +01:00
Andreas Schneider
89f0311927 Fixed a segfault on Windows. 2009-10-29 12:10:22 +01:00
Aris Adamantiadis
e455f6f756 Make libssh_scp a little more consistant 2009-10-29 10:50:47 +01:00
Aris Adamantiadis
17f2645a32 Fix server kex again 2009-10-29 10:36:00 +01:00
Aris Adamantiadis
9f034aca9c Fix server kex 2009-10-29 10:02:49 +01:00
Bernhard R. Link
22bdfa3886 improve error reporting of sftp.c
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-10-25 11:12:02 +01:00
Bernhard R. Link
ef8246a592 buffer_get_data returns 0 on error, so checking buffer_get_u* for < 0 makes no sense
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-10-25 09:50:06 +01:00
Aris Adamantiadis
110d201e02 fix stupid bug 2009-10-23 12:48:40 +02:00
Aris Adamantiadis
be4f695c5c Compatibility with (broken) sftp version 2 protocols 2009-10-23 12:19:22 +02:00
Andreas Schneider
792def7a65 Add missing free. 2009-10-23 11:45:44 +02:00
Andreas Schneider
840cecbe0e Fix memory leaks in ssh_bind_options_set() if called twice.
This fixes ticket #36.
2009-10-22 18:56:02 +02:00
Aris Adamantiadis
27d25752e9 Allow use of SSH_DIR/ when expanding key paths 2009-10-17 18:10:42 +02:00
Aris Adamantiadis
a479b30298 Verify existence of callback before using them 2009-10-17 17:54:39 +02:00
Andreas Schneider
86620fc991 Improve example authentication. 2009-10-15 17:56:03 +02:00
Andreas Schneider
b3dfd5cffc Added missing documentation for ssh_bind_options_set. 2009-10-15 17:22:04 +02:00
Andreas Schneider
f0858ff6b2 Added option parsing using GNU argp. 2009-10-15 17:17:58 +02:00
Andreas Schneider
7b7280e728 Added option to set log_verbosity in the server. 2009-10-15 17:17:36 +02:00
Andreas Schneider
2523ed0779 Added an option to set the port as string. 2009-10-15 17:02:51 +02:00
Andreas Schneider
e736b1a40e Fixed ssh_get_user_home_dir on Windows. 2009-10-15 16:37:07 +02:00
Andreas Schneider
cbf012c337 Fixed ssh_get_home_dir and ssh dir to be more portable on UNIX systems.
Thanks to Pino Toscano.
2009-10-15 14:53:11 +02:00
Andreas Schneider
c360ed1d9a Add API changes to README. 2009-10-13 22:23:06 +02:00
Andreas Schneider
22e74e3bab Remove deprecated functions. 2009-10-13 22:14:23 +02:00
Vic Lee
02b3104215 Fix a memory corruption in parse_status_msg
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-10-11 11:11:08 +02:00
Aris Adamantiadis
26a5294116 add logging 2009-10-11 00:20:37 +02:00
Aris Adamantiadis
5e4c78e114 Fix server. Now, it runs 2009-10-11 00:14:21 +02:00
Aris Adamantiadis
e74305c5eb updated the sftp subsystem to follow the type conv 2009-10-10 20:55:17 +02:00
Aris Adamantiadis
499f9aa707 Add structure cleaning in comment 2009-10-10 20:07:52 +02:00
Andreas Schneider
4dee9a3e68 Document the function to set the callbacks and provide an example. 2009-10-10 19:59:14 +02:00
Aris Adamantiadis
399041180f resolve callback crash 2009-10-10 16:25:40 +02:00
Aris Adamantiadis
3f55fb5b22 fix typo in header inclusion 2009-10-10 12:04:35 +02:00
Aris Adamantiadis
37a4a65d60 Add ssh_free at the end 2009-10-10 12:04:16 +02:00
Andreas Schneider
ccd886feb4 Added auth callback function to sample to test callback stuff. 2009-10-10 11:55:42 +02:00
Andreas Schneider
b1bc283e9a Rename callback header file. 2009-10-10 10:52:04 +02:00
Andreas Schneider
be75fac7ff Add a function to set the callback structure to the session. 2009-10-10 10:51:56 +02:00
Aris Adamantiadis
6ec65c6f9d ssh_disconnect doesn't free the session anymore 2009-10-09 22:50:48 +02:00
Aris Adamantiadis
71ab0cf6cc No more SSH_BIND SSH_MESSAGE etc. 2009-10-09 22:37:23 +02:00
Aris Adamantiadis
1e0e8a5493 samplessh uses ssh_options_getopt() 2009-10-09 22:28:03 +02:00
Aris Adamantiadis
4b65aea401 Last nail on SSH_OPTIONS, SSH_SESSION etc. 2009-10-09 22:26:08 +02:00
Aris Adamantiadis
98ff6fbbce get rid of the option structure 2009-10-09 22:24:23 +02:00
Aris Adamantiadis
43e0d73b63 sample.c compiles now 2009-10-09 22:04:56 +02:00
Aris Adamantiadis
58294442d3 Moved samples into examples directory 2009-10-09 21:44:05 +02:00
Aris Adamantiadis
2e9c13dad0 Modified server API 2009-10-09 21:26:15 +02:00
Andreas Schneider
9c667ebc26 Remove functions to set callbacks. 2009-10-09 15:18:06 +02:00
Andreas Schneider
d1b772f1bc Added more error messages to config parser. 2009-10-06 15:49:47 +02:00
Andreas Schneider
876f843f23 Update ChangeLog. 2009-10-06 15:44:12 +02:00
Andreas Schneider
0e2e0983f3 Fixed build temporarily. 2009-10-05 10:41:00 +02:00
Vic Lee
6063a8d09c Fix a segment fault in privatekey_from_file
Signed-off-by: Vic Lee <llyzs@163.com>
2009-10-05 10:02:04 +02:00
Aris Adamantiadis
40778d4ba9 Merge branch 'master' of git://git.libssh.org/projects/libssh/libssh 2009-10-05 10:01:24 +02:00
Bernhard R. Link
60d6954b75 samplesshd: allow overriding KEYS_FOLDER by compiler option
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-10-05 00:05:09 +02:00
Bernhard R. Link
bf376b6d4f do not segfault in ssh_bind_accept if bindaddr is NULL
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-10-05 00:04:38 +02:00
Bernhard R. Link
ff52e3630f improve error handling in options.c
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-10-05 00:04:02 +02:00
Andreas Schneider
f1f17f18dc Fix documentation. 2009-10-05 00:03:47 +02:00
Bernhard R. Link
7c759b9615 add ssh_set_error_oom and ssh_set_error_invalid
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-10-05 00:02:43 +02:00
Bernhard R. Link
d54e9550da proper prototype of ssh_session_new
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-10-05 00:01:50 +02:00
Andreas Schneider
d7c0270c89 Fixed SSHv1 to work with the option changes. 2009-10-04 11:47:26 +02:00
Andreas Schneider
7a37f9faf7 Fixed ssh_options_copy(). 2009-10-04 10:10:19 +02:00
Aris Adamantiadis
149a2b4a18 Temporary server fixup for options structure delet
server_set_kex needs to be rewritten
2009-10-03 23:06:26 +02:00
Andreas Schneider
ab5b4c7cfe Get rid of the options structure. 2009-10-02 20:26:14 +02:00
Andreas Schneider
e78334688f Fixed setting of LFS CFLAGS. 2009-10-02 20:19:48 +02:00
Andreas Schneider
566fda70a5 Fixed LFS support on unix. 2009-10-02 20:17:21 +02:00
Andreas Schneider
62cebe23d9 Fixed build of sample client. 2009-10-02 17:21:59 +02:00
Andreas Schneider
42aacc7106 Remove unused option functions. 2009-10-02 10:18:27 +02:00
Andreas Schneider
8ed9cdce80 Remove --as-needed linker flag. 2009-10-01 10:19:07 +02:00
Aris Adamantiadis
a3a7f17d0f Missed copying of log verbosity 2009-09-30 13:10:59 +02:00
Aris Adamantiadis
571dd56eca libcrypto.so is in /lib on opensolaris 2009-09-29 17:57:37 +02:00
Aris Adamantiadis
f6f0988d10 Fix warnings on opensolaris 2009-09-29 17:57:37 +02:00
Aris Adamantiadis
f9d1542542 resolve warning on opensolaris 2009-09-29 11:46:06 +02:00
Aris Adamantiadis
d32fe11da3 Fix build with SSH1 2009-09-28 10:28:52 +02:00
Aris Adamantiadis
cd7f6bea57 more priv.h splitting 2009-09-26 14:05:58 +02:00
Aris Adamantiadis
c3dc60103f Fix small bug in ssh_options_parse_config 2009-09-26 12:42:47 +02:00
Aris Adamantiadis
2a2616f65c Fix bug in dir_expand_sub 2009-09-26 12:28:03 +02:00
Bernhard R. Link
f643c34ee8 support in ~/ and SSH_DIR/ in filenames instead of %s/
Get rid of snprintf to fixed sized buffers in setting options.
Instead make locations starting with ~/ relative to the
users initial working directory (as libssh does not look into
the home directory but only at the initial home directory).
and starting with SSH_DIR/ relative to the configured ssh directory.
2009-09-26 12:23:30 +02:00
Aris Adamantiadis
0f77578ee2 Fixed doxygen compilation warnings 2009-09-26 01:34:14 +02:00
Aris Adamantiadis
3e314e863c More include file splitting 2009-09-26 01:15:48 +02:00
Aris Adamantiadis
adbb087221 Removed obsolete options 2009-09-26 00:36:02 +02:00
Aris Adamantiadis
3a8d839e86 More include file movings 2009-09-26 00:29:53 +02:00
Aris Adamantiadis
358647f5d9 More comment 2009-09-25 23:56:28 +02:00
Aris Adamantiadis
5e76118512 fix ssh_callbacks_init() macro + documentation
ssh_callbacks_init should not zero' the struct because
it could be used on staticaly declared structures
2009-09-25 23:50:18 +02:00
Aris Adamantiadis
e3bdc393cb callback.h should use public headers 2009-09-25 23:42:29 +02:00
Aris Adamantiadis
04b49d46c1 Fixed building with Gcrypt and arith with void* 2009-09-25 23:38:09 +02:00
Aris Adamantiadis
74b7fb7bba Add an option to let users choose libgcrypt 2009-09-25 23:31:48 +02:00
Aris Adamantiadis
c70694c594 Fix memory leaks found by tysonite 2009-09-25 18:49:26 +02:00
Aris Adamantiadis
fef87793a0 Fix openssl version usage, found by tysonite 2009-09-25 18:34:58 +02:00
Andreas Schneider
79c475c917 Fixed including of config.h.
If there is some option to modify libc behaviour (like if there was some
off_t usage to be modified by some flag to make that 64 bit) that
needs to be done before the first libc header. one could still do -D
there, though (unless cmake wants to do something automatically and puts
that in config.h)
2009-09-25 10:01:56 +02:00
Andreas Schneider
3dd03fec21 Add missing extern C. 2009-09-25 09:59:25 +02:00
Andreas Schneider
e8e07f7376 Fix typo. 2009-09-25 09:37:56 +02:00
Andreas Schneider
1c5ae7dd97 Install callbacks header file. 2009-09-25 09:33:11 +02:00
Andreas Schneider
f65e3566a2 Fixed typo in config.h.cmake.
This closes ticket #24.
2009-09-24 13:22:43 +02:00
Aris Adamantiadis
6b0a89a288 Get rid of CRYPTO 2009-09-23 23:55:07 +02:00
Aris Adamantiadis
f84ebc2e27 Moved lots of declaration out of priv.h 2009-09-23 23:51:04 +02:00
Aris Adamantiadis
b359229a2e Change #defines to enums when it makes sense 2009-09-23 22:42:29 +02:00
Aris Adamantiadis
496a8e12d9 Get rid of SSH_MESSAGE 2009-09-23 22:19:11 +02:00
Aris Adamantiadis
0e8e124d20 get rid of SSH_OPTIONS 2009-09-23 22:13:19 +02:00
Aris Adamantiadis
9a8d4cd0fd get rid of SSH_SESSION 2009-09-23 21:55:54 +02:00
Aris Adamantiadis
ffed8b03bb remove the broken setters for options,cb init macro 2009-09-23 21:40:58 +02:00
Aris Adamantiadis
5bd38a5f37 Changed the current callback sys to be scalable 2009-09-23 21:30:56 +02:00
Aris Adamantiadis
ab60d1d678 Ordered functions in libssh.h alphabeticaly 2009-09-23 20:42:59 +02:00
Aris Adamantiadis
5223fa5740 Shut up warning in libssh_scp 2009-09-23 11:43:06 +02:00
Aris Adamantiadis
95558d54b0 Fix typos in SSH_OPTIONS 2009-09-23 11:21:12 +02:00
Andreas Schneider
068a7dfc49 Fixed bindport in getop function. 2009-09-22 20:36:57 +02:00
Andreas Schneider
abd8b17a04 Fixed options used in server sample. 2009-09-22 20:34:23 +02:00
Andreas Schneider
343e6e482a Added handling of bindport in getopt. 2009-09-22 20:33:58 +02:00
Andreas Schneider
aae1df0589 Use new options interface in sample code. 2009-09-22 20:27:53 +02:00
Aris Adamantiadis
0a57ebb3a9 Fix README file which is really obsolete 2009-09-22 16:51:28 +02:00
Bernhard R. Link
9afad28255 fix copy&paste error
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-09-22 14:04:42 +02:00
Andreas Schneider
8b21b51a78 Use new ssh options interface in auth functions. 2009-09-22 13:32:06 +02:00
Andreas Schneider
2003a81b44 Use new ssh options interface in keyfiles. 2009-09-22 13:20:23 +02:00
Andreas Schneider
abe6c7c728 Use new options interface in server code. 2009-09-22 13:17:35 +02:00
Andreas Schneider
f78045dfd3 Use the new options interface in config parser. 2009-09-22 13:14:23 +02:00
Andreas Schneider
39729bd3de Use the new options function in deprecated functions. 2009-09-22 13:14:23 +02:00
Andreas Schneider
f6d2a66de2 Added a cleaned up interface for setting options. 2009-09-22 13:14:16 +02:00
Andreas Schneider
7de3122b42 Added a userdata generic pointer to the log callback function. 2009-09-22 12:28:07 +02:00
Andreas Schneider
88f4e9ea24 Added more logging output for publickey auth. 2009-09-21 15:54:49 +02:00
Andreas Schneider
4133f484ae Fixed building libssh with MSVC.
Thanks to Carlo Segato for the patch.
2009-09-21 12:23:47 +02:00
Aris Adamantiadis
041aff8060 Fix binding found by Bernhard R. Link 2009-09-19 19:35:55 +02:00
Aris Adamantiadis
7c7096d8f8 Limit the size of acceptable compressed packets 2009-09-16 22:29:22 +02:00
Andreas Schneider
fd7b7bc3b5 Added Solaris support for the build script.
Thanks to tysonite.
2009-09-16 14:47:45 +02:00
Andreas Schneider
bb034e8e1d Set package number to first beta release. 2009-09-15 23:07:24 +02:00
Andreas Schneider
d37a475816 Improve documentation of ssh_options_parse_config(). 2009-09-15 18:06:19 +02:00
Andreas Schneider
4845642611 Added support for ~/.ssh/config. 2009-09-15 17:26:13 +02:00
Andreas Schneider
de8808cb47 Fixed build with mingw. 2009-09-15 10:43:09 +02:00
Aris Adamantiadis
ca978a9e81 Merge branch 'master' of git://git.libssh.org/projects/libssh/libssh 2009-09-14 23:19:11 +02:00
Aris Adamantiadis
ffca268bee Add warning in channel_open_forward documentation
Tell users it does not do magic (yet)
2009-09-14 23:18:07 +02:00
Andreas Schneider
6a3d31acb7 Fix a possible stack overflow in agent code. 2009-09-14 19:01:20 +02:00
Aris Adamantiadis
f28352707a Fix the security bug found by Orange Labs
Verify the length of decrypt operation is a multiple of blocksize
2009-09-13 22:07:01 +02:00
Aris Adamantiadis
4b363928f6 SCP warning request 2009-09-13 14:03:35 +03:00
Aris Adamantiadis
929f5ca25b scp recursive mode 2009-09-13 14:03:34 +03:00
Aris Adamantiadis
7ff80a2666 Add better error detection + EOF request 2009-09-13 14:03:34 +03:00
Aris Adamantiadis
480dfd9050 add scp_download.c example 2009-09-13 14:03:34 +03:00
Aris Adamantiadis
bdb32afa20 Cycle the fetchs, remove the ssh_connect function 2009-09-13 14:03:34 +03:00
Aris Adamantiadis
f90ae73b6d Refactored the connect_ssh example function
into a new file
2009-09-13 14:03:34 +03:00
Aris Adamantiadis
7fed54b1e5 Fix scp pull bug + scp logging 2009-09-13 14:03:34 +03:00
Aris Adamantiadis
d5840aa1f0 add support for local output, scp input
Still needs to be debugged and improved but the idea it there
2009-09-13 14:03:34 +03:00
Aris Adamantiadis
6f2225e8fb fix ssh_scp_string_mode() bug + debug msgs 2009-09-13 14:03:33 +03:00
Aris Adamantiadis
07a9e6b7c6 Change scp API to use integers for perms 2009-09-13 14:03:33 +03:00
Aris Adamantiadis
86e6444656 Begin of scp reading in example 2009-09-13 14:03:33 +03:00
Andreas Schneider
8ef62cf784 Fixed fstatvfs function. 2009-09-10 18:57:58 +02:00
Andreas Schneider
8051ab044c Reformat lowercase function. 2009-09-10 14:37:09 +02:00
Dmitry V. Krivenok
18bce13617 Fixed possible memory leak in lowercase function.
If user passed NULL pointer to lowercase() function, duplicated
string "new" wasn't freed before return.

Signed-off-by: Dmitry V. Krivenok <krivenok@orangesystem.ru>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-09-10 14:35:02 +02:00
Dmitry V. Krivenok
2a10019f82 Fixed "var is uninitialized" bug.
gcc-4.4.1 reported:

/home/krivenok/dev_builds/libssh/libssh/sftp.c:2700: warning: 'sftp' is used uninitialized in this function

sftp is NULL-initialized now.

Signed-off-by: Dmitry V. Krivenok <krivenok@orangesystem.ru>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-09-10 12:35:11 +02:00
Dmitry V. Krivenok
df4c62212c Support for sending signals (RFC 4254, section 6.9).
Added function
int channel_request_send_signal(ssh_channel channel, const char *signal);
which implements signals delivery (as described in RFC 4254).
Only SSH-v2 is currently supported.

Signed-off-by: Dmitry V. Krivenok <krivenok@orangesystem.ru>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-09-10 12:34:58 +02:00
Andreas Schneider
97b6036cbf Add a portable ssh_mkdir function for Windows. 2009-09-09 13:42:00 +02:00
Andreas Schneider
df4f7ed5b8 Fix the free calls and use the safe free macro. 2009-09-03 17:22:34 +02:00
Andreas Schneider
0792c015d6 Add missing NULL pointer checks to crypt_set_algorithms_server.
Thanks to Orange Labs for the report.
2009-09-03 17:20:06 +02:00
Andreas Schneider
8344598910 Fix an integer overflow in buffer_get_data().
Thanks to Orange Labs for the report.
2009-09-03 17:11:42 +02:00
Andreas Schneider
16870abed7 Add more warnings to gcc. 2009-09-01 11:03:48 +02:00
Aris Adamantiadis
65850a1bad Fix "void * ptr used in pointer arithmetic" warng 2009-08-29 19:04:53 +02:00
Aris Adamantiadis
1137f0d48c Change SSH_LOG_RARE to SSH_LOG_PACKET in packet.c 2009-08-29 18:59:13 +02:00
Andreas Schneider
d9a50f04e7 Fix ssh_write_knownhost() if ~/.ssh doesn't exist. 2009-08-26 09:39:21 +02:00
Andreas Schneider
4aa7d73b43 Fix typo. 2009-08-25 15:23:28 +02:00
Andreas Schneider
3804e72e24 Fix linking on solaris.
libresolv and librt are required.
2009-08-25 15:07:29 +02:00
Andreas Schneider
b8508020e5 Link shared libraries with --as-needed by default. 2009-08-25 15:06:56 +02:00
Andreas Schneider
324be0eabd Fix poll sturct, ISO C doesn't allow unnamed unions. 2009-08-25 14:16:41 +02:00
Andreas Schneider
cfe5f83cf8 Fix shadow compiler warning in sample code. 2009-08-25 13:59:40 +02:00
Andreas Schneider
a1ad0deb32 Set gcc to c99 standard and enable pedantic. 2009-08-25 13:58:30 +02:00
Andreas Schneider
7c575a2418 Fix typedef collisons on Solaris. 2009-08-25 13:54:46 +02:00
Aris Adamantiadis
47cac13c0a Merge branch 'master' of git://git.libssh.org/projects/libssh/libssh 2009-08-24 16:08:17 +02:00
Aris Adamantiadis
16d1ef8933 buffer initialization change 2009-08-24 16:07:45 +02:00
Andreas Schneider
b500d76929 Add Solaris search path for libraries. 2009-08-24 14:49:07 +02:00
Aris Adamantiadis
aef9471217 fix memleak through requests 2009-08-23 23:43:07 +02:00
Aris Adamantiadis
f3454d571e ssh_scp_request_get_{filename,permissions,size} 2009-08-23 23:40:30 +02:00
Aris Adamantiadis
1df1f86f7e added ssh_scp_read 2009-08-23 23:24:46 +02:00
Aris Adamantiadis
f9db9c5a9c added ssh_scp_accept_request 2009-08-23 22:43:57 +02:00
Aris Adamantiadis
96bafeca4c corrected errors 2009-08-23 22:40:15 +02:00
Aris Adamantiadis
626d8ec637 forgot to set up state 2009-08-23 22:38:29 +02:00
Aris Adamantiadis
f3b36af50e added ssh_scp_deny_request 2009-08-23 22:36:32 +02:00
Aris Adamantiadis
385b640d1d Implementation of ssh_scp_pull_request
Still needed: code in ssh_scp_init,
implementation of ssh_scp_read
ssh_scp_request_get_filename,
ssh_scp_request_get_size,
ssh_scp_request_get_mode,
ssh_scp_deny_request
ssh_scp_accept_request
!!
2009-08-23 22:04:51 +02:00
Aris Adamantiadis
d4bc6fa954 Merge branch 'master' of git://git.libssh.org/projects/libssh/libssh
Conflicts:
	include/libssh/priv.h
2009-08-23 16:41:29 +02:00
Aris Adamantiadis
8bae43876f experimental callback system 2009-08-23 16:33:59 +02:00
Aris Adamantiadis
fbfea94559 Pending work 2009-08-23 16:29:31 +02:00
Aris Adamantiadis
6a04b43a45 added ssh_scp_request_new,ssh_scp_request_struct 2009-08-23 15:23:48 +02:00
Aris Adamantiadis
049c62098c add ssh_scp_push_directory,ssh_scp_leave_directory
Not yet carefully tested
2009-08-23 14:57:03 +02:00
Aris Adamantiadis
6801959989 Use ssh_basename on ssh_scp_file_push'ed files 2009-08-23 14:28:38 +02:00
Andreas Schneider
8463d9d7c6 Improve header checks on windows. 2009-08-21 15:15:49 +02:00
Andreas Schneider
c497f057a0 Improve detection for required libraries on Solaris. 2009-08-21 15:15:18 +02:00
Andreas Schneider
fc0af0f0d8 Add openssl include dir on Solaris. 2009-08-21 14:54:24 +02:00
Andreas Schneider
330c2004a1 Make the functions public. 2009-08-21 10:17:58 +02:00
Andreas Schneider
0b10493e90 Added ssh_basename() and ssh_dirname(). 2009-08-21 10:16:36 +02:00
Andreas Schneider
d23e64fc52 Add a warning if wspiapi.h doesn't exist. 2009-08-20 12:32:35 +02:00
Andreas Schneider
fd83d69440 Improve the configure checks. 2009-08-20 11:50:49 +02:00
Andreas Schneider
461e46b814 Improve checks for Windows version and wspiapi.h. 2009-08-20 11:43:37 +02:00
Andreas Schneider
4f95146151 Fix build warnings on Windows. 2009-08-20 10:50:02 +02:00
Andreas Schneider
3eb21053d0 Add a portable define to print size_t. 2009-08-20 10:49:27 +02:00
Andreas Schneider
92db6f8c6d Remove DEBUG_CRYPTO variable.
You can enable it with cmake -DWITH_DEBUG_CRYPTO:BOOL=TRUE.
2009-08-20 10:44:31 +02:00
Andreas Schneider
0fd0c6d293 Don't shadow global vairables. 2009-08-19 10:52:30 +02:00
Andreas Schneider
b49973f17b Fix compile warnings. 2009-08-17 08:56:43 +02:00
Andreas Schneider
978d265da8 Build channel_accept() on Windows too. 2009-08-16 19:01:13 +02:00
Vic Lee
cf6dddce34 Fix double free pointer crash in dsa_public_to_string
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-08-16 14:40:19 +02:00
Vic Lee
2c4bbe51dd Fix return code from packet_wait in channel_request
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-08-16 14:40:18 +02:00
Andreas Schneider
756d441f8c Fix channel_accept_x11 on Windows. 2009-08-16 14:40:18 +02:00
Vic Lee
db6aa88bc4 Add forward listening feature
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-08-16 14:40:18 +02:00
Aris Adamantiadis
e707af1cd7 Fix channel_get_exit_status bug reported by VicLee
It would return -1 if the channel received the exit status
and the close message at same time.
2009-08-16 13:51:55 +02:00
Aris Adamantiadis
380a70d650 fix ssh_finalize which didn't clear the flag 2009-08-13 23:26:17 +02:00
Andreas Schneider
2dc3b5c675 Add sftp_extension_supported() function. 2009-08-12 17:13:42 +02:00
Andreas Schneider
63011c29a0 Implement an example for statvfs. 2009-08-12 17:13:42 +02:00
Andreas Schneider
e68c3b09a6 Add support for OpenSSH's statvfs and fstatvfs calls. 2009-08-12 17:13:42 +02:00
Andreas Schneider
0793bf5aa6 Set version number to 0.4.0. 2009-08-12 17:13:04 +02:00
Andreas Schneider
d9b7e4cb7a Fix compilation with visibility flags with mingw.
Thanks to Patrick Spendrin.
2009-08-12 14:05:17 +02:00
Andreas Schneider
8e6ab1809f Enable the debug calltrace by default. 2009-08-12 10:08:20 +02:00
Aris Adamantiadis
86418bfbbe Merge branch 'master' of git://git.libssh.org/projects/libssh/libssh 2009-08-12 00:04:30 +02:00
Aris Adamantiadis
1e1c13f756 some tweaks of scp example 2009-08-12 00:04:04 +02:00
Aris Adamantiadis
8dae851836 Make the calltrace logging optional 2009-08-12 00:03:36 +02:00
Andreas Schneider
db284d60b9 Fix static build.
If you want to link against the static library you have to define
LIBSSH_STATIC and link against ssh_static.

gcc -static -DLIBSSH_STATIC -lssh_static foo.c -o foo
2009-08-11 18:16:43 +02:00
Andreas Schneider
bfc6c7e606 Remove the map file from the sources. 2009-08-11 17:11:44 +02:00
Andreas Schneider
9b13390ad0 Use gcc visibility attribute to get rid of the map file. 2009-08-11 17:10:00 +02:00
Andreas Schneider
81fe4299f7 Fix linking of the static library on Windows. 2009-08-11 16:12:53 +02:00
Andreas Schneider
5e4bc6ec79 Fix compilation with MSVC and use declspec to export functions.
Thanks to Patrick Spendrin <ps_ml@gmx.de> for all the MSVC fixes.
2009-08-11 15:38:49 +02:00
Andreas Schneider
f3612879a8 Remove InstallRequiredSystemLibraries from CPack. 2009-08-11 15:37:52 +02:00
Andreas Schneider
57088c4375 Fix libssh build and installation on MSVC. 2009-08-11 15:37:10 +02:00
Andreas Schneider
011ab7c8fe Suppress warning about "deprecated" functions in MSVC. 2009-08-11 15:36:37 +02:00
Aris Adamantiadis
e4422d6605 Fix memory leak introduced by previous bugfix 2009-08-11 13:15:23 +02:00
Andreas Schneider
14e1d015ee Fix uint8_t. 2009-08-11 09:41:52 +02:00
Andreas Schneider
3da1c17acb Add a NULL check for strdup memory allocation. 2009-08-11 09:41:07 +02:00
Aris Adamantiadis
7e9f0803c5 Latest scp code
The sample is now able to scp a file
2009-08-10 22:59:35 +02:00
Aris Adamantiadis
f989452b3e Fixed stupid "can't parse known host key" bug
due to a dangling \n in the base64 ...
2009-08-10 22:50:16 +02:00
Aris Adamantiadis
a2780d1dd4 I really really broke it
excuse me !
2009-08-10 14:34:04 +02:00
Aris Adamantiadis
ddca45804b oops I broke libssh.map 2009-08-10 14:32:50 +02:00
Aris Adamantiadis
f92e12c7b0 ssh_scp_push_file and ssh_scp_write
still needs tests
2009-08-09 22:51:03 +02:00
Aris Adamantiadis
e4da8b99fe Initial scp implementation in source tree 2009-08-09 02:01:54 +02:00
Aris Adamantiadis
b993579079 Got the scp sample to work
Problem was that the terminal was not needed, and some nul bytes were to be read.
2009-08-09 00:25:09 +02:00
Aris Adamantiadis
807cb635c1 Fixed channel_poll broken when delayed EOF recvd
Previous code returned SSH_EOF even if data was left in buffer
2009-08-09 00:20:42 +02:00
milo
3ad559cc23 Fix buffer overflow in generate_cookie()
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-08-07 12:49:55 +02:00
milo
ec02ce0ec2 Fix a typo: CHANNEL * -> ssh_channel
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-08-07 11:40:07 +02:00
milo
1b9676a0cc Fix possible memory corruption (#14)
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-08-06 10:29:36 +02:00
Andreas Schneider
f4b3ef7604 Remove ssh_fd_poll from map file. 2009-08-05 18:20:32 +02:00
Andreas Schneider
e9974c2053 Remove ssh_fd_poll which is gone. 2009-08-05 17:38:43 +02:00
Andreas Schneider
de532ee550 Move extension structure to the end. 2009-08-01 11:15:53 +02:00
Andreas Schneider
67b44e4417 Don't use the map file if the build type is debug. 2009-08-01 11:05:19 +02:00
Andreas Schneider
83f65031c0 Fixed libssh compilation without server support. 2009-07-31 12:31:46 +02:00
Vic Lee
63053541e6 Add x11 forwarding support for ssh client
Signed-off-by: Vic Lee <llyzs@163.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-07-31 11:17:51 +02:00
Andreas Schneider
a040e2e3db Cleanup the map file and oder it alphabetically. 2009-07-30 12:02:05 +02:00
Andreas Schneider
678d445075 Export public functions on Windows. 2009-07-30 12:01:39 +02:00
Andreas Schneider
3558b9e6b6 Fix Windows build. 2009-07-30 11:40:28 +02:00
Andreas Schneider
590c3e2f51 Add strange names for Windows. 2009-07-30 11:38:38 +02:00
Andreas Schneider
28a7343320 Fix project name in examples. 2009-07-30 11:11:00 +02:00
Andreas Schneider
766bae9d76 Fix build with MSVC. 2009-07-30 10:45:58 +02:00
Andreas Schneider
94a57df0c9 Compile the library with the map file again. 2009-07-30 00:46:57 +02:00
Andreas Schneider
5f93742c5e Add missing functions to map file. 2009-07-30 00:46:45 +02:00
Andreas Schneider
9457c770df Change the library so version. 2009-07-30 00:46:07 +02:00
Andreas Schneider
bccb9b16a5 Move channel_write_stderr to server.c. 2009-07-29 23:21:01 +02:00
Andreas Schneider
1355029ec9 Fix indent. 2009-07-29 23:02:12 +02:00
Andreas Schneider
5dc8d6069d Update map file and introduce a new version.
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-07-29 18:42:16 +02:00
Andreas Schneider
60837b1538 Add channel_write_stderr prototype to the right header file.
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-07-29 18:42:10 +02:00
Andreas Schneider
debfd1f3a3 Fix build errors in new messages functions.
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-07-29 18:42:05 +02:00
Preston A. Elder
4f70cc13e2 Fleshed out server interface
- Enables channel_request_open types of DIRECT_TCPIP, FORWARDED_TCPIP and X11 (ie. implemented the handling of those channel_request_open types).
- Adds functions to retrieve the extra information relating to channel_request_open messages and channel_request messages.
- Adds a channel_write_stderr method (obviously for writing to the STDERR channel from server side) - well, technically just converted the exiting channel_write to take an extra argument and created two wrapper functions.
- Actually does the invoking of message_handle() from channel_recv_request.
- Implemented the handling of the window-change and env channel_requests.
- Implemented a few functions in server.h that were declared but not defined (eg. ssh_message_channel_request_channel).

Signed-off-by: Preston A. Elder <prez@neuromancy.net>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-07-29 18:41:48 +02:00
Andreas Schneider
b4111c5c18 Add functions to get the extension count, name and data. 2009-07-28 14:13:22 +02:00
Andreas Schneider
b9b7174d85 Add support to read and store sftp extensions. 2009-07-28 13:25:35 +02:00
Andreas Schneider
69ceaae9a9 Check for OpenSSH and implement sftp_symlink correct.
When OpenSSH's sftp-server was implemented, the order of the arguments
to the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately,
the reversal was not noticed until the server was widely deployed.
Since fixing this to follow the specification would cause
incompatibility, the current order was retained.
2009-07-28 13:25:26 +02:00
Andreas Schneider
1abdb28995 Fix SSH1 compilation. 2009-07-27 23:17:35 +02:00
Andreas Schneider
81dab99afc Fix stdint type. 2009-07-27 23:14:04 +02:00
Andreas Schneider
291522772d Fix SSH1 and stdint in SSH1 code. 2009-07-27 23:13:24 +02:00
milo
26d1ac325b Fix potential memory corruption bug 2009-07-27 20:53:01 +02:00
milo
1311d03415 Fix typo orignator_port -> originator_port 2009-07-27 20:52:36 +02:00
Andreas Schneider
549fd32574 Fix compile errors in keyfiles. 2009-07-27 20:49:38 +02:00
Andreas Schneider
9f14bbd6ad Remove double SSH2_MSG_USERAUTH_PK_OK. 2009-07-27 20:30:27 +02:00
milo
e8f7801540 Public key authentication server side 2009-07-27 20:27:07 +02:00
Andreas Schneider
cdde79418a Add ssh_file_readaccess_ok to check read access on a file. 2009-07-27 14:20:32 +02:00
Andreas Schneider
9b97da65e6 Add a function to close the socket.
This fixes ssh_connect on Windows.
2009-07-27 14:19:06 +02:00
Andreas Schneider
1dcaebe1ce Fix a typo. 2009-07-27 13:20:29 +02:00
Andreas Schneider
28b5d0f875 Switch completly to stdint types. 2009-07-25 23:19:41 +02:00
Aris Adamantiadis
ba217dec1c First implementation of a scp transfer tool
Doesn't work yet. I've got a headache and debugging doesn't help.
2009-07-25 22:29:12 +02:00
Andreas Schneider
3b8c4dc750 Fix conflicting declarations of ssh_session and ssh_kbdint. 2009-07-25 20:26:56 +02:00
Andreas Schneider
5d1fa1be24 Fix return value of sftp_tell64(). 2009-07-25 19:52:07 +02:00
Andreas Schneider
c8e82528fc Update map file for ssh_clean_pubkey_hash; 2009-07-25 18:00:36 +02:00
Andreas Schneider
104e6d39ab Add a sftp_tel64() function. 2009-07-25 17:55:58 +02:00
Andreas Schneider
3f778d9a31 Add ssh_clean_pubkey_hash() which is needed on Windows. 2009-07-25 17:52:00 +02:00
Aris Adamantiadis
a935ad1857 New example directory with the begining of a scp 2009-07-25 17:03:01 +02:00
Aris Adamantiadis
7abb3941c8 Bumped the version numbers to 0.4.0 in HEAD 2009-07-25 16:32:10 +02:00
Andreas Schneider
194880b869 Update map file. 2009-07-25 11:56:59 +02:00
Andreas Schneider
737f588b3b Fix a typo. 2009-07-25 11:55:42 +02:00
Andreas Schneider
6d5b36fb79 Add symlink and readlink test to sample. 2009-07-25 11:55:42 +02:00
Andreas Schneider
8ce6bd3459 Add sftp_readlink function. 2009-07-25 11:55:42 +02:00
Andreas Schneider
5b8338d115 Add sftp_symlink function. 2009-07-25 11:55:33 +02:00
Aris Adamantiadis
e73cbbe18c Added a threading + sftp stress testcase 2009-07-24 22:52:10 +02:00
Aris Adamantiadis
69a01b3657 move all u32,u16,u8 and u64 declarations in priv.h
And fix all headers which need u32,u8,u64
2009-07-24 22:31:39 +02:00
Aris Adamantiadis
e406b81d34 Missed something in channel_select for CHANNEL 2009-07-24 22:24:10 +02:00
Aris Adamantiadis
fdc2751952 Make the SSH_SAFE_NAMESPACE flag active 2009-07-24 22:20:41 +02:00
Aris Adamantiadis
fa11083fcb Change refs from AGENT * to ssh_agent
Fixes also a typo in ssh_agent declaration
2009-07-24 22:19:40 +02:00
Aris Adamantiadis
2bc8819e8f Changes all CHANNEL * to ssh_channel 2009-07-24 22:15:33 +02:00
Aris Adamantiadis
23b6c95e04 Change PRIVATE_KEY * to ssh_private_key 2009-07-24 22:08:04 +02:00
Aris Adamantiadis
c041bcc6d9 Forgot sample* in previous BUFFER change 2009-07-24 22:03:36 +02:00
Aris Adamantiadis
fc5dd23afa Changed all PUBLIC_KEY * to ssh_public_key 2009-07-24 22:02:32 +02:00
Aris Adamantiadis
91d0660cc3 Changed all occurences of BUFFER * to ssh_buffer 2009-07-24 21:56:11 +02:00
Aris Adamantiadis
fb5769b4be You always forget SSH1 ... 2009-07-24 21:47:23 +02:00
Aris Adamantiadis
56ee212641 Change all occurences of STRING * to ssh_string 2009-07-24 21:45:41 +02:00
Aris Adamantiadis
8f3891e968 moved try_publickey_from_file in priv.h
Had nothing to do in libssh.h. 100% sure nobody
used it since one of the structure declaration
was not public.
2009-07-24 21:23:07 +02:00
Aris Adamantiadis
958a775afa replacing keys_struct with ssh_keys_struct 2009-07-24 21:18:15 +02:00
Aris Adamantiadis
e776dc16c9 Fixed namespace problem in public structures
changed
struct string_struct to ssh_string_struct
buffer_struct to ssh_buffer_struct
and so on.

Should not break apps using the caps version of these
2009-07-24 20:49:46 +02:00
Andreas Schneider
9450a3c987 Fix a possible segfault in sftp_canonicalize_path(). 2009-07-23 18:34:25 +02:00
Andreas Schneider
1939a55c3c Fix getaddrinfo and gethostbyname build problems on Solaris. 2009-07-23 11:57:17 +02:00
Andreas Schneider
2a116bb291 Fix OpenSSL include file checks on Solaris. 2009-07-23 11:54:32 +02:00
Andreas Schneider
d01c7320f9 Fix finding OpenSSL on Solaris. 2009-07-23 09:30:14 +02:00
Andreas Schneider
ea0315ed88 Add cmake check for big endian. 2009-07-23 09:25:36 +02:00
Andreas Schneider
85a5eb9499 Fix a segfault if a NULL pointer is passed to ssh_disconnect(). 2009-07-22 16:04:41 +02:00
Andreas Schneider
3cd06a1f26 Don't segfault if the session or the answer is NULL. 2009-07-22 12:18:34 +02:00
Andreas Schneider
19c3d02805 Merge branch 'master' of git://git.libssh.org/projects/libssh/libssh 2009-07-21 14:12:25 +02:00
Andreas Schneider
b534bfc520 Fix ssh_write_knownhost() which always returned -1.
fwrite() return the the number of items written not the size of the
buffer.
2009-07-21 14:07:23 +02:00
Andreas Schneider
ef2c8d66f1 Add compile flags and test for compiler options only if we use gcc. 2009-07-21 11:14:54 +02:00
Andreas Schneider
1a6038baa5 Only add additional warnings if we have a GNU compiler. 2009-07-21 11:10:09 +02:00
Andreas Schneider
41a8fb5810 Make the ssh_userauth_kbdint functions to get the prompts const.
They shouldn't be modified or free'd by a user.
2009-07-21 10:34:21 +02:00
Andreas Schneider
8843d8b68d Fix sol8 + ss11 compile errors.
Thanks to tysonite@gmail.com.
2009-07-20 22:50:45 +02:00
Andreas Schneider
2aec79ce36 Add missing changelog entries. 2009-07-14 11:10:22 +02:00
Aris Adamantiadis
bbcbc8425c Fix doxygen to match SSH_SERVER_FILE_NOT_FOUND fix 2009-07-14 10:09:18 +02:00
Andreas Schneider
ed8178f3c3 Fix build on windows, missing include. 2009-07-13 13:33:52 +02:00
Aris Adamantiadis
933527fc77 Put #ifdef around AI_NUMERICSERV which doesn't seem std 2009-07-13 13:29:00 +02:00
Aris Adamantiadis
bf8d139b2d Enable conditional compiling for IP regex code. 2009-07-13 12:32:06 +02:00
Aris Adamantiadis
093983b804 forgot init.c in copyright updates 2009-07-13 00:25:04 +02:00
Aris Adamantiadis
103292dd99 Fixed copyright notices 2009-07-13 00:23:42 +02:00
Aris Adamantiadis
76b6b1c694 typo in sample.c 2009-07-13 00:19:47 +02:00
Aris Adamantiadis
1301864f92 Reflect the SSH_SERVER_NOT_KNOWN add-on in sample 2009-07-12 23:17:12 +02:00
Aris Adamantiadis
d5b6f6cc37 Added return code SSH_SERVER_FILE_NOT_FOUND
This error is returned by ssh_is_server_known when known_hosts
file does not exist and gives more action to the developer.
2009-07-12 23:13:21 +02:00
Aris Adamantiadis
052073c36d Set correct hint when connecting to an IP address
libssh now uses a regular expression against destination
hostnames to match numerical IP addresses and set the
appropriate hint.

Patches also add init and finalize code to compile the regexp
2009-07-12 23:01:43 +02:00
Aris Adamantiadis
60c778ad7f fix int -> socket_t in SSH_POLL 2009-07-04 14:16:13 +02:00
Aris Adamantiadis
71100dadcd Temporary move of ssh_poll_* back to priv.h
We'll see later what needs to be put back in public
functions
2009-07-04 13:52:34 +02:00
Aris Adamantiadis
5ba33438f3 Move doxygen tags into C files 2009-07-04 13:47:57 +02:00
Aris Adamantiadis
708c0d32a2 Put back the poll declarations into priv.h
That are, poll constants.
2009-07-04 13:41:16 +02:00
Aleksandar Kanchev
3659e8c04a Add a generic way to handle sockets asynchronously.
It's based on poll objects, each of which store a socket, it's events and a callback,
which gets called whenever an event is set. The poll objects are attached to a poll
context, which should be allocated on per thread basis.

Polling the poll context will poll all the attached poll objects and call their
callbacks (handlers) if any of the socket events are set. This should be done within
the main loop of an application.

This is intended as a ground work for making libssh asynchronous.

Signed-off-by: Aleksandar Kanchev <aleksandar.kanchev@googlemail.com>
2009-07-03 21:53:53 +02:00
Aris Adamantiadis
c4cf349729 Add logging of the sftp flags used to open a file
Should be used to debug weird behaviour when using libssh on windows with different compiler chains.
2009-06-30 22:35:01 +02:00
Aris Adamantiadis
2c99566697 Fixed Could not write as much data as expected msg
Bug caused by verifying the size of the buffer in the wrong place
2009-06-30 22:17:35 +02:00
Aleksandar Kanchev
42470857e2 Fixed make condition in build_make.sh.
Signed-off-by: Aleksandar Kanchev <aleksandar.kanchev@googlemail.com>
Signed-off-by: Andreas Schneider <mail@cynapses.org>
2009-06-25 18:02:57 +02:00
Aris Adamantiadis
8724f97a19 Fixed memory leak in ssh_is_server_known() 2009-06-22 23:30:50 +02:00
Aris Adamantiadis
8960992267 Fixed yet another read-after-free bug
read of a buffer len after free in sftp_write()
2009-06-21 22:30:28 +02:00
Aris Adamantiadis
730af24de8 Fixed a use-after-free in match_hashed_host() 2009-06-21 22:09:19 +02:00
Aris Adamantiadis
a3fa6f3099 fix stupid "use unallocated memory" code in sample
it confused valgrind and wasted 2 precious hours of my life
2009-06-21 21:53:12 +02:00
Aris Adamantiadis
4dafc25927 Added a macro to test buffer_struct integrity
Nothing yet in cmake and config.h.in for this
2009-06-21 20:29:29 +02:00
Aris Adamantiadis
e671ebcd99 Modified the sftp test case so it creates 0700 fil 2009-06-21 20:14:10 +02:00
Aris Adamantiadis
bab8508eba Fix doublefree bug found by Cyril 2009-06-21 19:25:51 +02:00
Andreas Schneider
77cd4795c5 Remove unneeded printf. 2009-06-19 22:46:41 +02:00
Andreas Schneider
dc83f36a00 Add a git ignore file. 2009-06-19 10:25:51 +02:00
Aris Adamantiadis
8336c91e9c Verify memory return codes in ssh_list functions 2009-06-19 10:18:24 +02:00
Aris Adamantiadis
1bea53375b added ssh_message_callback support.
Not fully working yet. User can set his ssh_message_callback, and the function ssh_execute_message_callbacks will call them when appropriate. Messages are correctly stacked (in packet_parse) but no call to ssh_execute_callbacks exists yet.
2009-06-18 23:48:55 +02:00
Aris Adamantiadis
3af55a4f49 Created general singlelinked list implementation 2009-06-18 23:01:05 +02:00
Aris Adamantiadis
cf482ae3bf Begin of asynchronous SSH message parsing 2009-06-17 23:53:00 +02:00
Aris Adamantiadis
916958a2bb Fixed potential format string attacks
Potential format string attacks on error reporting in channels.c
2009-06-17 23:42:07 +02:00
Aris Adamantiadis
e2af94289f ssh_message_retrieve + memoryleak fixed in ssh_message_free
ssh_message_retrieve parses a specific SSH message and returns a pointer to it.
Hacked ssh_message_get to use it. This is the first step to have asynchronous ssh messages callbacks.
2009-06-17 23:28:05 +02:00
Aris Adamantiadis
fa4c81cfb9 Url change in README 2009-06-16 16:45:39 +02:00
Aris Adamantiadis
7dbc66e4a3 ssh_init()
fixes in client.c and server.c for this


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@778 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-06-15 15:31:23 +00:00
Andreas Schneider
3873489688 Simply leave the function, this should prevent a segfault.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@777 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-06-10 16:05:39 +00:00
Andreas Schneider
d14a492019 Fix a infinite loop on error.
Thanks to Milo for the pointer.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@776 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-06-10 15:29:11 +00:00
Andreas Schneider
848984f25f Fix a possible crash bug.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@775 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-06-09 12:03:24 +00:00
Andreas Schneider
5a755a8219 Fix build warnings.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@774 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-06-09 12:03:00 +00:00
Andreas Schneider
910689126a Fix cmake on BSD.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@773 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-06-09 10:54:48 +00:00
Andreas Schneider
87995db8fe Make use of poll() and add a poll-emulation for win32.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@772 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-06-04 07:23:55 +00:00
Laurent Bigonville
70c9da4fb0 Drop debian directory, new location: git://git.debian.org/collab-maint/libssh.git
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@771 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-06-01 16:49:46 +00:00
Andreas Schneider
1ac654ec6c Fix compilation of SSHv1.
Patch by Norbert Kiesel.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@770 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-23 08:27:31 +00:00
Andreas Schneider
fecbdff179 Set version to 0.3.0 and set release date.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@768 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-21 09:34:02 +00:00
Aris Adamantiadis
894b73abe2 updated changelog + authors
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@767 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-18 18:39:26 +00:00
Andreas Schneider
da4986e4bc Fix the homepage url and the vendor.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@766 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-14 11:20:17 +00:00
Andreas Schneider
08ab186471 Add missing vim modeline.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@765 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-13 07:59:59 +00:00
Andreas Schneider
439d995fed Fix some compiler warnings on windows.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@764 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-13 07:38:30 +00:00
Andreas Schneider
2e0b2e2e91 Fix the vim modeline and place it at the end of the file.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@763 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-12 17:49:23 +00:00
Andreas Schneider
80ba62a519 Add missing changelog entry.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@762 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 15:09:23 +00:00
Andreas Schneider
a065e35e37 Improve some debug statements.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@761 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 12:38:21 +00:00
Andreas Schneider
2eaf69ee06 Fix a double free corruption.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@760 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 12:31:54 +00:00
Andreas Schneider
a15a28e698 Remove a wrong NULL check.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@759 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 12:25:06 +00:00
Andreas Schneider
646a5a2cfc Don't force the CMAKE_BUILD_TYPE or we can't overwrite it.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@758 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 11:25:55 +00:00
Andreas Schneider
9196be1a42 Initialize the return value to fix a build warning.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@757 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 11:12:46 +00:00
Andreas Schneider
1657d0932f Document the ssh server bind functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@756 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 10:24:37 +00:00
Andreas Schneider
f0432cc24f Update changelog.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@755 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 10:06:15 +00:00
Andreas Schneider
d008e5aeb8 Added a ssh_bind_set_fd() function.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@754 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 10:05:47 +00:00
Andreas Schneider
2934765c76 Change variable names of the keys_struct to avoid conflicts.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@753 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-11 09:24:39 +00:00
Andreas Schneider
f29e119c25 Improve OpenSSL cmake checks.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@752 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-07 15:11:04 +00:00
Andreas Schneider
126dcd51e5 Improve GCrypt cmake checks.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@751 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-07 15:07:54 +00:00
Andreas Schneider
249e11bd2e Improve the INSTALL file.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@750 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-07 08:32:50 +00:00
Andreas Schneider
cea0ac4455 Fix typos.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@749 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-07 08:27:51 +00:00
Andreas Schneider
ae81c4124e Add channel_read() changes to changelog.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@748 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-06 07:22:04 +00:00
Andreas Schneider
d75b53805d Add more changelog entries for 0.3.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@747 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 14:21:05 +00:00
Andreas Schneider
bc0491c098 Update an format ChangeLog.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@746 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 13:51:50 +00:00
Andreas Schneider
1fd0237ddb Remove empty file.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@745 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 13:51:38 +00:00
Andreas Schneider
69af190acb Fix compilation on windows.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@744 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 10:03:34 +00:00
Andreas Schneider
c7806a6a16 Improve bin_to_base64() and use const for source.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@743 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 09:16:08 +00:00
Andreas Schneider
fdc1073e8a Format alphabet table.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@742 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 09:09:01 +00:00
Andreas Schneider
fb559c6ffd Fix the macros.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@741 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 09:08:33 +00:00
Andreas Schneider
f7d2040d5a Format _bin_to_base64().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@740 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 09:07:09 +00:00
Andreas Schneider
2e5f1c8955 Improve get_equals().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@739 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 09:05:09 +00:00
Andreas Schneider
184b711a04 Fix the prototype.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@738 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 09:04:10 +00:00
Andreas Schneider
5708fe1729 Improve _base64_to_bin().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@737 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 09:03:07 +00:00
Andreas Schneider
cc2df5487a Improve to_block4().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@736 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 09:00:29 +00:00
Andreas Schneider
fc50facaa3 Improve base64_to_bin().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@735 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 08:57:16 +00:00
Andreas Schneider
8f8e9a2f50 Improve channel_write1().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@734 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 08:30:13 +00:00
Andreas Schneider
ec714ea67d Improve channel_request_exec1().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@733 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 08:29:16 +00:00
Andreas Schneider
de138cd055 Improve channel_change_pty_size1().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@732 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 08:28:29 +00:00
Andreas Schneider
65331f470a Improve channel_request_pty_size1().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@731 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 08:27:30 +00:00
Andreas Schneider
d6e23b7628 Format channel_open_session1().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@730 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 08:25:39 +00:00
Andreas Schneider
f9baa6552c Format ssh_select().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@729 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 08:22:06 +00:00
Andreas Schneider
4bf12aaf56 Improve ssh_connect_host().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@728 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 08:05:03 +00:00
Andreas Schneider
7568e42f4e Improve ssh_connect_ai_timeout().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@727 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:55:24 +00:00
Andreas Schneider
83b26b97b5 Improve getai().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@726 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:47:11 +00:00
Andreas Schneider
ce1a5d7578 Reorder and format socket blocking functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@725 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:42:07 +00:00
Andreas Schneider
57b7e73394 Reoder define and includes.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@724 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:38:53 +00:00
Andreas Schneider
33a640e348 Use const char * and an unsigned int in ssh_crc32().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@723 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:34:16 +00:00
Andreas Schneider
03c40ac79f Format ssh_get_error_code().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@722 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:29:36 +00:00
Andreas Schneider
53a24a4f78 Format ssh_get_error().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@721 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:27:16 +00:00
Andreas Schneider
8af13665ab Make the documentation internal.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@720 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:26:19 +00:00
Andreas Schneider
4838742a8e Improve and document ssh_set_error().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@719 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:25:07 +00:00
Andreas Schneider
8c45767d34 Fix build error.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@718 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:20:12 +00:00
Andreas Schneider
1d78b6d00e Improve ssh_log().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@717 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:19:50 +00:00
Andreas Schneider
4c78793961 Format match_hostname().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@716 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:15:06 +00:00
Andreas Schneider
5c934d0970 Reformat match_pattern_list().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@715 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:14:09 +00:00
Andreas Schneider
1a280d859d Format match_pattern().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@714 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-05 07:11:21 +00:00
Andreas Schneider
dc07d46cca Add a exec test.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@713 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 22:30:21 +00:00
Andreas Schneider
6c51183f0e Wait for the exit status before returning.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@712 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 22:26:49 +00:00
Andreas Schneider
61ebfcfa5c Improve own gcrypt function.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@711 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 13:52:27 +00:00
Andreas Schneider
ff60d8ce22 Remove line which was accidently commited.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@710 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:52:08 +00:00
Andreas Schneider
c4169e3c41 Fix a bug in channel_poll().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@709 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:46:52 +00:00
Andreas Schneider
0b7ae624a3 Improve channel_select().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@708 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:42:07 +00:00
Andreas Schneider
d9a0b90701 Reformat count_ptrs().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@707 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:27:37 +00:00
Andreas Schneider
503bc1b95f Remove unused variable.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@706 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:26:45 +00:00
Andreas Schneider
cd71590fe0 Reformat channel_protocol_select().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@705 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:26:30 +00:00
Andreas Schneider
1afe6b13c5 Improve the docu of channel_get_exit_status().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@704 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:20:20 +00:00
Andreas Schneider
0d17b6778b Reformat channel_get_session() and improve docu.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@703 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:18:42 +00:00
Andreas Schneider
43d881ba28 Improve channel_poll() and add a SSH_EOF return value.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@702 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:17:10 +00:00
Andreas Schneider
3d9fbe8eea Add a warning.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@701 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:10:15 +00:00
Andreas Schneider
152da07023 Implement channel_read() as a POSIX like function.
Create channel_read_buffer() to have the old version still available.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@700 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 10:06:49 +00:00
Andreas Schneider
dda7808851 Improve the documentation in channel_request_exec().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@699 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 07:04:53 +00:00
Andreas Schneider
f40ae74f51 Improve the docu of channel_request_env().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@698 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 07:02:33 +00:00
Andreas Schneider
5b547812eb Improve the channel_request_subsystem() docu.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@697 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 07:00:47 +00:00
Andreas Schneider
8060f51ec7 Improve channel_request_shell().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@696 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 06:58:32 +00:00
Andreas Schneider
0e6359c63d Improve channel_change_pty_size().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@695 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 06:57:15 +00:00
Andreas Schneider
3e1ed1707c Reformat channel_request_pty().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@694 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 06:55:25 +00:00
Andreas Schneider
2688c1a1d5 Improve channel_request_pty_size().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@693 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 06:54:06 +00:00
Andreas Schneider
a08c56baf4 Improve channel_request().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@692 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 06:50:16 +00:00
Andreas Schneider
137669db3f Improve channel_set_blocking().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@691 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 06:48:04 +00:00
Andreas Schneider
98fbe3020d Improve channel_is_* functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@690 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 06:36:17 +00:00
Andreas Schneider
9345ba7030 Improve channel_write().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@689 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-04 06:30:12 +00:00
Andreas Schneider
17c146391c Improve channel_close().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@688 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 18:35:36 +00:00
Andreas Schneider
b27e5b6785 Improve channel_send_eof().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@687 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 18:32:33 +00:00
Andreas Schneider
9827cac475 Reformat channel_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@686 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 18:31:03 +00:00
Andreas Schneider
b23c68264d Improve channel_open_forward().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@685 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 18:27:45 +00:00
Andreas Schneider
095775ef1b Improve channel_open().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@684 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 18:25:13 +00:00
Andreas Schneider
c98fce8596 Reformat some code of channel_default_bufferize().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@683 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 18:22:10 +00:00
Andreas Schneider
e97275c7bc Reformat channel_handle().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@682 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 18:20:03 +00:00
Andreas Schneider
783825254a Improve channel_rcv_request().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@681 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 18:04:57 +00:00
Andreas Schneider
e7fc9ab369 Improve channel_rcv_close().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@680 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 17:54:16 +00:00
Andreas Schneider
2b705786c0 Reformat channel_rcv_eof().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@679 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 17:51:09 +00:00
Andreas Schneider
e46d2d024c Improve channel_rcv_data().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@678 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-03 17:49:56 +00:00
Andreas Schneider
06eceb3204 Improve channel_rcv_change_window().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@677 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-02 20:51:57 +00:00
Andreas Schneider
a7732ebbe5 Improve channel_from_msg().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@676 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-02 20:48:59 +00:00
Andreas Schneider
6538121494 Improve grow_window().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@675 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-02 20:47:19 +00:00
Andreas Schneider
0534fee674 Improve ssh_channel_from_local().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@674 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-02 20:46:10 +00:00
Andreas Schneider
c31893d246 Improve channel_open().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@673 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-02 20:41:21 +00:00
Andreas Schneider
f0b14c7b7a Improve ssh_channel_new_id().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@672 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-02 20:30:48 +00:00
Andreas Schneider
0b4159d1ec Fix the documentation.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@671 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-05-02 20:24:39 +00:00
Andreas Schneider
015b1649b1 Improve ssh_userauth_password().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@670 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:58:08 +00:00
Andreas Schneider
5b1c21593c Initialize the vars with NULL to prevent a segfault on error.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@669 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:53:42 +00:00
Andreas Schneider
2ed97906e3 Improve ssh_userauth_agent_pubkey().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@668 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:51:53 +00:00
Andreas Schneider
deb9d30f4d Improve ssh_userauth_pubkey().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@667 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:46:40 +00:00
Andreas Schneider
65d09f3268 Improve ssh_userauth_offer_pubkey().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@666 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:40:32 +00:00
Andreas Schneider
0881ba13d6 Improve ssh_userauth_none().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@665 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:34:36 +00:00
Andreas Schneider
83971c0188 Improve ssh_userauth_list().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@664 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:20:47 +00:00
Andreas Schneider
cc6199d9f0 Reformat ssh_auth_list().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@663 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:19:14 +00:00
Andreas Schneider
e8f783eb36 Improve wait_auth_status().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@662 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:18:44 +00:00
Andreas Schneider
a1802f1c32 Fix segfault.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@661 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:17:57 +00:00
Andreas Schneider
d680160500 Add a BURN_STRING macro and use it in auth.c.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@660 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:07:33 +00:00
Andreas Schneider
2317a58996 Improve ask_userauth().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@659 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 14:00:07 +00:00
Andreas Schneider
567cc5984a Improve the autopubkey authentication.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@658 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 13:58:20 +00:00
Andreas Schneider
06a0dea2ad Rename the symbol version map.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@657 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 09:47:57 +00:00
Andreas Schneider
982045bb96 Improve ssh_accept().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@656 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 09:07:12 +00:00
Andreas Schneider
c3ee07d747 Improve dh_handshake_server().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@655 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-30 09:04:15 +00:00
Andreas Schneider
fa63c0adee Improve server_set_kex().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@654 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 16:59:15 +00:00
Andreas Schneider
78ad279a43 Improve ssh_bind_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@653 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 11:55:43 +00:00
Andreas Schneider
e13c2871ff Improve ssh_bind_accept().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@652 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 11:54:32 +00:00
Andreas Schneider
f119a27bb6 Format ssh_bind options.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@651 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 11:49:44 +00:00
Andreas Schneider
23a55a0a0a Improve ssh_bind_listen().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@650 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 11:48:54 +00:00
Andreas Schneider
1cdc7c6e43 Format ssh_bind_set_options().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@649 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 11:47:18 +00:00
Andreas Schneider
5c662f6f6b Improve ssh_bind_new().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@648 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 11:46:51 +00:00
Andreas Schneider
afeaea318c Add more error checks to bind_socket().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@647 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 11:45:56 +00:00
Andreas Schneider
29035f952c Reorder the includes.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@646 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 11:40:02 +00:00
Andreas Schneider
3024e3652f Improve ssh_userauth_kbdint_getprompt.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@645 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 10:53:23 +00:00
Andreas Schneider
5fdcd4df7b Reformat ssh_userauth_kbdint functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@644 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 10:50:47 +00:00
Andreas Schneider
634a2d20b8 Improve ssh_userauth_kbdint.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@643 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 10:46:45 +00:00
Andreas Schneider
75fb96f740 Improve kbdauth_send.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@642 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 10:25:00 +00:00
Andreas Schneider
907b4075c0 Improve kbdauth_info_get.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@641 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 10:22:59 +00:00
Andreas Schneider
ddd1d62429 Improve kbdauth_init.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@640 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 10:09:16 +00:00
Andreas Schneider
84629a394e Improve kbdint_clean.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@639 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 10:04:32 +00:00
Andreas Schneider
c26fb22122 Improve kbdint_free.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@638 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 09:57:12 +00:00
Andreas Schneider
4cc2acda3a Improve kbdint_new.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@637 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-29 09:53:55 +00:00
Andreas Schneider
2c75ad7e19 Improve auto public key authentication.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@636 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-28 19:33:28 +00:00
Andreas Schneider
9f7d4d2d60 Improve ssh_write_knownhost.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@635 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-28 07:25:19 +00:00
Andreas Schneider
511213872b Improve ssh_is_server_known.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@634 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 18:21:12 +00:00
Andreas Schneider
8dbe59efde Improve match_hashed_host.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@633 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 18:08:46 +00:00
Andreas Schneider
b39fcd6470 Improve check_public_key().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@632 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 17:59:48 +00:00
Andreas Schneider
a19aebba18 Improve ssh_get_knownhost_line.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@631 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 17:52:09 +00:00
Andreas Schneider
b1e62ad22b Reformat sftp_handle_remove.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@630 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 12:01:40 +00:00
Andreas Schneider
9d270f99a7 Improve sftp_handle.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@629 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 12:00:42 +00:00
Andreas Schneider
315e5aca84 Improve sftp_handle_alloc.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@628 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:59:14 +00:00
Andreas Schneider
bf312c50a9 Improve sftp_reply_data and fix sftp_reply_status.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@627 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:54:47 +00:00
Andreas Schneider
52d20beb73 Improve sftp_reply_names.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@626 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:49:41 +00:00
Andreas Schneider
f11630ab68 Improve sftp_reply_names_add.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@625 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:46:41 +00:00
Andreas Schneider
f32e307899 Improve sftp_reply_attr.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@624 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:42:45 +00:00
Andreas Schneider
83142315da Improve sftp_reply_handle.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@623 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:41:08 +00:00
Andreas Schneider
db79fff00d Improve sftp_reply_name.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@622 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:39:25 +00:00
Andreas Schneider
5d23142599 Improve sftp_client_message_free.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@621 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:33:37 +00:00
Andreas Schneider
1f6341f549 Improve sftp_get_client_message.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@620 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:30:36 +00:00
Andreas Schneider
72aeba410f Don't set options again.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@619 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 11:00:32 +00:00
Andreas Schneider
c1c4f299ff Add option to build with or without sftp support.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@618 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:58:29 +00:00
Andreas Schneider
99946c7bcc Improve sftp_fstat.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@617 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:42:39 +00:00
Andreas Schneider
0eedebd84a Reformat sftp_stat and sftp_lstat.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@616 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:38:40 +00:00
Andreas Schneider
c1cd3b2974 Improve sftp_xstat().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@615 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:37:54 +00:00
Andreas Schneider
2b4efa171e Improve sftp_canonicalize_path().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@614 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:32:13 +00:00
Andreas Schneider
367f4b999a Reformat sftp_utimes().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@613 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:25:31 +00:00
Andreas Schneider
75c3996a49 Improve sftp_setstat().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@612 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:24:53 +00:00
Andreas Schneider
320c70a170 Improve sftp_rename().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@611 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:20:54 +00:00
Andreas Schneider
387f6473f7 Improve sftp_mkdir().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@610 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:14:59 +00:00
Andreas Schneider
4d80a1559a Improve sftp_rmdir().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@609 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:06:18 +00:00
Andreas Schneider
fd79249df6 Reformat the sftp_open() function.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@608 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-27 10:02:16 +00:00
Andreas Schneider
50616076c7 Improve sftp_unlink().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@607 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-24 12:57:11 +00:00
Andreas Schneider
4a383ab3cf Reformat sftp tell and seek functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@606 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-24 12:49:59 +00:00
Andreas Schneider
cefe239958 Improve the sftp seek functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@605 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-24 10:16:16 +00:00
Andreas Schneider
29e6f140fa Improve sftp_write().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@604 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-24 10:08:46 +00:00
Andreas Schneider
b0778ca169 Use a negative value for SSH_AGAIN.
This is needed for function which return the length read for example. If
we read only one byte then 1 would be returned and some function may
think that it has to read again.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@603 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-24 09:52:06 +00:00
Andreas Schneider
ac724eb3fb Improve the sftp async read functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@602 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-24 09:33:47 +00:00
Andreas Schneider
8ba57619fd Improve sftp_read().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@601 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-24 09:05:52 +00:00
Andreas Schneider
10ddf310a6 Improve sftp_closedir().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@600 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 15:15:02 +00:00
Andreas Schneider
5a84af65fa Improve sftp_close().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@599 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 15:10:59 +00:00
Andreas Schneider
5d689c2d29 Improve sftp_handle_close().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@598 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 15:08:34 +00:00
Andreas Schneider
baee8c17b5 Improve sftp_attributes_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@597 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 12:23:38 +00:00
Andreas Schneider
441929f8b8 Reformat sftp_dir_eof().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@596 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 12:21:30 +00:00
Andreas Schneider
75da135324 Reformat sftp_server_version().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@595 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 11:39:57 +00:00
Andreas Schneider
7592d9f42c Reformat sftp_parse_attr().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@594 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 11:38:55 +00:00
Andreas Schneider
62ac83a8ea Improve buffer_add_attributes() and add a return value.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@593 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 11:36:57 +00:00
Andreas Schneider
4ad9235805 Improve sftp_parse_attr_4().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@592 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 10:27:31 +00:00
Andreas Schneider
fbc6543c83 Improve sftp_parse_attr_4().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@591 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 09:37:28 +00:00
Andreas Schneider
cedc9d71c3 Improve sftp_opendir().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@590 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 09:09:36 +00:00
Andreas Schneider
39f8c7faab Map permission field to type field.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@589 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 09:07:18 +00:00
Andreas Schneider
8fecf4d74c Improve parse_handle_msg().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@588 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 07:13:25 +00:00
Andreas Schneider
b5bda67235 Fix a compile error.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@587 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 07:10:10 +00:00
Andreas Schneider
d62a43ee9d Improve status_msg_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@586 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 07:08:57 +00:00
Andreas Schneider
56e13b227f Improve parse_status_msg().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@585 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 07:06:07 +00:00
Andreas Schneider
a0b4b239fb Reformat sftp_get_new_id().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@584 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 06:59:18 +00:00
Andreas Schneider
4816afc9e8 Reformat sftp_dequeue().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@583 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-23 06:57:49 +00:00
Andreas Schneider
5be3a3c066 Improve sftp_enqueue().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@582 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 15:53:29 +00:00
Andreas Schneider
75eddb1ebb Improve request_queue_(new,free).
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@581 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 15:48:16 +00:00
Andreas Schneider
45d8248efb Improve sftp_init().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@580 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 15:41:14 +00:00
Andreas Schneider
47ff8d4679 Fix compile error.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@579 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 15:23:45 +00:00
Andreas Schneider
0f075f4d95 Improve sftp_packet_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@578 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 15:22:22 +00:00
Andreas Schneider
57a5c50a54 Add more error checks to sftp_read_and_dispatch().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@577 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 15:21:36 +00:00
Andreas Schneider
e99966772e Add more error checks to sftp_get_message().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@576 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 15:17:20 +00:00
Andreas Schneider
8a3c417e14 Improve sftp_message_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@575 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 15:09:54 +00:00
Andreas Schneider
e6c0155567 Add more error checks to sftp_message_new().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@574 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 15:06:28 +00:00
Andreas Schneider
ea59faaec9 Add more error checks to sftp_packet_read().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@573 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 14:52:04 +00:00
Andreas Schneider
6402559f28 Reformat sftp_packet_write().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@572 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 14:48:00 +00:00
Andreas Schneider
9766b2f8d2 Rename buffer_add_data_begin() to buffer_prepend_data().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@571 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 14:31:43 +00:00
Andreas Schneider
b875ce15e8 Add more error checks to sftp server init functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@570 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 14:05:11 +00:00
Andreas Schneider
f59630cbbc Improve sftp_new() and sftp_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@569 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-22 13:59:13 +00:00
Andreas Schneider
afe0c8b2b5 Use ctype to make alldigits simpler.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@568 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-20 14:09:21 +00:00
Andreas Schneider
e067061263 Improve publickey_from_file().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@567 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-20 09:14:35 +00:00
Andreas Schneider
9001a34cd3 Cleanup and add more error checks to _privatekey_from_file().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@566 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-20 08:58:08 +00:00
Andreas Schneider
2f51befc0f Add functions without any passphrase.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@565 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-20 08:42:42 +00:00
Andreas Schneider
03edd0ebb1 Cleanup and add more error checks to privatekey_from_file().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@564 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-20 08:11:24 +00:00
Andreas Schneider
9704df65e3 Rename privatekey_free() to be consistent with publickey_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@563 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-20 07:26:50 +00:00
Andreas Schneider
a3c820cf94 Add more error checks to read_dsa_privatekey().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@562 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-19 09:24:24 +00:00
Andreas Schneider
e6474a34c3 Add more error checks to read_rsa_privatekey().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@561 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-19 09:20:24 +00:00
Andreas Schneider
b7f93a4779 The description should be const.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@560 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-19 09:04:56 +00:00
Andreas Schneider
cc92391034 Add more error checks to privatekey_file_to_buffer().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@559 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-19 09:01:16 +00:00
Andreas Schneider
a1e154e9d5 Use POSIX return values and check them!
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@558 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-19 08:44:35 +00:00
Andreas Schneider
bfc428a0da Change back to a initialized variable and document ssh_finalize().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@557 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 16:19:24 +00:00
Andreas Schneider
44924db3e9 Add FIXME.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@556 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 15:57:23 +00:00
Andreas Schneider
ab8523a391 Fix gcrypt error if no auth callback has been set.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@555 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 15:56:36 +00:00
Andreas Schneider
460969a9ce Improve gcrypt private_key functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@554 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 15:22:59 +00:00
Andreas Schneider
5ef5841f99 Some minor improvements to passphrase_to_key().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@553 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 15:15:45 +00:00
Andreas Schneider
163fbfa44d Reformat asn1_check_sequence() and read_line().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@552 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 15:12:50 +00:00
Andreas Schneider
479744b146 Add more error checks to asn1_get_int().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@551 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 15:06:43 +00:00
Andreas Schneider
a58b7b93de Reformat some functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@550 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 14:56:56 +00:00
Andreas Schneider
c373e9bb03 Build with SSH1 and server by default.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@549 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 12:07:31 +00:00
Andreas Schneider
db2ff03392 Simplify signature_from_string() a bit.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@548 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 12:02:34 +00:00
Andreas Schneider
dc5ef34b54 Fix memleak in sample.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@547 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 11:24:35 +00:00
Andreas Schneider
f402e8d113 Add error checks to ssh_do_sign_with_agent() and fix a memleak.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@546 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 11:22:27 +00:00
Andreas Schneider
ff73826b45 Replace some strcmp with switch to make it a bit faster.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@545 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 11:18:35 +00:00
Andreas Schneider
95cd02c000 Make use of ssh_type_from_name().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@544 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 11:05:21 +00:00
Andreas Schneider
263b8d4f9c Some cleanup for publickey_to_string().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@543 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 10:59:53 +00:00
Andreas Schneider
d20ae18b00 Fix segfault with gcrypt.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@542 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 10:53:28 +00:00
Andreas Schneider
fa01372c88 Add more error checks to ssh_sign_session_id().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@541 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 09:57:20 +00:00
Andreas Schneider
9dab7771fa Fix a segfault if we try to a signature.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@540 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 09:47:22 +00:00
Andreas Schneider
038e6411da Add more error checks to RSA_do_sign().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@539 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 09:44:50 +00:00
Andreas Schneider
4308bb559c Add more error checks to signature_from_string().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@538 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 09:33:32 +00:00
Andreas Schneider
3df5a0dabe Add error checks to signature_to_string().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@537 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 09:14:44 +00:00
Andreas Schneider
192657d88c Add check for the return value of gcry_sexp_find_token().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@536 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 08:56:22 +00:00
Andreas Schneider
57a6388b82 Add more error checks to ssh_encrypt_rsa1().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@535 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 08:50:40 +00:00
Andreas Schneider
b9e91ce95a Add more error checks to ssh_do_sign().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@534 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 08:31:26 +00:00
Andreas Schneider
e4c521d896 Use a reference counter for the crypto functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@533 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-18 08:07:11 +00:00
Andreas Schneider
70b422d0fb Don't leak memory in publickey_make_* functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@532 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 18:30:25 +00:00
Andreas Schneider
91afe0de8a Revert commit 530.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@531 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 18:29:31 +00:00
Andreas Schneider
e85b16ae49 Don't leak memory in error path.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@530 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 18:26:59 +00:00
Andreas Schneider
a925c266ca Revert commit 527.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@529 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 18:22:53 +00:00
Andreas Schneider
c48d04b2c7 space_tokenize should be rewritten.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@528 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 14:56:44 +00:00
Andreas Schneider
44ab293f0b Don't leak memory.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@527 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 14:53:24 +00:00
Andreas Schneider
bf4d29b963 Fix memory leak.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@526 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 14:50:05 +00:00
Andreas Schneider
25e80032ba Don't leak memory in error path.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@525 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 14:47:53 +00:00
Andreas Schneider
7e3307cb44 Fix openSSL support.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@524 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 14:38:51 +00:00
Andreas Schneider
cf8e444764 Fix build with openssl.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@523 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 14:13:38 +00:00
Andreas Schneider
109c10bdfd Don't shadow a global variable.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@522 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 13:16:54 +00:00
Andreas Schneider
3216520b4c Reformat some of the code.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@521 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 13:13:14 +00:00
Andreas Schneider
09fdf0e8e6 Make the cipher table more readable.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@520 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 13:01:56 +00:00
Andreas Schneider
845615cdd8 Add return values to set_encrypt_key and set_decrypt_key.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@519 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 12:52:27 +00:00
Andreas Schneider
32fd37d1ad Reformat HMAC functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@518 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 12:03:59 +00:00
Andreas Schneider
42bdb90751 Reformat MD5 functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@517 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 11:59:17 +00:00
Andreas Schneider
2ed09734eb Cleanup SHA1 functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@516 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 08:37:28 +00:00
Andreas Schneider
b15a04e463 Improve sha1_init().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@515 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-17 08:31:59 +00:00
Andreas Schneider
2b12ffc820 Fix build warning.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@514 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 17:38:15 +00:00
Andreas Schneider
55d42b9c53 Fix typo.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@513 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 17:21:47 +00:00
Andreas Schneider
07506763ff Reformat signature_verify() and fix match check.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@512 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 17:15:50 +00:00
Andreas Schneider
55791d1fe6 Add more error checks to sig_verify().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@511 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 17:13:07 +00:00
Andreas Schneider
a2cce56134 Add a better match() function.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@510 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 16:20:32 +00:00
Andreas Schneider
59f04bfddd Add option to enable crypto debug output.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@509 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 15:47:15 +00:00
Andreas Schneider
5b2586312a Add return values to generate_session_keys() and generate_one_key().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@508 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 15:14:15 +00:00
Andreas Schneider
ac38bbc138 Free bignum_ctx in error path.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@507 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:58:40 +00:00
Andreas Schneider
a092a84139 Add return value to dh_build_k().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@506 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:55:38 +00:00
Andreas Schneider
c6eb54c39e Improve dh_import() functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@505 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:50:53 +00:00
Andreas Schneider
e8a9cb25fe Reformat some functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@504 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:46:34 +00:00
Andreas Schneider
08fcbdc97a Reformat make_string_bn().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@503 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:44:57 +00:00
Andreas Schneider
841de3439d Add memory error check to make_bignum_string().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@502 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:40:47 +00:00
Andreas Schneider
1a22d18afa Add return value to dh_generate_f().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@501 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:34:28 +00:00
Andreas Schneider
baf2eaf165 Add return value to dh_generate_e().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@500 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:31:06 +00:00
Andreas Schneider
ece047171a Add return value to dh_generate_y().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@499 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:27:50 +00:00
Andreas Schneider
5dc03728ed Add return value to dh_generate_x().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@498 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:24:13 +00:00
Andreas Schneider
50b701b4e4 Improve ssh_print_bignum().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@497 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:21:08 +00:00
Andreas Schneider
b246356ab5 Improve ssh_crypto_finalize().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@496 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:18:09 +00:00
Andreas Schneider
8f150afeeb Check return value of ssh_crypto_init().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@495 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:16:29 +00:00
Andreas Schneider
74a06555f6 Add a return value to ssh_socket_init().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@494 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:15:41 +00:00
Andreas Schneider
94021dcdb5 Add error checks to ssh_crypto_init().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@493 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:10:41 +00:00
Andreas Schneider
1ed7c90890 Revert commit 491.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@492 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 14:04:19 +00:00
Andreas Schneider
24fc1b2028 Make dh crypto functions thread safe.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@491 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 12:08:11 +00:00
Andreas Schneider
c608883205 Improve ssh_disconnect().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@490 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 08:53:57 +00:00
Andreas Schneider
c8269682fc Improve ssh_get_issue_banner().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@489 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 08:49:39 +00:00
Andreas Schneider
2bbb005980 Add more error checks to ssh_send_banner().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@488 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 08:46:46 +00:00
Andreas Schneider
a565f255f0 Add more error checks to ssh_connect().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@487 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 08:42:46 +00:00
Andreas Schneider
10dedee3ef Add more error checks to ssh_service_request().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@486 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 08:27:36 +00:00
Andreas Schneider
1ac6f38032 Add more error checks to dh_handshake().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@485 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 08:19:48 +00:00
Andreas Schneider
ea729492ec Reformat an document ssh_analyze_banner().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@484 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 07:56:16 +00:00
Andreas Schneider
160f6a08d0 Improve and document ssh_get_banner().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@483 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-16 07:49:44 +00:00
Andreas Schneider
1f1e9dc15b Add missing semicolon.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@482 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-15 08:13:10 +00:00
Andreas Schneider
4ca14e442c Improve packet_hmac_verify().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@481 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-15 08:11:33 +00:00
Andreas Schneider
367fd0cb35 Improve packet_encrypt().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@480 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-15 08:04:33 +00:00
Andreas Schneider
c50da458d1 Improve packet_decrypt().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@479 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-15 07:59:07 +00:00
Andreas Schneider
576187c686 Reformat packet_decrypt_len().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@478 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-15 07:56:57 +00:00
Andreas Schneider
af454c0f34 Improve ssh_get_version().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@477 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:54:20 +00:00
Andreas Schneider
317e90c1c1 Improve ssh_get_disconnect_message().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@476 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:52:50 +00:00
Andreas Schneider
8e34f0cf0c Improve ssh_get_status().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@475 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:50:11 +00:00
Andreas Schneider
16084e548e Cleanup ssh_handle_packets().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@474 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:46:04 +00:00
Andreas Schneider
118d4ee131 Add error checks to setter.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@473 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:40:50 +00:00
Andreas Schneider
c847e13c47 Only compile SSHv1 files if enabled.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@472 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:33:04 +00:00
Andreas Schneider
7f06a999e3 Reformat the remaining socket functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@471 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:30:12 +00:00
Andreas Schneider
cd5588aa75 Add more error checks to ssh_socket_blocking_flush().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@470 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:27:58 +00:00
Andreas Schneider
f6e3f1d985 Add more error checks to ssh_socket_nonblocking_flush().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@469 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:24:41 +00:00
Andreas Schneider
7eeb47ffad Reformat ssh_socket_poll().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@468 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:19:35 +00:00
Andreas Schneider
d36a208849 Add more error checks to ssh_socket_wait_for_data().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@467 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:12:50 +00:00
Andreas Schneider
fc1cba4407 Add error checks to ssh_socket_write().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@466 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:05:16 +00:00
Andreas Schneider
f2788c9866 Reformat ssh_socket_completewrite() and use const for buffer.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@465 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 14:02:37 +00:00
Andreas Schneider
e29ef25cdd Reformat socket functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@464 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 13:59:18 +00:00
Andreas Schneider
639e924ef5 Reformat some socket functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@463 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 13:50:55 +00:00
Andreas Schneider
4174577db3 Use consistend return values for packet_wait() functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@462 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 09:37:22 +00:00
Andreas Schneider
6ec84bfc2e Add more error checks to packet_parse().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@461 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 09:26:25 +00:00
Andreas Schneider
13dcfa6bfc Add more error checks to packet_send1().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@460 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 09:14:09 +00:00
Andreas Schneider
02ebbfdeca Add more error checks to packet_send2().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@459 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 09:05:57 +00:00
Andreas Schneider
749e95cbf1 Format packet_write().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@458 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 08:58:11 +00:00
Andreas Schneider
68710f3967 Format packet_flush().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@457 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 08:56:44 +00:00
Andreas Schneider
22b3122c6c Use consistent return values for packet_translate().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@456 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 08:55:33 +00:00
Andreas Schneider
640cf4cc93 Add more error checks to packet_read1().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@455 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-14 08:47:37 +00:00
Andreas Schneider
e0ae9635ea Add more error checks to packet_read2().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@454 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-10 09:26:18 +00:00
Andreas Schneider
e4624d6ed7 Cleanup misc functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@453 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-10 09:06:27 +00:00
Andreas Schneider
c841e984ba Add error checking to ssh message type functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@452 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-10 09:00:35 +00:00
Andreas Schneider
234844230c Add more error checks to ssh_message_get().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@451 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-10 08:55:31 +00:00
Andreas Schneider
a7b70bc9ee Add error checking to ssh_message_channel_request_reply_default().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@450 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 20:40:14 +00:00
Andreas Schneider
2a118371fa Add error checking to ssh_message_channel_request_reply_success().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@449 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 20:35:51 +00:00
Andreas Schneider
e954d54215 Add error checking to handle_channel_request().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@448 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 15:40:43 +00:00
Andreas Schneider
3ad76af469 Add error checking to ssh_message_channel_request_open_reply_default().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@447 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 15:29:13 +00:00
Andreas Schneider
926375e8aa Add error checking to ssh_message_channel_request_open_reply_accept().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@446 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 14:33:12 +00:00
Andreas Schneider
a8bb3024e8 Add error checking to handle_channel_request_open().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@445 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 14:28:23 +00:00
Andreas Schneider
38d8875021 Add error checking to ssh_message_auth_reply_success().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@444 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 14:24:49 +00:00
Andreas Schneider
e5b7e8fdfc Add error checks to ssh_message_auth_reply_default().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@443 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 14:22:29 +00:00
Andreas Schneider
3fab89b22f Improve ssh_message_auth* functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@442 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 11:07:31 +00:00
Andreas Schneider
61bee4c60c Add more error checks to handle_userauth_request().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@441 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 11:03:08 +00:00
Andreas Schneider
04ab5c1b82 Improve ssh_message_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@440 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 10:31:12 +00:00
Andreas Schneider
e9a7d98eac Add return value to handle_unimplemented().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@439 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 10:23:23 +00:00
Andreas Schneider
1715736f0f Add more error checks to handle_service_request().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@438 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 10:20:54 +00:00
Andreas Schneider
38176a753e Reformat message_new().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@437 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-09 10:16:49 +00:00
Andreas Schneider
89aac630ee Fix return value.
Thanks to Norbert Kiesel <nkiesel@tbdnetworks.com> for the patch.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@436 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 20:29:48 +00:00
Andreas Schneider
abf9ccdc5c Fix build error in SSHv1 channel code.
Thanks to Norbert Kiesel <nkiesel@tbdnetworks.com> for the patch.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@435 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 20:28:59 +00:00
Andreas Schneider
40ddc76e62 Add error checking to publickey to string functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@434 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 14:57:38 +00:00
Andreas Schneider
8333393470 Add error checking to publickey_from_privatekey().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@433 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 13:27:39 +00:00
Andreas Schneider
89670904c0 Add error checking to publickey_from_string().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@432 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 13:11:26 +00:00
Andreas Schneider
29c57bab33 Add error checking to publickey_make_rsa().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@431 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 13:03:50 +00:00
Andreas Schneider
da1eee8c89 Fix header functions and add return value checks.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@430 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 12:56:12 +00:00
Andreas Schneider
8948bf41f1 Add error checking to publickey_make_dss().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@429 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 12:52:32 +00:00
Andreas Schneider
befca1dc8a Add return values and error checking to SSHv1 channel functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@428 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 12:40:42 +00:00
Andreas Schneider
83f481981d Add error checking to SSHv1 auth functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@427 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 10:45:30 +00:00
Andreas Schneider
4f6fd0c451 Improve SSHv1 key exchange functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@426 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 08:40:29 +00:00
Andreas Schneider
faa83b2380 Fix SSHv1 channel window problems.
Thanks to Norbert Kiesel <nkiesel@tbdnetworks.com> for the patch.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@425 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 07:19:45 +00:00
Andreas Schneider
38d86e7e17 Fix SSHv1 compile errors.
Thanks to Norbert Kiesel <nkiesel@tbdnetworks.com> for the patch.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@424 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-08 07:13:18 +00:00
Andreas Schneider
c4f65cb5dd Add error checking for make_rsa1_string().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@423 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 19:50:41 +00:00
Andreas Schneider
586ed9103f Add return value and error checks to ssh_send_kex().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@422 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 19:37:45 +00:00
Andreas Schneider
d51dc0d80e Add more error checks to ssh_get_kex().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@421 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 19:27:50 +00:00
Andreas Schneider
efc3c494cc Add error checking to all gzip functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@420 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 19:07:20 +00:00
Andreas Schneider
8c05aab03d Add return value and error checking for hash buffer cookie functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@419 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 18:46:29 +00:00
Andreas Schneider
323ee63a1d Add return value and error checks to make_sessionid().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@418 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 18:38:09 +00:00
Andreas Schneider
1e52650dbf Fix typo.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@417 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 18:37:41 +00:00
Andreas Schneider
7c6f1be5ea Add my copyright.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@416 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 15:11:24 +00:00
Andreas Schneider
f84585ea2f Check for buffer_add_* return values in channel functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@415 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 15:10:47 +00:00
Andreas Schneider
aea8587586 Add return values and error checking to channel_default_bufferize().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@414 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 14:10:45 +00:00
Andreas Schneider
8d3a43db7a Improve channel_new().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@413 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 14:02:24 +00:00
Andreas Schneider
7059e05a2a Check return values of buffer functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@412 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 13:57:17 +00:00
Andreas Schneider
fe2bc30984 Fix a memory leak in realloc_buffer.
If realloc fails, the original block is left untouched. So
don't overwrite it that we can free it.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@411 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 13:48:34 +00:00
Andreas Schneider
d1fefb4de3 Check return values of buffer_add_* and packet_send functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@410 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-07 13:40:40 +00:00
Andreas Schneider
cd3dd624b3 Check return values of buffer_add_* functions in agent code.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@409 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 18:38:56 +00:00
Andreas Schneider
8d6d96657a Fix build warnings on x86_64.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@408 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 18:36:15 +00:00
Andreas Schneider
6c6094538f Use const where it should be used.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@407 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 11:26:34 +00:00
Andreas Schneider
db4ff30f38 Make use of const.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@406 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:59:16 +00:00
Andreas Schneider
8253e2170e Fix build warnings found with printf checking of ssh_set_error().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@405 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:43:59 +00:00
Andreas Schneider
2aeeb5a518 Add printf checking for ssh_set_error().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@404 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:39:08 +00:00
Andreas Schneider
c8265940ea Make return of ssh_get_error() const.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@403 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:38:30 +00:00
Andreas Schneider
6492e3e69c Fix build warning.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@402 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:34:02 +00:00
Andreas Schneider
081e81b813 Fix build warnings.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@401 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:32:08 +00:00
Andreas Schneider
688ac9382f Don't shadow a global variable declaration in unistd.h.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@400 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:29:48 +00:00
Andreas Schneider
1dc12b9cc5 Fix varable name.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@399 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:22:46 +00:00
Andreas Schneider
01e789184a Don't shadow a global variable declaration on unistd.h.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@398 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:15:57 +00:00
Andreas Schneider
58fd38cd90 Fix a build warning.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@397 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:12:25 +00:00
Andreas Schneider
f8ef75c510 Fix build warnings.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@396 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 10:00:41 +00:00
Andreas Schneider
b7c65baef3 Fix build warnings in key exchange functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@395 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 09:46:47 +00:00
Andreas Schneider
139eb4696c Fix build warnings, mostly const chars.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@394 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 09:41:54 +00:00
Andreas Schneider
ef1a41efcf Fix compile warning (const).
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@393 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 09:24:53 +00:00
Andreas Schneider
dbab7b5a18 Make service name const.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@392 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 09:18:29 +00:00
Andreas Schneider
b239fda60c Fix compile warning.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@391 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 09:16:15 +00:00
Andreas Schneider
f286e8c9b0 Don't shadow global variable sftp.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@390 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-05 09:10:48 +00:00
Andreas Schneider
f7959bd5eb Improve free functions of the keyfiles.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@389 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-04 14:38:39 +00:00
Andreas Schneider
226e48b4b7 Improve channel_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@388 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-04 14:27:59 +00:00
Andreas Schneider
a7fbedf8d6 Improve crypto free functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@387 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-04 14:15:14 +00:00
Andreas Schneider
b3a0c6d9cb Improve key free functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@386 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-04 13:55:32 +00:00
Andreas Schneider
1100a22e98 Improve ssh_cleanup().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@385 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 13:00:35 +00:00
Andreas Schneider
18bce1e209 Add NULL check to ssh_message_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@384 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 12:58:32 +00:00
Andreas Schneider
30d1bf863e Add NULL check to private_key_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@383 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 12:57:19 +00:00
Andreas Schneider
0e82ddbd81 Add NULL check for agent_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@382 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 12:52:34 +00:00
Andreas Schneider
b5eb33bb69 Improve ssh_socket_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@381 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 12:50:17 +00:00
Andreas Schneider
2791ce7e01 Add NULL checks to crypto free functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@380 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 12:48:45 +00:00
Andreas Schneider
8485c87cf2 Remove files which aren't in use anymore.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@379 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 09:22:05 +00:00
Andreas Schneider
5a75c0fd78 Don't leak memory in agent_new() error path.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@378 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 08:41:34 +00:00
Andreas Schneider
41dd2a2a3b Check return values of option setter.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@377 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 08:38:33 +00:00
Andreas Schneider
2aa81c0544 Add memory error checks for strdup().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@376 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 08:31:28 +00:00
Andreas Schneider
0856ba3008 Add memory error checks.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@375 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 08:29:36 +00:00
Andreas Schneider
8d66a455f7 Add my copyright.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@374 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 08:24:33 +00:00
Andreas Schneider
a4d98b58fc Improve the documentation of ssh_options_getopt().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@373 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 08:23:29 +00:00
Andreas Schneider
497c31d9a0 Improve ssh_options_getopt().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@372 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 08:19:57 +00:00
Andreas Schneider
4db7fc77ff Improve and document ssh_options_set_[dsa,rsa]_server_key().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@371 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-03 07:47:50 +00:00
Andreas Schneider
3b7940d05e Improve ssh_options_set_auth_callback().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@370 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 21:37:48 +00:00
Andreas Schneider
2afc8a4f1c Improve ssh_options_set_log_verbosity().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@369 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 16:33:28 +00:00
Andreas Schneider
da65ee4dbb Improve ssh_options_set_log_function().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@368 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:42:45 +00:00
Andreas Schneider
0dee533531 Improve ssh_options_allow_ssh2().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@367 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:39:49 +00:00
Andreas Schneider
396db49a41 Improve ssh_options_allow_ssh1().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@366 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:37:45 +00:00
Andreas Schneider
94e91b73f7 Fix typo.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@365 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:35:13 +00:00
Andreas Schneider
115450ac9b Improve ssh_options_set_timeout().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@364 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:34:55 +00:00
Andreas Schneider
eb461d1dbe Improve ssh_options_set_status_callback().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@363 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:32:03 +00:00
Andreas Schneider
cfea89fb7c Improve ssh_options_default_known_hosts_file().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@362 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:26:44 +00:00
Andreas Schneider
5309651849 Improve ssh_options_default_ssh_dir().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@361 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:25:02 +00:00
Andreas Schneider
30b02325cb Improve ssh_options_default_username().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@360 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:22:28 +00:00
Andreas Schneider
1fceffa434 Improve ssh_options_set_wanted_algos().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@359 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:19:51 +00:00
Andreas Schneider
3f4c1976fd Improve ssh_options_set_banner().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@358 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:14:27 +00:00
Andreas Schneider
a459a8b4db Improve ssh_options_set_identity().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@357 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:10:50 +00:00
Andreas Schneider
4d203e8420 Fix memory leaks.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@356 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:07:06 +00:00
Andreas Schneider
5ba2acde0a Improve ssh_options_set_known_hosts_file().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@355 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:04:56 +00:00
Andreas Schneider
9ea6ea581d Improve ssh_options_set_ssh_dir().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@354 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 12:00:45 +00:00
Andreas Schneider
4373fc64e3 Improve ssh_options_set_bind().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@353 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 11:56:13 +00:00
Andreas Schneider
b6fbe97f24 Improve ssh_options_set_fd().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@352 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 11:53:24 +00:00
Andreas Schneider
d86ac9e04b Improve ssh_options_set_port().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@351 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 11:50:23 +00:00
Andreas Schneider
71913c8fea Add missing argument checks for options.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@350 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 11:47:06 +00:00
Andreas Schneider
8de3dc44ca Improve ssh_options_set_username().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@349 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 10:18:01 +00:00
Andreas Schneider
ab54736b5d Make ssh_options_free() documentation public.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@348 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 10:14:09 +00:00
Andreas Schneider
6026de4648 Improve ssh_options_set_host().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@347 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 10:13:12 +00:00
Andreas Schneider
a9ef024f10 Make ssh_options_free() public.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@346 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 10:09:23 +00:00
Andreas Schneider
595a5d9ff2 Improve ssh_options_copy() and ssh_options_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@345 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 09:58:59 +00:00
Andreas Schneider
356a8a7631 Add error checking for strdup.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@344 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 09:35:41 +00:00
Andreas Schneider
9f581a2809 Add error checking of strdup.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@343 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 09:32:22 +00:00
Andreas Schneider
d60783eeb7 Improve ssh_send_banner() and add error checking of strdup.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@342 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 09:31:02 +00:00
Andreas Schneider
ae4265d304 Add a return value to ssh_userauth_kbdint_setanswer().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@341 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 09:24:46 +00:00
Andreas Schneider
ee3b641fb1 Cleanup todo's.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@340 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 08:36:32 +00:00
Andreas Schneider
c195e0fa7d There is no file to close here.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@339 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 08:33:04 +00:00
Andreas Schneider
f8d5bb9785 Fix string_new().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@338 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 08:32:30 +00:00
Andreas Schneider
3a67aaa428 Improve the ssh_get_pubkey_hash() function.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@337 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 07:31:54 +00:00
Andreas Schneider
4c84a3e0f2 Simply return 0.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@336 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-02 07:31:12 +00:00
Andreas Schneider
ff0f8b7608 Use memset cause something is wrong with the macro.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@335 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 22:33:35 +00:00
Andreas Schneider
9ff4afa523 Fix ssh connection.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@334 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 22:16:33 +00:00
Andreas Schneider
10397d44db Add one missing memory error check in crypt.c.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@333 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 21:30:53 +00:00
Andreas Schneider
fc73b0b33f Add NULL check to buffer free.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@332 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 21:29:04 +00:00
Andreas Schneider
7b464d4e15 Improve ssh_new().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@331 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 21:27:54 +00:00
Andreas Schneider
891539af6c Add memory error checks for crypto wrapper functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@330 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 21:24:16 +00:00
Andreas Schneider
1b627b3867 More memory error checks for ssh_socket_new().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@329 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 20:24:09 +00:00
Andreas Schneider
b06c167775 Fix memory error checking in socket functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@328 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 20:18:31 +00:00
Andreas Schneider
ace6eed6c0 Add memory error checking for sftpserver functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@327 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 20:14:43 +00:00
Andreas Schneider
cde3151634 Fix typo.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@326 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 20:14:24 +00:00
Andreas Schneider
cd4df00dff Add memory error checks for sftp functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@325 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 20:09:20 +00:00
Andreas Schneider
b2e50e8967 Add memory error checks for server functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@324 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 20:01:44 +00:00
Andreas Schneider
2c3e423480 Add memory error checking for packet functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@323 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 19:59:17 +00:00
Andreas Schneider
8bcd65193c Added memory error checks for option functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@322 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 19:54:41 +00:00
Andreas Schneider
54ce86e3b1 Added memory error checks for message functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@321 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 19:44:19 +00:00
Andreas Schneider
904a5b2f7c Fix memory error checking in key functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@320 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 19:34:26 +00:00
Andreas Schneider
ddd10236bd Add memory error checking to keyfile functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@319 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 11:03:06 +00:00
Andreas Schneider
b4c65e41f6 Fix build warning.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@318 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 10:50:12 +00:00
Andreas Schneider
79e9eb53d4 Add memory error checking to key exchange functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@317 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 10:49:27 +00:00
Andreas Schneider
10afd9818c Check for memory allocation errors.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@316 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 10:23:52 +00:00
Andreas Schneider
186667724a Fix build warnings.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@315 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 10:22:14 +00:00
Andreas Schneider
f80efcc260 Add checks for memory errors in channel functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@314 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 10:14:26 +00:00
Andreas Schneider
2634f45e11 Check for errors of memory allocation.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@313 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 10:05:15 +00:00
Andreas Schneider
98f78e1102 Add error checking to buffer functions.
We don't check arguments cause we want a segfault here.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@312 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 09:36:44 +00:00
Andreas Schneider
8758b1260b Fix segfaults in string.c.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@311 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 09:28:21 +00:00
Andreas Schneider
04d916f3aa Add arg and error checking for the string functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@310 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-04-01 08:37:26 +00:00
Andreas Schneider
15d0dc7a4e Fix sources list of libssh.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@309 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-30 16:36:28 +00:00
Andreas Schneider
ae4ef84702 Create a ssh_get_hexa function.
This function converts a buffer into a colon separated hex string.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@308 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-30 13:11:47 +00:00
Aris Adamantiadis
1fd7a875be Fixed memory leak and file descriptor leak in known host parsing
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@307 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-29 20:29:55 +00:00
Andreas Schneider
07d748ef5e Remove automake files.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@306 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-29 20:25:59 +00:00
Andreas Schneider
3441e77ddc Normalize the license in all files and add vim tab instructions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@305 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-29 20:19:18 +00:00
Andreas Schneider
84430b2277 Improve the lowercase function and free memory allocated by lowercase().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@304 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-29 15:19:45 +00:00
Aris Adamantiadis
4ab28a049f openssh Hashed host support !
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@303 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-29 00:31:36 +00:00
Aris Adamantiadis
3090d104cf Working new known_host algorithm
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@302 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 23:43:17 +00:00
Andreas Schneider
75d5bb457f Fix typos.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@301 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 22:34:51 +00:00
Andreas Schneider
6aff00e762 Ignore build files.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@300 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 22:24:26 +00:00
Andreas Schneider
2b07dcd1e3 Try to fix build file ignores.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@299 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 22:23:19 +00:00
Andreas Schneider
affe522b25 Ignore build, cscope and ctags files.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@298 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 22:22:45 +00:00
Andreas Schneider
f16cabc73e Undo the remove of the Doxyfiles.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@297 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 22:20:54 +00:00
Andreas Schneider
39a5b53eb5 Update INSTALL file.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@296 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 22:06:36 +00:00
Andreas Schneider
fc8ad69f5c Remove autotools and win32 specific files.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@295 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 22:01:05 +00:00
Andreas Schneider
78b6e25ede Fix compilation of the server with option turned off.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@294 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 21:58:54 +00:00
Andreas Schneider
e02a6e0225 Add WITH_SERVER option.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@293 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 21:56:28 +00:00
Andreas Schneider
fce4840c77 Fix SSH1 support.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@292 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 21:52:15 +00:00
Andreas Schneider
117fc43b69 Add myself to the authors file.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@291 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 21:48:04 +00:00
Andreas Schneider
01c0877495 Fix the name of the SSH1 support.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@290 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 21:44:36 +00:00
Andreas Schneider
33b948cab9 Add an option WITH_LIBZ to compile with zlib support.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@289 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 21:43:53 +00:00
Andreas Schneider
d3d7f08d6a Fix zlib detection.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@288 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-28 21:14:45 +00:00
Andreas Schneider
3b38c66b3d Fix possible precedence problems.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@287 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-26 23:00:53 +00:00
Andreas Schneider
390d9e53dc Fix win32 builds.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@286 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-25 16:17:11 +00:00
Andreas Schneider
fae68cac8a Add an option to build a static library.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@285 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-25 15:01:33 +00:00
Andreas Schneider
cf89b6eb48 Change the name of the doxygen group to match the others.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@284 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-21 09:56:29 +00:00
Andreas Schneider
9249006e64 Add a ssh_version function.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@283 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-21 09:29:31 +00:00
Andreas Schneider
c9818a9948 Fix doxygen generation.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@282 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-21 09:11:13 +00:00
Laurent Bigonville
e4d16db116 Use my debian.org address in Uploaders and takeover the package
with Jean-Philippe permission

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@281 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-18 16:24:23 +00:00
Laurent Bigonville
98711e9d0f debian/libssh-2-doc.doc-base: Fix doc-base-uses-applications-section
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@280 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-18 16:15:04 +00:00
Laurent Bigonville
6bda3c7466 Use my debian.org address in Uploaders
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@279 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-18 16:09:58 +00:00
Laurent Bigonville
139f59ec62 Add ${misc:Depends} to please lintian
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@278 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-18 16:05:33 +00:00
Laurent Bigonville
2ab6894132 Use debug section for -dbg package
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@277 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-18 16:02:53 +00:00
Andreas Schneider
63cff85b1a Fix compile warnings.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@276 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-18 09:27:08 +00:00
Andreas Schneider
0151b6e170 Fix build with cmake >= 2.6.3. -D does not overwrite FORCE.
Patch by Jim McDonough <jmcd@samba.org>


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@275 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-18 09:26:51 +00:00
Andreas Schneider
ee54acb417 Don't require C++ compiler.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@274 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-17 22:04:16 +00:00
Andreas Schneider
08e2408896 Fix build warnings.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@273 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-14 15:14:18 +00:00
Andreas Schneider
453b91903b Enable printf attribute checking on GNU systems.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@272 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-14 11:20:55 +00:00
Andreas Schneider
5681c542f6 R.I.P. ssh_say()
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@271 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-12 15:55:08 +00:00
Andreas Schneider
fe5f283c48 Get rid of ssh_say in the sample ssh client.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@270 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-12 15:52:17 +00:00
Andreas Schneider
05495a263a Use ssh_log instead of ssh_say in ssh_list_kex().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@269 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-12 15:45:38 +00:00
Andreas Schneider
40bce93e97 Get rid of a ssh_say.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@268 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-12 15:29:34 +00:00
Andreas Schneider
4d889e0af0 Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@267 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-12 15:28:57 +00:00
Andreas Schneider
49c88c2cd7 Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@266 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 12:20:47 +00:00
Andreas Schneider
1d3eeda7f9 Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@265 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 11:54:36 +00:00
Andreas Schneider
fe98c015e9 Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@264 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 11:07:57 +00:00
Andreas Schneider
d347b7e00f Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@263 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 10:52:37 +00:00
Andreas Schneider
f99fefc587 Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@262 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 10:49:04 +00:00
Andreas Schneider
eced7fb958 Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@261 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 10:30:15 +00:00
Andreas Schneider
1486d844e7 Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@260 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 10:22:28 +00:00
Andreas Schneider
78273fe5c5 Fix build.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@259 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 10:22:14 +00:00
Andreas Schneider
3247a7683a Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@258 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 09:56:58 +00:00
Andreas Schneider
39a8009e78 Remove ssh_say.
Aris, how should we print an error?


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@257 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 09:53:56 +00:00
Andreas Schneider
081adeb3d6 Replace ssh_say with ssh_log.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@256 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 09:52:01 +00:00
Andreas Schneider
1edc164265 Fix compiler warning about unused variable.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@255 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 09:31:50 +00:00
Andreas Schneider
acb4e37957 Fix compiler warnings in keyfile.c.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@254 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-11 09:29:21 +00:00
Andreas Schneider
02f2511985 Fix NSIS installer creation.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@253 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-10 13:51:26 +00:00
Andreas Schneider
a800db80e4 Add NSIS generator for CPack.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@252 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 16:11:56 +00:00
Andreas Schneider
ec0c1ef63b Add NSIS support.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@251 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 14:53:57 +00:00
Andreas Schneider
b4cebfb03d Fix compilation and installation of libssh.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@250 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 14:05:41 +00:00
Andreas Schneider
461d9413d3 Fix build warnings.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@249 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 14:05:10 +00:00
Andreas Schneider
cf1e7fa836 Fix cross compilation errors.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@248 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 13:35:34 +00:00
Andreas Schneider
14580705d5 Set needed functions on Windows to true for now.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@247 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 13:32:28 +00:00
Andreas Schneider
6ab119d8dc Fix cross compilation.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@246 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 13:31:35 +00:00
Andreas Schneider
f0b2c39d2f Fix crypto/gcrypt detection and prepare for cross compilation.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@245 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 12:11:10 +00:00
Andreas Schneider
814cde9069 Find zlib of cross mingw.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@244 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 12:10:07 +00:00
Andreas Schneider
851560426f Fix build warnings.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@243 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 12:09:22 +00:00
Andreas Schneider
facc434ce4 Add missing include file.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@242 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 12:06:04 +00:00
Andreas Schneider
4b8eb38586 Fix build errors.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@241 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 12:05:11 +00:00
Andreas Schneider
d3e64a744e Fix build on Windows.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@240 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 09:54:38 +00:00
Andreas Schneider
fad349fecd Fix version number.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@239 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 09:50:41 +00:00
Andreas Schneider
e1a1796783 Fix build on Windows.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@238 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-03-08 09:48:31 +00:00
Andreas Schneider
b9e6ce934d Rename function to set sftp error to be consistent.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@237 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-09 13:13:52 +00:00
Andreas Schneider
5ea8088938 Rename function to agent_is_running.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@236 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-09 12:56:58 +00:00
Andreas Schneider
7ceaf5c43a Fix the ifdefs.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@235 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-06 13:37:43 +00:00
Andreas Schneider
f4bbc45bbe Add missing ifdef for ssh-agent support.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@234 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-06 12:51:37 +00:00
Andreas Schneider
ff19095415 Fix build warnings in server sample.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@233 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-06 09:59:54 +00:00
Andreas Schneider
b8c78bdb5a Fix build warnings in client sample.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@232 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-06 09:58:44 +00:00
Andreas Schneider
73cde232be Complete ssh client agent support.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@231 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-06 09:46:10 +00:00
Aris Adamantiadis
53226f98f2 exit-status should be -1 when undefined
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@230 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-04 19:21:20 +00:00
Aris Adamantiadis
22b422995f adding error status in samplessh
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@229 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-04 19:18:06 +00:00
Aris Adamantiadis
ac3d66ac69 channel_get_exit_status()
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@228 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-03 18:07:26 +00:00
Aris Adamantiadis
903e22cd11 added logging for exit-status
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@227 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-03 17:54:27 +00:00
Andreas Schneider
0679dd4fd8 Fix typo.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@226 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-03 17:24:56 +00:00
Andreas Schneider
8eaecdc7b8 Update doxygen config file for user documentation.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@225 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-03 12:27:47 +00:00
Andreas Schneider
cfbc063dd3 Add a 'make doc' target to create doxygen documentation.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@224 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-03 10:43:45 +00:00
Andreas Schneider
81de36e923 Moved ssh_crypto_init to priv.h file and added a note.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@223 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 17:14:38 +00:00
Andreas Schneider
a80ad5cbd3 Remove deprecated pubkey_get_hash function.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@222 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 17:08:13 +00:00
Andreas Schneider
69a1fac7a1 Fix build warnings in the crypto wrapper functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@221 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 17:00:04 +00:00
Andreas Schneider
1fd6a2e9e0 Fix build warnings in socket code.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@220 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 16:56:31 +00:00
Andreas Schneider
9414b53bef Return count if the write was successful.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@219 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 16:49:05 +00:00
Andreas Schneider
5f58fc773c Fix build warnings in sftp code.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@218 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 16:47:51 +00:00
Andreas Schneider
3991b3a3aa Fix the build.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@217 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 16:22:07 +00:00
Andreas Schneider
58404116bc Fix build warnings in session code.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@216 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 16:20:55 +00:00
Andreas Schneider
8c60d864c7 Fix build warings in the server code.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@215 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 16:17:02 +00:00
Andreas Schneider
974a160fd3 Fix several build warnings.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@214 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 16:09:38 +00:00
Andreas Schneider
5e03a95a93 Fix compiler warnings.
Aris please check if ssh_crypto_init, ssh_crypto_finalize and
pubkey_get_hash could be removed.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@213 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 15:45:48 +00:00
Andreas Schneider
5db7ec356b Make ssh_connect_ai_timeout static.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@212 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 15:41:00 +00:00
Andreas Schneider
5d798f6225 Use unsigned values for length in buffer functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@211 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 15:39:09 +00:00
Andreas Schneider
7250e03f97 Fix build warnings in channel code.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@210 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 15:35:39 +00:00
Andreas Schneider
948c3f1bef The string_len function should return unsigned int.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@209 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 15:22:26 +00:00
Andreas Schneider
55c7cc6839 Fix compiler warning in client.c.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@208 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 15:19:44 +00:00
Andreas Schneider
ddf4a8e9c9 Make ssh_analyze_banner static as it is only used in this file.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@207 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 15:16:33 +00:00
Andreas Schneider
f4d74e285e Fix compiler warnings in buffer implementation.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@206 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 15:14:19 +00:00
Andreas Schneider
fc0928a572 Fix build warnings of the auth code.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@205 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 15:01:18 +00:00
Andreas Schneider
ed53a70854 Make the build_make shell script executable.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@204 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 14:50:44 +00:00
Andreas Schneider
460d0b402b Add Makefiles for the CMake build system.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@203 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 14:44:46 +00:00
Andreas Schneider
2347065481 Add missing agent files.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@202 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 14:43:48 +00:00
Andreas Schneider
4259c9195c Cleanup the define check in the libssh header file.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@201 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 14:42:40 +00:00
Andreas Schneider
70aa33c041 Start with ssh agent implementation.
This is work in progress.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@200 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-02-02 14:41:44 +00:00
Andreas Schneider
944084964a Add extern C declatrion to server header file.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@199 7dcaeef0-15fb-0310-b436-a5af3365683c
2009-01-08 17:48:35 +00:00
Andreas Schneider
f9f8ded7f0 Add a more generic auth callback function.
You should be able to obtain passwords or usernames with this
function.

Signed-off-by: Andreas Schneider <mail@cynapses.org>


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@198 7dcaeef0-15fb-0310-b436-a5af3365683c
2008-12-29 11:33:51 +00:00
Andreas Schneider
6ea3888054 Change version numbers to 0.3.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@197 7dcaeef0-15fb-0310-b436-a5af3365683c
2008-12-22 13:44:55 +00:00
Andreas Schneider
b11ddd23b2 Add doxygen documentation for all public sftp functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@196 7dcaeef0-15fb-0310-b436-a5af3365683c
2008-12-22 09:51:31 +00:00
Andreas Schneider
c3e026c303 Create POSIX like sftp functions.
This breaks the API and will be libssh 0.3.


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@195 7dcaeef0-15fb-0310-b436-a5af3365683c
2008-12-22 09:50:40 +00:00
142 changed files with 32987 additions and 14274 deletions

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
.*
*.swp
*~$
build
cscope.*
tags

View File

@@ -1,5 +1,7 @@
Author(s):
Aris Adamantiadis <aris (at) 0xbadc0de (dot) be> (project initiator)
Aris Adamantiadis <aris@0xbadc0de.be> (project initiator)
Andreas Schneider <mail@cynapses.org> (developer)
Nick Zitzmann <seiryu (at) comcast (dot) net> (mostly client SFTP stuff)

78
CMakeLists.txt Normal file
View File

@@ -0,0 +1,78 @@
project(libssh C)
# Required cmake version
cmake_minimum_required(VERSION 2.6.0)
# global needed variables
set(APPLICATION_NAME ${PROJECT_NAME})
set(APPLICATION_VERSION_MAJOR "0")
set(APPLICATION_VERSION_MINOR "4")
set(APPLICATION_VERSION_PATCH "5")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
# SOVERSION scheme: CURRENT.AGE.REVISION
# If there was an incompatible interface change:
# Increment CURRENT. Set AGE and REVISION to 0
# If there was a compatible interface change:
# Increment AGE. Set REVISION to 0
# If the source code was changed, but there were no interface changes:
# Increment REVISION.
set(LIBRARY_VERSION "4.1.2")
set(LIBRARY_SOVERSION "4")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake/Modules
)
# add definitions
include(DefineCMakeDefaults)
include(DefineCompilerFlags)
include(DefineInstallationPaths)
include(DefineOptions.cmake)
include(CPackConfig.cmake)
# disallow in-source build
include(MacroEnsureOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
# add macros
include(MacroAddPlugin)
include(MacroCopyFile)
# search for libraries
find_package(ZLIB REQUIRED)
if (WITH_GCRYPT)
find_package(GCrypt REQUIRED)
if (NOT GCRYPT_FOUND)
message(FATAL_ERROR "Could not find GCrypt")
endif (NOT GCRYPT_FOUND)
else (WITH_GCRYPT)
find_package(OpenSSL)
if (NOT OPENSSL_FOUND)
find_package(GCrypt)
if (NOT GCRYPT_FOUND)
message(FATAL_ERROR "Could not find OpenSSL or GCrypt")
endif (NOT GCRYPT_FOUND)
endif (NOT OPENSSL_FOUND)
endif(WITH_GCRYPT)
# config.h checks
include(ConfigureChecks.cmake)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
# check subdirectories
add_subdirectory(doc)
add_subdirectory(include)
add_subdirectory(libssh)
# build samples
include_directories(${CMAKE_SOURCE_DIR}/include)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_subdirectory(examples)
endif (CMAKE_SYSTEM_NAME STREQUAL "Linux")

48
CPackConfig.cmake Normal file
View File

@@ -0,0 +1,48 @@
# For help take a look at:
# http://www.cmake.org/Wiki/CMake:CPackConfiguration
### general settings
set(CPACK_PACKAGE_NAME ${APPLICATION_NAME})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The SSH library")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
set(CPACK_PACKAGE_VENDOR "The SSH Library Development Team")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
### versions
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "4")
set(CPACK_PACKAGE_VERSION_PATCH "5")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
### source generator
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;tags;cscope.*")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
### nsis generator
set(CPACK_GENERATOR "NSIS")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "libssh")
set(CPACK_NSIS_DISPLAY_NAME "The SSH Library")
set(CPACK_NSIS_COMPRESSOR "/SOLID zlib")
set(CPACK_NSIS_MENU_LINKS "http://www.libssh.org/" "libssh homepage")
set(CPACK_PACKAGE_FILE_NAME ${APPLICATION_NAME}-${CPACK_PACKAGE_VERSION})
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers")
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
"Libraries used to build programs which use libssh")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION
"C/C++ header files for use with libssh")
set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
#set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime")
set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
set(CPACK_COMPONENT_HEADERS_GROUP "Development")
include(CPack)

320
ChangeLog
View File

@@ -1,80 +1,248 @@
libssh-0.11-dev
-server implementation development. I won't document it before it even works.
-small bug corrected when connecting to sun ssh servers.
-channel wierdness corrected (writing huge data packets)
-channel_read_nonblocking added
-channel bug where stderr wasn't correctly read fixed.
-sftp_file_set_nonblocking added. It's now possible to have nonblocking SFTP IO
-connect_status callback.
-priv.h contains the internal functions, libssh.h the public interface
-options_set_timeout (thx marcelo) really working.
-tcp tunneling through channel_open_forward.
-channel_request_exec()
-channel_request_env()
-ssh_get_pubkey_hash()
-ssh_is_server_known()
-ssh_write_known_host()
-options_set_ssh_dir
-how could this happen ! there weren't any channel_close !
-nasty channel_free bug resolved.
-removed the unsigned long all around the code. use only u8,u32 & u64.
-it now compiles and runs under amd64 !
-channel_request_pty_size
-channel_change_pty_size
-options_copy()
-ported the doc to an HTML file.
-small bugfix in packet.c
-prefixed error constants with SSH_
-sftp_stat, sftp_lstat, sftp_fstat. thanks Michel Bardiaux for the patch.
-again channel number mismatch fixed.
-fixed a bug in ssh_select making the select fail when a signal has been caught.
-keyboard-interactive authentication working.
ChangeLog
==========
5th march 2004 : libssh-0.1
-Begining of sftp subsystem implementation. It's stable enough to be used :)
-some cleanup into channels implementation
-Now every channel functions is called by its CHANNEL handler. no any way to play again with numbers.
-added channel_poll() and channel_read(). Now, it's possible to manipulate channel streams only with channel_read() and channel_write(),
with help of channel_poll().
-changed the client so it uses the new channel_poll and channel_read interface
-small use-after-free bug with channels resolved, and a noninitialised data of SIGNATURE struct.
-changed stupidities in lot of function names.
-removed a debug output file opened by default.
-Added API.txt, the libssh programmer handbook. (I hate documentation)
-Various bug fixes from Nick Zitzmann. Thank to him, libssh now runs under macosX !
-Developed a cryptographic structure for handling protocols. Adding a custom-based cipher should be the story of thirty
minutes. It now supports aes-256,aes-192,aes-128 and blowfish-128 !
-An autoconf script which took me half of a day to set up. Respect it!
-A ssh_select wrapper has been written.
It all means the API has changed. not a lot but enough to be incompatible with anything which has been written.
version 0.4.5 (released 2010-07-13)
* Added option to bind a client to an ip address.
* Fixed the ssh socket polling function.
* Fixed Windows related bugs in bsd_poll().
* Fixed serveral build warnings.
10th october 2003 : libssh-0.0.4
-some terminal code (eof handling) added
-channels bugfix (it still needs some tweaking though)
-zlib support
-added a wrapper.c file. The goal is to provide a similar API to every cryptographic functions. bignums and sha/md5 are wrapped now.
-more work than it first looks.
-Support for other crypto libs planed (lighter libs)
-Fixed stupid select() bug.
-libssh now compiles and links with openssl 0.9.6 (but you're advised to upgrade)
-RSA pubkey authentication code now works !
version 0.4.4 (released 2010-06-01)
* Fixed a bug in the expand function for escape sequences.
* Fixed a bug in the tilde expand function.
* Fixed a bug in setting the options.
15th september 2003 : libssh-0.0.3
-added install target in makefile
-some cleanup in headers files and source code
-change default banner and project name to libssh.
-new file auth.c to support more and more authentication ways
-bugfix(read offbyone) in send_kex
-a base64 parser. don't read the source, it's awful. pure 0xbadc0de.
-changed the client filename to "ssh". logic isn't it ?
-dss publickey authentication ! still need to wait for the rsa one
-bugfix in packet.c : now packet are completely read (and read blocks if waiting the packet)
-new misc.c contains misc functions
version 0.4.3 (released 2010-05-18)
* Added global/keepalive responses.
* Added runtime detection of WSAPoll().
* Added a select(2) based poll-emulation if poll(2) is not available.
* Added a function to expand an escaped string.
* Added a function to expand the tilde from a path.
* Added a proxycommand support.
* Added ssh_privatekey_type public function
* Added the possibility to define _OPENSSL_DIR and _ZLIB_DIR.
* Fixed sftp_chown.
* Fixed sftp_rename on protocol version 3.
* Fixed a blocking bug in channel_poll.
* Fixed config parsing wich has overwritten user specified values.
* Fixed hashed [host]:port format in knownhosts
* Fixed Windows build.
* Fixed doublefree happening after a negociation error.
* Fixed aes*-ctr with <= OpenSSL 0.9.7b.
* Fixed some documentation.
* Fixed exec example which has broken read usage.
* Fixed broken algorithm choice for server.
* Fixed a typo that we don't export all symbols.
* Removed the unneeded dependency to doxygen.
* Build examples only on the Linux plattform.
3rd september 2003: libssh-0.0.2
initial release.
-client supports both ssh and dss hostkey verification, but doesn't compare
them to openssh's files. (~/.ssh/known_hosts)
-the only supported authentication method is password.
-compiles on linux and openbsd. freebsd and netbsd should work, too
-Lot of work which hasn't been discussed here.
version 0.4.2 (released 2010-03-15)
* Added owner and group information in sftp attributes.
* Added missing SSH_OPTIONS_FD option.
* Added printout of owner and group in the sftp example.
* Added a prepend function for ssh_list.
* Added send back replies to openssh's keepalives.
* Fixed documentation in scp code
* Fixed longname parsing, this only workings with readdir.
* Fixed and added support for several identity files.
* Fixed sftp_parse_longname() on Windows.
* Fixed a race condition bug in ssh_scp_close()
* Remove config support for SSHv1 Cipher variable.
* Rename ssh_list_add to ssh_list_append.
* Rename ssh_list_get_head to ssh_list_pop_head
version 0.4.1 (released 2010-02-13)
* Added support for aes128-ctr, aes192-ctr and aes256-ctr encryption.
* Added an example for exec.
* Added private key type detection feature in privatekey_from_file().
* Fixed zlib compression fallback.
* Fixed kex bug that client preference should be prioritary
* Fixed known_hosts file set by the user.
* Fixed a memleak in channel_accept().
* Fixed underflow when leave_function() are unbalanced
* Fixed memory corruption in handle_channel_request_open().
* Fixed closing of a file handle case of errors in privatekey_from_file().
* Fixed ssh_get_user_home_dir() to be thread safe.
* Fixed the doxygen documentation.
version 0.4.0 (released 2009-12-10)
* Added scp support.
* Added support for sending signals (RFC 4254, section 6.9).
* Added MSVC support.
* Added support for ~/.ssh/config.
* Added sftp extension support.
* Added X11 forwarding support for client.
* Added forward listening.
* Added support for openssh extensions (statvfs, fstatvfs).
* Added a cleaned up interface for setting options.
* Added a generic way to handle sockets asynchronously.
* Added logging of the sftp flags used to open a file.
* Added full poll() support and poll-emulation for win32.
* Added missing 64bit functions in sftp.
* Added support for ~/ and SSH_DIR/ in filenames instead of %s/.
* Fixed Fix channel_get_exit_status bug.
* Fixed calltrace logging to make it optional.
* Fixed compilation on Solaris.
* Fixed resolving of ip addresses.
* Fixed libssh compilation without server support.
* Fixed possible memory corruptions (ticket #14).
version 0.3.4 (released 2009-09-14)
* Added ssh_basename and ssh_dirname.
* Added a portable ssh_mkdir function.
* Added a sftp_tell64() function.
* Added missing NULL pointer checks to crypt_set_algorithms_server.
* Fixed ssh_write_knownhost if ~/.ssh doesn't exist.
* Fixed a possible integer overflow in buffer_get_data().
* Fixed possible security bug in packet_decrypt().
* Fixed a possible stack overflow in agent code.
version 0.3.3 (released 2009-08-18)
* Fixed double free pointer crash in dsa_public_to_string.
* Fixed channel_get_exit_status bug.
* Fixed ssh_finalize which didn't clear the flag.
* Fixed memory leak introduced by previous bugfix.
* Fixed channel_poll broken when delayed EOF recvd.
* Fixed stupid "can't parse known host key" bug.
* Fixed possible memory corruption (ticket #14).
version 0.3.2 (released 2009-08-05)
* Added ssh_init() function.
* Added sftp_readlink() function.
* Added sftp_symlink() function.
* Fixed ssh_write_knownhost().
* Fixed compilation on Solaris.
* Fixed SSHv1 compilation.
version 0.3.1 (released 2009-07-14)
* Added return code SSH_SERVER_FILE_NOT_FOUND.
* Fixed compilation of SSHv1.
* Fixed several memory leaks.
* Fixed possible infinite loops.
* Fixed a possible crash bug.
* Fixed build warnings.
* Fixed cmake on BSD.
version 0.3.1 (released 2009-07-14)
* Added return code SSH_SERVER_FILE_NOT_FOUND.
* Fixed compilation of SSHv1.
* Fixed several memory leaks.
* Fixed possible infinite loops.
* Fixed a possible crash bug.
* Fixed build warnings.
* Fixed cmake on BSD.
version 0.3 (released 2009-05-21)
* Added support for ssh-agent authentication.
* Added POSIX like sftp implementation.
* Added error checking to all functions.
* Added const to arguments where it was needed.
* Added a channel_get_exit_status() function.
* Added a channel_read_buffer() function, channel_read() is now
a POSIX like function.
* Added a more generic auth callback function.
* Added printf attribute checking for log and error functions.
* Added runtime function tracer support.
* Added NSIS build support with CPack.
* Added openssh hashed host support.
* Added API documentation for all public functions.
* Added asynchronous SFTP read function.
* Added a ssh_bind_set_fd() function.
* Fixed known_hosts parsing.
* Fixed a lot of build warnings.
* Fixed the Windows build.
* Fixed a lot of memory leaks.
* Fixed a double free corruption in the server support.
* Fixed the "ssh_accept:" bug in server support.
* Fixed important channel bugs.
* Refactored the socket handling.
* Switched to CMake build system.
* Improved performance.
version 0.2 (released 2007-11-29)
* General cleanup
* More comprehensive API
* Up-to-date Doxygen documentation of each public function
* Basic server-based support
* Libgcrypt support (alternative to openssl and its license)
* SSH1 support (disabled by default)
* Added 3des-cbc
* A lot of bugfixes
version 0.11-dev
* Server implementation development.
* Small bug corrected when connecting to sun ssh servers.
* Channel wierdness corrected (writing huge data packets)
* Channel_read_nonblocking added
* Channel bug where stderr wasn't correctly read fixed.
* Added sftp_file_set_nonblocking(), which is nonblocking SFTP IO
* Connect_status callback.
* Priv.h contains the internal functions, libssh.h the public interface
* Options_set_timeout (thx marcelo) really working.
* Tcp tunneling through channel_open_forward.
* Channel_request_exec()
* Channel_request_env()
* Ssh_get_pubkey_hash()
* Ssh_is_server_known()
* Ssh_write_known_host()
* Options_set_ssh_dir
* How could this happen ! there weren't any channel_close !
* Nasty channel_free bug resolved.
* Removed the unsigned long all around the code. use only u8,u32 & u64.
* It now compiles and runs under amd64 !
* Channel_request_pty_size
* Channel_change_pty_size
* Options_copy()
* Ported the doc to an HTML file.
* Small bugfix in packet.c
* Prefixed error constants with SSH_
* Sftp_stat, sftp_lstat, sftp_fstat. thanks Michel Bardiaux for the patch.
* Again channel number mismatch fixed.
* Fixed a bug in ssh_select making the select fail when a signal has been
caught.
* Keyboard-interactive authentication working.
version 0.1 (released 2004-03-05)
* Begining of sftp subsystem implementation.
* Some cleanup into channels implementation
* Now every channel functions is called by its CHANNEL handler.
* Added channel_poll() and channel_read().
* Changed the client so it uses the new channel_poll and channel_read interface
* Small use-after-free bug with channels resolved
* Changed stupidities in lot of function names.
* Removed a debug output file opened by default.
* Added API.txt, the libssh programmer handbook.
* Various bug fixes from Nick Zitzmann.
* Developed a cryptographic structure for handling protocols.
* An autoconf script which took me half of a day to set up.
* A ssh_select wrapper has been written.
version 0.0.4 (released 2003-10-10)
* Some terminal code (eof handling) added
* Channels bugfix (it still needs some tweaking though)
* Zlib support
* Added a wrapper.c file. The goal is to provide a similar API to every
cryptographic functions. bignums and sha/md5 are wrapped now.
* More work than it first looks.
* Support for other crypto libs planed (lighter libs)
* Fixed stupid select() bug.
* Libssh now compiles and links with openssl 0.9.6
* RSA pubkey authentication code now works !
version 0.0.3 (released 2003-09-15)
* Added install target in makefile
* Some cleanup in headers files and source code
* Change default banner and project name to libssh.
* New file auth.c to support more and more authentication ways
* Bugfix(read offbyone) in send_kex
* A base64 parser. don't read the source, it's awful. pure 0xbadc0de.
* Changed the client filename to "ssh". logic isn't it ?
* Dss publickey authentication ! still need to wait for the rsa one
* Bugfix in packet.c
* New misc.c contains misc functions
version 0.0.2 (released 2003-09-03)
* Initial release.
* Client supports both ssh and dss hostkey verification, but doesn't compare them to openssh's files. (~/.ssh/known_hosts)
* The only supported authentication method is password.
* Compiles on linux and openbsd. freebsd and netbsd should work, too
* Lot of work which hasn't been discussed here.

123
ConfigureChecks.cmake Normal file
View File

@@ -0,0 +1,123 @@
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
set(PACKAGE ${APPLICATION_NAME})
set(VERSION ${APPLICATION_VERSION})
set(DATADIR ${DATA_INSTALL_DIR})
set(LIBDIR ${LIB_INSTALL_DIR})
set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
set(BINARYDIR ${CMAKE_BINARY_DIR})
set(SOURCEDIR ${CMAKE_SOURCE_DIR})
if(CMAKE_COMPILER_IS_GNUCC)
check_c_compiler_flag("-fvisibility=hidden" WITH_VISIBILITY_HIDDEN)
endif(CMAKE_COMPILER_IS_GNUCC)
# HEADER FILES
check_include_file(argp.h HAVE_ARGP_H)
check_include_file(pty.h HAVE_PTY_H)
check_include_file(terminos.h HAVE_TERMIOS_H)
if (WIN32)
check_include_files("winsock2.h;ws2tcpip.h;wspiapi.h" HAVE_WSPIAPI_H)
if (NOT HAVE_WSPIAPI_H)
message(STATUS "WARNING: Without wspiapi.h (or dependencies), this build will only work on Windows XP and newer versions")
endif (NOT HAVE_WSPIAPI_H)
check_include_files("winsock2.h;ws2tcpip.h" HAVE_WS2TCPIP_H)
if (NOT HAVE_WS2TCPIP_H)
message(ERROR "WARNING: Does not have ws2tcpip.h or winsock2.h")
endif (NOT HAVE_WS2TCPIP_H)
if (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
set(HAVE_GETADDRINFO TRUE)
set(HAVE_GETHOSTBYNAME TRUE)
endif (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
check_function_exists(vsnprintf HAVE_VSNPRINTF)
if(NOT HAVE_VSNPRINTF)
check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
check_function_exists(_vsnprintf HAVE__VSNPRINTF)
endif(NOT HAVE_VSNPRINTF)
check_function_exists(snprintf HAVE_SNPRINTF)
if(NOT HAVE_SNPRINTF)
check_function_exists(_snprintf HAVE__SNPRINTF)
check_function_exists(_snprintf_s HAVE__SNPRINTF_S)
endif(NOT HAVE_SNPRINTF)
check_function_exists(strncpy HAVE_STRNCPY)
set(HAVE_SELECT TRUE)
endif (WIN32)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIRS})
check_include_file(openssl/aes.h HAVE_OPENSSL_AES_H)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIRS})
check_include_file(openssl/blowfish.h HAVE_OPENSSL_BLOWFISH_H)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIRS})
check_include_file(openssl/des.h HAVE_OPENSSL_DES_H)
# FUNCTIONS
if (UNIX)
# libsocket (Solaris)
check_library_exists(socket getaddrinfo "" HAVE_LIBSOCKET)
if (HAVE_LIBSOCKET)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} socket)
endif (HAVE_LIBSOCKET)
# libnsl (Solaris)
check_library_exists(nsl gethostbyname "" HAVE_LIBNSL)
if (HAVE_LIBNSL)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} nsl)
endif (HAVE_LIBNSL)
# libresolv
check_library_exists(resolv hstrerror "" HAVE_LIBRESOLV)
if (HAVE_LIBRESOLV)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} resolv)
endif (HAVE_LIBRESOLV)
check_library_exists(rt nanosleep "" HAVE_LIBRT)
# librt
if (HAVE_LIBRT)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} rt)
endif (HAVE_LIBRT)
check_function_exists(getaddrinfo HAVE_GETADDRINFO)
check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
check_function_exists(poll HAVE_POLL)
check_function_exists(select HAVE_SELECT)
check_function_exists(cfmakeraw HAVE_CFMAKERAW)
check_function_exists(regcomp HAVE_REGCOMP)
endif (UNIX)
set(LIBSSH_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "libssh required system libraries")
# LIBRARIES
if (OPENSSL_FOUND)
set(HAVE_LIBCRYPTO 1)
endif (OPENSSL_FOUND)
if (GCRYPT_FOUND)
set(HAVE_LIBGCRYPT 1)
endif (GCRYPT_FOUND)
if (Z_LIBRARY)
set(HAVE_LIBZ 1)
endif (Z_LIBRARY)
# OPTIONS
if (WITH_DEBUG_CRYPTO)
set(DEBUG_CRYPTO 1)
endif (WITH_DEBUG_CRYPTO)
if (WITH_DEBUG_CALLTRACE)
set(DEBUG_CALLTRACE 1)
endif (WITH_DEBUG_CALLTRACE)
# ENDIAN
test_big_endian(WORDS_BIGENDIAN)

9
DefineOptions.cmake Normal file
View File

@@ -0,0 +1,9 @@
option(WITH_LIBZ "Build with ZLIB support" ON)
option(WITH_SSH1 "Build with SSH1 support" OFF)
option(WITH_SFTP "Build with SFTP support" ON)
option(WITH_SERVER "Build with SSH server support" ON)
option(WITH_STATIC_LIB "Build with a static library" OFF)
option(WITH_DEBUG_CRYPTO "Build with cryto debug output" OFF)
option(WITH_DEBUG_CALLTRACE "Build with calltrace debug output" ON)
option(WITH_GCRYPT "Compile against libgcrypt" OFF)
option(WITH_PCAP "Compile with Pcap generation support" OFF)

View File

@@ -31,7 +31,7 @@ PROJECT_NAME = libssh
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.2.1-svn
PROJECT_NUMBER = 0.3-svn
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

View File

@@ -31,7 +31,7 @@ PROJECT_NAME = libssh
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.2.1-svn
PROJECT_NUMBER = 0.3-svn
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

258
INSTALL
View File

@@ -1,236 +1,78 @@
Installation Instructions
*************************
# How to build from source
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
## Requirements
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
### Common requirements
Basic Installation
==================
In order to build libssh, you need to install several components:
These are generic installation instructions.
- A C compiler
- [CMake](http://www.cmake.org) >= 2.6.0.
- [openssl](http://www.openssl.org) >= 0.9.8
or
- [gcrypt](http://www.gnu.org/directory/Security/libgcrypt.html) >= 1.4
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').
optional:
- [libz](http://www.zlib.net) >= 1.2
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.)
Note that these version numbers are version we know works correctly. If you
build and run libssh successfully with an older version, please let us know.
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'.
## Building
First, you need to configure the compilation, using CMake. Go inside the
`build` dir. Create it if it doesn't exist.
The simplest way to compile this package is:
GNU/Linux and MacOS X:
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.
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
make
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
### CMake standard options
Here is a list of the most interesting options provided out of the box by
CMake.
2. Type `make' to compile the package.
- CMAKE_BUILD_TYPE: The type of build (can be Debug Release MinSizeRel
RelWithDebInfo)
- CMAKE_INSTALL_PREFIX: The prefix to use when running make install (Default
to /usr/local on GNU/Linux and MacOS X)
- CMAKE_C_COMPILER: The path to the C compiler
- CMAKE_CXX_COMPILER: The path to the C++ compiler
3. Optionally, type `make check' to run any self-tests that come with
the package.
### CMake options defined for libssh
4. Type `make install' to install the programs and any data files and
documentation.
Options are defined in the following files:
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.
- DefineOptions.cmake
Compilers and Options
=====================
They can be changed with the -D option:
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.
`cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DWITH_LIBZ=OFF ..`
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
### Browsing/editing CMake options
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
In addition to passing options on the command line, you can browse and edit
CMake options using `cmakesetup` (Windows), `cmake-gui` or `ccmake` (GNU/Linux
and MacOS X).
*Note Defining Variables::, for more details.
- Go to the build dir
- On Windows: run `cmakesetup`
- On GNU/Linux and MacOS X: run `ccmake ..`
Compiling For Multiple Architectures
====================================
## Installing
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 want to install libssh after compilation run:
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.
make install
Installation Names
==================
## Running
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'.
The libssh binary can be found in the `build/libssh` directory.
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.
## About this document
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.
This document is written using [Markdown][] syntax, making it possible to
provide usable information in both plain text and HTML format. Whenever
modifying this document please use [Markdown][] syntax.
[markdown]: http://www.daringfireball.net/projects/markdown

View File

@@ -1,41 +0,0 @@
CC= gcc
DLLWRAP=dllwrap.exe
DEFFILE=libssh.def
STATICLIB=libssh.a
LIB="c:\Program files\Microsoft Visual Studio .NET 2003\vc7\bin\lib.exe"
INCS= -I. -Iinclude -Ic:/openssl/include -I"c:\Program files\gnuwin32\include"
CFLAGS= $(INCS)
LINK= -L. c:/openssl/lib/MinGW/libeay32.a "c:\program files\gnuwin32\lib\libz.a" c:\Dev-cpp\lib\libws2_32.a #-lws2_32 ##-lgdi32 -lshell32
libssh_HEADERS= config.h include/libssh/crypto.h include/libssh/libssh.h include/libssh/priv.h include/libssh/server.h include/libssh/sftp.h include/libssh/ssh1.h include/libssh/ssh2.h
libssh_OBJS = libssh/auth1.o libssh/auth.o libssh/base64.o libssh/buffer.o \
libssh/channels1.o libssh/channels.o libssh/client.o libssh/connect.o \
libssh/crc32.o libssh/crypt.o libssh/dh.o libssh/error.o libssh/gcrypt_missing.o \
libssh/gzip.o libssh/init.o libssh/kex.o libssh/keyfiles.o \
libssh/keys.o libssh/messages.o libssh/misc.o libssh/options.o \
libssh/packet.o libssh/server.o libssh/session.o libssh/sftp.o \
libssh/sftpserver.o libssh/string.o libssh/wrapper.o libssh/socket.o \
libssh/log.o
all: libssh.dll samplesshd.exe libssh.lib
config.h: config.h.win32-openssl
copy config.h.win32-openssl config.h
%.o: %.c $(libssh_HEADERS)
$(CC) -c $< -o $@ $(CFLAGS)
sample.exe: sample.o $(libssh_OBJS)
$(CC) $< -o $@ $(libssh_OBJS) $(LINK)
samplesshd.exe: samplesshd.o $(libssh_OBJS)
$(CC) $< -o $@ $(libssh_OBJS) $(LINK)
libssh.dll: $(libssh_OBJS)
# $(CC) -shared $(libssh_OBJS) -o libssh.dll $(LINK)
$(DLLWRAP) --export-all-symbols --output-def $(DEFFILE) --implib $(STATICLIB) $(libssh_OBJS) $(LINK) -o libssh.dll
libssh.lib: libssh.dll
lib.bat
clean:
rm -f $(libssh_OBJS) samplesshd.exe sample.exe samplesshd.o sample.o libssh.dll config.h

View File

@@ -1,44 +0,0 @@
SUBDIRS = libssh include
AM_CPPFLAGS = -I$(srcdir)/include
LDADD = $(top_builddir)/libssh/libssh.la
noinst_PROGRAMS = samplesshd samplessh
noinst_DATA = samplesftp doxygen
samplessh_SOURCES = sample.c
samplesshd_SOURCES = samplesshd.c
samplesftp: samplessh
$(LN_S) -f samplessh samplesftp
if HAS_DOXYGEN
install-doc: doxygen
$(INSTALL) -d $(DESTDIR)$(docdir)/html
$(INSTALL) --mode=644 doxygen/html/* $(DESTDIR)$(docdir)/html
$(INSTALL) -d $(DESTDIR)$(docdir)/examples
$(INSTALL) --mode=644 sample.c samplesshd.c $(DESTDIR)$(docdir)/examples
$(INSTALL) -d $(DESTDIR)$(mandir)/man3
$(INSTALL) --mode=644 doxygen/man/man3/* $(DESTDIR)$(mandir)/man3
doxygen: clean-local
@echo "Running doxygen..."
doxygen $(srcdir)/Doxyfile
doxygen-dev: clean-local
@echo "Running internal doxygen"
doxygen $(srcdir)/Doxyfile.internal
else
doxygen:
doxygen-dev:
install-doc: doxygen
endif
clean-local:
-rm -rf doxygen
EXTRA_DIST = Doxyfile Doxyfile.internal
CLEANFILES = samplesftp

0
NEWS
View File

49
README
View File

@@ -1,14 +1,14 @@
The libSSH and its client
~~~~~~~~~~~~~~~~~~~~~~~~~
-Aris Adamantiadis
libssh: the SSH library
~~~~~~~~~~~~~~~~~~~~~~~
1* Why ?
-_-_-_-_-_
Why not ? :) I've began to work on my own implementation of the ssh protocol
because i didn't like the currently public ones.
Not any allow you to import and use the functions as a library, and so i
worked on a library-based SSH implementation.
Not any allowed you to import and use the functions as a powerful library,
and so i worked on a library-based SSH implementation which was non-existing
in the free and open source software world.
2* How/Who ?
@@ -16,24 +16,33 @@ worked on a library-based SSH implementation.
If you downloaded this file, you must know what it is : a library for
accessing ssh client services through C libraries calls in a simple manner.
The client is there as a programming example and isn't at all doing its job
correctly (doesn't verify public key hashes with the ones in ~/.ssh/
and doesn't handle TERM - yet)
Everybody can use this software under the terms of the LGPL - see the COPYING
file
3* What ?
-_-_-_-_-_
If you ask yourself how to compile libssh, please read INSTALL before anything.
The SSH library features :
-Full C library functions for manipulating a client-side SSH connection
-Fully configurable sessions
-Support for AES-128,AES-192,AES-256,blowfish, in cbc mode
-use multiple SSH connections in a same process, at same time.
-usable SFTP implementation
-Public key and password authentication
4* Where ?
3* Where ?
-_-_-_-_-_-_
http://0xbadc0de.be/?part=libssh
http://www.libssh.org
4* API Changes !
-_-_-_-_-_-_-_-_-_
Changes between 0.3 and 0.4
---------------------------
We changed libssh to be typesafe now:
SSH_SESSION *session -> ssh_session session
SFTP_SESSION *sftp -> sftp_session sftp
CHANNEL *channel -> ssh_channel channel
STRING *string -> ssh_string string
...
The options structure has been removed and there is a new function. This
function can set all available options now. You can find the enum in the
header file and it is documented. Example:
ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");

View File

@@ -1,8 +0,0 @@
#!/bin/sh -e
aclocal
libtoolize --force --copy
autoheader
autoconf
automake --add-missing --copy --gnu
./configure $@

195
build/build_make.sh Executable file
View File

@@ -0,0 +1,195 @@
#!/bin/bash
#
# Last Change: 2008-06-18 14:13:46
#
# Script to build libssh on UNIX.
#
# Copyright (c) 2006-2007 Andreas Schneider <mail@cynapses.org>
#
SOURCE_DIR=".."
LANG=C
export LANG
SCRIPT="$0"
COUNT=0
while [ -L "${SCRIPT}" ]
do
SCRIPT=$(readlink ${SCRIPT})
COUNT=$(expr ${COUNT} + 1)
if [ ${COUNT} -gt 100 ]; then
echo "Too many symbolic links"
exit 1
fi
done
BUILDDIR=$(dirname ${SCRIPT})
cleanup_and_exit () {
if test "$1" = 0 -o -z "$1" ; then
exit 0
else
exit $1
fi
}
function configure() {
if [ -n "${CMAKEDIR}" ]; then
${CMAKEDIR}/bin/cmake "$@" ${SOURCE_DIR} || cleanup_and_exit $?
else
cmake "$@" ${SOURCE_DIR} || cleanup_and_exit $?
fi
}
function compile() {
if [ -f /proc/cpuinfo ]; then
CPUCOUNT=$(grep -c processor /proc/cpuinfo)
elif test `uname` = "SunOS" ; then
CPUCOUNT=$(psrinfo -p)
else
CPUCOUNT="1"
fi
if [ "${CPUCOUNT}" -gt "1" ]; then
${MAKE} -j${CPUCOUNT} $1 || cleanup_and_exit $?
else
${MAKE} $1 || exit $?
fi
}
function clean_build_dir() {
find ! -path "*.svn*" ! -name "*.bat" ! -name "*.sh" ! -name "." -print0 | xargs -0 rm -rf
}
function usage () {
echo "Usage: `basename $0` [--prefix /install_prefix|--build [debug|final]|--clean|--verbose|--libsuffix (32|64)|--help|--cmakedir /directory|--make
(gmake|make)|--ccompiler (gcc|cc)|--withstaticlib|--unittesting|--withss1|--withserver]"
cleanup_and_exit
}
cd ${BUILDDIR}
# the default CMake options:
OPTIONS="--graphviz=${BUILDDIR}/libssh.dot"
# the default 'make' utility:
MAKE="make"
while test -n "$1"; do
PARAM="$1"
ARG="$2"
shift
case ${PARAM} in
*-*=*)
ARG=${PARAM#*=}
PARAM=${PARAM%%=*}
set -- "----noarg=${PARAM}" "$@"
esac
case ${PARAM} in
*-help|-h)
#echo_help
usage
cleanup_and_exit
;;
*-build)
DOMAKE="1"
BUILD_TYPE="${ARG}"
test -n "${BUILD_TYPE}" && shift
;;
*-clean)
clean_build_dir
cleanup_and_exit
;;
*-verbose)
DOVERBOSE="1"
;;
*-memtest)
OPTIONS="${OPTIONS} -DMEM_NULL_TESTS=ON"
;;
*-libsuffix)
OPTIONS="${OPTIONS} -DLIB_SUFFIX=${ARG}"
shift
;;
*-prefix)
OPTIONS="${OPTIONS} -DCMAKE_INSTALL_PREFIX=${ARG}"
shift
;;
*-sysconfdir)
OPTIONS="${OPTIONS} -DSYSCONF_INSTALL_DIR=${ARG}"
shift
;;
*-cmakedir)
CMAKEDIR="${ARG}"
shift
;;
*-make)
MAKE="${ARG}"
shift
;;
*-ccompiler)
OPTIONS="${OPTIONS} -DCMAKE_C_COMPILER=${ARG}"
shift
;;
*-withstaticlib)
OPTIONS="${OPTIONS} -DWITH_STATIC_LIB=ON"
shift
;;
*-unittesting)
OPTIONS="${OPTIONS} -DUNIT_TESTING=ON"
shift
;;
*-withssh1)
OPTIONS="${OPTIONS} -DWITH_SSH1=ON"
shift
;;
*-withserver)
OPTIONS="${OPTIONS} -DWITH_SERVER=ON"
shift
;;
----noarg)
echo "$ARG does not take an argument"
cleanup_and_exit
;;
-*)
echo Unknown Option "$PARAM". Exit.
cleanup_and_exit 1
;;
*)
usage
;;
esac
done
if [ "${DOMAKE}" == "1" ]; then
OPTIONS="${OPTIONS} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
fi
if [ -n "${DOVERBOSE}" ]; then
OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=1"
else
OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=0"
fi
test -f "${BUILDDIR}/.build.log" && rm -f ${BUILDDIR}/.build.log
touch ${BUILDDIR}/.build.log
# log everything from here to .build.log
exec 1> >(exec -a 'build logging tee' tee -a ${BUILDDIR}/.build.log) 2>&1
echo "${HOST} started build at $(date)."
echo
configure ${OPTIONS} "$@"
if [ -n "${DOMAKE}" ]; then
test -n "${DOVERBOSE}" && compile VERBOSE=1 || compile
fi
DOT=$(which dot 2>/dev/null)
if [ -n "${DOT}" ]; then
${DOT} -Tpng -o${BUILDDIR}/libssh.png ${BUILDDIR}/libssh.dot
${DOT} -Tsvg -o${BUILDDIR}/libssh.svg ${BUILDDIR}/libssh.dot
fi
exec >&0 2>&0 # so that the logging tee finishes
sleep 1 # wait till tee terminates
cleanup_and_exit 0

View File

@@ -0,0 +1,22 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.

View File

@@ -0,0 +1,27 @@
# Always include srcdir and builddir in include path
# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
# about every subdir
# since cmake 2.4.0
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Put the include dirs which are in the source or build tree
# before all other include dirs, so the headers in the sources
# are prefered over the already installed ones
# since cmake 2.4.1
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
# Use colored output
# since cmake 2.4.0
set(CMAKE_COLOR_MAKEFILE ON)
# Define the generic version of the libraries here
set(GENERIC_LIB_VERSION "0.1.0")
set(GENERIC_LIB_SOVERSION "0")
# Set the default build type to release with debug info
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo
CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
)
endif (NOT CMAKE_BUILD_TYPE)

View File

@@ -0,0 +1,59 @@
# define system dependent compiler flags
include(CheckCCompilerFlag)
if (UNIX AND NOT WIN32)
if (${CMAKE_C_COMPILER_ID} MATCHES GNU)
# add -Wconversion ?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute")
# with -fPIC
check_c_compiler_flag("-fPIC" WITH_FPIC)
if (WITH_FPIC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif (WITH_FPIC)
check_c_compiler_flag("-fstack-protector" WITH_STACK_PROTECTOR)
if (WITH_STACK_PROTECTOR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
endif (WITH_STACK_PROTECTOR)
check_c_compiler_flag("-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
if (WITH_FORTIFY_SOURCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
endif (WITH_FORTIFY_SOURCE)
endif (${CMAKE_C_COMPILER_ID} MATCHES GNU)
if (CMAKE_SIZEOF_VOID_P MATCHES "8")
# with large file support
execute_process(
COMMAND
getconf LFS64_CFLAGS
OUTPUT_VARIABLE
_lfs_CFLAGS
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else (CMAKE_SIZEOF_VOID_P MATCHES "8")
# with large file support
execute_process(
COMMAND
getconf LFS_CFLAGS
OUTPUT_VARIABLE
_lfs_CFLAGS
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
if (_lfs_CFLAGS)
string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_lfs_CFLAGS}")
endif (_lfs_CFLAGS)
endif (UNIX AND NOT WIN32)
# suppress warning about "deprecated" functions
if (MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
endif (MSVC)

View File

@@ -0,0 +1,107 @@
if (UNIX)
IF (NOT APPLICATION_NAME)
MESSAGE(STATUS "${PROJECT_NAME} is used as APPLICATION_NAME")
SET(APPLICATION_NAME ${PROJECT_NAME})
ENDIF (NOT APPLICATION_NAME)
# Suffix for Linux
SET(LIB_SUFFIX
CACHE STRING "Define suffix of directory name (32/64)"
)
SET(EXEC_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}"
CACHE PATH "Base directory for executables and libraries"
)
SET(SHARE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}/share"
CACHE PATH "Base directory for files which go to share/"
)
SET(DATA_INSTALL_PREFIX
"${SHARE_INSTALL_PREFIX}/${APPLICATION_NAME}"
CACHE PATH "The parent directory where applications can install their data")
# The following are directories where stuff will be installed to
SET(BIN_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/bin"
CACHE PATH "The ${APPLICATION_NAME} binary install dir (default prefix/bin)"
)
SET(SBIN_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/sbin"
CACHE PATH "The ${APPLICATION_NAME} sbin install dir (default prefix/sbin)"
)
SET(LIB_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/lib)"
)
SET(LIBEXEC_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/libexec"
CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/libexec)"
)
SET(PLUGIN_INSTALL_DIR
"${LIB_INSTALL_DIR}/${APPLICATION_NAME}"
CACHE PATH "The subdirectory relative to the install prefix where plugins will be installed (default is prefix/lib/${APPLICATION_NAME})"
)
SET(INCLUDE_INSTALL_DIR
"${CMAKE_INSTALL_PREFIX}/include"
CACHE PATH "The subdirectory to the header prefix (default prefix/include)"
)
SET(DATA_INSTALL_DIR
"${DATA_INSTALL_PREFIX}"
CACHE PATH "The parent directory where applications can install their data (default prefix/share/${APPLICATION_NAME})"
)
SET(HTML_INSTALL_DIR
"${DATA_INSTALL_PREFIX}/doc/HTML"
CACHE PATH "The HTML install dir for documentation (default data/doc/html)"
)
SET(ICON_INSTALL_DIR
"${DATA_INSTALL_PREFIX}/icons"
CACHE PATH "The icon install dir (default data/icons/)"
)
SET(SOUND_INSTALL_DIR
"${DATA_INSTALL_PREFIX}/sounds"
CACHE PATH "The install dir for sound files (default data/sounds)"
)
SET(LOCALE_INSTALL_DIR
"${SHARE_INSTALL_PREFIX}/locale"
CACHE PATH "The install dir for translations (default prefix/share/locale)"
)
SET(XDG_APPS_DIR
"${SHARE_INSTALL_PREFIX}/applications/"
CACHE PATH "The XDG apps dir"
)
SET(XDG_DIRECTORY_DIR
"${SHARE_INSTALL_PREFIX}/desktop-directories"
CACHE PATH "The XDG directory"
)
SET(SYSCONF_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/etc"
CACHE PATH "The ${APPLICATION_NAME} sysconfig install dir (default prefix/etc)"
)
SET(MAN_INSTALL_DIR
"${SHARE_INSTALL_PREFIX}/man"
CACHE PATH "The ${APPLICATION_NAME} man install dir (default prefix/man)"
)
SET(INFO_INSTALL_DIR
"${SHARE_INSTALL_PREFIX}/info"
CACHE PATH "The ${APPLICATION_NAME} info install dir (default prefix/info)"
)
endif (UNIX)
if (WIN32)
# Same same
set(BIN_INSTALL_DIR "bin" CACHE PATH "-")
set(SBIN_INSTALL_DIR "." CACHE PATH "-")
set(LIB_INSTALL_DIR "lib" CACHE PATH "-")
set(INCLUDE_INSTALL_DIR "include" CACHE PATH "-")
set(PLUGIN_INSTALL_DIR "plugins" CACHE PATH "-")
set(HTML_INSTALL_DIR "doc/HTML" CACHE PATH "-")
set(ICON_INSTALL_DIR "." CACHE PATH "-")
set(SOUND_INSTALL_DIR "." CACHE PATH "-")
set(LOCALE_INSTALL_DIR "lang" CACHE PATH "-")
endif (WIN32)

View File

@@ -0,0 +1,77 @@
# - Try to find GCrypt
# Once done this will define
#
# GCRYPT_FOUND - system has GCrypt
# GCRYPT_INCLUDE_DIRS - the GCrypt include directory
# GCRYPT_LIBRARIES - Link these to use GCrypt
# GCRYPT_DEFINITIONS - Compiler switches required for using GCrypt
#
# Copyright (c) 2009 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (GCRYPT_LIBRARIES AND GCRYPT_INCLUDE_DIRS)
# in cache already
set(GCRYPT_FOUND TRUE)
else (GCRYPT_LIBRARIES AND GCRYPT_INCLUDE_DIRS)
find_path(GCRYPT_INCLUDE_DIR
NAMES
gcrypt.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
mark_as_advanced(GCRYPT_INCLUDE_DIR)
find_library(GCRYPT_LIBRARY
NAMES
gcrypt
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
mark_as_advanced(GCRYPT_LIBRARY)
if (GCRYPT_LIBRARY)
set(GCRYPT_FOUND TRUE CACHE INTERNAL "Wether the gcrypt library has been found" FORCE)
endif (GCRYPT_LIBRARY)
set(GCRYPT_INCLUDE_DIRS
${GCRYPT_INCLUDE_DIR}
)
if (GCRYPT_FOUND)
set(GCRYPT_LIBRARIES
${GCRYPT_LIBRARIES}
${GCRYPT_LIBRARY}
)
endif (GCRYPT_FOUND)
if (GCRYPT_INCLUDE_DIRS AND GCRYPT_LIBRARIES)
set(GCRYPT_FOUND TRUE)
endif (GCRYPT_INCLUDE_DIRS AND GCRYPT_LIBRARIES)
if (GCRYPT_FOUND)
if (NOT GCrypt_FIND_QUIETLY)
message(STATUS "Found GCrypt: ${GCRYPT_LIBRARIES}")
endif (NOT GCrypt_FIND_QUIETLY)
else (GCRYPT_FOUND)
if (GCrypt_FIND_REQUIRED)
message(FATAL_ERROR "Could not find GCrypt")
endif (GCrypt_FIND_REQUIRED)
endif (GCRYPT_FOUND)
# show the GCRYPT_INCLUDE_DIRS and GCRYPT_LIBRARIES variables only in the advanced view
mark_as_advanced(GCRYPT_INCLUDE_DIRS GCRYPT_LIBRARIES)
endif (GCRYPT_LIBRARIES AND GCRYPT_INCLUDE_DIRS)

View File

@@ -0,0 +1,185 @@
# - Try to find OpenSSL
# Once done this will define
#
# OPENSSL_FOUND - system has OpenSSL
# OPENSSL_INCLUDE_DIRS - the OpenSSL include directory
# OPENSSL_LIBRARIES - Link these to use OpenSSL
# OPENSSL_DEFINITIONS - Compiler switches required for using OpenSSL
#
# Copyright (c) 2009 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
# in cache already
set(OPENSSL_FOUND TRUE)
else (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(openssl _OPENSSL_INCLUDEDIR _OPENSSL_LIBDIR _OPENSSL_LDFLAGS _OPENSSL_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_OPENSSL openssl)
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_path(OPENSSL_INCLUDE_DIR
NAMES
openssl/ssl.h
PATHS
${_OPENSSL_DIR}/include
${_OPENSSL_INCLUDEDIR}
/usr/include
/usr/local/include
/usr/local/ssl/include
/opt/local/include
/sw/include
/usr/lib/sfw/include
)
mark_as_advanced(OPENSSL_INCLUDE_DIR)
find_library(SSL_LIBRARY
NAMES
ssl
libssl
PATHS
${_OPENSSL_DIR}/lib
${_OPENSSL_LIBDIR}
/usr/lib
/usr/local/lib
/usr/local/ssl/lib
/opt/local/lib
/sw/lib
/usr/sfw/lib/64
/usr/sfw/lib
)
mark_as_advanced(SSL_LIBRARY)
find_library(SSLEAY32_LIBRARY
NAMES
ssleay32
PATHS
${_OPENSSL_DIR}/lib
${_OPENSSL_LIBDIR}
/usr/lib
/usr/local/lib
/usr/local/ssl/lib
/opt/local/lib
/sw/lib
/usr/sfw/lib/64
/usr/sfw/lib
)
mark_as_advanced(SSLEAY32_LIBRARY)
find_library(SSLEAY32MD_LIBRARY
NAMES
ssleay32MD
PATHS
${_OPENSSL_DIR}/lib
${_OPENSSL_LIBDIR}
/usr/lib
/usr/local/lib
/usr/local/ssl/lib
/opt/local/lib
/sw/lib
/usr/sfw/lib/64
/usr/sfw/lib
)
mark_as_advanced(SSLEAY32MD_LIBRARY)
find_library(CRYPTO_LIBRARY
NAMES
crypto
libcrypto
eay
eay32
libeay
libeay32
PATHS
${_OPENSSL_DIR}/lib
${_OPENSSL_LIBDIR}
/lib
/usr/lib
/usr/local/lib
/usr/local/ssl/lib
/opt/local/lib
/sw/lib
/usr/sfw/lib/64
/usr/sfw/lib
)
mark_as_advanced(CRYPTO_LIBRARY)
if (SSL_LIBRARY)
set(SSL_FOUND TRUE CACHE INTERNAL "Wether the ssl library has been found" FORCE)
endif (SSL_LIBRARY)
if (SSLEAY32_LIBRARY)
set(SSLEAY32_FOUND TRUE CACHE INTERNAL "Wether the ssleay32 library has been found" FORCE)
endif (SSLEAY32_LIBRARY)
if (SSLEAY32MD_LIBRARY)
set(SSLEAY32MD_FOUND TRUE CACHE INTERNAL "Wether the ssleay32MD library has been found" FORCE)
endif (SSLEAY32MD_LIBRARY)
if (CRYPTO_LIBRARY)
set(CRYPTO_FOUND TRUE CACHE INTERNAL "Wether the crypto library has been found" FORCE)
endif (CRYPTO_LIBRARY)
set(OPENSSL_INCLUDE_DIRS
${OPENSSL_INCLUDE_DIR}
)
if (SSL_FOUND)
set(OPENSSL_LIBRARIES
${OPENSSL_LIBRARIES}
${SSL_LIBRARY}
)
endif (SSL_FOUND)
if (SSLEAY32_FOUND)
set(OPENSSL_LIBRARIES
${OPENSSL_LIBRARIES}
${SSLEAY32_LIBRARY}
)
endif (SSLEAY32_FOUND)
if (SSLEAY32MD_FOUND)
set(OPENSSL_LIBRARIES
${OPENSSL_LIBRARIES}
${SSLEAY32MD_LIBRARY}
)
endif (SSLEAY32MD_FOUND)
if (CRYPTO_FOUND)
set(OPENSSL_LIBRARIES
${OPENSSL_LIBRARIES}
${CRYPTO_LIBRARY}
)
endif (CRYPTO_FOUND)
if (OPENSSL_INCLUDE_DIRS AND OPENSSL_LIBRARIES)
set(OPENSSL_FOUND TRUE)
endif (OPENSSL_INCLUDE_DIRS AND OPENSSL_LIBRARIES)
if (OPENSSL_FOUND)
if (NOT OpenSSL_FIND_QUIETLY)
message(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
endif (NOT OpenSSL_FIND_QUIETLY)
else (OPENSSL_FOUND)
if (OpenSSL_FIND_REQUIRED)
message(FATAL_ERROR "Could not find OpenSSL")
endif (OpenSSL_FIND_REQUIRED)
endif (OPENSSL_FOUND)
# show the OPENSSL_INCLUDE_DIRS and OPENSSL_LIBRARIES variables only in the advanced view
mark_as_advanced(OPENSSL_INCLUDE_DIRS OPENSSL_LIBRARIES)
endif (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)

View File

@@ -0,0 +1,81 @@
# - Try to find ZLIB
# Once done this will define
#
# ZLIB_FOUND - system has ZLIB
# ZLIB_INCLUDE_DIRS - the ZLIB include directory
# ZLIB_LIBRARIES - Link these to use ZLIB
# ZLIB_DEFINITIONS - Compiler switches required for using ZLIB
#
# Copyright (c) 2009 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
# in cache already
set(ZLIB_FOUND TRUE)
else (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
find_path(ZLIB_INCLUDE_DIR
NAMES
zlib.h
PATHS
${_ZLIB_DIR}/include
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
mark_as_advanced(ZLIB_INCLUDE_DIR)
find_library(Z_LIBRARY
NAMES
z
zlib
zlib1
PATHS
${_ZLIB_DIR}/lib
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
mark_as_advanced(Z_LIBRARY)
if (Z_LIBRARY)
set(Z_FOUND TRUE)
endif (Z_LIBRARY)
set(ZLIB_INCLUDE_DIRS
${ZLIB_INCLUDE_DIR}
)
if (Z_FOUND)
set(ZLIB_LIBRARIES
${ZLIB_LIBRARIES}
${Z_LIBRARY}
)
endif (Z_FOUND)
if (ZLIB_INCLUDE_DIRS AND ZLIB_LIBRARIES)
set(ZLIB_FOUND TRUE)
endif (ZLIB_INCLUDE_DIRS AND ZLIB_LIBRARIES)
if (ZLIB_FOUND)
if (NOT ZLIB_FIND_QUIETLY)
message(STATUS "Found ZLIB: ${ZLIB_LIBRARIES}")
endif (NOT ZLIB_FIND_QUIETLY)
else (ZLIB_FOUND)
if (ZLIB_FIND_REQUIRED)
message(FATAL_ERROR "Could not find ZLIB")
endif (ZLIB_FIND_REQUIRED)
endif (ZLIB_FOUND)
# show the ZLIB_INCLUDE_DIRS and ZLIB_LIBRARIES variables only in the advanced view
mark_as_advanced(ZLIB_INCLUDE_DIRS ZLIB_LIBRARIES)
endif (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)

View File

@@ -0,0 +1,21 @@
# - MACRO_ADD_COMPILE_FLAGS(target_name flag1 ... flagN)
# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
# Copyright (c) 2006, Andreas Schneider, <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ADD_COMPILE_FLAGS _target)
get_target_property(_flags ${_target} COMPILE_FLAGS)
if (_flags)
set(_flags ${_flags} ${ARGN})
else (_flags)
set(_flags ${ARGN})
endif (_flags)
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS ${_flags})
endmacro (MACRO_ADD_COMPILE_FLAGS)

View File

@@ -0,0 +1,20 @@
# - MACRO_ADD_LINK_FLAGS(target_name flag1 ... flagN)
# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
# Copyright (c) 2006, Andreas Schneider, <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ADD_LINK_FLAGS _target)
get_target_property(_flags ${_target} LINK_FLAGS)
if (_flags)
set(_flags "${_flags} ${ARGN}")
else (_flags)
set(_flags "${ARGN}")
endif (_flags)
set_target_properties(${_target} PROPERTIES LINK_FLAGS "${_flags}")
endmacro (MACRO_ADD_LINK_FLAGS)

View File

@@ -0,0 +1,30 @@
# - MACRO_ADD_PLUGIN(name [WITH_PREFIX] file1 .. fileN)
#
# Create a plugin from the given source files.
# If WITH_PREFIX is given, the resulting plugin will have the
# prefix "lib", otherwise it won't.
#
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
# Copyright (c) 2006, Andreas Schneider, <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ADD_PLUGIN _target_NAME _with_PREFIX)
if (${_with_PREFIX} STREQUAL "WITH_PREFIX")
set(_first_SRC)
else (${_with_PREFIX} STREQUAL "WITH_PREFIX")
set(_first_SRC ${_with_PREFIX})
endif (${_with_PREFIX} STREQUAL "WITH_PREFIX")
add_library(${_target_NAME} MODULE ${_first_SRC} ${ARGN})
if (_first_SRC)
set_target_properties(${_target_NAME} PROPERTIES PREFIX "")
endif (_first_SRC)
endmacro (MACRO_ADD_PLUGIN _name _sources)

View File

@@ -0,0 +1,33 @@
# - macro_copy_file(_src _dst)
# Copies a file to ${_dst} only if ${_src} is different (newer) than ${_dst}
#
# Example:
# macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/icon.png ${CMAKE_CURRENT_BINARY_DIR}/.)
# Copies file icon.png to ${CMAKE_CURRENT_BINARY_DIR} directory
#
# Copyright (c) 2006-2007 Wengo
# Copyright (c) 2006-2008 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING file.
macro (macro_copy_file _src _dst)
# Removes all path containing .svn or CVS or CMakeLists.txt during the copy
if (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
if (CMAKE_VERBOSE_MAKEFILE)
message(STATUS "Copy file from ${_src} to ${_dst}")
endif (CMAKE_VERBOSE_MAKEFILE)
# Creates directory if necessary
get_filename_component(_path ${_dst} PATH)
file(MAKE_DIRECTORY ${_path})
execute_process(
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${_src} ${_dst}
OUTPUT_QUIET
)
endif (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
endmacro (macro_copy_file)

View File

@@ -0,0 +1,17 @@
# - MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource)
if (_insource)
message(SEND_ERROR "${_errorMessage}")
message(FATAL_ERROR "Remove the file CMakeCache.txt in ${CMAKE_SOURCE_DIR} first.")
endif (_insource)
endmacro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD)

View File

@@ -0,0 +1,100 @@
# - Run Doxygen
#
# Adds a doxygen target that runs doxygen to generate the html
# and optionally the LaTeX API documentation.
# The doxygen target is added to the doc target as dependency.
# i.e.: the API documentation is built with:
# make doc
#
# USAGE: INCLUDE IN PROJECT
#
# set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# include(UseDoxygen)
# Add the Doxyfile.in and UseDoxygen.cmake files to the projects source directory.
#
#
# Variables you may define are:
# DOXYFILE_OUTPUT_DIR - Path where the Doxygen output is stored. Defaults to "doc".
#
# DOXYFILE_LATEX_DIR - Directory where the Doxygen LaTeX output is stored. Defaults to "latex".
#
# DOXYFILE_HTML_DIR - Directory where the Doxygen html output is stored. Defaults to "html".
#
#
# Copyright (c) 2009-2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
# Copyright (c) 2010 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
macro(usedoxygen_set_default name value)
if(NOT DEFINED "${name}")
set("${name}" "${value}")
endif()
endmacro()
find_package(Doxygen)
if(DOXYGEN_FOUND)
find_file(DOXYFILE_IN
NAMES
doxy.config.in
PATHS
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_ROOT}/Modules/
NO_DEFAULT_PATH)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DOXYFILE_IN DEFAULT_MSG "DOXYFILE_IN")
endif()
if(DOXYGEN_FOUND AND DOXYFILE_IN_FOUND)
add_custom_target(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxy.config)
usedoxygen_set_default(DOXYFILE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
usedoxygen_set_default(DOXYFILE_HTML_DIR "html")
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_HTML_DIR}")
set(DOXYFILE_LATEX FALSE)
set(DOXYFILE_PDFLATEX FALSE)
set(DOXYFILE_DOT FALSE)
find_package(LATEX)
if(LATEX_COMPILER AND MAKEINDEX_COMPILER)
set(DOXYFILE_LATEX TRUE)
usedoxygen_set_default(DOXYFILE_LATEX_DIR "latex")
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
if(PDFLATEX_COMPILER)
set(DOXYFILE_PDFLATEX TRUE)
endif()
if(DOXYGEN_DOT_EXECUTABLE)
set(DOXYFILE_DOT TRUE)
endif()
add_custom_command(TARGET doxygen
POST_BUILD
COMMAND ${CMAKE_MAKE_PROGRAM}
WORKING_DIRECTORY "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
endif()
configure_file(${DOXYFILE_IN} ${CMAKE_CURRENT_BINARY_DIR}/doxy.config ESCAPE_QUOTES IMMEDIATE @ONLY)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doxy.trac.in)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxy.trac.in ${CMAKE_CURRENT_BINARY_DIR}/doxy.trac ESCAPE_QUOTES IMMEDIATE @ONLY)
add_custom_target(doxygen-trac ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxy.trac)
endif()
get_target_property(DOC_TARGET doc TYPE)
if(NOT DOC_TARGET)
add_custom_target(doc)
endif()
add_dependencies(doc doxygen)
endif()

132
config.h.cmake Normal file
View File

@@ -0,0 +1,132 @@
/* Name of package */
#cmakedefine PACKAGE "${APPLICATION_NAME}"
/* Version number of package */
#cmakedefine VERSION "${APPLICATION_VERSION}"
#cmakedefine LOCALEDIR "${LOCALE_INSTALL_DIR}"
#cmakedefine DATADIR "${DATADIR}"
#cmakedefine LIBDIR "${LIBDIR}"
#cmakedefine PLUGINDIR "${PLUGINDIR}"
#cmakedefine SYSCONFDIR "${SYSCONFDIR}"
#cmakedefine BINARYDIR "${BINARYDIR}"
#cmakedefine SOURCEDIR "${SOURCEDIR}"
/************************** HEADER FILES *************************/
/* Define to 1 if you have the <argp.h> header file. */
#cmakedefine HAVE_ARGP_H 1
/* Define to 1 if you have the <pty.h> header file. */
#cmakedefine HAVE_PTY_H 1
/* Define to 1 if you have the <termios.h> header file. */
#cmakedefine HAVE_TERMIOS_H 1
/* Define to 1 if you have the <openssl/aes.h> header file. */
#cmakedefine HAVE_OPENSSL_AES_H 1
/* Define to 1 if you have the <wspiapi.h> header file. */
#cmakedefine HAVE_WSPIAPI_H 1
/* Define to 1 if you have the <openssl/blowfish.h> header file. */
#cmakedefine HAVE_OPENSSL_BLOWFISH_H 1
/* Define to 1 if you have the <openssl/des.h> header file. */
#cmakedefine HAVE_OPENSSL_DES_H 1
/*************************** FUNCTIONS ***************************/
/* Define to 1 if you have the `vsnprintf' function. */
#cmakedefine HAVE_VSNPRINTF
/* Define to 1 if you have the `_vsnprintf' function. */
#cmakedefine HAVE__VSNPRINTF
/* Define to 1 if you have the `_vsnprintf_s' function. */
#cmakedefine HAVE__VSNPRINTF_S
/* Define to 1 if you have the `snprintf' function. */
#cmakedefine HAVE_SNPRINTF
/* Define to 1 if you have the `_snprintf' function. */
#cmakedefine HAVE__SNPRINTF
/* Define to 1 if you have the `_snprintf_s' function. */
#cmakedefine HAVE__SNPRINTF_S
/* Define to 1 if you have the `strncpy' function. */
#cmakedefine HAVE_STRNCPY
/* Define to 1 if you have the `cfmakeraw' function. */
#cmakedefine HAVE_CFMAKERAW 1
/* Define to 1 if you have the `getaddrinfo' function. */
#cmakedefine HAVE_GETADDRINFO 1
/* Define to 1 if you have the `gethostbyname' function. */
#cmakedefine HAVE_GETHOSTBYNAME 1
/* Define to 1 if you have the `poll' function. */
#cmakedefine HAVE_POLL 1
/* Define to 1 if you have the `select' function. */
#cmakedefine HAVE_SELECT 1
/* Define to 1 if you have the `regcomp' function. */
#cmakedefine HAVE_REGCOMP 1
/*************************** LIBRARIES ***************************/
/* Define to 1 if you have the `crypto' library (-lcrypto). */
#cmakedefine HAVE_LIBCRYPTO 1
/* Define to 1 if you have the `gcrypt' library (-lgcrypt). */
#cmakedefine HAVE_LIBGCRYPT 1
/* Define to 1 if you have the `z' library (-lz). */
#cmakedefine HAVE_LIBZ 1
/**************************** OPTIONS ****************************/
/* Define to 1 if you want to enable ZLIB */
#cmakedefine WITH_LIBZ 1
/* Define to 1 if you want to enable SFTP */
#cmakedefine WITH_SFTP 1
/* Define to 1 if you want to enable SSH1 */
#cmakedefine WITH_SSH1 1
/* Define to 1 if you want to enable server support */
#cmakedefine WITH_SERVER 1
/* Define to 1 if you want to enable debug output for crypto functions */
#cmakedefine DEBUG_CRYPTO 1
/* Define to 1 if you want to enable pcap output support (experimental) */
#cmakedefine WITH_PCAP 1
/* Define to 1 if you want to enable calltrace debug output */
#cmakedefine DEBUG_CALLTRACE 1
/*************************** ENDIAN *****************************/
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#cmakedefine WORDS_BIGENDIAN 1
/************************* MS Windows ***************************/
#ifdef _WIN32
# ifdef _MSC_VER
/* On Microsoft compilers define inline to __inline on all others use inline */
# undef inline
# define inline __inline
# undef strdup
# define strdup _strdup
# endif // _MSC_VER
#endif /* _WIN32 */

View File

@@ -1,193 +0,0 @@
/* config.h. Manually tweaked for Windows. */
/* Define to 1 if you have the `cfmakeraw' function. */
#define HAVE_CFMAKERAW 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
/* #undef HAVE_DOPRNT */
/* Define to 1 if you have the `endpwent' function. */
/* #undef HAVE_ENDPWENT */
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the <gcrypt.h> header file. */
/* #undef HAVE_GCRYPT_H */
/* Define to 1 if you have the `getaddrinfo' function. */
#define HAVE_GETADDRINFO 1
/* Define to 1 if you have the `gethostbyname' function. */
#define HAVE_GETHOSTBYNAME 1
/* Define to 1 if you have the `getpass' function. */
/* #undef HAVE_GETPASS */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `crypto' library (-lcrypto). */
#define HAVE_LIBCRYPTO 1
/* Define to 1 if you have the `gcrypt' library (-lgcrypt). */
/* #undef HAVE_LIBGCRYPT */
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#define HAVE_MALLOC 1
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the <netdb.h> header file. */
/* #undef HAVE_NETDB_H */
/* Define to 1 if you have the <netinet/in.h> header file. */
/* #undef HAVE_NETINET_IN_H */
/* Define to 1 if you have the <openssl/aes.h> header file. */
#define HAVE_OPENSSL_AES_H 1
/* Define to 1 if you have the <openssl/blowfish.h> header file. */
#define HAVE_OPENSSL_BLOWFISH_H 1
/* Define to 1 if you have the <openssl/des.h> header file. */
#define HAVE_OPENSSL_DES_H 1
/* Define to 1 if you have the `poll' function. */
/* #undef HAVE_POLL */
/* Define to 1 if you have the <pty.h> header file. */
/* #undef HAVE_PTY_H */
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
and to 0 otherwise. */
#define HAVE_REALLOC 1
/* Define to 1 if you have the `select' function. */
#define HAVE_SELECT 1
/* Define to 1 if you have the `socket' function. */
#define HAVE_SOCKET 1
/* Define to 1 if you want to enable SSH1 */
/* #undef HAVE_SSH1 */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strchr' function. */
#define HAVE_STRCHR 1
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strstr' function. */
#define HAVE_STRSTR 1
/* Define to 1 if you have the <sys/poll.h> header file. */
/* #undef HAVE_SYS_POLL_H */
/* Define to 1 if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define to 1 if you have the <sys/socket.h> header file. */
/* #undef HAVE_SYS_SOCKET_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <termios.h> header file. */
/* #undef HAVE_TERMIOS_H */
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Define to 1 if you have the <zlib.h> header file. */
#define HAVE_ZLIB_H 1
/* Name of package */
#define PACKAGE "libssh"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "aris@0xbadc0de.be"
/* Define to the full name of this package. */
#define PACKAGE_NAME "libssh"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libssh 0.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libssh"
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.2.1-win-svn"
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
/* Define to the type of arg 1 for `select'. */
#define SELECT_TYPE_ARG1 int
/* Define to the type of args 2, 3 and 4 for `select'. */
#define SELECT_TYPE_ARG234 (fd_set *)
/* Define to the type of arg 5 for `select'. */
#define SELECT_TYPE_ARG5 (struct timeval *)
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
#define VERSION "0.2.1-win-svn"
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to rpl_malloc if the replacement function should be used. */
/* #undef malloc */
/* Define to rpl_realloc if the replacement function should be used. */
/* #undef realloc */

View File

@@ -1,135 +0,0 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT([libssh], 0.2.1-svn, [aris@0xbadc0de.be])
AM_INIT_AUTOMAKE(1.9)
AC_CONFIG_SRCDIR([sample.c])
AC_CONFIG_HEADER([config.h])
AM_MAINTAINER_MODE
# LT Version numbers, remember to change them just *before* a release.
# (Interfaces removed: CURRENT++, AGE=0, REVISION=0)
# (Interfaces added: CURRENT++, AGE++, REVISION=0)
# (No interfaces changed: REVISION++)
LIBSSH_CURRENT=3
LIBSSH_AGE=1
LIBSSH_REVISION=0
AC_SUBST(LIBSSH_CURRENT)
AC_SUBST(LIBSSH_AGE)
AC_SUBST(LIBSSH_REVISION)
# Check for the OS.
AC_CANONICAL_HOST
case "$host" in
*-apple*)
LIBSSH_LDFLAGS="-prebind -seg1addr 0x3a000000 -headerpad_max_install_names"
;;
*)
LIBSSH_LDFLAGS=""
;;
esac
AC_SUBST(LIBSSH_LDFLAGS)
AC_MSG_CHECKING([version script options])
case "$host" in
*-*-linux*)
LIBSSH_VERS="$LIBSSH_LDFLAGS -Wl,--version-script,libssh.vers"
;;
*-*-gnu*)
LIBSSH_VERS="$LIBSSH_LDFLAGS -Wl,--version-script,libssh.vers"
;;
esac
AC_ARG_WITH([versioned-symbol],
AC_HELP_STRING([--with-versioned-symbol],[Use versioned symbols]),
[if test "$withval" = "yes"; then
LIBSSH_VERS="$LIBSSH_LDFLAGS -Wl,--version-script,libssh.vers"
else
LIBSSH_VERS=""
fi], [ : ])
AC_SUBST(LIBSSH_VERS)
enable_ssh1=${enable_ssh1:-"no"}
AC_ARG_ENABLE(ssh1, AC_HELP_STRING([--enable-ssh1], [enable SSH1 support]))
AC_MSG_CHECKING([for SSH1 support])
if test "$enable_ssh1" = "yes" ; then
AC_DEFINE(HAVE_SSH1,1,[Define to 1 if you want to enable SSH1])
fi
AC_MSG_RESULT([$enable_ssh1])
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
AC_C_BIGENDIAN
AC_CHECK_PROG([DOXYGEN], [doxygen], [yes], [no])
AM_CONDITIONAL([HAS_DOXYGEN], [test x"$DOXYGEN" = xyes])
# Checks for libraries.
with_gcrypt=${with_gcrypt:-"no"}
AC_ARG_WITH([libgcrypt],
AC_HELP_STRING([--with-libgcrypt],[Use libgcrypt instead of libcrypto]),
[if test "$withval" = "yes"; then
with_gcrypt="yes"
AC_CHECK_LIB([gcrypt], [gcry_md_open])
fi], [ : ])
if test "$with_gcrypt" = "no"; then
AC_CHECK_LIB([crypto], [BN_init])
fi
AC_CHECK_LIB([z], [deflateInit_])
AC_SEARCH_LIBS([hstrerror],[nsl resolv])
AC_SEARCH_LIBS([getaddrinfo],[nsl socket])
AC_SEARCH_LIBS([gethostbyname],[nsl resolv])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h \
sys/time.h termios.h unistd.h openssl/aes.h openssl/blowfish.h \
openssl/des.h zlib.h sys/poll.h stdint.h pty.h gcrypt.h])
#Warn user when no openssl available
if test "$with_gcrypt" = "no" && (test "$ac_cv_header_openssl_aes_h" != "yes" ||
test "$ac_cv_header_openssl_blowfish_h" != "yes"); then
echo "Can't find valid openssl files [e.g openssl/aes.h]"
echo "Please install Openssl-devel"
exit
fi
#Warn user when no libgcrypt available
if test "$with_gcrypt" = "yes" && test "$ac_cv_header_gcrypt_h" != "yes"; then
echo "Can't find valid libgcrypt files [e.g gcrypt.h]"
echo "Please install libgcrypt-devel"
exit
fi
#if ! test x"$ac_cv_header_zlib_h" != x"yes"; then
# echo "Can't find zlib.h"
# echo "Compression support won't be compiled in"
#fi
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_HEADER_TIME
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([endpwent getaddrinfo gethostbyname getpass memmove memset \
cfmakeraw select socket strchr strdup strerror strstr poll])
AC_CONFIG_FILES([Makefile
libssh/Makefile
include/Makefile
include/libssh/Makefile])
AC_OUTPUT

View File

@@ -1,7 +0,0 @@
libssh for Debian
----------------------
This is a package for the library libssh with the soname 2.
There are some other projects which have nearly the same name, so be careful.
-- Laurent Bigonville <bigon@bigon.be> Fri, 27 Jul 2007 14:59:00 +0200

50
debian/changelog vendored
View File

@@ -1,50 +0,0 @@
libssh (0.2+svn20070321-5) UNRELEASED; urgency=low
* NOT RELEASED YET
* Use now official Vcs-* field
* Use new Homepage field instead of old pseudo-field
* BumpStandards-Version to 3.7.3 (no further changes)
* debian/libssh-2-doc.doc-base: fix doc-base-unknown-section
-- Laurent Bigonville <bigon@bigon.be> Thu, 08 Nov 2007 05:59:18 +0100
libssh (0.2+svn20070321-4) unstable; urgency=low
* debian/control:
- Add XS-Vcs-Svn and XS-Vcs-Browser fields.
- Change to ${binary:Version} for versionized dependencies.
* Add debian/README.Debian to disambiguate the package name
-- Laurent Bigonville <bigon@bigon.be> Fri, 27 Jul 2007 15:00:06 +0200
libssh (0.2+svn20070321-3) unstable; urgency=low
* Fix wrong versionized Replaces for -doc package
-- Laurent Bigonville <bigon@bigon.be> Thu, 5 Apr 2007 17:58:27 +0200
libssh (0.2+svn20070321-2) unstable; urgency=low
* Split devel package into devel and documentation packages
-- Laurent Bigonville <bigon@bigon.be> Mon, 26 Mar 2007 15:29:51 +0200
libssh (0.2+svn20070321-1) unstable; urgency=low
* New svn snapshot:
- Fix broken include in include/libssh/server.h (Closes: #410020)
- Fix nasty bug in server side code
-- Laurent Bigonville <bigon@bigon.be> Mon, 26 Mar 2007 15:06:40 +0200
libssh (0.2-1) unstable; urgency=low
* New upstream release.
-- Laurent Bigonville <bigon@bigon.be> Fri, 29 Dec 2006 07:40:20 +0100
libssh (0.2~rc-1) unstable; urgency=low
* Initial release (Closes: #316872)
-- Jean-Philippe Garcia Ballester <giga@le-pec.org> Wed, 20 Dec 2006 23:56:50 +0100

1
debian/compat vendored
View File

@@ -1 +0,0 @@
5

65
debian/control vendored
View File

@@ -1,65 +0,0 @@
Source: libssh
Section: libs
Priority: optional
Maintainer: Jean-Philippe Garcia Ballester <giga@le-pec.org>
Uploaders: Laurent Bigonville <bigon@bigon.be>
Build-Depends: cdbs, debhelper (>= 5), libgcrypt11-dev, libz-dev, doxygen
Standards-Version: 3.7.3
Vcs-Svn: svn://svn.berlios.de/libssh/trunk
Vcs-Browser: http://svn.berlios.de/wsvn/libssh/trunk/
Homepage: http://0xbadc0de.be/wiki/doku.php?id=libssh:libssh
Package: libssh-2
Section: libs
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: A tiny C SSH library
The ssh library was designed to be used by programmers needing a working SSH
implementation by the mean of a library. The complete control of the client
is made by the programmer. With libssh, you can remotely execute programs,
transfer files, use a secure and transparent tunnel for your remote programs.
With its SFTP implementation, you can play with remote files easily.
Package: libssh-2-dev
Provides: libssh-dev
Section: libdevel
Architecture: any
Depends: libssh-2 (= ${binary:Version}), libgcrypt11-dev, zlib1g-dev
Suggests: libssh-2-doc
Conflicts: libssh-dev
Description: A tiny C SSH library. Development files
The ssh library was designed to be used by programmers needing a working SSH
implementation by the mean of a library. The complete control of the client
is made by the programmer. With libssh, you can remotely execute programs,
transfer files, use a secure and transparent tunnel for your remote programs.
With its SFTP implementation, you can play with remote files easily.
.
This package contains development files.
Package: libssh-2-dbg
Priority: extra
Section: libdevel
Architecture: any
Depends: libssh-2 (= ${binary:Version})
Description: A tiny C SSH library. Debug symbols
The ssh library was designed to be used by programmers needing a working SSH
implementation by the mean of a library. The complete control of the client
is made by the programmer. With libssh, you can remotely execute programs,
transfer files, use a secure and transparent tunnel for your remote programs.
With its SFTP implementation, you can play with remote files easily.
.
This package contains debug symbols.
Package: libssh-2-doc
Section: doc
Architecture: all
Suggests: doc-base
Replaces: libssh-2-dev (<< 0.2+svn20070321-2)
Description: A tiny C SSH library. Documentation files
The ssh library was designed to be used by programmers needing a working SSH
implementation by the mean of a library. The complete control of the client
is made by the programmer. With libssh, you can remotely execute programs,
transfer files, use a secure and transparent tunnel for your remote programs.
With its SFTP implementation, you can play with remote files easily.
.
This package contains documentation files.

33
debian/copyright vendored
View File

@@ -1,33 +0,0 @@
This package was debianized by Laurent Bigonville <bigon@bigon.be> on
Thu, 16 Nov 2006 20:34:01 +0100.
It was downloaded from http://www.0xbadc0de.be/
Upstream Author: Aris Adamantiadis (aka spacewalker) <aris@0xbadc0de.be>
Copyright: 2003 Aris Adamantiadis
License:
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On Debian systems, the complete text of the GNU Lesser General
Public License can be found in `/usr/share/common-licenses/LGPL'.
The Debian packaging is
(C) 2005-2006, Jean-Philippe Garcia Ballester <giga@le-pec.org>,
(C) 2006-2007, Laurent Bigonville <bigon@bigon.be> and
is licensed under the GPL, see `/usr/share/common-licenses/GPL'.

View File

@@ -1,2 +0,0 @@
debian/tmp/usr/include/*
debian/tmp/usr/lib/libssh.{a,la,so}

View File

@@ -1,9 +0,0 @@
Document: libssh
Title: Debian libssh Manual
Author: Aris Adamantiadis <aris@0xbadc0de.be>
Abstract: This manual describes libssh API.
Section: Apps/Programming
Format: HTML
Index: /usr/share/doc/libssh-2-doc/html/index.html
Files: /usr/share/doc/libssh-2-doc/html/*

View File

@@ -1 +0,0 @@
debian/tmp/usr/share/doc/libssh/html

View File

@@ -1 +0,0 @@
debian/tmp/usr/share/doc/libssh/examples/*

View File

@@ -1 +0,0 @@
doxygen/man/man3/ssh_*

View File

@@ -1 +0,0 @@
debian/tmp/usr/lib/libssh.so.*

View File

@@ -1,2 +0,0 @@
# We use libssh-2 name to avoid name clash with libssh2 package.
libssh-2: package-name-doesnt-match-sonames libssh2

21
debian/rules vendored
View File

@@ -1,21 +0,0 @@
#!/usr/bin/make -f
# Sample debian/rules that uses cdbs. Originaly written by Robert Millan.
# This file is public domain.
DEB_AUTO_CLEANUP_RCS := yes
# Add here any variable or target overrides you need
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/debhelper.mk
#include /usr/share/cdbs/1/rules/simple-patchsys.mk
DEB_CONFIGURE_EXTRA_FLAGS = --with-libgcrypt --enable-ssh1
DEB_DBG_PACKAGE_libssh-2 = libssh-2-dbg
install/libssh-2::
install -D -m 644 debian/libssh-2.lintian-overrides debian/libssh-2/usr/share/lintian/overrides/libssh-2
install/libssh-2-doc::
make install-doc DESTDIR=debian/tmp

2
debian/watch vendored
View File

@@ -1,2 +0,0 @@
version=3
http://0xbadc0de.be/libssh/libssh-(.*)\.tgz

5
doc/CMakeLists.txt Normal file
View File

@@ -0,0 +1,5 @@
#
# Build the documentation
#
include(UseDoxygen OPTIONAL)

1
doc/TracFooter.html Normal file
View File

@@ -0,0 +1 @@
<!-- Doxygen TracFooter -->

4
doc/TracHeader.html Normal file
View File

@@ -0,0 +1,4 @@
<!-- Doxygen TracHeader -->
<style>@import url(/chrome/site/doxygen.css);</style>
<style>@import url(/chrome/site/tabs.css);</style>
<!-- /Doxygen TracHeader -->

1445
doc/doxy.config.in Normal file

File diff suppressed because it is too large Load Diff

1546
doc/doxy.trac.in Normal file

File diff suppressed because it is too large Load Diff

12
doc/mainpage.dox Normal file
View File

@@ -0,0 +1,12 @@
/**
* @mainpage
* This manual documents the libssh C API.
*
* There are several other places to look for libssh information, such as the
* <a href="http://dev.libssh.org/wiki/Tutorial" target="_blank">tutorial</a>
* and the specification; those can be found at the <a
* href="http://www.libssh.org/" target="_blank">libssh website</a>.
*
* To be continued...
*/

38
examples/CMakeLists.txt Normal file
View File

@@ -0,0 +1,38 @@
project(libssh-examples C)
set(examples_SRCS
authentication.c
knownhosts.c
connect_ssh.c
)
include_directories(
${LIBSSH_PUBLIC_INCLUDE_DIRS}
${LIBSSH_PRIVATE_INCLUDE_DIRS}
)
add_executable(libssh_scp libssh_scp.c ${examples_SRCS})
add_executable(scp_download scp_download.c ${examples_SRCS})
add_executable(samplessh sample.c ${examples_SRCS})
add_executable(exec exec.c ${examples_SRCS})
target_link_libraries(libssh_scp ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(scp_download ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(samplessh ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(exec ${LIBSSH_SHARED_LIBRARY})
include_directories(
${LIBSSH_PUBLIC_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
)
if (WITH_SFTP)
add_executable(samplesftp samplesftp.c ${examples_SRCS})
target_link_libraries(samplesftp ${LIBSSH_SHARED_LIBRARY})
endif (WITH_SFTP)
if (WITH_SERVER)
add_executable(samplesshd samplesshd.c)
target_link_libraries(samplesshd ${LIBSSH_SHARED_LIBRARY})
endif (WITH_SERVER)

125
examples/authentication.c Normal file
View File

@@ -0,0 +1,125 @@
/*
* authentication.c
* This file contains an example of how to do an authentication to a
* SSH server using libssh
*/
/*
Copyright 2003-2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <libssh/libssh.h>
#include "examples_common.h"
int authenticate_kbdint(ssh_session session){
int err=ssh_userauth_kbdint(session,NULL,NULL);
const char *name, *instruction, *prompt;
char *ptr;
char buffer[128];
int i,n;
char echo;
while (err==SSH_AUTH_INFO){
name=ssh_userauth_kbdint_getname(session);
instruction=ssh_userauth_kbdint_getinstruction(session);
n=ssh_userauth_kbdint_getnprompts(session);
if(strlen(name)>0)
printf("%s\n",name);
if(strlen(instruction)>0)
printf("%s\n",instruction);
for(i=0;i<n;++i){
prompt=ssh_userauth_kbdint_getprompt(session,i,&echo);
if(echo){
printf("%s",prompt);
fgets(buffer,sizeof(buffer),stdin);
buffer[sizeof(buffer)-1]=0;
if((ptr=strchr(buffer,'\n')))
*ptr=0;
if (ssh_userauth_kbdint_setanswer(session,i,buffer) < 0) {
return SSH_AUTH_ERROR;
}
memset(buffer,0,strlen(buffer));
} else {
ptr=getpass(prompt);
if (ssh_userauth_kbdint_setanswer(session,i,ptr) < 0) {
return SSH_AUTH_ERROR;
}
}
}
err=ssh_userauth_kbdint(session,NULL,NULL);
}
return err;
}
int authenticate_console(ssh_session session){
int rc;
int method;
char *password;
char *banner;
// Try to authenticate
rc = ssh_userauth_none(session, NULL);
if (rc == SSH_AUTH_ERROR) {
perror("Authentication failed.");
return rc;
}
method = ssh_auth_list(session);
while (rc != SSH_AUTH_SUCCESS) {
// Try to authenticate with public key first
if (method & SSH_AUTH_METHOD_PUBLICKEY) {
rc = ssh_userauth_autopubkey(session, NULL);
if (rc == SSH_AUTH_ERROR) {
perror("Authentication failed.");
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
// Try to authenticate with keyboard interactive";
if (method & SSH_AUTH_METHOD_INTERACTIVE) {
rc = authenticate_kbdint(session);
if (rc == SSH_AUTH_ERROR) {
perror("Authentication failed.");
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
password=getpass("Password: ");
// Try to authenticate with password
if (method & SSH_AUTH_METHOD_PASSWORD) {
rc = ssh_userauth_password(session, NULL, password);
if (rc == SSH_AUTH_ERROR) {
perror("Authentication failed.");
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
}
banner = ssh_get_issue_banner(session);
if (banner) {
printf("%s\n",banner);
free(banner);
}
return rc;
}

63
examples/connect_ssh.c Normal file
View File

@@ -0,0 +1,63 @@
/*
* connect_ssh.c
* This file contains an example of how to connect to a
* SSH server using libssh
*/
/*
Copyright 2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include <libssh/libssh.h>
#include "examples_common.h"
#include <stdio.h>
ssh_session connect_ssh(const char *host, const char *user,int verbosity){
ssh_session session;
int auth=0;
session=ssh_new();
if (session == NULL) {
return NULL;
}
if(user != NULL){
if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0) {
ssh_disconnect(session);
return NULL;
}
}
if (ssh_options_set(session, SSH_OPTIONS_HOST, host) < 0) {
return NULL;
}
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
if(ssh_connect(session)){
fprintf(stderr,"Connection failed : %s\n",ssh_get_error(session));
ssh_disconnect(session);
return NULL;
}
if(verify_knownhost(session)<0){
ssh_disconnect(session);
return NULL;
}
auth=authenticate_console(session);
if(auth==SSH_AUTH_SUCCESS){
return session;
} else if(auth==SSH_AUTH_DENIED){
fprintf(stderr,"Authentication failed\n");
} else {
fprintf(stderr,"Error while authenticating : %s\n",ssh_get_error(session));
}
ssh_disconnect(session);
return NULL;
}

View File

@@ -0,0 +1,22 @@
/*
Copyright 2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#ifndef EXAMPLES_COMMON_H_
#define EXAMPLES_COMMON_H_
#include <libssh/libssh.h>
int authenticate_console(ssh_session session);
int authenticate_kbdint(ssh_session session);
int verify_knownhost(ssh_session session);
ssh_session connect_ssh(const char *hostname, const char *user, int verbosity);
#endif /* EXAMPLES_COMMON_H_ */

57
examples/exec.c Normal file
View File

@@ -0,0 +1,57 @@
/* simple exec example */
#include <stdio.h>
#include <libssh/libssh.h>
#include "examples_common.h"
int main(void) {
ssh_session session;
ssh_channel channel;
char buf[4096];
int rc;
session = connect_ssh("localhost", NULL, 0);
if (session == NULL) {
return 1;
}
channel = channel_new(session);;
if (channel == NULL) {
ssh_disconnect(session);
ssh_finalize();
return 1;
}
rc = channel_open_session(channel);
if (rc < 0) {
channel_close(channel);
ssh_disconnect(session);
ssh_finalize();
return 1;
}
rc = channel_request_exec(channel, "ps aux");
if (rc < 0) {
channel_close(channel);
ssh_disconnect(session);
ssh_finalize();
return 1;
}
do {
if (channel_is_open(channel)) {
rc = channel_read(channel, buf, sizeof(buf), 0);
if(rc > 0){
fwrite(buf,1,rc,stdout);
}
}
} while(rc > 0);
channel_send_eof(channel);
channel_close(channel);
ssh_disconnect(session);
ssh_finalize();
return 0;
}

88
examples/knownhosts.c Normal file
View File

@@ -0,0 +1,88 @@
/*
* knownhosts.c
* This file contains an example of how verify the identity of a
* SSH server using libssh
*/
/*
Copyright 2003-2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <libssh/libssh.h>
#include "examples_common.h"
int verify_knownhost(ssh_session session){
char *hexa;
int state;
char buf[10];
unsigned char *hash = NULL;
int hlen;
state=ssh_is_server_known(session);
hlen = ssh_get_pubkey_hash(session, &hash);
if (hlen < 0) {
return -1;
}
switch(state){
case SSH_SERVER_KNOWN_OK:
break; /* ok */
case SSH_SERVER_KNOWN_CHANGED:
fprintf(stderr,"Host key for server changed : server's one is now :\n");
ssh_print_hexa("Public key hash",hash, hlen);
free(hash);
fprintf(stderr,"For security reason, connection will be stopped\n");
return -1;
case SSH_SERVER_FOUND_OTHER:
fprintf(stderr,"The host key for this server was not found but an other type of key exists.\n");
fprintf(stderr,"An attacker might change the default server key to confuse your client"
"into thinking the key does not exist\n"
"We advise you to rerun the client with -d or -r for more safety.\n");
return -1;
case SSH_SERVER_FILE_NOT_FOUND:
fprintf(stderr,"Could not find known host file. If you accept the host key here,\n");
fprintf(stderr,"the file will be automatically created.\n");
/* fallback to SSH_SERVER_NOT_KNOWN behavior */
case SSH_SERVER_NOT_KNOWN:
hexa = ssh_get_hexa(hash, hlen);
fprintf(stderr,"The server is unknown. Do you trust the host key ?\n");
fprintf(stderr, "Public key hash: %s\n", hexa);
free(hexa);
fgets(buf,sizeof(buf),stdin);
if(strncasecmp(buf,"yes",3)!=0){
return -1;
}
fprintf(stderr,"This new key will be written on disk for further usage. do you agree ?\n");
fgets(buf,sizeof(buf),stdin);
if(strncasecmp(buf,"yes",3)==0){
if (ssh_write_knownhost(session) < 0) {
free(hash);
fprintf(stderr, "error %s\n", strerror(errno));
return -1;
}
}
break;
case SSH_SERVER_ERROR:
free(hash);
fprintf(stderr,"%s",ssh_get_error(session));
return -1;
}
free(hash);
return 0;
}

304
examples/libssh_scp.c Normal file
View File

@@ -0,0 +1,304 @@
/* libssh_scp.c
* Sample implementation of a SCP client
*/
/*
Copyright 2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <libssh/libssh.h>
#include "examples_common.h"
char **sources;
int nsources;
char *destination;
int verbosity=0;
struct location {
int is_ssh;
char *user;
char *host;
char *path;
ssh_session session;
ssh_scp scp;
FILE *file;
};
enum {
READ,
WRITE
};
static void usage(const char *argv0){
fprintf(stderr,"Usage : %s [options] [[user@]host1:]file1 ... \n"
" [[user@]host2:]destination\n"
"sample scp client - libssh-%s\n",
// "Options :\n",
// " -r : use RSA to verify host public key\n",
argv0,
ssh_version(0));
exit(0);
}
static int opts(int argc, char **argv){
int i;
while((i=getopt(argc,argv,"v"))!=-1){
switch(i){
case 'v':
verbosity++;
break;
default:
fprintf(stderr,"unknown option %c\n",optopt);
usage(argv[0]);
return -1;
}
}
nsources=argc-optind-1;
if(nsources < 1){
usage(argv[0]);
return -1;
}
sources=malloc((nsources + 1) * sizeof(char *));
if(sources == NULL)
return -1;
for(i=0;i<nsources;++i){
sources[i] = argv[optind];
optind++;
}
sources[i]=NULL;
destination=argv[optind];
return 0;
}
static struct location *parse_location(char *loc){
struct location *location=malloc(sizeof(struct location));
char *ptr;
location->host=location->user=NULL;
ptr=strchr(loc,':');
if(ptr != NULL){
location->is_ssh=1;
location->path=strdup(ptr+1);
*ptr='\0';
ptr=strchr(loc,'@');
if(ptr != NULL){
location->host=strdup(ptr+1);
*ptr='\0';
location->user=strdup(loc);
} else {
location->host=strdup(loc);
}
} else {
location->is_ssh=0;
location->path=strdup(loc);
}
return location;
}
static int open_location(struct location *loc, int flag){
if(loc->is_ssh && flag==WRITE){
loc->session=connect_ssh(loc->host,loc->user,verbosity);
if(!loc->session){
fprintf(stderr,"Couldn't connect to %s\n",loc->host);
return -1;
}
loc->scp=ssh_scp_new(loc->session,SSH_SCP_WRITE,loc->path);
if(!loc->scp){
fprintf(stderr,"error : %s\n",ssh_get_error(loc->session));
return -1;
}
if(ssh_scp_init(loc->scp)==SSH_ERROR){
fprintf(stderr,"error : %s\n",ssh_get_error(loc->session));
ssh_scp_free(loc->scp);
return -1;
}
return 0;
} else if(loc->is_ssh && flag==READ){
loc->session=connect_ssh(loc->host, loc->user,verbosity);
if(!loc->session){
fprintf(stderr,"Couldn't connect to %s\n",loc->host);
return -1;
}
loc->scp=ssh_scp_new(loc->session,SSH_SCP_READ,loc->path);
if(!loc->scp){
fprintf(stderr,"error : %s\n",ssh_get_error(loc->session));
return -1;
}
if(ssh_scp_init(loc->scp)==SSH_ERROR){
fprintf(stderr,"error : %s\n",ssh_get_error(loc->session));
ssh_scp_free(loc->scp);
return -1;
}
return 0;
} else {
loc->file=fopen(loc->path,flag==READ ? "r":"w");
if(!loc->file){
if(errno==EISDIR){
if(chdir(loc->path)){
fprintf(stderr,"Error changing directory to %s: %s\n",loc->path,strerror(errno));
return -1;
}
return 0;
}
fprintf(stderr,"Error opening %s: %s\n",loc->path,strerror(errno));
return -1;
}
return 0;
}
return -1;
}
/** @brief copies files from source location to destination
* @param src source location
* @param dest destination location
* @param recursive Copy also directories
*/
static int do_copy(struct location *src, struct location *dest, int recursive){
int size;
socket_t fd;
struct stat s;
int w,r;
char buffer[16384];
int total=0;
int mode;
char *filename;
/* recursive mode doesn't work yet */
(void)recursive;
/* Get the file name and size*/
if(!src->is_ssh){
fd=fileno(src->file);
fstat(fd,&s);
size=s.st_size;
mode=s.st_mode;
filename=ssh_basename(src->path);
} else {
size=0;
do {
r=ssh_scp_pull_request(src->scp);
if(r==SSH_SCP_REQUEST_NEWDIR){
ssh_scp_deny_request(src->scp,"Not in recursive mode");
continue;
}
if(r==SSH_SCP_REQUEST_NEWFILE){
size=ssh_scp_request_get_size(src->scp);
filename=strdup(ssh_scp_request_get_filename(src->scp));
mode=ssh_scp_request_get_permissions(src->scp);
//ssh_scp_accept_request(src->scp);
break;
}
if(r==SSH_ERROR){
fprintf(stderr,"Error: %s\n",ssh_get_error(src->session));
return -1;
}
} while(r != SSH_SCP_REQUEST_NEWFILE);
}
if(dest->is_ssh){
r=ssh_scp_push_file(dest->scp,src->path,size,0644);
// snprintf(buffer,sizeof(buffer),"C0644 %d %s\n",size,src->path);
if(r==SSH_ERROR){
fprintf(stderr,"error: %s\n",ssh_get_error(dest->session));
ssh_scp_free(dest->scp);
return -1;
}
} else {
if(!dest->file){
dest->file=fopen(filename,"w");
if(!dest->file){
fprintf(stderr,"Cannot open %s for writing: %s\n",filename,strerror(errno));
if(src->is_ssh)
ssh_scp_deny_request(src->scp,"Cannot open local file");
return -1;
}
}
if(src->is_ssh){
ssh_scp_accept_request(src->scp);
}
}
do {
if(src->is_ssh){
r=ssh_scp_read(src->scp,buffer,sizeof(buffer));
if(r==SSH_ERROR){
fprintf(stderr,"Error reading scp: %s\n",ssh_get_error(src->session));
return -1;
}
if(r==0)
break;
} else {
r=fread(buffer,1,sizeof(buffer),src->file);
if(r==0)
break;
if(r<0){
fprintf(stderr,"Error reading file: %s\n",strerror(errno));
return -1;
}
}
if(dest->is_ssh){
w=ssh_scp_write(dest->scp,buffer,r);
if(w == SSH_ERROR){
fprintf(stderr,"Error writing in scp: %s\n",ssh_get_error(dest->session));
ssh_scp_free(dest->scp);
dest->scp=NULL;
return -1;
}
} else {
w=fwrite(buffer,r,1,dest->file);
if(w<=0){
fprintf(stderr,"Error writing in local file: %s\n",strerror(errno));
return -1;
}
}
total+=r;
} while(total < size);
printf("wrote %d bytes\n",total);
return 0;
}
int main(int argc, char **argv){
struct location *dest, *src;
int i;
int r;
if(opts(argc,argv)<0)
return EXIT_FAILURE;
dest=parse_location(destination);
if(open_location(dest,WRITE)<0)
return EXIT_FAILURE;
for(i=0;i<nsources;++i){
src=parse_location(sources[i]);
if(open_location(src,READ)<0){
return EXIT_FAILURE;
}
if(do_copy(src,dest,0) < 0){
break;
}
}
if(dest->is_ssh){
r=ssh_scp_close(dest->scp);
if(r == SSH_ERROR){
fprintf(stderr,"Error closing scp: %s\n",ssh_get_error(dest->session));
ssh_scp_free(dest->scp);
dest->scp=NULL;
return -1;
}
} else {
fclose(dest->file);
dest->file=NULL;
}
ssh_disconnect(dest->session);
ssh_finalize();
return 0;
}

528
examples/sample.c Normal file
View File

@@ -0,0 +1,528 @@
/* client.c */
/*
Copyright 2003-2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include "config.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <sys/select.h>
#include <sys/time.h>
#ifdef HAVE_PTY_H
#include <pty.h>
#endif
#include <sys/ioctl.h>
#include <signal.h>
#include <errno.h>
#include <libssh/callbacks.h>
#include <libssh/libssh.h>
#include <libssh/sftp.h>
#include <fcntl.h>
#include "examples_common.h"
#define MAXCMD 10
char *host;
char *user;
char *cmds[MAXCMD];
struct termios terminal;
#ifdef WITH_PCAP
/* this header file won't be necessary in the future */
#include <libssh/pcap.h>
char *pcap_file=NULL;
#endif
char *proxycommand;
static int auth_callback(const char *prompt, char *buf, size_t len,
int echo, int verify, void *userdata) {
char *answer = NULL;
char *ptr;
(void) verify;
(void) userdata;
if (echo) {
while ((answer = fgets(buf, len, stdin)) == NULL);
if ((ptr = strchr(buf, '\n'))) {
ptr = '\0';
}
} else {
answer = getpass(prompt);
}
if (answer == NULL) {
return -1;
}
strncpy(buf, answer, len);
return 0;
}
struct ssh_callbacks_struct cb = {
.auth_function=auth_callback,
.userdata=NULL
};
static void add_cmd(char *cmd){
int n;
for(n=0;cmds[n] && (n<MAXCMD);n++);
if(n==MAXCMD)
return;
cmds[n]=strdup(cmd);
}
static void usage(){
fprintf(stderr,"Usage : ssh [options] [login@]hostname\n"
"sample client - libssh-%s\n"
"Options :\n"
" -l user : log in as user\n"
" -p port : connect to port\n"
" -d : use DSS to verify host public key\n"
" -r : use RSA to verify host public key\n"
#ifdef WITH_PCAP
" -P file : create a pcap debugging file\n"
#endif
#ifndef _WIN32
" -T proxycommand : command to execute as a socket proxy\n"
#endif
,
ssh_version(0));
exit(0);
}
static int opts(int argc, char **argv){
int i;
// for(i=0;i<argc;i++)
// printf("%d : %s\n",i,argv[i]);
/* insert your own arguments here */
while((i=getopt(argc,argv,"T:P:"))!=-1){
switch(i){
#ifdef WITH_PCAP
case 'P':
pcap_file=optarg;
break;
#endif
#ifndef _WIN32
case 'T':
proxycommand=optarg;
break;
#endif
default:
fprintf(stderr,"unknown option %c\n",optopt);
usage();
}
}
if(optind < argc)
host=argv[optind++];
while(optind < argc)
add_cmd(argv[optind++]);
if(host==NULL)
usage();
return 0;
}
#ifndef HAVE_CFMAKERAW
static void cfmakeraw(struct termios *termios_p){
termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
termios_p->c_oflag &= ~OPOST;
termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
termios_p->c_cflag &= ~(CSIZE|PARENB);
termios_p->c_cflag |= CS8;
}
#endif
static void do_cleanup(int i) {
/* unused variable */
(void) i;
tcsetattr(0,TCSANOW,&terminal);
}
static void do_exit(int i) {
/* unused variable */
(void) i;
do_cleanup(0);
exit(0);
}
ssh_channel chan;
int signal_delayed=0;
static void sigwindowchanged(int i){
(void) i;
signal_delayed=1;
}
static void setsignal(void){
signal(SIGWINCH, sigwindowchanged);
signal_delayed=0;
}
static void sizechanged(void){
struct winsize win = { 0, 0, 0, 0 };
ioctl(1, TIOCGWINSZ, &win);
channel_change_pty_size(chan,win.ws_col, win.ws_row);
// printf("Changed pty size\n");
setsignal();
}
/* There are two flavors of select loop: the one based on
* ssh_select and the one based on channel_select.
* The ssh_select one permits you to give your own file descriptors to
* follow. It is thus a complete select loop.
* The second one only selects on channels. It is simplier to use
* but doesn't permit you to fill in your own file descriptor. It is
* more adapted if you can't use ssh_select as a main loop (because
* you already have another main loop system).
*/
#ifdef USE_CHANNEL_SELECT
/* channel_select base main loop, with a standard select(2)
*/
static void select_loop(ssh_session session,ssh_channel channel){
fd_set fds;
struct timeval timeout;
char buffer[4096];
ssh_buffer readbuf=buffer_new();
ssh_channel channels[2];
int lus;
int eof=0;
int maxfd;
int ret;
while(channel){
/* when a signal is caught, ssh_select will return
* with SSH_EINTR, which means it should be started
* again. It lets you handle the signal the faster you
* can, like in this window changed example. Of course, if
* your signal handler doesn't call libssh at all, you're
* free to handle signals directly in sighandler.
*/
do{
FD_ZERO(&fds);
if(!eof)
FD_SET(0,&fds);
timeout.tv_sec=30;
timeout.tv_usec=0;
FD_SET(ssh_get_fd(session),&fds);
maxfd=ssh_get_fd(session)+1;
ret=select(maxfd,&fds,NULL,NULL,&timeout);
if(ret==EINTR)
continue;
if(FD_ISSET(0,&fds)){
lus=read(0,buffer,sizeof(buffer));
if(lus)
channel_write(channel,buffer,lus);
else {
eof=1;
channel_send_eof(channel);
}
}
if(FD_ISSET(ssh_get_fd(session),&fds)){
ssh_set_fd_toread(session);
}
channels[0]=channel; // set the first channel we want to read from
channels[1]=NULL;
ret=channel_select(channels,NULL,NULL,NULL); // no specific timeout - just poll
if(signal_delayed)
sizechanged();
} while (ret==EINTR || ret==SSH_EINTR);
// we already looked for input from stdin. Now, we are looking for input from the channel
if(channel && channel_is_closed(channel)){
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",channel_get_exit_status(channel));
channel_free(channel);
channel=NULL;
channels[0]=NULL;
}
if(channels[0]){
while(channel && channel_is_open(channel) && channel_poll(channel,0)){
lus=channel_read_buffer(channel,readbuf,0,0);
if(lus==-1){
fprintf(stderr, "Error reading channel: %s\n",
ssh_get_error(session));
return;
}
if(lus==0){
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",channel_get_exit_status(channel));
channel_free(channel);
channel=channels[0]=NULL;
} else
write(1,buffer_get(readbuf),lus);
}
while(channel && channel_is_open(channel) && channel_poll(channel,1)){ /* stderr */
lus=channel_read_buffer(channel,readbuf,0,1);
if(lus==-1){
fprintf(stderr, "Error reading channel: %s\n",
ssh_get_error(session));
return;
}
if(lus==0){
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",channel_get_exit_status(channel));
channel_free(channel);
channel=channels[0]=NULL;
} else
write(2,buffer_get(readbuf),lus);
}
}
if(channel && channel_is_closed(channel)){
channel_free(channel);
channel=NULL;
}
}
buffer_free(readbuf);
}
#else /* CHANNEL_SELECT */
static void select_loop(ssh_session session,ssh_channel channel){
fd_set fds;
struct timeval timeout;
char buffer[4096];
/* channels will be set to the channels to poll.
* outchannels will contain the result of the poll
*/
ssh_channel channels[2], outchannels[2];
int lus;
int eof=0;
int maxfd;
int ret;
while(channel){
do{
FD_ZERO(&fds);
if(!eof)
FD_SET(0,&fds);
timeout.tv_sec=30;
timeout.tv_usec=0;
FD_SET(ssh_get_fd(session),&fds);
maxfd=ssh_get_fd(session)+1;
channels[0]=channel; // set the first channel we want to read from
channels[1]=NULL;
ret=ssh_select(channels,outchannels,maxfd,&fds,&timeout);
if(signal_delayed)
sizechanged();
if(ret==EINTR)
continue;
if(FD_ISSET(0,&fds)){
lus=read(0,buffer,sizeof(buffer));
if(lus)
channel_write(channel,buffer,lus);
else {
eof=1;
channel_send_eof(channel);
}
}
if(channel && channel_is_closed(channel)){
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",channel_get_exit_status(channel));
channel_free(channel);
channel=NULL;
channels[0]=NULL;
}
if(outchannels[0]){
while(channel && channel_is_open(channel) && channel_poll(channel,0)){
lus=channel_read(channel,buffer,sizeof(buffer),0);
if(lus==-1){
fprintf(stderr, "Error reading channel: %s\n",
ssh_get_error(session));
return;
}
if(lus==0){
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",channel_get_exit_status(channel));
channel_free(channel);
channel=channels[0]=NULL;
} else
write(1,buffer,lus);
}
while(channel && channel_is_open(channel) && channel_poll(channel,1)){ /* stderr */
lus=channel_read(channel,buffer,sizeof(buffer),1);
if(lus==-1){
fprintf(stderr, "Error reading channel: %s\n",
ssh_get_error(session));
return;
}
if(lus==0){
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",channel_get_exit_status(channel));
channel_free(channel);
channel=channels[0]=NULL;
} else
write(2,buffer,lus);
}
}
if(channel && channel_is_closed(channel)){
channel_free(channel);
channel=NULL;
}
} while (ret==EINTR || ret==SSH_EINTR);
}
}
#endif
static void shell(ssh_session session){
ssh_channel channel;
struct termios terminal_local;
int interactive=isatty(0);
channel = channel_new(session);
if(interactive){
tcgetattr(0,&terminal_local);
memcpy(&terminal,&terminal_local,sizeof(struct termios));
}
if(channel_open_session(channel)){
printf("error opening channel : %s\n",ssh_get_error(session));
return;
}
chan=channel;
if(interactive){
channel_request_pty(channel);
sizechanged();
}
if(channel_request_shell(channel)){
printf("Requesting shell : %s\n",ssh_get_error(session));
return;
}
if(interactive){
cfmakeraw(&terminal_local);
tcsetattr(0,TCSANOW,&terminal_local);
setsignal();
}
signal(SIGTERM,do_cleanup);
select_loop(session,channel);
if(interactive)
do_cleanup(0);
}
static void batch_shell(ssh_session session){
ssh_channel channel;
char buffer[1024];
int i,s=0;
for(i=0;i<MAXCMD && cmds[i];++i)
s+=snprintf(buffer+s,sizeof(buffer)-s,"%s ",cmds[i]);
channel=channel_new(session);
channel_open_session(channel);
if(channel_request_exec(channel,buffer)){
printf("error executing \"%s\" : %s\n",buffer,ssh_get_error(session));
return;
}
select_loop(session,channel);
}
static int client(ssh_session session){
int auth=0;
char *banner;
int state;
if (user)
if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0)
return -1;
if (ssh_options_set(session, SSH_OPTIONS_HOST ,host) < 0)
return -1;
if (proxycommand != NULL){
if(ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, proxycommand))
return -1;
}
ssh_options_parse_config(session, NULL);
if(ssh_connect(session)){
fprintf(stderr,"Connection failed : %s\n",ssh_get_error(session));
return -1;
}
state=verify_knownhost(session);
if (state != 0)
return -1;
ssh_userauth_none(session, NULL);
banner=ssh_get_issue_banner(session);
if(banner){
printf("%s\n",banner);
free(banner);
}
auth=authenticate_console(session);
if(auth != SSH_AUTH_SUCCESS){
return -1;
}
ssh_log(session, SSH_LOG_FUNCTIONS, "Authentication success");
if(!cmds[0])
shell(session);
else
batch_shell(session);
return 0;
}
#ifdef WITH_PCAP
ssh_pcap_file pcap;
void set_pcap(ssh_session session);
void set_pcap(ssh_session session){
if(!pcap_file)
return;
pcap=ssh_pcap_file_new();
if(ssh_pcap_file_open(pcap,pcap_file) == SSH_ERROR){
printf("Error opening pcap file\n");
ssh_pcap_file_free(pcap);
pcap=NULL;
return;
}
ssh_set_pcap_file(session,pcap);
}
void cleanup_pcap(void);
void cleanup_pcap(){
ssh_pcap_file_free(pcap);
pcap=NULL;
}
#endif
int main(int argc, char **argv){
ssh_session session;
session = ssh_new();
ssh_callbacks_init(&cb);
ssh_set_callbacks(session,&cb);
if(ssh_options_getopt(session, &argc, argv)) {
fprintf(stderr, "error parsing command line :%s\n",
ssh_get_error(session));
usage();
}
opts(argc,argv);
signal(SIGTERM, do_exit);
#ifdef WITH_PCAP
set_pcap(session);
#endif
client(session);
ssh_disconnect(session);
ssh_free(session);
#ifdef WITH_PCAP
cleanup_pcap();
#endif
ssh_finalize();
return 0;
}

265
examples/samplesftp.c Normal file
View File

@@ -0,0 +1,265 @@
/*
Copyright 2003-2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include "config.h"
#include <sys/statvfs.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <libssh/libssh.h>
#include <libssh/sftp.h>
#include "examples_common.h"
#ifdef WITH_SFTP
int verbosity;
char *destination;
static void do_sftp(ssh_session session){
sftp_session sftp=sftp_new(session);
sftp_dir dir;
sftp_attributes file;
sftp_statvfs_t sftpstatvfs;
struct statvfs sysstatvfs;
sftp_file fichier;
sftp_file to;
int len=1;
unsigned int i;
char data[8000]={0};
char *lnk;
unsigned int count;
if(!sftp){
fprintf(stderr, "sftp error initialising channel: %s\n",
ssh_get_error(session));
return;
}
if(sftp_init(sftp)){
fprintf(stderr, "error initialising sftp: %s\n",
ssh_get_error(session));
return;
}
printf("Additional SFTP extensions provided by the server:\n");
count = sftp_extensions_get_count(sftp);
for (i = 0; i < count; i++) {
printf("\t%s, version: %s\n",
sftp_extensions_get_name(sftp, i),
sftp_extensions_get_data(sftp, i));
}
/* test symlink and readlink */
if (sftp_symlink(sftp, "/tmp/this_is_the_link",
"/tmp/sftp_symlink_test") < 0) {
fprintf(stderr, "Could not create link (%s)\n", ssh_get_error(session));
return;
}
lnk = sftp_readlink(sftp, "/tmp/sftp_symlink_test");
if (lnk == NULL) {
fprintf(stderr, "Could not read link (%s)\n", ssh_get_error(session));
return;
}
printf("readlink /tmp/sftp_symlink_test: %s\n", lnk);
sftp_unlink(sftp, "/tmp/sftp_symlink_test");
if (sftp_extension_supported(sftp, "statvfs@openssh.com", "2")) {
sftpstatvfs = sftp_statvfs(sftp, "/tmp");
if (sftpstatvfs == NULL) {
fprintf(stderr, "statvfs failed (%s)\n", ssh_get_error(session));
return;
}
printf("sftp statvfs:\n"
"\tfile system block size: %llu\n"
"\tfundamental fs block size: %llu\n"
"\tnumber of blocks (unit f_frsize): %llu\n"
"\tfree blocks in file system: %llu\n"
"\tfree blocks for non-root: %llu\n"
"\ttotal file inodes: %llu\n"
"\tfree file inodes: %llu\n"
"\tfree file inodes for to non-root: %llu\n"
"\tfile system id: %llu\n"
"\tbit mask of f_flag values: %llu\n"
"\tmaximum filename length: %llu\n",
(unsigned long long) sftpstatvfs->f_bsize,
(unsigned long long) sftpstatvfs->f_frsize,
(unsigned long long) sftpstatvfs->f_blocks,
(unsigned long long) sftpstatvfs->f_bfree,
(unsigned long long) sftpstatvfs->f_bavail,
(unsigned long long) sftpstatvfs->f_files,
(unsigned long long) sftpstatvfs->f_ffree,
(unsigned long long) sftpstatvfs->f_favail,
(unsigned long long) sftpstatvfs->f_fsid,
(unsigned long long) sftpstatvfs->f_flag,
(unsigned long long) sftpstatvfs->f_namemax);
sftp_statvfs_free(sftpstatvfs);
if (statvfs("/tmp", &sysstatvfs) < 0) {
fprintf(stderr, "statvfs failed (%s)\n", strerror(errno));
return;
}
printf("sys statvfs:\n"
"\tfile system block size: %llu\n"
"\tfundamental fs block size: %llu\n"
"\tnumber of blocks (unit f_frsize): %llu\n"
"\tfree blocks in file system: %llu\n"
"\tfree blocks for non-root: %llu\n"
"\ttotal file inodes: %llu\n"
"\tfree file inodes: %llu\n"
"\tfree file inodes for to non-root: %llu\n"
"\tfile system id: %llu\n"
"\tbit mask of f_flag values: %llu\n"
"\tmaximum filename length: %llu\n",
(unsigned long long) sysstatvfs.f_bsize,
(unsigned long long) sysstatvfs.f_frsize,
(unsigned long long) sysstatvfs.f_blocks,
(unsigned long long) sysstatvfs.f_bfree,
(unsigned long long) sysstatvfs.f_bavail,
(unsigned long long) sysstatvfs.f_files,
(unsigned long long) sysstatvfs.f_ffree,
(unsigned long long) sysstatvfs.f_favail,
(unsigned long long) sysstatvfs.f_fsid,
(unsigned long long) sysstatvfs.f_flag,
(unsigned long long) sysstatvfs.f_namemax);
}
/* the connection is made */
/* opening a directory */
dir=sftp_opendir(sftp,"./");
if(!dir) {
fprintf(stderr, "Directory not opened(%s)\n", ssh_get_error(session));
return ;
}
/* reading the whole directory, file by file */
while((file=sftp_readdir(sftp,dir))){
fprintf(stderr, "%30s(%.8o) : %s(%.5d) %s(%.5d) : %.10llu bytes\n",
file->name,
file->permissions,
file->owner,
file->uid,
file->group,
file->gid,
(long long unsigned int) file->size);
sftp_attributes_free(file);
}
/* when file=NULL, an error has occured OR the directory listing is end of file */
if(!sftp_dir_eof(dir)){
fprintf(stderr, "Error: %s\n", ssh_get_error(session));
return;
}
if(sftp_closedir(dir)){
fprintf(stderr, "Error: %s\n", ssh_get_error(session));
return;
}
/* this will open a file and copy it into your /home directory */
/* the small buffer size was intended to stress the library. of course, you can use a buffer till 20kbytes without problem */
fichier=sftp_open(sftp,"/usr/bin/ssh",O_RDONLY, 0);
if(!fichier){
fprintf(stderr, "Error opening /usr/bin/ssh: %s\n",
ssh_get_error(session));
return;
}
/* open a file for writing... */
to=sftp_open(sftp,"ssh-copy",O_WRONLY | O_CREAT, 0700);
if(!to){
fprintf(stderr, "Error opening ssh-copy for writing: %s\n",
ssh_get_error(session));
return;
}
while((len=sftp_read(fichier,data,4096)) > 0){
if(sftp_write(to,data,len)!=len){
fprintf(stderr, "Error writing %d bytes: %s\n",
len, ssh_get_error(session));
return;
}
}
printf("finished\n");
if(len<0)
fprintf(stderr, "Error reading file: %s\n", ssh_get_error(session));
sftp_close(fichier);
sftp_close(to);
printf("fichiers ferm\n");
to=sftp_open(sftp,"/tmp/grosfichier",O_WRONLY|O_CREAT, 0644);
for(i=0;i<1000;++i){
len=sftp_write(to,data,8000);
printf("wrote %d bytes\n",len);
if(len != 8000){
printf("chunk %d : %d (%s)\n",i,len,ssh_get_error(session));
}
}
sftp_close(to);
/* close the sftp session */
sftp_free(sftp);
printf("sftp session terminated\n");
}
static void usage(const char *argv0){
fprintf(stderr,"Usage : %s [-v] remotehost\n"
"sample sftp test client - libssh-%s\n"
"Options :\n"
" -v : increase log verbosity\n",
argv0,
ssh_version(0));
exit(0);
}
static int opts(int argc, char **argv){
int i;
while((i=getopt(argc,argv,"v"))!=-1){
switch(i){
case 'v':
verbosity++;
break;
default:
fprintf(stderr,"unknown option %c\n",optopt);
usage(argv[0]);
return -1;
}
}
destination=argv[optind];
if(destination == NULL){
usage(argv[0]);
return -1;
}
return 0;
}
int main(int argc, char **argv){
ssh_session session;
if(opts(argc,argv)<0)
return EXIT_FAILURE;
session=connect_ssh(destination,NULL,verbosity);
if(session == NULL)
return EXIT_FAILURE;
do_sftp(session);
ssh_disconnect(session);
ssh_free(session);
return 0;
}
#endif

269
examples/samplesshd.c Normal file
View File

@@ -0,0 +1,269 @@
/* This is a sample implementation of a libssh based SSH server */
/*
Copyright 2003-2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include "config.h"
#include <libssh/libssh.h>
#include <libssh/server.h>
#ifdef HAVE_ARGP_H
#include <argp.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#ifndef KEYS_FOLDER
#ifdef _WIN32
#define KEYS_FOLDER
#else
#define KEYS_FOLDER "/etc/ssh/"
#endif
#endif
static int auth_password(char *user, char *password){
if(strcmp(user,"aris"))
return 0;
if(strcmp(password,"lala"))
return 0;
return 1; // authenticated
}
#ifdef HAVE_ARGP_H
const char *argp_program_version = "libssh server example "
SSH_STRINGIFY(LIBSSH_VERSION);
const char *argp_program_bug_address = "<libssh@libssh.org>";
/* Program documentation. */
static char doc[] = "libssh -- a Secure Shell protocol implementation";
/* A description of the arguments we accept. */
static char args_doc[] = "BINDADDR";
/* The options we understand. */
static struct argp_option options[] = {
{
.name = "port",
.key = 'p',
.arg = "PORT",
.flags = 0,
.doc = "Set the port to bind.",
.group = 0
},
{
.name = "hostkey",
.key = 'k',
.arg = "FILE",
.flags = 0,
.doc = "Set the host key.",
.group = 0
},
{
.name = "dsakey",
.key = 'd',
.arg = "FILE",
.flags = 0,
.doc = "Set the dsa key.",
.group = 0
},
{
.name = "rsakey",
.key = 'r',
.arg = "FILE",
.flags = 0,
.doc = "Set the rsa key.",
.group = 0
},
{
.name = "verbose",
.key = 'v',
.arg = NULL,
.flags = 0,
.doc = "Get verbose output.",
.group = 0
},
{NULL, 0, 0, 0, NULL, 0}
};
/* Parse a single option. */
static error_t parse_opt (int key, char *arg, struct argp_state *state) {
/* Get the input argument from argp_parse, which we
* know is a pointer to our arguments structure.
*/
ssh_bind sshbind = state->input;
switch (key) {
case 'p':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT_STR, arg);
break;
case 'd':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, arg);
break;
case 'k':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_HOSTKEY, arg);
break;
case 'r':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, arg);
break;
case 'v':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, "3");
break;
case ARGP_KEY_ARG:
if (state->arg_num >= 1) {
/* Too many arguments. */
argp_usage (state);
}
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDADDR, arg);
break;
case ARGP_KEY_END:
if (state->arg_num < 1) {
/* Not enough arguments. */
argp_usage (state);
}
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
/* Our argp parser. */
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
#endif /* HAVE_ARGP_H */
int main(int argc, char **argv){
ssh_session session;
ssh_bind sshbind;
ssh_message message;
ssh_channel chan=0;
ssh_buffer buf;
int auth=0;
int sftp=0;
int i;
int r;
sshbind=ssh_bind_new();
session=ssh_new();
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, KEYS_FOLDER "ssh_host_dsa_key");
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, KEYS_FOLDER "ssh_host_rsa_key");
#ifdef HAVE_ARGP_H
/*
* Parse our arguments; every option seen by parse_opt will
* be reflected in arguments.
*/
argp_parse (&argp, argc, argv, 0, 0, sshbind);
#endif
if(ssh_bind_listen(sshbind)<0){
printf("Error listening to socket: %s\n",ssh_get_error(sshbind));
return 1;
}
r=ssh_bind_accept(sshbind,session);
if(r==SSH_ERROR){
printf("error accepting a connection : %s\n",ssh_get_error(sshbind));
return 1;
}
if(ssh_accept(session)){
printf("ssh_accept: %s\n",ssh_get_error(session));
return 1;
}
do {
message=ssh_message_get(session);
if(!message)
break;
switch(ssh_message_type(message)){
case SSH_REQUEST_AUTH:
switch(ssh_message_subtype(message)){
case SSH_AUTH_METHOD_PASSWORD:
printf("User %s wants to auth with pass %s\n",
ssh_message_auth_user(message),
ssh_message_auth_password(message));
if(auth_password(ssh_message_auth_user(message),
ssh_message_auth_password(message))){
auth=1;
ssh_message_auth_reply_success(message,0);
break;
}
// not authenticated, send default message
case SSH_AUTH_METHOD_NONE:
default:
ssh_message_auth_set_methods(message,SSH_AUTH_METHOD_PASSWORD);
ssh_message_reply_default(message);
break;
}
break;
default:
ssh_message_reply_default(message);
}
ssh_message_free(message);
} while (!auth);
if(!auth){
printf("auth error: %s\n",ssh_get_error(session));
ssh_disconnect(session);
return 1;
}
do {
message=ssh_message_get(session);
if(message){
switch(ssh_message_type(message)){
case SSH_REQUEST_CHANNEL_OPEN:
if(ssh_message_subtype(message)==SSH_CHANNEL_SESSION){
chan=ssh_message_channel_request_open_reply_accept(message);
break;
}
default:
ssh_message_reply_default(message);
}
ssh_message_free(message);
}
} while(message && !chan);
if(!chan){
printf("error : %s\n",ssh_get_error(session));
ssh_finalize();
return 1;
}
do {
message=ssh_message_get(session);
if(message && ssh_message_type(message)==SSH_REQUEST_CHANNEL &&
ssh_message_subtype(message)==SSH_CHANNEL_REQUEST_SHELL){
// if(!strcmp(ssh_message_channel_request_subsystem(message),"sftp")){
sftp=1;
ssh_message_channel_request_reply_success(message);
break;
// }
}
if(!sftp){
ssh_message_reply_default(message);
}
ssh_message_free(message);
} while (message && !sftp);
if(!sftp){
printf("error : %s\n",ssh_get_error(session));
return 1;
}
printf("it works !\n");
buf=buffer_new();
do{
i=channel_read_buffer(chan,buf,0,0);
if(i>0)
write(1,buffer_get(buf),buffer_get_len(buf));
} while (i>0);
buffer_free(buf);
ssh_disconnect(session);
ssh_bind_free(sshbind);
ssh_finalize();
return 0;
}

149
examples/scp_download.c Normal file
View File

@@ -0,0 +1,149 @@
/* scp_download.c
* Sample implementation of a tiny SCP downloader client
*/
/*
Copyright 2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <libssh/libssh.h>
#include "examples_common.h"
int verbosity=0;
const char *createcommand="rm -fr /tmp/libssh_tests && mkdir /tmp/libssh_tests && cd /tmp/libssh_tests && date > a && date > b && mkdir c && date > d";
char *host=NULL;
static void usage(const char *argv0){
fprintf(stderr,"Usage : %s [options] host\n"
"sample tiny scp downloader client - libssh-%s\n"
"This program will create files in /tmp and try to fetch them\n",
// "Options :\n",
// " -r : use RSA to verify host public key\n",
argv0,
ssh_version(0));
exit(0);
}
static int opts(int argc, char **argv){
int i;
while((i=getopt(argc,argv,"v"))!=-1){
switch(i){
case 'v':
verbosity++;
break;
default:
fprintf(stderr,"unknown option %c\n",optopt);
usage(argv[0]);
return -1;
}
}
host = argv[optind];
if(host == NULL)
usage(argv[0]);
return 0;
}
static void create_files(ssh_session session){
ssh_channel channel=channel_new(session);
char buffer[1];
if(channel == NULL){
fprintf(stderr,"Error creating channel: %s\n",ssh_get_error(session));
exit(EXIT_FAILURE);
}
if(channel_open_session(channel) != SSH_OK){
fprintf(stderr,"Error creating channel: %s\n",ssh_get_error(session));
exit(EXIT_FAILURE);
}
if(channel_request_exec(channel,createcommand) != SSH_OK){
fprintf(stderr,"Error executing command: %s\n",ssh_get_error(session));
exit(EXIT_FAILURE);
}
while(!channel_is_eof(channel)){
channel_read(channel,buffer,1,1);
write(1,buffer,1);
}
channel_close(channel);
channel_free(channel);
}
static int fetch_files(ssh_session session){
int size;
char buffer[16384];
int mode;
char *filename;
int r;
ssh_scp scp=ssh_scp_new(session, SSH_SCP_READ | SSH_SCP_RECURSIVE, "/tmp/libssh_tests/*");
if(ssh_scp_init(scp) != SSH_OK){
fprintf(stderr,"error initializing scp: %s\n",ssh_get_error(session));
return -1;
}
printf("Trying to download 3 files (a,b,d) and 1 directory (c)\n");
do {
r=ssh_scp_pull_request(scp);
switch(r){
case SSH_SCP_REQUEST_NEWFILE:
size=ssh_scp_request_get_size(scp);
filename=strdup(ssh_scp_request_get_filename(scp));
mode=ssh_scp_request_get_permissions(scp);
printf("downloading file %s, size %d, perms 0%o\n",filename,size,mode);
free(filename);
ssh_scp_accept_request(scp);
r=ssh_scp_read(scp,buffer,sizeof(buffer));
if(r==SSH_ERROR){
fprintf(stderr,"Error reading scp: %s\n",ssh_get_error(session));
return -1;
}
printf("done\n");
break;
case SSH_ERROR:
fprintf(stderr,"Error: %s\n",ssh_get_error(session));
return -1;
case SSH_SCP_REQUEST_WARNING:
fprintf(stderr,"Warning: %s\n",ssh_scp_request_get_warning(scp));
break;
case SSH_SCP_REQUEST_NEWDIR:
filename=strdup(ssh_scp_request_get_filename(scp));
mode=ssh_scp_request_get_permissions(scp);
printf("downloading directory %s, perms 0%o\n",filename,mode);
free(filename);
ssh_scp_accept_request(scp);
break;
case SSH_SCP_REQUEST_ENDDIR:
printf("End of directory\n");
break;
case SSH_SCP_REQUEST_EOF:
printf("End of requests\n");
goto end;
}
} while (1);
end:
return 0;
}
int main(int argc, char **argv){
ssh_session session;
if(opts(argc,argv)<0)
return EXIT_FAILURE;
session=connect_ssh(host,NULL,verbosity);
if(session == NULL)
return EXIT_FAILURE;
create_files(session);
fetch_files(session);
ssh_disconnect(session);
ssh_finalize();
return 0;
}

3
include/CMakeLists.txt Normal file
View File

@@ -0,0 +1,3 @@
project(headers C)
add_subdirectory(libssh)

View File

@@ -1 +0,0 @@
SUBDIRS = libssh

View File

@@ -0,0 +1,38 @@
project(libssh-headers C)
set(libssh_HDRS
callbacks.h
libssh.h
ssh2.h
)
if (WITH_SFTP)
set(libssh_HDRS
${libssh_HDRS}
sftp.h
)
endif (WITH_SFTP)
if (WITH_SSH1)
set(libssh_HDRS
${libssh_HDRS}
ssh1.h
)
endif (WITH_SSH1)
if (WITH_SERVER)
set(libssh_HDRS
${libssh_HDRS}
server.h
)
endif (WITH_SERVER)
install(
FILES
${libssh_HDRS}
DESTINATION
${INCLUDE_INSTALL_DIR}/${APPLICATION_NAME}
COMPONENT
headers
)

View File

@@ -1,8 +0,0 @@
libsshdir = $(includedir)/libssh
libssh_HEADERS = crypto.h libssh.h priv.h server.h sftp.h ssh1.h ssh2.h
nodist_libssh_HEADERS = config.h
config.h:
$(LN_S) $(top_builddir)/config.h ./config.h
DISTCLEANFILES = config.h

97
include/libssh/agent.h Normal file
View File

@@ -0,0 +1,97 @@
#ifndef __AGENT_H
#define __AGENT_H
#include "libssh/libssh.h"
/* Messages for the authentication agent connection. */
#define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1
#define SSH_AGENT_RSA_IDENTITIES_ANSWER 2
#define SSH_AGENTC_RSA_CHALLENGE 3
#define SSH_AGENT_RSA_RESPONSE 4
#define SSH_AGENT_FAILURE 5
#define SSH_AGENT_SUCCESS 6
#define SSH_AGENTC_ADD_RSA_IDENTITY 7
#define SSH_AGENTC_REMOVE_RSA_IDENTITY 8
#define SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES 9
/* private OpenSSH extensions for SSH2 */
#define SSH2_AGENTC_REQUEST_IDENTITIES 11
#define SSH2_AGENT_IDENTITIES_ANSWER 12
#define SSH2_AGENTC_SIGN_REQUEST 13
#define SSH2_AGENT_SIGN_RESPONSE 14
#define SSH2_AGENTC_ADD_IDENTITY 17
#define SSH2_AGENTC_REMOVE_IDENTITY 18
#define SSH2_AGENTC_REMOVE_ALL_IDENTITIES 19
/* smartcard */
#define SSH_AGENTC_ADD_SMARTCARD_KEY 20
#define SSH_AGENTC_REMOVE_SMARTCARD_KEY 21
/* lock/unlock the agent */
#define SSH_AGENTC_LOCK 22
#define SSH_AGENTC_UNLOCK 23
/* add key with constraints */
#define SSH_AGENTC_ADD_RSA_ID_CONSTRAINED 24
#define SSH2_AGENTC_ADD_ID_CONSTRAINED 25
#define SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED 26
#define SSH_AGENT_CONSTRAIN_LIFETIME 1
#define SSH_AGENT_CONSTRAIN_CONFIRM 2
/* extended failure messages */
#define SSH2_AGENT_FAILURE 30
/* additional error code for ssh.com's ssh-agent2 */
#define SSH_COM_AGENT2_FAILURE 102
#define SSH_AGENT_OLD_SIGNATURE 0x01
struct ssh_agent_struct {
struct socket *sock;
ssh_buffer ident;
unsigned int count;
};
#ifndef _WIN32
/* agent.c */
/**
* @brief Create a new ssh agent structure.
*
* @return An allocated ssh agent structure or NULL on error.
*/
struct ssh_agent_struct *agent_new(struct ssh_session_struct *session);
void agent_close(struct ssh_agent_struct *agent);
/**
* @brief Free an allocated ssh agent structure.
*
* @param agent The ssh agent structure to free.
*/
void agent_free(struct ssh_agent_struct *agent);
/**
* @brief Check if the ssh agent is running.
*
* @param session The ssh session to check for the agent.
*
* @return 1 if it is running, 0 if not.
*/
int agent_is_running(struct ssh_session_struct *session);
int agent_get_ident_count(struct ssh_session_struct *session);
struct ssh_public_key_struct *agent_get_next_ident(struct ssh_session_struct *session,
char **comment);
struct ssh_public_key_struct *agent_get_first_ident(struct ssh_session_struct *session,
char **comment);
ssh_string agent_sign_data(struct ssh_session_struct *session,
struct ssh_buffer_struct *data,
struct ssh_public_key_struct *pubkey);
#endif
#endif /* __AGENT_H */
/* vim: set ts=2 sw=2 et cindent: */

62
include/libssh/buffer.h Normal file
View File

@@ -0,0 +1,62 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef BUFFER_H_
#define BUFFER_H_
/* Describes a buffer state */
struct ssh_buffer_struct {
char *data;
uint32_t used;
uint32_t allocated;
uint32_t pos;
};
int buffer_add_ssh_string(ssh_buffer buffer, ssh_string string);
int buffer_add_u8(ssh_buffer buffer, uint8_t data);
int buffer_add_u16(ssh_buffer buffer, uint16_t data);
int buffer_add_u32(ssh_buffer buffer, uint32_t data);
int buffer_add_u64(ssh_buffer buffer, uint64_t data);
int buffer_add_data(ssh_buffer buffer, const void *data, uint32_t len);
int buffer_prepend_data(ssh_buffer buffer, const void *data, uint32_t len);
int buffer_add_buffer(ssh_buffer buffer, ssh_buffer source);
int buffer_reinit(ssh_buffer buffer);
/* buffer_get_rest returns a pointer to the current position into the buffer */
void *buffer_get_rest(ssh_buffer buffer);
/* buffer_get_rest_len returns the number of bytes which can be read */
uint32_t buffer_get_rest_len(ssh_buffer buffer);
/* buffer_read_*() returns the number of bytes read, except for ssh strings */
int buffer_get_u8(ssh_buffer buffer, uint8_t *data);
int buffer_get_u32(ssh_buffer buffer, uint32_t *data);
int buffer_get_u64(ssh_buffer buffer, uint64_t *data);
uint32_t buffer_get_data(ssh_buffer buffer, void *data, uint32_t requestedlen);
/* buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */
ssh_string buffer_get_ssh_string(ssh_buffer buffer);
/* gets a string out of a SSH-1 mpint */
ssh_string buffer_get_mpint(ssh_buffer buffer);
/* buffer_pass_bytes acts as if len bytes have been read (used for padding) */
uint32_t buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
uint32_t buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
#endif /* BUFFER_H_ */

113
include/libssh/callbacks.h Normal file
View File

@@ -0,0 +1,113 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 Aris Adamantiadis <aris@0xbadc0de.be>
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
/* callback.h
* This file includes the public declarations for the libssh callback mechanism
*/
#ifndef _SSH_CALLBACK_H
#define _SSH_CALLBACK_H
#include <libssh/libssh.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief SSH authentication callback.
*
* @param prompt Prompt to be displayed.
* @param buf Buffer to save the password. You should null-terminate it.
* @param len Length of the buffer.
* @param echo Enable or disable the echo of what you type.
* @param verify Should the password be verified?
* @param userdata Userdata to be passed to the callback function. Useful
* for GUI applications.
*
* @return 0 on success, < 0 on error.
*/
typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
int echo, int verify, void *userdata);
typedef void (*ssh_log_callback) (ssh_session session, int priority,
const char *message, void *userdata);
/** this callback will be called with status going from 0.0 to 1.0 during
* connection */
typedef void (*ssh_status_callback) (ssh_session session, float status,
void *userdata);
struct ssh_callbacks_struct {
/** size of this structure. internal, shoud be set with ssh_callbacks_init()*/
size_t size;
/** User-provided data. User is free to set anything he wants here */
void *userdata;
/** this functions will be called if e.g. a keyphrase is needed. */
ssh_auth_callback auth_function;
/** this function will be called each time a loggable event happens. */
ssh_log_callback log_function;
/** this function gets called during connection time to indicate the percentage
* of connection steps completed.
*/
void (*connect_status_function)(void *userdata, float status);
};
typedef struct ssh_callbacks_struct * ssh_callbacks;
/** Initializes an ssh_callbacks_struct
* A call to this macro is mandatory when you have set a new
* ssh_callback_struct structure. Its goal is to maintain the binary
* compatibility with future versions of libssh as the structure
* evolves with time.
*/
#define ssh_callbacks_init(p) do {\
(p)->size=sizeof(*(p)); \
} while(0);
/**
* @brief Set the callback functions.
*
* This functions sets the callback structure to use your own callback
* functions for auth, logging and status.
*
* @code
* struct ssh_callbacks_struct cb;
* memset(&cb, 0, sizeof(struct ssh_callbacks_struct));
* cb.userdata = data;
* cb.auth_function = my_auth_function;
*
* ssh_callbacks_init(&cb);
* ssh_set_callbacks(session, &cb);
* @endcode
*
* @param session The session to set the callback structure.
*
* @param cb The callback itself.
*
* @return 0 on success, < 0 on error.
*/
LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb);
#ifdef __cplusplus
}
#endif
#endif /*_SSH_CALLBACK_H */

58
include/libssh/channels.h Normal file
View File

@@ -0,0 +1,58 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef CHANNELS_H_
#define CHANNELS_H_
#include "libssh/priv.h"
struct ssh_channel_struct {
struct ssh_channel_struct *prev;
struct ssh_channel_struct *next;
ssh_session session; /* SSH_SESSION pointer */
uint32_t local_channel;
uint32_t local_window;
int local_eof;
uint32_t local_maxpacket;
uint32_t remote_channel;
uint32_t remote_window;
int remote_eof; /* end of file received */
uint32_t remote_maxpacket;
int open; /* shows if the channel is still opened */
int delayed_close;
ssh_buffer stdout_buffer;
ssh_buffer stderr_buffer;
void *userarg;
int version;
int blocking;
int exit_status;
};
void channel_handle(ssh_session session, int type);
ssh_channel channel_new(ssh_session session);
int channel_default_bufferize(ssh_channel channel, void *data, int len,
int is_stderr);
uint32_t ssh_channel_new_id(ssh_session session);
ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id);
int channel_write_common(ssh_channel channel, const void *data,
uint32_t len, int is_stderr);
#endif /* CHANNELS_H_ */

View File

@@ -1,44 +1,69 @@
/*
Copyright 2003 Aris Adamantiadis
* This file is part of the SSH Library
*
* Copyright (c) 2003,2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
This file is part of the SSH Library
/*
* crypto.h is an include file for internal cryptographic structures of libssh
*/
The SSH Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
#ifndef _CRYPTO_H_
#define _CRYPTO_H_
The SSH Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
#include "config.h"
You should have received a copy of the GNU Lesser General Public License
along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
/* Crypto.h is an include file for internal structures of libssh */
/* It hasn't to be into the final development set of files (and btw the filename would cause problems on most systems) */
/* Openssl has (really) stupid defines */
#ifdef set_key
#undef set_key
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
#endif
#include "libssh/wrapper.h"
#ifdef cbc_encrypt
#undef cbc_encrypt
#endif
#ifdef cbc_decrypt
#undef cbc_decrypt
#endif
#ifdef des_set_key
#undef des_set_key
#endif
#ifdef GCRYPT
#include <gcrypt.h>
#endif
struct ssh_crypto_struct {
bignum e,f,x,k,y;
unsigned char session_id[SHA_DIGEST_LEN];
unsigned char encryptIV[SHA_DIGEST_LEN*2];
unsigned char decryptIV[SHA_DIGEST_LEN*2];
unsigned char decryptkey[SHA_DIGEST_LEN*2];
unsigned char encryptkey[SHA_DIGEST_LEN*2];
unsigned char encryptMAC[SHA_DIGEST_LEN];
unsigned char decryptMAC[SHA_DIGEST_LEN];
unsigned char hmacbuf[EVP_MAX_MD_SIZE];
struct crypto_struct *in_cipher, *out_cipher; /* the cipher structures/objects */
ssh_string server_pubkey;
const char *server_pubkey_type;
int do_compress_out; /* idem */
int do_compress_in; /* don't set them, set the option instead */
void *compress_out_ctx; /* don't touch it */
void *compress_in_ctx; /* really, don't */
};
struct crypto_struct {
char *name; /* ssh name of the algorithm */
const char *name; /* ssh name of the algorithm */
unsigned int blocksize; /* blocksize of the algo */
unsigned int keylen; /* length of the key structure */
#ifdef HAVE_LIBGCRYPT
@@ -48,15 +73,23 @@ struct crypto_struct {
#endif
unsigned int keysize; /* bytes of key used. != keylen */
#ifdef HAVE_LIBGCRYPT
void (*set_encrypt_key)(struct crypto_struct *cipher, void *key, void *IV); /* sets the new key for immediate use */
void (*set_decrypt_key)(struct crypto_struct *cipher, void *key, void *IV);
void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,unsigned long len);
void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,unsigned long len);
/* sets the new key for immediate use */
int (*set_encrypt_key)(struct crypto_struct *cipher, void *key, void *IV);
int (*set_decrypt_key)(struct crypto_struct *cipher, void *key, void *IV);
void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,
unsigned long len);
void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,
unsigned long len);
#elif defined HAVE_LIBCRYPTO
void (*set_encrypt_key)(struct crypto_struct *cipher, void *key); /* sets the new key for immediate use */
void (*set_decrypt_key)(struct crypto_struct *cipher, void *key);
void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,unsigned long len,void *IV);
void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,unsigned long len,void *IV);
/* sets the new key for immediate use */
int (*set_encrypt_key)(struct crypto_struct *cipher, void *key);
int (*set_decrypt_key)(struct crypto_struct *cipher, void *key);
void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,
unsigned long len, void *IV);
void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,
unsigned long len, void *IV);
#endif
};
/* vim: set ts=2 sw=2 et cindent: */
#endif /* _CRYPTO_H_ */

57
include/libssh/dh.h Normal file
View File

@@ -0,0 +1,57 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef DH_H_
#define DH_H_
#include "config.h"
/* DH key generation */
#include "libssh/keys.h"
void ssh_print_bignum(const char *which,bignum num);
int dh_generate_e(ssh_session session);
int dh_generate_f(ssh_session session);
int dh_generate_x(ssh_session session);
int dh_generate_y(ssh_session session);
int ssh_crypto_init(void);
void ssh_crypto_finalize(void);
ssh_string dh_get_e(ssh_session session);
ssh_string dh_get_f(ssh_session session);
int dh_import_f(ssh_session session,ssh_string f_string);
int dh_import_e(ssh_session session, ssh_string e_string);
void dh_import_pubkey(ssh_session session,ssh_string pubkey_string);
int dh_build_k(ssh_session session);
int make_sessionid(ssh_session session);
/* add data for the final cookie */
int hashbufin_add_cookie(ssh_session session, unsigned char *cookie);
int hashbufout_add_cookie(ssh_session session);
int generate_session_keys(ssh_session session);
int sig_verify(ssh_session session, ssh_public_key pubkey,
SIGNATURE *signature, unsigned char *digest, int size);
/* returns 1 if server signature ok, 0 otherwise. The NEXT crypto is checked, not the current one */
int signature_verify(ssh_session session,ssh_string signature);
bignum make_string_bn(ssh_string string);
ssh_string make_bignum_string(bignum num);
#endif /* DH_H_ */

33
include/libssh/keyfiles.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef KEYFILES_H_
#define KEYFILES_H_
/* in keyfiles.c */
ssh_private_key _privatekey_from_file(void *session, const char *filename,
int type);
ssh_string try_publickey_from_file(ssh_session session,
struct ssh_keys_struct keytab,
char **privkeyfile, int *type);
#endif /* KEYFILES_H_ */

84
include/libssh/keys.h Normal file
View File

@@ -0,0 +1,84 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef KEYS_H_
#define KEYS_H_
#include "config.h"
#include "libssh/libssh.h"
#include "libssh/wrapper.h"
struct ssh_public_key_struct {
int type;
const char *type_c; /* Don't free it ! it is static */
#ifdef HAVE_LIBGCRYPT
gcry_sexp_t dsa_pub;
gcry_sexp_t rsa_pub;
#elif HAVE_LIBCRYPTO
DSA *dsa_pub;
RSA *rsa_pub;
#endif
};
struct ssh_private_key_struct {
int type;
#ifdef HAVE_LIBGCRYPT
gcry_sexp_t dsa_priv;
gcry_sexp_t rsa_priv;
#elif defined HAVE_LIBCRYPTO
DSA *dsa_priv;
RSA *rsa_priv;
#endif
};
typedef struct signature_struct {
int type;
#ifdef HAVE_LIBGCRYPT
gcry_sexp_t dsa_sign;
gcry_sexp_t rsa_sign;
#elif defined HAVE_LIBCRYPTO
DSA_SIG *dsa_sign;
ssh_string rsa_sign;
#endif
} SIGNATURE;
const char *ssh_type_to_char(int type);
int ssh_type_from_name(const char *name);
ssh_buffer ssh_userauth_build_digest(ssh_session session, ssh_message msg, char *service);
ssh_private_key privatekey_make_dss(ssh_session session, ssh_buffer buffer);
ssh_private_key privatekey_make_rsa(ssh_session session, ssh_buffer buffer,
const char *type);
ssh_private_key privatekey_from_string(ssh_session session, ssh_string privkey_s);
ssh_public_key publickey_make_dss(ssh_session session, ssh_buffer buffer);
ssh_public_key publickey_make_rsa(ssh_session session, ssh_buffer buffer, int type);
ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s);
SIGNATURE *signature_from_string(ssh_session session, ssh_string signature,ssh_public_key pubkey,int needed_type);
void signature_free(SIGNATURE *sign);
ssh_string ssh_do_sign_with_agent(struct ssh_session_struct *session,
struct ssh_buffer_struct *buf, struct ssh_public_key_struct *publickey);
ssh_string ssh_do_sign(ssh_session session,ssh_buffer sigbuf,
ssh_private_key privatekey);
ssh_string ssh_sign_session_id(ssh_session session, ssh_private_key privatekey);
ssh_string ssh_encrypt_rsa1(ssh_session session, ssh_string data, ssh_public_key key);
#endif /* KEYS_H_ */

View File

@@ -1,136 +1,233 @@
/*
Copyright (c) 2003-2008 Aris Adamantiadis
This file is part of the SSH Library
The SSH Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
The SSH Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
* This file is part of the SSH Library
*
* Copyright (c) 2003-2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef _LIBSSH_H
#define _LIBSSH_H
#ifndef _MSC_VER
#include <unistd.h>
#include <inttypes.h>
#ifdef LIBSSH_STATIC
#define LIBSSH_API
#else
//visual studio hasn't inttypes.h so it doesn't know uint32_t
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
typedef unsigned long long uint64_t;
#if defined _WIN32 || defined __CYGWIN__
#ifdef LIBSSH_EXPORTS
#ifdef __GNUC__
#define LIBSSH_API __attribute__((dllexport))
#else
#define LIBSSH_API __declspec(dllexport)
#endif
#else
#ifdef __GNUC__
#define LIBSSH_API __attribute__((dllimport))
#else
#define LIBSSH_API __declspec(dllimport)
#endif
#endif
#else
#if __GNUC__ >= 4
#define LIBSSH_API __attribute__((visibility("default")))
#else
#define LIBSSH_API
#endif
#endif
#endif
#ifdef _MSC_VER
/* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
typedef int int32_t;
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
typedef unsigned long long uint64_t;
typedef int mode_t;
#else /* _MSC_VER */
#include <unistd.h>
#include <inttypes.h>
#endif /* _MSC_VER */
#endif
#ifndef _WIN32
#include <sys/select.h> /* for fd_set * */
#include <netdb.h>
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <winsock2.h>
#else /* _WIN32 */
#include <sys/select.h> /* for fd_set * */
#include <netdb.h>
#endif /* _WIN32 */
#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
#define SSH_TOSTRING(s) #s
/* libssh version macros */
#define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
#define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c
#define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c)
/* libssh version */
#define LIBSSH_VERSION_MAJOR 0
#define LIBSSH_VERSION_MINOR 4
#define LIBSSH_VERSION_MICRO 5
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
LIBSSH_VERSION_MINOR, \
LIBSSH_VERSION_MICRO)
#define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \
LIBSSH_VERSION_MINOR, \
LIBSSH_VERSION_MICRO)
/* GCC have printf type attribute check. */
#ifdef __GNUC__
#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
#else
#define PRINTF_ATTRIBUTE(a,b)
#endif /* __GNUC__ */
#ifdef __GNUC__
#define SSH_DEPRECATED __attribute__ ((deprecated))
#else
#define SSH_DEPRECATED
#endif
#define LIBSSH_VERSION "libssh-0.2.1-svn"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct string_struct STRING;
typedef struct buffer_struct BUFFER;
typedef struct public_key_struct PUBLIC_KEY;
typedef struct private_key_struct PRIVATE_KEY;
typedef struct ssh_options_struct SSH_OPTIONS;
typedef struct channel_struct CHANNEL;
typedef struct ssh_session SSH_SESSION;
typedef struct ssh_kbdint SSH_KBDINT;
/* integer values */
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint64_t u64;
typedef uint8_t u8;
typedef struct ssh_agent_struct* ssh_agent;
typedef struct ssh_buffer_struct* ssh_buffer;
typedef struct ssh_channel_struct* ssh_channel;
typedef struct ssh_message_struct* ssh_message;
typedef struct ssh_pcap_file_struct* ssh_pcap_file;
typedef struct ssh_private_key_struct* ssh_private_key;
typedef struct ssh_public_key_struct* ssh_public_key;
typedef struct ssh_scp_struct* ssh_scp;
typedef struct ssh_session_struct* ssh_session;
typedef struct ssh_string_struct* ssh_string;
/* Socket type */
#ifdef _WIN32
#define socket_t SOCKET
#else
#ifndef socket_t
typedef SOCKET socket_t;
#endif /* socket_t */
#else /* _WIN32 */
#ifndef socket_t
typedef int socket_t;
#endif
#endif /* _WIN32 */
#define SSH_INVALID_SOCKET ((socket_t) -1)
/* the offsets of methods */
#define SSH_KEX 0
#define SSH_HOSTKEYS 1
#define SSH_CRYPT_C_S 2
#define SSH_CRYPT_S_C 3
#define SSH_MAC_C_S 4
#define SSH_MAC_S_C 5
#define SSH_COMP_C_S 6
#define SSH_COMP_S_C 7
#define SSH_LANG_C_S 8
#define SSH_LANG_S_C 9
enum ssh_kex_types_e {
SSH_KEX=0,
SSH_HOSTKEYS,
SSH_CRYPT_C_S,
SSH_CRYPT_S_C,
SSH_MAC_C_S,
SSH_MAC_S_C,
SSH_COMP_C_S,
SSH_COMP_S_C,
SSH_LANG_C_S,
SSH_LANG_S_C
};
#define SSH_CRYPT 2
#define SSH_MAC 3
#define SSH_COMP 4
#define SSH_LANG 5
#define SSH_AUTH_SUCCESS 0
#define SSH_AUTH_DENIED 1
#define SSH_AUTH_PARTIAL 2
#define SSH_AUTH_INFO 3
#define SSH_AUTH_ERROR -1
enum ssh_auth_e {
SSH_AUTH_SUCCESS=0,
SSH_AUTH_DENIED,
SSH_AUTH_PARTIAL,
SSH_AUTH_INFO,
SSH_AUTH_ERROR=-1
};
#define SSH_AUTH_METHOD_PASSWORD 0x0001
#define SSH_AUTH_METHOD_PUBLICKEY 0x0002
#define SSH_AUTH_METHOD_HOSTBASED 0x0004
#define SSH_AUTH_METHOD_INTERACTIVE 0x0008
/* auth flags */
#define SSH_AUTH_METHOD_UNKNOWN 0
#define SSH_AUTH_METHOD_NONE 0x0001
#define SSH_AUTH_METHOD_PASSWORD 0x0002
#define SSH_AUTH_METHOD_PUBLICKEY 0x0004
#define SSH_AUTH_METHOD_HOSTBASED 0x0008
#define SSH_AUTH_METHOD_INTERACTIVE 0x0010
/* messages */
enum ssh_requests_e {
SSH_REQUEST_AUTH=1,
SSH_REQUEST_CHANNEL_OPEN,
SSH_REQUEST_CHANNEL,
SSH_REQUEST_SERVICE,
SSH_REQUEST_GLOBAL,
};
enum ssh_channel_type_e {
SSH_CHANNEL_UNKNOWN=0,
SSH_CHANNEL_SESSION,
SSH_CHANNEL_DIRECT_TCPIP,
SSH_CHANNEL_FORWARDED_TCPIP,
SSH_CHANNEL_X11
};
enum ssh_channel_requests_e {
SSH_CHANNEL_REQUEST_UNKNOWN=0,
SSH_CHANNEL_REQUEST_PTY,
SSH_CHANNEL_REQUEST_EXEC,
SSH_CHANNEL_REQUEST_SHELL,
SSH_CHANNEL_REQUEST_ENV,
SSH_CHANNEL_REQUEST_SUBSYSTEM,
SSH_CHANNEL_REQUEST_WINDOW_CHANGE,
};
/* status flags */
#define SSH_CLOSED 0x01
#define SSH_READ_PENDING 0x02
#define SSH_CLOSED_ERROR 0x04
#define SSH_CLOSED (1<<0)
#define SSH_READ_PENDING (1<<1)
#define SSH_CLOSED_ERROR (1<<2)
#define SSH_SERVER_ERROR -1
#define SSH_SERVER_NOT_KNOWN 0
#define SSH_SERVER_KNOWN_OK 1
#define SSH_SERVER_KNOWN_CHANGED 2
#define SSH_SERVER_FOUND_OTHER 3
enum ssh_server_known_e {
SSH_SERVER_ERROR=-1,
SSH_SERVER_NOT_KNOWN=0,
SSH_SERVER_KNOWN_OK,
SSH_SERVER_KNOWN_CHANGED,
SSH_SERVER_FOUND_OTHER,
SSH_SERVER_FILE_NOT_FOUND,
};
#ifndef MD5_DIGEST_LEN
#define MD5_DIGEST_LEN 16
#endif
/* errors */
#define SSH_NO_ERROR 0
#define SSH_REQUEST_DENIED 1
#define SSH_FATAL 2
#define SSH_EINTR 3
enum ssh_error_types_e {
SSH_NO_ERROR=0,
SSH_REQUEST_DENIED,
SSH_FATAL,
SSH_EINTR
};
/* error return codes */
/* Error return codes */
#define SSH_OK 0 /* No error */
#define SSH_ERROR -1 /* error of some kind */
#define SSH_AGAIN 1 /* the nonblocking call must be repeated */
#define SSH_ERROR -1 /* Error of some kind */
#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
#define SSH_EOF -127 /* We have already a eof */
char *ssh_get_error(void *error);
int ssh_get_error_code(void *error);
void ssh_say(int priority, const char *format, ...);
void ssh_set_verbosity(int num);
/** \addtogroup ssh_log
* @{
*/
/** \brief Verbosity level for logging and help to debugging
/** \brief Verbosity level for logging and help to debugging
*/
enum {
@@ -140,177 +237,227 @@ enum {
/** Only rare and noteworthy events
*/
SSH_LOG_RARE,
/** High level protocol informations
/** High level protocol information
*/
SSH_LOG_PROTOCOL,
/** Lower level protocol infomations, packet level
*/
SSH_LOG_PACKET,
SSH_LOG_PACKET,
/** Every function path
*/
SSH_LOG_FUNCTIONS
SSH_LOG_FUNCTIONS
};
/** @}
*/
/*#define SSH_LOG_NOLOG 0 // no log
#define SSH_LOG_RARE 1 // rare conditions
#define SSH_LOG_ENTRY 2 // user-accessible entrypoints
#define SSH_LOG_PACKET 3 // packet id and size
#define SSH_LOG_FUNCTIONS 4 // every function in and return
*/
/* log.c */
void ssh_log(SSH_SESSION *session, int prioriry, char *format, ...);
/* session.c */
SSH_SESSION *ssh_new();
void ssh_set_options(SSH_SESSION *session, SSH_OPTIONS *options);
socket_t ssh_get_fd(SSH_SESSION *session);
void ssh_silent_disconnect(SSH_SESSION *session);
int ssh_get_version(SSH_SESSION *session);
void ssh_set_fd_toread(SSH_SESSION *session);
void ssh_set_fd_towrite(SSH_SESSION *session);
void ssh_set_fd_except(SSH_SESSION *session);
enum ssh_options_e {
SSH_OPTIONS_HOST,
SSH_OPTIONS_PORT,
SSH_OPTIONS_PORT_STR,
SSH_OPTIONS_FD,
SSH_OPTIONS_USER,
SSH_OPTIONS_SSH_DIR,
SSH_OPTIONS_IDENTITY,
SSH_OPTIONS_ADD_IDENTITY,
SSH_OPTIONS_KNOWNHOSTS,
SSH_OPTIONS_TIMEOUT,
SSH_OPTIONS_TIMEOUT_USEC,
SSH_OPTIONS_SSH1,
SSH_OPTIONS_SSH2,
SSH_OPTIONS_LOG_VERBOSITY,
SSH_OPTIONS_LOG_VERBOSITY_STR,
SSH_OPTIONS_CIPHERS_C_S,
SSH_OPTIONS_CIPHERS_S_C,
SSH_OPTIONS_COMPRESSION_C_S,
SSH_OPTIONS_COMPRESSION_S_C,
SSH_OPTIONS_PROXYCOMMAND,
SSH_OPTIONS_BINDADDR
};
/* client.c */
int ssh_connect(SSH_SESSION *session);
void ssh_disconnect(SSH_SESSION *session);
int ssh_service_request(SSH_SESSION *session,char *service);
char *ssh_get_issue_banner(SSH_SESSION *session);
/* get copyright informations */
const char *ssh_copyright();
/* string.h */
enum {
/** Code is going to write/create remote files */
SSH_SCP_WRITE,
/** Code is going to read remote files */
SSH_SCP_READ,
SSH_SCP_RECURSIVE=0x10
};
/* You can use these functions, they won't change */
/* makestring returns a newly allocated string from a char * ptr */
STRING *string_from_char(const char *what);
/* it returns the string len in host byte orders. str->size is big endian warning ! */
int string_len(STRING *str);
STRING *string_new(unsigned int size);
/* string_fill copies the data in the string. it does NOT check for boundary so allocate enough place with string_new */
void string_fill(STRING *str, const void *data,int len);
/* returns a newly allocated char array with the str string and a final nul caracter */
char *string_to_char(STRING *str);
STRING *string_copy(STRING *str);
/* burns the data inside a string */
void string_burn(STRING *str);
void *string_data(STRING *str);
void string_free(STRING *str);
enum ssh_scp_request_types {
/** A new directory is going to be pulled */
SSH_SCP_REQUEST_NEWDIR=1,
/** A new file is going to be pulled */
SSH_SCP_REQUEST_NEWFILE,
/** End of requests */
SSH_SCP_REQUEST_EOF,
/** End of directory */
SSH_SCP_REQUEST_ENDDIR,
/** Warning received */
SSH_SCP_REQUEST_WARNING
};
/* deprecated */
void ssh_crypto_init();
LIBSSH_API void buffer_free(ssh_buffer buffer);
LIBSSH_API void *buffer_get(ssh_buffer buffer);
LIBSSH_API uint32_t buffer_get_len(ssh_buffer buffer);
LIBSSH_API ssh_buffer buffer_new(void);
/* useful for debug */
void ssh_print_hexa(char *descr, const unsigned char *what, int len);
int ssh_get_random(void *where,int len,int strong);
/* this one can be called by the client to see the hash of the public key before accepting it */
int ssh_get_pubkey_hash(SSH_SESSION *session,unsigned char hash[MD5_DIGEST_LEN]);
STRING *ssh_get_pubkey(SSH_SESSION *session);
/* in connect.c */
int ssh_fd_poll(SSH_SESSION *session,int *write, int *except);
int ssh_select(CHANNEL **channels,CHANNEL **outchannels, socket_t maxfd, fd_set *readfds, struct timeval *timeout);
void publickey_free(PUBLIC_KEY *key);
/* in keyfiles.c */
PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session,char *filename,int type,char *passphrase);
STRING *publickey_to_string(PUBLIC_KEY *key);
PUBLIC_KEY *publickey_from_privatekey(PRIVATE_KEY *prv);
void private_key_free(PRIVATE_KEY *prv);
STRING *publickey_from_file(SSH_SESSION *session, char *filename,int *_type);
STRING *publickey_from_next_file(SSH_SESSION *session,char **pub_keys_path,char **keys_path,
char **privkeyfile,int *type,int *count);
int ssh_is_server_known(SSH_SESSION *session);
int ssh_write_knownhost(SSH_SESSION *session);
/* in channels.c */
CHANNEL *channel_new(SSH_SESSION *session);
int channel_open_forward(CHANNEL *channel,char *remotehost, int remoteport, char *sourcehost, int localport);
int channel_open_session(CHANNEL *channel);
void channel_free(CHANNEL *channel);
int channel_request_pty(CHANNEL *channel);
int channel_request_pty_size(CHANNEL *channel, char *term,int cols, int rows);
int channel_change_pty_size(CHANNEL *channel,int cols,int rows);
int channel_request_shell(CHANNEL *channel);
int channel_request_subsystem(CHANNEL *channel, char *system);
int channel_request_env(CHANNEL *channel,char *name, char *value);
int channel_request_exec(CHANNEL *channel, char *cmd);
int channel_request_sftp(CHANNEL *channel);
int channel_write(CHANNEL *channel,void *data,int len);
int channel_send_eof(CHANNEL *channel);
int channel_is_eof(CHANNEL *channel);
int channel_read(CHANNEL *channel, BUFFER *buffer,int bytes,int is_stderr);
int channel_poll(CHANNEL *channel, int is_stderr);
int channel_close(CHANNEL *channel);
int channel_read_nonblocking(CHANNEL *channel, char *dest, int len, int is_stderr);
int channel_is_open(CHANNEL *channel);
int channel_is_closed(CHANNEL *channel);
int channel_select(CHANNEL **readchans, CHANNEL **writechans, CHANNEL **exceptchans, struct
LIBSSH_API ssh_channel channel_accept_x11(ssh_channel channel, int timeout_ms);
LIBSSH_API int channel_change_pty_size(ssh_channel channel,int cols,int rows);
LIBSSH_API ssh_channel channel_forward_accept(ssh_session session, int timeout_ms);
LIBSSH_API int channel_close(ssh_channel channel);
LIBSSH_API int channel_forward_cancel(ssh_session session, const char *address, int port);
LIBSSH_API int channel_forward_listen(ssh_session session, const char *address, int port, int *bound_port);
LIBSSH_API void channel_free(ssh_channel channel);
LIBSSH_API int channel_get_exit_status(ssh_channel channel);
LIBSSH_API ssh_session channel_get_session(ssh_channel channel);
LIBSSH_API int channel_is_closed(ssh_channel channel);
LIBSSH_API int channel_is_eof(ssh_channel channel);
LIBSSH_API int channel_is_open(ssh_channel channel);
LIBSSH_API ssh_channel channel_new(ssh_session session);
LIBSSH_API int channel_open_forward(ssh_channel channel, const char *remotehost,
int remoteport, const char *sourcehost, int localport);
LIBSSH_API int channel_open_session(ssh_channel channel);
LIBSSH_API int channel_poll(ssh_channel channel, int is_stderr);
LIBSSH_API int channel_read(ssh_channel channel, void *dest, uint32_t count, int is_stderr);
LIBSSH_API int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count,
int is_stderr);
LIBSSH_API int channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count,
int is_stderr);
LIBSSH_API int channel_request_env(ssh_channel channel, const char *name, const char *value);
LIBSSH_API int channel_request_exec(ssh_channel channel, const char *cmd);
LIBSSH_API int channel_request_pty(ssh_channel channel);
LIBSSH_API int channel_request_pty_size(ssh_channel channel, const char *term,
int cols, int rows);
LIBSSH_API int channel_request_shell(ssh_channel channel);
LIBSSH_API int channel_request_send_signal(ssh_channel channel, const char *signum);
LIBSSH_API int channel_request_sftp(ssh_channel channel);
LIBSSH_API int channel_request_subsystem(ssh_channel channel, const char *subsystem);
LIBSSH_API int channel_request_x11(ssh_channel channel, int single_connection, const char *protocol,
const char *cookie, int screen_number);
LIBSSH_API int channel_send_eof(ssh_channel channel);
LIBSSH_API int channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
timeval * timeout);
/* in options.c */
LIBSSH_API void channel_set_blocking(ssh_channel channel, int blocking);
LIBSSH_API int channel_write(ssh_channel channel, const void *data, uint32_t len);
SSH_OPTIONS *ssh_options_new();
SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt);
int ssh_options_set_wanted_algos(SSH_OPTIONS *opt, int algo, const char *list);
void ssh_options_set_username(SSH_OPTIONS *opt, const char *username);
void ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port);
int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv);
void ssh_options_set_host(SSH_OPTIONS *opt, const char *host);
void ssh_options_set_fd(SSH_OPTIONS *opt, socket_t fd);
void ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port);
void ssh_options_set_identity(SSH_OPTIONS *opt, const char *identity);
void ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback)
(void *arg, float status), void *arg);
void ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec);
void ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir);
void ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, const char *dir);
void ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow);
void ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow);
void ssh_options_set_dsa_server_key(SSH_OPTIONS *opt, const char *dsakey);
void ssh_options_set_rsa_server_key(SSH_OPTIONS *opt, const char *rsakey);
void ssh_options_set_log_function(SSH_OPTIONS *opt,
void (*callback)(const char *message, SSH_SESSION *session, int verbosity ));
void ssh_options_set_log_verbosity(SSH_OPTIONS *opt, int verbosity);
LIBSSH_API void privatekey_free(ssh_private_key prv);
LIBSSH_API ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
int type, const char *passphrase);
LIBSSH_API void publickey_free(ssh_public_key key);
LIBSSH_API int ssh_publickey_to_file(ssh_session session, const char *file,
ssh_string pubkey, int type);
LIBSSH_API ssh_string publickey_from_file(ssh_session session, const char *filename,
int *type);
LIBSSH_API ssh_public_key publickey_from_privatekey(ssh_private_key prv);
LIBSSH_API ssh_string publickey_to_string(ssh_public_key key);
LIBSSH_API int ssh_try_publickey_from_file(ssh_session session, const char *keyfile,
ssh_string *publickey, int *type);
LIBSSH_API int ssh_auth_list(ssh_session session);
LIBSSH_API char *ssh_basename (const char *path);
LIBSSH_API void ssh_clean_pubkey_hash(unsigned char **hash);
LIBSSH_API int ssh_connect(ssh_session session);
LIBSSH_API const char *ssh_copyright(void);
LIBSSH_API void ssh_disconnect(ssh_session session);
LIBSSH_API char *ssh_dirname (const char *path);
LIBSSH_API int ssh_finalize(void);
LIBSSH_API void ssh_free(ssh_session session);
LIBSSH_API const char *ssh_get_disconnect_message(ssh_session session);
LIBSSH_API const char *ssh_get_error(void *error);
LIBSSH_API int ssh_get_error_code(void *error);
LIBSSH_API socket_t ssh_get_fd(ssh_session session);
LIBSSH_API char *ssh_get_hexa(const unsigned char *what, size_t len);
LIBSSH_API char *ssh_get_issue_banner(ssh_session session);
LIBSSH_API int ssh_get_openssh_version(ssh_session session);
LIBSSH_API ssh_string ssh_get_pubkey(ssh_session session);
LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash);
LIBSSH_API int ssh_get_random(void *where,int len,int strong);
LIBSSH_API int ssh_get_version(ssh_session session);
LIBSSH_API int ssh_get_status(ssh_session session);
LIBSSH_API int ssh_init(void);
LIBSSH_API int ssh_is_server_known(ssh_session session);
LIBSSH_API void ssh_log(ssh_session session, int prioriry, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg);
LIBSSH_API int ssh_message_channel_request_reply_success(ssh_message msg);
LIBSSH_API void ssh_message_free(ssh_message msg);
LIBSSH_API ssh_message ssh_message_get(ssh_session session);
LIBSSH_API ssh_message ssh_message_retrieve(ssh_session session, uint32_t packettype);
LIBSSH_API int ssh_message_subtype(ssh_message msg);
LIBSSH_API int ssh_message_type(ssh_message msg);
LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
LIBSSH_API ssh_session ssh_new(void);
LIBSSH_API int ssh_options_copy(ssh_session src, ssh_session *dest);
LIBSSH_API int ssh_options_getopt(ssh_session session, int *argcptr, char **argv);
LIBSSH_API int ssh_options_parse_config(ssh_session session, const char *filename);
LIBSSH_API int ssh_options_set(ssh_session session, enum ssh_options_e type,
const void *value);
LIBSSH_API int ssh_pcap_file_close(ssh_pcap_file pcap);
LIBSSH_API void ssh_pcap_file_free(ssh_pcap_file pcap);
LIBSSH_API ssh_pcap_file ssh_pcap_file_new(void);
LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename);
LIBSSH_API int ssh_privatekey_type(ssh_private_key privatekey);
LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
LIBSSH_API int ssh_scp_accept_request(ssh_scp scp);
LIBSSH_API int ssh_scp_close(ssh_scp scp);
LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason);
LIBSSH_API void ssh_scp_free(ssh_scp scp);
LIBSSH_API int ssh_scp_init(ssh_scp scp);
LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp);
LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location);
LIBSSH_API int ssh_scp_pull_request(ssh_scp scp);
LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode);
LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms);
LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size);
LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp);
LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp);
LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp);
LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp);
LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
fd_set *readfds, struct timeval *timeout);
LIBSSH_API int ssh_service_request(ssh_session session, const char *service);
LIBSSH_API void ssh_set_blocking(ssh_session session, int blocking);
LIBSSH_API void ssh_set_fd_except(ssh_session session);
LIBSSH_API void ssh_set_fd_toread(ssh_session session);
LIBSSH_API void ssh_set_fd_towrite(ssh_session session);
LIBSSH_API void ssh_silent_disconnect(ssh_session session);
LIBSSH_API int ssh_set_pcap_file(ssh_session session, ssh_pcap_file pcapfile);
#ifndef _WIN32
LIBSSH_API int ssh_userauth_agent_pubkey(ssh_session session, const char *username,
ssh_public_key publickey);
#endif
LIBSSH_API int ssh_userauth_autopubkey(ssh_session session, const char *passphrase);
LIBSSH_API int ssh_userauth_kbdint(ssh_session session, const char *user, const char *submethods);
LIBSSH_API const char *ssh_userauth_kbdint_getinstruction(ssh_session session);
LIBSSH_API const char *ssh_userauth_kbdint_getname(ssh_session session);
LIBSSH_API int ssh_userauth_kbdint_getnprompts(ssh_session session);
LIBSSH_API const char *ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i, char *echo);
LIBSSH_API int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i,
const char *answer);
LIBSSH_API int ssh_userauth_list(ssh_session session, const char *username);
LIBSSH_API int ssh_userauth_none(ssh_session session, const char *username);
LIBSSH_API int ssh_userauth_offer_pubkey(ssh_session session, const char *username, int type, ssh_string publickey);
LIBSSH_API int ssh_userauth_password(ssh_session session, const char *username, const char *password);
LIBSSH_API int ssh_userauth_pubkey(ssh_session session, const char *username, ssh_string publickey, ssh_private_key privatekey);
LIBSSH_API const char *ssh_version(int req_version);
LIBSSH_API int ssh_write_knownhost(ssh_session session);
LIBSSH_API void string_burn(ssh_string str);
LIBSSH_API ssh_string string_copy(ssh_string str);
LIBSSH_API void *string_data(ssh_string str);
LIBSSH_API int string_fill(ssh_string str, const void *data, size_t len);
LIBSSH_API void string_free(ssh_string str);
LIBSSH_API ssh_string string_from_char(const char *what);
LIBSSH_API size_t string_len(ssh_string str);
LIBSSH_API ssh_string string_new(size_t size);
LIBSSH_API char *string_to_char(ssh_string str);
/* buffer.c */
/** creates a new buffer
*/
BUFFER *buffer_new();
void buffer_free(BUFFER *buffer);
/* buffer_get returns a pointer to the begining of the buffer. no position is taken into account */
void *buffer_get(BUFFER *buffer);
/* same here */
int buffer_get_len(BUFFER *buffer);
/* in auth.c */
/* these functions returns AUTH_ERROR is some serious error has happened,
AUTH_SUCCESS if success,
AUTH_PARTIAL if partial success,
AUTH_DENIED if refused */
int ssh_userauth_list(SSH_SESSION *session, const char *username);
int ssh_userauth_none(SSH_SESSION *session, const char *username);
int ssh_userauth_password(SSH_SESSION *session, const char *username, const char *password);
int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username, int type, STRING *publickey);
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username, STRING *publickey, PRIVATE_KEY *privatekey);
int ssh_userauth_autopubkey(SSH_SESSION *session);
int ssh_userauth_kbdint(SSH_SESSION *session, const char *user, const char *submethods);
int ssh_userauth_kbdint_getnprompts(SSH_SESSION *session);
char *ssh_userauth_kbdint_getname(SSH_SESSION *session);
char *ssh_userauth_kbdint_getinstruction(SSH_SESSION *session);
char *ssh_userauth_kbdint_getprompt(SSH_SESSION *session, int i, char *echo);
void ssh_userauth_kbdint_setanswer(SSH_SESSION *session, unsigned int i, const char *answer);
/* init.c */
int ssh_finalize();
#ifdef __cplusplus
}
}
#endif
#endif /* _LIBSSH_H */
/* vim: set ts=2 sw=2 et cindent: */

84
include/libssh/messages.h Normal file
View File

@@ -0,0 +1,84 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef MESSAGES_H_
#define MESSAGES_H_
#include "config.h"
struct ssh_auth_request {
char *username;
int method;
char *password;
struct ssh_public_key_struct *public_key;
char signature_state;
};
struct ssh_channel_request_open {
int type;
uint32_t sender;
uint32_t window;
uint32_t packet_size;
char *originator;
uint16_t originator_port;
char *destination;
uint16_t destination_port;
};
struct ssh_service_request {
char *service;
};
struct ssh_channel_request {
int type;
ssh_channel channel;
uint8_t want_reply;
/* pty-req type specifics */
char *TERM;
uint32_t width;
uint32_t height;
uint32_t pxwidth;
uint32_t pxheight;
ssh_string modes;
/* env type request */
char *var_name;
char *var_value;
/* exec type request */
char *command;
/* subsystem */
char *subsystem;
};
struct ssh_message_struct {
ssh_session session;
int type;
struct ssh_auth_request auth_request;
struct ssh_channel_request_open channel_request_open;
struct ssh_channel_request channel_request;
struct ssh_service_request service_request;
};
void message_handle(ssh_session session, uint32_t type);
int ssh_execute_message_callbacks(ssh_session session);
#endif /* MESSAGES_H_ */

71
include/libssh/misc.h Normal file
View File

@@ -0,0 +1,71 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef MISC_H_
#define MISC_H_
/* in misc.c */
/* gets the user home dir. */
char *ssh_get_user_home_dir(void);
char *ssh_get_local_username(ssh_session session);
int ssh_file_readaccess_ok(const char *file);
char *ssh_path_expand_tilde(const char *d);
char *ssh_path_expand_escape(ssh_session session, const char *s);
/* macro for byte ordering */
uint64_t ntohll(uint64_t);
#define htonll(x) ntohll(x)
/* list processing */
struct ssh_list {
struct ssh_iterator *root;
struct ssh_iterator *end;
};
struct ssh_iterator {
struct ssh_iterator *next;
const void *data;
};
struct ssh_list *ssh_list_new(void);
void ssh_list_free(struct ssh_list *list);
struct ssh_iterator *ssh_list_get_iterator(const struct ssh_list *list);
int ssh_list_append(struct ssh_list *list, const void *data);
int ssh_list_prepend(struct ssh_list *list, const void *data);
void ssh_list_remove(struct ssh_list *list, struct ssh_iterator *iterator);
char *ssh_hostport(const char *host, int port);
const void *_ssh_list_pop_head(struct ssh_list *list);
#define ssh_iterator_value(type, iterator)\
((type)((iterator)->data))
/** @brief fetch the head element of a list and remove it from list
* @param type type of the element to return
* @param list the ssh_list to use
* @return the first element of the list, or NULL if the list is empty
*/
#define ssh_list_pop_head(type, ssh_list)\
((type)_ssh_list_pop_head(ssh_list))
#endif /* MISC_H_ */

41
include/libssh/packet.h Normal file
View File

@@ -0,0 +1,41 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef PACKET_H_
#define PACKET_H_
/* this structure should go someday */
typedef struct packet_struct {
int valid;
uint32_t len;
uint8_t type;
} PACKET;
void packet_parse(ssh_session session);
int packet_send(ssh_session session);
int packet_read(ssh_session session);
int packet_translate(ssh_session session);
int packet_wait(ssh_session session,int type,int blocking);
int packet_flush(ssh_session session, int enforce_blocking);
#endif /* PACKET_H_ */

26
include/libssh/pcap.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef PCAP_H_
#define PCAP_H_
#include "config.h"
#include "libssh/libssh.h"
#ifdef WITH_PCAP
typedef struct ssh_pcap_context_struct* ssh_pcap_context;
int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len);
ssh_pcap_context ssh_pcap_context_new(ssh_session session);
void ssh_pcap_context_free(ssh_pcap_context ctx);
enum ssh_pcap_direction{
SSH_PCAP_DIR_IN,
SSH_PCAP_DIR_OUT
};
void ssh_pcap_context_set_file(ssh_pcap_context, ssh_pcap_file);
int ssh_pcap_context_write(ssh_pcap_context,enum ssh_pcap_direction direction, void *data,
uint32_t len, uint32_t origlen);
#endif /* WITH_PCAP */
#endif /* PCAP_H_ */
/* vim: set ts=2 sw=2 et cindent: */

155
include/libssh/poll.h Normal file
View File

@@ -0,0 +1,155 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef POLL_H_
#define POLL_H_
#include "config.h"
#ifdef HAVE_POLL
#include <poll.h>
typedef struct pollfd ssh_pollfd_t;
#else /* HAVE_POLL */
/* poll emulation support */
typedef struct ssh_pollfd_struct {
socket_t fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
} ssh_pollfd_t;
typedef unsigned long int nfds_t;
#ifdef _WIN32
#ifndef POLLRDNORM
#define POLLRDNORM 0x0100
#endif
#ifndef POLLRDBAND
#define POLLRDBAND 0x0200
#endif
#ifndef POLLIN
#define POLLIN (POLLRDNORM | POLLRDBAND)
#endif
#ifndef POLLPRI
#define POLLPRI 0x0400
#endif
#ifndef POLLWRNORM
#define POLLWRNORM 0x0010
#endif
#ifndef POLLOUT
#define POLLOUT (POLLWRNORM)
#endif
#ifndef POLLWRBAND
#define POLLWRBAND 0x0020
#endif
#ifndef POLLERR
#define POLLERR 0x0001
#endif
#ifndef POLLHUP
#define POLLHUP 0x0002
#endif
#ifndef POLLNVAL
#define POLLNVAL 0x0004
#endif
#else /* _WIN32 */
/* poll.c */
#ifndef POLLIN
#define POLLIN 0x001 /* There is data to read. */
#endif
#ifndef POLLPRI
#define POLLPRI 0x002 /* There is urgent data to read. */
#endif
#ifndef POLLOUT
#define POLLOUT 0x004 /* Writing now will not block. */
#endif
#ifndef POLLERR
#define POLLERR 0x008 /* Error condition. */
#endif
#ifndef POLLHUP
#define POLLHUP 0x010 /* Hung up. */
#endif
#ifndef POLLNVAL
#define POLLNVAL 0x020 /* Invalid polling request. */
#endif
#ifndef POLLRDNORM
#define POLLRDNORM 0x040 /* mapped to read fds_set */
#endif
#ifndef POLLRDBAND
#define POLLRDBAND 0x080 /* mapped to exception fds_set */
#endif
#ifndef POLLWRNORM
#define POLLWRNORM 0x100 /* mapped to write fds_set */
#endif
#ifndef POLLWRBAND
#define POLLWRBAND 0x200 /* mapped to write fds_set */
#endif
#endif /* WIN32 */
#endif /* HAVE_POLL */
void ssh_poll_init(void);
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
typedef struct ssh_poll_ctx_struct *ssh_poll_ctx;
typedef struct ssh_poll_handle_struct *ssh_poll_handle;
/**
* @brief SSH poll callback.
*
* @param p Poll object this callback belongs to.
* @param fd The raw socket.
* @param revents The current poll events on the socket.
* @param userdata Userdata to be passed to the callback function.
*
* @return 0 on success, < 0 if you removed the poll object from
* it's poll context.
*/
typedef int (*ssh_poll_callback)(ssh_poll_handle p, socket_t fd, int revents,
void *userdata);
ssh_poll_handle ssh_poll_new(socket_t fd, short events, ssh_poll_callback cb,
void *userdata);
void ssh_poll_free(ssh_poll_handle p);
ssh_poll_ctx ssh_poll_get_ctx(ssh_poll_handle p);
short ssh_poll_get_events(ssh_poll_handle p);
void ssh_poll_set_events(ssh_poll_handle p, short events);
void ssh_poll_add_events(ssh_poll_handle p, short events);
void ssh_poll_remove_events(ssh_poll_handle p, short events);
socket_t ssh_poll_get_fd(ssh_poll_handle p);
void ssh_poll_set_callback(ssh_poll_handle p, ssh_poll_callback cb, void *userdata);
ssh_poll_ctx ssh_poll_ctx_new(size_t chunk_size);
void ssh_poll_ctx_free(ssh_poll_ctx ctx);
int ssh_poll_ctx_add(ssh_poll_ctx ctx, ssh_poll_handle p);
void ssh_poll_ctx_remove(ssh_poll_ctx ctx, ssh_poll_handle p);
int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout);
#endif /* POLL_H_ */

View File

@@ -1,622 +1,240 @@
/*
Copyright (c) 2003-2008 Aris Adamantiadis
* This file is part of the SSH Library
*
* Copyright (c) 2003-2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
This file is part of the SSH Library
The SSH Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
The SSH Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
/* priv.h file */
/* This include file contains everything you shouldn't deal with in user programs. */
/* Consider that anything in this file might change without notice; libssh.h file will keep */
/* backward compatibility on binary & source */
/*
* priv.h file
* This include file contains everything you shouldn't deal with in
* user programs. Consider that anything in this file might change
* without notice; libssh.h file will keep backward compatibility
* on binary & source
*/
#ifndef _LIBSSH_PRIV_H
#define _LIBSSH_PRIV_H
#include "config.h"
#ifdef _MSC_VER
/** Imitate define of inttypes.h */
#define PRIdS "Id"
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define strtoull _strtoui64
#define isblank(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\n' || (ch) == '\r')
#if _MSC_VER >= 1400
#define strdup _strdup
#endif
#define usleep(X) Sleep(((X)+1000)/1000)
#undef strtok_r
#define strtok_r strtok_s
#ifndef HAVE_SNPRINTF
#ifdef HAVE__SNPRINTF_S
#define snprintf(d, n, ...) _snprintf_s((d), (n), _TRUNCATE, __VA_ARGS__)
#else
#ifdef HAVE__SNPRINTF
#define snprintf _snprintf
#else
#error "no snprintf compatible function found"
#endif /* HAVE__SNPRINTF */
#endif /* HAVE__SNPRINTF_S */
#endif /* HAVE_SNPRINTF */
#ifndef HAVE_VSNPRINTF
#ifdef HAVE__VSNPRINTF_S
#define vsnprintf(s, n, f, v) _vsnprintf_s((s), (n), _TRUNCATE, (f), (v))
#else
#ifdef HAVE__VSNPRINTF
#define vsnprintf _vsnprintf
#else /* HAVE_VSNPRINTF */
#error "No vsnprintf compatible function found"
#endif /* HAVE__VSNPRINTF */
#endif /* HAVE__VSNPRINTF_S */
#endif /* HAVE_VSNPRINTF */
#ifndef HAVE_STRNCPY
#define strncpy(d, s, n) strncpy_s((d), (n), (s), _TRUNCATE)
#endif
#else /* _MSC_VER */
#include <unistd.h>
#define PRIdS "zd"
#endif /* _MSC_VER */
#include "libssh/libssh.h"
/* Debugging constants */
/* Define this if you want to debug crypto systems */
/* it's usefull when you are debugging the lib */
/*#define DEBUG_CRYPTO */
#include "libssh/callbacks.h"
#include "libssh/crypto.h"
/* some constants */
#define MAX_PACKET_LEN 262144
#define ERROR_BUFFERLEN 1024
#define CLIENTBANNER1 "SSH-1.5-" LIBSSH_VERSION
#define CLIENTBANNER2 "SSH-2.0-" LIBSSH_VERSION
#define CLIENTBANNER1 "SSH-1.5-libssh-" SSH_STRINGIFY(LIBSSH_VERSION)
#define CLIENTBANNER2 "SSH-2.0-libssh-" SSH_STRINGIFY(LIBSSH_VERSION)
#define KBDINT_MAX_PROMPT 256 /* more than openssh's :) */
/* some types for public keys */
#define TYPE_DSS 1
#define TYPE_RSA 2
#define TYPE_RSA1 3
/* profiling constants. Don't touch them unless you know what you do */
#ifdef HAVE_LIBCRYPTO
#define OPENSSL_BIGNUMS
#endif
enum public_key_types_e{
TYPE_DSS=1,
TYPE_RSA,
TYPE_RSA1
};
#ifdef __cplusplus
extern "C" {
#endif
/* wrapper things */
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
typedef gcry_md_hd_t SHACTX;
typedef gcry_md_hd_t MD5CTX;
typedef gcry_md_hd_t HMACCTX;
#ifdef MD5_DIGEST_LEN
#undef MD5_DIGEST_LEN
#endif
#define SHA_DIGEST_LEN 20
#define MD5_DIGEST_LEN 16
#define EVP_MAX_MD_SIZE 36
typedef gcry_mpi_t bignum;
#define bignum_new() gcry_mpi_new(0)
#define bignum_free(num) gcry_mpi_release(num)
#define bignum_set_word(bn,n) gcry_mpi_set_ui(bn,n)
#define bignum_bin2bn(bn,datalen,data) gcry_mpi_scan(data,GCRYMPI_FMT_USG,bn,datalen,NULL)
#define bignum_bn2dec(num) my_gcry_bn2dec(num)
#define bignum_dec2bn(num, data) my_gcry_dec2bn(data, num)
#define bignum_bn2hex(num,data) gcry_mpi_aprint(GCRYMPI_FMT_HEX,data,NULL,num)
#define bignum_hex2bn(num,datalen,data) gcry_mpi_scan(num,GCRYMPI_FMT_HEX,data,datalen,NULL)
#define bignum_rand(num,bits) gcry_mpi_randomize(num,bits,GCRY_STRONG_RANDOM),gcry_mpi_set_bit(num,bits-1),gcry_mpi_set_bit(num,0)
#define bignum_mod_exp(dest,generator,exp,modulo) gcry_mpi_powm(dest,generator,exp,modulo)
#define bignum_num_bits(num) gcry_mpi_get_nbits(num)
#define bignum_num_bytes(num) ((gcry_mpi_get_nbits(num)+7)/8)
#define bignum_is_bit_set(num,bit) gcry_mpi_test_bit(num,bit)
#define bignum_bn2bin(num,datalen,data) gcry_mpi_print(GCRYMPI_FMT_USG,data,datalen,NULL,num)
#define bignum_cmp(num1,num2) gcry_mpi_cmp(num1,num2)
#elif defined HAVE_LIBCRYPTO
#include <openssl/dsa.h>
#include <openssl/rsa.h>
#include <openssl/sha.h>
#include <openssl/md5.h>
#include <openssl/hmac.h>
typedef SHA_CTX* SHACTX;
typedef MD5_CTX* MD5CTX;
typedef HMAC_CTX* HMACCTX;
#ifdef MD5_DIGEST_LEN
#undef MD5_DIGEST_LEN
#endif
#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
#define MD5_DIGEST_LEN MD5_DIGEST_LENGTH
#endif /* OPENSSL_CRYPTO */
#ifdef OPENSSL_BIGNUMS
#include <openssl/bn.h>
typedef BIGNUM* bignum;
typedef BN_CTX* bignum_CTX;
#define bignum_new() BN_new()
#define bignum_free(num) BN_clear_free(num)
#define bignum_set_word(bn,n) BN_set_word(bn,n)
#define bignum_bin2bn(bn,datalen,data) BN_bin2bn(bn,datalen,data)
#define bignum_bn2dec(num) BN_bn2dec(num)
#define bignum_dec2bn(bn,data) BN_dec2bn(data,bn)
#define bignum_bn2hex(num) BN_bn2hex(num)
#define bignum_rand(rnd, bits, top, bottom) BN_rand(rnd,bits,top,bottom)
#define bignum_ctx_new() BN_CTX_new()
#define bignum_ctx_free(num) BN_CTX_free(num)
#define bignum_mod_exp(dest,generator,exp,modulo,ctx) BN_mod_exp(dest,generator,exp,modulo,ctx)
#define bignum_num_bytes(num) BN_num_bytes(num)
#define bignum_num_bits(num) BN_num_bits(num)
#define bignum_is_bit_set(num,bit) BN_is_bit_set(num,bit)
#define bignum_bn2bin(num,ptr) BN_bn2bin(num,ptr)
#define bignum_cmp(num1,num2) BN_cmp(num1,num2)
#endif /* OPENSSL_BIGNUMS */
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
/* wrapper.c */
MD5CTX md5_init(void);
void md5_update(MD5CTX c, const void *data, unsigned long len);
void md5_final(unsigned char *md,MD5CTX c);
SHACTX sha1_init(void);
void sha1_update(SHACTX c, const void *data, unsigned long len);
void sha1_final(unsigned char *md,SHACTX c);
void sha1(unsigned char *digest,int len,unsigned char *hash);
#define HMAC_SHA1 1
#define HMAC_MD5 2
HMACCTX hmac_init(const void *key,int len,int type);
void hmac_update(HMACCTX c, const void *data, unsigned long len);
void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
/* strings and buffers */
/* must be 32 bits number + immediatly our data */
struct string_struct {
u32 size;
unsigned char string[MAX_PACKET_LEN];
} __attribute__ ((packed));
/** Describes a buffer state at a moment
*/
struct buffer_struct {
char *data;
int used;
int allocated;
int pos;
};
/* i should remove it one day */
typedef struct packet_struct {
int valid;
u32 len;
u8 type;
} PACKET;
typedef struct kex_struct {
unsigned char cookie[16];
char **methods;
} KEX;
struct public_key_struct {
int type;
char *type_c; /* Don't free it ! it is static */
#ifdef HAVE_LIBGCRYPT
gcry_sexp_t dsa_pub;
gcry_sexp_t rsa_pub;
#elif HAVE_LIBCRYPTO
DSA *dsa_pub;
RSA *rsa_pub;
#endif
};
struct private_key_struct {
int type;
#ifdef HAVE_LIBGCRYPT
gcry_sexp_t dsa_priv;
gcry_sexp_t rsa_priv;
#elif defined HAVE_LIBCRYPTO
DSA *dsa_priv;
RSA *rsa_priv;
#endif
};
typedef struct signature_struct {
int type;
#ifdef HAVE_LIBGCRYPT
gcry_sexp_t dsa_sign;
gcry_sexp_t rsa_sign;
#elif defined HAVE_LIBCRYPTO
DSA_SIG *dsa_sign;
STRING *rsa_sign;
#endif
} SIGNATURE;
struct error_struct {
/* error handling */
int error_code;
unsigned int error_code;
char error_buffer[ERROR_BUFFERLEN];
};
struct ssh_options_struct {
struct error_struct error;
char *banner; /* explicit banner to send */
char *username;
char *host;
char *bindaddr;
int bindport;
char *identity;
char *ssh_dir;
char *known_hosts_file;
socket_t fd; /* specificaly wanted file descriptor, don't connect host */
int port;
int dont_verify_hostkey; /* Don't spare time, don't check host key ! unneeded to say it's dangerous and not safe */
int use_nonexisting_algo; /* if user sets a not supported algorithm for kex, don't complain */
char *wanted_methods[10]; /* the kex methods can be choosed. better use the kex fonctions to do that */
void *wanted_cookie; /* wants a specific cookie to be sent ? if null, generate a new one */
void *passphrase_function; /* this functions will be called if a keyphrase is needed. look keyfiles.c for more info */
void (*connect_status_function)(void *arg, float status); /* status callback function */
void *connect_status_arg; /* arbitrary argument */
long timeout; /* seconds */
long timeout_usec;
int ssh2allowed;
int ssh1allowed;
char *dsakey;
char *rsakey; /* host key for server implementation */
int log_verbosity;
void (*log_function)(const char *message, SSH_SESSION *session, int verbosity); //log callback
/* TODO: remove that include */
#include "libssh/wrapper.h"
struct ssh_keys_struct {
const char *privatekey;
const char *publickey;
};
typedef struct ssh_crypto_struct {
bignum e,f,x,k,y;
unsigned char session_id[SHA_DIGEST_LEN];
unsigned char encryptIV[SHA_DIGEST_LEN*2];
unsigned char decryptIV[SHA_DIGEST_LEN*2];
struct ssh_message_struct;
unsigned char decryptkey[SHA_DIGEST_LEN*2];
unsigned char encryptkey[SHA_DIGEST_LEN*2];
unsigned char encryptMAC[SHA_DIGEST_LEN];
unsigned char decryptMAC[SHA_DIGEST_LEN];
unsigned char hmacbuf[EVP_MAX_MD_SIZE];
struct crypto_struct *in_cipher, *out_cipher; /* the cipher structures/objects */
STRING *server_pubkey;
char *server_pubkey_type;
int do_compress_out; /* idem */
int do_compress_in; /* don't set them, set the option instead */
void *compress_out_ctx; /* don't touch it */
void *compress_in_ctx; /* really, don't */
} CRYPTO;
struct channel_struct {
struct channel_struct *prev;
struct channel_struct *next;
SSH_SESSION *session; /* SSH_SESSION pointer */
u32 local_channel;
u32 local_window;
int local_eof;
u32 local_maxpacket;
u32 remote_channel;
u32 remote_window;
int remote_eof; /* end of file received */
u32 remote_maxpacket;
int open; /* shows if the channel is still opened */
int delayed_close;
BUFFER *stdout_buffer;
BUFFER *stderr_buffer;
void *userarg;
int version;
int blocking;
};
struct ssh_session {
struct error_struct error;
struct socket *socket;
SSH_OPTIONS *options;
char *serverbanner;
char *clientbanner;
int protoversion;
int server;
int client;
u32 send_seq;
u32 recv_seq;
/* status flags */
int closed;
int closed_by_except;
int connected;
/* !=0 when the user got a session handle */
int alive;
/* two previous are deprecated */
int auth_service_asked;
/* socket status */
int blocking; // functions should block
STRING *banner; /* that's the issue banner from
the server */
char *remotebanner; /* that's the SSH- banner from
remote host. */
char *discon_msg; /* disconnect message from
the remote host */
BUFFER *in_buffer;
PACKET in_packet;
BUFFER *out_buffer;
/* the states are used by the nonblocking stuff to remember */
/* where it was before being interrupted */
int packet_state;
int dh_handshake_state;
STRING *dh_server_signature; //information used by dh_handshake.
KEX server_kex;
KEX client_kex;
BUFFER *in_hashbuf;
BUFFER *out_hashbuf;
CRYPTO *current_crypto;
CRYPTO *next_crypto; /* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */
CHANNEL *channels; /* linked list of channels */
int maxchannel;
int exec_channel_opened; /* version 1 only. more
info in channels1.c */
/* keyb interactive data */
struct ssh_kbdint *kbdint;
int version; /* 1 or 2 */
/* server host keys */
PRIVATE_KEY *rsa_key;
PRIVATE_KEY *dsa_key;
/* auths accepted by server */
int auth_methods;
int hostkeys; /* contains type of host key wanted by client, in server impl */
struct ssh_message *ssh_message; /* ssh message */
int log_verbosity; /*cached copy of the option structure */
int log_indent; /* indentation level in enter_function logs */
};
struct ssh_kbdint {
u32 nprompts;
char *name;
char *instruction;
char **prompts;
unsigned char *echo; /* bool array */
char **answers;
};
/* server data */
struct ssh_bind_struct {
struct error_struct error;
socket_t bindfd;
SSH_OPTIONS *options;
int blocking;
int toaccept;
struct error_struct error;
ssh_callbacks callbacks; /* Callbacks to user functions */
/* options */
char *wanted_methods[10];
char *banner;
char *dsakey;
char *rsakey;
char *bindaddr;
socket_t bindfd;
unsigned int bindport;
unsigned int log_verbosity;
int blocking;
int toaccept;
};
struct ssh_auth_request {
char *username;
int method;
char *password;
};
struct ssh_channel_request_open {
int type;
u32 sender;
u32 window;
u32 packet_size;
char *originator;
u16 orignator_port;
char *destination;
u16 destination_port;
};
struct ssh_channel_request {
int type;
CHANNEL *channel;
u8 want_reply;
/* pty-req type specifics */
char *TERM;
u32 width;
u32 height;
u32 pxwidth;
u32 pxheight;
STRING *modes;
/* env type request */
char *var_name;
char *var_value;
/* exec type request */
char *command;
/* subsystem */
char *subsystem;
};
struct ssh_message {
SSH_SESSION *session;
int type;
struct ssh_auth_request auth_request;
struct ssh_channel_request_open channel_request_open;
struct ssh_channel_request channel_request;
};
/* socket.c */
struct socket;
void ssh_socket_init();
struct socket *ssh_socket_new(SSH_SESSION *session);
void ssh_socket_free(struct socket *s);
void ssh_socket_set_fd(struct socket *s, socket_t fd);
socket_t ssh_socket_get_fd(struct socket *s);
void ssh_socket_close(struct socket *s);
int ssh_socket_read(struct socket *s, void *buffer, int len);
int ssh_socket_write(struct socket *s,const void *buffer, int len);
int ssh_socket_is_open(struct socket *s);
int ssh_socket_fd_isset(struct socket *s, fd_set *set);
void ssh_socket_fd_set(struct socket *s, fd_set *set, int *fd_max);
int ssh_socket_completeread(struct socket *s, void *buffer, int len);
int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session,int len);
int ssh_socket_nonblocking_flush(struct socket *s);
int ssh_socket_blocking_flush(struct socket *s);
int ssh_socket_poll(struct socket *s, int *write, int *except);
void ssh_socket_set_towrite(struct socket *s);
void ssh_socket_set_toread(struct socket *s);
void ssh_socket_set_except(struct socket *s);
int ssh_socket_get_status(struct socket *s);
int ssh_socket_data_available(struct socket *s);
int ssh_socket_data_writable(struct socket *s);
/* session.c */
void ssh_cleanup(SSH_SESSION *session);
/* client.c */
int ssh_send_banner(SSH_SESSION *session, int is_server);
char *ssh_get_banner(SSH_SESSION *session);
int ssh_send_banner(ssh_session session, int is_server);
char *ssh_get_banner(ssh_session session);
/* config.c */
int ssh_config_parse_file(ssh_session session, const char *filename);
/* errors.c */
void ssh_set_error(void *error,int code,char *descr,...);
/* in dh.c */
/* DH key generation */
void dh_generate_e(SSH_SESSION *session);
void ssh_print_bignum(char *which,bignum num);
void dh_generate_x(SSH_SESSION *session);
void dh_generate_y(SSH_SESSION *session);
void dh_generate_f(SSH_SESSION *session);
void ssh_crypto_finalize();
STRING *dh_get_e(SSH_SESSION *session);
STRING *dh_get_f(SSH_SESSION *session);
void dh_import_f(SSH_SESSION *session,STRING *f_string);
void dh_import_e(SSH_SESSION *session, STRING *e_string);
void dh_import_pubkey(SSH_SESSION *session,STRING *pubkey_string);
void dh_build_k(SSH_SESSION *session);
void make_sessionid(SSH_SESSION *session);
/* add data for the final cookie */
void hashbufin_add_cookie(SSH_SESSION *session,unsigned char *cookie);
void hashbufout_add_cookie(SSH_SESSION *session);
void generate_session_keys(SSH_SESSION *session);
/* returns 1 if server signature ok, 0 otherwise. The NEXT crypto is checked, not the current one */
int signature_verify(SSH_SESSION *session,STRING *signature);
bignum make_string_bn(STRING *string);
STRING *make_bignum_string(bignum num);
void ssh_set_error(void *error, int code, const char *descr, ...) PRINTF_ATTRIBUTE(3, 4);
void ssh_set_error_oom(void *);
void ssh_set_error_invalid(void *, const char *);
/* in crypt.c */
u32 packet_decrypt_len(SSH_SESSION *session,char *crypted);
int packet_decrypt(SSH_SESSION *session, void *packet,unsigned int len);
unsigned char *packet_encrypt(SSH_SESSION *session,void *packet,unsigned int len);
uint32_t packet_decrypt_len(ssh_session session,char *crypted);
int packet_decrypt(ssh_session session, void *packet,unsigned int len);
unsigned char *packet_encrypt(ssh_session session,void *packet,unsigned int len);
/* it returns the hmac buffer if exists*/
int packet_hmac_verify(SSH_SESSION *session,BUFFER *buffer,unsigned char *mac);
int packet_hmac_verify(ssh_session session,ssh_buffer buffer,unsigned char *mac);
/* in packet.c */
void packet_parse(SSH_SESSION *session);
int packet_send(SSH_SESSION *session);
int packet_read(SSH_SESSION *session);
int packet_translate(SSH_SESSION *session);
int packet_wait(SSH_SESSION *session,int type,int blocking);
int packet_flush(SSH_SESSION *session, int enforce_blocking);
/* connect.c */
SSH_SESSION *ssh_session_new();
socket_t ssh_connect_host(SSH_SESSION *session, const char *host,const char
int ssh_regex_init(void);
void ssh_regex_finalize(void);
ssh_session ssh_session_new(void);
socket_t ssh_connect_host(ssh_session session, const char *host,const char
*bind_addr, int port, long timeout, long usec);
/* in kex.c */
extern char *ssh_kex_nums[];
void ssh_send_kex(SSH_SESSION *session,int server_kex);
void ssh_list_kex(KEX *kex);
int set_kex(SSH_SESSION *session);
int ssh_get_kex(SSH_SESSION *session, int server_kex);
extern const char *ssh_kex_nums[];
int ssh_send_kex(ssh_session session, int server_kex);
void ssh_list_kex(ssh_session session, KEX *kex);
int set_kex(ssh_session session);
int ssh_get_kex(ssh_session session, int server_kex);
int verify_existing_algo(int algo, const char *name);
char **space_tokenize(const char *chain);
int ssh_get_kex1(SSH_SESSION *session);
int ssh_get_kex1(ssh_session session);
char *ssh_find_matching(const char *in_d, const char *what_d);
/* in keyfiles.c */
PRIVATE_KEY *_privatekey_from_file(void *session,char *filename,int type);
/* in keys.c */
char *ssh_type_to_char(int type);
PUBLIC_KEY *publickey_make_dss(SSH_SESSION *session, BUFFER *buffer);
PUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer,char *type);
PUBLIC_KEY *publickey_from_string(SSH_SESSION *session, STRING *pubkey_s);
SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature,PUBLIC_KEY *pubkey,int needed_type);
void signature_free(SIGNATURE *sign);
STRING *ssh_do_sign(SSH_SESSION *session,BUFFER *sigbuf,
PRIVATE_KEY *privatekey);
STRING *ssh_sign_session_id(SSH_SESSION *session, PRIVATE_KEY *privatekey);
STRING *ssh_encrypt_rsa1(SSH_SESSION *session, STRING *data, PUBLIC_KEY *key);
/* channel.c */
void channel_handle(SSH_SESSION *session, int type);
CHANNEL *channel_new(SSH_SESSION *session);
void channel_default_bufferize(CHANNEL *channel, void *data, int len,
int is_stderr);
u32 ssh_channel_new_id(SSH_SESSION *session);
CHANNEL *ssh_channel_from_local(SSH_SESSION *session,u32 num);
/* options.c */
void ssh_options_free(SSH_OPTIONS *opt);
/* this function must be called when no specific username has been asked. it has to guess it */
int ssh_options_default_username(SSH_OPTIONS *opt);
int ssh_options_default_ssh_dir(SSH_OPTIONS *opt);
int ssh_options_default_known_hosts_file(SSH_OPTIONS *opt);
/* buffer.c */
void buffer_add_ssh_string(BUFFER *buffer,STRING *string);
void buffer_add_u8(BUFFER *buffer, u8 data);
void buffer_add_u32(BUFFER *buffer, u32 data);
void buffer_add_u64(BUFFER *buffer,u64 data);
void buffer_add_data(BUFFER *buffer,const void *data, int len);
void buffer_add_data_begin(BUFFER *buffer,const void *data,int len);
void buffer_add_buffer(BUFFER *buffer, BUFFER *source);
void buffer_reinit(BUFFER *buffer);
/* buffer_get_rest returns a pointer to the current position into the buffer */
void *buffer_get_rest(BUFFER *buffer);
/* buffer_get_rest_len returns the number of bytes which can be read */
int buffer_get_rest_len(BUFFER *buffer);
/* buffer_read_*() returns the number of bytes read, except for ssh strings */
int buffer_get_u8(BUFFER *buffer,u8 *data);
int buffer_get_u32(BUFFER *buffer,u32 *data);
int buffer_get_u64(BUFFER *buffer, u64 *data);
int buffer_get_data(BUFFER *buffer,void *data,int requestedlen);
/* buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */
STRING *buffer_get_ssh_string(BUFFER *buffer);
/* gets a string out of a SSH-1 mpint */
STRING *buffer_get_mpint(BUFFER *buffer);
/* buffer_pass_bytes acts as if len bytes have been read (used for padding) */
int buffer_pass_bytes_end(BUFFER *buffer,int len);
int buffer_pass_bytes(BUFFER *buffer, int len);
/* in base64.c */
BUFFER *base64_to_bin(char *source);
unsigned char *bin_to_base64(unsigned char *source, int len);
ssh_buffer base64_to_bin(const char *source);
unsigned char *bin_to_base64(const unsigned char *source, int len);
/* gzip.c */
int compress_buffer(SSH_SESSION *session,BUFFER *buf);
int decompress_buffer(SSH_SESSION *session,BUFFER *buf);
/* wrapper.c */
int crypt_set_algorithms(SSH_SESSION *);
int crypt_set_algorithms_server(SSH_SESSION *session);
CRYPTO *crypto_new();
void crypto_free(CRYPTO *crypto);
int compress_buffer(ssh_session session,ssh_buffer buf);
int decompress_buffer(ssh_session session,ssh_buffer buf, size_t maxlen);
/* crc32.c */
u32 ssh_crc32(char *buffer, int len);
uint32_t ssh_crc32(const char *buf, uint32_t len);
/* auth1.c */
int ssh_userauth1_none(SSH_SESSION *session, char *username);
int ssh_userauth1_offer_pubkey(SSH_SESSION *session, char *username,
int type, STRING *pubkey);
int ssh_userauth1_password(SSH_SESSION *session, char *username,
char *password);
/* in misc.c */
/* gets the user home dir. */
char *ssh_get_user_home_dir();
int ssh_file_readaccess_ok(char *file);
/* macro for byte ordering */
u64 ntohll(u64);
#define htonll(x) ntohll(x)
int ssh_userauth1_none(ssh_session session, const char *username);
int ssh_userauth1_offer_pubkey(ssh_session session, const char *username,
int type, ssh_string pubkey);
int ssh_userauth1_password(ssh_session session, const char *username,
const char *password);
/* channels1.c */
int channel_open_session1(CHANNEL *channel);
int channel_request_pty_size1(CHANNEL *channel, char *terminal,int cols,
int rows);
int channel_change_pty_size1(CHANNEL *channel, int cols, int rows);
int channel_request_shell1(CHANNEL *channel);
int channel_request_exec1(CHANNEL *channel, char *cmd);
void channel_handle1(SSH_SESSION *session,int type);
int channel_write1(CHANNEL *channel, void *data, int len);
int channel_open_session1(ssh_channel channel);
int channel_request_pty_size1(ssh_channel channel, const char *terminal,
int cols, int rows);
int channel_change_pty_size1(ssh_channel channel, int cols, int rows);
int channel_request_shell1(ssh_channel channel);
int channel_request_exec1(ssh_channel channel, const char *cmd);
int channel_handle1(ssh_session session, int type);
int channel_write1(ssh_channel channel, const void *data, int len);
/* session.c */
int ssh_handle_packets(SSH_SESSION *session);
/* match.c */
int match_hostname(const char *host, const char *pattern, unsigned int len);
/* log.c */
/* misc.c */
#ifdef _WIN32
int gettimeofday(struct timeval *__p, void *__t);
#endif /* _WIN32 */
#ifndef __FUNCTION__
#if defined(__SUNPRO_C)
#define __FUNCTION__ __func__
#endif
#endif
#define _enter_function(sess) \
do {\
if((sess)->log_verbosity >= SSH_LOG_FUNCTIONS){ \
@@ -633,8 +251,33 @@ int ssh_handle_packets(SSH_SESSION *session);
}\
} while(0)
#ifdef DEBUG_CALLTRACE
#define enter_function() _enter_function(session)
#define leave_function() _leave_function(session)
#else
#define enter_function() (void)session
#define leave_function() (void)session
#endif
/* options.c */
int ssh_options_set_algo(ssh_session session, int algo, const char *list);
int ssh_options_apply(ssh_session session);
/** Free memory space */
#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
/** Zero a structure */
#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
/** Zero a structure given a pointer to the structure */
#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
/** Get the size of an array */
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
/** Overwrite the complete string with 'X' */
#define BURN_STRING(x) do { if ((x) != NULL) memset((x), 'X', strlen((x))); } while(0)
#ifdef HAVE_LIBGCRYPT
/* gcrypt_missing.c */
@@ -643,7 +286,8 @@ char *my_gcry_bn2dec(bignum bn);
#endif /* !HAVE_LIBGCRYPT */
#ifdef __cplusplus
}
}
#endif
#endif /* _LIBSSH_PRIV_H */
/* vim: set ts=2 sw=2 et cindent: */

56
include/libssh/scp.h Normal file
View File

@@ -0,0 +1,56 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2003-2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef _SCP_H
#define _SCP_H
enum ssh_scp_states {
SSH_SCP_NEW, //Data structure just created
SSH_SCP_WRITE_INITED, //Gave our intention to write
SSH_SCP_WRITE_WRITING,//File was opened and currently writing
SSH_SCP_READ_INITED, //Gave our intention to read
SSH_SCP_READ_REQUESTED, //We got a read request
SSH_SCP_READ_READING, //File is opened and reading
SSH_SCP_ERROR, //Something bad happened
SSH_SCP_TERMINATED //Transfer finished
};
struct ssh_scp_struct {
ssh_session session;
int mode;
int recursive;
ssh_channel channel;
char *location;
enum ssh_scp_states state;
size_t filelen;
size_t processed;
enum ssh_scp_request_types request_type;
char *request_name;
char *warning;
int request_mode;
};
int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len);
int ssh_scp_integer_mode(const char *mode);
char *ssh_scp_string_mode(int mode);
int ssh_scp_response(ssh_scp scp, char **response);
#endif

View File

@@ -1,22 +1,30 @@
/* Public include file for server support */
/*
Copyright 2004 Aris Adamantiadis
* This file is part of the SSH Library
*
* Copyright (c) 2003-2008 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
This file is part of the SSH Library
The SSH Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
The SSH Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
/**
* @defgroup ssh_server SSH Server
* @addtogroup ssh_server
* @{
*/
#ifndef SERVER_H
#define SERVER_H
@@ -24,63 +32,160 @@ MA 02111-1307, USA. */
#include "libssh/libssh.h"
#define SERVERBANNER CLIENTBANNER
typedef struct ssh_bind_struct SSH_BIND;
#ifdef __cplusplus
extern "C" {
#endif
SSH_BIND *ssh_bind_new();
void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options);
int ssh_bind_listen(SSH_BIND *ssh_bind);
void ssh_bind_set_blocking(SSH_BIND *ssh_bind,int blocking);
int ssh_bind_get_fd(SSH_BIND *ssh_bind);
int ssh_bind_set_toaccept(SSH_BIND *ssh_bind);
SSH_SESSION *ssh_bind_accept(SSH_BIND *ssh_bind);
void ssh_bind_free(SSH_BIND *ssh_bind);
int ssh_accept(SSH_SESSION *session);
enum ssh_bind_options_e {
SSH_BIND_OPTIONS_BINDADDR,
SSH_BIND_OPTIONS_BINDPORT,
SSH_BIND_OPTIONS_BINDPORT_STR,
SSH_BIND_OPTIONS_HOSTKEY,
SSH_BIND_OPTIONS_DSAKEY,
SSH_BIND_OPTIONS_RSAKEY,
SSH_BIND_OPTIONS_BANNER,
SSH_BIND_OPTIONS_LOG_VERBOSITY,
SSH_BIND_OPTIONS_LOG_VERBOSITY_STR
};
//typedef struct ssh_bind_struct SSH_BIND;
typedef struct ssh_bind_struct* ssh_bind;
/**
* @brief Creates a new SSH server bind.
*
* @return A newly allocated ssh_bind session pointer.
*/
LIBSSH_API ssh_bind ssh_bind_new(void);
/**
* @brief Set the opitons for the current SSH server bind.
*
* @param sshbind The ssh server bind to use.
*
* @param type The option type to set.
*
* @param value The option value to set.
*
* @return 0 on success, < 0 on error.
*/
LIBSSH_API int ssh_bind_options_set(ssh_bind sshbind,
enum ssh_bind_options_e type, const void *value);
/**
* @brief Start listening to the socket.
*
* @param ssh_bind_o The ssh server bind to use.
*
* @return 0 on success, < 0 on error.
*/
LIBSSH_API int ssh_bind_listen(ssh_bind ssh_bind_o);
/**
* @brief Set the session to blocking/nonblocking mode.
*
* @param ssh_bind_o The ssh server bind to use.
*
* @param blocking Zero for nonblocking mode.
*/
LIBSSH_API void ssh_bind_set_blocking(ssh_bind ssh_bind_o, int blocking);
/**
* @brief Recover the file descriptor from the session.
*
* @param ssh_bind_o The ssh server bind to get the fd from.
*
* @return The file descriptor.
*/
LIBSSH_API socket_t ssh_bind_get_fd(ssh_bind ssh_bind_o);
/**
* @brief Set the file descriptor for a session.
*
* @param ssh_bind_o The ssh server bind to set the fd.
*
* @param fd The file descriptssh_bind B
*/
LIBSSH_API void ssh_bind_set_fd(ssh_bind ssh_bind_o, socket_t fd);
/**
* @brief Allow the file descriptor to accept new sessions.
*
* @param ssh_bind_o The ssh server bind to use.
*/
LIBSSH_API void ssh_bind_fd_toaccept(ssh_bind ssh_bind_o);
/**
* @brief Accept an incoming ssh connection and initialize the session.
*
* @param ssh_bind_o The ssh server bind to accept a connection.
* @param session A preallocated ssh session
* @see ssh_new
* @return A newly allocated ssh session, NULL on error.
*/
LIBSSH_API int ssh_bind_accept(ssh_bind ssh_bind_o, ssh_session session);
/**
* @brief Free a ssh servers bind.
*
* @param ssh_bind_o The ssh server bind to free.
*/
LIBSSH_API void ssh_bind_free(ssh_bind ssh_bind_o);
/**
* @brief Exchange the banner and cryptographic keys.
*
* @param session The ssh session to accept a connection.
*
* @return 0 on success, < 0 on error.
*/
LIBSSH_API int ssh_accept(ssh_session session);
LIBSSH_API int channel_write_stderr(ssh_channel channel, const void *data, uint32_t len);
/* messages.c */
LIBSSH_API int ssh_message_reply_default(ssh_message msg);
#define SSH_AUTH_REQUEST 1
#define SSH_CHANNEL_REQUEST_OPEN 2
#define SSH_CHANNEL_REQUEST 3
LIBSSH_API char *ssh_message_auth_user(ssh_message msg);
LIBSSH_API char *ssh_message_auth_password(ssh_message msg);
LIBSSH_API ssh_public_key ssh_message_auth_publickey(ssh_message msg);
LIBSSH_API int ssh_message_auth_reply_success(ssh_message msg,int partial);
LIBSSH_API int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey);
LIBSSH_API int ssh_message_auth_set_methods(ssh_message msg, int methods);
#define SSH_AUTH_NONE (1<<0)
#define SSH_AUTH_PASSWORD (1<<1)
#define SSH_AUTH_HOSTBASED (1<<2)
#define SSH_AUTH_PUBLICKEY (1<<3)
#define SSH_AUTH_KEYBINT (1<<4)
#define SSH_AUTH_UNKNOWN 0
LIBSSH_API int ssh_message_service_reply_success(ssh_message msg);
LIBSSH_API char *ssh_message_service_service(ssh_message msg);
#define SSH_CHANNEL_SESSION 1
#define SSH_CHANNEL_TCPIP 2
#define SSH_CHANNEL_X11 3
#define SSH_CHANNEL_UNKNOWN 4
LIBSSH_API void ssh_set_message_callback(ssh_session session,
int(*ssh_message_callback)(ssh_session session, ssh_message msg));
#define SSH_CHANNEL_REQUEST_PTY 1
#define SSH_CHANNEL_REQUEST_EXEC 2
#define SSH_CHANNEL_REQUEST_SHELL 3
#define SSH_CHANNEL_REQUEST_ENV 4
#define SSH_CHANNEL_REQUEST_SUBSYSTEM 5
#define SSH_CHANNEL_REQUEST_WINDOW_CHANGE 6
#define SSH_CHANNEL_REQUEST_UNKNOWN 7
LIBSSH_API char *ssh_message_channel_request_open_originator(ssh_message msg);
LIBSSH_API int ssh_message_channel_request_open_originator_port(ssh_message msg);
LIBSSH_API char *ssh_message_channel_request_open_destination(ssh_message msg);
LIBSSH_API int ssh_message_channel_request_open_destination_port(ssh_message msg);
typedef struct ssh_message SSH_MESSAGE;
LIBSSH_API ssh_channel ssh_message_channel_request_channel(ssh_message msg);
SSH_MESSAGE *ssh_message_get(SSH_SESSION *session);
int ssh_message_type(SSH_MESSAGE *msg);
int ssh_message_subtype(SSH_MESSAGE *msg);
int ssh_message_reply_default(SSH_MESSAGE *msg);
void ssh_message_free(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_channel_request_pty_term(ssh_message msg);
LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg);
LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg);
LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg);
LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg);
char *ssh_message_auth_user(SSH_MESSAGE *msg);
char *ssh_message_auth_password(SSH_MESSAGE *msg);
int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial);
void ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
LIBSSH_API char *ssh_message_channel_request_env_name(ssh_message msg);
LIBSSH_API char *ssh_message_channel_request_env_value(ssh_message msg);
CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_channel_request_command(ssh_message msg);
CHANNEL *ssh_message_channel_request_channel(SSH_MESSAGE *msg);
// returns the TERM env variable
char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg);
char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg);
int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg);
LIBSSH_API char *ssh_message_channel_request_subsystem(ssh_message msg);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* SERVER_H */
/**
* @}
*/
/* vim: set ts=2 sw=2 et cindent: */

122
include/libssh/session.h Normal file
View File

@@ -0,0 +1,122 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef SESSION_H_
#define SESSION_H_
#include "libssh/priv.h"
#include "libssh/packet.h"
#include "libssh/pcap.h"
typedef struct ssh_kbdint_struct* ssh_kbdint;
struct ssh_session_struct {
struct error_struct error;
struct socket *socket;
char *serverbanner;
char *clientbanner;
int protoversion;
int server;
int client;
int openssh;
uint32_t send_seq;
uint32_t recv_seq;
/* status flags */
int closed;
int closed_by_except;
int connected;
/* !=0 when the user got a session handle */
int alive;
/* two previous are deprecated */
int auth_service_asked;
/* socket status */
int blocking; // functions should block
ssh_string banner; /* that's the issue banner from
the server */
char *remotebanner; /* that's the SSH- banner from
remote host. */
char *discon_msg; /* disconnect message from
the remote host */
ssh_buffer in_buffer;
PACKET in_packet;
ssh_buffer out_buffer;
/* the states are used by the nonblocking stuff to remember */
/* where it was before being interrupted */
int packet_state;
int dh_handshake_state;
ssh_string dh_server_signature; //information used by dh_handshake.
KEX server_kex;
KEX client_kex;
ssh_buffer in_hashbuf;
ssh_buffer out_hashbuf;
struct ssh_crypto_struct *current_crypto;
struct ssh_crypto_struct *next_crypto; /* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */
ssh_channel channels; /* linked list of channels */
int maxchannel;
int exec_channel_opened; /* version 1 only. more
info in channels1.c */
ssh_agent agent; /* ssh agent */
/* keyb interactive data */
struct ssh_kbdint_struct *kbdint;
int version; /* 1 or 2 */
/* server host keys */
ssh_private_key rsa_key;
ssh_private_key dsa_key;
/* auths accepted by server */
int auth_methods;
int hostkeys; /* contains type of host key wanted by client, in server impl */
struct ssh_list *ssh_message_list; /* list of delayed SSH messages */
int (*ssh_message_callback)( struct ssh_session_struct *session, ssh_message msg);
int log_verbosity; /*cached copy of the option structure */
int log_indent; /* indentation level in enter_function logs */
ssh_callbacks callbacks; /* Callbacks to user functions */
/* options */
#ifdef WITH_PCAP
ssh_pcap_context pcap_ctx; /* pcap debugging context */
#endif
char *username;
char *host;
char *bindaddr; /* bind the client to an ip addr */
char *xbanner; /* TODO: looks like it is not needed */
struct ssh_list *identity;
char *sshdir;
char *knownhosts;
char *wanted_methods[10];
unsigned long timeout; /* seconds */
unsigned long timeout_usec;
unsigned int port;
socket_t fd;
int ssh2;
int ssh1;
char *ProxyCommand;
};
int ssh_handle_packets(ssh_session session);
void ssh_global_request_handle(ssh_session session);
#endif /* SESSION_H_ */

View File

@@ -1,194 +1,792 @@
/* sftp headers */
/*
Copyright 2003-2005 Aris Adamantiadis
* This file is part of the SSH Library
*
* Copyright (c) 2003-2008 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
This file is part of the SSH Library
The SSH Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
The SSH Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
/**
* @file sftp.h
*
* @brief SFTP handling functions
*
* SFTP commands are channeled by the ssh sftp subsystem. Every packet is
* sent/read using a sftp_packet type structure. Related to these packets,
* most of the server answers are messages having an ID and a message
* specific part. It is described by sftp_message when reading a message,
* the sftp system puts it into the queue, so the process having asked for
* it can fetch it, while continuing to read for other messages (it is
* unspecified in which order messages may be sent back to the client
*
* @defgroup ssh_sftp SFTP Functions
* @{
*/
#ifndef SFTP_H
#define SFTP_H
#include <libssh/libssh.h>
#include <sys/types.h>
#include "libssh.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct sftp_session_struct {
SSH_SESSION *session;
CHANNEL *channel;
#ifdef _WIN32
#ifndef uid_t
typedef uint32_t uid_t;
#endif /* uid_t */
#ifndef gid_t
typedef uint32_t gid_t;
#endif /* gid_t */
#ifdef _MSC_VER
#ifndef ssize_t
typedef _W64 SSIZE_T ssize_t;
#endif /* ssize_t */
#endif /* _MSC_VER */
#endif /* _WIN32 */
typedef struct sftp_attributes_struct* sftp_attributes;
typedef struct sftp_client_message_struct* sftp_client_message;
typedef struct sftp_dir_struct* sftp_dir;
typedef struct sftp_ext_struct *sftp_ext;
typedef struct sftp_file_struct* sftp_file;
typedef struct sftp_message_struct* sftp_message;
typedef struct sftp_packet_struct* sftp_packet;
typedef struct sftp_request_queue_struct* sftp_request_queue;
typedef struct sftp_session_struct* sftp_session;
typedef struct sftp_status_message_struct* sftp_status_message;
typedef struct sftp_statvfs_struct* sftp_statvfs_t;
struct sftp_session_struct {
ssh_session session;
ssh_channel channel;
int server_version;
int client_version;
int version;
struct request_queue *queue;
u32 id_counter;
sftp_request_queue queue;
uint32_t id_counter;
int errnum;
void **handles;
} SFTP_SESSION ;
sftp_ext ext;
};
typedef struct {
SFTP_SESSION *sftp;
u8 type;
BUFFER *payload;
} SFTP_PACKET;
struct sftp_packet_struct {
sftp_session sftp;
uint8_t type;
ssh_buffer payload;
};
/* file handler */
typedef struct sftp_file{
SFTP_SESSION *sftp;
struct sftp_file_struct {
sftp_session sftp;
char *name;
u64 offset;
STRING *handle;
uint64_t offset;
ssh_string handle;
int eof;
int nonblocking;
} SFTP_FILE ;
};
typedef struct sftp_dir {
SFTP_SESSION *sftp;
struct sftp_dir_struct {
sftp_session sftp;
char *name;
STRING *handle; /* handle to directory */
BUFFER *buffer; /* contains raw attributes from server which haven't been parsed */
u32 count; /* counts the number of following attributes structures into buffer */
ssh_string handle; /* handle to directory */
ssh_buffer buffer; /* contains raw attributes from server which haven't been parsed */
uint32_t count; /* counts the number of following attributes structures into buffer */
int eof; /* end of directory listing */
} SFTP_DIR;
};
typedef struct {
SFTP_SESSION *sftp;
u8 packet_type;
BUFFER *payload;
u32 id;
} SFTP_MESSAGE;
struct sftp_message_struct {
sftp_session sftp;
uint8_t packet_type;
ssh_buffer payload;
uint32_t id;
};
/* this is a bunch of all data that could be into a message */
typedef struct sftp_client_message{
SFTP_SESSION *sftp;
u8 type;
u32 id;
struct sftp_client_message_struct {
sftp_session sftp;
uint8_t type;
uint32_t id;
char *filename; /* can be "path" */
u32 flags;
struct sftp_attributes *attr;
STRING *handle;
u64 offset;
u32 len;
uint32_t flags;
sftp_attributes attr;
ssh_string handle;
uint64_t offset;
uint32_t len;
int attr_num;
BUFFER *attrbuf; /* used by sftp_reply_attrs */
STRING *data; /* can be newpath of rename() */
} SFTP_CLIENT_MESSAGE;
ssh_buffer attrbuf; /* used by sftp_reply_attrs */
ssh_string data; /* can be newpath of rename() */
};
typedef struct request_queue{
struct request_queue *next;
SFTP_MESSAGE *message;
} REQUEST_QUEUE;
struct sftp_request_queue_struct {
sftp_request_queue next;
sftp_message message;
};
/* SSH_FXP_MESSAGE described into .7 page 26 */
typedef struct {
u32 id;
u32 status;
STRING *error;
STRING *lang;
struct sftp_status_message_struct {
uint32_t id;
uint32_t status;
ssh_string error;
ssh_string lang;
char *errormsg;
char *langmsg;
} STATUS_MESSAGE;
};
/* don't worry much of these aren't really used */
typedef struct sftp_attributes{
struct sftp_attributes_struct {
char *name;
char *longname; /* some weird stuff */
u32 flags;
u8 type;
u64 size;
u32 uid;
u32 gid;
char *owner;
char *group;
u32 permissions;
u64 atime64;
u32 atime;
u32 atime_nseconds;
u64 createtime;
u32 createtime_nseconds;
u64 mtime64;
u32 mtime;
u32 mtime_nseconds;
STRING *acl;
u32 extended_count;
STRING *extended_type;
STRING *extended_data;
} SFTP_ATTRIBUTES;
char *longname; /* ls -l output on openssh, not reliable else */
uint32_t flags;
uint8_t type;
uint64_t size;
uint32_t uid;
uint32_t gid;
char *owner; /* set if openssh and version 4 */
char *group; /* set if openssh and version 4 */
uint32_t permissions;
uint64_t atime64;
uint32_t atime;
uint32_t atime_nseconds;
uint64_t createtime;
uint32_t createtime_nseconds;
uint64_t mtime64;
uint32_t mtime;
uint32_t mtime_nseconds;
ssh_string acl;
uint32_t extended_count;
ssh_string extended_type;
ssh_string extended_data;
};
struct sftp_statvfs_struct {
uint64_t f_bsize; /* file system block size */
uint64_t f_frsize; /* fundamental fs block size */
uint64_t f_blocks; /* number of blocks (unit f_frsize) */
uint64_t f_bfree; /* free blocks in file system */
uint64_t f_bavail; /* free blocks for non-root */
uint64_t f_files; /* total file inodes */
uint64_t f_ffree; /* free file inodes */
uint64_t f_favail; /* free file inodes for to non-root */
uint64_t f_fsid; /* file system id */
uint64_t f_flag; /* bit mask of f_flag values */
uint64_t f_namemax; /* maximum filename length */
};
#define LIBSFTP_VERSION 3
SFTP_SESSION *sftp_new(SSH_SESSION *session);
void sftp_free(SFTP_SESSION *sftp);
int sftp_init(SFTP_SESSION *sftp);
int sftp_get_error(SFTP_SESSION *sftp);
SFTP_DIR *sftp_opendir(SFTP_SESSION *session, const char *path);
/* reads one file and attribute from opened directory. fails at end */
SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *session, SFTP_DIR *dir);
/* returns 1 if the directory was EOF */
int sftp_dir_eof(SFTP_DIR *dir);
SFTP_ATTRIBUTES *sftp_stat(SFTP_SESSION *session, const char *path);
SFTP_ATTRIBUTES *sftp_lstat(SFTP_SESSION *session, const char *path);
/* sftp_lstat stats a file but doesn't follow symlinks */
SFTP_ATTRIBUTES *sftp_fstat(SFTP_FILE *file);
void sftp_attributes_free(SFTP_ATTRIBUTES *file);
int sftp_dir_close(SFTP_DIR *dir);
int sftp_file_close(SFTP_FILE *file);
/* access are the sames than the ones from ansi fopen() */
SFTP_FILE *sftp_open(SFTP_SESSION *session, const char *file, int access, SFTP_ATTRIBUTES *attr);
int sftp_read(SFTP_FILE *file, void *dest, int len);
u32 sftp_async_read_begin(SFTP_FILE *file, int len);
int sftp_async_read(SFTP_FILE *file, void *data, int len, u32 id);
int sftp_write(SFTP_FILE *file, const void *source, int len);
void sftp_seek(SFTP_FILE *file, int new_offset);
void sftp_seek64(SFTP_FILE *file, u64 new_offset);
unsigned long sftp_tell(SFTP_FILE *file);
void sftp_rewind(SFTP_FILE *file);
int sftp_rm(SFTP_SESSION *sftp, char *file);
int sftp_rmdir(SFTP_SESSION *sftp, const char *directory);
int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, SFTP_ATTRIBUTES *attr);
int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname);
int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr);
char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path);
/**
* @brief Start a new sftp session.
*
* @param session The ssh session to use.
*
* @return A new sftp session or NULL on error.
*/
LIBSSH_API sftp_session sftp_new(ssh_session session);
#ifndef NO_SERVER
SFTP_SESSION *sftp_server_new(SSH_SESSION *session, CHANNEL *chan);
int sftp_server_init(SFTP_SESSION *sftp);
#endif
/**
* @brief Close and deallocate a sftp session.
*
* @param sftp The sftp session handle to free.
*/
LIBSSH_API void sftp_free(sftp_session sftp);
/**
* @brief Initialize the sftp session with the server.
*
* @param sftp The sftp session to initialize.
*
* @return 0 on success, < 0 on error with ssh error set.
*/
LIBSSH_API int sftp_init(sftp_session sftp);
/**
* @brief Get the last sftp error.
*
* Use this function to get the latest error set by a posix like sftp function.
*
* @param sftp The sftp session where the error is saved.
*
* @return The saved error (see server responses), < 0 if an error
* in the function occured.
*/
LIBSSH_API int sftp_get_error(sftp_session sftp);
/**
* @brief Get the count of extensions provided by the server.
*
* @param sftp The sftp session to use.
*
* @return The count of extensions provided by the server, 0 on error or
* not available.
*/
LIBSSH_API unsigned int sftp_extensions_get_count(sftp_session sftp);
/**
* @brief Get the name of the extension provided by the server.
*
* @param sftp The sftp session to use.
*
* @param indexn The index number of the extension name you want.
*
* @return The name of the extension.
*/
LIBSSH_API const char *sftp_extensions_get_name(sftp_session sftp, unsigned int indexn);
/**
* @brief Get the data of the extension provided by the server.
*
* This is normally the version number of the extension.
*
* @param sftp The sftp session to use.
*
* @param indexn The index number of the extension data you want.
*
* @return The data of the extension.
*/
LIBSSH_API const char *sftp_extensions_get_data(sftp_session sftp, unsigned int indexn);
/**
* @brief Check if the given extension is supported.
*
* @param sftp The sftp session to use.
*
* @param name The name of the extension.
*
* @param data The data of the extension.
*
* @return 1 if supported, 0 if not.
*
* Example:
*
* @code
* sftp_extension_supported(sftp, "statvfs@openssh.com", "2");
* @endcode
*/
LIBSSH_API int sftp_extension_supported(sftp_session sftp, const char *name,
const char *data);
/**
* @brief Open a directory used to obtain directory entries.
* @param session The sftp session handle to open the directory.
* @param path The path of the directory to open.
*
* @return A sftp directory handle or NULL on error with ssh and
* sftp error set.
*
* @see sftp_readdir
* @see sftp_closedir
*/
LIBSSH_API sftp_dir sftp_opendir(sftp_session session, const char *path);
/**
* @brief Get a single file attributes structure of a directory.
*
* @param session The sftp session handle to read the directory entry.
* @param dir The opened sftp directory handle to read from.
*
* @return A file attribute structure or NULL at the end of the
* directory.
*
* @see sftp_opendir()
* @see sftp_attribute_free()
* @see sftp_closedir()
*/
LIBSSH_API sftp_attributes sftp_readdir(sftp_session session, sftp_dir dir);
/**
* @brief Tell if the directory has reached EOF (End Of File).
*
* @param dir The sftp directory handle.
*
* @return 1 if the directory is EOF, 0 if not.
*
* @see sftp_readdir()
*/
LIBSSH_API int sftp_dir_eof(sftp_dir dir);
/**
* @brief Get information about a file or directory.
*
* @param session The sftp session handle.
* @param path The path to the file or directory to obtain the
* information.
*
* @return The sftp attributes structure of the file or directory,
* NULL on error with ssh and sftp error set.
*/
LIBSSH_API sftp_attributes sftp_stat(sftp_session session, const char *path);
/**
* @brief Get information about a file or directory.
*
* Identical to sftp_stat, but if the file or directory is a symbolic link,
* then the link itself is stated, not the file that it refers to.
*
* @param session The sftp session handle.
* @param path The path to the file or directory to obtain the
* information.
*
* @return The sftp attributes structure of the file or directory,
* NULL on error with ssh and sftp error set.
*/
LIBSSH_API sftp_attributes sftp_lstat(sftp_session session, const char *path);
/**
* @brief Get information about a file or directory from a file handle.
*
* @param file The sftp file handle to get the stat information.
*
* @return The sftp attributes structure of the file or directory,
* NULL on error with ssh and sftp error set.
*/
LIBSSH_API sftp_attributes sftp_fstat(sftp_file file);
/**
* @brief Free a sftp attribute structure.
*
* @param file The sftp attribute structure to free.
*/
LIBSSH_API void sftp_attributes_free(sftp_attributes file);
/**
* @brief Close a directory handle opened by sftp_opendir().
*
* @param dir The sftp directory handle to close.
*
* @return Returns SSH_NO_ERROR or SSH_ERROR if an error occured.
*/
LIBSSH_API int sftp_closedir(sftp_dir dir);
/**
* @brief Close an open file handle.
*
* @param file The open sftp file handle to close.
*
* @return Returns SSH_NO_ERROR or SSH_ERROR if an error occured.
*
* @see sftp_open()
*/
LIBSSH_API int sftp_close(sftp_file file);
/**
* @brief Open a file on the server.
*
* @param session The sftp session handle.
*
* @param file The file to be opened.
*
* @param accesstype Is one of O_RDONLY, O_WRONLY or O_RDWR which request
* opening the file read-only,write-only or read/write.
* Acesss may also be bitwise-or'd with one or more of
* the following:
* O_CREAT - If the file does not exist it will be
* created.
* O_EXCL - When used with O_CREAT, if the file already
* exists it is an error and the open will fail.
* O_TRUNC - If the file already exists it will be
* truncated.
*
* @param mode Mode specifies the permissions to use if a new file is
* created. It is modified by the process's umask in
* the usual way: The permissions of the created file are
* (mode & ~umask)
*
* @return A sftp file handle, NULL on error with ssh and sftp
* error set.
*/
LIBSSH_API sftp_file sftp_open(sftp_session session, const char *file, int accesstype,
mode_t mode);
LIBSSH_API void sftp_file_set_nonblocking(sftp_file handle);
LIBSSH_API void sftp_file_set_blocking(sftp_file handle);
/**
* @brief Read from a file using an opened sftp file handle.
*
* @param file The opened sftp file handle to be read from.
*
* @param buf Pointer to buffer to recieve read data.
*
* @param count Size of the buffer in bytes.
*
* @return Number of bytes written, < 0 on error with ssh and sftp
* error set.
*/
LIBSSH_API ssize_t sftp_read(sftp_file file, void *buf, size_t count);
/**
* @brief Start an asynchronous read from a file using an opened sftp file handle.
*
* Its goal is to avoid the slowdowns related to the request/response pattern
* of a synchronous read. To do so, you must call 2 functions:
*
* sftp_async_read_begin() and sftp_async_read().
*
* The first step is to call sftp_async_read_begin(). This function returns a
* request identifier. The second step is to call sftp_async_read() using the
* returned identifier.
*
* @param file The opened sftp file handle to be read from.
*
* @param len Size to read in bytes.
*
* @return An identifier corresponding to the sent request, < 0 on
* error.
*
* @warning When calling this function, the internal offset is
* updated corresponding to the len parameter.
*
* @warning A call to sftp_async_read_begin() sends a request to
* the server. When the server answers, libssh allocates
* memory to store it until sftp_async_read() is called.
* Not calling sftp_async_read() will lead to memory
* leaks.
*
* @see sftp_async_read()
* @see sftp_open()
*/
LIBSSH_API int sftp_async_read_begin(sftp_file file, uint32_t len);
/**
* @brief Wait for an asynchronous read to complete and save the data.
*
* @param file The opened sftp file handle to be read from.
*
* @param data Pointer to buffer to recieve read data.
*
* @param len Size of the buffer in bytes. It should be bigger or
* equal to the length parameter of the
* sftp_async_read_begin() call.
*
* @param id The identifier returned by the sftp_async_read_begin()
* function.
*
* @return Number of bytes read, 0 on EOF, SSH_ERROR if an error
* occured, SSH_AGAIN if the file is opened in nonblocking
* mode and the request hasn't been executed yet.
*
* @warning A call to this function with an invalid identifier
* will never return.
*
* @see sftp_async_read_begin()
*/
LIBSSH_API int sftp_async_read(sftp_file file, void *data, uint32_t len, uint32_t id);
/**
* @brief Write to a file using an opened sftp file handle.
*
* @param file Open sftp file handle to write to.
*
* @param buf Pointer to buffer to write data.
*
* @param count Size of buffer in bytes.
*
* @return Number of bytes written, < 0 on error with ssh and sftp
* error set.
*
* @see sftp_open()
* @see sftp_read()
* @see sftp_close()
*/
LIBSSH_API ssize_t sftp_write(sftp_file file, const void *buf, size_t count);
/**
* @brief Seek to a specific location in a file.
*
* @param file Open sftp file handle to seek in.
*
* @param new_offset Offset in bytes to seek.
*
* @return 0 on success, < 0 on error.
*/
LIBSSH_API int sftp_seek(sftp_file file, uint32_t new_offset);
/**
* @brief Seek to a specific location in a file. This is the
* 64bit version.
*
* @param file Open sftp file handle to seek in.
*
* @param new_offset Offset in bytes to seek.
*
* @return 0 on success, < 0 on error.
*/
LIBSSH_API int sftp_seek64(sftp_file file, uint64_t new_offset);
/**
* @brief Report current byte position in file.
*
* @param file Open sftp file handle.
*
* @return The offset of the current byte relative to the beginning
* of the file associated with the file descriptor. < 0 on
* error.
*/
LIBSSH_API unsigned long sftp_tell(sftp_file file);
/**
* @brief Report current byte position in file.
*
* @param file Open sftp file handle.
*
* @return The offset of the current byte relative to the beginning
* of the file associated with the file descriptor. < 0 on
* error.
*/
LIBSSH_API uint64_t sftp_tell64(sftp_file file);
/**
* @brief Rewinds the position of the file pointer to the beginning of the
* file.
*
* @param file Open sftp file handle.
*/
LIBSSH_API void sftp_rewind(sftp_file file);
/**
* @brief Unlink (delete) a file.
*
* @param sftp The sftp session handle.
*
* @param file The file to unlink/delete.
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
LIBSSH_API int sftp_unlink(sftp_session sftp, const char *file);
/**
* @brief Remove a directoy.
*
* @param sftp The sftp session handle.
*
* @param directory The directory to remove.
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
LIBSSH_API int sftp_rmdir(sftp_session sftp, const char *directory);
/**
* @brief Create a directory.
*
* @param sftp The sftp session handle.
*
* @param directory The directory to create.
*
* @param mode Specifies the permissions to use. It is modified by the
* process's umask in the usual way:
* The permissions of the created file are (mode & ~umask)
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
LIBSSH_API int sftp_mkdir(sftp_session sftp, const char *directory, mode_t mode);
/**
* @brief Rename or move a file or directory.
*
* @param sftp The sftp session handle.
*
* @param original The original url (source url) of file or directory to
* be moved.
*
* @param newname The new url (destination url) of the file or directory
* after the move.
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
LIBSSH_API int sftp_rename(sftp_session sftp, const char *original, const char *newname);
/**
* @brief Set file attributes on a file, directory or symbolic link.
*
* @param sftp The sftp session handle.
*
* @param file The file which attributes should be changed.
*
* @param attr The file attributes structure with the attributes set
* which should be changed.
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
LIBSSH_API int sftp_setstat(sftp_session sftp, const char *file, sftp_attributes attr);
/**
* @brief Change the file owner and group
*
* @param sftp The sftp session handle.
*
* @param file The file which owner and group should be changed.
*
* @param owner The new owner which should be set.
*
* @param group The new group which should be set.
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
LIBSSH_API int sftp_chown(sftp_session sftp, const char *file, uid_t owner, gid_t group);
/**
* @brief Change permissions of a file
*
* @param sftp The sftp session handle.
*
* @param file The file which owner and group should be changed.
*
* @param mode Specifies the permissions to use. It is modified by the
* process's umask in the usual way:
* The permissions of the created file are (mode & ~umask)
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
LIBSSH_API int sftp_chmod(sftp_session sftp, const char *file, mode_t mode);
/**
* @brief Change the last modification and access time of a file.
*
* @param sftp The sftp session handle.
*
* @param file The file which owner and group should be changed.
*
* @param times A timeval structure which contains the desired access
* and modification time.
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
LIBSSH_API int sftp_utimes(sftp_session sftp, const char *file, const struct timeval *times);
/**
* @brief Create a symbolic link.
*
* @param sftp The sftp session handle.
*
* @param target Specifies the target of the symlink.
*
* @param dest Specifies the path name of the symlink to be created.
*
* @return 0 on success, < 0 on error with ssh and sftp error set.
*/
LIBSSH_API int sftp_symlink(sftp_session sftp, const char *target, const char *dest);
/**
* @brief Read the value of a symbolic link.
*
* @param sftp The sftp session handle.
*
* @param path Specifies the path name of the symlink to be read.
*
* @return The target of the link, NULL on error.
*/
LIBSSH_API char *sftp_readlink(sftp_session sftp, const char *path);
/**
* @brief Get information about a mounted file system.
*
* @param sftp The sftp session handle.
*
* @param path The pathname of any file within the mounted file system.
*
* @return A statvfs structure or NULL on error.
*/
LIBSSH_API sftp_statvfs_t sftp_statvfs(sftp_session sftp, const char *path);
/**
* @brief Get information about a mounted file system.
*
* @param file An opened file.
*
* @return A statvfs structure or NULL on error.
*/
LIBSSH_API sftp_statvfs_t sftp_fstatvfs(sftp_file file);
/**
* @brief Free the memory of an allocated statvfs.
*
* @param statvfs_o The statvfs to free.
*/
LIBSSH_API void sftp_statvfs_free(sftp_statvfs_t statvfs_o);
/**
* @brief Canonicalize a sftp path.
*
* @param sftp The sftp session handle.
*
* @param path The path to be canonicalized.
*
* @return The canonicalize path, NULL on error.
*/
LIBSSH_API char *sftp_canonicalize_path(sftp_session sftp, const char *path);
/**
* @brief Get the version of the SFTP protocol supported by the server
*
* @param sftp The sftp session handle.
*
* @return The server version.
*/
LIBSSH_API int sftp_server_version(sftp_session sftp);
#ifdef WITH_SERVER
/**
* @brief Create a new sftp server session.
*
* @param session The ssh session to use.
*
* @param chan The ssh channel to use.
*
* @return A new sftp server session.
*/
LIBSSH_API sftp_session sftp_server_new(ssh_session session, ssh_channel chan);
/**
* @brief Intialize the sftp server.
*
* @param sftp The sftp session to init.
*
* @return 0 on success, < 0 on error.
*/
LIBSSH_API int sftp_server_init(sftp_session sftp);
#endif /* WITH_SERVER */
/* this is not a public interface */
#define SFTP_HANDLES 256
SFTP_PACKET *sftp_packet_read(SFTP_SESSION *sftp);
int sftp_packet_write(SFTP_SESSION *sftp,u8 type, BUFFER *payload);
void sftp_packet_free(SFTP_PACKET *packet);
void buffer_add_attributes(BUFFER *buffer, SFTP_ATTRIBUTES *attr);
SFTP_ATTRIBUTES *sftp_parse_attr(SFTP_SESSION *session, BUFFER *buf,int expectname);
sftp_packet sftp_packet_read(sftp_session sftp);
int sftp_packet_write(sftp_session sftp,uint8_t type, ssh_buffer payload);
void sftp_packet_free(sftp_packet packet);
int buffer_add_attributes(ssh_buffer buffer, sftp_attributes attr);
sftp_attributes sftp_parse_attr(sftp_session session, ssh_buffer buf,int expectname);
/* sftpserver.c */
SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp);
void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg);
int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, char *name, SFTP_ATTRIBUTES *attr);
int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, STRING *handle);
STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info);
int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr);
void *sftp_handle(SFTP_SESSION *sftp, STRING *handle);
int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, u32 status, char *message);
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, char *file, char *longname,
SFTP_ATTRIBUTES *attr);
int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg);
int sftp_reply_data(SFTP_CLIENT_MESSAGE *msg, void *data, int len);
void sftp_handle_remove(SFTP_SESSION *sftp, void *handle);
sftp_client_message sftp_get_client_message(sftp_session sftp);
void sftp_client_message_free(sftp_client_message msg);
int sftp_reply_name(sftp_client_message msg, const char *name,
sftp_attributes attr);
int sftp_reply_handle(sftp_client_message msg, ssh_string handle);
ssh_string sftp_handle_alloc(sftp_session sftp, void *info);
int sftp_reply_attr(sftp_client_message msg, sftp_attributes attr);
void *sftp_handle(sftp_session sftp, ssh_string handle);
int sftp_reply_status(sftp_client_message msg, uint32_t status, const char *message);
int sftp_reply_names_add(sftp_client_message msg, const char *file,
const char *longname, sftp_attributes attr);
int sftp_reply_names(sftp_client_message msg);
int sftp_reply_data(sftp_client_message msg, const void *data, int len);
void sftp_handle_remove(sftp_session sftp, void *handle);
/* SFTP commands and constants */
#define SSH_FXP_INIT 1
@@ -270,6 +868,11 @@ void sftp_handle_remove(SFTP_SESSION *sftp, void *handle);
#define SSH_FXF_EXCL 0x20
#define SSH_FXF_TEXT 0x40
/* rename flags */
#define SSH_FXF_RENAME_OVERWRITE 0x00000001
#define SSH_FXF_RENAME_ATOMIC 0x00000002
#define SSH_FXF_RENAME_NATIVE 0x00000004
#define SFTP_OPEN SSH_FXP_OPEN
#define SFTP_CLOSE SSH_FXP_CLOSE
#define SFTP_READ SSH_FXP_READ
@@ -289,9 +892,15 @@ void sftp_handle_remove(SFTP_SESSION *sftp, void *handle);
#define SFTP_READLINK SSH_FXP_READLINK
#define SFTP_SYMLINK SSH_FXP_SYMLINK
/* openssh flags */
#define SSH_FXE_STATVFS_ST_RDONLY 0x1 /* read-only */
#define SSH_FXE_STATVFS_ST_NOSUID 0x2 /* no setuid */
#ifdef __cplusplus
} ;
#endif
#endif /* SFTP_H */
/** @} */
/* vim: set ts=2 sw=2 et cindent: */

61
include/libssh/socket.h Normal file
View File

@@ -0,0 +1,61 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef SOCKET_H_
#define SOCKET_H_
/* socket.c */
struct socket;
int ssh_socket_init(void);
struct socket *ssh_socket_new(ssh_session session);
void ssh_socket_free(struct socket *s);
void ssh_socket_set_fd(struct socket *s, socket_t fd);
socket_t ssh_socket_get_fd(struct socket *s);
#ifndef _WIN32
int ssh_socket_unix(struct socket *s, const char *path);
#endif
void ssh_socket_close(struct socket *s);
int ssh_socket_read(struct socket *s, void *buffer, int len);
int ssh_socket_write(struct socket *s,const void *buffer, int len);
int ssh_socket_is_open(struct socket *s);
int ssh_socket_fd_isset(struct socket *s, fd_set *set);
void ssh_socket_fd_set(struct socket *s, fd_set *set, socket_t *max_fd);
int ssh_socket_completeread(struct socket *s, void *buffer, uint32_t len);
int ssh_socket_completewrite(struct socket *s, const void *buffer, uint32_t len);
int ssh_socket_wait_for_data(struct socket *s, ssh_session session, uint32_t len);
int ssh_socket_nonblocking_flush(struct socket *s);
int ssh_socket_blocking_flush(struct socket *s);
int ssh_socket_poll(struct socket *s, int *writeable, int *except);
void ssh_socket_set_towrite(struct socket *s);
void ssh_socket_set_toread(struct socket *s);
void ssh_socket_set_except(struct socket *s);
int ssh_socket_get_status(struct socket *s);
int ssh_socket_data_available(struct socket *s);
int ssh_socket_data_writable(struct socket *s);
#ifndef _WIN32
void ssh_execute_command(const char *command, socket_t in, socket_t out);
socket_t ssh_socket_connect_proxycommand(ssh_session session,
const char *command);
#endif
#endif /* SOCKET_H_ */

42
include/libssh/string.h Normal file
View File

@@ -0,0 +1,42 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef STRING_H_
#define STRING_H_
#include "libssh/priv.h"
/* must be 32 bits number + immediately our data */
#ifdef _MSC_VER
#pragma pack(1)
#endif
struct ssh_string_struct {
uint32_t size;
unsigned char string[MAX_PACKET_LEN];
}
#if !defined(__SUNPRO_C) && !defined(_MSC_VER)
__attribute__ ((packed))
#endif
#ifdef _MSC_VER
#pragma pack()
#endif
;
#endif /* STRING_H_ */

119
include/libssh/wrapper.h Normal file
View File

@@ -0,0 +1,119 @@
/*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef WRAPPER_H_
#define WRAPPER_H_
#include "config.h"
#ifdef MD5_DIGEST_LEN
#undef MD5_DIGEST_LEN
#endif
/* wrapper things */
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
typedef gcry_md_hd_t SHACTX;
typedef gcry_md_hd_t MD5CTX;
typedef gcry_md_hd_t HMACCTX;
#define SHA_DIGEST_LEN 20
#define MD5_DIGEST_LEN 16
#define EVP_MAX_MD_SIZE 36
typedef gcry_mpi_t bignum;
#define bignum_new() gcry_mpi_new(0)
#define bignum_free(num) gcry_mpi_release(num)
#define bignum_set_word(bn,n) gcry_mpi_set_ui(bn,n)
#define bignum_bin2bn(bn,datalen,data) gcry_mpi_scan(data,GCRYMPI_FMT_USG,bn,datalen,NULL)
#define bignum_bn2dec(num) my_gcry_bn2dec(num)
#define bignum_dec2bn(num, data) my_gcry_dec2bn(data, num)
#define bignum_bn2hex(num,data) gcry_mpi_aprint(GCRYMPI_FMT_HEX,data,NULL,num)
#define bignum_hex2bn(num,datalen,data) gcry_mpi_scan(num,GCRYMPI_FMT_HEX,data,datalen,NULL)
#define bignum_rand(num,bits) gcry_mpi_randomize(num,bits,GCRY_STRONG_RANDOM),gcry_mpi_set_bit(num,bits-1),gcry_mpi_set_bit(num,0)
#define bignum_mod_exp(dest,generator,exp,modulo) gcry_mpi_powm(dest,generator,exp,modulo)
#define bignum_num_bits(num) gcry_mpi_get_nbits(num)
#define bignum_num_bytes(num) ((gcry_mpi_get_nbits(num)+7)/8)
#define bignum_is_bit_set(num,bit) gcry_mpi_test_bit(num,bit)
#define bignum_bn2bin(num,datalen,data) gcry_mpi_print(GCRYMPI_FMT_USG,data,datalen,NULL,num)
#define bignum_cmp(num1,num2) gcry_mpi_cmp(num1,num2)
#elif defined HAVE_LIBCRYPTO
#include <openssl/dsa.h>
#include <openssl/rsa.h>
#include <openssl/sha.h>
#include <openssl/md5.h>
#include <openssl/hmac.h>
typedef SHA_CTX* SHACTX;
typedef MD5_CTX* MD5CTX;
typedef HMAC_CTX* HMACCTX;
#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
#define MD5_DIGEST_LEN MD5_DIGEST_LENGTH
#include <openssl/bn.h>
#include <openssl/opensslv.h>
#define OPENSSL_0_9_7b 0x0090702fL
#if (OPENSSL_VERSION_NUMBER <= OPENSSL_0_9_7b)
#define BROKEN_AES_CTR
#endif
typedef BIGNUM* bignum;
typedef BN_CTX* bignum_CTX;
#define bignum_new() BN_new()
#define bignum_free(num) BN_clear_free(num)
#define bignum_set_word(bn,n) BN_set_word(bn,n)
#define bignum_bin2bn(bn,datalen,data) BN_bin2bn(bn,datalen,data)
#define bignum_bn2dec(num) BN_bn2dec(num)
#define bignum_dec2bn(bn,data) BN_dec2bn(data,bn)
#define bignum_bn2hex(num) BN_bn2hex(num)
#define bignum_rand(rnd, bits, top, bottom) BN_rand(rnd,bits,top,bottom)
#define bignum_ctx_new() BN_CTX_new()
#define bignum_ctx_free(num) BN_CTX_free(num)
#define bignum_mod_exp(dest,generator,exp,modulo,ctx) BN_mod_exp(dest,generator,exp,modulo,ctx)
#define bignum_num_bytes(num) BN_num_bytes(num)
#define bignum_num_bits(num) BN_num_bits(num)
#define bignum_is_bit_set(num,bit) BN_is_bit_set(num,bit)
#define bignum_bn2bin(num,ptr) BN_bn2bin(num,ptr)
#define bignum_cmp(num1,num2) BN_cmp(num1,num2)
#endif /* OPENSSL_CRYPTO */
MD5CTX md5_init(void);
void md5_update(MD5CTX c, const void *data, unsigned long len);
void md5_final(unsigned char *md,MD5CTX c);
SHACTX sha1_init(void);
void sha1_update(SHACTX c, const void *data, unsigned long len);
void sha1_final(unsigned char *md,SHACTX c);
void sha1(unsigned char *digest,int len,unsigned char *hash);
#define HMAC_SHA1 1
#define HMAC_MD5 2
HMACCTX hmac_init(const void *key,int len,int type);
void hmac_update(HMACCTX c, const void *data, unsigned long len);
void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
int crypt_set_algorithms(ssh_session );
int crypt_set_algorithms_server(ssh_session session);
struct ssh_crypto_struct *crypto_new(void);
void crypto_free(struct ssh_crypto_struct *crypto);
#endif /* WRAPPER_H_ */

View File

@@ -1,999 +0,0 @@
/*++
Copyright (c) 2000, Microsoft Corporation
Module Name:
wspiapi.h
Abstract:
The file contains protocol independent API functions.
Revision History:
Wed Jul 12 10:50:31 2000, Created
--*/
#ifndef _WSPIAPI_H_
#define _WSPIAPI_H_
#include <stdio.h> // sprintf()
#include <stdlib.h> // calloc(), strtoul()
#include <malloc.h> // calloc()
#include <string.h> // strlen(), strcmp(), strstr()
#define WspiapiMalloc(tSize) calloc(1, (tSize))
#define WspiapiFree(p) free(p)
#define WspiapiSwap(a, b, c) { (c) = (a); (a) = (b); (b) = (c); }
#define getaddrinfo WspiapiGetAddrInfo
#define getnameinfo WspiapiGetNameInfo
#define freeaddrinfo WspiapiFreeAddrInfo
typedef int (WINAPI *WSPIAPI_PGETADDRINFO) (
IN const char *nodename,
IN const char *servname,
IN const struct addrinfo *hints,
OUT struct addrinfo **res);
typedef int (WINAPI *WSPIAPI_PGETNAMEINFO) (
IN const struct sockaddr *sa,
IN socklen_t salen,
OUT char *host,
IN size_t hostlen,
OUT char *serv,
IN size_t servlen,
IN int flags);
typedef void (WINAPI *WSPIAPI_PFREEADDRINFO) (
IN struct addrinfo *ai);
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////////////////////////
// v4 only versions of getaddrinfo and friends.
// NOTE: gai_strerror is inlined in ws2tcpip.h
////////////////////////////////////////////////////////////
__inline
char *
WINAPI
WspiapiStrdup (
IN const char * pszString)
/*++
Routine Description
allocates enough storage via calloc() for a copy of the string,
copies the string into the new memory, and returns a pointer to it.
Arguments
pszString string to copy into new memory
Return Value
a pointer to the newly allocated storage with the string in it.
NULL if enough memory could not be allocated, or string was NULL.
--*/
{
char *pszMemory;
if (!pszString)
return(NULL);
pszMemory = (char *) WspiapiMalloc(strlen(pszString) + 1);
if (!pszMemory)
return(NULL);
return(strcpy(pszMemory, pszString));
}
__inline
BOOL
WINAPI
WspiapiParseV4Address (
IN const char * pszAddress,
OUT PDWORD pdwAddress)
/*++
Routine Description
get the IPv4 address (in network byte order) from its string
representation. the syntax should be a.b.c.d.
Arguments
pszArgument string representation of the IPv4 address
ptAddress pointer to the resulting IPv4 address
Return Value
Returns FALSE if there is an error, TRUE for success.
--*/
{
DWORD dwAddress = 0;
const char *pcNext = NULL;
int iCount = 0;
// ensure there are 3 '.' (periods)
for (pcNext = pszAddress; *pcNext != '\0'; pcNext++)
if (*pcNext == '.')
iCount++;
if (iCount != 3)
return FALSE;
// return an error if dwAddress is INADDR_NONE (255.255.255.255)
// since this is never a valid argument to getaddrinfo.
dwAddress = inet_addr(pszAddress);
if (dwAddress == INADDR_NONE)
return FALSE;
*pdwAddress = dwAddress;
return TRUE;
}
__inline
struct addrinfo *
WINAPI
WspiapiNewAddrInfo (
IN int iSocketType,
IN int iProtocol,
IN WORD wPort,
IN DWORD dwAddress)
/*++
Routine Description
allocate an addrinfo structure and populate fields.
IPv4 specific internal function, not exported.
Arguments
iSocketType SOCK_*. can be wildcarded (zero).
iProtocol IPPROTO_*. can be wildcarded (zero).
wPort port number of service (in network order).
dwAddress IPv4 address (in network order).
Return Value
returns an addrinfo struct, or NULL if out of memory.
--*/
{
struct addrinfo *ptNew;
struct sockaddr_in *ptAddress;
// allocate a new addrinfo structure.
ptNew =
(struct addrinfo *) WspiapiMalloc(sizeof(struct addrinfo));
if (!ptNew)
return NULL;
ptAddress =
(struct sockaddr_in *) WspiapiMalloc(sizeof(struct sockaddr_in));
if (!ptAddress)
{
WspiapiFree(ptNew);
return NULL;
}
ptAddress->sin_family = AF_INET;
ptAddress->sin_port = wPort;
ptAddress->sin_addr.s_addr = dwAddress;
// fill in the fields...
ptNew->ai_family = PF_INET;
ptNew->ai_socktype = iSocketType;
ptNew->ai_protocol = iProtocol;
ptNew->ai_addrlen = sizeof(struct sockaddr_in);
ptNew->ai_addr = (struct sockaddr *) ptAddress;
return ptNew;
}
__inline
int
WINAPI
WspiapiQueryDNS(
IN const char *pszNodeName,
IN int iSocketType,
IN int iProtocol,
IN WORD wPort,
OUT char *pszAlias,
OUT struct addrinfo **pptResult)
/*++
Routine Description
helper routine for WspiapiLookupNode.
performs name resolution by querying the DNS for A records.
*pptResult would need to be freed if an error is returned.
Arguments
pszNodeName name of node to resolve.
iSocketType SOCK_*. can be wildcarded (zero).
iProtocol IPPROTO_*. can be wildcarded (zero).
wPort port number of service (in network order).
pszAlias where to return the alias.
pptResult where to return the result.
Return Value
Returns 0 on success, an EAI_* style error value otherwise.
--*/
{
struct addrinfo **pptNext = pptResult;
struct hostent *ptHost = NULL;
char **ppAddresses;
*pptNext = NULL;
pszAlias[0] = '\0';
ptHost = gethostbyname(pszNodeName);
if (ptHost)
{
if ((ptHost->h_addrtype == AF_INET) &&
(ptHost->h_length == sizeof(struct in_addr)))
{
for (ppAddresses = ptHost->h_addr_list;
*ppAddresses != NULL;
ppAddresses++)
{
// create an addrinfo structure...
*pptNext = WspiapiNewAddrInfo(
iSocketType,
iProtocol,
wPort,
((struct in_addr *) *ppAddresses)->s_addr);
if (!*pptNext)
return EAI_MEMORY;
pptNext = &((*pptNext)->ai_next);
}
}
// pick up the canonical name.
strcpy(pszAlias, ptHost->h_name);
return 0;
}
switch (WSAGetLastError())
{
case WSAHOST_NOT_FOUND: return EAI_NONAME;
case WSATRY_AGAIN: return EAI_AGAIN;
case WSANO_RECOVERY: return EAI_FAIL;
case WSANO_DATA: return EAI_NODATA;
default: return EAI_NONAME;
}
}
__inline
int
WINAPI
WspiapiLookupNode(
IN const char *pszNodeName,
IN int iSocketType,
IN int iProtocol,
IN WORD wPort,
IN BOOL bAI_CANONNAME,
OUT struct addrinfo **pptResult)
/*++
Routine Description
resolve a nodename and return a list of addrinfo structures.
IPv4 specific internal function, not exported.
*pptResult would need to be freed if an error is returned.
NOTE: if bAI_CANONNAME is true, the canonical name should be
returned in the first addrinfo structure.
Arguments
pszNodeName name of node to resolve.
iSocketType SOCK_*. can be wildcarded (zero).
iProtocol IPPROTO_*. can be wildcarded (zero).
wPort port number of service (in network order).
bAI_CANONNAME whether the AI_CANONNAME flag is set.
pptResult where to return result.
Return Value
Returns 0 on success, an EAI_* style error value otherwise.
--*/
{
int iError = 0;
int iAliasCount = 0;
char szFQDN1[NI_MAXHOST] = "";
char szFQDN2[NI_MAXHOST] = "";
char *pszName = szFQDN1;
char *pszAlias = szFQDN2;
char *pszScratch = NULL;
strcpy(pszName, pszNodeName);
for (;;)
{
iError = WspiapiQueryDNS(pszNodeName,
iSocketType,
iProtocol,
wPort,
pszAlias,
pptResult);
if (iError)
break;
// if we found addresses, then we are done.
if (*pptResult)
break;
// stop infinite loops due to DNS misconfiguration. there appears
// to be no particular recommended limit in RFCs 1034 and 1035.
if ((!strlen(pszAlias)) ||
(!strcmp(pszName, pszAlias)) ||
(++iAliasCount == 16))
{
iError = EAI_FAIL;
break;
}
// there was a new CNAME, look again.
WspiapiSwap(pszName, pszAlias, pszScratch);
}
if (!iError && bAI_CANONNAME)
{
(*pptResult)->ai_canonname = WspiapiStrdup(pszAlias);
if (!(*pptResult)->ai_canonname)
iError = EAI_MEMORY;
}
return iError;
}
__inline
int
WINAPI
WspiapiClone (
IN WORD wPort,
IN struct addrinfo *ptResult)
/*++
Routine Description
clone every addrinfo structure in ptResult for the UDP service.
ptResult would need to be freed if an error is returned.
Arguments
wPort port number of UDP service.
ptResult list of addrinfo structures, each
of whose node needs to be cloned.
Return Value
Returns 0 on success, an EAI_MEMORY on allocation failure.
--*/
{
struct addrinfo *ptNext = NULL;
struct addrinfo *ptNew = NULL;
for (ptNext = ptResult; ptNext != NULL; )
{
// create an addrinfo structure...
ptNew = WspiapiNewAddrInfo(
SOCK_DGRAM,
ptNext->ai_protocol,
wPort,
((struct sockaddr_in *) ptNext->ai_addr)->sin_addr.s_addr);
if (!ptNew)
break;
// link the cloned addrinfo
ptNew->ai_next = ptNext->ai_next;
ptNext->ai_next = ptNew;
ptNext = ptNew->ai_next;
}
if (ptNext != NULL)
return EAI_MEMORY;
return 0;
}
__inline
void
WINAPI
WspiapiLegacyFreeAddrInfo (
IN struct addrinfo *ptHead)
/*++
Routine Description
Free an addrinfo structure (or chain of structures).
As specified in RFC 2553, Section 6.4.
Arguments
ptHead structure (chain) to free
--*/
{
struct addrinfo *ptNext; // next strcture to free
for (ptNext = ptHead; ptNext != NULL; ptNext = ptHead)
{
if (ptNext->ai_canonname)
WspiapiFree(ptNext->ai_canonname);
if (ptNext->ai_addr)
WspiapiFree(ptNext->ai_addr);
ptHead = ptNext->ai_next;
WspiapiFree(ptNext);
}
}
__inline
int
WINAPI
WspiapiLegacyGetAddrInfo(
IN const char *pszNodeName,
IN const char *pszServiceName,
IN const struct addrinfo *ptHints,
OUT struct addrinfo **pptResult)
/*++
Routine Description
Protocol-independent name-to-address translation.
As specified in RFC 2553, Section 6.4.
This is the hacked version that only supports IPv4.
Arguments
pszNodeName node name to lookup.
pszServiceName service name to lookup.
ptHints hints about how to process request.
pptResult where to return result.
Return Value
returns zero if successful, an EAI_* error code if not.
--*/
{
int iError = 0;
int iFlags = 0;
int iFamily = PF_UNSPEC;
int iSocketType = 0;
int iProtocol = 0;
WORD wPort = 0;
DWORD dwAddress = 0;
struct servent *ptService = NULL;
char *pc = NULL;
BOOL bClone = FALSE;
WORD wTcpPort = 0;
WORD wUdpPort = 0;
// initialize pptResult with default return value.
*pptResult = NULL;
////////////////////////////////////////
// validate arguments...
//
// both the node name and the service name can't be NULL.
if ((!pszNodeName) && (!pszServiceName))
return EAI_NONAME;
// validate hints.
if (ptHints)
{
// all members other than ai_flags, ai_family, ai_socktype
// and ai_protocol must be zero or a null pointer.
if ((ptHints->ai_addrlen != 0) ||
(ptHints->ai_canonname != NULL) ||
(ptHints->ai_addr != NULL) ||
(ptHints->ai_next != NULL))
{
return EAI_FAIL;
}
// the spec has the "bad flags" error code, so presumably we
// should check something here. insisting that there aren't
// any unspecified flags set would break forward compatibility,
// however. so we just check for non-sensical combinations.
//
// we cannot come up with a canonical name given a null node name.
iFlags = ptHints->ai_flags;
if ((iFlags & AI_CANONNAME) && !pszNodeName)
return EAI_BADFLAGS;
// we only support a limited number of protocol families.
iFamily = ptHints->ai_family;
if ((iFamily != PF_UNSPEC) && (iFamily != PF_INET))
return EAI_FAMILY;
// we only support only these socket types.
iSocketType = ptHints->ai_socktype;
if ((iSocketType != 0) &&
(iSocketType != SOCK_STREAM) &&
(iSocketType != SOCK_DGRAM) &&
(iSocketType != SOCK_RAW))
return EAI_SOCKTYPE;
// REVIEW: What if ai_socktype and ai_protocol are at odds?
iProtocol = ptHints->ai_protocol;
}
////////////////////////////////////////
// do service lookup...
if (pszServiceName)
{
wPort = (WORD) strtoul(pszServiceName, &pc, 10);
if (*pc == '\0') // numeric port string
{
wPort = wTcpPort = wUdpPort = htons(wPort);
if (iSocketType == 0)
{
bClone = TRUE;
iSocketType = SOCK_STREAM;
}
}
else // non numeric port string
{
if ((iSocketType == 0) || (iSocketType == SOCK_DGRAM))
{
ptService = getservbyname(pszServiceName, "udp");
if (ptService)
wPort = wUdpPort = ptService->s_port;
}
if ((iSocketType == 0) || (iSocketType == SOCK_STREAM))
{
ptService = getservbyname(pszServiceName, "tcp");
if (ptService)
wPort = wTcpPort = ptService->s_port;
}
// assumes 0 is an invalid service port...
if (wPort == 0) // no service exists
return (iSocketType ? EAI_SERVICE : EAI_NONAME);
if (iSocketType == 0)
{
// if both tcp and udp, process tcp now & clone udp later.
iSocketType = (wTcpPort) ? SOCK_STREAM : SOCK_DGRAM;
bClone = (wTcpPort && wUdpPort);
}
}
}
////////////////////////////////////////
// do node name lookup...
// if we weren't given a node name,
// return the wildcard or loopback address (depending on AI_PASSIVE).
//
// if we have a numeric host address string,
// return the binary address.
//
if ((!pszNodeName) || (WspiapiParseV4Address(pszNodeName, &dwAddress)))
{
if (!pszNodeName)
{
dwAddress = htonl((iFlags & AI_PASSIVE)
? INADDR_ANY
: INADDR_LOOPBACK);
}
// create an addrinfo structure...
*pptResult =
WspiapiNewAddrInfo(iSocketType, iProtocol, wPort, dwAddress);
if (!(*pptResult))
iError = EAI_MEMORY;
if (!iError && pszNodeName)
{
// implementation specific behavior: set AI_NUMERICHOST
// to indicate that we got a numeric host address string.
(*pptResult)->ai_flags |= AI_NUMERICHOST;
// return the numeric address string as the canonical name
if (iFlags & AI_CANONNAME)
{
(*pptResult)->ai_canonname =
WspiapiStrdup(inet_ntoa(*((struct in_addr *) &dwAddress)));
if (!(*pptResult)->ai_canonname)
iError = EAI_MEMORY;
}
}
}
// if we do not have a numeric host address string and
// AI_NUMERICHOST flag is set, return an error!
else if (iFlags & AI_NUMERICHOST)
{
iError = EAI_NONAME;
}
// since we have a non-numeric node name,
// we have to do a regular node name lookup.
else
{
iError = WspiapiLookupNode(pszNodeName,
iSocketType,
iProtocol,
wPort,
(iFlags & AI_CANONNAME),
pptResult);
}
if (!iError && bClone)
{
iError = WspiapiClone(wUdpPort, *pptResult);
}
if (iError)
{
WspiapiLegacyFreeAddrInfo(*pptResult);
*pptResult = NULL;
}
return (iError);
}
__inline
int
WINAPI
WspiapiLegacyGetNameInfo(
IN const struct sockaddr *ptSocketAddress,
IN socklen_t tSocketLength,
OUT char *pszNodeName,
IN size_t tNodeLength,
OUT char *pszServiceName,
IN size_t tServiceLength,
IN int iFlags)
/*++
Routine Description
protocol-independent address-to-name translation.
as specified in RFC 2553, Section 6.5.
this is the hacked version that only supports IPv4.
Arguments
ptSocketAddress socket address to translate.
tSocketLength length of above socket address.
pszNodeName where to return the node name.
tNodeLength size of above buffer.
pszServiceName where to return the service name.
tServiceLength size of above buffer.
iFlags flags of type NI_*.
Return Value
returns zero if successful, an EAI_* error code if not.
--*/
{
struct servent *ptService;
WORD wPort;
char szBuffer[] = "65535";
char *pszService = szBuffer;
struct hostent *ptHost;
struct in_addr tAddress;
char *pszNode = NULL;
char *pc = NULL;
// sanity check ptSocketAddress and tSocketLength.
if (!ptSocketAddress)
return EAI_FAIL;
if ((ptSocketAddress->sa_family != AF_INET) ||
(tSocketLength != sizeof(struct sockaddr_in)))
{
return EAI_FAMILY;
}
if (!(pszNodeName && tNodeLength) &&
!(pszServiceName && tServiceLength))
{
return EAI_NONAME;
}
// the draft has the "bad flags" error code, so presumably we
// should check something here. insisting that there aren't
// any unspecified flags set would break forward compatibility,
// however. so we just check for non-sensical combinations.
if ((iFlags & NI_NUMERICHOST) && (iFlags & NI_NAMEREQD))
{
return EAI_BADFLAGS;
}
// translate the port to a service name (if requested).
if (pszServiceName && tServiceLength)
{
wPort = ((struct sockaddr_in *) ptSocketAddress)->sin_port;
if (iFlags & NI_NUMERICSERV)
{
// return numeric form of the address.
sprintf(szBuffer, "%u", ntohs(wPort));
}
else
{
// return service name corresponding to port.
ptService = getservbyport(wPort,
(iFlags & NI_DGRAM) ? "udp" : NULL);
if (ptService && ptService->s_name)
{
// lookup successful.
pszService = ptService->s_name;
}
else
{
// DRAFT: return numeric form of the port!
sprintf(szBuffer, "%u", ntohs(wPort));
}
}
if (tServiceLength > strlen(pszService))
strcpy(pszServiceName, pszService);
else
return EAI_FAIL;
}
// translate the address to a node name (if requested).
if (pszNodeName && tNodeLength)
{
// this is the IPv4-only version, so we have an IPv4 address.
tAddress = ((struct sockaddr_in *) ptSocketAddress)->sin_addr;
if (iFlags & NI_NUMERICHOST)
{
// return numeric form of the address.
pszNode = inet_ntoa(tAddress);
}
else
{
// return node name corresponding to address.
ptHost = gethostbyaddr((char *) &tAddress,
sizeof(struct in_addr),
AF_INET);
if (ptHost && ptHost->h_name)
{
// DNS lookup successful.
// stop copying at a "." if NI_NOFQDN is specified.
pszNode = ptHost->h_name;
if ((iFlags & NI_NOFQDN) && (pc = strchr(pszNode, '.')))
*pc = '\0';
}
else
{
// DNS lookup failed. return numeric form of the address.
if (iFlags & NI_NAMEREQD)
{
switch (WSAGetLastError())
{
case WSAHOST_NOT_FOUND: return EAI_NONAME;
case WSATRY_AGAIN: return EAI_AGAIN;
case WSANO_RECOVERY: return EAI_FAIL;
default: return EAI_NONAME;
}
}
else
pszNode = inet_ntoa(tAddress);
}
}
if (tNodeLength > strlen(pszNode))
strcpy(pszNodeName, pszNode);
else
return EAI_FAIL;
}
return 0;
}
typedef struct
{
char const *pszName;
FARPROC pfAddress;
} WSPIAPI_FUNCTION;
#define WSPIAPI_FUNCTION_ARRAY \
{ \
"getaddrinfo", (FARPROC) WspiapiLegacyGetAddrInfo, \
"getnameinfo", (FARPROC) WspiapiLegacyGetNameInfo, \
"freeaddrinfo", (FARPROC) WspiapiLegacyFreeAddrInfo, \
}
__inline
FARPROC
WINAPI
WspiapiLoad(
IN WORD wFunction)
/*++
Routine Description
try to locate the address family independent name resolution routines
(i.e. getaddrinfo, getnameinfo, freeaddrinfo, gai_strerror).
Locks
this function call is not synchronized. hence the library containing
the routines might be loaded multiple times. another option is to
synchronize through a spin lock using a static local variable and the
InterlockedExchange operation.
Arguments
wFunction ordinal # of the function to get the pointer to
0 getaddrinfo
1 getnameinfo
2 freeaddrinfo
Return Value
address of the library/legacy routine
--*/
{
HMODULE hLibrary = NULL;
// these static variables store state across calls, across threads.
static BOOL bInitialized = FALSE;
static WSPIAPI_FUNCTION rgtGlobal[] = WSPIAPI_FUNCTION_ARRAY;
static const int iNumGlobal = (sizeof(rgtGlobal) /
sizeof(WSPIAPI_FUNCTION));
// we overwrite rgtGlobal only if all routines exist in library.
WSPIAPI_FUNCTION rgtLocal[] = WSPIAPI_FUNCTION_ARRAY;
FARPROC fScratch = NULL;
int i = 0;
if (bInitialized) // WspiapiLoad has already been called once
return (rgtGlobal[wFunction].pfAddress);
do // breakout loop
{
// in Whistler and beyond...
// the routines are present in the WinSock 2 library (ws2_32.dll).
// printf("Looking in ws2_32 for getaddrinfo...\n");
hLibrary = LoadLibraryA("ws2_32");
if (hLibrary != NULL)
{
fScratch = GetProcAddress(hLibrary, "getaddrinfo");
if (fScratch == NULL)
{
FreeLibrary(hLibrary);
hLibrary = NULL;
}
}
if (hLibrary != NULL)
break;
// in the IPv6 Technology Preview...
// the routines are present in the IPv6 WinSock library (wship6.dll).
// printf("Looking in wship6 for getaddrinfo...\n");
hLibrary = LoadLibraryA("wship6");
if (hLibrary != NULL)
{
fScratch = GetProcAddress(hLibrary, "getaddrinfo");
if (fScratch == NULL)
{
FreeLibrary(hLibrary);
hLibrary = NULL;
}
}
} while (FALSE);
if (hLibrary != NULL)
{
// use routines from this library...
// since getaddrinfo is here, we expect all routines to be here,
// but will fall back to IPv4-only if any of them is missing.
for (i = 0; i < iNumGlobal; i++)
{
rgtLocal[i].pfAddress
= GetProcAddress(hLibrary, rgtLocal[i].pszName);
if (rgtLocal[i].pfAddress == NULL)
{
FreeLibrary(hLibrary);
hLibrary = NULL;
break;
}
}
if (hLibrary != NULL)
{
// printf("found!\n");
for (i = 0; i < iNumGlobal; i++)
rgtGlobal[i].pfAddress = rgtLocal[i].pfAddress;
}
}
bInitialized = TRUE;
return (rgtGlobal[wFunction].pfAddress);
}
__inline
int
WINAPI
WspiapiGetAddrInfo(
IN const char *nodename,
IN const char *servname,
IN const struct addrinfo *hints,
OUT struct addrinfo **res)
{
static WSPIAPI_PGETADDRINFO pfGetAddrInfo = NULL;
if (!pfGetAddrInfo)
pfGetAddrInfo = (WSPIAPI_PGETADDRINFO) WspiapiLoad(0);
return ((*pfGetAddrInfo)
(nodename, servname, hints, res));
}
__inline
int
WINAPI
WspiapiGetNameInfo (
IN const struct sockaddr *sa,
IN socklen_t salen,
OUT char *host,
IN size_t hostlen,
OUT char *serv,
IN size_t servlen,
IN int flags)
{
static WSPIAPI_PGETNAMEINFO pfGetNameInfo = NULL;
if (!pfGetNameInfo)
pfGetNameInfo = (WSPIAPI_PGETNAMEINFO) WspiapiLoad(1);
return ((*pfGetNameInfo)
(sa, salen, host, hostlen, serv, servlen, flags));
}
__inline
void
WINAPI
WspiapiFreeAddrInfo (
IN struct addrinfo *ai)
{
static WSPIAPI_PFREEADDRINFO pfFreeAddrInfo = NULL;
if (!pfFreeAddrInfo)
pfFreeAddrInfo = (WSPIAPI_PFREEADDRINFO) WspiapiLoad(2);
(*pfFreeAddrInfo)(ai);
}
#ifdef __cplusplus
}
#endif
#endif // _WSPIAPI_H_

15
lib.bat
View File

@@ -1,15 +0,0 @@
@SET VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE
@SET VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio .NET 2003
@SET FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework
@SET FrameworkVersion=v1.1.4322
@SET FrameworkSDKDir=C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1
@set DevEnvDir=%VSINSTALLDIR%
@rem
@rem Root of Visual C++ installed files.
@rem
@set MSVCDir=%VCINSTALLDIR%\VC7
@set PATH=%DevEnvDir%;%MSVCDir%\BIN;%VCINSTALLDIR%\Common7\Tools;%VCINSTALLDIR%\Common7\Tools\bin\prerelease;%VCINSTALLDIR%\Common7\Tools\bin;%FrameworkSDKDir%\bin;%FrameworkDir%\%FrameworkVersion%;%PATH%;
@set INCLUDE=%MSVCDir%\ATLMFC\INCLUDE;%MSVCDir%\INCLUDE;%MSVCDir%\PlatformSDK\include\prerelease;%MSVCDir%\PlatformSDK\include;%FrameworkSDKDir%\include;%INCLUDE%
@set LIB=%MSVCDir%\ATLMFC\LIB;%MSVCDir%\LIB;%MSVCDir%\PlatformSDK\lib\prerelease;%MSVCDir%\PlatformSDK\lib;%FrameworkSDKDir%\lib;%LIB%
"c:\Program files\Microsoft Visual Studio .NET 2003\vc7\bin\lib.exe" /machine:i386 /def:libssh.def

View File

@@ -1,427 +0,0 @@
[Project]
FileName=libssh.dev
Name=libssh
UnitCount=38
Type=1
Ver=1
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
IsCpp=0
Icon=
ExeOutput=
ObjectOutput=
OverrideOutput=0
OverrideOutputName=libssh.exe
HostApplication=
Folders=include
CommandLine=
UseCustomMakefile=1
CustomMakefile=Makefile.Windows
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=0000000000000000000000
[Unit1]
FileName=libssh\init.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit2]
FileName=libssh\kex.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit3]
FileName=libssh\keyfiles.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit4]
FileName=libssh\keys.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit5]
FileName=libssh\messages.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit6]
FileName=libssh\misc.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit7]
FileName=libssh\options.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit8]
FileName=libssh\packet.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit9]
FileName=libssh\server.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit10]
FileName=libssh\session.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit11]
FileName=libssh\sftp.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit12]
FileName=libssh\sftpserver.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit13]
FileName=libssh\socket.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit14]
FileName=libssh\string.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit15]
FileName=libssh\wrapper.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit16]
FileName=libssh\auth1.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit17]
FileName=libssh\auth.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit18]
FileName=libssh\base64.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit19]
FileName=libssh\buffer.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit20]
FileName=libssh\channels1.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit21]
FileName=libssh\channels.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit22]
FileName=libssh\client.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit23]
FileName=libssh\connect.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit24]
FileName=libssh\crc32.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit25]
FileName=libssh\crypt.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit26]
FileName=libssh\dh.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit27]
FileName=libssh\error.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit28]
FileName=libssh\gcrypt_missing.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit29]
FileName=libssh\gzip.c
CompileCpp=0
Folder=libssh
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit30]
FileName=include\libssh\crypto.h
CompileCpp=0
Folder=include
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit31]
FileName=include\libssh\libssh.h
CompileCpp=0
Folder=include
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit32]
FileName=include\libssh\priv.h
CompileCpp=0
Folder=include
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit33]
FileName=include\libssh\server.h
CompileCpp=0
Folder=include
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit34]
FileName=include\libssh\sftp.h
CompileCpp=0
Folder=include
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit35]
FileName=include\libssh\ssh1.h
CompileCpp=0
Folder=include
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit36]
FileName=include\libssh\ssh2.h
CompileCpp=0
Folder=include
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[VersionInfo]
Major=0
Minor=1
Release=1
Build=1
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0
[Unit37]
FileName=lib.bat
Folder=libssh
Compile=0
Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit38]
FileName=Makefile.Windows
Folder=libssh
Compile=0
Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=

200
libssh/CMakeLists.txt Normal file
View File

@@ -0,0 +1,200 @@
project(libssh-library C)
set(LIBSSH_PUBLIC_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}
CACHE INTERNAL "libssh public include directories"
)
set(LIBSSH_PRIVATE_INCLUDE_DIRS
${CMAKE_BINARY_DIR}
${ZLIB_INCLUDE_DIRS}
)
set(LIBSSH_SHARED_LIBRARY
ssh_shared
CACHE INTERNAL "libssh shared library"
)
if (WITH_STATIC_LIB)
set(LIBSSH_STATIC_LIBRARY
ssh_static
CACHE INTERNAL "libssh static library"
)
endif (WITH_STATIC_LIB)
set(LIBSSH_LINK_LIBRARIES
${LIBSSH_REQUIRED_LIBRARIES}
${ZLIB_LIBRARIES}
)
if (WIN32)
set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
ws2_32
)
endif (WIN32)
if (HAVE_LIBSOCKET)
set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
socket
)
endif (HAVE_LIBSOCKET)
if (OPENSSL_LIBRARIES)
set(LIBSSH_PRIVATE_INCLUDE_DIRS
${LIBSSH_PRIVATE_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIRS}
)
set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
${OPENSSL_LIBRARIES}
)
endif (OPENSSL_LIBRARIES)
if (GCRYPT_LIBRARY)
set(LIBSSH_PRIVATE_INCLUDE_DIRS
${LIBSSH_PRIVATE_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIRS}
)
set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
${GCRYPT_LIBRARY}
)
endif (GCRYPT_LIBRARY)
set(libssh_SRCS
agent.c
auth.c
base64.c
buffer.c
callbacks.c
channels.c
client.c
config.c
connect.c
crc32.c
crypt.c
dh.c
error.c
gcrypt_missing.c
gzip.c
init.c
kex.c
keyfiles.c
keys.c
log.c
match.c
messages.c
misc.c
options.c
packet.c
poll.c
session.c
scp.c
socket.c
string.c
wrapper.c
)
if (WITH_PCAP)
set(libssh_SRCS
${libssh_SRCS}
pcap.c
)
endif (WITH_PCAP)
if (WITH_SFTP)
set(libssh_SRCS
${libssh_SRCS}
sftp.c
)
if (WITH_SERVER)
set(libssh_SRCS
${libssh_SRCS}
sftpserver.c
)
endif (WITH_SERVER)
endif (WITH_SFTP)
if (WITH_SSH1)
set(libssh_SRCS
${libssh_SRCS}
auth1.c
channels1.c
)
endif (WITH_SSH1)
if (WITH_SERVER)
set(libssh_SRCS
${libssh_SRCS}
server.c
)
endif (WITH_SERVER)
include_directories(
${LIBSSH_PUBLIC_INCLUDE_DIRS}
${LIBSSH_PRIVATE_INCLUDE_DIRS}
)
add_library(${LIBSSH_SHARED_LIBRARY} SHARED ${libssh_SRCS})
target_link_libraries(${LIBSSH_SHARED_LIBRARY} ${LIBSSH_LINK_LIBRARIES})
set_target_properties(
${LIBSSH_SHARED_LIBRARY}
PROPERTIES
VERSION
${LIBRARY_VERSION}
SOVERSION
${LIBRARY_SOVERSION}
OUTPUT_NAME
ssh
DEFINE_SYMBOL
LIBSSH_EXPORTS
)
if (WITH_VISIBILITY_HIDDEN)
set_target_properties(${LIBSSH_SHARED_LIBRARY} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
endif (WITH_VISIBILITY_HIDDEN)
install(
TARGETS
${LIBSSH_SHARED_LIBRARY}
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
COMPONENT libraries
)
if (WITH_STATIC_LIB)
add_library(${LIBSSH_STATIC_LIBRARY} STATIC ${libssh_SRCS})
set_target_properties(
${LIBSSH_STATIC_LIBRARY}
PROPERTIES
VERSION
${LIBRARY_VERSION}
SOVERSION
${LIBRARY_SOVERSION}
COMPILE_FLAGS
"-DLIBSSH_STATIC"
)
install(
TARGETS
${LIBSSH_STATIC_LIBRARY}
DESTINATION
${LIB_INSTALL_DIR}
COMPONENT
libraries
)
endif (WITH_STATIC_LIB)

View File

@@ -1,14 +0,0 @@
lib_LTLIBRARIES = libssh.la
libssh_la_SOURCES = auth1.c auth.c base64.c buffer.c \
channels1.c channels.c client.c connect.c \
crc32.c crypt.c dh.c error.c gcrypt_missing.c \
gzip.c init.c kex.c keyfiles.c \
keys.c messages.c misc.c options.c \
packet.c server.c session.c sftp.c \
sftpserver.c string.c wrapper.c \
socket.c log.c match.c
libssh_la_CPPFLAGS = -I$(top_srcdir)/include
libssh_la_LDFLAGS = -version-info $(LIBSSH_CURRENT):$(LIBSSH_REVISION):$(LIBSSH_AGE)

502
libssh/agent.c Normal file
View File

@@ -0,0 +1,502 @@
/*
* agent.c - ssh agent functions
*
* This file is part of the SSH Library
*
* Copyright (c) 2008-2009 by Andreas Schneider <mail@cynapses.org>
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
/* This file is based on authfd.c from OpenSSH */
/*
* How does the ssh-agent work?
*
* a) client sends a request to get a list of all keys
* the agent returns the cound and all public keys
* b) iterate over them to check if the server likes one
* c) the client sends a sign request to the agent
* type, pubkey as blob, data to sign, flags
* the agent returns the signed data
*/
#ifndef _WIN32
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#ifndef _WIN32
#include <arpa/inet.h>
#endif
#include "libssh/agent.h"
#include "libssh/priv.h"
#include "libssh/socket.h"
#include "libssh/buffer.h"
#include "libssh/session.h"
#include "libssh/keys.h"
#include "libssh/poll.h"
/* macro to check for "agent failure" message */
#define agent_failed(x) \
(((x) == SSH_AGENT_FAILURE) || ((x) == SSH_COM_AGENT2_FAILURE) || \
((x) == SSH2_AGENT_FAILURE))
static uint32_t agent_get_u32(const void *vp) {
const uint8_t *p = (const uint8_t *)vp;
uint32_t v;
v = (uint32_t)p[0] << 24;
v |= (uint32_t)p[1] << 16;
v |= (uint32_t)p[2] << 8;
v |= (uint32_t)p[3];
return v;
}
static void agent_put_u32(void *vp, uint32_t v) {
uint8_t *p = (uint8_t *)vp;
p[0] = (uint8_t)(v >> 24) & 0xff;
p[1] = (uint8_t)(v >> 16) & 0xff;
p[2] = (uint8_t)(v >> 8) & 0xff;
p[3] = (uint8_t)v & 0xff;
}
static size_t atomicio(struct socket *s, void *buf, size_t n, int do_read) {
char *b = buf;
size_t pos = 0;
ssize_t res;
ssh_pollfd_t pfd;
socket_t fd = ssh_socket_get_fd(s);
pfd.fd = fd;
pfd.events = do_read ? POLLIN : POLLOUT;
while (n > pos) {
if (do_read) {
res = read(fd, b + pos, n - pos);
} else {
res = write(fd, b + pos, n - pos);
}
switch (res) {
case -1:
if (errno == EINTR) {
continue;
}
#ifdef EWOULDBLOCK
if (errno == EAGAIN || errno == EWOULDBLOCK) {
#else
if (errno == EAGAIN) {
#endif
(void) ssh_poll(&pfd, 1, -1);
continue;
}
return 0;
case 0:
errno = EPIPE;
return pos;
default:
pos += (size_t) res;
}
}
return pos;
}
ssh_agent agent_new(struct ssh_session_struct *session) {
ssh_agent agent = NULL;
agent = malloc(sizeof(struct ssh_agent_struct));
if (agent == NULL) {
return NULL;
}
ZERO_STRUCTP(agent);
agent->count = 0;
agent->sock = ssh_socket_new(session);
if (agent->sock == NULL) {
SAFE_FREE(agent);
return NULL;
}
return agent;
}
void agent_close(struct ssh_agent_struct *agent) {
if (agent == NULL) {
return;
}
if (getenv("SSH_AUTH_SOCK")) {
ssh_socket_close(agent->sock);
}
}
void agent_free(ssh_agent agent) {
if (agent) {
if (agent->ident) {
buffer_free(agent->ident);
}
if (agent->sock) {
agent_close(agent);
ssh_socket_free(agent->sock);
}
SAFE_FREE(agent);
}
}
static int agent_connect(ssh_session session) {
const char *auth_sock = NULL;
if (session == NULL || session->agent == NULL) {
return -1;
}
auth_sock = getenv("SSH_AUTH_SOCK");
if (auth_sock && *auth_sock) {
if (ssh_socket_unix(session->agent->sock, auth_sock) < 0) {
return -1;
}
return 0;
}
return -1;
}
#if 0
static int agent_decode_reply(struct ssh_session_struct *session, int type) {
switch (type) {
case SSH_AGENT_FAILURE:
case SSH2_AGENT_FAILURE:
case SSH_COM_AGENT2_FAILURE:
ssh_log(session, SSH_LOG_RARE, "SSH_AGENT_FAILURE");
return 0;
case SSH_AGENT_SUCCESS:
return 1;
default:
ssh_set_error(session, SSH_FATAL,
"Bad response from authentication agent: %d", type);
break;
}
return -1;
}
#endif
static int agent_talk(struct ssh_session_struct *session,
struct ssh_buffer_struct *request, struct ssh_buffer_struct *reply) {
uint32_t len = 0;
uint8_t payload[1024] = {0};
len = buffer_get_len(request);
ssh_log(session, SSH_LOG_PACKET, "agent_talk - len of request: %u", len);
agent_put_u32(payload, len);
/* send length and then the request packet */
if (atomicio(session->agent->sock, payload, 4, 0) == 4) {
if (atomicio(session->agent->sock, buffer_get_rest(request), len, 0)
!= len) {
ssh_log(session, SSH_LOG_PACKET, "atomicio sending request failed: %s",
strerror(errno));
return -1;
}
} else {
ssh_log(session, SSH_LOG_PACKET,
"atomicio sending request length failed: %s",
strerror(errno));
return -1;
}
/* wait for response, read the length of the response packet */
if (atomicio(session->agent->sock, payload, 4, 1) != 4) {
ssh_log(session, SSH_LOG_PACKET, "atomicio read response length failed: %s",
strerror(errno));
return -1;
}
len = agent_get_u32(payload);
if (len > 256 * 1024) {
ssh_set_error(session, SSH_FATAL,
"Authentication response too long: %u", len);
return -1;
}
ssh_log(session, SSH_LOG_PACKET, "agent_talk - response length: %u", len);
while (len > 0) {
size_t n = len;
if (n > sizeof(payload)) {
n = sizeof(payload);
}
if (atomicio(session->agent->sock, payload, n, 1) != n) {
ssh_log(session, SSH_LOG_RARE,
"Error reading response from authentication socket.");
return -1;
}
if (buffer_add_data(reply, payload, n) < 0) {
ssh_log(session, SSH_LOG_FUNCTIONS,
"Not enough space");
return -1;
}
len -= n;
}
return 0;
}
int agent_get_ident_count(struct ssh_session_struct *session) {
ssh_buffer request = NULL;
ssh_buffer reply = NULL;
unsigned int type = 0;
unsigned int c1 = 0, c2 = 0;
uint8_t buf[4] = {0};
switch (session->version) {
case 1:
c1 = SSH_AGENTC_REQUEST_RSA_IDENTITIES;
c2 = SSH_AGENT_RSA_IDENTITIES_ANSWER;
break;
case 2:
c1 = SSH2_AGENTC_REQUEST_IDENTITIES;
c2 = SSH2_AGENT_IDENTITIES_ANSWER;
break;
default:
return 0;
}
/* send message to the agent requesting the list of identities */
request = buffer_new();
if (buffer_add_u8(request, c1) < 0) {
ssh_set_error(session, SSH_FATAL, "Not enough space");
return -1;
}
reply = buffer_new();
if (reply == NULL) {
ssh_set_error(session, SSH_FATAL, "Not enough space");
return -1;
}
if (agent_talk(session, request, reply) < 0) {
buffer_free(request);
return 0;
}
buffer_free(request);
/* get message type and verify the answer */
buffer_get_u8(reply, (uint8_t *) &type);
ssh_log(session, SSH_LOG_PACKET,
"agent_ident_count - answer type: %d, expected answer: %d",
type, c2);
if (agent_failed(type)) {
return 0;
} else if (type != c2) {
ssh_set_error(session, SSH_FATAL,
"Bad authentication reply message type: %d", type);
return -1;
}
buffer_get_u32(reply, (uint32_t *) buf);
session->agent->count = agent_get_u32(buf);
ssh_log(session, SSH_LOG_PACKET, "agent_ident_count - count: %d",
session->agent->count);
if (session->agent->count > 1024) {
ssh_set_error(session, SSH_FATAL,
"Too many identities in authentication reply: %d",
session->agent->count);
buffer_free(reply);
return -1;
}
if (session->agent->ident) {
buffer_reinit(session->agent->ident);
}
session->agent->ident = reply;
return session->agent->count;
}
/* caller has to free commment */
struct ssh_public_key_struct *agent_get_first_ident(struct ssh_session_struct *session,
char **comment) {
if (agent_get_ident_count(session) > 0) {
return agent_get_next_ident(session, comment);
}
return NULL;
}
/* caller has to free commment */
struct ssh_public_key_struct *agent_get_next_ident(struct ssh_session_struct *session,
char **comment) {
struct ssh_public_key_struct *pubkey = NULL;
struct ssh_string_struct *blob = NULL;
struct ssh_string_struct *tmp = NULL;
if (session->agent->count == 0) {
return NULL;
}
switch(session->version) {
case 1:
return NULL;
case 2:
/* get the blob */
blob = buffer_get_ssh_string(session->agent->ident);
if (blob == NULL) {
return NULL;
}
/* get the comment */
tmp = buffer_get_ssh_string(session->agent->ident);
if (tmp == NULL) {
string_free(blob);
return NULL;
}
if (comment) {
*comment = string_to_char(tmp);
} else {
string_free(blob);
string_free(tmp);
return NULL;
}
string_free(tmp);
/* get key from blob */
pubkey = publickey_from_string(session, blob);
string_free(blob);
break;
default:
return NULL;
}
return pubkey;
}
ssh_string agent_sign_data(struct ssh_session_struct *session,
struct ssh_buffer_struct *data,
struct ssh_public_key_struct *pubkey) {
struct ssh_string_struct *blob = NULL;
struct ssh_string_struct *sig = NULL;
struct ssh_buffer_struct *request = NULL;
struct ssh_buffer_struct *reply = NULL;
int type = SSH2_AGENT_FAILURE;
int flags = 0;
uint32_t dlen = 0;
/* create blob from the pubkey */
blob = publickey_to_string(pubkey);
request = buffer_new();
if (request == NULL) {
goto error;
}
/* create request */
if (buffer_add_u8(request, SSH2_AGENTC_SIGN_REQUEST) < 0) {
goto error;
}
/* adds len + blob */
if (buffer_add_ssh_string(request, blob) < 0) {
goto error;
}
/* Add data */
dlen = buffer_get_len(data);
if (buffer_add_u32(request, htonl(dlen)) < 0) {
goto error;
}
if (buffer_add_data(request, buffer_get(data), dlen) < 0) {
goto error;
}
if (buffer_add_u32(request, htonl(flags)) < 0) {
goto error;
}
string_free(blob);
reply = buffer_new();
if (reply == NULL) {
goto error;
}
/* send the request */
if (agent_talk(session, request, reply) < 0) {
buffer_free(request);
return NULL;
}
buffer_free(request);
/* check if reply is valid */
if (buffer_get_u8(reply, (uint8_t *) &type) != sizeof(uint8_t)) {
goto error;
}
if (agent_failed(type)) {
ssh_log(session, SSH_LOG_RARE, "Agent reports failure in signing the key");
buffer_free(reply);
return NULL;
} else if (type != SSH2_AGENT_SIGN_RESPONSE) {
ssh_set_error(session, SSH_FATAL, "Bad authentication response: %d", type);
buffer_free(reply);
return NULL;
}
sig = buffer_get_ssh_string(reply);
buffer_free(reply);
return sig;
error:
ssh_set_error(session, SSH_FATAL, "Not enough memory");
string_free(blob);
buffer_free(request);
buffer_free(reply);
return NULL;
}
int agent_is_running(ssh_session session) {
if (session == NULL || session->agent == NULL) {
return 0;
}
if (ssh_socket_is_open(session->agent->sock)) {
return 1;
} else {
if (agent_connect(session) < 0) {
return 0;
} else {
return 1;
}
}
return 0;
}
#endif /* _WIN32 */
/* vim: set ts=2 sw=2 et cindent: */

File diff suppressed because it is too large Load Diff

View File

@@ -1,85 +1,112 @@
/* auth1.c deals with authentication with SSH-1 protocol */
/*
Copyright (c) 2005-2008 Aris Adamantiadis
* auth1.c - authentication with SSH-1 protocol
*
* This file is part of the SSH Library
*
* Copyright (c) 2005-2008 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
This file is part of the SSH Library
#include "config.h"
The SSH Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
The SSH Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include "libssh/priv.h"
#include "libssh/ssh1.h"
#include <string.h>
#include <stdlib.h>
/*
static void burn(char *ptr){
if(ptr)
memset(ptr,'X',strlen(ptr));
}
*/
#ifdef HAVE_SSH1
static int wait_auth1_status(SSH_SESSION *session){
/* wait for a packet */
if(packet_read(session))
return SSH_AUTH_ERROR;
if(packet_translate(session))
return SSH_AUTH_ERROR;
switch(session->in_packet.type){
case SSH_SMSG_SUCCESS:
return SSH_AUTH_SUCCESS;
case SSH_SMSG_FAILURE:
return SSH_AUTH_DENIED;
}
ssh_set_error(session,SSH_FATAL,"Was waiting for a SUCCESS or "
"FAILURE, got %d",session->in_packet.type);
#include "libssh/priv.h"
#include "libssh/ssh1.h"
#include "libssh/buffer.h"
#include "libssh/packet.h"
#include "libssh/session.h"
#include "libssh/string.h"
#ifdef WITH_SSH1
static int wait_auth1_status(ssh_session session) {
/* wait for a packet */
if (packet_read(session) != SSH_OK) {
return SSH_AUTH_ERROR;
}
if(packet_translate(session) != SSH_OK) {
return SSH_AUTH_ERROR;
}
switch(session->in_packet.type) {
case SSH_SMSG_SUCCESS:
return SSH_AUTH_SUCCESS;
case SSH_SMSG_FAILURE:
return SSH_AUTH_DENIED;
}
ssh_set_error(session, SSH_FATAL, "Was waiting for a SUCCESS or "
"FAILURE, got %d", session->in_packet.type);
return SSH_AUTH_ERROR;
}
static int send_username(SSH_SESSION *session, char *username){
STRING *user;
/* returns SSH_AUTH_SUCCESS or SSH_AUTH_DENIED */
if(session->auth_service_asked)
return session->auth_service_asked;
buffer_add_u8(session->out_buffer,SSH_CMSG_USER);
if(!username)
if(!(username=session->options->username)){
if(ssh_options_default_username(session->options))
return session->auth_service_asked=SSH_AUTH_ERROR;
else
username=session->options->username;
}
user=string_from_char(username);
buffer_add_ssh_string(session->out_buffer,user);
free(user);
packet_send(session);
session->auth_service_asked=wait_auth1_status(session);
static int send_username(ssh_session session, const char *username) {
ssh_string user = NULL;
/* returns SSH_AUTH_SUCCESS or SSH_AUTH_DENIED */
if(session->auth_service_asked) {
return session->auth_service_asked;
}
if (!username) {
if(!(username = session->username)) {
if (ssh_options_set(session, SSH_OPTIONS_USER, NULL) < 0) {
return session->auth_service_asked = SSH_AUTH_ERROR;
} else {
username = session->username;
}
}
}
user = string_from_char(username);
if (user == NULL) {
return SSH_AUTH_ERROR;
}
if (buffer_add_u8(session->out_buffer, SSH_CMSG_USER) < 0) {
string_free(user);
return SSH_AUTH_ERROR;
}
if (buffer_add_ssh_string(session->out_buffer, user) < 0) {
string_free(user);
return SSH_AUTH_ERROR;
}
string_free(user);
if (packet_send(session) != SSH_OK) {
return SSH_AUTH_ERROR;
}
session->auth_service_asked = wait_auth1_status(session);
return session->auth_service_asked;
}
/* use the "none" authentication question */
int ssh_userauth1_none(SSH_SESSION *session,char *username){
return send_username(session,username);
int ssh_userauth1_none(ssh_session session, const char *username){
return send_username(session, username);
}
/*
int ssh_userauth_offer_pubkey(SSH_SESSION *session, char *username,int type, STRING *publickey){
STRING *user;
STRING *service;
STRING *method;
STRING *algo;
int ssh_userauth_offer_pubkey(ssh_session session, char *username,int type, ssh_string publickey){
ssh_string user;
ssh_string service;
ssh_string method;
ssh_string algo;
int err=SSH_AUTH_ERROR;
if(!username)
if(!(username=session->options->username)){
@@ -115,18 +142,22 @@ int ssh_userauth_offer_pubkey(SSH_SESSION *session, char *username,int type, STR
/** \internal
* \todo implement ssh1 public key
*/
int ssh_userauth1_offer_pubkey(SSH_SESSION *session, char *username, int type,
STRING *pubkey){
return SSH_AUTH_DENIED;
int ssh_userauth1_offer_pubkey(ssh_session session, const char *username,
int type, ssh_string pubkey) {
(void) session;
(void) username;
(void) type;
(void) pubkey;
return SSH_AUTH_DENIED;
}
/*
int ssh_userauth_pubkey(SSH_SESSION *session, char *username, STRING *publickey, PRIVATE_KEY *privatekey){
STRING *user;
STRING *service;
STRING *method;
STRING *algo;
STRING *sign;
int ssh_userauth_pubkey(ssh_session session, char *username, ssh_string publickey, ssh_private_key privatekey){
ssh_string user;
ssh_string service;
ssh_string method;
ssh_string algo;
ssh_string sign;
int err=SSH_AUTH_ERROR;
if(!username)
if(!(username=session->options->username)){
@@ -167,39 +198,64 @@ int ssh_userauth_pubkey(SSH_SESSION *session, char *username, STRING *publickey,
}
*/
int ssh_userauth1_password(SSH_SESSION *session,char *username,char *password){
STRING *password_s;
int err;
err=send_username(session,username);
if(err!=SSH_AUTH_DENIED)
return err;
/* we trick a bit here. A known flaw in SSH1 protocol is that it's
* easy to guess password sizes.
* not that sure ...
*/
/* XXX fix me here ! */
/* cisco IOS doesn't like when a password is followed by zeroes and random pad. */
if(strlen(password)>=0){
/* not risky to disclose the size of such a big password .. */
password_s=string_from_char(password);
} else {
/* fill the password string from random things. the strcpy
* ensure there is at least a nul byte after the password.
* most implementation won't see the garbage at end.
* why garbage ? because nul bytes will be compressed by
* gzip and disclose password len.
*/
password_s=string_new(128);
ssh_get_random(password_s->string,128,0);
strcpy((char *)password_s->string,password);
}
int ssh_userauth1_password(ssh_session session, const char *username,
const char *password) {
ssh_string pwd = NULL;
int rc;
buffer_add_u8(session->out_buffer,SSH_CMSG_AUTH_PASSWORD);
buffer_add_ssh_string(session->out_buffer,password_s);
string_burn(password_s);
free(password_s);
packet_send(session);
return wait_auth1_status(session);
rc = send_username(session, username);
if (rc != SSH_AUTH_DENIED) {
return rc;
}
/* we trick a bit here. A known flaw in SSH1 protocol is that it's
* easy to guess password sizes.
* not that sure ...
*/
/* XXX fix me here ! */
/* cisco IOS doesn't like when a password is followed by zeroes and random pad. */
if(1 || strlen(password) >= 128) {
/* not risky to disclose the size of such a big password .. */
pwd = string_from_char(password);
if (pwd == NULL) {
return SSH_AUTH_ERROR;
}
} else {
/* fill the password string from random things. the strcpy
* ensure there is at least a nul byte after the password.
* most implementation won't see the garbage at end.
* why garbage ? because nul bytes will be compressed by
* gzip and disclose password len.
*/
pwd = string_new(128);
if (pwd == NULL) {
return SSH_AUTH_ERROR;
}
ssh_get_random( pwd->string, 128, 0);
strcpy((char *) pwd->string, password);
}
if (buffer_add_u8(session->out_buffer, SSH_CMSG_AUTH_PASSWORD) < 0) {
string_burn(pwd);
string_free(pwd);
return SSH_AUTH_ERROR;
}
if (buffer_add_ssh_string(session->out_buffer, pwd) < 0) {
string_burn(pwd);
string_free(pwd);
return SSH_AUTH_ERROR;
}
string_burn(pwd);
string_free(pwd);
if (packet_send(session) != SSH_OK) {
return SSH_AUTH_ERROR;
}
return wait_auth1_status(session);
}
#endif /* HAVE_SSH1 */
#endif /* WITH_SSH1 */
/* vim: set ts=2 sw=2 et cindent: */

View File

@@ -1,217 +1,287 @@
/* base64 contains the needed support for base64 alphabet system, */
/* as described in RFC1521 */
/*
Copyright 2003-2005 Aris Adamantiadis
This file is part of the SSH Library
The SSH Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
The SSH Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
* base64.c - support for base64 alphabet system, described in RFC1521
*
* This file is part of the SSH Library
*
* Copyright (c) 2005-2005 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
/* just the dirtiest part of code i ever made */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "libssh/priv.h"
static char alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/" ;
#include "libssh/buffer.h"
/* transformations */
#define SET_A(n,i) do { n |= (i&63) <<18; } while (0)
#define SET_B(n,i) do { n |= (i&63) <<12; } while (0)
#define SET_C(n,i) do { n |= (i&63) << 6; } while (0)
#define SET_D(n,i) do { n |= (i&63); } while (0)
static char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
#define GET_A(n) ((n & 0xff0000) >> 16)
#define GET_B(n) ((n & 0xff00) >> 8)
#define GET_C(n) (n & 0xff)
/* Transformations */
#define SET_A(n, i) do { (n) |= ((i) & 63) <<18; } while (0)
#define SET_B(n, i) do { (n) |= ((i) & 63) <<12; } while (0)
#define SET_C(n, i) do { (n) |= ((i) & 63) << 6; } while (0)
#define SET_D(n, i) do { (n) |= ((i) & 63); } while (0)
static int _base64_to_bin(unsigned char dest[3], char *source,int num);
#define GET_A(n) (((n) & 0xff0000) >> 16)
#define GET_B(n) (((n) & 0xff00) >> 8)
#define GET_C(n) ((n) & 0xff)
static int _base64_to_bin(unsigned char dest[3], const char *source, int num);
static int get_equals(char *string);
/* first part : base 64 to binary */
/* First part: base64 to binary */
/** \brief base64_to_bin translates a base64 string into a binary one. important,
* \returns NULL if something went wrong (ie incorrect char)
* \returns BUFFER containing the decoded string
* \internal
/**
* @internal
*
* @brief Translates a base64 string into a binary one.
*
* @returns A buffer containing the decoded string, NULL if something went
* wrong (e.g. incorrect char).
*/
ssh_buffer base64_to_bin(const char *source) {
ssh_buffer buffer = NULL;
unsigned char block[3];
char *base64;
char *ptr;
size_t len;
int equals;
BUFFER *base64_to_bin(char *source){
int len;
int equals;
BUFFER *buffer=buffer_new();
unsigned char block[3];
base64 = strdup(source);
if (base64 == NULL) {
return NULL;
}
ptr = base64;
/* get the number of equals signs, which mirrors the padding */
equals=get_equals(source);
if(equals>2){
buffer_free(buffer);
return NULL;
/* Get the number of equals signs, which mirrors the padding */
equals = get_equals(ptr);
if (equals > 2) {
SAFE_FREE(base64);
return NULL;
}
buffer = buffer_new();
if (buffer == NULL) {
SAFE_FREE(base64);
return NULL;
}
len = strlen(ptr);
while (len > 4) {
if (_base64_to_bin(block, ptr, 3) < 0) {
goto error;
}
len=strlen(source);
while(len>4){
if(_base64_to_bin(block,source,3)){
buffer_free(buffer);
return NULL;
}
buffer_add_data(buffer,block,3);
len-=4;
source+=4;
if (buffer_add_data(buffer, block, 3) < 0) {
goto error;
}
/* depending of the number of bytes resting, there are 3 possibilities (from the rfc) */
switch(len){
/* (1) the final quantum of encoding input is an integral
multiple of 24 bits; here, the final unit of encoded output will be
an integral multiple of 4 characters with no "=" padding */
case 4:
if(equals!=0){
buffer_free(buffer);
return NULL;
}
if(_base64_to_bin(block,source,3)){
buffer_free(buffer);
return NULL;
}
buffer_add_data(buffer,block,3);
return buffer;
/*(2) the final quantum of encoding input is exactly 8 bits; here, the final
unit of encoded output will be two characters followed by two "="
padding characters */
case 2:
if(equals!=2){
buffer_free(buffer);
return NULL;
}
if(_base64_to_bin(block,source,1)){
buffer_free(buffer);
return NULL;
}
buffer_add_data(buffer,block,1);
return buffer;
/* the final quantum of encoding input is
exactly 16 bits; here, the final unit of encoded output will be three
characters followed by one "=" padding character */
case 3:
if(equals!=1){
buffer_free(buffer);
return NULL;
}
if(_base64_to_bin(block,source,2)){
buffer_free(buffer);
return NULL;
}
buffer_add_data(buffer,block,2);
return buffer;
default:
/* 4,3,2 are the only padding size allowed */
buffer_free(buffer);
return NULL;
}
return NULL;
len -= 4;
ptr += 4;
}
/*
* Depending on the number of bytes resting, there are 3 possibilities
* from the RFC.
*/
switch (len) {
/*
* (1) The final quantum of encoding input is an integral multiple of
* 24 bits. Here, the final unit of encoded output will be an integral
* multiple of 4 characters with no "=" padding
*/
case 4:
if (equals != 0) {
goto error;
}
if (_base64_to_bin(block, ptr, 3) < 0) {
goto error;
}
if (buffer_add_data(buffer, block, 3) < 0) {
goto error;
}
SAFE_FREE(base64);
return buffer;
/*
* (2) The final quantum of encoding input is exactly 8 bits; here, the
* final unit of encoded output will be two characters followed by
* two "=" padding characters.
*/
case 2:
if (equals != 2){
goto error;
}
if (_base64_to_bin(block, ptr, 1) < 0) {
goto error;
}
if (buffer_add_data(buffer, block, 1) < 0) {
goto error;
}
SAFE_FREE(base64);
return buffer;
/*
* The final quantum of encoding input is exactly 16 bits. Here, the final
* unit of encoded output will be three characters followed by one "="
* padding character.
*/
case 3:
if (equals != 1) {
goto error;
}
if (_base64_to_bin(block, ptr, 2) < 0) {
goto error;
}
if (buffer_add_data(buffer,block,2) < 0) {
goto error;
}
SAFE_FREE(base64);
return buffer;
default:
/* 4,3,2 are the only padding size allowed */
goto error;
}
error:
SAFE_FREE(base64);
buffer_free(buffer);
return NULL;
}
#define BLOCK(letter,n) do { ptr=strchr(alphabet,source[n]);\
if(!ptr) return -1;\
i=ptr-alphabet;\
SET_##letter(*block,i);\
} while(0)
/* returns 0 if ok, -1 if not (ie invalid char into the stuff) */
static int to_block4(unsigned long *block, char *source,int num){
char *ptr;
unsigned int i;
*block=0;
if(num<1)
return 0;
BLOCK(A,0); /* 6 bits */
BLOCK(B,1); /* 12 */
if(num<2)
return 0;
BLOCK(C,2); /* 18 */
if(num < 3)
return 0;
BLOCK(D,3); /* 24 */
#define BLOCK(letter, n) do {ptr = strchr(alphabet, source[n]); \
if(!ptr) return -1; \
i = ptr - alphabet; \
SET_##letter(*block, i); \
} while(0)
/* Returns 0 if ok, -1 if not (ie invalid char into the stuff) */
static int to_block4(unsigned long *block, const char *source, int num) {
char *ptr;
unsigned int i;
*block = 0;
if (num < 1) {
return 0;
}
BLOCK(A, 0); /* 6 bit */
BLOCK(B,1); /* 12 bit */
if (num < 2) {
return 0;
}
BLOCK(C, 2); /* 18 bit */
if (num < 3) {
return 0;
}
BLOCK(D, 3); /* 24 bit */
return 0;
}
/* num = numbers of final bytes to be decoded */
static int _base64_to_bin(unsigned char dest[3], char *source,int num){
unsigned long block;
if(to_block4(&block,source,num))
return -1;
dest[0]=GET_A(block);
dest[1]=GET_B(block);
dest[2]=GET_C(block);
return 0;
static int _base64_to_bin(unsigned char dest[3], const char *source, int num) {
unsigned long block;
if (to_block4(&block, source, num) < 0) {
return -1;
}
dest[0] = GET_A(block);
dest[1] = GET_B(block);
dest[2] = GET_C(block);
return 0;
}
/* counts the number of "=" signs, and replace them by zeroes */
static int get_equals(char *string){
char *ptr=string;
int num=0;
while((ptr=strchr(ptr,'='))){
num++;
*ptr=0;
ptr++;
}
/* Count the number of "=" signs and replace them by zeroes */
static int get_equals(char *string) {
char *ptr = string;
int num = 0;
return num;
while ((ptr=strchr(ptr,'=')) != NULL) {
num++;
*ptr = '\0';
ptr++;
}
return num;
}
/* thanks sysk for debugging my mess :) */
#define BITS(n) ((1<<n)-1)
static void _bin_to_base64(unsigned char *dest, unsigned char source[3], int len){
switch (len){
case 1:
dest[0]=alphabet[(source[0]>>2)];
dest[1]=alphabet[((source[0] & BITS(2)) << 4)];
dest[2]='=';
dest[3]='=';
break;
case 2:
dest[0]=alphabet[source[0]>>2];
dest[1]=alphabet[(source[1]>>4) | ((source[0] & BITS(2)) << 4)];
dest[2]=alphabet[(source[1]&BITS(4)) << 2];
dest[3]='=';
break;
case 3:
dest[0]=alphabet[(source[0]>>2)];
dest[1]=alphabet[(source[1]>>4) | ((source[0] & BITS(2)) << 4)];
dest[2]=alphabet[ (source[2] >> 6) | (source[1]&BITS(4)) << 2];
dest[3]=alphabet[source[2]&BITS(6)];
break;
}
#define BITS(n) ((1 << (n)) - 1)
static void _bin_to_base64(unsigned char *dest, const unsigned char source[3],
int len) {
switch (len) {
case 1:
dest[0] = alphabet[(source[0] >> 2)];
dest[1] = alphabet[((source[0] & BITS(2)) << 4)];
dest[2] = '=';
dest[3] = '=';
break;
case 2:
dest[0] = alphabet[source[0] >> 2];
dest[1] = alphabet[(source[1] >> 4) | ((source[0] & BITS(2)) << 4)];
dest[2] = alphabet[(source[1] & BITS(4)) << 2];
dest[3] = '=';
break;
case 3:
dest[0] = alphabet[(source[0] >> 2)];
dest[1] = alphabet[(source[1] >> 4) | ((source[0] & BITS(2)) << 4)];
dest[2] = alphabet[ (source[2] >> 6) | (source[1] & BITS(4)) << 2];
dest[3] = alphabet[source[2] & BITS(6)];
break;
}
}
/** \brief Converts binary data to a base64 string
* \returns the converted string
* \internal
/**
* @internal
*
* @brief Converts binary data to a base64 string.
*
* @returns the converted string
*/
unsigned char *bin_to_base64(unsigned char *source, int len){
int flen=len + (3 - (len %3)); /* round to upper 3 multiple */
unsigned char *buffer;
unsigned char *ptr;
flen=(4 * flen)/3 + 1 ;
ptr=buffer=malloc(flen);
while(len>0){
_bin_to_base64(ptr,source,len>3?3:len);
ptr+=4;
source +=3;
len -=3;
}
ptr[0]=0;
return buffer;
unsigned char *bin_to_base64(const unsigned char *source, int len) {
unsigned char *base64;
unsigned char *ptr;
int flen = len + (3 - (len % 3)); /* round to upper 3 multiple */
flen = (4 * flen) / 3 + 1;
base64 = malloc(flen);
if (base64 == NULL) {
return NULL;
}
ptr = base64;
while(len > 0){
_bin_to_base64(ptr, source, len > 3 ? 3 : len);
ptr += 4;
source += 3;
len -= 3;
}
ptr[0] = '\0';
return base64;
}
/* vim: set ts=2 sw=2 et cindent: */

View File

@@ -1,27 +1,35 @@
/*
Copyright (c) 2003-2008 Aris Adamantiadis
This file is part of the SSH Library
The SSH Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
The SSH Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
* buffer.c - buffer functions
*
* This file is part of the SSH Library
*
* Copyright (c) 2003-2009 by Aris Adamantiadis
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include "libssh/priv.h"
#ifndef _WIN32
#include <arpa/inet.h>
#endif
#include "libssh/priv.h"
#include "libssh/buffer.h"
/** \defgroup ssh_buffer SSH Buffers
* \brief buffer handling
*/
@@ -30,51 +38,103 @@ MA 02111-1307, USA. */
* @{
*/
/** \brief creates a new buffer
* \return a new initialized buffer
/** \brief checks that preconditions and postconditions are valid
* \internal
*/
BUFFER *buffer_new(){
BUFFER *buffer=malloc(sizeof(BUFFER));
memset(buffer,0,sizeof(BUFFER));
return buffer;
#ifdef DEBUG_BUFFER
static void buffer_verify(struct buffer_struct *buf){
int doabort=0;
if(buf->data == NULL)
return;
if(buf->used > buf->allocated){
fprintf(stderr,"Buffer error : allocated %u, used %u\n",buf->allocated, buf->used);
doabort=1;
}
if(buf->pos > buf->used){
fprintf(stderr,"Buffer error : position %u, used %u\n",buf->pos, buf->used);
doabort=1;
}
if(buf->pos > buf->allocated){
fprintf(stderr,"Buffer error : position %u, allocated %u\n",buf->pos, buf->allocated);
doabort=1;
}
if(doabort)
abort();
}
#else
#define buffer_verify(x)
#endif
/** \brief creates a new buffer
* \return a new initialized buffer, NULL on error.
*/
struct ssh_buffer_struct *buffer_new(void) {
struct ssh_buffer_struct *buf = malloc(sizeof(struct ssh_buffer_struct));
if (buf == NULL) {
return NULL;
}
memset(buf, 0, sizeof(struct ssh_buffer_struct));
buffer_verify(buf);
return buf;
}
/** \brief deallocate a buffer
* \param buffer buffer to free
*/
void buffer_free(BUFFER *buffer){
// printf("buffer %p : free(%p);\n",buffer,buffer->data);
if(buffer->data){
memset(buffer->data,0,buffer->allocated); /* burn the data */
free(buffer->data);
}
memset(buffer,'x',sizeof (*buffer));
free(buffer);
void buffer_free(struct ssh_buffer_struct *buffer) {
if (buffer == NULL) {
return;
}
buffer_verify(buffer);
if (buffer->data) {
/* burn the data */
memset(buffer->data, 0, buffer->allocated);
SAFE_FREE(buffer->data);
}
memset(buffer, 'X', sizeof(*buffer));
SAFE_FREE(buffer);
}
static void realloc_buffer(BUFFER *buffer,int needed){
int smallest=1;
// find the smallest power of two which is greater or equal to needed
while(smallest<=needed)
smallest <<= 1;
needed=smallest;
// printf("buffer %p : realloc(%x,%d)=",buffer,buffer->data,needed);
buffer->data=realloc(buffer->data,needed);
// printf("%p\n",buffer->data);
buffer->allocated=needed;
static int realloc_buffer(struct ssh_buffer_struct *buffer, int needed) {
int smallest = 1;
char *new = NULL;
buffer_verify(buffer);
/* Find the smallest power of two which is greater or equal to needed */
while(smallest < needed) {
smallest <<= 1;
}
needed = smallest;
new = realloc(buffer->data, needed);
if (new == NULL) {
return -1;
}
buffer->data = new;
buffer->allocated = needed;
buffer_verify(buffer);
return 0;
}
/* \internal
* \brief reinitialize a buffer
* \param buffer buffer
* \return 0 on sucess, < 0 on error
*/
void buffer_reinit(BUFFER *buffer){
memset(buffer->data,0,buffer->used);
buffer->used=0;
buffer->pos=0;
if(buffer->allocated > 127){
realloc_buffer(buffer,127);
int buffer_reinit(struct ssh_buffer_struct *buffer) {
buffer_verify(buffer);
memset(buffer->data, 0, buffer->used);
buffer->used = 0;
buffer->pos = 0;
if(buffer->allocated > 127) {
if (realloc_buffer(buffer, 127) < 0) {
return -1;
}
}
buffer_verify(buffer);
return 0;
}
/** \internal
@@ -83,45 +143,91 @@ void buffer_reinit(BUFFER *buffer){
* \param data data pointer
* \param len length of data
*/
void buffer_add_data(BUFFER *buffer,const void *data,int len){
if(buffer->allocated < buffer->used+len)
realloc_buffer(buffer,buffer->used+len);
memcpy(buffer->data+buffer->used,data,len);
buffer->used+=len;
int buffer_add_data(struct ssh_buffer_struct *buffer, const void *data, uint32_t len) {
buffer_verify(buffer);
if (buffer->allocated < (buffer->used + len)) {
if (realloc_buffer(buffer, buffer->used + len) < 0) {
return -1;
}
}
memcpy(buffer->data+buffer->used, data, len);
buffer->used+=len;
buffer_verify(buffer);
return 0;
}
/** \internal
* \brief add a SSH string to the tail of buffer
* \param buffer buffer
* \param string SSH String to add
* \return 0 on success, -1 on error.
*/
void buffer_add_ssh_string(BUFFER *buffer,STRING *string){
u32 len=ntohl(string->size);
buffer_add_data(buffer,string,len+sizeof(u32));
int buffer_add_ssh_string(struct ssh_buffer_struct *buffer,
struct ssh_string_struct *string) {
uint32_t len = 0;
len = string_len(string);
if (buffer_add_data(buffer, string, len + sizeof(uint32_t)) < 0) {
return -1;
}
return 0;
}
/** \internal
* \brief add a 32 bits unsigned integer to the tail of buffer
* \param buffer buffer
* \param data 32 bits integer
* \return 0 on success, -1 on error.
*/
void buffer_add_u32(BUFFER *buffer,u32 data){
buffer_add_data(buffer,&data,sizeof(data));
int buffer_add_u32(struct ssh_buffer_struct *buffer,uint32_t data){
if (buffer_add_data(buffer, &data, sizeof(data)) < 0) {
return -1;
}
return 0;
}
/** \internal
* \brief add a 16 bits unsigned integer to the tail of buffer
* \param buffer buffer
* \param data 16 bits integer
* \return 0 on success, -1 on error.
*/
int buffer_add_u16(struct ssh_buffer_struct *buffer,uint16_t data){
if (buffer_add_data(buffer, &data, sizeof(data)) < 0) {
return -1;
}
return 0;
}
/** \internal
* \brief add a 64 bits unsigned integer to the tail of buffer
* \param buffer buffer
* \param data 64 bits integer
* \return 0 on success, -1 on error.
*/
void buffer_add_u64(BUFFER *buffer,u64 data){
buffer_add_data(buffer,&data,sizeof(data));
int buffer_add_u64(struct ssh_buffer_struct *buffer, uint64_t data){
if (buffer_add_data(buffer, &data, sizeof(data)) < 0) {
return -1;
}
return 0;
}
/** \internal
* \brief add a 8 bits unsigned integer to the tail of buffer
* \param buffer buffer
* \param data 8 bits integer
* \return 0 on success, -1 on error.
*/
void buffer_add_u8(BUFFER *buffer,u8 data){
buffer_add_data(buffer,&data,sizeof(u8));
int buffer_add_u8(struct ssh_buffer_struct *buffer,uint8_t data){
if (buffer_add_data(buffer, &data, sizeof(uint8_t)) < 0) {
return -1;
}
return 0;
}
/** \internal
@@ -129,22 +235,36 @@ void buffer_add_u8(BUFFER *buffer,u8 data){
* \param buffer buffer
* \param data data to add
* \param len length of data
* \return 0 on success, -1 on error.
*/
void buffer_add_data_begin(BUFFER *buffer, const void *data, int len){
if(buffer->allocated < buffer->used + len)
realloc_buffer(buffer,buffer->used+len);
memmove(buffer->data+len,buffer->data,buffer->used);
memcpy(buffer->data,data,len);
buffer->used+=len;
int buffer_prepend_data(struct ssh_buffer_struct *buffer, const void *data,
uint32_t len) {
buffer_verify(buffer);
if (buffer->allocated < (buffer->used + len)) {
if (realloc_buffer(buffer, buffer->used + len) < 0) {
return -1;
}
}
memmove(buffer->data + len, buffer->data, buffer->used);
memcpy(buffer->data, data, len);
buffer->used += len;
buffer_verify(buffer);
return 0;
}
/** \internal
* \brief append data from a buffer to tail of another
* \param buffer destination buffer
* \param source source buffer. Doesn't take position in buffer into account
* \return 0 on success, -1 on error.
*/
void buffer_add_buffer(BUFFER *buffer, BUFFER *source){
buffer_add_data(buffer,buffer_get(source),buffer_get_len(source));
int buffer_add_buffer(struct ssh_buffer_struct *buffer,
struct ssh_buffer_struct *source) {
if (buffer_add_data(buffer, buffer_get(source), buffer_get_len(source)) < 0) {
return -1;
}
return 0;
}
/** \brief get a pointer on the head of the buffer
@@ -154,8 +274,8 @@ void buffer_add_buffer(BUFFER *buffer, BUFFER *source){
* \see buffer_get_rest()
* \see buffer_get_len()
*/
void *buffer_get(BUFFER *buffer){
return buffer->data;
void *buffer_get(struct ssh_buffer_struct *buffer){
return buffer->data;
}
/** \internal
@@ -165,8 +285,8 @@ void *buffer_get(BUFFER *buffer){
* \see buffer_get_rest_len()
* \see buffer_get()
*/
void *buffer_get_rest(BUFFER *buffer){
return buffer->data+buffer->pos;
void *buffer_get_rest(struct ssh_buffer_struct *buffer){
return buffer->data + buffer->pos;
}
/** \brief get length of the buffer, not counting position
@@ -174,7 +294,7 @@ void *buffer_get_rest(BUFFER *buffer){
* \return length of the buffer
* \see buffer_get()
*/
int buffer_get_len(BUFFER *buffer){
uint32_t buffer_get_len(struct ssh_buffer_struct *buffer){
return buffer->used;
}
@@ -184,8 +304,9 @@ int buffer_get_len(BUFFER *buffer){
* \return length of the buffer
* \see buffer_get_rest()
*/
int buffer_get_rest_len(BUFFER *buffer){
return buffer->used - buffer->pos;
uint32_t buffer_get_rest_len(struct ssh_buffer_struct *buffer){
buffer_verify(buffer);
return buffer->used - buffer->pos;
}
/** \internal
@@ -195,7 +316,8 @@ int buffer_get_rest_len(BUFFER *buffer){
* \param len number of bytes to eat
* \return new size of the buffer
*/
int buffer_pass_bytes(BUFFER *buffer,int len){
uint32_t buffer_pass_bytes(struct ssh_buffer_struct *buffer, uint32_t len){
buffer_verify(buffer);
if(buffer->used < buffer->pos+len)
return 0;
buffer->pos+=len;
@@ -204,6 +326,7 @@ int buffer_pass_bytes(BUFFER *buffer,int len){
buffer->pos=0;
buffer->used=0;
}
buffer_verify(buffer);
return len;
}
@@ -213,11 +336,13 @@ int buffer_pass_bytes(BUFFER *buffer,int len){
* \param len number of bytes to remove from tail
* \return new size of the buffer
*/
int buffer_pass_bytes_end(BUFFER *buffer,int len){
if(buffer->used < buffer->pos + len)
return 0;
buffer->used-=len;
return len;
uint32_t buffer_pass_bytes_end(struct ssh_buffer_struct *buffer, uint32_t len){
buffer_verify(buffer);
if(buffer->used < buffer->pos + len)
return 0;
buffer->used-=len;
buffer_verify(buffer);
return len;
}
/** \internal
@@ -228,9 +353,14 @@ int buffer_pass_bytes_end(BUFFER *buffer,int len){
* \returns 0 if there is not enough data in buffer
* \returns len otherwise.
*/
int buffer_get_data(BUFFER *buffer, void *data, int len){
if(buffer->pos+len>buffer->used)
return 0; /*no enough data in buffer */
uint32_t buffer_get_data(struct ssh_buffer_struct *buffer, void *data, uint32_t len){
/*
* Check for a integer overflow first, then check if not enough data is in
* the buffer.
*/
if (buffer->pos + len < len || buffer->pos + len > buffer->used) {
return 0;
}
memcpy(data,buffer->data+buffer->pos,len);
buffer->pos+=len;
return len; /* no yet support for partial reads (is it really needed ?? ) */
@@ -238,33 +368,33 @@ int buffer_get_data(BUFFER *buffer, void *data, int len){
/** \internal
* \brief gets a 8 bits unsigned int out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read
* \param data pointer to a u8 where to store the data
* \param data pointer to a uint8_t where to store the data
* \returns 0 if there is not enough data in buffer
* \returns 1 otherwise.
*/
int buffer_get_u8(BUFFER *buffer, u8 *data){
return buffer_get_data(buffer,data,sizeof(u8));
int buffer_get_u8(struct ssh_buffer_struct *buffer, uint8_t *data){
return buffer_get_data(buffer,data,sizeof(uint8_t));
}
/** \internal
* \brief gets a 32 bits unsigned int out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read
* \param data pointer to a u32 where to store the data
* \param data pointer to a uint32_t where to store the data
* \returns 0 if there is not enough data in buffer
* \returns 4 otherwise.
*/
int buffer_get_u32(BUFFER *buffer, u32 *data){
return buffer_get_data(buffer,data,sizeof(u32));
int buffer_get_u32(struct ssh_buffer_struct *buffer, uint32_t *data){
return buffer_get_data(buffer,data,sizeof(uint32_t));
}
/** \internal
* \brief gets a 64 bits unsigned int out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read
* \param data pointer to a u64 where to store the data
* \param data pointer to a uint64_t where to store the data
* \returns 0 if there is not enough data in buffer
* \returns 8 otherwise.
*/
int buffer_get_u64(BUFFER *buffer, u64 *data){
return buffer_get_data(buffer,data,sizeof(u64));
int buffer_get_u64(struct ssh_buffer_struct *buffer, uint64_t *data){
return buffer_get_data(buffer,data,sizeof(uint64_t));
}
/** \internal
* \brief gets a SSH String out of the buffer. Adjusts the read pointer.
@@ -272,23 +402,30 @@ int buffer_get_u64(BUFFER *buffer, u64 *data){
* \returns The SSH String read
* \returns NULL otherwise.
*/
STRING *buffer_get_ssh_string(BUFFER *buffer){
u32 stringlen;
u32 hostlen;
STRING *str;
if(buffer_get_u32(buffer,&stringlen)==0)
return NULL;
hostlen=ntohl(stringlen);
/* verify if there is enough space in buffer to get it */
if(buffer->pos+hostlen>buffer->used)
return NULL; /* it is indeed */
str=string_new(hostlen);
if(buffer_get_data(buffer,str->string,hostlen)!=hostlen){
// should never happen
free(str);
return NULL;
}
return str;
struct ssh_string_struct *buffer_get_ssh_string(struct ssh_buffer_struct *buffer) {
uint32_t stringlen;
uint32_t hostlen;
struct ssh_string_struct *str = NULL;
if (buffer_get_u32(buffer, &stringlen) == 0) {
return NULL;
}
hostlen = ntohl(stringlen);
/* verify if there is enough space in buffer to get it */
if ((buffer->pos + hostlen) > buffer->used) {
return NULL; /* it is indeed */
}
str = string_new(hostlen);
if (str == NULL) {
return NULL;
}
if (buffer_get_data(buffer, string_data(str), hostlen) != hostlen) {
/* should never happen */
SAFE_FREE(str);
return NULL;
}
return str;
}
/** \internal
* \brief gets a mpint out of the buffer. Adjusts the read pointer.
@@ -298,22 +435,28 @@ STRING *buffer_get_ssh_string(BUFFER *buffer){
* \returns NULL otherwise
*/
STRING *buffer_get_mpint(BUFFER *buffer){
u16 bits;
u32 len;
STRING *str;
if(buffer_get_data(buffer,&bits,sizeof(u16))!= sizeof(u16))
return NULL;
bits=ntohs(bits);
len=(bits+7)/8;
if(buffer->pos+len > buffer->used)
return NULL;
str=string_new(len);
if(buffer_get_data(buffer,str->string,len)!=len){
free(str);
return NULL;
}
return str;
struct ssh_string_struct *buffer_get_mpint(struct ssh_buffer_struct *buffer) {
uint16_t bits;
uint32_t len;
struct ssh_string_struct *str = NULL;
if (buffer_get_data(buffer, &bits, sizeof(uint16_t)) != sizeof(uint16_t)) {
return NULL;
}
bits = ntohs(bits);
len = (bits + 7) / 8;
if ((buffer->pos + len) > buffer->used) {
return NULL;
}
str = string_new(len);
if (str == NULL) {
return NULL;
}
if (buffer_get_data(buffer, string_data(str), len) != len) {
SAFE_FREE(str);
return NULL;
}
return str;
}
/** @} */
/* vim: set ts=2 sw=2 et cindent: */

37
libssh/callbacks.c Normal file
View File

@@ -0,0 +1,37 @@
/*
* callbacks.c - callback functions
*
* This file is part of the SSH Library
*
* Copyright (c) 2009 by Andreas Schneider <mail@cynapses.org>
*
* The SSH Library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* The SSH Library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the SSH Library; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#include "config.h"
#include "libssh/callbacks.h"
#include "libssh/session.h"
int ssh_set_callbacks(ssh_session session, ssh_callbacks cb) {
if (session == NULL || cb == NULL) {
return -1;
}
session->callbacks = cb;
return 0;
}

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