mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 02:38:09 +09:00
Compare commits
21 Commits
release-0-
...
release-0-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d411260a68 | ||
|
|
f8f0663eb9 | ||
|
|
cedc635ed0 | ||
|
|
ff819489b7 | ||
|
|
37dc2a5279 | ||
|
|
50ebbe636e | ||
|
|
101bf21d41 | ||
|
|
ae3bb42da5 | ||
|
|
918a912cd5 | ||
|
|
7ba81b974e | ||
|
|
b5e868fb8b | ||
|
|
693c041ba9 | ||
|
|
39c7e3c7dd | ||
|
|
3873489688 | ||
|
|
d14a492019 | ||
|
|
848984f25f | ||
|
|
5a755a8219 | ||
|
|
910689126a | ||
|
|
87995db8fe | ||
|
|
70c9da4fb0 | ||
|
|
1ac654ec6c |
@@ -10,9 +10,9 @@ set(APPLICATION_VERSION "0.3.0")
|
|||||||
|
|
||||||
set(APPLICATION_VERSION_MAJOR "0")
|
set(APPLICATION_VERSION_MAJOR "0")
|
||||||
set(APPLICATION_VERSION_MINOR "3")
|
set(APPLICATION_VERSION_MINOR "3")
|
||||||
set(APPLICATION_VERSION_PATCH "0")
|
set(APPLICATION_VERSION_PATCH "1")
|
||||||
|
|
||||||
set(LIBRARY_VERSION "3.0.0")
|
set(LIBRARY_VERSION "3.1.0")
|
||||||
set(LIBRARY_SOVERSION "3")
|
set(LIBRARY_SOVERSION "3")
|
||||||
|
|
||||||
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
|
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
|
|||||||
### versions
|
### versions
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "3")
|
set(CPACK_PACKAGE_VERSION_MINOR "3")
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
set(CPACK_PACKAGE_VERSION_PATCH "1")
|
||||||
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
ChangeLog
|
ChangeLog
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
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)
|
version 0.3 (released 2009-05-21)
|
||||||
* Added support for ssh-agent authentication.
|
* Added support for ssh-agent authentication.
|
||||||
* Added POSIX like sftp implementation.
|
* Added POSIX like sftp implementation.
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ if (UNIX AND NOT WIN32)
|
|||||||
ERROR_QUIET
|
ERROR_QUIET
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}")
|
||||||
|
|
||||||
string(REGEX REPLACE "[\r\n]" " " ${_lfs_CFLAGS} "${${_lfs_CFLAGS}}")
|
|
||||||
|
|
||||||
add_definitions(${_lfs_CFLAGS})
|
add_definitions(${_lfs_CFLAGS})
|
||||||
|
endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||||
|
|
||||||
add_definitions(-Wall -Wextra -Wmissing-prototypes -Wdeclaration-after-statement -Wunused)
|
add_definitions(-Wall -Wextra -Wmissing-prototypes -Wdeclaration-after-statement -Wunused)
|
||||||
|
|
||||||
check_c_compiler_flag("-fstack-protector" WITH_STACK_PROTECTOR)
|
check_c_compiler_flag("-fstack-protector" WITH_STACK_PROTECTOR)
|
||||||
|
|||||||
7
debian/README.Debian
vendored
7
debian/README.Debian
vendored
@@ -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
|
|
||||||
55
debian/changelog
vendored
55
debian/changelog
vendored
@@ -1,55 +0,0 @@
|
|||||||
libssh (0.2+svn20070321-5) UNRELEASED; urgency=low
|
|
||||||
|
|
||||||
* NOT RELEASED YET
|
|
||||||
* debian/control:
|
|
||||||
- Use my debian.org address in Uploaders and takeover the package
|
|
||||||
with Jean-Philippe permission
|
|
||||||
- Use now official Vcs-* field
|
|
||||||
- Use new Homepage field instead of old pseudo-field
|
|
||||||
- Bump Standards-Version to 3.8.1 (no further changes)
|
|
||||||
- Use debug section for -dbg package
|
|
||||||
- Add ${misc:Depends} to please lintian
|
|
||||||
* debian/libssh-2-doc.doc-base: Fix doc-base-uses-applications-section
|
|
||||||
|
|
||||||
-- Laurent Bigonville <bigon@debian.org> 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
1
debian/compat
vendored
@@ -1 +0,0 @@
|
|||||||
5
|
|
||||||
65
debian/control
vendored
65
debian/control
vendored
@@ -1,65 +0,0 @@
|
|||||||
Source: libssh
|
|
||||||
Section: libs
|
|
||||||
Priority: optional
|
|
||||||
Maintainer: Laurent Bigonville <bigon@debian.org>
|
|
||||||
Build-Depends: cdbs, debhelper (>= 5), libgcrypt11-dev, libz-dev, doxygen
|
|
||||||
Standards-Version: 3.8.1
|
|
||||||
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}), ${misc:Depends}, 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: debug
|
|
||||||
Architecture: any
|
|
||||||
Depends: libssh-2 (= ${binary:Version}), ${misc:Depends}
|
|
||||||
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
|
|
||||||
Depends: ${misc:Depends}
|
|
||||||
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
33
debian/copyright
vendored
@@ -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'.
|
|
||||||
2
debian/libssh-2-dev.install
vendored
2
debian/libssh-2-dev.install
vendored
@@ -1,2 +0,0 @@
|
|||||||
debian/tmp/usr/include/*
|
|
||||||
debian/tmp/usr/lib/libssh.{a,la,so}
|
|
||||||
9
debian/libssh-2-doc.doc-base
vendored
9
debian/libssh-2-doc.doc-base
vendored
@@ -1,9 +0,0 @@
|
|||||||
Document: libssh
|
|
||||||
Title: Debian libssh Manual
|
|
||||||
Author: Aris Adamantiadis <aris@0xbadc0de.be>
|
|
||||||
Abstract: This manual describes libssh API.
|
|
||||||
Section: Programming/C
|
|
||||||
|
|
||||||
Format: HTML
|
|
||||||
Index: /usr/share/doc/libssh-2-doc/html/index.html
|
|
||||||
Files: /usr/share/doc/libssh-2-doc/html/*
|
|
||||||
1
debian/libssh-2-doc.docs
vendored
1
debian/libssh-2-doc.docs
vendored
@@ -1 +0,0 @@
|
|||||||
debian/tmp/usr/share/doc/libssh/html
|
|
||||||
1
debian/libssh-2-doc.examples
vendored
1
debian/libssh-2-doc.examples
vendored
@@ -1 +0,0 @@
|
|||||||
debian/tmp/usr/share/doc/libssh/examples/*
|
|
||||||
1
debian/libssh-2-doc.manpages
vendored
1
debian/libssh-2-doc.manpages
vendored
@@ -1 +0,0 @@
|
|||||||
doxygen/man/man3/ssh_*
|
|
||||||
1
debian/libssh-2.install
vendored
1
debian/libssh-2.install
vendored
@@ -1 +0,0 @@
|
|||||||
debian/tmp/usr/lib/libssh.so.*
|
|
||||||
2
debian/libssh-2.lintian-overrides
vendored
2
debian/libssh-2.lintian-overrides
vendored
@@ -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
21
debian/rules
vendored
@@ -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
2
debian/watch
vendored
@@ -1,2 +0,0 @@
|
|||||||
version=3
|
|
||||||
http://0xbadc0de.be/libssh/libssh-(.*)\.tgz
|
|
||||||
@@ -51,7 +51,7 @@ typedef unsigned long long uint64_t;
|
|||||||
/* libssh version */
|
/* libssh version */
|
||||||
#define LIBSSH_VERSION_MAJOR 0
|
#define LIBSSH_VERSION_MAJOR 0
|
||||||
#define LIBSSH_VERSION_MINOR 3
|
#define LIBSSH_VERSION_MINOR 3
|
||||||
#define LIBSSH_VERSION_MICRO 0
|
#define LIBSSH_VERSION_MICRO 1
|
||||||
|
|
||||||
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
|
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
|
||||||
LIBSSH_VERSION_MINOR, \
|
LIBSSH_VERSION_MINOR, \
|
||||||
@@ -134,6 +134,7 @@ typedef int socket_t;
|
|||||||
#define SSH_SERVER_KNOWN_OK 1
|
#define SSH_SERVER_KNOWN_OK 1
|
||||||
#define SSH_SERVER_KNOWN_CHANGED 2
|
#define SSH_SERVER_KNOWN_CHANGED 2
|
||||||
#define SSH_SERVER_FOUND_OTHER 3
|
#define SSH_SERVER_FOUND_OTHER 3
|
||||||
|
#define SSH_SERVER_FILE_NOT_FOUND 4
|
||||||
|
|
||||||
#ifndef MD5_DIGEST_LEN
|
#ifndef MD5_DIGEST_LEN
|
||||||
#define MD5_DIGEST_LEN 16
|
#define MD5_DIGEST_LEN 16
|
||||||
|
|||||||
@@ -133,6 +133,28 @@ typedef BN_CTX* bignum_CTX;
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* poll support */
|
||||||
|
#ifdef HAVE_POLL
|
||||||
|
#include <poll.h>
|
||||||
|
typedef struct pollfd pollfd_t;
|
||||||
|
#else /* HAVE_POLL */
|
||||||
|
typedef struct pollfd_s {
|
||||||
|
socket_t fd; /* file descriptor */
|
||||||
|
short events; /* requested events */
|
||||||
|
short revents; /* returned events */
|
||||||
|
} pollfd_t;
|
||||||
|
|
||||||
|
#define POLLIN 0x001 /* There is data to read. */
|
||||||
|
#define POLLPRI 0x002 /* There is urgent data to read. */
|
||||||
|
#define POLLOUT 0x004 /* Writing now will not block. */
|
||||||
|
|
||||||
|
#define POLLERR 0x008 /* Error condition. */
|
||||||
|
#define POLLHUP 0x010 /* Hung up. */
|
||||||
|
#define POLLNVAL 0x020 /* Invalid polling request. */
|
||||||
|
|
||||||
|
typedef unsigned long int nfds_t;
|
||||||
|
#endif /* HAVE_POLL */
|
||||||
|
|
||||||
/* wrapper.c */
|
/* wrapper.c */
|
||||||
MD5CTX md5_init(void);
|
MD5CTX md5_init(void);
|
||||||
void md5_update(MD5CTX c, const void *data, unsigned long len);
|
void md5_update(MD5CTX c, const void *data, unsigned long len);
|
||||||
@@ -474,6 +496,9 @@ STRING *agent_sign_data(struct ssh_session *session,
|
|||||||
struct public_key_struct *pubkey);
|
struct public_key_struct *pubkey);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* poll.c */
|
||||||
|
int ssh_poll(pollfd_t *fds, nfds_t nfds, int timeout);
|
||||||
|
|
||||||
/* socket.c */
|
/* socket.c */
|
||||||
|
|
||||||
struct socket;
|
struct socket;
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ set(libssh_SRCS
|
|||||||
misc.c
|
misc.c
|
||||||
options.c
|
options.c
|
||||||
packet.c
|
packet.c
|
||||||
|
poll.c
|
||||||
session.c
|
session.c
|
||||||
socket.c
|
socket.c
|
||||||
string.c
|
string.c
|
||||||
|
|||||||
@@ -44,6 +44,10 @@
|
|||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/agent.h"
|
#include "libssh/agent.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
|||||||
@@ -22,12 +22,17 @@
|
|||||||
* MA 02111-1307, USA.
|
* MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
|
||||||
#include "libssh/ssh2.h"
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/ssh2.h"
|
||||||
|
|
||||||
/** \defgroup ssh_auth SSH Authentication functions
|
/** \defgroup ssh_auth SSH Authentication functions
|
||||||
* \brief functions to authenticate to servers
|
* \brief functions to authenticate to servers
|
||||||
*/
|
*/
|
||||||
@@ -1070,10 +1075,10 @@ static void kbdint_clean(struct ssh_kbdint *kbd) {
|
|||||||
* of the draft */
|
* of the draft */
|
||||||
static int kbdauth_init(SSH_SESSION *session, const char *user,
|
static int kbdauth_init(SSH_SESSION *session, const char *user,
|
||||||
const char *submethods) {
|
const char *submethods) {
|
||||||
STRING *usr;
|
STRING *usr = NULL;
|
||||||
STRING *sub;
|
STRING *sub = NULL;
|
||||||
STRING *service;
|
STRING *service = NULL;
|
||||||
STRING *method;
|
STRING *method = NULL;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
|
|||||||
@@ -23,6 +23,11 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
/** \defgroup ssh_buffer SSH Buffers
|
/** \defgroup ssh_buffer SSH Buffers
|
||||||
|
|||||||
@@ -28,6 +28,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
|
|
||||||
@@ -311,7 +315,7 @@ static void channel_rcv_change_window(SSH_SESSION *session) {
|
|||||||
|
|
||||||
channel = channel_from_msg(session);
|
channel = channel_from_msg(session);
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
ssh_log(session, SSH_LOG_FUNCTIONS, ssh_get_error(session));
|
ssh_log(session, SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = buffer_get_u32(session->in_buffer, &bytes);
|
rc = buffer_get_u32(session->in_buffer, &bytes);
|
||||||
@@ -409,7 +413,7 @@ static void channel_rcv_eof(SSH_SESSION *session) {
|
|||||||
|
|
||||||
channel = channel_from_msg(session);
|
channel = channel_from_msg(session);
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
ssh_log(session, SSH_LOG_FUNCTIONS, ssh_get_error(session));
|
ssh_log(session, SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
|
||||||
leave_function();
|
leave_function();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -431,7 +435,7 @@ static void channel_rcv_close(SSH_SESSION *session) {
|
|||||||
|
|
||||||
channel = channel_from_msg(session);
|
channel = channel_from_msg(session);
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
ssh_log(session, SSH_LOG_FUNCTIONS, ssh_get_error(session));
|
ssh_log(session, SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
|
||||||
leave_function();
|
leave_function();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -473,7 +477,7 @@ static void channel_rcv_request(SSH_SESSION *session) {
|
|||||||
|
|
||||||
channel = channel_from_msg(session);
|
channel = channel_from_msg(session);
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
ssh_log(session, SSH_LOG_FUNCTIONS, ssh_get_error(session));
|
ssh_log(session, SSH_LOG_FUNCTIONS,"%s", ssh_get_error(session));
|
||||||
leave_function();
|
leave_function();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -900,7 +904,10 @@ int channel_write(CHANNEL *channel, const void *data, u32 len) {
|
|||||||
/* What happens when the channel window is zero? */
|
/* What happens when the channel window is zero? */
|
||||||
while(channel->remote_window == 0) {
|
while(channel->remote_window == 0) {
|
||||||
/* parse every incoming packet */
|
/* parse every incoming packet */
|
||||||
packet_wait(channel->session, 0, 0);
|
if (packet_wait(channel->session, 0, 0) == SSH_ERROR) {
|
||||||
|
leave_function();
|
||||||
|
return SSH_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
effectivelen = len > channel->remote_window ? channel->remote_window : len;
|
effectivelen = len > channel->remote_window ? channel->remote_window : len;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -24,6 +24,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
|
|
||||||
@@ -216,6 +221,7 @@ static int dh_handshake(SSH_SESSION *session) {
|
|||||||
}
|
}
|
||||||
string_burn(e);
|
string_burn(e);
|
||||||
string_free(e);
|
string_free(e);
|
||||||
|
e=NULL;
|
||||||
|
|
||||||
rc = packet_send(session);
|
rc = packet_send(session);
|
||||||
if (rc == SSH_ERROR) {
|
if (rc == SSH_ERROR) {
|
||||||
@@ -256,7 +262,7 @@ static int dh_handshake(SSH_SESSION *session) {
|
|||||||
}
|
}
|
||||||
string_burn(f);
|
string_burn(f);
|
||||||
string_free(f);
|
string_free(f);
|
||||||
|
f=NULL;
|
||||||
signature = buffer_get_ssh_string(session->in_buffer);
|
signature = buffer_get_ssh_string(session->in_buffer);
|
||||||
if (signature == NULL) {
|
if (signature == NULL) {
|
||||||
ssh_set_error(session, SSH_FATAL, "No signature in packet");
|
ssh_set_error(session, SSH_FATAL, "No signature in packet");
|
||||||
@@ -327,13 +333,14 @@ static int dh_handshake(SSH_SESSION *session) {
|
|||||||
/* forget it for now ... */
|
/* forget it for now ... */
|
||||||
string_burn(signature);
|
string_burn(signature);
|
||||||
string_free(signature);
|
string_free(signature);
|
||||||
|
signature=NULL;
|
||||||
/*
|
/*
|
||||||
* Once we got SSH2_MSG_NEWKEYS we can switch next_crypto and
|
* Once we got SSH2_MSG_NEWKEYS we can switch next_crypto and
|
||||||
* current_crypto
|
* current_crypto
|
||||||
*/
|
*/
|
||||||
if (session->current_crypto) {
|
if (session->current_crypto) {
|
||||||
crypto_free(session->current_crypto);
|
crypto_free(session->current_crypto);
|
||||||
|
session->current_crypto=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME later, include a function to change keys */
|
/* FIXME later, include a function to change keys */
|
||||||
@@ -359,14 +366,22 @@ static int dh_handshake(SSH_SESSION *session) {
|
|||||||
|
|
||||||
/* not reached */
|
/* not reached */
|
||||||
error:
|
error:
|
||||||
|
if(e != NULL){
|
||||||
string_burn(e);
|
string_burn(e);
|
||||||
string_free(e);
|
string_free(e);
|
||||||
|
}
|
||||||
|
if(f != NULL){
|
||||||
string_burn(f);
|
string_burn(f);
|
||||||
string_free(f);
|
string_free(f);
|
||||||
|
}
|
||||||
|
if(pubkey != NULL){
|
||||||
string_burn(pubkey);
|
string_burn(pubkey);
|
||||||
string_free(pubkey);
|
string_free(pubkey);
|
||||||
|
}
|
||||||
|
if(signature != NULL){
|
||||||
string_burn(signature);
|
string_burn(signature);
|
||||||
string_free(signature);
|
string_free(signature);
|
||||||
|
}
|
||||||
|
|
||||||
leave_function();
|
leave_function();
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@@ -26,6 +26,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef OPENSSL_CRYPTO
|
#ifdef OPENSSL_CRYPTO
|
||||||
#include <openssl/blowfish.h>
|
#include <openssl/blowfish.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|||||||
@@ -44,6 +44,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/crypto.h"
|
#include "libssh/crypto.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
|
|||||||
@@ -29,6 +29,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
@@ -1275,9 +1280,9 @@ static int match_hashed_host(SSH_SESSION *session, const char *host,
|
|||||||
leave_function();
|
leave_function();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SAFE_FREE(source);
|
|
||||||
|
|
||||||
hash = base64_to_bin(b64hash);
|
hash = base64_to_bin(b64hash);
|
||||||
|
SAFE_FREE(source);
|
||||||
if (hash == NULL) {
|
if (hash == NULL) {
|
||||||
buffer_free(salt);
|
buffer_free(salt);
|
||||||
leave_function();
|
leave_function();
|
||||||
@@ -1337,6 +1342,9 @@ static int match_hashed_host(SSH_SESSION *session, const char *host,
|
|||||||
* possible attack \n
|
* possible attack \n
|
||||||
* SSH_SERVER_NOT_KNOWN: The server is unknown. User should confirm
|
* SSH_SERVER_NOT_KNOWN: The server is unknown. User should confirm
|
||||||
* the MD5 is correct\n
|
* the MD5 is correct\n
|
||||||
|
* SSH_SERVER_FILE_NOT_FOUND:The known host file does not exist. The
|
||||||
|
* host is thus unknown. File will be created
|
||||||
|
* if host key is accepted\n
|
||||||
* SSH_SERVER_ERROR: Some error happened
|
* SSH_SERVER_ERROR: Some error happened
|
||||||
*
|
*
|
||||||
* \see ssh_options_set_wanted_algo()
|
* \see ssh_options_set_wanted_algo()
|
||||||
@@ -1356,10 +1364,10 @@ int ssh_is_server_known(SSH_SESSION *session) {
|
|||||||
enter_function();
|
enter_function();
|
||||||
|
|
||||||
if (ssh_options_default_known_hosts_file(session->options) < 0) {
|
if (ssh_options_default_known_hosts_file(session->options) < 0) {
|
||||||
ssh_set_error(session, SSH_FATAL,
|
ssh_set_error(session, SSH_REQUEST_DENIED,
|
||||||
"Can't find a known_hosts file");
|
"Can't find a known_hosts file");
|
||||||
leave_function();
|
leave_function();
|
||||||
return SSH_SERVER_ERROR;
|
return SSH_SERVER_FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session->options->host == NULL) {
|
if (session->options->host == NULL) {
|
||||||
@@ -1413,6 +1421,8 @@ int ssh_is_server_known(SSH_SESSION *session) {
|
|||||||
/* We override the status with the wrong key state */
|
/* We override the status with the wrong key state */
|
||||||
ret = SSH_SERVER_KNOWN_CHANGED;
|
ret = SSH_SERVER_KNOWN_CHANGED;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tokens_free(tokens);
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
@@ -1427,7 +1437,7 @@ int ssh_is_server_known(SSH_SESSION *session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** You generaly use it when ssh_is_server_known() answered SSH_SERVER_NOT_KNOWN
|
/** You generaly use it when ssh_is_server_known() answered SSH_SERVER_NOT_KNOWN
|
||||||
* \brief write the current server as known in the known hosts file
|
* \brief write the current server as known in the known hosts file. This will create the known hosts file if it does not exist.
|
||||||
* \param session ssh session
|
* \param session ssh session
|
||||||
* \return 0 on success, -1 on error
|
* \return 0 on success, -1 on error
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -34,6 +34,11 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/server.h"
|
#include "libssh/server.h"
|
||||||
@@ -778,7 +783,9 @@ void ssh_message_free(SSH_MESSAGE *msg){
|
|||||||
SAFE_FREE(msg->channel_request.subsystem);
|
SAFE_FREE(msg->channel_request.subsystem);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZERO_STRUCTP(msg);
|
ZERO_STRUCTP(msg);
|
||||||
|
SAFE_FREE(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
@@ -534,7 +538,7 @@ static int packet_send1(SSH_SESSION *session) {
|
|||||||
"%d bytes after comp + %d padding bytes = %d bytes packet",
|
"%d bytes after comp + %d padding bytes = %d bytes packet",
|
||||||
currentlen, padding, ntohl(finallen));
|
currentlen, padding, ntohl(finallen));
|
||||||
|
|
||||||
if (buffer_prepend_data(session->out_buffer,i &padstring, padding) < 0) {
|
if (buffer_prepend_data(session->out_buffer, &padstring, padding) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (buffer_prepend_data(session->out_buffer, &finallen, sizeof(u32)) < 0) {
|
if (buffer_prepend_data(session->out_buffer, &finallen, sizeof(u32)) < 0) {
|
||||||
@@ -607,7 +611,7 @@ void packet_parse(SSH_SESSION *session) {
|
|||||||
case SSH_SMSG_STDOUT_DATA:
|
case SSH_SMSG_STDOUT_DATA:
|
||||||
case SSH_SMSG_STDERR_DATA:
|
case SSH_SMSG_STDERR_DATA:
|
||||||
case SSH_SMSG_EXITSTATUS:
|
case SSH_SMSG_EXITSTATUS:
|
||||||
channel_handle1(session,type)
|
channel_handle1(session,type);
|
||||||
return;
|
return;
|
||||||
case SSH_MSG_DEBUG:
|
case SSH_MSG_DEBUG:
|
||||||
case SSH_MSG_IGNORE:
|
case SSH_MSG_IGNORE:
|
||||||
|
|||||||
206
libssh/poll.c
Normal file
206
libssh/poll.c
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
/*
|
||||||
|
* poll.c - poll wrapper
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* vim: ts=2 sw=2 et cindent
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This code is based on glib's gpoll */
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_POLL
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
|
int ssh_poll(pollfd_t *fds, nfds_t nfds, int timeout) {
|
||||||
|
return poll((struct pollfd *) fds, nfds, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* HAVE_POLL */
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600)
|
||||||
|
|
||||||
|
#include <winsock2.h>
|
||||||
|
|
||||||
|
int ssh_poll(pollfd_t *fds, nfds_t nfds, int timeout) {
|
||||||
|
return WSAPoll(fds, nfds, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _WIN32_WINNT */
|
||||||
|
|
||||||
|
#ifndef STRICT
|
||||||
|
#define STRICT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
static int poll_rest (HANDLE *handles, int nhandles,
|
||||||
|
pollfd_t *fds, nfds_t nfds, int timeout) {
|
||||||
|
DWORD ready;
|
||||||
|
pollfd_t *f;
|
||||||
|
int recursed_result;
|
||||||
|
|
||||||
|
if (nhandles == 0) {
|
||||||
|
/* No handles to wait for, just the timeout */
|
||||||
|
if (timeout == INFINITE) {
|
||||||
|
ready = WAIT_FAILED;
|
||||||
|
} else {
|
||||||
|
SleepEx(timeout, 1);
|
||||||
|
ready = WAIT_TIMEOUT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Wait for just handles */
|
||||||
|
ready = WaitForMultipleObjectsEx(nhandles, handles, FALSE, timeout, TRUE);
|
||||||
|
#if 0
|
||||||
|
if (ready == WAIT_FAILED) {
|
||||||
|
fprintf(stderr, "WaitForMultipleObjectsEx failed: %d\n", GetLastError());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ready == WAIT_FAILED) {
|
||||||
|
return -1;
|
||||||
|
} else if (ready == WAIT_TIMEOUT || ready == WAIT_IO_COMPLETION) {
|
||||||
|
return 0;
|
||||||
|
} else if (ready >= WAIT_OBJECT_0 && ready < WAIT_OBJECT_0 + nhandles) {
|
||||||
|
for (f = fds; f < &fds[nfds]; f++) {
|
||||||
|
if ((HANDLE) f->fd == handles[ready - WAIT_OBJECT_0]) {
|
||||||
|
f->revents = f->events;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If no timeout and polling several handles, recurse to poll
|
||||||
|
* the rest of them.
|
||||||
|
*/
|
||||||
|
if (timeout == 0 && nhandles > 1) {
|
||||||
|
/* Remove the handle that fired */
|
||||||
|
int i;
|
||||||
|
if (ready < nhandles - 1) {
|
||||||
|
for (i = ready - WAIT_OBJECT_0 + 1; i < nhandles; i++) {
|
||||||
|
handles[i-1] = handles[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nhandles--;
|
||||||
|
recursed_result = poll_rest(handles, nhandles, fds, nfds, 0);
|
||||||
|
if (recursed_result < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return recursed_result + 1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ssh_poll(pollfd_t *fds, nfds_t nfds, int timeout) {
|
||||||
|
HANDLE handles[MAXIMUM_WAIT_OBJECTS];
|
||||||
|
pollfd_t *f;
|
||||||
|
int nhandles = 0;
|
||||||
|
int rc = -1;
|
||||||
|
|
||||||
|
if (fds == NULL) {
|
||||||
|
errno = EFAULT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nfds >= MAXIMUM_WAIT_OBJECTS) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (f = fds; f < &fds[nfds]; f++) {
|
||||||
|
if (f->fd > 0) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't add the same handle several times into the array, as
|
||||||
|
* docs say that is not allowed, even if it actually does seem
|
||||||
|
* to work.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < nhandles; i++) {
|
||||||
|
if (handles[i] == (HANDLE) f->fd) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == nhandles) {
|
||||||
|
if (nhandles == MAXIMUM_WAIT_OBJECTS) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
handles[nhandles++] = (HANDLE) f->fd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeout == -1) {
|
||||||
|
timeout = INFINITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nhandles > 1) {
|
||||||
|
/*
|
||||||
|
* First check if one or several of them are immediately
|
||||||
|
* available.
|
||||||
|
*/
|
||||||
|
rc = poll_rest(handles, nhandles, fds, nfds, 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If not, and we have a significant timeout, poll again with
|
||||||
|
* timeout then. Note that this will return indication for only
|
||||||
|
* one event, or only for messages. We ignore timeouts less than
|
||||||
|
* ten milliseconds as they are mostly pointless on Windows, the
|
||||||
|
* MsgWaitForMultipleObjectsEx() call will timeout right away
|
||||||
|
* anyway.
|
||||||
|
*/
|
||||||
|
if (rc == 0 && (timeout == INFINITE || timeout >= 10)) {
|
||||||
|
rc = poll_rest(handles, nhandles, fds, nfds, timeout);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Just polling for one thing, so no need to check first if
|
||||||
|
* available immediately
|
||||||
|
*/
|
||||||
|
rc = poll_rest(handles, nhandles, fds, nfds, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc < 0) {
|
||||||
|
for (f = fds; f < &fds[nfds]; f++) {
|
||||||
|
f->revents = 0;
|
||||||
|
}
|
||||||
|
errno = EBADF;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _WIN32_WINNT */
|
||||||
|
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
#endif /* HAVE_POLL */
|
||||||
|
|
||||||
@@ -31,6 +31,10 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
#include "libssh/sftp.h"
|
#include "libssh/sftp.h"
|
||||||
@@ -1677,6 +1681,7 @@ ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count) {
|
|||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
u32 id;
|
u32 id;
|
||||||
int len;
|
int len;
|
||||||
|
int packetlen;
|
||||||
|
|
||||||
buffer = buffer_new();
|
buffer = buffer_new();
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
@@ -1700,12 +1705,12 @@ ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
string_free(datastring);
|
string_free(datastring);
|
||||||
|
|
||||||
len = sftp_packet_write(file->sftp, SSH_FXP_WRITE, buffer);
|
len = sftp_packet_write(file->sftp, SSH_FXP_WRITE, buffer);
|
||||||
|
packetlen=buffer_get_len(buffer);
|
||||||
buffer_free(buffer);
|
buffer_free(buffer);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if ((u32) len != buffer_get_len(buffer)) {
|
} else if (len != packetlen) {
|
||||||
ssh_log(sftp->session, SSH_LOG_PACKET,
|
ssh_log(sftp->session, SSH_LOG_PACKET,
|
||||||
"Could not write as much data as expected");
|
"Could not write as much data as expected");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
#include "libssh/sftp.h"
|
#include "libssh/sftp.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
|
|||||||
@@ -36,22 +36,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
#if !defined(HAVE_SELECT) && !defined(HAVE_POLL)
|
|
||||||
#error Your system must have either select() or poll()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(HAVE_POLL) && !defined(_WIN32)
|
|
||||||
#warning your system does not have poll. Select has known limitations
|
|
||||||
#define SELECT_LIMIT_CHECK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_POLL
|
|
||||||
#define USE_POLL
|
|
||||||
#include <poll.h>
|
|
||||||
#else
|
|
||||||
#define USE_SELECT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** \defgroup ssh_socket SSH Sockets
|
/** \defgroup ssh_socket SSH Sockets
|
||||||
* \addtogroup ssh_socket
|
* \addtogroup ssh_socket
|
||||||
* @{
|
* @{
|
||||||
@@ -472,86 +456,10 @@ int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, u32 len) {
|
|||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_SELECT
|
/* ssh_socket_poll */
|
||||||
/* ssh_socket_poll, select() version */
|
|
||||||
|
|
||||||
/* \internal
|
|
||||||
* \brief polls the socket for data
|
|
||||||
* \param session ssh session
|
|
||||||
* \param writeable value pointed to set to 1 if it is possible to write
|
|
||||||
* \param except value pointed to set to 1 if there is an exception
|
|
||||||
* \return 1 if it is possible to read, 0 otherwise, -1 on error
|
|
||||||
*/
|
|
||||||
int ssh_socket_poll(struct socket *s, int *writeable, int *except) {
|
int ssh_socket_poll(struct socket *s, int *writeable, int *except) {
|
||||||
SSH_SESSION *session = s->session;
|
SSH_SESSION *session = s->session;
|
||||||
struct timeval sometime;
|
pollfd_t fd[1];
|
||||||
fd_set rdes; // read set
|
|
||||||
fd_set wdes; // writing set
|
|
||||||
fd_set edes; // exception set
|
|
||||||
int fdmax =- 1;
|
|
||||||
|
|
||||||
enter_function();
|
|
||||||
|
|
||||||
FD_ZERO(&rdes);
|
|
||||||
FD_ZERO(&wdes);
|
|
||||||
FD_ZERO(&edes);
|
|
||||||
|
|
||||||
if (!ssh_socket_is_open(s)) {
|
|
||||||
*except = 1;
|
|
||||||
*writeable = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#ifdef SELECT_LIMIT_CHECK
|
|
||||||
// some systems don't handle the fds > FD_SETSIZE
|
|
||||||
if(s->fd > FD_SETSIZE){
|
|
||||||
ssh_set_error(session, SSH_REQUEST_DENIED,
|
|
||||||
"File descriptor out of range for select: %d", s->fd);
|
|
||||||
|
|
||||||
leave_function();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!s->data_to_read) {
|
|
||||||
ssh_socket_fd_set(s, &rdes, &fdmax);
|
|
||||||
}
|
|
||||||
if (!s->data_to_write) {
|
|
||||||
ssh_socket_fd_set(s, &wdes, &fdmax);
|
|
||||||
}
|
|
||||||
ssh_socket_fd_set(s, &edes, &fdmax);
|
|
||||||
|
|
||||||
/* Set to return immediately (no blocking) */
|
|
||||||
sometime.tv_sec = 0;
|
|
||||||
sometime.tv_usec = 0;
|
|
||||||
|
|
||||||
/* Make the call, and listen for errors */
|
|
||||||
if (select(fdmax, &rdes, &wdes, &edes, &sometime) < 0) {
|
|
||||||
ssh_set_error(session, SSH_FATAL, "select(): %s", strerror(errno));
|
|
||||||
leave_function();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!s->data_to_read) {
|
|
||||||
s->data_to_read = ssh_socket_fd_isset(s, &rdes);
|
|
||||||
}
|
|
||||||
if (!s->data_to_write) {
|
|
||||||
s->data_to_write = ssh_socket_fd_isset(s, &wdes);
|
|
||||||
}
|
|
||||||
if (!s->data_except) {
|
|
||||||
s->data_except = ssh_socket_fd_isset(s, &edes);
|
|
||||||
}
|
|
||||||
*except = s->data_except;
|
|
||||||
*writeable = s->data_to_write;
|
|
||||||
|
|
||||||
leave_function();
|
|
||||||
return (s->data_to_read || (buffer_get_rest_len(s->in_buffer) > 0));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_POLL
|
|
||||||
/* ssh_socket_poll, poll() version */
|
|
||||||
int ssh_socket_poll(struct socket *s, int *writeable, int *except) {
|
|
||||||
SSH_SESSION *session = s->session;
|
|
||||||
struct pollfd fd[1];
|
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -573,7 +481,7 @@ int ssh_socket_poll(struct socket *s, int *writeable, int *except) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make the call, and listen for errors */
|
/* Make the call, and listen for errors */
|
||||||
rc = poll(fd, 1, 0);
|
rc = ssh_poll(fd, 1, 0);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ssh_set_error(session, SSH_FATAL, "poll(): %s", strerror(errno));
|
ssh_set_error(session, SSH_FATAL, "poll(): %s", strerror(errno));
|
||||||
leave_function();
|
leave_function();
|
||||||
@@ -596,7 +504,6 @@ int ssh_socket_poll(struct socket *s, int *writeable, int *except) {
|
|||||||
leave_function();
|
leave_function();
|
||||||
return (s->data_to_read || (buffer_get_rest_len(s->in_buffer) > 0));
|
return (s->data_to_read || (buffer_get_rest_len(s->in_buffer) > 0));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* \brief nonblocking flush of the output buffer
|
* \brief nonblocking flush of the output buffer
|
||||||
|
|||||||
@@ -24,6 +24,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
/** \defgroup ssh_string SSH Strings
|
/** \defgroup ssh_string SSH Strings
|
||||||
|
|||||||
4
sample.c
4
sample.c
@@ -469,6 +469,10 @@ int main(int argc, char **argv){
|
|||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
exit(-1);
|
exit(-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 behaviour */
|
||||||
case SSH_SERVER_NOT_KNOWN:
|
case SSH_SERVER_NOT_KNOWN:
|
||||||
hexa = ssh_get_hexa(hash, hlen);
|
hexa = ssh_get_hexa(hash, hlen);
|
||||||
free(hash);
|
free(hash);
|
||||||
|
|||||||
Reference in New Issue
Block a user