mirror of
https://github.com/php-win-ext/libssh2.git
synced 2026-03-24 17:12:15 +01:00
Compare commits
12 Commits
libssh2-1.
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60401ec4c2 | ||
|
|
c9d9ea4f2d | ||
|
|
660faf6946 | ||
|
|
314c2127c2 | ||
|
|
6b93b1a5ab | ||
|
|
40fd51727e | ||
|
|
557e55cd59 | ||
|
|
8dc8fa5e1f | ||
|
|
f93d744e98 | ||
|
|
15f0a3a1f0 | ||
|
|
29ad98fd94 | ||
|
|
c4da10e055 |
117
CMakeLists.txt
Normal file
117
CMakeLists.txt
Normal file
@@ -0,0 +1,117 @@
|
||||
# Copyright (c) 2014, 2015 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
project(libssh2 C)
|
||||
set(PROJECT_URL "https://www.libssh2.org/")
|
||||
set(PROJECT_DESCRIPTION "The SSH library")
|
||||
|
||||
if (CMAKE_VERSION VERSION_LESS "3.1")
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
set (CMAKE_C_FLAGS "--std=gnu90 ${CMAKE_C_FLAGS}")
|
||||
endif()
|
||||
else()
|
||||
set (CMAKE_C_STANDARD 90)
|
||||
endif()
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
|
||||
|
||||
# Parse version
|
||||
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/include/libssh2.h _HEADER_CONTENTS)
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
|
||||
LIBSSH2_VERSION "${_HEADER_CONTENTS}")
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1"
|
||||
LIBSSH2_VERSION_MAJOR "${_HEADER_CONTENTS}")
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION_MINOR[ \t]+([0-9]+).*" "\\1"
|
||||
LIBSSH2_VERSION_MINOR "${_HEADER_CONTENTS}")
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION_PATCH[ \t]+([0-9]+).*" "\\1"
|
||||
LIBSSH2_VERSION_PATCH "${_HEADER_CONTENTS}")
|
||||
|
||||
if(NOT LIBSSH2_VERSION OR
|
||||
NOT LIBSSH2_VERSION_MAJOR MATCHES "^[0-9]+$" OR
|
||||
NOT LIBSSH2_VERSION_MINOR MATCHES "^[0-9]+$" OR
|
||||
NOT LIBSSH2_VERSION_PATCH MATCHES "^[0-9]+$")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Unable to parse version from"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/libssh2.h")
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(
|
||||
FILES docs/AUTHORS COPYING docs/HACKING README RELEASE-NOTES NEWS
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
|
||||
include(max_warnings)
|
||||
include(FeatureSummary)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
option(BUILD_EXAMPLES "Build libssh2 examples" ON)
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
option(BUILD_TESTING "Build libssh2 test suite" ON)
|
||||
if(BUILD_TESTING)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
option(LINT "Check style while building" OFF)
|
||||
if(LINT)
|
||||
add_custom_target(lint ALL
|
||||
./ci/checksrc.sh
|
||||
WORKING_DIRECTORY ${libssh2_SOURCE_DIR})
|
||||
add_dependencies(libssh2 lint)
|
||||
endif()
|
||||
|
||||
add_subdirectory(docs)
|
||||
|
||||
feature_summary(WHAT ALL)
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${LIBSSH2_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${LIBSSH2_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${LIBSSH2_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VERSION ${LIBSSH2_VERSION})
|
||||
include(CPack)
|
||||
4
COPYING
4
COPYING
@@ -2,8 +2,10 @@
|
||||
* Copyright (c) 2005,2006 Mikhail Gusarov <dottedmag@dottedmag.net>
|
||||
* Copyright (c) 2006-2007 The Written Word, Inc.
|
||||
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
|
||||
* Copyright (c) 2009-2014 Daniel Stenberg
|
||||
* Copyright (c) 2009-2021 Daniel Stenberg
|
||||
* Copyright (C) 2008, 2009 Simon Josefsson
|
||||
* Copyright (c) 2000 Markus Friedl
|
||||
* Copyright (c) 2015 Microsoft Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
CRYPTO_CSOURCES = openssl.c
|
||||
CRYPTO_HHEADERS = openssl.h
|
||||
CRYPTO_LTLIBS = $(LTLIBSSL)
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
CRYPTO_CSOURCES = wincng.c
|
||||
CRYPTO_HHEADERS = wincng.h
|
||||
CRYPTO_LTLIBS = $(LTLIBBCRYPT) $(LTLIBCRYPT32)
|
||||
|
||||
27
Makefile.am
27
Makefile.am
@@ -32,8 +32,20 @@ win32/libssh2_config.h win32/config.mk win32/rules.mk \
|
||||
win32/Makefile.Watcom win32/libssh2.dsw win32/tests.dsp $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk \
|
||||
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath
|
||||
OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \
|
||||
os400/make-src.sh os400/make-rpg.sh os400/make-include.sh \
|
||||
os400/os400sys.c os400/ccsid.c \
|
||||
os400/libssh2_config.h os400/macros.h os400/libssh2_ccsid.h \
|
||||
os400/include/alloca.h os400/include/sys/socket.h os400/include/stdio.h \
|
||||
os400/libssh2rpg/libssh2.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_ccsid.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_publickey.rpgle \
|
||||
os400/libssh2rpg/libssh2_sftp.rpgle \
|
||||
Makefile.os400qc3.inc
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) $(NETWAREFILES) get_ver.awk \
|
||||
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath \
|
||||
CMakeLists.txt cmake $(OS400FILES)
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
@@ -76,8 +88,8 @@ coverage: init-coverage build-coverage gen-coverage
|
||||
|
||||
# DSP/VCPROJ generation adapted from libcurl
|
||||
# only OpenSSL and WinCNG are supported with this build system
|
||||
CRYPTO_CSOURCES = openssl.c wincng.c
|
||||
CRYPTO_HHEADERS = openssl.h wincng.h
|
||||
CRYPTO_CSOURCES = openssl.c wincng.c mbedtls.c
|
||||
CRYPTO_HHEADERS = openssl.h wincng.h mbedtls.h
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
include Makefile.inc
|
||||
|
||||
@@ -107,7 +119,7 @@ $(DSP): win32/msvcproj.head win32/msvcproj.foot Makefile.am
|
||||
for file in $$sorted_hdrs; do \
|
||||
echo "# Begin Source File"; \
|
||||
echo ""; \
|
||||
if [ "$$file" == "libssh2_config.h" ]; \
|
||||
if [ "$$file" = "libssh2_config.h" ]; \
|
||||
then \
|
||||
echo "SOURCE=.\\"$$file; \
|
||||
else \
|
||||
@@ -135,3 +147,8 @@ $(VCPROJ): win32/vc8proj.head win32/vc8proj.foot Makefile.am
|
||||
done; \
|
||||
cat $(srcdir)/vc8proj.foot) | \
|
||||
awk '{printf("%s\r\n", gensub("\r", "", "g"))}' > $@ )
|
||||
|
||||
checksrc:
|
||||
perl src/checksrc.pl -i4 -m79 -ASIZEOFNOPAREN -ASNPRINTF -ACOPYRIGHT \
|
||||
-AFOPENMODE -Wsrc/libssh2_config.h src/*.[ch] include/*.h example/*.c \
|
||||
tests/*.[ch]
|
||||
|
||||
132
Makefile.in
132
Makefile.in
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.4 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -16,7 +16,17 @@
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@@ -80,12 +90,6 @@ POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@BUILD_EXAMPLES_TRUE@am__append_1 = example
|
||||
DIST_COMMON = $(srcdir)/Makefile.inc $(srcdir)/Makefile.in \
|
||||
$(srcdir)/Makefile.am $(top_srcdir)/configure \
|
||||
$(am__configure_deps) $(srcdir)/libssh2.pc.in \
|
||||
$(include_HEADERS) COPYING ChangeLog NEWS README compile \
|
||||
config.guess config.rpath config.sub depcomp install-sh \
|
||||
missing ltmain.sh
|
||||
subdir = .
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
@@ -96,11 +100,12 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
|
||||
$(am__configure_deps) $(include_HEADERS) $(am__DIST_COMMON)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/src/libssh2_config.h \
|
||||
$(top_builddir)/example/libssh2_config.h
|
||||
CONFIG_HEADER = $(top_builddir)/src/libssh2_config.h
|
||||
CONFIG_CLEAN_FILES = libssh2.pc
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
@@ -168,7 +173,7 @@ am__recursive_targets = \
|
||||
$(RECURSIVE_CLEAN_TARGETS) \
|
||||
$(am__extra_recursive_targets)
|
||||
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
|
||||
cscope distdir dist dist-all distcheck
|
||||
cscope distdir distdir-am dist dist-all distcheck
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
@@ -186,10 +191,11 @@ am__define_uniq_tagged_files = \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
CSCOPE = cscope
|
||||
DIST_SUBDIRS = src tests docs example
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.inc \
|
||||
$(srcdir)/libssh2.pc.in COPYING ChangeLog NEWS README compile \
|
||||
config.guess config.rpath config.sub depcomp install-sh \
|
||||
ltmain.sh missing
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
@@ -228,6 +234,8 @@ am__relativize = \
|
||||
DIST_ARCHIVES = $(distdir).tar.gz
|
||||
GZIP_ENV = --best
|
||||
DIST_TARGETS = dist-gzip
|
||||
# Exists only to be overridden by the user if desired.
|
||||
AM_DISTCHECK_DVI_TARGET = dvi
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
|
||||
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
|
||||
@@ -247,6 +255,12 @@ CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
@@ -257,12 +271,14 @@ ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_LIBBCRYPT = @HAVE_LIBBCRYPT@
|
||||
HAVE_LIBCRYPT32 = @HAVE_LIBCRYPT32@
|
||||
HAVE_LIBGCRYPT = @HAVE_LIBGCRYPT@
|
||||
HAVE_LIBMBEDCRYPTO = @HAVE_LIBMBEDCRYPTO@
|
||||
HAVE_LIBSSL = @HAVE_LIBSSL@
|
||||
HAVE_LIBZ = @HAVE_LIBZ@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -278,6 +294,8 @@ LIBCRYPT32 = @LIBCRYPT32@
|
||||
LIBCRYPT32_PREFIX = @LIBCRYPT32_PREFIX@
|
||||
LIBGCRYPT = @LIBGCRYPT@
|
||||
LIBGCRYPT_PREFIX = @LIBGCRYPT_PREFIX@
|
||||
LIBMBEDCRYPTO = @LIBMBEDCRYPTO@
|
||||
LIBMBEDCRYPTO_PREFIX = @LIBMBEDCRYPTO_PREFIX@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBSREQUIRED = @LIBSREQUIRED@
|
||||
@@ -287,14 +305,17 @@ LIBSSL_PREFIX = @LIBSSL_PREFIX@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBZ = @LIBZ@
|
||||
LIBZ_PREFIX = @LIBZ_PREFIX@
|
||||
LIB_FUZZING_ENGINE = @LIB_FUZZING_ENGINE@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBBCRYPT = @LTLIBBCRYPT@
|
||||
LTLIBCRYPT32 = @LTLIBCRYPT32@
|
||||
LTLIBGCRYPT = @LTLIBGCRYPT@
|
||||
LTLIBMBEDCRYPTO = @LTLIBMBEDCRYPTO@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LTLIBSSL = @LTLIBSSL@
|
||||
LTLIBZ = @LTLIBZ@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
@@ -326,6 +347,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
@@ -364,6 +386,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@@ -398,21 +421,34 @@ win32/libssh2_config.h win32/config.mk win32/rules.mk \
|
||||
win32/Makefile.Watcom win32/libssh2.dsw win32/tests.dsp $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk \
|
||||
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath
|
||||
OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \
|
||||
os400/make-src.sh os400/make-rpg.sh os400/make-include.sh \
|
||||
os400/os400sys.c os400/ccsid.c \
|
||||
os400/libssh2_config.h os400/macros.h os400/libssh2_ccsid.h \
|
||||
os400/include/alloca.h os400/include/sys/socket.h os400/include/stdio.h \
|
||||
os400/libssh2rpg/libssh2.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_ccsid.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_publickey.rpgle \
|
||||
os400/libssh2rpg/libssh2_sftp.rpgle \
|
||||
Makefile.os400qc3.inc
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) $(NETWAREFILES) get_ver.awk \
|
||||
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath \
|
||||
CMakeLists.txt cmake $(OS400FILES)
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
# DSP/VCPROJ generation adapted from libcurl
|
||||
# only OpenSSL and WinCNG are supported with this build system
|
||||
CRYPTO_CSOURCES = openssl.c wincng.c
|
||||
CRYPTO_HHEADERS = openssl.h wincng.h
|
||||
CRYPTO_CSOURCES = openssl.c wincng.c mbedtls.c
|
||||
CRYPTO_HHEADERS = openssl.h wincng.h mbedtls.h
|
||||
CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \
|
||||
packet.c publickey.c scp.c session.c sftp.c userauth.c transport.c \
|
||||
version.c knownhost.c agent.c $(CRYPTO_CSOURCES) pem.c keepalive.c global.c
|
||||
version.c knownhost.c agent.c $(CRYPTO_CSOURCES) pem.c keepalive.c global.c \
|
||||
blowfish.c bcrypt_pbkdf.c agent_win.c
|
||||
|
||||
HHEADERS = libssh2_priv.h $(CRYPTO_HHEADERS) transport.h channel.h comp.h \
|
||||
mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h
|
||||
mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h blf.h agent.h
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
WIN32SOURCES = $(CSOURCES)
|
||||
@@ -435,17 +471,16 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/Ma
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
echo ' $(SHELL) ./config.status'; \
|
||||
$(SHELL) ./config.status;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
|
||||
esac;
|
||||
$(srcdir)/Makefile.inc:
|
||||
$(srcdir)/Makefile.inc $(am__empty):
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
@@ -614,8 +649,10 @@ cscopelist-am: $(am__tagged_files)
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
distdir-am: $(DISTFILES)
|
||||
$(am__remove_distdir)
|
||||
test -d "$(distdir)" || mkdir "$(distdir)"
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
@@ -683,7 +720,7 @@ distdir: $(DISTFILES)
|
||||
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|
||||
|| chmod -R a+r "$(distdir)"
|
||||
dist-gzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-bzip2: distdir
|
||||
@@ -698,18 +735,22 @@ dist-xz: distdir
|
||||
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-zstd: distdir
|
||||
tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
@echo WARNING: "Support for shar distribution archives is" \
|
||||
"deprecated." >&2
|
||||
@echo WARNING: "Support for distribution archives compressed with" \
|
||||
"legacy program 'compress' is deprecated." >&2
|
||||
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
|
||||
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-shar: distdir
|
||||
@echo WARNING: "Support for distribution archives compressed with" \
|
||||
"legacy program 'compress' is deprecated." >&2
|
||||
@echo WARNING: "Support for shar distribution archives is" \
|
||||
"deprecated." >&2
|
||||
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
|
||||
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
|
||||
shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-zip: distdir
|
||||
@@ -727,7 +768,7 @@ dist dist-all:
|
||||
distcheck: dist
|
||||
case '$(DIST_ARCHIVES)' in \
|
||||
*.tar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
|
||||
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
|
||||
*.tar.bz2*) \
|
||||
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
*.tar.lz*) \
|
||||
@@ -737,25 +778,27 @@ distcheck: dist
|
||||
*.tar.Z*) \
|
||||
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||
*.shar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
|
||||
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
|
||||
*.zip*) \
|
||||
unzip $(distdir).zip ;;\
|
||||
*.tar.zst*) \
|
||||
zstd -dc $(distdir).tar.zst | $(am__untar) ;;\
|
||||
esac
|
||||
chmod -R a-w $(distdir)
|
||||
chmod u+w $(distdir)
|
||||
mkdir $(distdir)/_build $(distdir)/_inst
|
||||
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
|
||||
chmod a-w $(distdir)
|
||||
test -d $(distdir)/_build || exit 0; \
|
||||
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build \
|
||||
&& ../configure \
|
||||
&& $(am__cd) $(distdir)/_build/sub \
|
||||
&& ../../configure \
|
||||
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
--srcdir=.. --prefix="$$dc_install_base" \
|
||||
--srcdir=../.. --prefix="$$dc_install_base" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
@@ -921,7 +964,7 @@ uninstall-am: uninstall-includeHEADERS uninstall-pkgconfigDATA
|
||||
am--refresh check check-am clean clean-cscope clean-generic \
|
||||
clean-libtool cscope cscopelist-am ctags ctags-am dist \
|
||||
dist-all dist-bzip2 dist-gzip dist-hook dist-lzip dist-shar \
|
||||
dist-tarZ dist-xz dist-zip distcheck distclean \
|
||||
dist-tarZ dist-xz dist-zip dist-zstd distcheck distclean \
|
||||
distclean-generic distclean-libtool distclean-tags \
|
||||
distcleancheck distdir distuninstallcheck dvi dvi-am html \
|
||||
html-am info info-am install install-am install-data \
|
||||
@@ -935,6 +978,8 @@ uninstall-am: uninstall-includeHEADERS uninstall-pkgconfigDATA
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
|
||||
uninstall-am uninstall-includeHEADERS uninstall-pkgconfigDATA
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
.PHONY: ChangeLog
|
||||
ChangeLog:
|
||||
@@ -995,7 +1040,7 @@ $(DSP): win32/msvcproj.head win32/msvcproj.foot Makefile.am
|
||||
for file in $$sorted_hdrs; do \
|
||||
echo "# Begin Source File"; \
|
||||
echo ""; \
|
||||
if [ "$$file" == "libssh2_config.h" ]; \
|
||||
if [ "$$file" = "libssh2_config.h" ]; \
|
||||
then \
|
||||
echo "SOURCE=.\\"$$file; \
|
||||
else \
|
||||
@@ -1024,6 +1069,11 @@ $(VCPROJ): win32/vc8proj.head win32/vc8proj.foot Makefile.am
|
||||
cat $(srcdir)/vc8proj.foot) | \
|
||||
awk '{printf("%s\r\n", gensub("\r", "", "g"))}' > $@ )
|
||||
|
||||
checksrc:
|
||||
perl src/checksrc.pl -i4 -m79 -ASIZEOFNOPAREN -ASNPRINTF -ACOPYRIGHT \
|
||||
-AFOPENMODE -Wsrc/libssh2_config.h src/*.[ch] include/*.h example/*.c \
|
||||
tests/*.[ch]
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \
|
||||
packet.c publickey.c scp.c session.c sftp.c userauth.c transport.c \
|
||||
version.c knownhost.c agent.c $(CRYPTO_CSOURCES) pem.c keepalive.c global.c
|
||||
version.c knownhost.c agent.c $(CRYPTO_CSOURCES) pem.c keepalive.c global.c \
|
||||
blowfish.c bcrypt_pbkdf.c agent_win.c
|
||||
|
||||
HHEADERS = libssh2_priv.h $(CRYPTO_HHEADERS) transport.h channel.h comp.h \
|
||||
mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h
|
||||
mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h blf.h agent.h
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
CRYPTO_CSOURCES = libgcrypt.c
|
||||
CRYPTO_HHEADERS = libgcrypt.h
|
||||
CRYPTO_LTLIBS = $(LTLIBGCRYPT)
|
||||
|
||||
3
Makefile.mbedTLS.inc
Normal file
3
Makefile.mbedTLS.inc
Normal file
@@ -0,0 +1,3 @@
|
||||
CRYPTO_CSOURCES = mbedtls.c
|
||||
CRYPTO_HHEADERS = mbedtls.h
|
||||
CRYPTO_LTLIBS = $(LTLIBMBEDCRYPTO)
|
||||
2
Makefile.os400qc3.inc
Normal file
2
Makefile.os400qc3.inc
Normal file
@@ -0,0 +1,2 @@
|
||||
CRYPTO_CSOURCES = os400qc3.c
|
||||
CRYPTO_HHEADERS = os400qc3.h
|
||||
4
README
4
README
@@ -4,9 +4,9 @@ libssh2 - SSH2 library
|
||||
libssh2 is a library implementing the SSH2 protocol, available under
|
||||
the revised BSD license.
|
||||
|
||||
Web site: http://www.libssh2.org/
|
||||
Web site: https://www.libssh2.org/
|
||||
|
||||
Mailing list: http://cool.haxx.se/mailman/listinfo/libssh2-devel
|
||||
Mailing list: https://cool.haxx.se/mailman/listinfo/libssh2-devel
|
||||
|
||||
License: see COPYING
|
||||
|
||||
|
||||
12
README.md
12
README.md
@@ -1,12 +0,0 @@
|
||||
# libssh2
|
||||
|
||||
libssh2 is a client-side C library implementing the SSH2 protocol.
|
||||
|
||||
# Building for PHP
|
||||
|
||||
libssh2 depends on openssl and zlib. To build follow these steps:
|
||||
|
||||
* create a directory named "deps" at the level of the libssh2 source dir and put the dependencies there
|
||||
* build libssh2
|
||||
* use win32/libssh2.vcproj to build with VS2008
|
||||
* use win32/libssh2.vc11.sln to build with VS2012
|
||||
@@ -1,45 +1,62 @@
|
||||
libssh2 1.6.0
|
||||
libssh2 1.10
|
||||
|
||||
This release includes the following changes:
|
||||
This release includes the following enhancements and bugfixes:
|
||||
|
||||
o Added CMake build system
|
||||
o Added libssh2_userauth_publickey_frommemory()
|
||||
o adds agent forwarding support
|
||||
o adds OpenSSH Agent support on Windows
|
||||
o adds ECDSA key support using the Mbed TLS backend
|
||||
o adds ECDSA cert authentication
|
||||
o adds diffie-hellman-group14-sha256, diffie-hellman-group16-sha512,
|
||||
diffie-hellman-group18-sha512 key exchanges
|
||||
o adds support for PKIX key reading when using ed25519 with OpenSSL
|
||||
o adds support for EWOULDBLOCK on VMS systems
|
||||
o adds support for building with OpenSSL 3
|
||||
o adds support for using FIPS mode in OpenSSL
|
||||
o adds debug symbols when building with MSVC
|
||||
o adds support for building on the 3DS
|
||||
o adds unicode build support on Windows
|
||||
o restores os400 building
|
||||
o increases min, max and opt Diffie Hellman group values
|
||||
o improves portiablity of the make file
|
||||
o improves timeout behavior with 2FA keyboard auth
|
||||
o various improvements to the Wincng backend
|
||||
o fixes reading parital packet replies when using an agent
|
||||
o fixes Diffie Hellman key exchange on Windows 1903+ builds
|
||||
o fixes building tests with older versions of OpenSSL
|
||||
o fixes possible multiple definition warnings
|
||||
o fixes potential cast issues _libssh2_ecdsa_key_get_curve_type()
|
||||
o fixes potential use after free if libssh2_init() is called twice
|
||||
o improved linking when using Mbed TLS
|
||||
o fixes call to libssh2_crypto_exit() if crypto hasn't been initialized
|
||||
o fixes crash when loading public keys with no id
|
||||
o fixes possible out of bounds read when exchanging keys
|
||||
o fixes possible out of bounds read when reading packets
|
||||
o fixes possible out of bounds read when opening an X11 connection
|
||||
o fixes possible out of bounds read when ecdh host keys
|
||||
o fixes possible hang when trying to read a disconnected socket
|
||||
o fixes a crash when using the delayed compression option
|
||||
o fixes read error with large known host entries
|
||||
o fixes various warnings
|
||||
o fixes various small memory leaks
|
||||
o improved error handling, various detailed errors will now be reported
|
||||
o builds are now using OSS-Fuzz
|
||||
o builds now use autoreconf instead of a custom build script
|
||||
o cmake now respects install directory
|
||||
o improved CI backend
|
||||
o updated HACKING-CRYPTO documentation
|
||||
o use markdown file extensions
|
||||
o improved unit tests
|
||||
|
||||
This release includes the following bugfixes:
|
||||
|
||||
o wait_socket: wrong use of difftime() [1]
|
||||
o userauth: Fixed prompt text no longer being copied to the prompts struct
|
||||
o mingw build: allow to pass custom CFLAGS
|
||||
o Let mansyntax.sh work regardless of where it is called from
|
||||
o Init HMAC_CTX before using it
|
||||
o direct_tcpip: Fixed channel write
|
||||
o WinCNG: fixed backend breakage
|
||||
o OpenSSL: caused by introducing libssh2_hmac_ctx_init
|
||||
o userauth.c: fix possible dereferences of a null pointer
|
||||
o wincng: Added explicit clear memory feature to WinCNG backend
|
||||
o openssl.c: fix possible segfault in case EVP_DigestInit fails
|
||||
o wincng: fix return code of libssh2_md5_init()
|
||||
o kex: do not ignore failure of libssh2_sha1_init()
|
||||
o scp: fix that scp_send may transmit not initialised memory [3]
|
||||
o scp.c: improved command length calculation
|
||||
o nonblocking examples: fix warning about unused tvdiff on Mac OS X
|
||||
o configure: make clear-memory default but WARN if backend unsupported
|
||||
o OpenSSL: Enable use of OpenSSL that doesn't have DSA
|
||||
o OpenSSL: Use correct no-blowfish #define
|
||||
o kex: fix libgcrypt memory leaks of bignum [2]
|
||||
o libssh2_channel_open: more detailed error message
|
||||
o wincng: fixed memleak in (block) cipher destructor
|
||||
|
||||
|
||||
This release would not have looked like this without help, code, reports and
|
||||
advice from friends like these:
|
||||
|
||||
Alexander Lamaison, Daniel Stenberg, David Calavera, Hannes Domani,
|
||||
Jakob Egger, Joe Turpin, Marc Hoersken, Viktor Szakáts, Will Cosgrove,
|
||||
(9 contributors)
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
katzer, Orgad Shaneh, mark-i-m, Zenju, axjowa, Thilo Schulz,
|
||||
Etienne Samson, hlefebvre, seba30, Panos, jethrogb, Fabrice Fontaine,
|
||||
Will Cosgrove, Daniel Stenberg, Michael Buckley, Wallace Souza Silva,
|
||||
Romain-Geissler-1A, meierha, Tseng Jun, Thomas Klausner, Brendan Shanks,
|
||||
Harry Sintonen, monnerat, Koutheir Attouchi, Marc Hörsken, yann-morin-1998,
|
||||
Wez Furlong, TDi-jonesds, David Benjamin, Max Dymond, Igor Klevanets,
|
||||
Viktor Szakats, Laurent Stacul, Mstrodl, Gabriel Smith, MarcT512,
|
||||
Paul Capron, teottin, Tor Erik Ottinsen, Brian Inglis
|
||||
|
||||
[1] = https://github.com/bagder/libssh2/issues/1
|
||||
[2] = https://trac.libssh2.org/ticket/168
|
||||
[3] = https://trac.libssh2.org/ticket/244
|
||||
(40 contributors)
|
||||
|
||||
128
acinclude.m4
128
acinclude.m4
@@ -382,3 +382,131 @@ AC_DEFUN([CURL_CONFIGURE_REENTRANT], [
|
||||
#
|
||||
])
|
||||
|
||||
dnl LIBSSH2_LIB_HAVE_LINKFLAGS
|
||||
dnl --------------------------
|
||||
dnl Wrapper around AC_LIB_HAVE_LINKFLAGS to also check $prefix/lib, if set.
|
||||
dnl
|
||||
dnl autoconf only checks $prefix/lib64 if gcc -print-search-dirs output
|
||||
dnl includes a directory named lib64. So, to find libraries in $prefix/lib
|
||||
dnl we append -L$prefix/lib to LDFLAGS before checking.
|
||||
dnl
|
||||
dnl For conveniece, $4 is expanded if [lib]$1 is found.
|
||||
|
||||
AC_DEFUN([LIBSSH2_LIB_HAVE_LINKFLAGS], [
|
||||
libssh2_save_CPPFLAGS="$CPPFLAGS"
|
||||
libssh2_save_LDFLAGS="$LDFLAGS"
|
||||
|
||||
if test "${with_lib$1_prefix+set}" = set; then
|
||||
CPPFLAGS="$CPPFLAGS${CPPFLAGS:+ }-I${with_lib$1_prefix}/include"
|
||||
LDFLAGS="$LDFLAGS${LDFLAGS:+ }-L${with_lib$1_prefix}/lib"
|
||||
fi
|
||||
|
||||
AC_LIB_HAVE_LINKFLAGS([$1], [$2], [$3])
|
||||
|
||||
LDFLAGS="$libssh2_save_LDFLAGS"
|
||||
|
||||
if test "$ac_cv_lib$1" = "yes"; then :
|
||||
$4
|
||||
else
|
||||
CPPFLAGS="$libssh2_save_CPPFLAGS"
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([LIBSSH2_CHECK_CRYPTO], [
|
||||
if test "$use_crypto" = "auto" && test "$found_crypto" = "none" || test "$use_crypto" = "$1"; then
|
||||
m4_case([$1],
|
||||
[openssl], [
|
||||
LIBSSH2_LIB_HAVE_LINKFLAGS([ssl], [crypto], [#include <openssl/ssl.h>], [
|
||||
AC_DEFINE(LIBSSH2_OPENSSL, 1, [Use $1])
|
||||
LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }libssl libcrypto"
|
||||
|
||||
# Not all OpenSSL have AES-CTR functions.
|
||||
libssh2_save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $LIBSSL"
|
||||
AC_CHECK_FUNCS(EVP_aes_128_ctr)
|
||||
LIBS="$libssh2_save_LIBS"
|
||||
|
||||
found_crypto="$1"
|
||||
found_crypto_str="OpenSSL (AES-CTR: ${ac_cv_func_EVP_aes_128_ctr:-N/A})"
|
||||
])
|
||||
],
|
||||
|
||||
[libgcrypt], [
|
||||
LIBSSH2_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>], [
|
||||
AC_DEFINE(LIBSSH2_LIBGCRYPT, 1, [Use $1])
|
||||
found_crypto="$1"
|
||||
])
|
||||
],
|
||||
|
||||
[mbedtls], [
|
||||
LIBSSH2_LIB_HAVE_LINKFLAGS([mbedcrypto], [], [#include <mbedtls/version.h>], [
|
||||
AC_DEFINE(LIBSSH2_MBEDTLS, 1, [Use $1])
|
||||
LIBS="$LIBS -lmbedcrypto"
|
||||
found_crypto="$1"
|
||||
support_clear_memory=yes
|
||||
])
|
||||
],
|
||||
|
||||
[wincng], [
|
||||
# Look for Windows Cryptography API: Next Generation
|
||||
|
||||
AC_CHECK_HEADERS([ntdef.h ntstatus.h], [], [], [#include <windows.h>])
|
||||
AC_CHECK_DECLS([SecureZeroMemory], [], [], [#include <windows.h>])
|
||||
|
||||
LIBSSH2_LIB_HAVE_LINKFLAGS([crypt32], [], [
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
])
|
||||
LIBSSH2_LIB_HAVE_LINKFLAGS([bcrypt], [], [
|
||||
#include <windows.h>
|
||||
#include <bcrypt.h>
|
||||
], [
|
||||
AC_DEFINE(LIBSSH2_WINCNG, 1, [Use $1])
|
||||
found_crypto="$1"
|
||||
found_crypto_str="Windows Cryptography API: Next Generation"
|
||||
support_clear_memory="$ac_cv_have_decl_SecureZeroMemory"
|
||||
])
|
||||
],
|
||||
)
|
||||
test "$found_crypto" = "none" &&
|
||||
crypto_errors="${crypto_errors}No $1 crypto library found!
|
||||
"
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl LIBSSH2_CHECK_OPTION_WERROR
|
||||
dnl -------------------------------------------------
|
||||
dnl Verify if configure has been invoked with option
|
||||
dnl --enable-werror or --disable-werror, and set
|
||||
dnl shell variable want_werror as appropriate.
|
||||
|
||||
AC_DEFUN([LIBSSH2_CHECK_OPTION_WERROR], [
|
||||
AC_BEFORE([$0],[LIBSSH2_CHECK_COMPILER])dnl
|
||||
AC_MSG_CHECKING([whether to enable compiler warnings as errors])
|
||||
OPT_COMPILER_WERROR="default"
|
||||
AC_ARG_ENABLE(werror,
|
||||
AC_HELP_STRING([--enable-werror],[Enable compiler warnings as errors])
|
||||
AC_HELP_STRING([--disable-werror],[Disable compiler warnings as errors]),
|
||||
OPT_COMPILER_WERROR=$enableval)
|
||||
case "$OPT_COMPILER_WERROR" in
|
||||
no)
|
||||
dnl --disable-werror option used
|
||||
want_werror="no"
|
||||
;;
|
||||
default)
|
||||
dnl configure option not specified
|
||||
want_werror="no"
|
||||
;;
|
||||
*)
|
||||
dnl --enable-werror option used
|
||||
want_werror="yes"
|
||||
;;
|
||||
esac
|
||||
AC_MSG_RESULT([$want_werror])
|
||||
|
||||
if test X"$want_werror" = Xyes; then
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
229
aclocal.m4
vendored
229
aclocal.m4
vendored
@@ -1,6 +1,6 @@
|
||||
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
|
||||
# generated automatically by aclocal 1.16.4 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -14,13 +14,13 @@
|
||||
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
|
||||
[m4_warning([this file was generated for autoconf 2.69.
|
||||
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],,
|
||||
[m4_warning([this file was generated for autoconf 2.71.
|
||||
You have another version of autoconf. It may work, but is not guaranteed to.
|
||||
If you have problems, you may need to regenerate the build system entirely.
|
||||
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
|
||||
|
||||
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
|
||||
# generated from the m4 files accompanying Automake X.Y.
|
||||
# (This private macro should not be called outside this file.)
|
||||
AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||
[am__api_version='1.14'
|
||||
[am__api_version='1.16'
|
||||
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||
dnl require some minimum version. Point them to the right macro.
|
||||
m4_if([$1], [1.14.1], [],
|
||||
m4_if([$1], [1.16.4], [],
|
||||
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||
])
|
||||
|
||||
@@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
|
||||
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
|
||||
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||
[AM_AUTOMAKE_VERSION([1.14.1])dnl
|
||||
[AM_AUTOMAKE_VERSION([1.16.4])dnl
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
||||
|
||||
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
|
||||
|
||||
# AM_CONDITIONAL -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -141,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
|
||||
Usually this means the macro was only invoked conditionally.]])
|
||||
fi])])
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -332,13 +332,12 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
|
||||
|
||||
# Generate code to set up dependency tracking. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
|
||||
# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
# ------------------------------
|
||||
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
@@ -346,49 +345,43 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
# Older Autoconf quotes --file arguments for eval, but not when files
|
||||
# are listed without --file. Let's play safe and only enable the eval
|
||||
# if we detect the quoting.
|
||||
case $CONFIG_FILES in
|
||||
*\'*) eval set x "$CONFIG_FILES" ;;
|
||||
*) set x $CONFIG_FILES ;;
|
||||
esac
|
||||
# TODO: see whether this extra hack can be removed once we start
|
||||
# requiring Autoconf 2.70 or later.
|
||||
AS_CASE([$CONFIG_FILES],
|
||||
[*\'*], [eval set x "$CONFIG_FILES"],
|
||||
[*], [set x $CONFIG_FILES])
|
||||
shift
|
||||
for mf
|
||||
# Used to flag and report bootstrapping failures.
|
||||
am_rc=0
|
||||
for am_mf
|
||||
do
|
||||
# Strip MF so we end up with the name of the file.
|
||||
mf=`echo "$mf" | sed -e 's/:.*$//'`
|
||||
# Check whether this is an Automake generated Makefile or not.
|
||||
# We used to match only the files named 'Makefile.in', but
|
||||
# some people rename them; so instead we look at the file content.
|
||||
# Grep'ing the first line is not enough: some people post-process
|
||||
# each Makefile.in and add a new line on top of each file to say so.
|
||||
# Grep'ing the whole file is not good either: AIX grep has a line
|
||||
am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'`
|
||||
# Check whether this is an Automake generated Makefile which includes
|
||||
# dependency-tracking related rules and includes.
|
||||
# Grep'ing the whole file directly is not great: AIX grep has a line
|
||||
# limit of 2048, but all sed's we know have understand at least 4000.
|
||||
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
|
||||
dirpart=`AS_DIRNAME("$mf")`
|
||||
else
|
||||
continue
|
||||
fi
|
||||
# Extract the definition of DEPDIR, am__include, and am__quote
|
||||
# from the Makefile without running 'make'.
|
||||
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
|
||||
test -z "$DEPDIR" && continue
|
||||
am__include=`sed -n 's/^am__include = //p' < "$mf"`
|
||||
test -z "$am__include" && continue
|
||||
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
|
||||
# Find all dependency output files, they are included files with
|
||||
# $(DEPDIR) in their names. We invoke sed twice because it is the
|
||||
# simplest approach to changing $(DEPDIR) to its actual value in the
|
||||
# expansion.
|
||||
for file in `sed -n "
|
||||
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
|
||||
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
|
||||
# Make sure the directory exists.
|
||||
test -f "$dirpart/$file" && continue
|
||||
fdir=`AS_DIRNAME(["$file"])`
|
||||
AS_MKDIR_P([$dirpart/$fdir])
|
||||
# echo "creating $dirpart/$file"
|
||||
echo '# dummy' > "$dirpart/$file"
|
||||
done
|
||||
sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \
|
||||
|| continue
|
||||
am_dirpart=`AS_DIRNAME(["$am_mf"])`
|
||||
am_filepart=`AS_BASENAME(["$am_mf"])`
|
||||
AM_RUN_LOG([cd "$am_dirpart" \
|
||||
&& sed -e '/# am--include-marker/d' "$am_filepart" \
|
||||
| $MAKE -f - am--depfiles]) || am_rc=$?
|
||||
done
|
||||
if test $am_rc -ne 0; then
|
||||
AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments
|
||||
for automatic dependency tracking. If GNU make was not used, consider
|
||||
re-running the configure script with MAKE="gmake" (or whatever is
|
||||
necessary). You can also try re-running configure with the
|
||||
'--disable-dependency-tracking' option to at least be able to build
|
||||
the package (albeit without support for automatic dependency tracking).])
|
||||
fi
|
||||
AS_UNSET([am_dirpart])
|
||||
AS_UNSET([am_filepart])
|
||||
AS_UNSET([am_mf])
|
||||
AS_UNSET([am_rc])
|
||||
rm -f conftest-deps.mk
|
||||
}
|
||||
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
|
||||
@@ -397,18 +390,17 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
# -----------------------------
|
||||
# This macro should only be invoked once -- use via AC_REQUIRE.
|
||||
#
|
||||
# This code is only required when automatic dependency tracking
|
||||
# is enabled. FIXME. This creates each '.P' file that we will
|
||||
# need in order to bootstrap the dependency handling code.
|
||||
# This code is only required when automatic dependency tracking is enabled.
|
||||
# This creates each '.Po' and '.Plo' makefile fragment that we'll need in
|
||||
# order to bootstrap the dependency handling code.
|
||||
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
[AC_CONFIG_COMMANDS([depfiles],
|
||||
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
|
||||
])
|
||||
[AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])])
|
||||
|
||||
# Do all the work for Automake. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -472,7 +464,7 @@ m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
|
||||
[_AM_SET_OPTIONS([$1])dnl
|
||||
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
|
||||
m4_if(
|
||||
m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
|
||||
m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
|
||||
[ok:ok],,
|
||||
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
|
||||
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
|
||||
@@ -495,11 +487,11 @@ AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
|
||||
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
|
||||
# For better backward compatibility. To be removed once Automake 1.9.x
|
||||
# dies out for good. For more background, see:
|
||||
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
|
||||
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
|
||||
# <https://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
|
||||
# <https://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
|
||||
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
|
||||
# We need awk for the "check" target. The system "awk" is bad on
|
||||
# some platforms.
|
||||
# We need awk for the "check" target (and possibly the TAP driver). The
|
||||
# system "awk" is bad on some platforms.
|
||||
AC_REQUIRE([AC_PROG_AWK])dnl
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
|
||||
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||
@@ -524,6 +516,20 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
|
||||
[m4_define([AC_PROG_OBJCXX],
|
||||
m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
|
||||
])
|
||||
# Variables for tags utilities; see am/tags.am
|
||||
if test -z "$CTAGS"; then
|
||||
CTAGS=ctags
|
||||
fi
|
||||
AC_SUBST([CTAGS])
|
||||
if test -z "$ETAGS"; then
|
||||
ETAGS=etags
|
||||
fi
|
||||
AC_SUBST([ETAGS])
|
||||
if test -z "$CSCOPE"; then
|
||||
CSCOPE=cscope
|
||||
fi
|
||||
AC_SUBST([CSCOPE])
|
||||
|
||||
AC_REQUIRE([AM_SILENT_RULES])dnl
|
||||
dnl The testsuite driver may need to know about EXEEXT, so add the
|
||||
dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
|
||||
@@ -563,7 +569,7 @@ END
|
||||
Aborting the configuration process, to ensure you take notice of the issue.
|
||||
|
||||
You can download and install GNU coreutils to get an 'rm' implementation
|
||||
that behaves properly: <http://www.gnu.org/software/coreutils/>.
|
||||
that behaves properly: <https://www.gnu.org/software/coreutils/>.
|
||||
|
||||
If you want to complete the configuration process using your problematic
|
||||
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
|
||||
@@ -573,6 +579,9 @@ END
|
||||
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
|
||||
fi
|
||||
fi
|
||||
dnl The trailing newline in this macro's definition is deliberate, for
|
||||
dnl backward compatibility and to allow trailing 'dnl'-style comments
|
||||
dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
|
||||
])
|
||||
|
||||
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
|
||||
@@ -602,7 +611,7 @@ for _am_header in $config_headers :; do
|
||||
done
|
||||
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -613,7 +622,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
|
||||
# Define $install_sh.
|
||||
AC_DEFUN([AM_PROG_INSTALL_SH],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
if test x"${install_sh}" != xset; then
|
||||
if test x"${install_sh+set}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
|
||||
@@ -623,7 +632,7 @@ if test x"${install_sh}" != xset; then
|
||||
fi
|
||||
AC_SUBST([install_sh])])
|
||||
|
||||
# Copyright (C) 2003-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -645,7 +654,7 @@ AC_SUBST([am__leading_dot])])
|
||||
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
|
||||
# From Jim Meyering
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -680,7 +689,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
|
||||
|
||||
# Check to see how 'make' treats includes. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -688,49 +697,42 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
|
||||
|
||||
# AM_MAKE_INCLUDE()
|
||||
# -----------------
|
||||
# Check to see how make treats includes.
|
||||
# Check whether make has an 'include' directive that can support all
|
||||
# the idioms we need for our automatic dependency tracking code.
|
||||
AC_DEFUN([AM_MAKE_INCLUDE],
|
||||
[am_make=${MAKE-make}
|
||||
cat > confinc << 'END'
|
||||
[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive])
|
||||
cat > confinc.mk << 'END'
|
||||
am__doit:
|
||||
@echo this is the am__doit target
|
||||
@echo this is the am__doit target >confinc.out
|
||||
.PHONY: am__doit
|
||||
END
|
||||
# If we don't find an include directive, just comment out the code.
|
||||
AC_MSG_CHECKING([for style of include used by $am_make])
|
||||
am__include="#"
|
||||
am__quote=
|
||||
_am_result=none
|
||||
# First try GNU make style include.
|
||||
echo "include confinc" > confmf
|
||||
# Ignore all kinds of additional output from 'make'.
|
||||
case `$am_make -s -f confmf 2> /dev/null` in #(
|
||||
*the\ am__doit\ target*)
|
||||
am__include=include
|
||||
am__quote=
|
||||
_am_result=GNU
|
||||
;;
|
||||
esac
|
||||
# Now try BSD make style include.
|
||||
if test "$am__include" = "#"; then
|
||||
echo '.include "confinc"' > confmf
|
||||
case `$am_make -s -f confmf 2> /dev/null` in #(
|
||||
*the\ am__doit\ target*)
|
||||
am__include=.include
|
||||
am__quote="\""
|
||||
_am_result=BSD
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
AC_SUBST([am__include])
|
||||
AC_SUBST([am__quote])
|
||||
AC_MSG_RESULT([$_am_result])
|
||||
rm -f confinc confmf
|
||||
])
|
||||
# BSD make does it like this.
|
||||
echo '.include "confinc.mk" # ignored' > confmf.BSD
|
||||
# Other make implementations (GNU, Solaris 10, AIX) do it like this.
|
||||
echo 'include confinc.mk # ignored' > confmf.GNU
|
||||
_am_result=no
|
||||
for s in GNU BSD; do
|
||||
AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out])
|
||||
AS_CASE([$?:`cat confinc.out 2>/dev/null`],
|
||||
['0:this is the am__doit target'],
|
||||
[AS_CASE([$s],
|
||||
[BSD], [am__include='.include' am__quote='"'],
|
||||
[am__include='include' am__quote=''])])
|
||||
if test "$am__include" != "#"; then
|
||||
_am_result="yes ($s style)"
|
||||
break
|
||||
fi
|
||||
done
|
||||
rm -f confinc.* confmf.*
|
||||
AC_MSG_RESULT([${_am_result}])
|
||||
AC_SUBST([am__include])])
|
||||
AC_SUBST([am__quote])])
|
||||
|
||||
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -751,12 +753,7 @@ AC_DEFUN([AM_MISSING_HAS_RUN],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
AC_REQUIRE_AUX_FILE([missing])dnl
|
||||
if test x"${MISSING+set}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
|
||||
*)
|
||||
MISSING="\${SHELL} $am_aux_dir/missing" ;;
|
||||
esac
|
||||
MISSING="\${SHELL} '$am_aux_dir/missing'"
|
||||
fi
|
||||
# Use eval to expand $SHELL
|
||||
if eval "$MISSING --is-lightweight"; then
|
||||
@@ -769,7 +766,7 @@ fi
|
||||
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -798,7 +795,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
|
||||
AC_DEFUN([_AM_IF_OPTION],
|
||||
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -845,7 +842,7 @@ AC_LANG_POP([C])])
|
||||
# For backward compatibility.
|
||||
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -864,7 +861,7 @@ AC_DEFUN([AM_RUN_LOG],
|
||||
|
||||
# Check to make sure that the build environment is sane. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -945,7 +942,7 @@ AC_CONFIG_COMMANDS_PRE(
|
||||
rm -f conftest.file
|
||||
])
|
||||
|
||||
# Copyright (C) 2009-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2009-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -1005,7 +1002,7 @@ AC_SUBST([AM_BACKSLASH])dnl
|
||||
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
|
||||
])
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -1033,7 +1030,7 @@ fi
|
||||
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||
|
||||
# Copyright (C) 2006-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -1052,7 +1049,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
|
||||
|
||||
# Check how to create a tarball. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2004-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
||||
22
buildconf
22
buildconf
@@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LIBTOOLIZE="libtoolize"
|
||||
|
||||
if [ "x`which $LIBTOOLIZE`" = "x" ]; then
|
||||
LIBTOOLIZE="glibtoolize"
|
||||
fi
|
||||
|
||||
if [ "x`which $LIBTOOLIZE`" = "x" ]; then
|
||||
echo "Neither libtoolize nor glibtoolize could be found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
${LIBTOOLIZE} --copy --automake --force
|
||||
${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS
|
||||
${AUTOHEADER:-autoheader}
|
||||
# copy the private libssh2_config.h.in to the examples dir so that
|
||||
# it can be included without pointing the include path to the private
|
||||
# source dir
|
||||
cp src/libssh2_config.h.in example/libssh2_config.h.in
|
||||
${AUTOCONF:-autoconf}
|
||||
${AUTOMAKE:-automake} --add-missing --copy
|
||||
81
cmake/CheckFunctionExistsMayNeedLibrary.cmake
Normal file
81
cmake/CheckFunctionExistsMayNeedLibrary.cmake
Normal file
@@ -0,0 +1,81 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
|
||||
# - check_function_exists_maybe_need_library(<function> <var> [lib1 ... libn])
|
||||
#
|
||||
# Check if function is available for linking, first without extra libraries, and
|
||||
# then, if not found that way, linking in each optional library as well. This
|
||||
# function is similar to autotools AC_SEARCH_LIBS.
|
||||
#
|
||||
# If the function if found, this will define <var>.
|
||||
#
|
||||
# If the function was only found by linking in an additional library, this
|
||||
# will define NEED_LIB_LIBX, where LIBX is the one of lib1 to libn that
|
||||
# makes the function available, in uppercase.
|
||||
#
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
#
|
||||
|
||||
include(CheckFunctionExists)
|
||||
include(CheckLibraryExists)
|
||||
|
||||
function(check_function_exists_may_need_library function variable)
|
||||
|
||||
check_function_exists(${function} ${variable})
|
||||
|
||||
if(NOT ${variable})
|
||||
foreach(lib ${ARGN})
|
||||
string(TOUPPER ${lib} UP_LIB)
|
||||
# Use new variable to prevent cache from previous step shortcircuiting
|
||||
# new test
|
||||
check_library_exists(${lib} ${function} "" HAVE_${function}_IN_${lib})
|
||||
if(HAVE_${function}_IN_${lib})
|
||||
set(${variable} 1 CACHE INTERNAL
|
||||
"Function ${function} found in library ${lib}")
|
||||
set(NEED_LIB_${UP_LIB} 1 CACHE INTERNAL
|
||||
"Need to link ${lib}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
119
cmake/CheckNonblockingSocketSupport.cmake
Normal file
119
cmake/CheckNonblockingSocketSupport.cmake
Normal file
@@ -0,0 +1,119 @@
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
# - check_nonblocking_socket_support()
|
||||
#
|
||||
# Check for how to set a socket to non-blocking state. There seems to exist
|
||||
# four known different ways, with the one used almost everywhere being POSIX
|
||||
# and XPG3, while the other different ways for different systems (old BSD,
|
||||
# Windows and Amiga).
|
||||
#
|
||||
# One of the following variables will be set indicating the supported
|
||||
# method (if any):
|
||||
# HAVE_O_NONBLOCK
|
||||
# HAVE_FIONBIO
|
||||
# HAVE_IOCTLSOCKET
|
||||
# HAVE_IOCTLSOCKET_CASE
|
||||
# HAVE_SO_NONBLOCK
|
||||
# HAVE_DISABLED_NONBLOCKING
|
||||
#
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
#
|
||||
macro(check_nonblocking_socket_support)
|
||||
# There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
|
||||
# O_NONBLOCK define is found but does not work.
|
||||
check_c_source_compiles("
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
|
||||
# if defined(__SVR4) || defined(__srv4__)
|
||||
# define PLATFORM_SOLARIS
|
||||
# else
|
||||
# define PLATFORM_SUNOS4
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
|
||||
# define PLATFORM_AIX_V3
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
|
||||
#error \"O_NONBLOCK does not work on this platform\"
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int socket;
|
||||
int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
|
||||
}"
|
||||
HAVE_O_NONBLOCK)
|
||||
|
||||
if(NOT HAVE_O_NONBLOCK)
|
||||
check_c_source_compiles("/* FIONBIO test (old-style unix) */
|
||||
#include <unistd.h>
|
||||
#include <stropts.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int socket;
|
||||
int flags = ioctl(socket, FIONBIO, &flags);
|
||||
}"
|
||||
HAVE_FIONBIO)
|
||||
|
||||
if(NOT HAVE_FIONBIO)
|
||||
check_c_source_compiles("/* ioctlsocket test (Windows) */
|
||||
#undef inline
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
SOCKET sd;
|
||||
unsigned long flags = 0;
|
||||
sd = socket(0, 0, 0);
|
||||
ioctlsocket(sd, FIONBIO, &flags);
|
||||
}"
|
||||
HAVE_IOCTLSOCKET)
|
||||
|
||||
if(NOT HAVE_IOCTLSOCKET)
|
||||
check_c_source_compiles("/* IoctlSocket test (Amiga?) */
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int socket;
|
||||
int flags = IoctlSocket(socket, FIONBIO, (long)1);
|
||||
}"
|
||||
HAVE_IOCTLSOCKET_CASE)
|
||||
|
||||
if(NOT HAVE_IOCTLSOCKET_CASE)
|
||||
check_c_source_compiles("/* SO_NONBLOCK test (BeOS) */
|
||||
#include <socket.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
long b = 1;
|
||||
int socket;
|
||||
int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
|
||||
}"
|
||||
HAVE_SO_NONBLOCK)
|
||||
|
||||
if(NOT HAVE_SO_NONBLOCK)
|
||||
# No non-blocking socket method found
|
||||
set(HAVE_DISABLED_NONBLOCKING 1)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
72
cmake/CopyRuntimeDependencies.cmake
Normal file
72
cmake/CopyRuntimeDependencies.cmake
Normal file
@@ -0,0 +1,72 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(ADD_TARGET_TO_COPY_DEPENDENCIES)
|
||||
set(options)
|
||||
set(oneValueArgs TARGET)
|
||||
set(multiValueArgs DEPENDENCIES BEFORE_TARGETS)
|
||||
cmake_parse_arguments(COPY
|
||||
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT COPY_DEPENDENCIES)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Using a custom target to drive custom commands stops multiple
|
||||
# parallel builds trying to kick off the commands at the same time
|
||||
add_custom_target(${COPY_TARGET})
|
||||
|
||||
foreach(target ${COPY_BEFORE_TARGETS})
|
||||
add_dependencies(${target} ${COPY_TARGET})
|
||||
endforeach()
|
||||
|
||||
foreach(dependency ${COPY_DEPENDENCIES})
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${COPY_TARGET}
|
||||
DEPENDS ${dependency}
|
||||
# Make directory first otherwise file is copied in place of
|
||||
# directory instead of into it
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy ${dependency} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
|
||||
VERBATIM)
|
||||
|
||||
endforeach()
|
||||
|
||||
endfunction()
|
||||
53
cmake/FindLibgcrypt.cmake
Normal file
53
cmake/FindLibgcrypt.cmake
Normal file
@@ -0,0 +1,53 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
# - Try to find Libgcrypt
|
||||
# This will define all or none of:
|
||||
# LIBGCRYPT_FOUND - if Libgcrypt headers and library was found
|
||||
# LIBGCRYPT_INCLUDE_DIRS - The Libgcrypt include directories
|
||||
# LIBGCRYPT_LIBRARIES - The libraries needed to use Libgcrypt
|
||||
|
||||
find_path(LIBGCRYPT_INCLUDE_DIR gcrypt.h)
|
||||
|
||||
find_library(LIBGCRYPT_LIBRARY NAMES gcrypt libgcrypt)
|
||||
|
||||
set(LIBGCRYPT_LIBRARIES ${LIBGCRYPT_LIBRARY})
|
||||
set(LIBGCRYPT_INCLUDE_DIRS ${LIBGCRYPT_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libgcrypt DEFAULT_MSG
|
||||
LIBGCRYPT_LIBRARY LIBGCRYPT_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LIBGCRYPT_INCLUDE_DIR LIBGCRYPT_LIBRARY)
|
||||
64
cmake/FindmbedTLS.cmake
Normal file
64
cmake/FindmbedTLS.cmake
Normal file
@@ -0,0 +1,64 @@
|
||||
# - Try to find mbedTLS
|
||||
# Once done this will define
|
||||
#
|
||||
# Read-Only variables
|
||||
# MBEDTLS_FOUND - system has mbedTLS
|
||||
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
|
||||
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
|
||||
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
|
||||
# MBEDTLS_LIBRARY - path to mbedTLS library
|
||||
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
|
||||
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
|
||||
|
||||
FIND_PATH(MBEDTLS_INCLUDE_DIR mbedtls/version.h)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(MBEDTLS_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
FIND_LIBRARY(MBEDTLS_LIBRARY NAMES mbedtls libmbedtls libmbedx509)
|
||||
FIND_LIBRARY(MBEDX509_LIBRARY NAMES mbedx509 libmbedx509)
|
||||
FIND_LIBRARY(MBEDCRYPTO_LIBRARY NAMES mbedcrypto libmbedcrypto)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
|
||||
SET(MBEDTLS_FOUND TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(MBEDTLS_FOUND)
|
||||
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
|
||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
|
||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
|
||||
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
|
||||
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
|
||||
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
|
||||
|
||||
IF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found mbedTLS:")
|
||||
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
|
||||
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
|
||||
IF (MBEDTLSMATCH)
|
||||
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
|
||||
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
|
||||
ENDIF(MBEDTLSMATCH)
|
||||
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
|
||||
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
|
||||
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
|
||||
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
ELSE(MBEDTLS_FOUND)
|
||||
IF(MBEDTLS_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
|
||||
ENDIF(MBEDTLS_FIND_REQUIRED)
|
||||
ENDIF(MBEDTLS_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MBEDTLS_INCLUDE_DIR
|
||||
MBEDTLS_LIBRARY_DIR
|
||||
MBEDTLS_LIBRARIES
|
||||
MBEDTLS_LIBRARY
|
||||
MBEDX509_LIBRARY
|
||||
MBEDCRYPTO_LIBRARY
|
||||
)
|
||||
64
cmake/SocketLibraries.cmake
Normal file
64
cmake/SocketLibraries.cmake
Normal file
@@ -0,0 +1,64 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
# Some systems have their socket functions in a library.
|
||||
# (Solaris -lsocket/-lnsl, Windows -lws2_32). This macro appends those
|
||||
# libraries to the given list
|
||||
macro(append_needed_socket_libraries LIBRARIES_LIST)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
# x86 Windows uses STDCALL for these functions, so their names are mangled,
|
||||
# meaning the platform checks don't work. Hardcoding these until we get
|
||||
# a better solution.
|
||||
set(HAVE_SOCKET 1)
|
||||
set(HAVE_SELECT 1)
|
||||
set(HAVE_INET_ADDR 1)
|
||||
set(NEED_LIB_WS2_32 1)
|
||||
else()
|
||||
check_function_exists_may_need_library(socket HAVE_SOCKET socket ws2_32)
|
||||
check_function_exists_may_need_library(select HAVE_SELECT ws2_32)
|
||||
check_function_exists_may_need_library(inet_addr HAVE_INET_ADDR nsl ws2_32)
|
||||
endif()
|
||||
|
||||
if(NEED_LIB_SOCKET)
|
||||
list(APPEND ${LIBRARIES_LIST} socket)
|
||||
endif()
|
||||
if(NEED_LIB_NSL)
|
||||
list(APPEND ${LIBRARIES_LIST} nsl)
|
||||
endif()
|
||||
if(NEED_LIB_WS2_32)
|
||||
list(APPEND ${LIBRARIES_LIST} ws2_32)
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
42
cmake/Toolchain-Linux-32.cmake
Normal file
42
cmake/Toolchain-Linux-32.cmake
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
# Cross-compile 32-bit binary on 64-bit linux host
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
set(CMAKE_SYSTEM_PROCESSOR "i386")
|
||||
|
||||
set(CMAKE_CXX_COMPILER_ARG1 "-m32")
|
||||
set(CMAKE_C_COMPILER_ARG1 "-m32")
|
||||
23
cmake/max_warnings.cmake
Normal file
23
cmake/max_warnings.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
if(MSVC)
|
||||
# Use the highest warning level for visual studio.
|
||||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
endif()
|
||||
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
|
||||
endif()
|
||||
|
||||
# Disable broken warnings
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
endif()
|
||||
if(NOT CMAKE_C_FLAGS MATCHES "-Wall")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
endif()
|
||||
endif()
|
||||
17
compile
17
compile
@@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-10-14.11; # UTC
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2020 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -53,7 +53,7 @@ func_file_conv ()
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
CYGWIN* | MSYS*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
@@ -67,7 +67,7 @@ func_file_conv ()
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
cygwin/* | msys/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
@@ -255,7 +255,8 @@ EOF
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
|
||||
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
@@ -339,9 +340,9 @@ exit $ret
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
||||
920
config.guess
vendored
920
config.guess
vendored
File diff suppressed because it is too large
Load Diff
418
config.sub
vendored
418
config.sub
vendored
@@ -1,36 +1,31 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
# 2011, 2012 Free Software Foundation, Inc.
|
||||
# Copyright 1992-2018 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2012-02-10'
|
||||
timestamp='2018-02-22'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
# can handle that machine. It does not imply ALL GNU software can.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 General Public License for more details.
|
||||
# This program 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
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
# the same distribution terms that you use for the rest of that
|
||||
# program. This Exception is an additional permission under section 7
|
||||
# of the GNU General Public License, version 3 ("GPLv3").
|
||||
|
||||
|
||||
# Please send patches to <config-patches@gnu.org>. Submit a context
|
||||
# diff and a properly formatted GNU ChangeLog entry.
|
||||
# Please send patches to <config-patches@gnu.org>.
|
||||
#
|
||||
# Configuration subroutine to validate and canonicalize a configuration type.
|
||||
# Supply the specified configuration type as an argument.
|
||||
@@ -38,7 +33,7 @@ timestamp='2012-02-10'
|
||||
# Otherwise, we print the canonical config type on stdout and succeed.
|
||||
|
||||
# You can get the latest version of this script from:
|
||||
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
|
||||
# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
|
||||
|
||||
# This file is supposed to be the same for all GNU packages
|
||||
# and recognize all the CPU types, system types and aliases
|
||||
@@ -58,12 +53,11 @@ timestamp='2012-02-10'
|
||||
me=`echo "$0" | sed -e 's,.*/,,'`
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION] CPU-MFR-OPSYS
|
||||
$0 [OPTION] ALIAS
|
||||
Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
|
||||
|
||||
Canonicalize a configuration name.
|
||||
|
||||
Operation modes:
|
||||
Options:
|
||||
-h, --help print this help, then exit
|
||||
-t, --time-stamp print date of last modification, then exit
|
||||
-v, --version print version number, then exit
|
||||
@@ -73,9 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
|
||||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
|
||||
Free Software Foundation, Inc.
|
||||
Copyright 1992-2018 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
@@ -102,7 +94,7 @@ while test $# -gt 0 ; do
|
||||
|
||||
*local*)
|
||||
# First pass through any local machine types.
|
||||
echo $1
|
||||
echo "$1"
|
||||
exit ;;
|
||||
|
||||
* )
|
||||
@@ -120,24 +112,24 @@ esac
|
||||
|
||||
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
|
||||
linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
|
||||
knetbsd*-gnu* | netbsd*-gnu* | \
|
||||
kopensolaris*-gnu* | \
|
||||
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
|
||||
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
|
||||
kopensolaris*-gnu* | cloudabi*-eabi* | \
|
||||
storm-chaos* | os2-emx* | rtmk-nova*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
android-linux)
|
||||
os=-linux-android
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
|
||||
basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
|
||||
;;
|
||||
*)
|
||||
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
|
||||
if [ $basic_machine != $1 ]
|
||||
then os=`echo $1 | sed 's/.*-/-/'`
|
||||
basic_machine=`echo "$1" | sed 's/-[^-]*$//'`
|
||||
if [ "$basic_machine" != "$1" ]
|
||||
then os=`echo "$1" | sed 's/.*-/-/'`
|
||||
else os=; fi
|
||||
;;
|
||||
esac
|
||||
@@ -156,7 +148,7 @@ case $os in
|
||||
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
|
||||
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
|
||||
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
|
||||
-apple | -axis | -knuth | -cray | -microblaze)
|
||||
-apple | -axis | -knuth | -cray | -microblaze*)
|
||||
os=
|
||||
basic_machine=$1
|
||||
;;
|
||||
@@ -186,53 +178,56 @@ case $os in
|
||||
;;
|
||||
-sco6)
|
||||
os=-sco5v6
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco5)
|
||||
os=-sco3.2v5
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco4)
|
||||
os=-sco3.2v4
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2.[4-9]*)
|
||||
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco3.2v[4-9]*)
|
||||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco5v6*)
|
||||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco*)
|
||||
os=-sco3.2v2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-udk*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-isc)
|
||||
os=-isc2.2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-clix*)
|
||||
basic_machine=clipper-intergraph
|
||||
;;
|
||||
-isc*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-lynx*178)
|
||||
os=-lynxos178
|
||||
;;
|
||||
-lynx*5)
|
||||
os=-lynxos5
|
||||
;;
|
||||
-lynx*)
|
||||
os=-lynxos
|
||||
;;
|
||||
-ptx*)
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
|
||||
;;
|
||||
-windowsnt*)
|
||||
os=`echo $os | sed -e 's/windowsnt/winnt/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'`
|
||||
;;
|
||||
-psos*)
|
||||
os=-psos
|
||||
@@ -253,21 +248,25 @@ case $basic_machine in
|
||||
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
|
||||
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
|
||||
| am33_2.0 \
|
||||
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
|
||||
| be32 | be64 \
|
||||
| arc | arceb \
|
||||
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
|
||||
| avr | avr32 \
|
||||
| ba \
|
||||
| be32 | be64 \
|
||||
| bfin \
|
||||
| c4x | clipper \
|
||||
| c4x | c8051 | clipper \
|
||||
| d10v | d30v | dlx | dsp16xx \
|
||||
| epiphany \
|
||||
| fido | fr30 | frv \
|
||||
| e2k | epiphany \
|
||||
| fido | fr30 | frv | ft32 \
|
||||
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||
| hexagon \
|
||||
| i370 | i860 | i960 | ia64 \
|
||||
| i370 | i860 | i960 | ia16 | ia64 \
|
||||
| ip2k | iq2000 \
|
||||
| k1om \
|
||||
| le32 | le64 \
|
||||
| lm32 \
|
||||
| m32c | m32r | m32rle | m68000 | m68k | m88k \
|
||||
| maxq | mb | microblaze | mcore | mep | metag \
|
||||
| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
|
||||
| mips | mipsbe | mipseb | mipsel | mipsle \
|
||||
| mips16 \
|
||||
| mips64 | mips64el \
|
||||
@@ -281,26 +280,30 @@ case $basic_machine in
|
||||
| mips64vr5900 | mips64vr5900el \
|
||||
| mipsisa32 | mipsisa32el \
|
||||
| mipsisa32r2 | mipsisa32r2el \
|
||||
| mipsisa32r6 | mipsisa32r6el \
|
||||
| mipsisa64 | mipsisa64el \
|
||||
| mipsisa64r2 | mipsisa64r2el \
|
||||
| mipsisa64r6 | mipsisa64r6el \
|
||||
| mipsisa64sb1 | mipsisa64sb1el \
|
||||
| mipsisa64sr71k | mipsisa64sr71kel \
|
||||
| mipsr5900 | mipsr5900el \
|
||||
| mipstx39 | mipstx39el \
|
||||
| mn10200 | mn10300 \
|
||||
| moxie \
|
||||
| mt \
|
||||
| msp430 \
|
||||
| nds32 | nds32le | nds32be \
|
||||
| nios | nios2 \
|
||||
| nios | nios2 | nios2eb | nios2el \
|
||||
| ns16k | ns32k \
|
||||
| open8 \
|
||||
| or32 \
|
||||
| pdp10 | pdp11 | pj | pjl \
|
||||
| open8 | or1k | or1knd | or32 \
|
||||
| pdp10 | pj | pjl \
|
||||
| powerpc | powerpc64 | powerpc64le | powerpcle \
|
||||
| pru \
|
||||
| pyramid \
|
||||
| riscv32 | riscv64 \
|
||||
| rl78 | rx \
|
||||
| score \
|
||||
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh64 | sh64le \
|
||||
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
|
||||
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
|
||||
@@ -308,7 +311,8 @@ case $basic_machine in
|
||||
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
|
||||
| ubicom32 \
|
||||
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
|
||||
| we32k \
|
||||
| visium \
|
||||
| wasm32 \
|
||||
| x86 | xc16x | xstormy16 | xtensa \
|
||||
| z8k | z80)
|
||||
basic_machine=$basic_machine-unknown
|
||||
@@ -322,11 +326,14 @@ case $basic_machine in
|
||||
c6x)
|
||||
basic_machine=tic6x-unknown
|
||||
;;
|
||||
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
|
||||
leon|leon[3-9])
|
||||
basic_machine=sparc-$basic_machine
|
||||
;;
|
||||
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
|
||||
basic_machine=$basic_machine-unknown
|
||||
os=-none
|
||||
;;
|
||||
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
|
||||
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
|
||||
;;
|
||||
ms1)
|
||||
basic_machine=mt-unknown
|
||||
@@ -355,7 +362,7 @@ case $basic_machine in
|
||||
;;
|
||||
# Object if more than one company name word.
|
||||
*-*-*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
# Recognize the basic CPU types with company name.
|
||||
@@ -364,26 +371,29 @@ case $basic_machine in
|
||||
| aarch64-* | aarch64_be-* \
|
||||
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
|
||||
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
|
||||
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
|
||||
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
|
||||
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
|
||||
| avr-* | avr32-* \
|
||||
| ba-* \
|
||||
| be32-* | be64-* \
|
||||
| bfin-* | bs2000-* \
|
||||
| c[123]* | c30-* | [cjt]90-* | c4x-* \
|
||||
| clipper-* | craynv-* | cydra-* \
|
||||
| c8051-* | clipper-* | craynv-* | cydra-* \
|
||||
| d10v-* | d30v-* | dlx-* \
|
||||
| elxsi-* \
|
||||
| e2k-* | elxsi-* \
|
||||
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
|
||||
| h8300-* | h8500-* \
|
||||
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
|
||||
| hexagon-* \
|
||||
| i*86-* | i860-* | i960-* | ia64-* \
|
||||
| i*86-* | i860-* | i960-* | ia16-* | ia64-* \
|
||||
| ip2k-* | iq2000-* \
|
||||
| k1om-* \
|
||||
| le32-* | le64-* \
|
||||
| lm32-* \
|
||||
| m32c-* | m32r-* | m32rle-* \
|
||||
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
|
||||
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
|
||||
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
|
||||
| microblaze-* | microblazeel-* \
|
||||
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
|
||||
| mips16-* \
|
||||
| mips64-* | mips64el-* \
|
||||
@@ -397,28 +407,34 @@ case $basic_machine in
|
||||
| mips64vr5900-* | mips64vr5900el-* \
|
||||
| mipsisa32-* | mipsisa32el-* \
|
||||
| mipsisa32r2-* | mipsisa32r2el-* \
|
||||
| mipsisa32r6-* | mipsisa32r6el-* \
|
||||
| mipsisa64-* | mipsisa64el-* \
|
||||
| mipsisa64r2-* | mipsisa64r2el-* \
|
||||
| mipsisa64r6-* | mipsisa64r6el-* \
|
||||
| mipsisa64sb1-* | mipsisa64sb1el-* \
|
||||
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
|
||||
| mipsr5900-* | mipsr5900el-* \
|
||||
| mipstx39-* | mipstx39el-* \
|
||||
| mmix-* \
|
||||
| mt-* \
|
||||
| msp430-* \
|
||||
| nds32-* | nds32le-* | nds32be-* \
|
||||
| nios-* | nios2-* \
|
||||
| nios-* | nios2-* | nios2eb-* | nios2el-* \
|
||||
| none-* | np1-* | ns16k-* | ns32k-* \
|
||||
| open8-* \
|
||||
| or1k*-* \
|
||||
| orion-* \
|
||||
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
|
||||
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
|
||||
| pru-* \
|
||||
| pyramid-* \
|
||||
| riscv32-* | riscv64-* \
|
||||
| rl78-* | romp-* | rs6000-* | rx-* \
|
||||
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
|
||||
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
|
||||
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
|
||||
| sparclite-* \
|
||||
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
|
||||
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
|
||||
| tahoe-* \
|
||||
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
|
||||
| tile*-* \
|
||||
@@ -426,6 +442,8 @@ case $basic_machine in
|
||||
| ubicom32-* \
|
||||
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
|
||||
| vax-* \
|
||||
| visium-* \
|
||||
| wasm32-* \
|
||||
| we32k-* \
|
||||
| x86-* | x86_64-* | xc16x-* | xps100-* \
|
||||
| xstormy16-* | xtensa*-* \
|
||||
@@ -439,7 +457,7 @@ case $basic_machine in
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
386bsd)
|
||||
basic_machine=i386-unknown
|
||||
basic_machine=i386-pc
|
||||
os=-bsd
|
||||
;;
|
||||
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
|
||||
@@ -473,7 +491,7 @@ case $basic_machine in
|
||||
basic_machine=x86_64-pc
|
||||
;;
|
||||
amd64-*)
|
||||
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
amdahl)
|
||||
basic_machine=580-amdahl
|
||||
@@ -502,6 +520,9 @@ case $basic_machine in
|
||||
basic_machine=i386-pc
|
||||
os=-aros
|
||||
;;
|
||||
asmjs)
|
||||
basic_machine=asmjs-unknown
|
||||
;;
|
||||
aux)
|
||||
basic_machine=m68k-apple
|
||||
os=-aux
|
||||
@@ -515,7 +536,7 @@ case $basic_machine in
|
||||
os=-linux
|
||||
;;
|
||||
blackfin-*)
|
||||
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
bluegene*)
|
||||
@@ -523,13 +544,13 @@ case $basic_machine in
|
||||
os=-cnk
|
||||
;;
|
||||
c54x-*)
|
||||
basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
c55x-*)
|
||||
basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
c6x-*)
|
||||
basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
c90)
|
||||
basic_machine=c90-cray
|
||||
@@ -618,10 +639,18 @@ case $basic_machine in
|
||||
basic_machine=rs6000-bull
|
||||
os=-bosx
|
||||
;;
|
||||
dpx2* | dpx2*-bull)
|
||||
dpx2*)
|
||||
basic_machine=m68k-bull
|
||||
os=-sysv3
|
||||
;;
|
||||
e500v[12])
|
||||
basic_machine=powerpc-unknown
|
||||
os=$os"spe"
|
||||
;;
|
||||
e500v[12]-*)
|
||||
basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
os=$os"spe"
|
||||
;;
|
||||
ebmon29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-ebmon
|
||||
@@ -711,9 +740,6 @@ case $basic_machine in
|
||||
hp9k8[0-9][0-9] | hp8[0-9][0-9])
|
||||
basic_machine=hppa1.0-hp
|
||||
;;
|
||||
hppa-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
hppaosf)
|
||||
basic_machine=hppa1.1-hp
|
||||
os=-osf
|
||||
@@ -726,26 +752,26 @@ case $basic_machine in
|
||||
basic_machine=i370-ibm
|
||||
;;
|
||||
i*86v32)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv32
|
||||
;;
|
||||
i*86v4*)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv4
|
||||
;;
|
||||
i*86v)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv
|
||||
;;
|
||||
i*86sol2)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
|
||||
os=-solaris2
|
||||
;;
|
||||
i386mach)
|
||||
basic_machine=i386-mach
|
||||
os=-mach
|
||||
;;
|
||||
i386-vsta | vsta)
|
||||
vsta)
|
||||
basic_machine=i386-unknown
|
||||
os=-vsta
|
||||
;;
|
||||
@@ -763,17 +789,17 @@ case $basic_machine in
|
||||
basic_machine=m68k-isi
|
||||
os=-sysv
|
||||
;;
|
||||
leon-*|leon[3-9]-*)
|
||||
basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'`
|
||||
;;
|
||||
m68knommu)
|
||||
basic_machine=m68k-unknown
|
||||
os=-linux
|
||||
;;
|
||||
m68knommu-*)
|
||||
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
m88k-omron*)
|
||||
basic_machine=m88k-omron
|
||||
;;
|
||||
magnum | m3230)
|
||||
basic_machine=mips-mips
|
||||
os=-sysv
|
||||
@@ -782,11 +808,15 @@ case $basic_machine in
|
||||
basic_machine=ns32k-utek
|
||||
os=-sysv
|
||||
;;
|
||||
microblaze)
|
||||
microblaze*)
|
||||
basic_machine=microblaze-xilinx
|
||||
;;
|
||||
mingw64)
|
||||
basic_machine=x86_64-pc
|
||||
os=-mingw64
|
||||
;;
|
||||
mingw32)
|
||||
basic_machine=i386-pc
|
||||
basic_machine=i686-pc
|
||||
os=-mingw32
|
||||
;;
|
||||
mingw32ce)
|
||||
@@ -801,10 +831,10 @@ case $basic_machine in
|
||||
os=-mint
|
||||
;;
|
||||
mips3*-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
|
||||
basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`
|
||||
;;
|
||||
mips3*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
|
||||
basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown
|
||||
;;
|
||||
monitor)
|
||||
basic_machine=m68k-rom68k
|
||||
@@ -814,15 +844,19 @@ case $basic_machine in
|
||||
basic_machine=powerpc-unknown
|
||||
os=-morphos
|
||||
;;
|
||||
moxiebox)
|
||||
basic_machine=moxie-unknown
|
||||
os=-moxiebox
|
||||
;;
|
||||
msdos)
|
||||
basic_machine=i386-pc
|
||||
os=-msdos
|
||||
;;
|
||||
ms1-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
|
||||
basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'`
|
||||
;;
|
||||
msys)
|
||||
basic_machine=i386-pc
|
||||
basic_machine=i686-pc
|
||||
os=-msys
|
||||
;;
|
||||
mvs)
|
||||
@@ -861,7 +895,7 @@ case $basic_machine in
|
||||
basic_machine=v70-nec
|
||||
os=-sysv
|
||||
;;
|
||||
next | m*-next )
|
||||
next | m*-next)
|
||||
basic_machine=m68k-next
|
||||
case $os in
|
||||
-nextstep* )
|
||||
@@ -906,6 +940,12 @@ case $basic_machine in
|
||||
nsr-tandem)
|
||||
basic_machine=nsr-tandem
|
||||
;;
|
||||
nsv-tandem)
|
||||
basic_machine=nsv-tandem
|
||||
;;
|
||||
nsx-tandem)
|
||||
basic_machine=nsx-tandem
|
||||
;;
|
||||
op50n-* | op60c-*)
|
||||
basic_machine=hppa1.1-oki
|
||||
os=-proelf
|
||||
@@ -938,7 +978,7 @@ case $basic_machine in
|
||||
os=-linux
|
||||
;;
|
||||
parisc-*)
|
||||
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
os=-linux
|
||||
;;
|
||||
pbd)
|
||||
@@ -954,7 +994,7 @@ case $basic_machine in
|
||||
basic_machine=i386-pc
|
||||
;;
|
||||
pc98-*)
|
||||
basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentium | p5 | k5 | k6 | nexgen | viac3)
|
||||
basic_machine=i586-pc
|
||||
@@ -969,16 +1009,16 @@ case $basic_machine in
|
||||
basic_machine=i786-pc
|
||||
;;
|
||||
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
|
||||
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumpro-* | p6-* | 6x86-* | athlon-*)
|
||||
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
|
||||
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentium4-*)
|
||||
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pn)
|
||||
basic_machine=pn-gould
|
||||
@@ -988,23 +1028,23 @@ case $basic_machine in
|
||||
ppc | ppcbe) basic_machine=powerpc-unknown
|
||||
;;
|
||||
ppc-* | ppcbe-*)
|
||||
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppcle | powerpclittle | ppc-le | powerpc-little)
|
||||
ppcle | powerpclittle)
|
||||
basic_machine=powerpcle-unknown
|
||||
;;
|
||||
ppcle-* | powerpclittle-*)
|
||||
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppc64) basic_machine=powerpc64-unknown
|
||||
;;
|
||||
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
|
||||
ppc64le | powerpc64little)
|
||||
basic_machine=powerpc64le-unknown
|
||||
;;
|
||||
ppc64le-* | powerpc64little-*)
|
||||
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
ps2)
|
||||
basic_machine=i386-ibm
|
||||
@@ -1013,7 +1053,11 @@ case $basic_machine in
|
||||
basic_machine=i586-unknown
|
||||
os=-pw32
|
||||
;;
|
||||
rdos)
|
||||
rdos | rdos64)
|
||||
basic_machine=x86_64-pc
|
||||
os=-rdos
|
||||
;;
|
||||
rdos32)
|
||||
basic_machine=i386-pc
|
||||
os=-rdos
|
||||
;;
|
||||
@@ -1054,17 +1098,10 @@ case $basic_machine in
|
||||
sequent)
|
||||
basic_machine=i386-sequent
|
||||
;;
|
||||
sh)
|
||||
basic_machine=sh-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
sh5el)
|
||||
basic_machine=sh5le-unknown
|
||||
;;
|
||||
sh64)
|
||||
basic_machine=sh64-unknown
|
||||
;;
|
||||
sparclite-wrs | simso-wrs)
|
||||
simso-wrs)
|
||||
basic_machine=sparclite-wrs
|
||||
os=-vxworks
|
||||
;;
|
||||
@@ -1083,7 +1120,7 @@ case $basic_machine in
|
||||
os=-sysv4
|
||||
;;
|
||||
strongarm-* | thumb-*)
|
||||
basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
sun2)
|
||||
basic_machine=m68000-sun
|
||||
@@ -1205,6 +1242,9 @@ case $basic_machine in
|
||||
basic_machine=hppa1.1-winbond
|
||||
os=-proelf
|
||||
;;
|
||||
x64)
|
||||
basic_machine=x86_64-pc
|
||||
;;
|
||||
xbox)
|
||||
basic_machine=i686-pc
|
||||
os=-mingw32
|
||||
@@ -1213,20 +1253,12 @@ case $basic_machine in
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
xscale-* | xscalee[bl]-*)
|
||||
basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
|
||||
basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'`
|
||||
;;
|
||||
ymp)
|
||||
basic_machine=ymp-cray
|
||||
os=-unicos
|
||||
;;
|
||||
z8k-*-coff)
|
||||
basic_machine=z8k-unknown
|
||||
os=-sim
|
||||
;;
|
||||
z80-*-coff)
|
||||
basic_machine=z80-unknown
|
||||
os=-sim
|
||||
;;
|
||||
none)
|
||||
basic_machine=none-none
|
||||
os=-none
|
||||
@@ -1255,10 +1287,6 @@ case $basic_machine in
|
||||
vax)
|
||||
basic_machine=vax-dec
|
||||
;;
|
||||
pdp10)
|
||||
# there are many clones, so DEC is not a safe bet
|
||||
basic_machine=pdp10-unknown
|
||||
;;
|
||||
pdp11)
|
||||
basic_machine=pdp11-dec
|
||||
;;
|
||||
@@ -1268,9 +1296,6 @@ case $basic_machine in
|
||||
sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
|
||||
basic_machine=sh-unknown
|
||||
;;
|
||||
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
cydra)
|
||||
basic_machine=cydra-cydrome
|
||||
;;
|
||||
@@ -1290,7 +1315,7 @@ case $basic_machine in
|
||||
# Make sure to match an already-canonicalized machine name.
|
||||
;;
|
||||
*)
|
||||
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
|
||||
echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -1298,10 +1323,10 @@ esac
|
||||
# Here we canonicalize certain aliases for manufacturers.
|
||||
case $basic_machine in
|
||||
*-digital*)
|
||||
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
|
||||
basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'`
|
||||
;;
|
||||
*-commodore*)
|
||||
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
|
||||
basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'`
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
@@ -1312,8 +1337,8 @@ esac
|
||||
if [ x"$os" != x"" ]
|
||||
then
|
||||
case $os in
|
||||
# First match some system type aliases
|
||||
# that might get confused with valid system types.
|
||||
# First match some system type aliases that might get confused
|
||||
# with valid system types.
|
||||
# -solaris* is a basic system type, with this one exception.
|
||||
-auroraux)
|
||||
os=-auroraux
|
||||
@@ -1324,45 +1349,48 @@ case $os in
|
||||
-solaris)
|
||||
os=-solaris2
|
||||
;;
|
||||
-svr4*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-unixware*)
|
||||
os=-sysv4.2uw
|
||||
;;
|
||||
-gnu/linux*)
|
||||
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
|
||||
;;
|
||||
# First accept the basic system types.
|
||||
# es1800 is here to avoid being matched by es* (a different OS)
|
||||
-es1800*)
|
||||
os=-ose
|
||||
;;
|
||||
# Now accept the basic system types.
|
||||
# The portable systems comes first.
|
||||
# Each alternative MUST END IN A *, to match a version number.
|
||||
# Each alternative MUST end in a * to match a version number.
|
||||
# -sysv* is not here because it comes later, after sysvr4.
|
||||
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
|
||||
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
|
||||
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
|
||||
| -sym* | -kopensolaris* \
|
||||
| -sym* | -kopensolaris* | -plan9* \
|
||||
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
|
||||
| -aos* | -aros* \
|
||||
| -aos* | -aros* | -cloudabi* | -sortix* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
|
||||
| -openbsd* | -solidbsd* \
|
||||
| -hiux* | -knetbsd* | -mirbsd* | -netbsd* \
|
||||
| -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
|
||||
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
|
||||
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -chorusos* | -chorusrdb* | -cegcc* \
|
||||
| -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
|
||||
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -linux-android* \
|
||||
| -linux-newlib* | -linux-uclibc* \
|
||||
| -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
|
||||
| -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
|
||||
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
|
||||
| -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
|
||||
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \
|
||||
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
|
||||
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
|
||||
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
||||
| -morphos* | -superux* | -rtmk* | -windiss* \
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
|
||||
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
|
||||
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
|
||||
| -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \
|
||||
| -midnightbsd*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-qnx*)
|
||||
@@ -1379,12 +1407,12 @@ case $os in
|
||||
-nto*)
|
||||
os=`echo $os | sed -e 's|nto|nto-qnx|'`
|
||||
;;
|
||||
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
|
||||
| -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
|
||||
-sim | -xray | -os68k* | -v88r* \
|
||||
| -windows* | -osx | -abug | -netware* | -os9* \
|
||||
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
|
||||
;;
|
||||
-mac*)
|
||||
os=`echo $os | sed -e 's|mac|macos|'`
|
||||
os=`echo "$os" | sed -e 's|mac|macos|'`
|
||||
;;
|
||||
-linux-dietlibc)
|
||||
os=-linux-dietlibc
|
||||
@@ -1393,10 +1421,10 @@ case $os in
|
||||
os=`echo $os | sed -e 's|linux|linux-gnu|'`
|
||||
;;
|
||||
-sunos5*)
|
||||
os=`echo $os | sed -e 's|sunos5|solaris2|'`
|
||||
os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
|
||||
;;
|
||||
-sunos6*)
|
||||
os=`echo $os | sed -e 's|sunos6|solaris3|'`
|
||||
os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
|
||||
;;
|
||||
-opened*)
|
||||
os=-openedition
|
||||
@@ -1407,12 +1435,6 @@ case $os in
|
||||
-wince*)
|
||||
os=-wince
|
||||
;;
|
||||
-osfrose*)
|
||||
os=-osfrose
|
||||
;;
|
||||
-osf*)
|
||||
os=-osf
|
||||
;;
|
||||
-utek*)
|
||||
os=-bsd
|
||||
;;
|
||||
@@ -1437,7 +1459,7 @@ case $os in
|
||||
-nova*)
|
||||
os=-rtmk-nova
|
||||
;;
|
||||
-ns2 )
|
||||
-ns2)
|
||||
os=-nextstep2
|
||||
;;
|
||||
-nsk*)
|
||||
@@ -1459,7 +1481,7 @@ case $os in
|
||||
-oss*)
|
||||
os=-sysv3
|
||||
;;
|
||||
-svr4)
|
||||
-svr4*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-svr3)
|
||||
@@ -1474,35 +1496,38 @@ case $os in
|
||||
-ose*)
|
||||
os=-ose
|
||||
;;
|
||||
-es1800*)
|
||||
os=-ose
|
||||
;;
|
||||
-xenix)
|
||||
os=-xenix
|
||||
;;
|
||||
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
|
||||
os=-mint
|
||||
;;
|
||||
-aros*)
|
||||
os=-aros
|
||||
;;
|
||||
-kaos*)
|
||||
os=-kaos
|
||||
;;
|
||||
-zvmoe)
|
||||
os=-zvmoe
|
||||
;;
|
||||
-dicos*)
|
||||
os=-dicos
|
||||
;;
|
||||
-pikeos*)
|
||||
# Until real need of OS specific support for
|
||||
# particular features comes up, bare metal
|
||||
# configurations are quite functional.
|
||||
case $basic_machine in
|
||||
arm*)
|
||||
os=-eabi
|
||||
;;
|
||||
*)
|
||||
os=-elf
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-nacl*)
|
||||
;;
|
||||
-ios)
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
# Get rid of the `-' at the beginning of $os.
|
||||
os=`echo $os | sed 's/[^-]*-//'`
|
||||
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
|
||||
echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -1537,6 +1562,12 @@ case $basic_machine in
|
||||
c4x-* | tic4x-*)
|
||||
os=-coff
|
||||
;;
|
||||
c8051-*)
|
||||
os=-elf
|
||||
;;
|
||||
hexagon-*)
|
||||
os=-elf
|
||||
;;
|
||||
tic54x-*)
|
||||
os=-coff
|
||||
;;
|
||||
@@ -1586,12 +1617,12 @@ case $basic_machine in
|
||||
sparc-* | *-sun)
|
||||
os=-sunos4.1.1
|
||||
;;
|
||||
pru-*)
|
||||
os=-elf
|
||||
;;
|
||||
*-be)
|
||||
os=-beos
|
||||
;;
|
||||
*-haiku)
|
||||
os=-haiku
|
||||
;;
|
||||
*-ibm)
|
||||
os=-aix
|
||||
;;
|
||||
@@ -1631,7 +1662,7 @@ case $basic_machine in
|
||||
m88k-omron*)
|
||||
os=-luna
|
||||
;;
|
||||
*-next )
|
||||
*-next)
|
||||
os=-nextstep
|
||||
;;
|
||||
*-sequent)
|
||||
@@ -1646,9 +1677,6 @@ case $basic_machine in
|
||||
i370-*)
|
||||
os=-mvs
|
||||
;;
|
||||
*-next)
|
||||
os=-nextstep3
|
||||
;;
|
||||
*-gould)
|
||||
os=-sysv
|
||||
;;
|
||||
@@ -1758,15 +1786,15 @@ case $basic_machine in
|
||||
vendor=stratus
|
||||
;;
|
||||
esac
|
||||
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
|
||||
basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"`
|
||||
;;
|
||||
esac
|
||||
|
||||
echo $basic_machine$os
|
||||
echo "$basic_machine$os"
|
||||
exit
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# eval: (add-hook 'write-file-functions 'time-stamp)
|
||||
# time-stamp-start: "timestamp='"
|
||||
# time-stamp-format: "%:y-%02m-%02d"
|
||||
# time-stamp-end: "'"
|
||||
|
||||
194
configure.ac
194
configure.ac
@@ -2,8 +2,9 @@
|
||||
AC_INIT(libssh2, [-], libssh2-devel@cool.haxx.se)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([src])
|
||||
AC_CONFIG_HEADERS([src/libssh2_config.h example/libssh2_config.h])
|
||||
AC_CONFIG_HEADERS([src/libssh2_config.h])
|
||||
AM_MAINTAINER_MODE
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
dnl SED is needed by some of the tools
|
||||
AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
|
||||
@@ -35,12 +36,9 @@ case "$host" in
|
||||
CFLAGS="$CFLAGS -DLIBSSH2_WIN32"
|
||||
LIBS="$LIBS -lws2_32"
|
||||
;;
|
||||
*-cygwin)
|
||||
CFLAGS="$CFLAGS -DLIBSSH2_WIN32"
|
||||
*darwin*)
|
||||
CFLAGS="$CFLAGS -DLIBSSH2_DARWIN"
|
||||
;;
|
||||
*darwin*)
|
||||
CFLAGS="$CFLAGS -DLIBSSH2_DARWIN"
|
||||
;;
|
||||
*hpux*)
|
||||
;;
|
||||
*osf*)
|
||||
@@ -68,6 +66,7 @@ AC_SEARCH_LIBS(inet_addr, nsl)
|
||||
AC_SUBST(LIBS)
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
@@ -82,105 +81,76 @@ AC_C_BIGENDIAN
|
||||
dnl check for how to do large files
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
# Configure parameters
|
||||
AC_ARG_WITH(openssl,
|
||||
AC_HELP_STRING([--with-openssl],[Use OpenSSL for crypto]),
|
||||
use_openssl=$withval,use_openssl=auto)
|
||||
AC_ARG_WITH(libgcrypt,
|
||||
AC_HELP_STRING([--with-libgcrypt],[Use libgcrypt for crypto]),
|
||||
use_libgcrypt=$withval,use_libgcrypt=auto)
|
||||
AC_ARG_WITH(wincng,
|
||||
AC_HELP_STRING([--with-wincng],[Use Windows CNG for crypto]),
|
||||
use_wincng=$withval,use_wincng=auto)
|
||||
AC_ARG_WITH(libz,
|
||||
AC_HELP_STRING([--with-libz],[Use zlib for compression]),
|
||||
use_libz=$withval,use_libz=auto)
|
||||
# Crypto backends
|
||||
|
||||
found_crypto=none
|
||||
found_crypto_str=""
|
||||
support_clear_memory=no
|
||||
crypto_errors=""
|
||||
|
||||
# Look for OpenSSL
|
||||
if test "$found_crypto" = "none" && test "$use_openssl" != "no"; then
|
||||
AC_LIB_HAVE_LINKFLAGS([ssl], [crypto], [#include <openssl/ssl.h>])
|
||||
fi
|
||||
if test "$ac_cv_libssl" = "yes"; then
|
||||
AC_DEFINE(LIBSSH2_OPENSSL, 1, [Use OpenSSL])
|
||||
LIBSREQUIRED=libssl,libcrypto
|
||||
m4_set_add([crypto_backends], [openssl])
|
||||
m4_set_add([crypto_backends], [libgcrypt])
|
||||
m4_set_add([crypto_backends], [mbedtls])
|
||||
m4_set_add([crypto_backends], [wincng])
|
||||
|
||||
# Not all OpenSSL have AES-CTR functions.
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $LIBSSL"
|
||||
AC_CHECK_FUNCS(EVP_aes_128_ctr)
|
||||
LIBS="$save_LIBS"
|
||||
AC_ARG_WITH([crypto],
|
||||
AC_HELP_STRING([--with-crypto=auto|]m4_set_contents([crypto_backends], [|]),
|
||||
[Select crypto backend (default: auto)]),
|
||||
use_crypto=$withval,
|
||||
use_crypto=auto
|
||||
)
|
||||
|
||||
found_crypto="OpenSSL (AES-CTR: ${ac_cv_func_EVP_aes_128_ctr:-N/A})"
|
||||
fi
|
||||
AM_CONDITIONAL(OPENSSL, test "$ac_cv_libssl" = "yes")
|
||||
case "${use_crypto}" in
|
||||
auto|m4_set_contents([crypto_backends], [|]))
|
||||
m4_set_map([crypto_backends], [LIBSSH2_CHECK_CRYPTO])
|
||||
;;
|
||||
yes|"")
|
||||
crypto_errors="No crypto backend specified!"
|
||||
;;
|
||||
*)
|
||||
crypto_errors="Unknown crypto backend '${use_crypto}' specified!"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Look for libgcrypt
|
||||
if test "$found_crypto" = "none" && test "$use_libgcrypt" != "no"; then
|
||||
AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
|
||||
fi
|
||||
if test "$ac_cv_libgcrypt" = "yes"; then
|
||||
AC_DEFINE(LIBSSH2_LIBGCRYPT, 1, [Use libgcrypt])
|
||||
LIBSREQUIRED= # libgcrypt doesn't provide a .pc file. sad face.
|
||||
LIBS="$LIBS -lgcrypt"
|
||||
found_crypto=libgcrypt
|
||||
fi
|
||||
AM_CONDITIONAL(LIBGCRYPT, test "$ac_cv_libgcrypt" = "yes")
|
||||
|
||||
# Look for Windows Cryptography API: Next Generation
|
||||
if test "$found_crypto" = "none" && test "$use_wincng" != "no"; then
|
||||
AC_LIB_HAVE_LINKFLAGS([bcrypt], [], [
|
||||
#include <windows.h>
|
||||
#include <bcrypt.h>
|
||||
])
|
||||
AC_LIB_HAVE_LINKFLAGS([crypt32], [], [
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
])
|
||||
AC_CHECK_HEADERS([ntdef.h ntstatus.h], [], [], [
|
||||
#include <windows.h>
|
||||
])
|
||||
AC_CHECK_DECLS([SecureZeroMemory], [], [], [
|
||||
#include <windows.h>
|
||||
])
|
||||
fi
|
||||
if test "$ac_cv_libbcrypt" = "yes"; then
|
||||
AC_DEFINE(LIBSSH2_WINCNG, 1, [Use Windows CNG])
|
||||
LIBSREQUIRED= # wincng doesn't provide a .pc file. sad face.
|
||||
LIBS="$LIBS -lbcrypt"
|
||||
if test "$ac_cv_libcrypt32" = "yes"; then
|
||||
LIBS="$LIBS -lcrypt32"
|
||||
fi
|
||||
found_crypto="Windows Cryptography API: Next Generation"
|
||||
if test "$ac_cv_have_decl_SecureZeroMemory" = "yes"; then
|
||||
support_clear_memory=yes
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL(WINCNG, test "$ac_cv_libbcrypt" = "yes")
|
||||
|
||||
# Check if crypto library was found
|
||||
if test "$found_crypto" = "none"; then
|
||||
AC_MSG_ERROR([No crypto library found!
|
||||
Try --with-libssl-prefix=PATH
|
||||
or --with-libgcrypt-prefix=PATH
|
||||
or --with-wincng on Windows\
|
||||
])
|
||||
crypto_errors="${crypto_errors}
|
||||
Specify --with-crypto=\$backend and/or the neccessary library search prefix.
|
||||
|
||||
Known crypto backends: auto, m4_set_contents([crypto_backends], [, ])"
|
||||
AS_MESSAGE([ERROR: ${crypto_errors}])
|
||||
else
|
||||
test "$found_crypto_str" = "" && found_crypto_str="$found_crypto"
|
||||
fi
|
||||
|
||||
# Look for Libz
|
||||
if test "$use_libz" != "no"; then
|
||||
m4_set_foreach([crypto_backends], [backend],
|
||||
[AM_CONDITIONAL(m4_toupper(backend), test "$found_crypto" = "backend")]
|
||||
)
|
||||
|
||||
# libz
|
||||
|
||||
AC_ARG_WITH([libz],
|
||||
AC_HELP_STRING([--with-libz],[Use libz for compression]),
|
||||
use_libz=$withval,
|
||||
use_libz=auto)
|
||||
|
||||
found_libz=no
|
||||
libz_errors=""
|
||||
|
||||
if test "$use_libz" != no; then
|
||||
AC_LIB_HAVE_LINKFLAGS([z], [], [#include <zlib.h>])
|
||||
if test "$ac_cv_libz" != yes; then
|
||||
AC_MSG_NOTICE([Cannot find zlib, disabling compression])
|
||||
AC_MSG_NOTICE([Try --with-libz-prefix=PATH if you know you have it])
|
||||
if test "$use_libz" = auto; then
|
||||
AC_MSG_NOTICE([Cannot find libz, disabling compression])
|
||||
found_libz="disabled; no libz found"
|
||||
else
|
||||
libz_errors="No libz found!
|
||||
Try --with-libz-prefix=PATH if you know that you have it."
|
||||
AS_MESSAGE([ERROR: $libz_errors])
|
||||
fi
|
||||
else
|
||||
AC_DEFINE(LIBSSH2_HAVE_ZLIB, 1, [Compile in zlib support])
|
||||
if test "${LIBSREQUIRED}" != ""; then
|
||||
LIBSREQUIRED="${LIBSREQUIRED},"
|
||||
fi
|
||||
LIBSREQUIRED="${LIBSREQUIRED}zlib"
|
||||
LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }zlib"
|
||||
found_libz="yes"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -238,6 +208,7 @@ AC_HELP_STRING([--disable-debug],[Disable debug options]),
|
||||
[ case "$enable_debug" in
|
||||
no)
|
||||
AC_MSG_RESULT(no)
|
||||
CPPFLAGS="$CPPFLAGS -DNDEBUG"
|
||||
;;
|
||||
*) AC_MSG_RESULT(yes)
|
||||
enable_debug=yes
|
||||
@@ -309,6 +280,21 @@ esac], [build_examples='yes'])
|
||||
AC_MSG_RESULT($build_examples)
|
||||
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
|
||||
|
||||
|
||||
# Build OSS fuzzing targets?
|
||||
AC_ARG_ENABLE([ossfuzzers],
|
||||
[AS_HELP_STRING([--enable-ossfuzzers],
|
||||
[Whether to generate the fuzzers for OSS-Fuzz])],
|
||||
[have_ossfuzzers=yes], [have_ossfuzzers=no])
|
||||
AM_CONDITIONAL([USE_OSSFUZZERS], [test "x$have_ossfuzzers" = "xyes"])
|
||||
|
||||
|
||||
# Set the correct flags for the given fuzzing engine.
|
||||
AC_SUBST([LIB_FUZZING_ENGINE])
|
||||
AM_CONDITIONAL([USE_OSSFUZZ_FLAG], [test "x$LIB_FUZZING_ENGINE" = "x-fsanitize=fuzzer"])
|
||||
AM_CONDITIONAL([USE_OSSFUZZ_STATIC], [test -f "$LIB_FUZZING_ENGINE"])
|
||||
|
||||
|
||||
# Checks for header files.
|
||||
# AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h])
|
||||
@@ -344,7 +330,7 @@ case $host in
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_CHECK_FUNCS(gettimeofday select strtoll)
|
||||
AC_CHECK_FUNCS(gettimeofday select strtoll memset_s)
|
||||
|
||||
dnl Check for select() into ws2_32 for Msys/Mingw
|
||||
if test "$ac_cv_func_select" != "yes"; then
|
||||
@@ -376,9 +362,29 @@ AC_C_INLINE
|
||||
|
||||
CURL_CHECK_NONBLOCKING_SOCKET
|
||||
|
||||
missing_required_deps=0
|
||||
|
||||
if test "${libz_errors}" != ""; then
|
||||
AS_MESSAGE([ERROR: ${libz_errors}])
|
||||
missing_required_deps=1
|
||||
fi
|
||||
|
||||
if test "$found_crypto" = "none"; then
|
||||
AS_MESSAGE([ERROR: ${crypto_errors}])
|
||||
missing_required_deps=1
|
||||
fi
|
||||
|
||||
if test $missing_required_deps = 1; then
|
||||
AC_MSG_ERROR([Required dependencies are missing!])
|
||||
fi
|
||||
|
||||
# Configure parameters
|
||||
LIBSSH2_CHECK_OPTION_WERROR
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
src/Makefile
|
||||
tests/Makefile
|
||||
tests/ossfuzz/Makefile
|
||||
example/Makefile
|
||||
docs/Makefile
|
||||
libssh2.pc])
|
||||
@@ -392,10 +398,10 @@ AC_MSG_NOTICE([summary of build options:
|
||||
Compiler: ${CC}
|
||||
Compiler flags: ${CFLAGS}
|
||||
Library types: Shared=${enable_shared}, Static=${enable_static}
|
||||
Crypto library: ${found_crypto}
|
||||
Crypto library: ${found_crypto_str}
|
||||
Clear memory: $enable_clear_memory
|
||||
Debug build: $enable_debug
|
||||
Build examples: $build_examples
|
||||
Path to sshd: $ac_cv_path_SSHD (only for self-tests)
|
||||
zlib compression: $ac_cv_libz
|
||||
zlib compression: ${found_libz}
|
||||
])
|
||||
|
||||
635
depcomp
635
depcomp
@@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2005-07-09.11
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2020 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -16,9 +16,7 @@ scriptversion=2005-07-09.11
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -29,9 +27,9 @@ scriptversion=2005-07-09.11
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
@@ -41,11 +39,11 @@ as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
source Source file read by 'PROGRAMS ARGS'.
|
||||
object Object file output by 'PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
tmpdepfile Temporary file to use when outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
@@ -58,6 +56,66 @@ EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get the directory component of the given path, and save it in the
|
||||
# global variables '$dir'. Note that this directory component will
|
||||
# be either empty or ending with a '/' character. This is deliberate.
|
||||
set_dir_from ()
|
||||
{
|
||||
case $1 in
|
||||
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
|
||||
*) dir=;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Get the suffix-stripped basename of the given path, and save it the
|
||||
# global variable '$base'.
|
||||
set_base_from ()
|
||||
{
|
||||
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
|
||||
}
|
||||
|
||||
# If no dependency file was actually created by the compiler invocation,
|
||||
# we still have to create a dummy depfile, to avoid errors with the
|
||||
# Makefile "include basename.Plo" scheme.
|
||||
make_dummy_depfile ()
|
||||
{
|
||||
echo "#dummy" > "$depfile"
|
||||
}
|
||||
|
||||
# Factor out some common post-processing of the generated depfile.
|
||||
# Requires the auxiliary global variable '$tmpdepfile' to be set.
|
||||
aix_post_process_depfile ()
|
||||
{
|
||||
# If the compiler actually managed to produce a dependency file,
|
||||
# post-process it.
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form 'foo.o: dependency.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# $object: dependency.h
|
||||
# and one to simply output
|
||||
# dependency.h:
|
||||
# which is needed to avoid the deleted-header problem.
|
||||
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
|
||||
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
|
||||
} > "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
}
|
||||
|
||||
# A tabulation character.
|
||||
tab=' '
|
||||
# A newline character.
|
||||
nl='
|
||||
'
|
||||
# Character ranges might be problematic outside the C locale.
|
||||
# These definitions help.
|
||||
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
lower=abcdefghijklmnopqrstuvwxyz
|
||||
digits=0123456789
|
||||
alpha=${upper}${lower}
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
@@ -70,6 +128,9 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Avoid interferences from the environment.
|
||||
gccflag= dashmflag=
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
@@ -81,9 +142,32 @@ if test "$depmode" = hp; then
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
if test "$depmode" = msvc7msys; then
|
||||
# This is just like msvc7 but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvc7
|
||||
fi
|
||||
|
||||
if test "$depmode" = xlc; then
|
||||
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
|
||||
gccflag=-qmakedep=gcc,-MF
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
@@ -91,10 +175,22 @@ gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
@@ -102,13 +198,17 @@ gcc3)
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
|
||||
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
|
||||
## (see the conditional assignment to $gccflag above).
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## -MM, not -M (despite what the docs say). Also, it might not be
|
||||
## supported by the other compilers which use the 'gcc' depmode.
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
@@ -116,31 +216,31 @@ gcc)
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
# The second -e expression handles DOS-style file names with drive
|
||||
# letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## This next piece of magic avoids the "deleted header file" problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## Some versions of gcc put a space before the ':'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## well. hp depmode also adds that space, but also prefixes the VPATH
|
||||
## to the object. Take care to not repeat it in the output.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
@@ -158,8 +258,7 @@ sgi)
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
@@ -167,99 +266,156 @@ sgi)
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# the IRIX cc adds comments like '#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> $depfile
|
||||
echo >> $depfile
|
||||
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
|
||||
| tr "$nl" ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> $depfile
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
xlc)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# current directory. Also, the AIX compiler puts '$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
|
||||
tmpdepfile="$stripped.u"
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test -f "$tmpdepfile"; then :
|
||||
else
|
||||
stripped=`echo "$stripped" | sed 's,^.*/,,'`
|
||||
tmpdepfile="$stripped.u"
|
||||
fi
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile"; then
|
||||
outname="$stripped.o"
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
tcc)
|
||||
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
|
||||
# FIXME: That version still under development at the moment of writing.
|
||||
# Make that this statement remains true also for stable, released
|
||||
# versions.
|
||||
# It will wrap lines (doesn't matter whether long or short) with a
|
||||
# trailing '\', as in:
|
||||
#
|
||||
# foo.o : \
|
||||
# foo.c \
|
||||
# foo.h \
|
||||
#
|
||||
# It will put a trailing '\' even on the last line, and will use leading
|
||||
# spaces rather than leading tabs (at least since its commit 0394caf7
|
||||
# "Emit spaces for -MD").
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
|
||||
# We have to change lines of the first kind to '$object: \'.
|
||||
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
|
||||
# And for each line of the second kind, we have to emit a 'dep.h:'
|
||||
# dummy dependency, to avoid the deleted-header problem.
|
||||
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
## The order of this option in the case statement is important, since the
|
||||
## shell code in configure will try each of these formats in the order
|
||||
## listed in this file. A plain '-MD' option would be understood by many
|
||||
## compilers, so we must ensure this comes after the gcc and icc options.
|
||||
pgcc)
|
||||
# Portland's C compiler understands '-MD'.
|
||||
# Will always output deps to 'file.d' where file is the root name of the
|
||||
# source file under compilation, even if file resides in a subdirectory.
|
||||
# The object file name does not affect the name of the '.d' file.
|
||||
# pgcc 10.2 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# and will wrap long lines using '\' :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
set_dir_from "$object"
|
||||
# Use the source, not the object, to determine the base name, since
|
||||
# that's sadly what pgcc will do too.
|
||||
set_base_from "$source"
|
||||
tmpdepfile=$base.d
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
# For projects that build the same source file twice into different object
|
||||
# files, the pgcc approach of using the *source* file root name can cause
|
||||
# problems in parallel builds. Use a locking strategy to avoid stomping on
|
||||
# the same $tmpdepfile.
|
||||
lockdir=$base.d-lock
|
||||
trap "
|
||||
echo '$0: caught signal, cleaning up...' >&2
|
||||
rmdir '$lockdir'
|
||||
exit 1
|
||||
" 1 2 13 15
|
||||
numtries=100
|
||||
i=$numtries
|
||||
while test $i -gt 0; do
|
||||
# mkdir is a portable test-and-set.
|
||||
if mkdir "$lockdir" 2>/dev/null; then
|
||||
# This process acquired the lock.
|
||||
"$@" -MD
|
||||
stat=$?
|
||||
# Release the lock.
|
||||
rmdir "$lockdir"
|
||||
break
|
||||
else
|
||||
# If the lock is being held by a different process, wait
|
||||
# until the winning process is done or we timeout.
|
||||
while test -d "$lockdir" && test $i -gt 0; do
|
||||
sleep 1
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
fi
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
trap - 1 2 13 15
|
||||
if test $i -le 0; then
|
||||
echo "$0: failed to acquire lock after $numtries attempts" >&2
|
||||
echo "$0: check lockdir '$lockdir'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
@@ -271,68 +427,141 @@ icc)
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add 'dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in 'foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mecanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
if test "$libtool" = yes; then
|
||||
# Libtool generates 2 separate objects for the 2 libraries. These
|
||||
# two compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
|
||||
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
# Same post-processing that is required for AIX mode.
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
msvc7)
|
||||
if test "$libtool" = yes; then
|
||||
showIncludes=-Wc,-showIncludes
|
||||
else
|
||||
showIncludes=-showIncludes
|
||||
fi
|
||||
"$@" $showIncludes > "$tmpdepfile"
|
||||
stat=$?
|
||||
grep -v '^Note: including file: ' "$tmpdepfile"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The first sed program below extracts the file names and escapes
|
||||
# backslashes for cygpath. The second sed program outputs the file
|
||||
# name when reading, but also accumulates all include files in the
|
||||
# hold buffer in order to output them again at the end. This only
|
||||
# works with sed implementations that can handle large buffers.
|
||||
sed < "$tmpdepfile" -n '
|
||||
/^Note: including file: *\(.*\)/ {
|
||||
s//\1/
|
||||
s/\\/\\\\/g
|
||||
p
|
||||
}' | $cygpath_u | sort -u | sed -n '
|
||||
s/ /\\ /g
|
||||
s/\(.*\)/'"$tab"'\1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/'"$tab"'/
|
||||
G
|
||||
p
|
||||
}' >> "$depfile"
|
||||
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7msys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
@@ -345,13 +574,13 @@ dashmstdout)
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
@@ -371,18 +600,18 @@ dashmstdout)
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# Require at least two characters before searching for ':'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this sed invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
@@ -396,41 +625,51 @@ makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no
|
||||
for arg in "$@"; do
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
# makedepend may prepend the VPATH from the source file name to the object.
|
||||
# No need to regex-escape $object, excess matching of '.' is harmless.
|
||||
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process the last invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed '1,2d' "$tmpdepfile" \
|
||||
| tr ' ' "$nl" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
@@ -441,13 +680,13 @@ cpp)
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
@@ -466,10 +705,10 @@ cpp)
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
"$@" -E \
|
||||
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
| sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
@@ -479,35 +718,56 @@ cpp)
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
|
||||
echo "$tab" >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
@@ -523,8 +783,9 @@ exit 0
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
||||
@@ -10,16 +10,16 @@ Cocoa/Objective-C
|
||||
https://github.com/karelia/libssh2_sftp-Cocoa-wrapper
|
||||
|
||||
Haskell
|
||||
FFI bindings - http://hackage.haskell.org/package/libssh2
|
||||
FFI bindings - https://hackage.haskell.org/package/libssh2
|
||||
|
||||
Perl
|
||||
Net::SSH2 - http://search.cpan.org/~rkitover/Net-SSH2-0.45/lib/Net/SSH2.pm
|
||||
Net::SSH2 - https://metacpan.org/pod/Net::SSH2
|
||||
|
||||
PHP
|
||||
ssh2 - http://pecl.php.net/package/ssh2
|
||||
ssh2 - https://pecl.php.net/package/ssh2
|
||||
|
||||
Python
|
||||
pylibssh2 - http://www.wallix.org/pylibssh2-project/
|
||||
pylibssh2 - https://pypi.python.org/pypi/pylibssh2
|
||||
|
||||
Python-ctypes
|
||||
|
||||
|
||||
210
docs/CMakeLists.txt
Normal file
210
docs/CMakeLists.txt
Normal file
@@ -0,0 +1,210 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
set(MAN_PAGES
|
||||
libssh2_agent_connect.3
|
||||
libssh2_agent_disconnect.3
|
||||
libssh2_agent_free.3
|
||||
libssh2_agent_get_identity.3
|
||||
libssh2_agent_get_identity_path.3
|
||||
libssh2_agent_init.3
|
||||
libssh2_agent_list_identities.3
|
||||
libssh2_agent_set_identity_path.3
|
||||
libssh2_agent_userauth.3
|
||||
libssh2_banner_set.3
|
||||
libssh2_base64_decode.3
|
||||
libssh2_channel_close.3
|
||||
libssh2_channel_direct_tcpip.3
|
||||
libssh2_channel_direct_tcpip_ex.3
|
||||
libssh2_channel_eof.3
|
||||
libssh2_channel_exec.3
|
||||
libssh2_channel_flush.3
|
||||
libssh2_channel_flush_ex.3
|
||||
libssh2_channel_flush_stderr.3
|
||||
libssh2_channel_forward_accept.3
|
||||
libssh2_channel_forward_cancel.3
|
||||
libssh2_channel_forward_listen.3
|
||||
libssh2_channel_forward_listen_ex.3
|
||||
libssh2_channel_free.3
|
||||
libssh2_channel_get_exit_signal.3
|
||||
libssh2_channel_get_exit_status.3
|
||||
libssh2_channel_handle_extended_data.3
|
||||
libssh2_channel_handle_extended_data2.3
|
||||
libssh2_channel_ignore_extended_data.3
|
||||
libssh2_channel_open_ex.3
|
||||
libssh2_channel_open_session.3
|
||||
libssh2_channel_process_startup.3
|
||||
libssh2_channel_read.3
|
||||
libssh2_channel_read_ex.3
|
||||
libssh2_channel_read_stderr.3
|
||||
libssh2_channel_receive_window_adjust.3
|
||||
libssh2_channel_receive_window_adjust2.3
|
||||
libssh2_channel_request_pty.3
|
||||
libssh2_channel_request_pty_ex.3
|
||||
libssh2_channel_request_pty_size.3
|
||||
libssh2_channel_request_pty_size_ex.3
|
||||
libssh2_channel_send_eof.3
|
||||
libssh2_channel_set_blocking.3
|
||||
libssh2_channel_setenv.3
|
||||
libssh2_channel_setenv_ex.3
|
||||
libssh2_channel_shell.3
|
||||
libssh2_channel_subsystem.3
|
||||
libssh2_channel_wait_closed.3
|
||||
libssh2_channel_wait_eof.3
|
||||
libssh2_channel_window_read.3
|
||||
libssh2_channel_window_read_ex.3
|
||||
libssh2_channel_window_write.3
|
||||
libssh2_channel_window_write_ex.3
|
||||
libssh2_channel_write.3
|
||||
libssh2_channel_write_ex.3
|
||||
libssh2_channel_write_stderr.3
|
||||
libssh2_channel_x11_req.3
|
||||
libssh2_channel_x11_req_ex.3
|
||||
libssh2_exit.3
|
||||
libssh2_free.3
|
||||
libssh2_hostkey_hash.3
|
||||
libssh2_init.3
|
||||
libssh2_keepalive_config.3
|
||||
libssh2_keepalive_send.3
|
||||
libssh2_knownhost_add.3
|
||||
libssh2_knownhost_addc.3
|
||||
libssh2_knownhost_check.3
|
||||
libssh2_knownhost_checkp.3
|
||||
libssh2_knownhost_del.3
|
||||
libssh2_knownhost_free.3
|
||||
libssh2_knownhost_get.3
|
||||
libssh2_knownhost_init.3
|
||||
libssh2_knownhost_readfile.3
|
||||
libssh2_knownhost_readline.3
|
||||
libssh2_knownhost_writefile.3
|
||||
libssh2_knownhost_writeline.3
|
||||
libssh2_poll.3
|
||||
libssh2_poll_channel_read.3
|
||||
libssh2_publickey_add.3
|
||||
libssh2_publickey_add_ex.3
|
||||
libssh2_publickey_init.3
|
||||
libssh2_publickey_list_fetch.3
|
||||
libssh2_publickey_list_free.3
|
||||
libssh2_publickey_remove.3
|
||||
libssh2_publickey_remove_ex.3
|
||||
libssh2_publickey_shutdown.3
|
||||
libssh2_scp_recv.3
|
||||
libssh2_scp_recv2.3
|
||||
libssh2_scp_send.3
|
||||
libssh2_scp_send64.3
|
||||
libssh2_scp_send_ex.3
|
||||
libssh2_session_abstract.3
|
||||
libssh2_session_banner_get.3
|
||||
libssh2_session_banner_set.3
|
||||
libssh2_session_block_directions.3
|
||||
libssh2_session_callback_set.3
|
||||
libssh2_session_disconnect.3
|
||||
libssh2_session_disconnect_ex.3
|
||||
libssh2_session_flag.3
|
||||
libssh2_session_free.3
|
||||
libssh2_session_get_blocking.3
|
||||
libssh2_session_get_timeout.3
|
||||
libssh2_session_handshake.3
|
||||
libssh2_session_hostkey.3
|
||||
libssh2_session_init.3
|
||||
libssh2_session_init_ex.3
|
||||
libssh2_session_last_errno.3
|
||||
libssh2_session_last_error.3
|
||||
libssh2_session_set_last_error.3
|
||||
libssh2_session_method_pref.3
|
||||
libssh2_session_methods.3
|
||||
libssh2_session_set_blocking.3
|
||||
libssh2_session_set_timeout.3
|
||||
libssh2_session_startup.3
|
||||
libssh2_session_supported_algs.3
|
||||
libssh2_sftp_close.3
|
||||
libssh2_sftp_close_handle.3
|
||||
libssh2_sftp_closedir.3
|
||||
libssh2_sftp_fsetstat.3
|
||||
libssh2_sftp_fstat.3
|
||||
libssh2_sftp_fstat_ex.3
|
||||
libssh2_sftp_fstatvfs.3
|
||||
libssh2_sftp_fsync.3
|
||||
libssh2_sftp_get_channel.3
|
||||
libssh2_sftp_init.3
|
||||
libssh2_sftp_last_error.3
|
||||
libssh2_sftp_lstat.3
|
||||
libssh2_sftp_mkdir.3
|
||||
libssh2_sftp_mkdir_ex.3
|
||||
libssh2_sftp_open.3
|
||||
libssh2_sftp_open_ex.3
|
||||
libssh2_sftp_opendir.3
|
||||
libssh2_sftp_read.3
|
||||
libssh2_sftp_readdir.3
|
||||
libssh2_sftp_readdir_ex.3
|
||||
libssh2_sftp_readlink.3
|
||||
libssh2_sftp_realpath.3
|
||||
libssh2_sftp_rename.3
|
||||
libssh2_sftp_rename_ex.3
|
||||
libssh2_sftp_rewind.3
|
||||
libssh2_sftp_rmdir.3
|
||||
libssh2_sftp_rmdir_ex.3
|
||||
libssh2_sftp_seek.3
|
||||
libssh2_sftp_seek64.3
|
||||
libssh2_sftp_setstat.3
|
||||
libssh2_sftp_shutdown.3
|
||||
libssh2_sftp_stat.3
|
||||
libssh2_sftp_stat_ex.3
|
||||
libssh2_sftp_statvfs.3
|
||||
libssh2_sftp_symlink.3
|
||||
libssh2_sftp_symlink_ex.3
|
||||
libssh2_sftp_tell.3
|
||||
libssh2_sftp_tell64.3
|
||||
libssh2_sftp_unlink.3
|
||||
libssh2_sftp_unlink_ex.3
|
||||
libssh2_sftp_write.3
|
||||
libssh2_trace.3
|
||||
libssh2_trace_sethandler.3
|
||||
libssh2_userauth_authenticated.3
|
||||
libssh2_userauth_hostbased_fromfile.3
|
||||
libssh2_userauth_hostbased_fromfile_ex.3
|
||||
libssh2_userauth_keyboard_interactive.3
|
||||
libssh2_userauth_keyboard_interactive_ex.3
|
||||
libssh2_userauth_list.3
|
||||
libssh2_userauth_password.3
|
||||
libssh2_userauth_password_ex.3
|
||||
libssh2_userauth_publickey.3
|
||||
libssh2_userauth_publickey_fromfile.3
|
||||
libssh2_userauth_publickey_fromfile_ex.3
|
||||
libssh2_userauth_publickey_frommemory.3
|
||||
libssh2_version.3)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(FILES ${MAN_PAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
|
||||
902
docs/HACKING-CRYPTO
Normal file
902
docs/HACKING-CRYPTO
Normal file
@@ -0,0 +1,902 @@
|
||||
Definitions needed to implement a specific crypto library
|
||||
|
||||
This document offers some hints about implementing a new crypto library
|
||||
interface.
|
||||
|
||||
A crypto library interface consists of at least a header file, defining
|
||||
entities referenced from the libssh2 core modules.
|
||||
Real code implementation (if needed), is left at the implementor's choice.
|
||||
|
||||
This document lists the entities that must/may be defined in the header file.
|
||||
|
||||
Procedures listed as "void" may indeed have a result type: the void indication
|
||||
indicates the libssh2 core modules never use the function result.
|
||||
|
||||
|
||||
0) Build system.
|
||||
|
||||
Adding a crypto backend to the autotools build system (./configure) is easy:
|
||||
|
||||
0.1) Add one new line in configure.ac
|
||||
|
||||
m4_set_add([crypto_backends], [newname])
|
||||
|
||||
This automatically creates a --with-crypto=newname option.
|
||||
|
||||
0.2) Add an m4_case stanza to LIBSSH2_CRYPTO_CHECK in acinclude.m4
|
||||
|
||||
This must check for all required libraries, and if found set and AC_SUBST a
|
||||
variable with the library linking flags. The recommended method is to use
|
||||
LIBSSH2_LIB_HAVE_LINKFLAGS from LIBSSH2_CRYPTO_CHECK, which automatically
|
||||
creates and handles a --with-$newname-prefix option and sets an
|
||||
LTLIBNEWNAME variable on success.
|
||||
|
||||
0.3) Create Makefile.newname.inc in the top-level directory
|
||||
|
||||
This must set CRYPTO_CSOURCES, CRYPTO_HHEADERS and CRYPTO_LTLIBS.
|
||||
Set CRYPTO_CSOURCES and CRYPTO_HHEADERS to the new backend source files
|
||||
and set CRYPTO_LTLIBS to the required library linking parameters, e.g.
|
||||
$(LTLIBNEWNAME) as generated by by LIBSSH2_LIB_HAVE_LINKFLAGS.
|
||||
|
||||
0.4) Add a new block in src/Makefile.am
|
||||
|
||||
if NEWNAME
|
||||
include ../Makefile.newname.inc
|
||||
endif
|
||||
|
||||
|
||||
1) Crypto library initialization/termination.
|
||||
|
||||
void libssh2_crypto_init(void);
|
||||
Initializes the crypto library. May be an empty macro if not needed.
|
||||
|
||||
void libssh2_crypto_exit(void);
|
||||
Terminates the crypto library use. May be an empty macro if not needed.
|
||||
|
||||
|
||||
2) HMAC
|
||||
|
||||
libssh2_hmac_ctx
|
||||
Type of an HMAC computation context. Generally a struct.
|
||||
Used for all hash algorithms.
|
||||
|
||||
void libssh2_hmac_ctx_init(libssh2_hmac_ctx ctx);
|
||||
Initializes the HMAC computation context ctx.
|
||||
Called before setting-up the hash algorithm.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_update(libssh2_hmac_ctx ctx,
|
||||
const unsigned char *data,
|
||||
int datalen);
|
||||
Continue computation of an HMAC on datalen bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_final(libssh2_hmac_ctx ctx,
|
||||
unsigned char output[]);
|
||||
Get the computed HMAC from context ctx into the output buffer. The
|
||||
minimum data buffer size depends on the HMAC hash algorithm.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_cleanup(libssh2_hmac_ctx *ctx);
|
||||
Releases the HMAC computation context at ctx.
|
||||
|
||||
|
||||
3) Hash algorithms.
|
||||
|
||||
3.1) SHA-1
|
||||
Must always be implemented.
|
||||
|
||||
SHA_DIGEST_LENGTH
|
||||
#define to 20, the SHA-1 digest length.
|
||||
|
||||
libssh2_sha1_ctx
|
||||
Type of an SHA-1 computation context. Generally a struct.
|
||||
|
||||
int libssh2_sha1_init(libssh2_sha1_ctx *x);
|
||||
Initializes the SHA-1 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_sha1_update(libssh2_sha1_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continue computation of SHA-1 on len bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_sha1_final(libssh2_sha1_ctx ctx,
|
||||
unsigned char output[SHA_DIGEST_LEN]);
|
||||
Get the computed SHA-1 signature from context ctx and store it into the
|
||||
output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_sha1_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-SHA-1 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.2) SHA-256
|
||||
Must always be implemented.
|
||||
|
||||
SHA256_DIGEST_LENGTH
|
||||
#define to 32, the SHA-256 digest length.
|
||||
|
||||
libssh2_sha256_ctx
|
||||
Type of an SHA-256 computation context. Generally a struct.
|
||||
|
||||
int libssh2_sha256_init(libssh2_sha256_ctx *x);
|
||||
Initializes the SHA-256 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_sha256_update(libssh2_sha256_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continue computation of SHA-256 on len bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_sha256_final(libssh2_sha256_ctx ctx,
|
||||
unsigned char output[SHA256_DIGEST_LENGTH]);
|
||||
Gets the computed SHA-256 signature from context ctx into the output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
int libssh2_sha256(const unsigned char *message,
|
||||
unsigned long len,
|
||||
unsigned char output[SHA256_DIGEST_LENGTH]);
|
||||
Computes the SHA-256 signature over the given message of length len and
|
||||
store the result into the output buffer.
|
||||
Return 1 if error, else 0.
|
||||
Note: Seems unused in current code, but defined in each crypto library backend.
|
||||
|
||||
LIBSSH2_HMAC_SHA256
|
||||
#define as 1 if the crypto library supports HMAC-SHA-256, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
void libssh2_hmac_sha256_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-256 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.3) SHA-384
|
||||
Mandatory if ECDSA is implemented. Can be omitted otherwise.
|
||||
|
||||
SHA384_DIGEST_LENGTH
|
||||
#define to 48, the SHA-384 digest length.
|
||||
|
||||
libssh2_sha384_ctx
|
||||
Type of an SHA-384 computation context. Generally a struct.
|
||||
|
||||
int libssh2_sha384_init(libssh2_sha384_ctx *x);
|
||||
Initializes the SHA-384 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_sha384_update(libssh2_sha384_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continue computation of SHA-384 on len bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_sha384_final(libssh2_sha384_ctx ctx,
|
||||
unsigned char output[SHA384_DIGEST_LENGTH]);
|
||||
Gets the computed SHA-384 signature from context ctx into the output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
int libssh2_sha384(const unsigned char *message,
|
||||
unsigned long len,
|
||||
unsigned char output[SHA384_DIGEST_LENGTH]);
|
||||
Computes the SHA-384 signature over the given message of length len and
|
||||
store the result into the output buffer.
|
||||
Return 1 if error, else 0.
|
||||
|
||||
3.4) SHA-512
|
||||
Must always be implemented.
|
||||
|
||||
SHA512_DIGEST_LENGTH
|
||||
#define to 64, the SHA-512 digest length.
|
||||
|
||||
libssh2_sha512_ctx
|
||||
Type of an SHA-512 computation context. Generally a struct.
|
||||
|
||||
int libssh2_sha512_init(libssh2_sha512_ctx *x);
|
||||
Initializes the SHA-512 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_sha512_update(libssh2_sha512_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continue computation of SHA-512 on len bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_sha512_final(libssh2_sha512_ctx ctx,
|
||||
unsigned char output[SHA512_DIGEST_LENGTH]);
|
||||
Gets the computed SHA-512 signature from context ctx into the output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
int libssh2_sha512(const unsigned char *message,
|
||||
unsigned long len,
|
||||
unsigned char output[SHA512_DIGEST_LENGTH]);
|
||||
Computes the SHA-512 signature over the given message of length len and
|
||||
store the result into the output buffer.
|
||||
Return 1 if error, else 0.
|
||||
Note: Seems unused in current code, but defined in each crypto library backend.
|
||||
|
||||
LIBSSH2_HMAC_SHA512
|
||||
#define as 1 if the crypto library supports HMAC-SHA-512, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
void libssh2_hmac_sha512_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-512 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.5) MD5
|
||||
LIBSSH2_MD5
|
||||
#define to 1 if the crypto library supports MD5, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
MD5_DIGEST_LENGTH
|
||||
#define to 16, the MD5 digest length.
|
||||
|
||||
libssh2_md5_ctx
|
||||
Type of an MD5 computation context. Generally a struct.
|
||||
|
||||
int libssh2_md5_init(libssh2_md5_ctx *x);
|
||||
Initializes the MD5 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_md5_update(libssh2_md5_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continues computation of MD5 on len bytes at data using context ctx.
|
||||
Returns 1 for success and 0 for failure.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_md5_final(libssh2_md5_ctx ctx,
|
||||
unsigned char output[MD5_DIGEST_LENGTH]);
|
||||
Gets the computed MD5 signature from context ctx into the output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_md5_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-MD5 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.6) RIPEMD-160
|
||||
LIBSSH2_HMAC_RIPEMD
|
||||
#define as 1 if the crypto library supports HMAC-RIPEMD-160, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
void libssh2_hmac_ripemd160_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-RIPEMD-160 computation using
|
||||
the keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
Returns 1 for success and 0 for failure.
|
||||
|
||||
|
||||
4) Bidirectional key ciphers.
|
||||
|
||||
_libssh2_cipher_ctx
|
||||
Type of a cipher computation context.
|
||||
|
||||
_libssh2_cipher_type(name);
|
||||
Macro defining name as storage identifying a cipher algorithm for
|
||||
the crypto library interface. No trailing semicolon.
|
||||
|
||||
int _libssh2_cipher_init(_libssh2_cipher_ctx *h,
|
||||
_libssh2_cipher_type(algo),
|
||||
unsigned char *iv,
|
||||
unsigned char *secret,
|
||||
int encrypt);
|
||||
Creates a cipher context for the given algorithm with the initialization vector
|
||||
iv and the secret key secret. Prepare for encryption or decryption depending on
|
||||
encrypt.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_cipher_crypt(_libssh2_cipher_ctx *ctx,
|
||||
_libssh2_cipher_type(algo),
|
||||
int encrypt,
|
||||
unsigned char *block,
|
||||
size_t blocksize);
|
||||
Encrypt or decrypt in-place data at (block, blocksize) using the given
|
||||
context and/or algorithm.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
void _libssh2_cipher_dtor(_libssh2_cipher_ctx *ctx);
|
||||
Release cipher context at ctx.
|
||||
|
||||
4.1) AES
|
||||
4.1.1) AES in CBC block mode.
|
||||
LIBSSH2_AES
|
||||
#define as 1 if the crypto library supports AES in CBC mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_aes128
|
||||
AES-128-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes192
|
||||
AES-192-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes256
|
||||
AES-256-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.1.2) AES in CTR block mode.
|
||||
LIBSSH2_AES_CTR
|
||||
#define as 1 if the crypto library supports AES in CTR mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_aes128ctr
|
||||
AES-128-CTR algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes192ctr
|
||||
AES-192-CTR algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes256ctr
|
||||
AES-256-CTR algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.2) Blowfish in CBC block mode.
|
||||
LIBSSH2_BLOWFISH
|
||||
#define as 1 if the crypto library supports blowfish in CBC mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_blowfish
|
||||
Blowfish-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.3) RC4.
|
||||
LIBSSH2_RC4
|
||||
#define as 1 if the crypto library supports RC4 (arcfour), else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_arcfour
|
||||
RC4 algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.4) CAST5 in CBC block mode.
|
||||
LIBSSH2_CAST
|
||||
#define 1 if the crypto library supports cast, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_cast5
|
||||
CAST5-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.5) Tripple DES in CBC block mode.
|
||||
LIBSSH2_3DES
|
||||
#define as 1 if the crypto library supports TripleDES in CBC mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_3des
|
||||
TripleDES-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
|
||||
5) Diffie-Hellman support.
|
||||
|
||||
5.1) Diffie-Hellman context.
|
||||
_libssh2_dh_ctx
|
||||
Type of a Diffie-Hellman computation context.
|
||||
Must always be defined.
|
||||
|
||||
5.2) Diffie-Hellman computation procedures.
|
||||
void libssh2_dh_init(_libssh2_dh_ctx *dhctx);
|
||||
Initializes the Diffie-Hellman context at `dhctx'. No effective context
|
||||
creation needed here.
|
||||
|
||||
int libssh2_dh_key_pair(_libssh2_dh_ctx *dhctx, _libssh2_bn *public,
|
||||
_libssh2_bn *g, _libssh2_bn *p, int group_order,
|
||||
_libssh2_bn_ctx *bnctx);
|
||||
Generates a Diffie-Hellman key pair using base `g', prime `p' and the given
|
||||
`group_order'. Can use the given big number context `bnctx' if needed.
|
||||
The private key is stored as opaque in the Diffie-Hellman context `*dhctx' and
|
||||
the public key is returned in `public'.
|
||||
0 is returned upon success, else -1.
|
||||
|
||||
int libssh2_dh_secret(_libssh2_dh_ctx *dhctx, _libssh2_bn *secret,
|
||||
_libssh2_bn *f, _libssh2_bn *p, _libssh2_bn_ctx * bnctx)
|
||||
Computes the Diffie-Hellman secret from the previously created context `*dhctx',
|
||||
the public key `f' from the other party and the same prime `p' used at
|
||||
context creation. The result is stored in `secret'.
|
||||
0 is returned upon success, else -1.
|
||||
|
||||
void libssh2_dh_dtor(_libssh2_dh_ctx *dhctx)
|
||||
Destroys Diffie-Hellman context at `dhctx' and resets its storage.
|
||||
|
||||
|
||||
6) Big numbers.
|
||||
Positive multi-byte integers support is sufficient.
|
||||
|
||||
6.1) Computation contexts.
|
||||
This has a real meaning if the big numbers computations need some context
|
||||
storage. If not, use a dummy type and functions (macros).
|
||||
|
||||
_libssh2_bn_ctx
|
||||
Type of multiple precision computation context. May not be empty. if not used,
|
||||
#define as char, for example.
|
||||
|
||||
_libssh2_bn_ctx _libssh2_bn_ctx_new(void);
|
||||
Returns a new multiple precision computation context.
|
||||
|
||||
void _libssh2_bn_ctx_free(_libssh2_bn_ctx ctx);
|
||||
Releases a multiple precision computation context.
|
||||
|
||||
6.2) Computation support.
|
||||
_libssh2_bn
|
||||
Type of multiple precision numbers (aka bignumbers or huge integers) for the
|
||||
crypto library.
|
||||
|
||||
_libssh2_bn * _libssh2_bn_init(void);
|
||||
Creates a multiple precision number (preset to zero).
|
||||
|
||||
_libssh2_bn * _libssh2_bn_init_from_bin(void);
|
||||
Create a multiple precision number intended to be set by the
|
||||
_libssh2_bn_from_bin() function (see below). Unlike _libssh2_bn_init(), this
|
||||
code may be a dummy initializer if the _libssh2_bn_from_bin() actually
|
||||
allocates the number. Returns a value of type _libssh2_bn *.
|
||||
|
||||
void _libssh2_bn_free(_libssh2_bn *bn);
|
||||
Destroys the multiple precision number at bn.
|
||||
|
||||
unsigned long _libssh2_bn_bytes(_libssh2_bn *bn);
|
||||
Get the number of bytes needed to store the bits of the multiple precision
|
||||
number at bn.
|
||||
|
||||
unsigned long _libssh2_bn_bits(_libssh2_bn *bn);
|
||||
Returns the number of bits of multiple precision number at bn.
|
||||
|
||||
int _libssh2_bn_set_word(_libssh2_bn *bn, unsigned long val);
|
||||
Sets the value of bn to val.
|
||||
Returns 1 on success, 0 otherwise.
|
||||
|
||||
_libssh2_bn * _libssh2_bn_from_bin(_libssh2_bn *bn, int len,
|
||||
const unsigned char *val);
|
||||
Converts the positive integer in big-endian form of length len at val
|
||||
into a _libssh2_bn and place it in bn. If bn is NULL, a new _libssh2_bn is
|
||||
created.
|
||||
Returns a pointer to target _libssh2_bn or NULL if error.
|
||||
|
||||
int _libssh2_bn_to_bin(_libssh2_bn *bn, unsigned char *val);
|
||||
Converts the absolute value of bn into big-endian form and store it at
|
||||
val. val must point to _libssh2_bn_bytes(bn) bytes of memory.
|
||||
Returns the length of the big-endian number.
|
||||
|
||||
|
||||
7) Private key algorithms.
|
||||
Format of an RSA public key:
|
||||
a) "ssh-rsa".
|
||||
b) RSA exponent, MSB first, with high order bit = 0.
|
||||
c) RSA modulus, MSB first, with high order bit = 0.
|
||||
Each item is preceded by its 32-bit byte length, MSB first.
|
||||
|
||||
Format of a DSA public key:
|
||||
a) "ssh-dss".
|
||||
b) p, MSB first, with high order bit = 0.
|
||||
c) q, MSB first, with high order bit = 0.
|
||||
d) g, MSB first, with high order bit = 0.
|
||||
e) pub_key, MSB first, with high order bit = 0.
|
||||
Each item is preceded by its 32-bit byte length, MSB first.
|
||||
|
||||
Format of an ECDSA public key:
|
||||
a) "ecdsa-sha2-nistp256" or "ecdsa-sha2-nistp384" or "ecdsa-sha2-nistp521".
|
||||
b) domain: "nistp256", "nistp384" or "nistp521" matching a).
|
||||
c) raw public key ("octal").
|
||||
Each item is preceded by its 32-bit byte length, MSB first.
|
||||
|
||||
Format of an ED25519 public key:
|
||||
a) "ssh-ed25519".
|
||||
b) raw key (32 bytes).
|
||||
Each item is preceded by its 32-bit byte length, MSB first.
|
||||
|
||||
int _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
Reads a private key from file privatekey and extract the public key -->
|
||||
(pubkeydata, pubkeydata_len). Store the associated method (ssh-rsa or ssh-dss)
|
||||
into (method, method_len).
|
||||
Both buffers have to be allocated using LIBSSH2_ALLOC().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase);
|
||||
Gets a private key from bytes at (privatekeydata, privatekeydata_len) and
|
||||
extract the public key --> (pubkeydata, pubkeydata_len). Store the associated
|
||||
method (ssh-rsa or ssh-dss) into (method, method_len).
|
||||
Both buffers have to be allocated using LIBSSH2_ALLOC().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
|
||||
7.1) RSA
|
||||
LIBSSH2_RSA
|
||||
#define as 1 if the crypto library supports RSA, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
libssh2_rsa_ctx
|
||||
Type of an RSA computation context. Generally a struct.
|
||||
|
||||
int _libssh2_rsa_new(libssh2_rsa_ctx **rsa,
|
||||
const unsigned char *edata,
|
||||
unsigned long elen,
|
||||
const unsigned char *ndata,
|
||||
unsigned long nlen,
|
||||
const unsigned char *ddata,
|
||||
unsigned long dlen,
|
||||
const unsigned char *pdata,
|
||||
unsigned long plen,
|
||||
const unsigned char *qdata,
|
||||
unsigned long qlen,
|
||||
const unsigned char *e1data,
|
||||
unsigned long e1len,
|
||||
const unsigned char *e2data,
|
||||
unsigned long e2len,
|
||||
const unsigned char *coeffdata, unsigned long coefflen);
|
||||
Creates a new context for RSA computations from key source values:
|
||||
pdata, plen Prime number p. Only used if private key known (ddata).
|
||||
qdata, qlen Prime number q. Only used if private key known (ddata).
|
||||
ndata, nlen Modulus n.
|
||||
edata, elen Exponent e.
|
||||
ddata, dlen e^-1 % phi(n) = private key. May be NULL if unknown.
|
||||
e1data, e1len dp = d % (p-1). Only used if private key known (dtata).
|
||||
e2data, e2len dq = d % (q-1). Only used if private key known (dtata).
|
||||
coeffdata, coefflen q^-1 % p. Only used if private key known.
|
||||
Returns 0 if OK.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
Note: the current generic code only calls this function with e and n (public
|
||||
key parameters): unless used internally by the backend, it is not needed to
|
||||
support the private key and the other parameters here.
|
||||
|
||||
int _libssh2_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
unsigned const char *passphrase);
|
||||
Reads an RSA private key from file filename into a new RSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *data,
|
||||
size_t data_len,
|
||||
unsigned const char *passphrase);
|
||||
Gets an RSA private key from data into a new RSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_rsa_sha1_verify(libssh2_rsa_ctx *rsa,
|
||||
const unsigned char *sig,
|
||||
unsigned long sig_len,
|
||||
const unsigned char *m, unsigned long m_len);
|
||||
Verify (sig, sig_len) signature of (m, m_len) using an SHA-1 hash and the
|
||||
RSA context.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_rsa_sha1_signv(LIBSSH2_SESSION *session,
|
||||
unsigned char **sig, size_t *siglen,
|
||||
int count, const struct iovec vector[],
|
||||
libssh2_rsa_ctx *ctx);
|
||||
RSA signs the SHA-1 hash computed over the count data chunks in vector.
|
||||
Signature is stored at (sig, siglen).
|
||||
Signature buffer must be allocated from the given session.
|
||||
Returns 0 if OK, else -1.
|
||||
Note: this procedure is optional: if provided, it MUST be defined as a macro.
|
||||
|
||||
int _libssh2_rsa_sha1_sign(LIBSSH2_SESSION *session,
|
||||
libssh2_rsa_ctx *rsactx,
|
||||
const unsigned char *hash,
|
||||
size_t hash_len,
|
||||
unsigned char **signature,
|
||||
size_t *signature_len);
|
||||
RSA signs the (hash, hashlen) SHA-1 hash bytes and stores the allocated
|
||||
signature at (signature, signature_len).
|
||||
Signature buffer must be allocated from the given session.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
Note: this procedure is not used if macro _libssh2_rsa_sha1_signv() is defined.
|
||||
|
||||
void _libssh2_rsa_free(libssh2_rsa_ctx *rsactx);
|
||||
Releases the RSA computation context at rsactx.
|
||||
|
||||
|
||||
7.2) DSA
|
||||
LIBSSH2_DSA
|
||||
#define as 1 if the crypto library supports DSA, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
|
||||
libssh2_dsa_ctx
|
||||
Type of a DSA computation context. Generally a struct.
|
||||
|
||||
int _libssh2_dsa_new(libssh2_dsa_ctx **dsa,
|
||||
const unsigned char *pdata,
|
||||
unsigned long plen,
|
||||
const unsigned char *qdata,
|
||||
unsigned long qlen,
|
||||
const unsigned char *gdata,
|
||||
unsigned long glen,
|
||||
const unsigned char *ydata,
|
||||
unsigned long ylen,
|
||||
const unsigned char *x, unsigned long x_len);
|
||||
Creates a new context for DSA computations from source key values:
|
||||
pdata, plen Prime number p. Only used if private key known (ddata).
|
||||
qdata, qlen Prime number q. Only used if private key known (ddata).
|
||||
gdata, glen G number.
|
||||
ydata, ylen Public key.
|
||||
xdata, xlen Private key. Only taken if xlen non-zero.
|
||||
Returns 0 if OK.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_new_private(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
unsigned const char *passphrase);
|
||||
Gets a DSA private key from file filename into a new DSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *data,
|
||||
size_t data_len,
|
||||
unsigned const char *passphrase);
|
||||
Gets a DSA private key from the data_len-bytes data into a new DSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx *dsactx,
|
||||
const unsigned char *sig,
|
||||
const unsigned char *m, unsigned long m_len);
|
||||
Verify (sig, siglen) signature of (m, m_len) using an SHA-1 hash and the
|
||||
DSA context.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_sha1_sign(libssh2_dsa_ctx *dsactx,
|
||||
const unsigned char *hash,
|
||||
unsigned long hash_len, unsigned char *sig);
|
||||
DSA signs the (hash, hash_len) data using SHA-1 and store the signature at sig.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
void _libssh2_dsa_free(libssh2_dsa_ctx *dsactx);
|
||||
Releases the DSA computation context at dsactx.
|
||||
|
||||
|
||||
7.3) ECDSA
|
||||
LIBSSH2_ECDSA
|
||||
#define as 1 if the crypto library supports ECDSA, else 0.
|
||||
If defined as 0, _libssh2_ec_key should be defined as void and the rest of
|
||||
this section can be omitted.
|
||||
|
||||
EC_MAX_POINT_LEN
|
||||
Maximum point length. Usually defined as ((528 * 2 / 8) + 1) (= 133).
|
||||
|
||||
libssh2_ecdsa_ctx
|
||||
Type of an ECDSA computation context. Generally a struct.
|
||||
|
||||
_libssh2_ec_key
|
||||
Type of an elliptic curve key.
|
||||
|
||||
libssh2_curve_type
|
||||
An enum type defining curve types. Current supported identifiers are:
|
||||
LIBSSH2_EC_CURVE_NISTP256
|
||||
LIBSSH2_EC_CURVE_NISTP384
|
||||
LIBSSH2_EC_CURVE_NISTP521
|
||||
|
||||
int _libssh2_ecdsa_create_key(_libssh2_ec_key **out_private_key,
|
||||
unsigned char **out_public_key_octal,
|
||||
size_t *out_public_key_octal_len,
|
||||
libssh2_curve_type curve_type);
|
||||
Create a new ECDSA private key of type curve_type and return it at
|
||||
out_private_key. If out_public_key_octal is not NULL, store an allocated
|
||||
pointer to the associated public key in "octal" form in it and its length
|
||||
at out_public_key_octal_len.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ecdsa_new_private(libssh2_ecdsa_ctx **ec_ctx,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filename,
|
||||
unsigned const char *passphrase);
|
||||
Reads an ECDSA private key from PEM file filename into a new ECDSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ecdsa_new_private_frommemory(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata,
|
||||
size_t filedata_len,
|
||||
unsigned const char *passphrase);
|
||||
Builds an ECDSA private key from PEM data at filedata of length filedata_len
|
||||
into a new ECDSA context stored at ec_ctx.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ecdsa_curve_name_with_octal_new(libssh2_ecdsa_ctx **ecdsactx,
|
||||
const unsigned char *k,
|
||||
size_t k_len,
|
||||
libssh2_curve_type type);
|
||||
Stores at ecdsactx a new ECDSA context associated with the given curve type
|
||||
and with "octal" form public key (k, k_len).
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ecdsa_new_openssh_private(libssh2_ecdsa_ctx **ec_ctx,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filename,
|
||||
unsigned const char *passphrase);
|
||||
Reads a PEM-encoded ECDSA private key from file filename encrypted with
|
||||
passphrase and stores at ec_ctx a new ECDSA context for it.
|
||||
Return 0 if OK, else -1.
|
||||
Currently used only from openssl backend (ought to be private).
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ecdsa_sign(LIBSSH2_SESSION *session, libssh2_ecdsa_ctx *ec_ctx,
|
||||
const unsigned char *hash, unsigned long hash_len,
|
||||
unsigned char **signature, size_t *signature_len);
|
||||
ECDSA signs the (hash, hashlen) hash bytes and stores the allocated
|
||||
signature at (signature, signature_len). Hash algorithm used should be
|
||||
SHA-256, SHA-384 or SHA-512 depending on type stored in ECDSA context at ec_ctx.
|
||||
Signature buffer must be allocated from the given session.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ecdsa_verify(libssh2_ecdsa_ctx *ctx,
|
||||
const unsigned char *r, size_t r_len,
|
||||
const unsigned char *s, size_t s_len,
|
||||
const unsigned char *m, size_t m_len);
|
||||
Verify the ECDSA signature made of (r, r_len) and (s, s_len) of (m, m_len)
|
||||
using the hash algorithm configured in the ECDSA context ctx.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
libssh2_curve_type _libssh2_ecdsa_get_curve_type(libssh2_ecdsa_ctx *ecdsactx);
|
||||
Returns the curve type associated with given context.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ecdsa_curve_type_from_name(const char *name,
|
||||
libssh2_curve_type *out_type);
|
||||
Stores in out_type the curve type matching string name of the form
|
||||
"ecdsa-sha2-nistpxxx".
|
||||
Return 0 if OK, else -1.
|
||||
Currently used only from openssl backend (ought to be private).
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
void _libssh2_ecdsa_free(libssh2_ecdsa_ctx *ecdsactx);
|
||||
Releases the ECDSA computation context at ecdsactx.
|
||||
|
||||
|
||||
7.4) ED25519
|
||||
LIBSSH2_ED25519
|
||||
#define as 1 if the crypto library supports ED25519, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
|
||||
libssh2_ed25519_ctx
|
||||
Type of an ED25519 computation context. Generally a struct.
|
||||
|
||||
int _libssh2_curve25519_new(LIBSSH2_SESSION *session, libssh2_ed25519_ctx **ctx,
|
||||
uint8_t **out_public_key,
|
||||
uint8_t **out_private_key);
|
||||
Generates an ED25519 key pair, stores a pointer to them at out_private_key
|
||||
and out_public_key respectively and stores at ctx a new ED25519 context for
|
||||
this key.
|
||||
Argument ctx, out_private_key and out_public key may be NULL to disable storing
|
||||
the corresponding value.
|
||||
Length of each key is LIBSSH2_ED25519_KEY_LEN (32 bytes).
|
||||
Key buffers are allocated and should be released by caller after use.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ed25519_new_private(libssh2_ed25519_ctx **ed_ctx,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
const uint8_t *passphrase);
|
||||
Reads an ED25519 private key from PEM file filename into a new ED25519 context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ed25519_new_public(libssh2_ed25519_ctx **ed_ctx,
|
||||
LIBSSH2_SESSION *session,
|
||||
const unsigned char *raw_pub_key,
|
||||
const uint8_t key_len);
|
||||
Stores at ed_ctx a new ED25519 key context for raw public key (raw_pub_key,
|
||||
key_len).
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ed25519_new_private_frommemory(libssh2_ed25519_ctx **ed_ctx,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filedata,
|
||||
size_t filedata_len,
|
||||
unsigned const char *passphrase);
|
||||
Builds an ED25519 private key from PEM data at filedata of length filedata_len
|
||||
into a new ED25519 context stored at ed_ctx.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ed25519_sign(libssh2_ed25519_ctx *ctx, LIBSSH2_SESSION *session,
|
||||
uint8_t **out_sig, size_t *out_sig_len,
|
||||
const uint8_t *message, size_t message_len);
|
||||
ED25519 signs the (message, message_len) bytes and stores the allocated
|
||||
signature at (sig, sig_len).
|
||||
Signature buffer is allocated from the given session.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_ed25519_verify(libssh2_ed25519_ctx *ctx, const uint8_t *s,
|
||||
size_t s_len, const uint8_t *m, size_t m_len);
|
||||
Verify (s, s_len) signature of (m, m_len) using the given ED25519 context.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_curve25519_gen_k(_libssh2_bn **k,
|
||||
uint8_t private_key[LIBSSH2_ED25519_KEY_LEN],
|
||||
uint8_t srvr_public_key[LIBSSH2_ED25519_KEY_LEN]);
|
||||
Computes a shared ED25519 secret key from the given raw server public key and
|
||||
raw client public key and stores it as a big number in *k. Big number should
|
||||
have been initialized before calling this function.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
void _libssh2_ed25519_free(libssh2_ed25519_ctx *ed25519ctx);
|
||||
Releases the ED25519 computation context at ed25519ctx.
|
||||
|
||||
|
||||
8) Miscellaneous
|
||||
|
||||
void libssh2_prepare_iovec(struct iovec *vector, unsigned int len);
|
||||
Prepare len consecutive iovec slots before using them.
|
||||
In example, this is needed to preset unused structure slacks on platforms
|
||||
requiring it.
|
||||
If this is not needed, it should be defined as an empty macro.
|
||||
|
||||
int _libssh2_random(unsigned char *buf, int len);
|
||||
Store len random bytes at buf.
|
||||
Returns 0 if OK, else -1.
|
||||
@@ -7,6 +7,22 @@ Software Foundation, Inc.
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
When Building directly from Master
|
||||
==================================
|
||||
|
||||
If you want to build directly from the git repository, you must first
|
||||
generate the configure script and Makefile using autotools. There is
|
||||
a convenience script that calls all tools in the correct order. Make
|
||||
sure that autoconf, automake and libtool are installed on your system,
|
||||
then execute:
|
||||
|
||||
autoreconf -fi
|
||||
|
||||
After executing this script, you can build the project as usual:
|
||||
|
||||
./configure
|
||||
make
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
@@ -284,8 +300,8 @@ Some ./configure options deserve additional comments:
|
||||
* --with-libgcrypt-prefix=DIR
|
||||
|
||||
libssh2 can use the Libgcrypt library
|
||||
(http://www.gnupg.org/) for cryptographic operations.
|
||||
Either Libgcrypt or OpenSSL is required.
|
||||
(https://www.gnupg.org/) for cryptographic operations.
|
||||
One of the cryptographic libraries is required.
|
||||
|
||||
Configure will attempt to locate Libgcrypt
|
||||
automatically.
|
||||
@@ -298,8 +314,8 @@ Some ./configure options deserve additional comments:
|
||||
* --with-libssl-prefix=[DIR]
|
||||
|
||||
libssh2 can use the OpenSSL library
|
||||
(http://www.openssl.org) for cryptographic operations.
|
||||
Either Libgcrypt or OpenSSL is required.
|
||||
(https://www.openssl.org) for cryptographic operations.
|
||||
One of the cryptographic libraries is required.
|
||||
|
||||
Configure will attempt to locate OpenSSL in the
|
||||
default location.
|
||||
@@ -307,6 +323,20 @@ Some ./configure options deserve additional comments:
|
||||
If your installation of OpenSSL is in another
|
||||
location, specify it using --with-libssl-prefix.
|
||||
|
||||
* --with-mbedtls
|
||||
* --without-mbedtls
|
||||
* --with-libmbedtls-prefix=[DIR]
|
||||
|
||||
libssh2 can use the mbedTLS library
|
||||
(https://tls.mbed.org) for cryptographic operations.
|
||||
One of the cryptographic libraries is required.
|
||||
|
||||
Configure will attempt to locate mbedTLS in the
|
||||
default location.
|
||||
|
||||
If your installation of mbedTLS is in another
|
||||
location, specify it using --with-libmbedtls-prefix.
|
||||
|
||||
* --with-libz
|
||||
* --without-libz
|
||||
* --with-libz-prefix=[DIR]
|
||||
|
||||
@@ -12,6 +12,7 @@ following cryptography libraries:
|
||||
* OpenSSL
|
||||
* Libgcrypt
|
||||
* WinCNG
|
||||
* mbedTLS
|
||||
|
||||
Getting started
|
||||
---------------
|
||||
@@ -19,10 +20,12 @@ Getting started
|
||||
If you are happy with the default options, make a new build directory,
|
||||
change to it, configure the build environment and build the project:
|
||||
|
||||
```
|
||||
mkdir bin
|
||||
cd bin
|
||||
cmake ..
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
libssh2 will be built as a static library and will use any
|
||||
cryptography library available. The library binary will be put in
|
||||
@@ -39,6 +42,11 @@ pass the options to CMake on the command line:
|
||||
|
||||
The following options are available:
|
||||
|
||||
* `LINT=ON`
|
||||
|
||||
Enables running the source code linter when building. Can be `ON` or `OFF`.
|
||||
|
||||
|
||||
* `BUILD_SHARED_LIBS=OFF`
|
||||
|
||||
Determines whether libssh2 is built as a static library or as a
|
||||
@@ -47,9 +55,9 @@ The following options are available:
|
||||
* `CRYPTO_BACKEND=`
|
||||
|
||||
Chooses a specific cryptography library to use for cryptographic
|
||||
operations. Can be `OpenSSL` (http://www.openssl.org),
|
||||
`Libgcrypt` (http://www.gnupg.org/), `WinCNG` (Windows Vista+) or
|
||||
blank to use any library available.
|
||||
operations. Can be `OpenSSL` (https://www.openssl.org),
|
||||
`Libgcrypt` (https://www.gnupg.org/), `WinCNG` (Windows Vista+),
|
||||
`mbedTLS` (https://tls.mbed.org/) or blank to use any library available.
|
||||
|
||||
CMake will attempt to locate the libraries automatically. See [2]
|
||||
for more information.
|
||||
@@ -97,6 +105,10 @@ The following options are available:
|
||||
|
||||
Will enable the libssh2_trace() function for showing debug traces.
|
||||
|
||||
* `CLEAR_MEMORY=ON`
|
||||
|
||||
Securely zero memory before freeing it (if the backend supports this).
|
||||
|
||||
Build tools
|
||||
-----------
|
||||
|
||||
@@ -114,20 +126,27 @@ Tests
|
||||
To test the build, run the appropriate test target for your build
|
||||
system. For example:
|
||||
|
||||
```
|
||||
cmake --build . --target test
|
||||
```
|
||||
or
|
||||
```
|
||||
cmake --build . --target RUN_TESTS
|
||||
```
|
||||
|
||||
How do I use libssh2 in my project if my project doesn't use CMake?
|
||||
-------------------------------------------------------------------
|
||||
|
||||
If you are not using CMake for your own project, install libssh2
|
||||
|
||||
```
|
||||
cmake <libssh2 source location>
|
||||
cmake --build .
|
||||
cmake --build . --target install
|
||||
```
|
||||
or
|
||||
```
|
||||
cmake --build . --target INSTALL
|
||||
```
|
||||
|
||||
and then specify the install location to your project in the normal
|
||||
way for your build environment. If you don't like the default install
|
||||
@@ -161,14 +180,14 @@ builds your project:
|
||||
Libssh2
|
||||
URL <libssh2 download location>
|
||||
URL_HASH SHA1=<libssh2 archive SHA1>
|
||||
INSTALL_COMMAND "")
|
||||
INSTALL_COMMAND "")
|
||||
|
||||
ExternalProject_Add(
|
||||
MyProject DEPENDS Libssh2
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
INSTALL_COMMAND "")
|
||||
|
||||
[1] http://www.cmake.org/cmake/resources/software.html
|
||||
[2] http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html
|
||||
[3] http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#package-registry
|
||||
[4] http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html
|
||||
[1] https://www.cmake.org/cmake/resources/software.html
|
||||
[2] https://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html
|
||||
[3] https://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#package-registry
|
||||
[4] https://blog.kitware.com/wp-content/uploads/2016/01/kitware_quarterly1009.pdf
|
||||
@@ -1,15 +1,17 @@
|
||||
# $Id: Makefile.am,v 1.37 2009/03/26 15:41:15 bagder Exp $
|
||||
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE HACKING TODO \
|
||||
AUTHORS
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE.md HACKING TODO \
|
||||
AUTHORS CMakeLists.txt HACKING-CRYPTO SECURITY.md
|
||||
|
||||
dist_man_MANS = \
|
||||
libssh2_agent_connect.3 \
|
||||
libssh2_agent_disconnect.3 \
|
||||
libssh2_agent_free.3 \
|
||||
libssh2_agent_get_identity.3 \
|
||||
libssh2_agent_get_identity_path.3 \
|
||||
libssh2_agent_init.3 \
|
||||
libssh2_agent_list_identities.3 \
|
||||
libssh2_agent_set_identity_path.3 \
|
||||
libssh2_agent_userauth.3 \
|
||||
libssh2_banner_set.3 \
|
||||
libssh2_base64_decode.3 \
|
||||
@@ -89,6 +91,7 @@ dist_man_MANS = \
|
||||
libssh2_publickey_remove_ex.3 \
|
||||
libssh2_publickey_shutdown.3 \
|
||||
libssh2_scp_recv.3 \
|
||||
libssh2_scp_recv2.3 \
|
||||
libssh2_scp_send.3 \
|
||||
libssh2_scp_send64.3 \
|
||||
libssh2_scp_send_ex.3 \
|
||||
@@ -109,6 +112,7 @@ dist_man_MANS = \
|
||||
libssh2_session_init_ex.3 \
|
||||
libssh2_session_last_errno.3 \
|
||||
libssh2_session_last_error.3 \
|
||||
libssh2_session_set_last_error.3 \
|
||||
libssh2_session_method_pref.3 \
|
||||
libssh2_session_methods.3 \
|
||||
libssh2_session_set_blocking.3 \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.4 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -16,7 +16,17 @@
|
||||
|
||||
# $Id: Makefile.am,v 1.37 2009/03/26 15:41:15 bagder Exp $
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@@ -80,8 +90,6 @@ POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = docs
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(dist_man_MANS) AUTHORS TODO
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
@@ -91,9 +99,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/src/libssh2_config.h \
|
||||
$(top_builddir)/example/libssh2_config.h
|
||||
CONFIG_HEADER = $(top_builddir)/src/libssh2_config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
@@ -147,6 +155,7 @@ am__installdirs = "$(DESTDIR)$(man3dir)"
|
||||
NROFF = nroff
|
||||
MANS = $(dist_man_MANS)
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in AUTHORS TODO
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
@@ -163,6 +172,12 @@ CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
@@ -173,12 +188,14 @@ ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_LIBBCRYPT = @HAVE_LIBBCRYPT@
|
||||
HAVE_LIBCRYPT32 = @HAVE_LIBCRYPT32@
|
||||
HAVE_LIBGCRYPT = @HAVE_LIBGCRYPT@
|
||||
HAVE_LIBMBEDCRYPTO = @HAVE_LIBMBEDCRYPTO@
|
||||
HAVE_LIBSSL = @HAVE_LIBSSL@
|
||||
HAVE_LIBZ = @HAVE_LIBZ@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -194,6 +211,8 @@ LIBCRYPT32 = @LIBCRYPT32@
|
||||
LIBCRYPT32_PREFIX = @LIBCRYPT32_PREFIX@
|
||||
LIBGCRYPT = @LIBGCRYPT@
|
||||
LIBGCRYPT_PREFIX = @LIBGCRYPT_PREFIX@
|
||||
LIBMBEDCRYPTO = @LIBMBEDCRYPTO@
|
||||
LIBMBEDCRYPTO_PREFIX = @LIBMBEDCRYPTO_PREFIX@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBSREQUIRED = @LIBSREQUIRED@
|
||||
@@ -203,14 +222,17 @@ LIBSSL_PREFIX = @LIBSSL_PREFIX@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBZ = @LIBZ@
|
||||
LIBZ_PREFIX = @LIBZ_PREFIX@
|
||||
LIB_FUZZING_ENGINE = @LIB_FUZZING_ENGINE@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBBCRYPT = @LTLIBBCRYPT@
|
||||
LTLIBCRYPT32 = @LTLIBCRYPT32@
|
||||
LTLIBGCRYPT = @LTLIBGCRYPT@
|
||||
LTLIBMBEDCRYPTO = @LTLIBMBEDCRYPTO@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LTLIBSSL = @LTLIBSSL@
|
||||
LTLIBZ = @LTLIBZ@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
@@ -242,6 +264,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
@@ -280,6 +303,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@@ -288,16 +312,18 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE HACKING TODO \
|
||||
AUTHORS
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE.md HACKING TODO \
|
||||
AUTHORS CMakeLists.txt HACKING-CRYPTO SECURITY.md
|
||||
|
||||
dist_man_MANS = \
|
||||
libssh2_agent_connect.3 \
|
||||
libssh2_agent_disconnect.3 \
|
||||
libssh2_agent_free.3 \
|
||||
libssh2_agent_get_identity.3 \
|
||||
libssh2_agent_get_identity_path.3 \
|
||||
libssh2_agent_init.3 \
|
||||
libssh2_agent_list_identities.3 \
|
||||
libssh2_agent_set_identity_path.3 \
|
||||
libssh2_agent_userauth.3 \
|
||||
libssh2_banner_set.3 \
|
||||
libssh2_base64_decode.3 \
|
||||
@@ -377,6 +403,7 @@ dist_man_MANS = \
|
||||
libssh2_publickey_remove_ex.3 \
|
||||
libssh2_publickey_shutdown.3 \
|
||||
libssh2_scp_recv.3 \
|
||||
libssh2_scp_recv2.3 \
|
||||
libssh2_scp_send.3 \
|
||||
libssh2_scp_send64.3 \
|
||||
libssh2_scp_send_ex.3 \
|
||||
@@ -397,6 +424,7 @@ dist_man_MANS = \
|
||||
libssh2_session_init_ex.3 \
|
||||
libssh2_session_last_errno.3 \
|
||||
libssh2_session_last_error.3 \
|
||||
libssh2_session_set_last_error.3 \
|
||||
libssh2_session_method_pref.3 \
|
||||
libssh2_session_methods.3 \
|
||||
libssh2_session_set_blocking.3 \
|
||||
@@ -475,14 +503,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign docs/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign docs/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
@@ -548,8 +575,10 @@ ctags CTAGS:
|
||||
|
||||
cscope cscopelist:
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
distdir-am: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
@@ -699,6 +728,8 @@ uninstall-man: uninstall-man3
|
||||
ps ps-am tags-am uninstall uninstall-am uninstall-man \
|
||||
uninstall-man3
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
||||
100
docs/SECURITY.md
Normal file
100
docs/SECURITY.md
Normal file
@@ -0,0 +1,100 @@
|
||||
libssh2 security
|
||||
================
|
||||
|
||||
This document is intended to provide guidance on how security vulnerabilities
|
||||
should be handled in the libssh2 project.
|
||||
|
||||
Publishing Information
|
||||
----------------------
|
||||
|
||||
All known and public libssh2 vulnerabilities will be listed on [the libssh2
|
||||
web site](https://www.libssh2.org/).
|
||||
|
||||
Security vulnerabilities should not be entered in the project's public bug
|
||||
tracker unless the necessary configuration is in place to limit access to the
|
||||
issue to only the reporter and the project's security team.
|
||||
|
||||
Vulnerability Handling
|
||||
----------------------
|
||||
|
||||
The typical process for handling a new security vulnerability is as follows.
|
||||
|
||||
No information should be made public about a vulnerability until it is
|
||||
formally announced at the end of this process. That means, for example that a
|
||||
bug tracker entry must NOT be created to track the issue since that will make
|
||||
the issue public and it should not be discussed on the project's public
|
||||
mailing list. Also messages associated with any commits should not make any
|
||||
reference to the security nature of the commit if done prior to the public
|
||||
announcement.
|
||||
|
||||
- The person discovering the issue, the reporter, reports the vulnerability
|
||||
privately to `libssh2-security@haxx.se`. That's an email alias that reaches a
|
||||
handful of selected and trusted people.
|
||||
|
||||
- Messages that do not relate to the reporting or managing of an undisclosed
|
||||
security vulnerability in libssh2 are ignored and no further action is
|
||||
required.
|
||||
|
||||
- A person in the security team sends an e-mail to the original reporter to
|
||||
acknowledge the report.
|
||||
|
||||
- The security team investigates the report and either rejects it or accepts
|
||||
it.
|
||||
|
||||
- If the report is rejected, the team writes to the reporter to explain why.
|
||||
|
||||
- If the report is accepted, the team writes to the reporter to let him/her
|
||||
know it is accepted and that they are working on a fix.
|
||||
|
||||
- The security team discusses the problem, works out a fix, considers the
|
||||
impact of the problem and suggests a release schedule. This discussion
|
||||
should involve the reporter as much as possible.
|
||||
|
||||
- The release of the information should be "as soon as possible" and is most
|
||||
often synced with an upcoming release that contains the fix. If the
|
||||
reporter, or anyone else, thinks the next planned release is too far away
|
||||
then a separate earlier release for security reasons should be considered.
|
||||
|
||||
- Write a security advisory draft about the problem that explains what the
|
||||
problem is, its impact, which versions it affects, solutions or
|
||||
workarounds, when the release is out and make sure to credit all
|
||||
contributors properly.
|
||||
|
||||
- Request a CVE number from
|
||||
[distros@openwall](http://oss-security.openwall.org/wiki/mailing-lists/distros)
|
||||
when also informing and preparing them for the upcoming public security
|
||||
vulnerability announcement - attach the advisory draft for information. Note
|
||||
that 'distros' won't accept an embargo longer than 14 days.
|
||||
|
||||
- Update the "security advisory" with the CVE number.
|
||||
|
||||
- The security team commits the fix in a private branch. The commit message
|
||||
should ideally contain the CVE number. This fix is usually also distributed
|
||||
to the 'distros' mailing list to allow them to use the fix prior to the
|
||||
public announcement.
|
||||
|
||||
- At the day of the next release, the private branch is merged into the master
|
||||
branch and pushed. Once pushed, the information is accessible to the public
|
||||
and the actual release should follow suit immediately afterwards.
|
||||
|
||||
- The project team creates a release that includes the fix.
|
||||
|
||||
- The project team announces the release and the vulnerability to the world in
|
||||
the same manner we always announce releases. It gets sent to the libssh2
|
||||
mailing list and the oss-security mailing list.
|
||||
|
||||
- The security web page on the web site should get the new vulnerability
|
||||
mentioned.
|
||||
|
||||
LIBSSH2-SECURITY (at haxx dot se)
|
||||
--------------------------------
|
||||
|
||||
Who is on this list? There are a couple of criteria you must meet, and then we
|
||||
might ask you to join the list or you can ask to join it. It really isn't very
|
||||
formal. We basically only require that you have a long-term presence in the
|
||||
libssh2 project and you have shown an understanding for the project and its way
|
||||
of working. You must've been around for a good while and you should have no
|
||||
plans in vanishing in the near future.
|
||||
|
||||
We do not make the list of participants public mostly because it tends to vary
|
||||
somewhat over time and a list somewhere will only risk getting outdated.
|
||||
22
docs/libssh2_agent_get_identity_path.3
Normal file
22
docs/libssh2_agent_get_identity_path.3
Normal file
@@ -0,0 +1,22 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2019 by Will Cosgrove
|
||||
.\"
|
||||
.TH libssh2_agent_get_identity_path 3 "6 Mar 2019" "libssh2 1.9" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_agent_get_identity_path - gets the custom ssh-agent socket path
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
const char *
|
||||
libssh2_agent_get_identity_path(LIBSSH2_AGENT *agent);
|
||||
.SH DESCRIPTION
|
||||
Returns the custom agent identity socket path if set using libssh2_agent_set_identity_path()
|
||||
|
||||
.SH RETURN VALUE
|
||||
Returns the socket path on disk.
|
||||
.SH AVAILABILITY
|
||||
Added in libssh2 1.9
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_agent_init(3)
|
||||
.BR libssh2_agent_set_identity_path(3)
|
||||
|
||||
22
docs/libssh2_agent_set_identity_path.3
Normal file
22
docs/libssh2_agent_set_identity_path.3
Normal file
@@ -0,0 +1,22 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2019 by Will Cosgrove
|
||||
.\"
|
||||
.TH libssh2_agent_set_identity_path 3 "6 Mar 2019" "libssh2 1.9" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_agent_set_identity_path - set an ssh-agent socket path on disk
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
void
|
||||
libssh2_agent_set_identity_path(LIBSSH2_AGENT *agent, const char *path);
|
||||
.SH DESCRIPTION
|
||||
Allows a custom agent identity socket path instead of the default SSH_AUTH_SOCK env value
|
||||
|
||||
.SH RETURN VALUE
|
||||
Returns void
|
||||
.SH AVAILABILITY
|
||||
Added in libssh2 1.9
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_agent_init(3)
|
||||
.BR libssh2_agent_get_identity_path(3)
|
||||
|
||||
@@ -8,7 +8,7 @@ int
|
||||
libssh2_channel_wait_eof(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
.SH DESCRIPTION
|
||||
Wait for the remote end to acknowledge an EOF request.
|
||||
Wait for the remote end to send EOF.
|
||||
|
||||
.SH RETURN VALUE
|
||||
Return 0 on success or negative on failure. It returns
|
||||
|
||||
@@ -11,12 +11,12 @@ libssh2_hostkey_hash(LIBSSH2_SESSION *session, int hash_type);
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
\fIhash_type\fP - One of: \fBLIBSSH2_HOSTKEY_HASH_MD5\fP or
|
||||
\fBLIBSSH2_HOSTKEY_HASH_SHA1\fP.
|
||||
\fIhash_type\fP - One of: \fBLIBSSH2_HOSTKEY_HASH_MD5\fP,
|
||||
\fBLIBSSH2_HOSTKEY_HASH_SHA1\fP or \fBLIBSSH2_HOSTKEY_HASH_SHA256\fP.
|
||||
|
||||
Returns the computed digest of the remote system's hostkey. The length of
|
||||
the returned string is hash_type specific (e.g. 16 bytes for MD5,
|
||||
20 bytes for SHA1).
|
||||
20 bytes for SHA1, 32 bytes for SHA256).
|
||||
.SH RETURN VALUE
|
||||
Computed hostkey hash value, or NULL if the information is not available
|
||||
(either the session has not yet been started up, or the requested hash
|
||||
|
||||
@@ -8,6 +8,9 @@ LIBSSH2_CHANNEL *
|
||||
libssh2_scp_recv(LIBSSH2_SESSION *session, const char *path, struct stat *sb);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This function is \fBDEPRECATED\fP. Use \fIlibssh2_scp_recv2(3)\fP
|
||||
instead!
|
||||
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
|
||||
32
docs/libssh2_scp_recv2.3
Normal file
32
docs/libssh2_scp_recv2.3
Normal file
@@ -0,0 +1,32 @@
|
||||
.TH libssh2_scp_recv2 3 "29 Jun 2015" "libssh2 1.6.1" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_scp_recv2 - request a remote file via SCP
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
LIBSSH2_CHANNEL *
|
||||
libssh2_scp_recv2(LIBSSH2_SESSION *session, const char *path, struct_stat *sb);
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
\fIpath\fP - Full path and filename of file to transfer. That is the remote
|
||||
file name.
|
||||
|
||||
\fIsb\fP - Populated with remote file's size, mode, mtime, and atime
|
||||
|
||||
Request a file from the remote host via SCP.
|
||||
.SH RETURN VALUE
|
||||
Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors.
|
||||
.SH ERRORS
|
||||
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
|
||||
|
||||
\fILIBSSH2_ERROR_SCP_PROTOCOL\fP -
|
||||
|
||||
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would
|
||||
block.
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_init_ex(3)
|
||||
.BR libssh2_channel_open_ex(3)
|
||||
|
||||
@@ -32,11 +32,43 @@ function returns 0, the packet will be accepted nonetheless.
|
||||
.IP LIBSSH2_CALLBACK_X11
|
||||
Called when an X11 connection has been accepted
|
||||
.IP LIBSSH2_CALLBACK_SEND
|
||||
Called when libssh2 wants to send some data on the connection.
|
||||
Can be set to a custom function to handle I/O your own way.
|
||||
Called when libssh2 wants to send data on the connection. Can be set to a
|
||||
custom function to handle I/O your own way.
|
||||
|
||||
The prototype of the callback:
|
||||
|
||||
.nf
|
||||
ssize_t sendcb(libssh2_socket_t sockfd, const void *buffer,
|
||||
size_t length, int flags, void **abstract);
|
||||
.fi
|
||||
|
||||
\fBsockfd\fP is the socket to write to, \fBbuffer\fP points to the data to
|
||||
send, \fBlength\fP is the size of the data, \fBflags\fP is the flags that
|
||||
would've been used to a \fIsend()\fP call and \fBabstract\fP is a pointer to
|
||||
the abstract pointer set in the \fIlibssh2_session_init_ex(3)\fP call.
|
||||
|
||||
The callback returns the number of bytes sent, or -1 for error. The special
|
||||
return code \fB-EAGAIN\fP can be returned to signal that the send was aborted
|
||||
to prevent getting blocked and it needs to be called again.
|
||||
.IP LIBSSH2_CALLBACK_RECV
|
||||
Called when libssh2 wants to receive some data from the connection.
|
||||
Can be set to a custom function to handle I/O your own way.
|
||||
Called when libssh2 wants to read data from the connection. Can be set to a
|
||||
custom function to handle I/O your own way.
|
||||
|
||||
The prototype of the callback:
|
||||
|
||||
.nf
|
||||
ssize_t recvcb(libssh2_socket_t sockfd, void *buffer,
|
||||
size_t length, int flags, void **abstract);
|
||||
.fi
|
||||
|
||||
\fBsockfd\fP is the socket to read from, \fBbuffer\fP where to store received
|
||||
data into, \fBlength\fP is the size of the buffer, \fBflags\fP is the flags
|
||||
that would've been used to a \fIrecv()\fP call and \fBabstract\fP is a pointer
|
||||
to the abstract pointer set in the \fIlibssh2_session_init_ex(3)\fP call.
|
||||
|
||||
The callback returns the number of bytes read, or -1 for error. The special
|
||||
return code \fB-EAGAIN\fP can be returned to signal that the read was aborted
|
||||
to prevent getting blocked and it needs to be called again.
|
||||
.SH RETURN VALUE
|
||||
Pointer to previous callback handler. Returns NULL if no prior callback
|
||||
handler was set or the callback type was unknown.
|
||||
|
||||
@@ -18,3 +18,4 @@ Numeric error code corresponding to the the Error Code constants.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_last_error(3)
|
||||
.BR libssh2_session_set_last_error(3)
|
||||
|
||||
@@ -29,3 +29,4 @@ Numeric error code corresponding to the the Error Code constants.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_last_errno(3)
|
||||
.BR libssh2_session_set_last_error(3)
|
||||
|
||||
33
docs/libssh2_session_set_last_error.3
Normal file
33
docs/libssh2_session_set_last_error.3
Normal file
@@ -0,0 +1,33 @@
|
||||
.TH libssh2_session_set_last_error 3 "26 Oct 2015" "libssh2 1.6.1" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_session_set_last_error - sets the internal error state
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
int
|
||||
libssh2_session_set_last_error(LIBSSH2_SESSION *session, int errcode, const char *errmsg)
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
\fIerrcode\fP - One of the error codes as defined in the public
|
||||
libssh2 header file.
|
||||
|
||||
\fIerrmsg\fP - If not NULL, a copy of the given string is stored
|
||||
inside the session object as the error message.
|
||||
|
||||
This function is provided for high level language wrappers
|
||||
(i.e. Python or Perl) and other libraries that may extend libssh2 with
|
||||
additional features while still relying on its error reporting
|
||||
mechanism.
|
||||
|
||||
.SH RETURN VALUE
|
||||
Numeric error code corresponding to the the Error Code constants.
|
||||
|
||||
.SH AVAILABILITY
|
||||
Added in 1.6.1
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_last_error(3)
|
||||
.BR libssh2_session_last_errno(3)
|
||||
@@ -10,9 +10,9 @@ int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
|
||||
const char*** algs);
|
||||
.SH DESCRIPTION
|
||||
\fIsession\fP - An instance of initialized LIBSSH2_SESSION (the function will
|
||||
use its pointer to the memory allocation function). \fImethod_type\fP - Method
|
||||
type. See .BR \fIlibssh2_session_method_pref(3)\fP. \fIalgs\fP - Address of a
|
||||
pointer that will point to an array of returned algorithms
|
||||
use its pointer to the memory allocation function). \fImethod_type\fP -
|
||||
Method type. See \fIlibssh2_session_method_pref(3)\fP. \fIalgs\fP - Address
|
||||
of a pointer that will point to an array of returned algorithms
|
||||
|
||||
Get a list of supported algorithms for the given \fImethod_type\fP. The
|
||||
method_type parameter is equivalent to method_type in
|
||||
@@ -44,9 +44,9 @@ rc = libssh2_session_supported_algs(session,
|
||||
if (rc>0) {
|
||||
/* the call succeeded, do sth. with the list of algorithms
|
||||
(e.g. list them)... */
|
||||
printf("Supported symmetric algorithms:\n");
|
||||
printf("Supported symmetric algorithms:\\n");
|
||||
for ( i=0; i<rc; i++ )
|
||||
printf("\t%s\n", algorithms[i]);
|
||||
printf("\\t%s\\n", algorithms[i]);
|
||||
|
||||
/* ... and free the allocated memory when not needed anymore */
|
||||
libssh2_free(session, algorithms);
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
.TH libssh2_sftp_get_channel 3 "9 Sep 2011" "libssh2 1.4.0" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_sftp_get_channel - return the channel of sftp
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
.fi
|
||||
LIBSSH2_CHANNEL *libssh2_sftp_get_channel(LIBSSH2_SFTP *sftp);
|
||||
.SH DESCRIPTION
|
||||
\fIsftp\fP - SFTP instance as returned by
|
||||
.BR libssh2_sftp_init(3)
|
||||
|
||||
Return the channel of the given sftp handle.
|
||||
.SH RETURN VALUE
|
||||
The channel of the SFTP instance or NULL if something was wrong.
|
||||
.SH AVAILABILITY
|
||||
Added in 1.4.0
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_sftp_init(3)
|
||||
.TH libssh2_sftp_get_channel 3 "9 Sep 2011" "libssh2 1.4.0" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_sftp_get_channel - return the channel of sftp
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
.fi
|
||||
LIBSSH2_CHANNEL *libssh2_sftp_get_channel(LIBSSH2_SFTP *sftp);
|
||||
.SH DESCRIPTION
|
||||
\fIsftp\fP - SFTP instance as returned by
|
||||
.BR libssh2_sftp_init(3)
|
||||
|
||||
Return the channel of the given sftp handle.
|
||||
.SH RETURN VALUE
|
||||
The channel of the SFTP instance or NULL if something was wrong.
|
||||
.SH AVAILABILITY
|
||||
Added in 1.4.0
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_sftp_init(3)
|
||||
|
||||
101
example/CMakeLists.txt
Normal file
101
example/CMakeLists.txt
Normal file
@@ -0,0 +1,101 @@
|
||||
# Copyright (c) 2014, 2015 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckSymbolExists)
|
||||
include(CopyRuntimeDependencies)
|
||||
include(SocketLibraries)
|
||||
|
||||
set(EXAMPLES
|
||||
direct_tcpip
|
||||
ssh2
|
||||
scp
|
||||
scp_nonblock
|
||||
scp_write
|
||||
scp_write_nonblock
|
||||
sftp
|
||||
sftp_nonblock
|
||||
sftp_write
|
||||
sftp_write_nonblock
|
||||
sftp_mkdir
|
||||
sftp_mkdir_nonblock
|
||||
sftp_RW_nonblock
|
||||
sftp_write_sliding
|
||||
sftpdir
|
||||
sftpdir_nonblock
|
||||
ssh2_exec
|
||||
ssh2_agent
|
||||
ssh2_agent_forwarding
|
||||
ssh2_echo
|
||||
sftp_append
|
||||
subsystem_netconf
|
||||
tcpip-forward)
|
||||
|
||||
append_needed_socket_libraries(LIBRARIES)
|
||||
|
||||
foreach(example ${EXAMPLES})
|
||||
add_executable(example-${example} ${example}.c)
|
||||
list(APPEND EXAMPLE_TARGETS example-${example})
|
||||
# to find generated header
|
||||
target_include_directories(example-${example} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(example-${example} libssh2 ${LIBRARIES})
|
||||
endforeach()
|
||||
add_target_to_copy_dependencies(
|
||||
TARGET copy_example_dependencies
|
||||
DEPENDENCIES ${RUNTIME_DEPENDENCIES}
|
||||
BEFORE_TARGETS ${EXAMPLE_TARGETS})
|
||||
|
||||
## Platform checks
|
||||
check_include_files(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||
check_include_files(stdlib.h HAVE_STDLIB_H)
|
||||
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
|
||||
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
|
||||
check_include_files(sys/time.h HAVE_SYS_TIME_H)
|
||||
check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
|
||||
check_include_files(netinet/in.h HAVE_NETINET_IN_H)
|
||||
check_include_files(winsock2.h HAVE_WINSOCK2_H)
|
||||
|
||||
check_symbol_exists(strcasecmp strings.h HAVE_STRCASECMP)
|
||||
check_symbol_exists(_stricmp string.h HAVE__STRICMP)
|
||||
check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF)
|
||||
check_symbol_exists(_snprintf stdio.h HAVE__SNPRINTF)
|
||||
|
||||
check_symbol_exists(__func__ "" HAVE___FUNC__)
|
||||
check_symbol_exists(__FUNCTION__ "" HAVE___FUNCTION__)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libssh2_config_cmake.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libssh2_config.h)
|
||||
@@ -1,17 +1,17 @@
|
||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||
|
||||
EXTRA_DIST = libssh2_config.h.in
|
||||
EXTRA_DIST = libssh2_config.h.in libssh2_config_cmake.h.in CMakeLists.txt
|
||||
|
||||
# samples
|
||||
noinst_PROGRAMS = direct_tcpip ssh2 scp scp_nonblock scp_write \
|
||||
scp_write_nonblock sftp sftp_nonblock sftp_write sftp_write_nonblock \
|
||||
sftp_mkdir sftp_mkdir_nonblock sftp_RW_nonblock sftp_write_sliding \
|
||||
sftpdir sftpdir_nonblock ssh2_exec ssh2_agent ssh2_echo sftp_append \
|
||||
subsystem_netconf tcpip-forward
|
||||
sftpdir sftpdir_nonblock ssh2_exec ssh2_agent ssh2_agent_forwarding \
|
||||
ssh2_echo sftp_append subsystem_netconf tcpip-forward
|
||||
|
||||
if HAVE_SYS_UN_H
|
||||
noinst_PROGRAMS += x11
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/example
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/example -I../src
|
||||
LDADD = $(top_builddir)/src/libssh2.la
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.14.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.4 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -15,7 +15,17 @@
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
@@ -86,13 +96,12 @@ noinst_PROGRAMS = direct_tcpip$(EXEEXT) ssh2$(EXEEXT) scp$(EXEEXT) \
|
||||
sftp_mkdir_nonblock$(EXEEXT) sftp_RW_nonblock$(EXEEXT) \
|
||||
sftp_write_sliding$(EXEEXT) sftpdir$(EXEEXT) \
|
||||
sftpdir_nonblock$(EXEEXT) ssh2_exec$(EXEEXT) \
|
||||
ssh2_agent$(EXEEXT) ssh2_echo$(EXEEXT) sftp_append$(EXEEXT) \
|
||||
ssh2_agent$(EXEEXT) ssh2_agent_forwarding$(EXEEXT) \
|
||||
ssh2_echo$(EXEEXT) sftp_append$(EXEEXT) \
|
||||
subsystem_netconf$(EXEEXT) tcpip-forward$(EXEEXT) \
|
||||
$(am__EXEEXT_1)
|
||||
@HAVE_SYS_UN_H_TRUE@am__append_1 = x11
|
||||
subdir = example
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
$(srcdir)/libssh2_config.h.in $(top_srcdir)/depcomp
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
@@ -102,8 +111,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/src/libssh2_config.h libssh2_config.h
|
||||
CONFIG_HEADER = $(top_builddir)/src/libssh2_config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
@HAVE_SYS_UN_H_TRUE@am__EXEEXT_1 = x11$(EXEEXT)
|
||||
@@ -184,6 +194,10 @@ ssh2_agent_SOURCES = ssh2_agent.c
|
||||
ssh2_agent_OBJECTS = ssh2_agent.$(OBJEXT)
|
||||
ssh2_agent_LDADD = $(LDADD)
|
||||
ssh2_agent_DEPENDENCIES = $(top_builddir)/src/libssh2.la
|
||||
ssh2_agent_forwarding_SOURCES = ssh2_agent_forwarding.c
|
||||
ssh2_agent_forwarding_OBJECTS = ssh2_agent_forwarding.$(OBJEXT)
|
||||
ssh2_agent_forwarding_LDADD = $(LDADD)
|
||||
ssh2_agent_forwarding_DEPENDENCIES = $(top_builddir)/src/libssh2.la
|
||||
ssh2_echo_SOURCES = ssh2_echo.c
|
||||
ssh2_echo_OBJECTS = ssh2_echo.$(OBJEXT)
|
||||
ssh2_echo_LDADD = $(LDADD)
|
||||
@@ -218,7 +232,20 @@ am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
DEFAULT_INCLUDES =
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__maybe_remake_depfiles = depfiles
|
||||
am__depfiles_remade = ./$(DEPDIR)/direct_tcpip.Po ./$(DEPDIR)/scp.Po \
|
||||
./$(DEPDIR)/scp_nonblock.Po ./$(DEPDIR)/scp_write.Po \
|
||||
./$(DEPDIR)/scp_write_nonblock.Po ./$(DEPDIR)/sftp.Po \
|
||||
./$(DEPDIR)/sftp_RW_nonblock.Po ./$(DEPDIR)/sftp_append.Po \
|
||||
./$(DEPDIR)/sftp_mkdir.Po ./$(DEPDIR)/sftp_mkdir_nonblock.Po \
|
||||
./$(DEPDIR)/sftp_nonblock.Po ./$(DEPDIR)/sftp_write.Po \
|
||||
./$(DEPDIR)/sftp_write_nonblock.Po \
|
||||
./$(DEPDIR)/sftp_write_sliding.Po ./$(DEPDIR)/sftpdir.Po \
|
||||
./$(DEPDIR)/sftpdir_nonblock.Po ./$(DEPDIR)/ssh2.Po \
|
||||
./$(DEPDIR)/ssh2_agent.Po ./$(DEPDIR)/ssh2_agent_forwarding.Po \
|
||||
./$(DEPDIR)/ssh2_echo.Po ./$(DEPDIR)/ssh2_exec.Po \
|
||||
./$(DEPDIR)/subsystem_netconf.Po ./$(DEPDIR)/tcpip-forward.Po \
|
||||
./$(DEPDIR)/x11.Po
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
@@ -242,21 +269,22 @@ SOURCES = direct_tcpip.c scp.c scp_nonblock.c scp_write.c \
|
||||
scp_write_nonblock.c sftp.c sftp_RW_nonblock.c sftp_append.c \
|
||||
sftp_mkdir.c sftp_mkdir_nonblock.c sftp_nonblock.c \
|
||||
sftp_write.c sftp_write_nonblock.c sftp_write_sliding.c \
|
||||
sftpdir.c sftpdir_nonblock.c ssh2.c ssh2_agent.c ssh2_echo.c \
|
||||
ssh2_exec.c subsystem_netconf.c tcpip-forward.c x11.c
|
||||
sftpdir.c sftpdir_nonblock.c ssh2.c ssh2_agent.c \
|
||||
ssh2_agent_forwarding.c ssh2_echo.c ssh2_exec.c \
|
||||
subsystem_netconf.c tcpip-forward.c x11.c
|
||||
DIST_SOURCES = direct_tcpip.c scp.c scp_nonblock.c scp_write.c \
|
||||
scp_write_nonblock.c sftp.c sftp_RW_nonblock.c sftp_append.c \
|
||||
sftp_mkdir.c sftp_mkdir_nonblock.c sftp_nonblock.c \
|
||||
sftp_write.c sftp_write_nonblock.c sftp_write_sliding.c \
|
||||
sftpdir.c sftpdir_nonblock.c ssh2.c ssh2_agent.c ssh2_echo.c \
|
||||
ssh2_exec.c subsystem_netconf.c tcpip-forward.c x11.c
|
||||
sftpdir.c sftpdir_nonblock.c ssh2.c ssh2_agent.c \
|
||||
ssh2_agent_forwarding.c ssh2_echo.c ssh2_exec.c \
|
||||
subsystem_netconf.c tcpip-forward.c x11.c
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
|
||||
$(LISP)libssh2_config.h.in
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
@@ -273,8 +301,7 @@ am__define_uniq_tagged_files = \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
@@ -291,6 +318,12 @@ CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
@@ -301,12 +334,14 @@ ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_LIBBCRYPT = @HAVE_LIBBCRYPT@
|
||||
HAVE_LIBCRYPT32 = @HAVE_LIBCRYPT32@
|
||||
HAVE_LIBGCRYPT = @HAVE_LIBGCRYPT@
|
||||
HAVE_LIBMBEDCRYPTO = @HAVE_LIBMBEDCRYPTO@
|
||||
HAVE_LIBSSL = @HAVE_LIBSSL@
|
||||
HAVE_LIBZ = @HAVE_LIBZ@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -322,6 +357,8 @@ LIBCRYPT32 = @LIBCRYPT32@
|
||||
LIBCRYPT32_PREFIX = @LIBCRYPT32_PREFIX@
|
||||
LIBGCRYPT = @LIBGCRYPT@
|
||||
LIBGCRYPT_PREFIX = @LIBGCRYPT_PREFIX@
|
||||
LIBMBEDCRYPTO = @LIBMBEDCRYPTO@
|
||||
LIBMBEDCRYPTO_PREFIX = @LIBMBEDCRYPTO_PREFIX@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBSREQUIRED = @LIBSREQUIRED@
|
||||
@@ -331,14 +368,17 @@ LIBSSL_PREFIX = @LIBSSL_PREFIX@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBZ = @LIBZ@
|
||||
LIBZ_PREFIX = @LIBZ_PREFIX@
|
||||
LIB_FUZZING_ENGINE = @LIB_FUZZING_ENGINE@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBBCRYPT = @LTLIBBCRYPT@
|
||||
LTLIBCRYPT32 = @LTLIBCRYPT32@
|
||||
LTLIBGCRYPT = @LTLIBGCRYPT@
|
||||
LTLIBMBEDCRYPTO = @LTLIBMBEDCRYPTO@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LTLIBSSL = @LTLIBSSL@
|
||||
LTLIBZ = @LTLIBZ@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
@@ -370,6 +410,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
@@ -408,6 +449,7 @@ pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
@@ -417,11 +459,10 @@ top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||
EXTRA_DIST = libssh2_config.h.in
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/example
|
||||
EXTRA_DIST = libssh2_config.h.in libssh2_config_cmake.h.in CMakeLists.txt
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/example -I../src
|
||||
LDADD = $(top_builddir)/src/libssh2.la
|
||||
all: libssh2_config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
@@ -437,14 +478,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign example/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign example/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
@@ -456,17 +496,6 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
libssh2_config.h: stamp-h2
|
||||
@test -f $@ || rm -f stamp-h2
|
||||
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h2
|
||||
|
||||
stamp-h2: $(srcdir)/libssh2_config.h.in $(top_builddir)/config.status
|
||||
@rm -f stamp-h2
|
||||
cd $(top_builddir) && $(SHELL) ./config.status example/libssh2_config.h
|
||||
|
||||
distclean-hdr:
|
||||
-rm -f libssh2_config.h stamp-h2
|
||||
|
||||
clean-noinstPROGRAMS:
|
||||
@list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
|
||||
echo " rm -f" $$list; \
|
||||
@@ -548,6 +577,10 @@ ssh2_agent$(EXEEXT): $(ssh2_agent_OBJECTS) $(ssh2_agent_DEPENDENCIES) $(EXTRA_ss
|
||||
@rm -f ssh2_agent$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(ssh2_agent_OBJECTS) $(ssh2_agent_LDADD) $(LIBS)
|
||||
|
||||
ssh2_agent_forwarding$(EXEEXT): $(ssh2_agent_forwarding_OBJECTS) $(ssh2_agent_forwarding_DEPENDENCIES) $(EXTRA_ssh2_agent_forwarding_DEPENDENCIES)
|
||||
@rm -f ssh2_agent_forwarding$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(ssh2_agent_forwarding_OBJECTS) $(ssh2_agent_forwarding_LDADD) $(LIBS)
|
||||
|
||||
ssh2_echo$(EXEEXT): $(ssh2_echo_OBJECTS) $(ssh2_echo_DEPENDENCIES) $(EXTRA_ssh2_echo_DEPENDENCIES)
|
||||
@rm -f ssh2_echo$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(ssh2_echo_OBJECTS) $(ssh2_echo_LDADD) $(LIBS)
|
||||
@@ -574,29 +607,36 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/direct_tcpip.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scp.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scp_nonblock.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scp_write.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scp_write_nonblock.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_RW_nonblock.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_append.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_mkdir.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_mkdir_nonblock.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_nonblock.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_write.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_write_nonblock.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_write_sliding.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftpdir.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftpdir_nonblock.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh2.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh2_agent.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh2_echo.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh2_exec.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subsystem_netconf.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpip-forward.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/direct_tcpip.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scp.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scp_nonblock.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scp_write.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scp_write_nonblock.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_RW_nonblock.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_append.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_mkdir.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_mkdir_nonblock.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_nonblock.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_write.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_write_nonblock.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftp_write_sliding.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftpdir.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sftpdir_nonblock.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh2.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh2_agent.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh2_agent_forwarding.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh2_echo.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssh2_exec.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subsystem_netconf.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpip-forward.Po@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11.Po@am__quote@ # am--include-marker
|
||||
|
||||
$(am__depfiles_remade):
|
||||
@$(MKDIR_P) $(@D)
|
||||
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
|
||||
|
||||
am--depfiles: $(am__depfiles_remade)
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@@ -676,8 +716,10 @@ cscopelist-am: $(am__tagged_files)
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
distdir-am: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
@@ -709,7 +751,7 @@ distdir: $(DISTFILES)
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(PROGRAMS) libssh2_config.h
|
||||
all-am: Makefile $(PROGRAMS)
|
||||
installdirs:
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
@@ -747,10 +789,33 @@ clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f ./$(DEPDIR)/direct_tcpip.Po
|
||||
-rm -f ./$(DEPDIR)/scp.Po
|
||||
-rm -f ./$(DEPDIR)/scp_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/scp_write.Po
|
||||
-rm -f ./$(DEPDIR)/scp_write_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_RW_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_append.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_mkdir.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_mkdir_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_write.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_write_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_write_sliding.Po
|
||||
-rm -f ./$(DEPDIR)/sftpdir.Po
|
||||
-rm -f ./$(DEPDIR)/sftpdir_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2_agent.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2_agent_forwarding.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2_echo.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2_exec.Po
|
||||
-rm -f ./$(DEPDIR)/subsystem_netconf.Po
|
||||
-rm -f ./$(DEPDIR)/tcpip-forward.Po
|
||||
-rm -f ./$(DEPDIR)/x11.Po
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-hdr distclean-tags
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
@@ -793,7 +858,30 @@ install-ps-am:
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f ./$(DEPDIR)/direct_tcpip.Po
|
||||
-rm -f ./$(DEPDIR)/scp.Po
|
||||
-rm -f ./$(DEPDIR)/scp_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/scp_write.Po
|
||||
-rm -f ./$(DEPDIR)/scp_write_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_RW_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_append.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_mkdir.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_mkdir_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_write.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_write_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/sftp_write_sliding.Po
|
||||
-rm -f ./$(DEPDIR)/sftpdir.Po
|
||||
-rm -f ./$(DEPDIR)/sftpdir_nonblock.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2_agent.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2_agent_forwarding.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2_echo.Po
|
||||
-rm -f ./$(DEPDIR)/ssh2_exec.Po
|
||||
-rm -f ./$(DEPDIR)/subsystem_netconf.Po
|
||||
-rm -f ./$(DEPDIR)/tcpip-forward.Po
|
||||
-rm -f ./$(DEPDIR)/x11.Po
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
@@ -812,22 +900,24 @@ ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: all install-am install-strip
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \
|
||||
ctags-am distclean distclean-compile distclean-generic \
|
||||
distclean-hdr distclean-libtool distclean-tags distdir dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-data install-data-am install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-html install-html-am \
|
||||
install-info install-info-am install-man install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-strip \
|
||||
installcheck installcheck-am installdirs maintainer-clean \
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
|
||||
clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \
|
||||
ctags ctags-am distclean distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags distdir dvi dvi-am html \
|
||||
html-am info info-am install install-am install-data \
|
||||
install-data-am install-dvi install-dvi-am install-exec \
|
||||
install-exec-am install-html install-html-am install-info \
|
||||
install-info-am install-man install-pdf install-pdf-am \
|
||||
install-ps install-ps-am install-strip installcheck \
|
||||
installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags tags-am uninstall uninstall-am
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
||||
@@ -72,8 +72,8 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
@@ -82,49 +82,50 @@ int main(int argc, char *argv[])
|
||||
int listensock = -1, forwardsock = -1;
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
if(argc > 1)
|
||||
server_ip = argv[1];
|
||||
if (argc > 2)
|
||||
if(argc > 2)
|
||||
username = argv[2];
|
||||
if (argc > 3)
|
||||
if(argc > 3)
|
||||
password = argv[3];
|
||||
if (argc > 4)
|
||||
if(argc > 4)
|
||||
local_listenip = argv[4];
|
||||
if (argc > 5)
|
||||
if(argc > 5)
|
||||
local_listenport = atoi(argv[5]);
|
||||
if (argc > 6)
|
||||
if(argc > 6)
|
||||
remote_desthost = argv[6];
|
||||
if (argc > 7)
|
||||
if(argc > 7)
|
||||
remote_destport = atoi(argv[7]);
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Connect to SSH server */
|
||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (sock == INVALID_SOCKET) {
|
||||
if(sock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open socket!\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (sock == -1) {
|
||||
if(sock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(server_ip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
perror("inet_addr");
|
||||
return -1;
|
||||
}
|
||||
sin.sin_port = htons(22);
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -159,44 +160,46 @@ int main(int argc, char *argv[])
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password"))
|
||||
if(strstr(userauthlist, "password"))
|
||||
auth |= AUTH_PASSWORD;
|
||||
if (strstr(userauthlist, "publickey"))
|
||||
if(strstr(userauthlist, "publickey"))
|
||||
auth |= AUTH_PUBLICKEY;
|
||||
|
||||
/* check for options */
|
||||
if(argc > 8) {
|
||||
if ((auth & AUTH_PASSWORD) && !strcasecmp(argv[8], "-p"))
|
||||
if((auth & AUTH_PASSWORD) && !strcasecmp(argv[8], "-p"))
|
||||
auth = AUTH_PASSWORD;
|
||||
if ((auth & AUTH_PUBLICKEY) && !strcasecmp(argv[8], "-k"))
|
||||
if((auth & AUTH_PUBLICKEY) && !strcasecmp(argv[8], "-k"))
|
||||
auth = AUTH_PUBLICKEY;
|
||||
}
|
||||
|
||||
if (auth & AUTH_PASSWORD) {
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(auth & AUTH_PASSWORD) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
}
|
||||
else if(auth & AUTH_PUBLICKEY) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
listensock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (listensock == INVALID_SOCKET) {
|
||||
if(listensock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open listen socket!\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (listensock == -1) {
|
||||
if(listensock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
@@ -204,18 +207,20 @@ int main(int argc, char *argv[])
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(local_listenport);
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(local_listenip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(local_listenip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
perror("inet_addr");
|
||||
goto shutdown;
|
||||
}
|
||||
sockopt = 1;
|
||||
setsockopt(listensock, SOL_SOCKET, SO_REUSEADDR, &sockopt, sizeof(sockopt));
|
||||
sinlen=sizeof(sin);
|
||||
if (-1 == bind(listensock, (struct sockaddr *)&sin, sinlen)) {
|
||||
setsockopt(listensock, SOL_SOCKET, SO_REUSEADDR, &sockopt,
|
||||
sizeof(sockopt));
|
||||
sinlen = sizeof(sin);
|
||||
if(-1 == bind(listensock, (struct sockaddr *)&sin, sinlen)) {
|
||||
perror("bind");
|
||||
goto shutdown;
|
||||
}
|
||||
if (-1 == listen(listensock, 2)) {
|
||||
if(-1 == listen(listensock, 2)) {
|
||||
perror("listen");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -225,12 +230,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
forwardsock = accept(listensock, (struct sockaddr *)&sin, &sinlen);
|
||||
#ifdef WIN32
|
||||
if (forwardsock == INVALID_SOCKET) {
|
||||
if(forwardsock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to accept forward socket!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
#else
|
||||
if (forwardsock == -1) {
|
||||
if(forwardsock == -1) {
|
||||
perror("accept");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -244,7 +249,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
channel = libssh2_channel_direct_tcpip_ex(session, remote_desthost,
|
||||
remote_destport, shost, sport);
|
||||
if (!channel) {
|
||||
if(!channel) {
|
||||
fprintf(stderr, "Could not open the direct-tcpip channel!\n"
|
||||
"(Note that this can be a problem at the server!"
|
||||
" Please review the server logs.)\n");
|
||||
@@ -254,22 +259,23 @@ int main(int argc, char *argv[])
|
||||
/* Must use non-blocking IO hereafter due to the current libssh2 API */
|
||||
libssh2_session_set_blocking(session, 0);
|
||||
|
||||
while (1) {
|
||||
while(1) {
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(forwardsock, &fds);
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 100000;
|
||||
rc = select(forwardsock + 1, &fds, NULL, NULL, &tv);
|
||||
if (-1 == rc) {
|
||||
if(-1 == rc) {
|
||||
perror("select");
|
||||
goto shutdown;
|
||||
}
|
||||
if (rc && FD_ISSET(forwardsock, &fds)) {
|
||||
if(rc && FD_ISSET(forwardsock, &fds)) {
|
||||
len = recv(forwardsock, buf, sizeof(buf), 0);
|
||||
if (len < 0) {
|
||||
if(len < 0) {
|
||||
perror("read");
|
||||
goto shutdown;
|
||||
} else if (0 == len) {
|
||||
}
|
||||
else if(0 == len) {
|
||||
fprintf(stderr, "The client at %s:%d disconnected!\n", shost,
|
||||
sport);
|
||||
goto shutdown;
|
||||
@@ -277,34 +283,34 @@ int main(int argc, char *argv[])
|
||||
wr = 0;
|
||||
while(wr < len) {
|
||||
i = libssh2_channel_write(channel, buf + wr, len - wr);
|
||||
if (LIBSSH2_ERROR_EAGAIN == i) {
|
||||
if(LIBSSH2_ERROR_EAGAIN == i) {
|
||||
continue;
|
||||
}
|
||||
if (i < 0) {
|
||||
if(i < 0) {
|
||||
fprintf(stderr, "libssh2_channel_write: %d\n", i);
|
||||
goto shutdown;
|
||||
}
|
||||
wr += i;
|
||||
}
|
||||
}
|
||||
while (1) {
|
||||
while(1) {
|
||||
len = libssh2_channel_read(channel, buf, sizeof(buf));
|
||||
if (LIBSSH2_ERROR_EAGAIN == len)
|
||||
if(LIBSSH2_ERROR_EAGAIN == len)
|
||||
break;
|
||||
else if (len < 0) {
|
||||
else if(len < 0) {
|
||||
fprintf(stderr, "libssh2_channel_read: %d", (int)len);
|
||||
goto shutdown;
|
||||
}
|
||||
wr = 0;
|
||||
while (wr < len) {
|
||||
while(wr < len) {
|
||||
i = send(forwardsock, buf + wr, len - wr, 0);
|
||||
if (i <= 0) {
|
||||
if(i <= 0) {
|
||||
perror("write");
|
||||
goto shutdown;
|
||||
}
|
||||
wr += i;
|
||||
}
|
||||
if (libssh2_channel_eof(channel)) {
|
||||
if(libssh2_channel_eof(channel)) {
|
||||
fprintf(stderr, "The server at %s:%d disconnected!\n",
|
||||
remote_desthost, remote_destport);
|
||||
goto shutdown;
|
||||
@@ -320,7 +326,7 @@ shutdown:
|
||||
close(forwardsock);
|
||||
close(listensock);
|
||||
#endif
|
||||
if (channel)
|
||||
if(channel)
|
||||
libssh2_channel_free(channel);
|
||||
libssh2_session_disconnect(session, "Client disconnecting normally");
|
||||
libssh2_session_free(session);
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#undef HAVE_ARPA_INET_H
|
||||
|
||||
/* Define to 1 if you have the declaration of `SecureZeroMemory', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_SECUREZEROMEMORY
|
||||
|
||||
/* disabled non-blocking sockets */
|
||||
#undef HAVE_DISABLED_NONBLOCKING
|
||||
|
||||
@@ -60,6 +64,9 @@
|
||||
/* Define if you have the gcrypt library. */
|
||||
#undef HAVE_LIBGCRYPT
|
||||
|
||||
/* Define if you have the mbedcrypto library. */
|
||||
#undef HAVE_LIBMBEDCRYPTO
|
||||
|
||||
/* Define if you have the ssl library. */
|
||||
#undef HAVE_LIBSSL
|
||||
|
||||
@@ -72,6 +79,9 @@
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset_s' function. */
|
||||
#undef HAVE_MEMSET_S
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
@@ -168,14 +178,16 @@
|
||||
/* Enable "none" MAC -- NOT RECOMMENDED */
|
||||
#undef LIBSSH2_MAC_NONE
|
||||
|
||||
/* Use OpenSSL */
|
||||
/* Use mbedtls */
|
||||
#undef LIBSSH2_MBEDTLS
|
||||
|
||||
/* Use openssl */
|
||||
#undef LIBSSH2_OPENSSL
|
||||
|
||||
/* Use Windows CNG */
|
||||
/* Use wincng */
|
||||
#undef LIBSSH2_WINCNG
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
|
||||
|
||||
72
example/libssh2_config_cmake.h.in
Normal file
72
example/libssh2_config_cmake.h.in
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Headers */
|
||||
#cmakedefine HAVE_UNISTD_H
|
||||
#cmakedefine HAVE_INTTYPES_H
|
||||
#cmakedefine HAVE_STDLIB_H
|
||||
#cmakedefine HAVE_SYS_SELECT_H
|
||||
#cmakedefine HAVE_SYS_SOCKET_H
|
||||
#cmakedefine HAVE_SYS_TIME_H
|
||||
#cmakedefine HAVE_ARPA_INET_H
|
||||
#cmakedefine HAVE_NETINET_IN_H
|
||||
#cmakedefine HAVE_WINSOCK2_H
|
||||
|
||||
/* Functions */
|
||||
#cmakedefine HAVE_STRCASECMP
|
||||
#cmakedefine HAVE__STRICMP
|
||||
#cmakedefine HAVE_SNPRINTF
|
||||
#cmakedefine HAVE__SNPRINTF
|
||||
|
||||
/* Workaround for platforms without POSIX strcasecmp (e.g. Windows) */
|
||||
#ifndef HAVE_STRCASECMP
|
||||
# ifdef HAVE__STRICMP
|
||||
# define strcasecmp _stricmp
|
||||
# define HAVE_STRCASECMP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Symbols */
|
||||
#cmakedefine HAVE___FUNC__
|
||||
#cmakedefine HAVE___FUNCTION__
|
||||
|
||||
/* Workaround for platforms without C90 __func__ */
|
||||
#ifndef HAVE___FUNC__
|
||||
# ifdef HAVE___FUNCTION__
|
||||
# define __func__ __FUNCTION__
|
||||
# define HAVE___FUNC__
|
||||
# endif
|
||||
#endif
|
||||
@@ -38,42 +38,43 @@ int main(int argc, char *argv[])
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *scppath="/tmp/TEST";
|
||||
struct stat fileinfo;
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *scppath = "/tmp/TEST";
|
||||
libssh2_struct_stat fileinfo;
|
||||
int rc;
|
||||
off_t got=0;
|
||||
libssh2_struct_stat_size got = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
if (argc > 2) {
|
||||
if(argc > 2) {
|
||||
username = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if(argc > 3) {
|
||||
password = argv[3];
|
||||
}
|
||||
if (argc > 4) {
|
||||
if(argc > 4) {
|
||||
scppath = argv[4];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -86,8 +87,8 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -119,27 +120,29 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
#define HOME_DIR "/home/username/"
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
HOME_DIR ".ssh/id_rsa.pub",
|
||||
HOME_DIR ".ssh/id_rsa",
|
||||
password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
/* Request a file via SCP */
|
||||
channel = libssh2_scp_recv(session, scppath, &fileinfo);
|
||||
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
|
||||
|
||||
if (!channel) {
|
||||
if(!channel) {
|
||||
fprintf(stderr, "Unable to open a session: %d\n",
|
||||
libssh2_session_last_errno(session));
|
||||
goto shutdown;
|
||||
@@ -148,10 +151,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
while(got < fileinfo.st_size) {
|
||||
char mem[1024];
|
||||
int amount=sizeof(mem);
|
||||
int amount = sizeof(mem);
|
||||
|
||||
if((fileinfo.st_size -got) < amount) {
|
||||
amount = fileinfo.st_size -got;
|
||||
amount = (int)(fileinfo.st_size -got);
|
||||
}
|
||||
|
||||
rc = libssh2_channel_read(channel, mem, amount);
|
||||
@@ -170,7 +173,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session,
|
||||
"Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -85,49 +85,50 @@ int main(int argc, char *argv[])
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *scppath="/tmp/TEST";
|
||||
struct stat fileinfo;
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *scppath = "/tmp/TEST";
|
||||
libssh2_struct_stat fileinfo;
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
long time_ms;
|
||||
#endif
|
||||
int rc;
|
||||
int total = 0;
|
||||
int spin = 0;
|
||||
off_t got=0;
|
||||
libssh2_struct_stat_size got = 0;
|
||||
libssh2_struct_stat_size total = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
if (argc > 2) {
|
||||
if(argc > 2) {
|
||||
username = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if(argc > 3) {
|
||||
password = argv[3];
|
||||
}
|
||||
if (argc > 4) {
|
||||
if(argc > 4) {
|
||||
scppath = argv[4];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -140,14 +141,14 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in)) != 0) {
|
||||
if(connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in))) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create a session instance */
|
||||
session = libssh2_session_init();
|
||||
if (!session)
|
||||
if(!session)
|
||||
return -1;
|
||||
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
@@ -160,9 +161,9 @@ int main(int argc, char *argv[])
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
while ((rc = libssh2_session_handshake(session, sock)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
while((rc = libssh2_session_handshake(session, sock)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
@@ -179,24 +180,25 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/"
|
||||
".ssh/id_rsa.pub",
|
||||
"/home/username/"
|
||||
".ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/"
|
||||
".ssh/id_rsa.pub",
|
||||
"/home/username/"
|
||||
".ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -207,11 +209,11 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
/* Request a file via SCP */
|
||||
fprintf(stderr, "libssh2_scp_recv()!\n");
|
||||
fprintf(stderr, "libssh2_scp_recv2()!\n");
|
||||
do {
|
||||
channel = libssh2_scp_recv(session, scppath, &fileinfo);
|
||||
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
|
||||
|
||||
if (!channel) {
|
||||
if(!channel) {
|
||||
if(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
|
||||
char *err_msg;
|
||||
|
||||
@@ -224,7 +226,7 @@ int main(int argc, char *argv[])
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
}
|
||||
} while (!channel);
|
||||
} while(!channel);
|
||||
fprintf(stderr, "libssh2_scp_recv() is done, now receive data!\n");
|
||||
|
||||
while(got < fileinfo.st_size) {
|
||||
@@ -232,22 +234,22 @@ int main(int argc, char *argv[])
|
||||
int rc;
|
||||
|
||||
do {
|
||||
int amount=sizeof(mem);
|
||||
int amount = sizeof(mem);
|
||||
|
||||
if ((fileinfo.st_size -got) < amount) {
|
||||
amount = fileinfo.st_size - got;
|
||||
if((fileinfo.st_size -got) < amount) {
|
||||
amount = (int)(fileinfo.st_size - got);
|
||||
}
|
||||
|
||||
/* loop until we block */
|
||||
rc = libssh2_channel_read(channel, mem, amount);
|
||||
if (rc > 0) {
|
||||
if(rc > 0) {
|
||||
write(1, mem, rc);
|
||||
got += rc;
|
||||
total += rc;
|
||||
}
|
||||
} while (rc > 0);
|
||||
} while(rc > 0);
|
||||
|
||||
if ((rc == LIBSSH2_ERROR_EAGAIN) && (got < fileinfo.st_size)) {
|
||||
if((rc == LIBSSH2_ERROR_EAGAIN) && (got < fileinfo.st_size)) {
|
||||
/* this is due to blocking that would occur otherwise
|
||||
so we loop on this condition */
|
||||
|
||||
@@ -262,10 +264,11 @@ int main(int argc, char *argv[])
|
||||
gettimeofday(&end, NULL);
|
||||
|
||||
time_ms = tvdiff(end, start);
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin );
|
||||
fprintf(stderr, "Got %ld bytes in %ld ms = %.1f bytes/sec spin: %d\n",
|
||||
(long)total,
|
||||
time_ms, total/(time_ms/1000.0), spin);
|
||||
#else
|
||||
fprintf(stderr, "Got %d bytes spin: %d\n", total, spin);
|
||||
fprintf(stderr, "Got %ld bytes spin: %d\n", (long)total, spin);
|
||||
#endif
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
|
||||
@@ -38,10 +38,10 @@ int main(int argc, char *argv[])
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session = NULL;
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *loclfile="scp_write.c";
|
||||
const char *scppath="/tmp/TEST";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *loclfile = "scp_write.c";
|
||||
const char *scppath = "/tmp/TEST";
|
||||
FILE *local;
|
||||
int rc;
|
||||
char mem[1024];
|
||||
@@ -53,39 +53,40 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
if (argc > 2) {
|
||||
if(argc > 2) {
|
||||
username = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if(argc > 3) {
|
||||
password = argv[3];
|
||||
}
|
||||
if(argc > 4) {
|
||||
loclfile = argv[4];
|
||||
}
|
||||
if (argc > 5) {
|
||||
if(argc > 5) {
|
||||
scppath = argv[5];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
if(!local) {
|
||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
@@ -105,8 +106,8 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -138,18 +139,20 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
#define HOME "/home/username/"
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
HOME ".ssh/id_rsa.pub",
|
||||
HOME ".ssh/id_rsa",
|
||||
password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -159,7 +162,7 @@ int main(int argc, char *argv[])
|
||||
channel = libssh2_scp_send(session, scppath, fileinfo.st_mode & 0777,
|
||||
(unsigned long)fileinfo.st_size);
|
||||
|
||||
if (!channel) {
|
||||
if(!channel) {
|
||||
char *errmsg;
|
||||
int errlen;
|
||||
int err = libssh2_session_last_error(session, &errmsg, &errlen, 0);
|
||||
@@ -170,7 +173,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "SCP session waiting to send file\n");
|
||||
do {
|
||||
nread = fread(mem, 1, sizeof(mem), local);
|
||||
if (nread <= 0) {
|
||||
if(nread <= 0) {
|
||||
/* end of file */
|
||||
break;
|
||||
}
|
||||
@@ -179,7 +182,7 @@ int main(int argc, char *argv[])
|
||||
do {
|
||||
/* write the same data over and over, until error or completion */
|
||||
rc = libssh2_channel_write(channel, ptr, nread);
|
||||
if (rc < 0) {
|
||||
if(rc < 0) {
|
||||
fprintf(stderr, "ERROR %d\n", rc);
|
||||
break;
|
||||
}
|
||||
@@ -188,9 +191,9 @@ int main(int argc, char *argv[])
|
||||
ptr += rc;
|
||||
nread -= rc;
|
||||
}
|
||||
} while (nread);
|
||||
} while(nread);
|
||||
|
||||
} while (1);
|
||||
} while(1);
|
||||
|
||||
fprintf(stderr, "Sending EOF\n");
|
||||
libssh2_channel_send_eof(channel);
|
||||
@@ -207,7 +210,7 @@ int main(int argc, char *argv[])
|
||||
shutdown:
|
||||
|
||||
if(session) {
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
}
|
||||
#ifdef WIN32
|
||||
@@ -215,7 +218,7 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
if (local)
|
||||
if(local)
|
||||
fclose(local);
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
|
||||
@@ -73,10 +73,10 @@ int main(int argc, char *argv[])
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session = NULL;
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *loclfile="scp_write.c";
|
||||
const char *scppath="/tmp/TEST";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *loclfile = "scp_write.c";
|
||||
const char *scppath = "/tmp/TEST";
|
||||
FILE *local;
|
||||
int rc;
|
||||
char mem[1024*100];
|
||||
@@ -92,39 +92,40 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
if (argc > 2) {
|
||||
if(argc > 2) {
|
||||
username = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if(argc > 3) {
|
||||
password = argv[3];
|
||||
}
|
||||
if(argc > 4) {
|
||||
loclfile = argv[4];
|
||||
}
|
||||
if (argc > 5) {
|
||||
if(argc > 5) {
|
||||
scppath = argv[5];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
if(!local) {
|
||||
fprintf(stderr, "Can't local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
@@ -140,8 +141,8 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -158,8 +159,8 @@ int main(int argc, char *argv[])
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
while ((rc = libssh2_session_handshake(session, sock))
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
while((rc = libssh2_session_handshake(session, sock))
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
@@ -177,21 +178,24 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) == LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
#define HOME "/home/username/"
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
HOME ".ssh/id_rsa.pub",
|
||||
HOME ".ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -202,21 +206,21 @@ int main(int argc, char *argv[])
|
||||
channel = libssh2_scp_send(session, scppath, fileinfo.st_mode & 0777,
|
||||
(unsigned long)fileinfo.st_size);
|
||||
|
||||
if ((!channel) && (libssh2_session_last_errno(session) !=
|
||||
LIBSSH2_ERROR_EAGAIN)) {
|
||||
if((!channel) && (libssh2_session_last_errno(session) !=
|
||||
LIBSSH2_ERROR_EAGAIN)) {
|
||||
char *err_msg;
|
||||
|
||||
libssh2_session_last_error(session, &err_msg, NULL, 0);
|
||||
fprintf(stderr, "%s\n", err_msg);
|
||||
goto shutdown;
|
||||
}
|
||||
} while (!channel);
|
||||
} while(!channel);
|
||||
|
||||
fprintf(stderr, "SCP session waiting to send file\n");
|
||||
start = time(NULL);
|
||||
do {
|
||||
nread = fread(mem, 1, sizeof(mem), local);
|
||||
if (nread <= 0) {
|
||||
if(nread <= 0) {
|
||||
/* end of file */
|
||||
break;
|
||||
}
|
||||
@@ -226,12 +230,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
prev = 0;
|
||||
do {
|
||||
while ((rc = libssh2_channel_write(channel, ptr, nread)) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
while((rc = libssh2_channel_write(channel, ptr, nread)) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
prev = 0;
|
||||
}
|
||||
if (rc < 0) {
|
||||
if(rc < 0) {
|
||||
fprintf(stderr, "ERROR %d total %ld / %d prev %d\n", rc,
|
||||
total, (int)nread, (int)prev);
|
||||
break;
|
||||
@@ -243,8 +247,8 @@ int main(int argc, char *argv[])
|
||||
nread -= rc;
|
||||
ptr += rc;
|
||||
}
|
||||
} while (nread);
|
||||
} while (!nread); /* only continue if nread was drained */
|
||||
} while(nread);
|
||||
} while(!nread); /* only continue if nread was drained */
|
||||
|
||||
duration = (int)(time(NULL)-start);
|
||||
|
||||
@@ -252,22 +256,22 @@ int main(int argc, char *argv[])
|
||||
total, duration, total/(double)duration);
|
||||
|
||||
fprintf(stderr, "Sending EOF\n");
|
||||
while (libssh2_channel_send_eof(channel) == LIBSSH2_ERROR_EAGAIN);
|
||||
while(libssh2_channel_send_eof(channel) == LIBSSH2_ERROR_EAGAIN);
|
||||
|
||||
fprintf(stderr, "Waiting for EOF\n");
|
||||
while (libssh2_channel_wait_eof(channel) == LIBSSH2_ERROR_EAGAIN);
|
||||
while(libssh2_channel_wait_eof(channel) == LIBSSH2_ERROR_EAGAIN);
|
||||
|
||||
fprintf(stderr, "Waiting for channel to close\n");
|
||||
while (libssh2_channel_wait_closed(channel) == LIBSSH2_ERROR_EAGAIN);
|
||||
while(libssh2_channel_wait_closed(channel) == LIBSSH2_ERROR_EAGAIN);
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
channel = NULL;
|
||||
|
||||
shutdown:
|
||||
|
||||
while (libssh2_session_disconnect(session,
|
||||
"Normal Shutdown, Thank you for playing") ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
while(libssh2_session_disconnect(session,
|
||||
"Normal Shutdown,") ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -37,18 +37,19 @@
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
const char *keyfile1="~/.ssh/id_rsa.pub";
|
||||
const char *keyfile2="~/.ssh/id_rsa";
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *sftppath="/tmp/TEST";
|
||||
const char *keyfile1 = "~/.ssh/id_rsa.pub";
|
||||
const char *keyfile2 = "~/.ssh/id_rsa";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *sftppath = "/tmp/TEST";
|
||||
|
||||
|
||||
static void kbd_callback(const char *name, int name_len,
|
||||
const char *instruction, int instruction_len, int num_prompts,
|
||||
const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
|
||||
void **abstract)
|
||||
static void kbd_callback(const char *name, int name_len,
|
||||
const char *instruction, int instruction_len,
|
||||
int num_prompts,
|
||||
const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
|
||||
void **abstract)
|
||||
{
|
||||
int i;
|
||||
size_t n;
|
||||
@@ -67,7 +68,7 @@ static void kbd_callback(const char *name, int name_len,
|
||||
|
||||
fprintf(stderr, "Number of prompts: %d\n\n", num_prompts);
|
||||
|
||||
for (i = 0; i < num_prompts; i++) {
|
||||
for(i = 0; i < num_prompts; i++) {
|
||||
fprintf(stderr, "Prompt %d from server: '", i);
|
||||
fwrite(prompts[i].text, 1, prompts[i].length, stderr);
|
||||
fprintf(stderr, "'\n");
|
||||
@@ -75,7 +76,7 @@ static void kbd_callback(const char *name, int name_len,
|
||||
fprintf(stderr, "Please type response: ");
|
||||
fgets(buf, sizeof(buf), stdin);
|
||||
n = strlen(buf);
|
||||
while (n > 0 && strchr("\r\n", buf[n - 1]))
|
||||
while(n > 0 && strchr("\r\n", buf[n - 1]))
|
||||
n--;
|
||||
buf[n] = 0;
|
||||
|
||||
@@ -108,16 +109,17 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@@ -131,8 +133,8 @@ int main(int argc, char *argv[])
|
||||
sftppath = argv[4];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
@@ -146,8 +148,8 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -185,54 +187,61 @@ int main(int argc, char *argv[])
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password") != NULL) {
|
||||
if(strstr(userauthlist, "password") != NULL) {
|
||||
auth_pw |= 1;
|
||||
}
|
||||
if (strstr(userauthlist, "keyboard-interactive") != NULL) {
|
||||
if(strstr(userauthlist, "keyboard-interactive") != NULL) {
|
||||
auth_pw |= 2;
|
||||
}
|
||||
if (strstr(userauthlist, "publickey") != NULL) {
|
||||
if(strstr(userauthlist, "publickey") != NULL) {
|
||||
auth_pw |= 4;
|
||||
}
|
||||
|
||||
/* if we got an 4. argument we set this option if supported */
|
||||
/* if we got an 4. argument we set this option if supported */
|
||||
if(argc > 5) {
|
||||
if ((auth_pw & 1) && !strcasecmp(argv[5], "-p")) {
|
||||
if((auth_pw & 1) && !strcasecmp(argv[5], "-p")) {
|
||||
auth_pw = 1;
|
||||
}
|
||||
if ((auth_pw & 2) && !strcasecmp(argv[5], "-i")) {
|
||||
if((auth_pw & 2) && !strcasecmp(argv[5], "-i")) {
|
||||
auth_pw = 2;
|
||||
}
|
||||
if ((auth_pw & 4) && !strcasecmp(argv[5], "-k")) {
|
||||
if((auth_pw & 4) && !strcasecmp(argv[5], "-k")) {
|
||||
auth_pw = 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (auth_pw & 1) {
|
||||
if(auth_pw & 1) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else if (auth_pw & 2) {
|
||||
}
|
||||
else if(auth_pw & 2) {
|
||||
/* Or via keyboard-interactive */
|
||||
if (libssh2_userauth_keyboard_interactive(session, username, &kbd_callback) ) {
|
||||
if(libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 4) {
|
||||
}
|
||||
else if(auth_pw & 4) {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1, keyfile2, password)) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -240,7 +249,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if (!sftp_session) {
|
||||
if(!sftp_session) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -250,7 +259,7 @@ int main(int argc, char *argv[])
|
||||
sftp_handle =
|
||||
libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);
|
||||
|
||||
if (!sftp_handle) {
|
||||
if(!sftp_handle) {
|
||||
fprintf(stderr, "Unable to open file with SFTP: %ld\n",
|
||||
libssh2_sftp_last_error(sftp_session));
|
||||
goto shutdown;
|
||||
@@ -262,19 +271,20 @@ int main(int argc, char *argv[])
|
||||
/* loop until we fail */
|
||||
fprintf(stderr, "libssh2_sftp_read()!\n");
|
||||
rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
|
||||
if (rc > 0) {
|
||||
if(rc > 0) {
|
||||
write(1, mem, rc);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
} while(1);
|
||||
|
||||
libssh2_sftp_close(sftp_handle);
|
||||
libssh2_sftp_shutdown(sftp_session);
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -79,10 +79,10 @@ int main(int argc, char *argv[])
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *sftppath="/tmp/TEST"; /* source path */
|
||||
const char *dest="/tmp/TEST2"; /* destination path */
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *sftppath = "/tmp/TEST"; /* source path */
|
||||
const char *dest = "/tmp/TEST2"; /* destination path */
|
||||
int rc;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
LIBSSH2_SFTP_HANDLE *sftp_handle;
|
||||
@@ -90,21 +90,22 @@ int main(int argc, char *argv[])
|
||||
char mem[1000];
|
||||
struct timeval timeout;
|
||||
fd_set fd;
|
||||
fd_set fd2;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -117,7 +118,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = htonl(0x7F000001);
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -171,25 +172,26 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password))
|
||||
while((rc = libssh2_userauth_password(session, username, password))
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while ((rc =
|
||||
libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/"
|
||||
".ssh/id_rsa.pub",
|
||||
"/home/username/"
|
||||
".ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
while((rc =
|
||||
libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/"
|
||||
".ssh/id_rsa.pub",
|
||||
"/home/username/"
|
||||
".ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -209,15 +211,15 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
} while (!sftp_session);
|
||||
} while(!sftp_session);
|
||||
|
||||
/* Request a file via SFTP */
|
||||
do {
|
||||
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
||||
LIBSSH2_FXF_READ, 0);
|
||||
|
||||
if (!sftp_handle) {
|
||||
if (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
|
||||
if(!sftp_handle) {
|
||||
if(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
|
||||
fprintf(stderr, "Unable to open file with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -226,7 +228,7 @@ int main(int argc, char *argv[])
|
||||
waitsocket(sock, session); /* now we wait */
|
||||
}
|
||||
}
|
||||
} while (!sftp_handle);
|
||||
} while(!sftp_handle);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
|
||||
do {
|
||||
@@ -242,7 +244,7 @@ int main(int argc, char *argv[])
|
||||
/* write to temporary storage area */
|
||||
fwrite(mem, rc, 1, tempstorage);
|
||||
}
|
||||
} while (rc > 0);
|
||||
} while(rc > 0);
|
||||
|
||||
if(rc != LIBSSH2_ERROR_EAGAIN) {
|
||||
/* error or end of file */
|
||||
@@ -253,11 +255,12 @@ int main(int argc, char *argv[])
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&fd);
|
||||
|
||||
FD_ZERO(&fd2);
|
||||
FD_SET(sock, &fd);
|
||||
FD_SET(sock, &fd2);
|
||||
|
||||
/* wait for readable or writeable */
|
||||
rc = select(sock+1, &fd, &fd, NULL, &timeout);
|
||||
rc = select(sock + 1, &fd, &fd2, NULL, &timeout);
|
||||
if(rc <= 0) {
|
||||
/* negative is error
|
||||
0 is timeout */
|
||||
@@ -265,7 +268,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
} while (1);
|
||||
} while(1);
|
||||
|
||||
libssh2_sftp_close(sftp_handle);
|
||||
fclose(tempstorage);
|
||||
@@ -301,7 +304,7 @@ int main(int argc, char *argv[])
|
||||
nread);
|
||||
ptr += rc;
|
||||
nread -= nread;
|
||||
} while (rc >= 0);
|
||||
} while(rc >= 0);
|
||||
|
||||
if(rc != LIBSSH2_ERROR_EAGAIN) {
|
||||
/* error or end of file */
|
||||
@@ -312,11 +315,12 @@ int main(int argc, char *argv[])
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&fd);
|
||||
|
||||
FD_ZERO(&fd2);
|
||||
FD_SET(sock, &fd);
|
||||
FD_SET(sock, &fd2);
|
||||
|
||||
/* wait for readable or writeable */
|
||||
rc = select(sock+1, &fd, &fd, NULL, &timeout);
|
||||
rc = select(sock + 1, &fd, &fd2, NULL, &timeout);
|
||||
if(rc <= 0) {
|
||||
/* negative is error
|
||||
0 is timeout */
|
||||
@@ -324,7 +328,7 @@ int main(int argc, char *argv[])
|
||||
rc);
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
} while(1);
|
||||
fprintf(stderr, "SFTP upload done!\n");
|
||||
}
|
||||
else {
|
||||
@@ -336,7 +340,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -344,7 +348,7 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
if (tempstorage)
|
||||
if(tempstorage)
|
||||
fclose(tempstorage);
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
|
||||
@@ -40,10 +40,10 @@ int main(int argc, char *argv[])
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *loclfile="sftp_write.c";
|
||||
const char *sftppath="/tmp/TEST";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *loclfile = "sftp_write.c";
|
||||
const char *sftppath = "/tmp/TEST";
|
||||
int rc;
|
||||
FILE *local;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
@@ -57,16 +57,17 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@@ -83,14 +84,14 @@ int main(int argc, char *argv[])
|
||||
sftppath = argv[5];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
if(!local) {
|
||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
@@ -104,8 +105,8 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -140,18 +141,20 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
#define HOME "/home/username/"
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
HOME ".ssh/id_rsa.pub",
|
||||
HOME ".ssh/id_rsa",
|
||||
password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -160,7 +163,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if (!sftp_session) {
|
||||
if(!sftp_session) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -173,7 +176,7 @@ int main(int argc, char *argv[])
|
||||
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_READ,
|
||||
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
|
||||
if (!sftp_handle) {
|
||||
if(!sftp_handle) {
|
||||
fprintf(stderr, "Unable to open file with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -188,14 +191,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open() a handle for APPEND\n");
|
||||
|
||||
if (!sftp_handle) {
|
||||
if(!sftp_handle) {
|
||||
fprintf(stderr, "Unable to open file with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
|
||||
do {
|
||||
nread = fread(mem, 1, sizeof(mem), local);
|
||||
if (nread <= 0) {
|
||||
if(nread <= 0) {
|
||||
/* end of file */
|
||||
break;
|
||||
}
|
||||
@@ -208,9 +211,9 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
ptr += rc;
|
||||
nread -= rc;
|
||||
} while (nread);
|
||||
} while(nread);
|
||||
|
||||
} while (rc > 0);
|
||||
} while(rc > 0);
|
||||
|
||||
libssh2_sftp_close(sftp_handle);
|
||||
libssh2_sftp_shutdown(sftp_session);
|
||||
@@ -225,7 +228,7 @@ shutdown:
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
if (local)
|
||||
if(local)
|
||||
fclose(local);
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ int main(int argc, char *argv[])
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *sftppath="/tmp/sftp_mkdir";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *sftppath = "/tmp/sftp_mkdir";
|
||||
int rc;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
|
||||
@@ -50,16 +50,17 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@@ -73,9 +74,9 @@ int main(int argc, char *argv[])
|
||||
sftppath = argv[4];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -121,15 +122,16 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username,
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
@@ -140,7 +142,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if (!sftp_session) {
|
||||
if(!sftp_session) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -161,7 +163,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -40,9 +40,9 @@ int main(int argc, char *argv[])
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *sftppath="/tmp/sftp_mkdir_nonblock";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *sftppath = "/tmp/sftp_mkdir_nonblock";
|
||||
int rc;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
|
||||
@@ -50,16 +50,17 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@@ -73,9 +74,9 @@ int main(int argc, char *argv[])
|
||||
sftppath = argv[4];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -121,15 +122,16 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username,
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
@@ -141,7 +143,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if (!sftp_session) {
|
||||
if(!sftp_session) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -151,7 +153,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_mkdirnb()!\n");
|
||||
/* Make a directory via SFTP */
|
||||
while (libssh2_sftp_mkdir(sftp_session, sftppath,
|
||||
while(libssh2_sftp_mkdir(sftp_session, sftppath,
|
||||
LIBSSH2_SFTP_S_IRWXU|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IXGRP|
|
||||
LIBSSH2_SFTP_S_IROTH|LIBSSH2_SFTP_S_IXOTH)
|
||||
@@ -161,7 +163,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -85,9 +85,9 @@ int main(int argc, char *argv[])
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *sftppath="/tmp/TEST";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *sftppath = "/tmp/TEST";
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
@@ -103,32 +103,33 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
if(argc > 2) {
|
||||
username = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if(argc > 3) {
|
||||
password = argv[3];
|
||||
}
|
||||
if (argc > 4) {
|
||||
if(argc > 4) {
|
||||
sftppath = argv[4];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -141,7 +142,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -149,7 +150,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Create a session instance */
|
||||
session = libssh2_session_init();
|
||||
if (!session)
|
||||
if(!session)
|
||||
return -1;
|
||||
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
@@ -162,9 +163,9 @@ int main(int argc, char *argv[])
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
while ((rc = libssh2_session_handshake(session, sock)) ==
|
||||
while((rc = libssh2_session_handshake(session, sock)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
@@ -181,25 +182,26 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password))
|
||||
while((rc = libssh2_userauth_password(session, username, password))
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while ((rc =
|
||||
libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/"
|
||||
".ssh/id_rsa.pub",
|
||||
"/home/username/"
|
||||
".ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
while((rc =
|
||||
libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/"
|
||||
".ssh/id_rsa.pub",
|
||||
"/home/username/"
|
||||
".ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -222,7 +224,7 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
} while (!sftp_session);
|
||||
} while(!sftp_session);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open()!\n");
|
||||
/* Request a file via SFTP */
|
||||
@@ -230,8 +232,8 @@ int main(int argc, char *argv[])
|
||||
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
|
||||
LIBSSH2_FXF_READ, 0);
|
||||
|
||||
if (!sftp_handle) {
|
||||
if (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
|
||||
if(!sftp_handle) {
|
||||
if(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
|
||||
fprintf(stderr, "Unable to open file with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -240,31 +242,33 @@ int main(int argc, char *argv[])
|
||||
waitsocket(sock, session); /* now we wait */
|
||||
}
|
||||
}
|
||||
} while (!sftp_handle);
|
||||
} while(!sftp_handle);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
|
||||
do {
|
||||
char mem[1024*24];
|
||||
|
||||
/* loop until we fail */
|
||||
while ((rc = libssh2_sftp_read(sftp_handle, mem,
|
||||
while((rc = libssh2_sftp_read(sftp_handle, mem,
|
||||
sizeof(mem))) == LIBSSH2_ERROR_EAGAIN) {
|
||||
spin++;
|
||||
waitsocket(sock, session); /* now we wait */
|
||||
}
|
||||
if (rc > 0) {
|
||||
if(rc > 0) {
|
||||
total += rc;
|
||||
write(1, mem, rc);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
} while(1);
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&end, NULL);
|
||||
time_ms = tvdiff(end, start);
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin );
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n",
|
||||
total,
|
||||
time_ms, total/(time_ms/1000.0), spin);
|
||||
#else
|
||||
fprintf(stderr, "Got %d bytes spin: %d\n", total, spin);
|
||||
#endif
|
||||
@@ -275,7 +279,7 @@ int main(int argc, char *argv[])
|
||||
shutdown:
|
||||
|
||||
fprintf(stderr, "libssh2_session_disconnect\n");
|
||||
while (libssh2_session_disconnect(session,
|
||||
while(libssh2_session_disconnect(session,
|
||||
"Normal Shutdown, Thank you") ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
libssh2_session_free(session);
|
||||
|
||||
@@ -40,10 +40,10 @@ int main(int argc, char *argv[])
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *loclfile="sftp_write.c";
|
||||
const char *sftppath="/tmp/TEST";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *loclfile = "sftp_write.c";
|
||||
const char *sftppath = "/tmp/TEST";
|
||||
int rc;
|
||||
FILE *local;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
@@ -56,16 +56,17 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@@ -82,14 +83,14 @@ int main(int argc, char *argv[])
|
||||
sftppath = argv[5];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
if(!local) {
|
||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
@@ -103,7 +104,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -139,18 +140,20 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
const char *pubkey = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *privkey = "/home/username/.ssh/id_rsa.pub";
|
||||
if(libssh2_userauth_publickey_fromfile(session, username,
|
||||
pubkey, privkey,
|
||||
password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -159,7 +162,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if (!sftp_session) {
|
||||
if(!sftp_session) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -172,14 +175,14 @@ int main(int argc, char *argv[])
|
||||
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
|
||||
|
||||
if (!sftp_handle) {
|
||||
if(!sftp_handle) {
|
||||
fprintf(stderr, "Unable to open file with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
|
||||
do {
|
||||
nread = fread(mem, 1, sizeof(mem), local);
|
||||
if (nread <= 0) {
|
||||
if(nread <= 0) {
|
||||
/* end of file */
|
||||
break;
|
||||
}
|
||||
@@ -192,9 +195,9 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
ptr += rc;
|
||||
nread -= rc;
|
||||
} while (nread);
|
||||
} while(nread);
|
||||
|
||||
} while (rc > 0);
|
||||
} while(rc > 0);
|
||||
|
||||
libssh2_sftp_close(sftp_handle);
|
||||
libssh2_sftp_shutdown(sftp_session);
|
||||
@@ -209,7 +212,7 @@ shutdown:
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
if (local)
|
||||
if(local)
|
||||
fclose(local);
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* The sample code has default values for host name, user name, password
|
||||
* and path to copy, but you can specify them on the command line like:
|
||||
*
|
||||
* "sftp 192.168.0.1 user password sftp_write_nonblock.c /tmp/sftp_write_nonblock.c"
|
||||
* "sftp 192.168.0.1 user password thisfile /tmp/storehere"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
@@ -77,10 +77,10 @@ int main(int argc, char *argv[])
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *loclfile="sftp_write_nonblock.c";
|
||||
const char *sftppath="/tmp/sftp_write_nonblock.c";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *loclfile = "sftp_write_nonblock.c";
|
||||
const char *sftppath = "/tmp/sftp_write_nonblock.c";
|
||||
int rc;
|
||||
FILE *local;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
@@ -96,40 +96,41 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
if(argc > 2) {
|
||||
username = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if(argc > 3) {
|
||||
password = argv[3];
|
||||
}
|
||||
if (argc > 4) {
|
||||
if(argc > 4) {
|
||||
loclfile = argv[4];
|
||||
}
|
||||
if (argc > 5) {
|
||||
if(argc > 5) {
|
||||
sftppath = argv[5];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
if(!local) {
|
||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
@@ -143,7 +144,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -152,7 +153,7 @@ int main(int argc, char *argv[])
|
||||
/* Create a session instance
|
||||
*/
|
||||
session = libssh2_session_init();
|
||||
if (!session)
|
||||
if(!session)
|
||||
return -1;
|
||||
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
@@ -161,9 +162,9 @@ int main(int argc, char *argv[])
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
while ((rc = libssh2_session_handshake(session, sock))
|
||||
while((rc = libssh2_session_handshake(session, sock))
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
@@ -180,22 +181,24 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
const char *pubkey = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *privkey = "/home/username/.ssh/id_rsa";
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
pubkey, privkey,
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -205,28 +208,28 @@ int main(int argc, char *argv[])
|
||||
do {
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if (!sftp_session &&
|
||||
if(!sftp_session &&
|
||||
(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} while (!sftp_session);
|
||||
} while(!sftp_session);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open()!\n");
|
||||
/* Request a file via SFTP */
|
||||
do {
|
||||
sftp_handle =
|
||||
libssh2_sftp_open(sftp_session, sftppath,
|
||||
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
|
||||
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
|
||||
|
||||
if (!sftp_handle &&
|
||||
(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
||||
libssh2_sftp_open(sftp_session, sftppath,
|
||||
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|
|
||||
LIBSSH2_FXF_TRUNC,
|
||||
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
|
||||
if(!sftp_handle &&
|
||||
(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
||||
fprintf(stderr, "Unable to open file with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} while (!sftp_handle);
|
||||
} while(!sftp_handle);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
|
||||
|
||||
@@ -234,7 +237,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
do {
|
||||
nread = fread(mem, 1, sizeof(mem), local);
|
||||
if (nread <= 0) {
|
||||
if(nread <= 0) {
|
||||
/* end of file */
|
||||
break;
|
||||
}
|
||||
@@ -244,7 +247,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
do {
|
||||
/* write data in a loop until we block */
|
||||
while ((rc = libssh2_sftp_write(sftp_handle, ptr, nread)) ==
|
||||
while((rc = libssh2_sftp_write(sftp_handle, ptr, nread)) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
@@ -253,8 +256,8 @@ int main(int argc, char *argv[])
|
||||
ptr += rc;
|
||||
nread -= rc;
|
||||
|
||||
} while (nread);
|
||||
} while (rc > 0);
|
||||
} while(nread);
|
||||
} while(rc > 0);
|
||||
|
||||
duration = (int)(time(NULL)-start);
|
||||
|
||||
@@ -268,7 +271,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
while (libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")
|
||||
while(libssh2_session_disconnect(session, "Normal Shutdown")
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
libssh2_session_free(session);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* The sample code has default values for host name, user name, password
|
||||
* and path to copy, but you can specify them on the command line like:
|
||||
*
|
||||
* "sftp 192.168.0.1 user password sftp_write_nonblock.c /tmp/sftp_write_nonblock.c"
|
||||
* "sftp 192.168.0.1 user password file /tmp/storehere"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
@@ -77,10 +77,10 @@ int main(int argc, char *argv[])
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *loclfile="sftp_write_nonblock.c";
|
||||
const char *sftppath="/tmp/sftp_write_nonblock.c";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *loclfile = "sftp_write_nonblock.c";
|
||||
const char *sftppath = "/tmp/sftp_write_nonblock.c";
|
||||
int rc;
|
||||
FILE *local;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
@@ -96,40 +96,41 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
if(argc > 2) {
|
||||
username = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if(argc > 3) {
|
||||
password = argv[3];
|
||||
}
|
||||
if (argc > 4) {
|
||||
if(argc > 4) {
|
||||
loclfile = argv[4];
|
||||
}
|
||||
if (argc > 5) {
|
||||
if(argc > 5) {
|
||||
sftppath = argv[5];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
local = fopen(loclfile, "rb");
|
||||
if (!local) {
|
||||
if(!local) {
|
||||
fprintf(stderr, "Can't open local file %s\n", loclfile);
|
||||
return -1;
|
||||
}
|
||||
@@ -143,7 +144,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -152,7 +153,7 @@ int main(int argc, char *argv[])
|
||||
/* Create a session instance
|
||||
*/
|
||||
session = libssh2_session_init();
|
||||
if (!session)
|
||||
if(!session)
|
||||
return -1;
|
||||
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
@@ -161,9 +162,9 @@ int main(int argc, char *argv[])
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
while ((rc = libssh2_session_handshake(session, sock))
|
||||
while((rc = libssh2_session_handshake(session, sock))
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
@@ -180,22 +181,24 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
#define PUBKEY "/home/username/.ssh/id_rsa.pub"
|
||||
#define PRIVKEY "/home/username/.ssh/id_rsa"
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
PUBKEY, PRIVKEY,
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -205,28 +208,29 @@ int main(int argc, char *argv[])
|
||||
do {
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if (!sftp_session &&
|
||||
if(!sftp_session &&
|
||||
(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} while (!sftp_session);
|
||||
} while(!sftp_session);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open()!\n");
|
||||
/* Request a file via SFTP */
|
||||
do {
|
||||
sftp_handle =
|
||||
libssh2_sftp_open(sftp_session, sftppath,
|
||||
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
|
||||
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
|
||||
libssh2_sftp_open(sftp_session, sftppath,
|
||||
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|
|
||||
LIBSSH2_FXF_TRUNC,
|
||||
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
|
||||
|
||||
if (!sftp_handle &&
|
||||
(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
||||
if(!sftp_handle &&
|
||||
(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
||||
fprintf(stderr, "Unable to open file with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} while (!sftp_handle);
|
||||
} while(!sftp_handle);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
|
||||
|
||||
@@ -235,9 +239,9 @@ int main(int argc, char *argv[])
|
||||
memuse = 0; /* it starts blank */
|
||||
do {
|
||||
nread = fread(&mem[memuse], 1, sizeof(mem)-memuse, local);
|
||||
if (nread <= 0) {
|
||||
if(nread <= 0) {
|
||||
/* end of file */
|
||||
if (memuse > 0)
|
||||
if(memuse > 0)
|
||||
/* the previous sending is not finished */
|
||||
nread = 0;
|
||||
else
|
||||
@@ -247,7 +251,7 @@ int main(int argc, char *argv[])
|
||||
total += nread;
|
||||
|
||||
/* write data in a loop until we block */
|
||||
while ((rc = libssh2_sftp_write(sftp_handle, mem, memuse)) ==
|
||||
while((rc = libssh2_sftp_write(sftp_handle, mem, memuse)) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
@@ -263,7 +267,7 @@ int main(int argc, char *argv[])
|
||||
/* 'mem' was consumed fully */
|
||||
memuse = 0;
|
||||
|
||||
} while (rc > 0);
|
||||
} while(rc > 0);
|
||||
|
||||
duration = (int)(time(NULL)-start);
|
||||
|
||||
@@ -277,8 +281,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
shutdown:
|
||||
|
||||
while (libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
while(libssh2_session_disconnect(session, "Normal Shutdown")
|
||||
== LIBSSH2_ERROR_EAGAIN);
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -36,26 +36,16 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* last resort for systems not defining PRIu64 in inttypes.h */
|
||||
#ifndef __PRI64_PREFIX
|
||||
#ifdef WIN32
|
||||
#define __PRI64_PREFIX "I64"
|
||||
#define __FILESIZE "I64"
|
||||
#else
|
||||
#if __WORDSIZE == 64
|
||||
#define __PRI64_PREFIX "l"
|
||||
#else
|
||||
#define __PRI64_PREFIX "ll"
|
||||
#endif /* __WORDSIZE */
|
||||
#endif /* WIN32 */
|
||||
#endif /* !__PRI64_PREFIX */
|
||||
#ifndef PRIu64
|
||||
#define PRIu64 __PRI64_PREFIX "u"
|
||||
#endif /* PRIu64 */
|
||||
#define __FILESIZE "llu"
|
||||
#endif
|
||||
|
||||
const char *keyfile1="~/.ssh/id_rsa.pub";
|
||||
const char *keyfile2="~/.ssh/id_rsa";
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *keyfile1 = "~/.ssh/id_rsa.pub";
|
||||
const char *keyfile2 = "~/.ssh/id_rsa";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
|
||||
static void kbd_callback(const char *name, int name_len,
|
||||
const char *instruction, int instruction_len,
|
||||
@@ -68,7 +58,7 @@ static void kbd_callback(const char *name, int name_len,
|
||||
(void)name_len;
|
||||
(void)instruction;
|
||||
(void)instruction_len;
|
||||
if (num_prompts == 1) {
|
||||
if(num_prompts == 1) {
|
||||
responses[0].text = strdup(password);
|
||||
responses[0].length = strlen(password);
|
||||
}
|
||||
@@ -84,7 +74,7 @@ int main(int argc, char *argv[])
|
||||
const char *fingerprint;
|
||||
char *userauthlist;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *sftppath="/tmp/secretdir";
|
||||
const char *sftppath = "/tmp/secretdir";
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
LIBSSH2_SFTP_HANDLE *sftp_handle;
|
||||
|
||||
@@ -92,16 +82,17 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@@ -115,9 +106,9 @@ int main(int argc, char *argv[])
|
||||
sftppath = argv[4];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -130,8 +121,8 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -166,58 +157,64 @@ int main(int argc, char *argv[])
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password") != NULL) {
|
||||
if(strstr(userauthlist, "password") != NULL) {
|
||||
auth_pw |= 1;
|
||||
}
|
||||
if (strstr(userauthlist, "keyboard-interactive") != NULL) {
|
||||
if(strstr(userauthlist, "keyboard-interactive") != NULL) {
|
||||
auth_pw |= 2;
|
||||
}
|
||||
if (strstr(userauthlist, "publickey") != NULL) {
|
||||
if(strstr(userauthlist, "publickey") != NULL) {
|
||||
auth_pw |= 4;
|
||||
}
|
||||
|
||||
/* if we got an 5. argument we set this option if supported */
|
||||
if(argc > 5) {
|
||||
if ((auth_pw & 1) && !strcasecmp(argv[5], "-p")) {
|
||||
if((auth_pw & 1) && !strcasecmp(argv[5], "-p")) {
|
||||
auth_pw = 1;
|
||||
}
|
||||
if ((auth_pw & 2) && !strcasecmp(argv[5], "-i")) {
|
||||
if((auth_pw & 2) && !strcasecmp(argv[5], "-i")) {
|
||||
auth_pw = 2;
|
||||
}
|
||||
if ((auth_pw & 4) && !strcasecmp(argv[5], "-k")) {
|
||||
if((auth_pw & 4) && !strcasecmp(argv[5], "-k")) {
|
||||
auth_pw = 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (auth_pw & 1) {
|
||||
if(auth_pw & 1) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "\tAuthentication by password failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by password succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 2) {
|
||||
}
|
||||
else if(auth_pw & 2) {
|
||||
/* Or via keyboard-interactive */
|
||||
if (libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
if(libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 4) {
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
}
|
||||
else if(auth_pw & 4) {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -225,7 +222,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if (!sftp_session) {
|
||||
if(!sftp_session) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -237,7 +234,7 @@ int main(int argc, char *argv[])
|
||||
/* Request a dir listing via SFTP */
|
||||
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
|
||||
|
||||
if (!sftp_handle) {
|
||||
if(!sftp_handle) {
|
||||
fprintf(stderr, "Unable to open dir with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -254,9 +251,10 @@ int main(int argc, char *argv[])
|
||||
/* rc is the length of the file name in the mem
|
||||
buffer */
|
||||
|
||||
if (longentry[0] != '\0') {
|
||||
if(longentry[0] != '\0') {
|
||||
printf("%s\n", longentry);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if(attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) {
|
||||
/* this should check what permissions it
|
||||
is and print the output accordingly */
|
||||
@@ -267,14 +265,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if(attrs.flags & LIBSSH2_SFTP_ATTR_UIDGID) {
|
||||
printf("%4ld %4ld ", attrs.uid, attrs.gid);
|
||||
printf("%4d %4d ", (int) attrs.uid, (int) attrs.gid);
|
||||
}
|
||||
else {
|
||||
printf(" - - ");
|
||||
}
|
||||
|
||||
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
|
||||
printf("%8" PRIu64 " ", attrs.filesize);
|
||||
printf("%8" __FILESIZE " ", attrs.filesize);
|
||||
}
|
||||
|
||||
printf("%s\n", mem);
|
||||
@@ -283,14 +281,14 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
break;
|
||||
|
||||
} while (1);
|
||||
} while(1);
|
||||
|
||||
libssh2_sftp_closedir(sftp_handle);
|
||||
libssh2_sftp_shutdown(sftp_session);
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -36,21 +36,11 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* last resort for systems not defining PRIu64 in inttypes.h */
|
||||
#ifndef __PRI64_PREFIX
|
||||
#ifdef WIN32
|
||||
#define __PRI64_PREFIX "I64"
|
||||
#define __FILESIZE "I64"
|
||||
#else
|
||||
#if __WORDSIZE == 64
|
||||
#define __PRI64_PREFIX "l"
|
||||
#else
|
||||
#define __PRI64_PREFIX "ll"
|
||||
#endif /* __WORDSIZE */
|
||||
#endif /* WIN32 */
|
||||
#endif /* !__PRI64_PREFIX */
|
||||
#ifndef PRIu64
|
||||
#define PRIu64 __PRI64_PREFIX "u"
|
||||
#endif /* PRIu64 */
|
||||
#define __FILESIZE "llu"
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -59,9 +49,11 @@ int main(int argc, char *argv[])
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *sftppath="/tmp/secretdir";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
const char *sftppath = "/tmp/secretdir";
|
||||
const char *pubkey = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *privkey = "/home/username/.ssh/id_rsa";
|
||||
int rc;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
LIBSSH2_SFTP_HANDLE *sftp_handle;
|
||||
@@ -70,16 +62,17 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@@ -93,9 +86,9 @@ int main(int argc, char *argv[])
|
||||
sftppath = argv[4];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -108,8 +101,8 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -126,8 +119,8 @@ int main(int argc, char *argv[])
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
while ((rc = libssh2_session_handshake(session, sock)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
while((rc = libssh2_session_handshake(session, sock)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
@@ -145,21 +138,22 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
if(auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) == LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
pubkey, privkey,
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -169,24 +163,24 @@ int main(int argc, char *argv[])
|
||||
do {
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if ((!sftp_session) && (libssh2_session_last_errno(session) !=
|
||||
LIBSSH2_ERROR_EAGAIN)) {
|
||||
if((!sftp_session) && (libssh2_session_last_errno(session) !=
|
||||
LIBSSH2_ERROR_EAGAIN)) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} while (!sftp_session);
|
||||
} while(!sftp_session);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_opendir()!\n");
|
||||
/* Request a dir listing via SFTP */
|
||||
do {
|
||||
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
|
||||
|
||||
if ((!sftp_handle) && (libssh2_session_last_errno(session) !=
|
||||
LIBSSH2_ERROR_EAGAIN)) {
|
||||
if((!sftp_handle) && (libssh2_session_last_errno(session) !=
|
||||
LIBSSH2_ERROR_EAGAIN)) {
|
||||
fprintf(stderr, "Unable to open dir with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} while (!sftp_handle);
|
||||
} while(!sftp_handle);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_opendir() is done, now receive listing!\n");
|
||||
do {
|
||||
@@ -194,8 +188,8 @@ int main(int argc, char *argv[])
|
||||
LIBSSH2_SFTP_ATTRIBUTES attrs;
|
||||
|
||||
/* loop until we fail */
|
||||
while ((rc = libssh2_sftp_readdir(sftp_handle, mem, sizeof(mem),
|
||||
&attrs)) == LIBSSH2_ERROR_EAGAIN) {
|
||||
while((rc = libssh2_sftp_readdir(sftp_handle, mem, sizeof(mem),
|
||||
&attrs)) == LIBSSH2_ERROR_EAGAIN) {
|
||||
;
|
||||
}
|
||||
if(rc > 0) {
|
||||
@@ -206,37 +200,40 @@ int main(int argc, char *argv[])
|
||||
/* this should check what permissions it
|
||||
is and print the output accordingly */
|
||||
printf("--fix----- ");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
printf("---------- ");
|
||||
}
|
||||
|
||||
if(attrs.flags & LIBSSH2_SFTP_ATTR_UIDGID) {
|
||||
printf("%4ld %4ld ", attrs.uid, attrs.gid);
|
||||
} else {
|
||||
printf("%4d %4d ", (int) attrs.uid, (int) attrs.gid);
|
||||
}
|
||||
else {
|
||||
printf(" - - ");
|
||||
}
|
||||
|
||||
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
|
||||
printf("%8" PRIu64 " ", attrs.filesize);
|
||||
printf("%8" __FILESIZE " ", attrs.filesize);
|
||||
}
|
||||
|
||||
printf("%s\n", mem);
|
||||
}
|
||||
else if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
else if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
/* blocking */
|
||||
fprintf(stderr, "Blocking\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
} while (1);
|
||||
} while(1);
|
||||
|
||||
libssh2_sftp_closedir(sftp_handle);
|
||||
libssh2_sftp_shutdown(sftp_session);
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_disconnect(session, "Normal Shutdown");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
const char *keyfile1="~/.ssh/id_rsa.pub";
|
||||
const char *keyfile2="~/.ssh/id_rsa";
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *keyfile1 = "~/.ssh/id_rsa.pub";
|
||||
const char *keyfile2 = "~/.ssh/id_rsa";
|
||||
const char *username = "username";
|
||||
const char *password = "password";
|
||||
|
||||
|
||||
static void kbd_callback(const char *name, int name_len,
|
||||
@@ -54,7 +54,7 @@ static void kbd_callback(const char *name, int name_len,
|
||||
(void)name_len;
|
||||
(void)instruction;
|
||||
(void)instruction_len;
|
||||
if (num_prompts == 1) {
|
||||
if(num_prompts == 1) {
|
||||
responses[0].text = strdup(password);
|
||||
responses[0].length = strlen(password);
|
||||
}
|
||||
@@ -77,16 +77,17 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@@ -97,9 +98,9 @@ int main(int argc, char *argv[])
|
||||
password = argv[3];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -121,7 +122,7 @@ int main(int argc, char *argv[])
|
||||
* banners, exchange keys, and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
session = libssh2_session_init();
|
||||
if (libssh2_session_handshake(session, sock)) {
|
||||
if(libssh2_session_handshake(session, sock)) {
|
||||
fprintf(stderr, "Failure establishing SSH session\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -141,64 +142,71 @@ int main(int argc, char *argv[])
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password") != NULL) {
|
||||
if(strstr(userauthlist, "password") != NULL) {
|
||||
auth_pw |= 1;
|
||||
}
|
||||
if (strstr(userauthlist, "keyboard-interactive") != NULL) {
|
||||
if(strstr(userauthlist, "keyboard-interactive") != NULL) {
|
||||
auth_pw |= 2;
|
||||
}
|
||||
if (strstr(userauthlist, "publickey") != NULL) {
|
||||
if(strstr(userauthlist, "publickey") != NULL) {
|
||||
auth_pw |= 4;
|
||||
}
|
||||
|
||||
/* if we got an 4. argument we set this option if supported */
|
||||
if(argc > 4) {
|
||||
if ((auth_pw & 1) && !strcasecmp(argv[4], "-p")) {
|
||||
if((auth_pw & 1) && !strcasecmp(argv[4], "-p")) {
|
||||
auth_pw = 1;
|
||||
}
|
||||
if ((auth_pw & 2) && !strcasecmp(argv[4], "-i")) {
|
||||
if((auth_pw & 2) && !strcasecmp(argv[4], "-i")) {
|
||||
auth_pw = 2;
|
||||
}
|
||||
if ((auth_pw & 4) && !strcasecmp(argv[4], "-k")) {
|
||||
if((auth_pw & 4) && !strcasecmp(argv[4], "-k")) {
|
||||
auth_pw = 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (auth_pw & 1) {
|
||||
if(auth_pw & 1) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "\tAuthentication by password failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by password succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 2) {
|
||||
}
|
||||
else if(auth_pw & 2) {
|
||||
/* Or via keyboard-interactive */
|
||||
if (libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
if(libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 4) {
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
}
|
||||
else if(auth_pw & 4) {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
/* Request a shell */
|
||||
if (!(channel = libssh2_channel_open_session(session))) {
|
||||
channel = libssh2_channel_open_session(session);
|
||||
if(!channel) {
|
||||
fprintf(stderr, "Unable to open a session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -211,13 +219,13 @@ int main(int argc, char *argv[])
|
||||
/* Request a terminal with 'vanilla' terminal emulation
|
||||
* See /etc/termcap for more options
|
||||
*/
|
||||
if (libssh2_channel_request_pty(channel, "vanilla")) {
|
||||
if(libssh2_channel_request_pty(channel, "vanilla")) {
|
||||
fprintf(stderr, "Failed requesting pty\n");
|
||||
goto skip_shell;
|
||||
}
|
||||
|
||||
/* Open a SHELL on that pty */
|
||||
if (libssh2_channel_shell(channel)) {
|
||||
if(libssh2_channel_shell(channel)) {
|
||||
fprintf(stderr, "Unable to request shell on allocated pty\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -236,14 +244,14 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
|
||||
skip_shell:
|
||||
if (channel) {
|
||||
if(channel) {
|
||||
libssh2_channel_free(channel);
|
||||
channel = NULL;
|
||||
}
|
||||
|
||||
/* Other channel types are supported via:
|
||||
* libssh2_scp_send()
|
||||
* libssh2_scp_recv()
|
||||
* libssh2_scp_recv2()
|
||||
* libssh2_channel_direct_tcpip()
|
||||
*/
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
const char *username="username";
|
||||
const char *username = "username";
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -54,16 +54,17 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if(argc > 1) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hostaddr = htonl(0x7F000001);
|
||||
}
|
||||
|
||||
@@ -71,9 +72,9 @@ int main(int argc, char *argv[])
|
||||
username = argv[2];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ int main(int argc, char *argv[])
|
||||
* responsible for creating the socket establishing the connection
|
||||
*/
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sock == -1) {
|
||||
if(sock == -1) {
|
||||
fprintf(stderr, "failed to create socket!\n");
|
||||
rc = 1;
|
||||
goto shutdown;
|
||||
@@ -90,7 +91,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
goto shutdown;
|
||||
@@ -100,7 +101,7 @@ int main(int argc, char *argv[])
|
||||
* banners, exchange keys, and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
session = libssh2_session_init();
|
||||
if (libssh2_session_handshake(session, sock)) {
|
||||
if(libssh2_session_handshake(session, sock)) {
|
||||
fprintf(stderr, "Failure establishing SSH session\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -120,43 +121,44 @@ int main(int argc, char *argv[])
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "publickey") == NULL) {
|
||||
if(strstr(userauthlist, "publickey") == NULL) {
|
||||
fprintf(stderr, "\"publickey\" authentication is not supported\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
/* Connect to the ssh-agent */
|
||||
agent = libssh2_agent_init(session);
|
||||
if (!agent) {
|
||||
if(!agent) {
|
||||
fprintf(stderr, "Failure initializing ssh-agent support\n");
|
||||
rc = 1;
|
||||
goto shutdown;
|
||||
}
|
||||
if (libssh2_agent_connect(agent)) {
|
||||
if(libssh2_agent_connect(agent)) {
|
||||
fprintf(stderr, "Failure connecting to ssh-agent\n");
|
||||
rc = 1;
|
||||
goto shutdown;
|
||||
}
|
||||
if (libssh2_agent_list_identities(agent)) {
|
||||
if(libssh2_agent_list_identities(agent)) {
|
||||
fprintf(stderr, "Failure requesting identities to ssh-agent\n");
|
||||
rc = 1;
|
||||
goto shutdown;
|
||||
}
|
||||
while (1) {
|
||||
while(1) {
|
||||
rc = libssh2_agent_get_identity(agent, &identity, prev_identity);
|
||||
if (rc == 1)
|
||||
if(rc == 1)
|
||||
break;
|
||||
if (rc < 0) {
|
||||
if(rc < 0) {
|
||||
fprintf(stderr,
|
||||
"Failure obtaining identity from ssh-agent support\n");
|
||||
rc = 1;
|
||||
goto shutdown;
|
||||
}
|
||||
if (libssh2_agent_userauth(agent, username, identity)) {
|
||||
if(libssh2_agent_userauth(agent, username, identity)) {
|
||||
fprintf(stderr, "\tAuthentication with username %s and "
|
||||
"public key %s failed!\n",
|
||||
username, identity->comment);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication with username %s and "
|
||||
"public key %s succeeded!\n",
|
||||
username, identity->comment);
|
||||
@@ -164,7 +166,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
prev_identity = identity;
|
||||
}
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Couldn't continue authentication\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -172,7 +174,8 @@ int main(int argc, char *argv[])
|
||||
/* We're authenticated now. */
|
||||
|
||||
/* Request a shell */
|
||||
if (!(channel = libssh2_channel_open_session(session))) {
|
||||
channel = libssh2_channel_open_session(session);
|
||||
if(!channel) {
|
||||
fprintf(stderr, "Unable to open a session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -185,13 +188,13 @@ int main(int argc, char *argv[])
|
||||
/* Request a terminal with 'vanilla' terminal emulation
|
||||
* See /etc/termcap for more options
|
||||
*/
|
||||
if (libssh2_channel_request_pty(channel, "vanilla")) {
|
||||
if(libssh2_channel_request_pty(channel, "vanilla")) {
|
||||
fprintf(stderr, "Failed requesting pty\n");
|
||||
goto skip_shell;
|
||||
}
|
||||
|
||||
/* Open a SHELL on that pty */
|
||||
if (libssh2_channel_shell(channel)) {
|
||||
if(libssh2_channel_shell(channel)) {
|
||||
fprintf(stderr, "Unable to request shell on allocated pty\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -210,21 +213,23 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
|
||||
skip_shell:
|
||||
if (channel) {
|
||||
if(channel) {
|
||||
libssh2_channel_free(channel);
|
||||
channel = NULL;
|
||||
}
|
||||
|
||||
/* Other channel types are supported via:
|
||||
* libssh2_scp_send()
|
||||
* libssh2_scp_recv()
|
||||
* libssh2_scp_recv2()
|
||||
* libssh2_channel_direct_tcpip()
|
||||
*/
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_agent_disconnect(agent);
|
||||
libssh2_agent_free(agent);
|
||||
if(agent) {
|
||||
libssh2_agent_disconnect(agent);
|
||||
libssh2_agent_free(agent);
|
||||
}
|
||||
|
||||
if(session) {
|
||||
libssh2_session_disconnect(session,
|
||||
@@ -232,7 +237,7 @@ int main(int argc, char *argv[])
|
||||
libssh2_session_free(session);
|
||||
}
|
||||
|
||||
if (sock != -1) {
|
||||
if(sock != -1) {
|
||||
#ifdef WIN32
|
||||
closesocket(sock);
|
||||
#else
|
||||
|
||||
292
example/ssh2_agent_forwarding.c
Normal file
292
example/ssh2_agent_forwarding.c
Normal file
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Sample showing how to use libssh2 to request agent forwarding
|
||||
* on the remote host. The command executed will run with agent forwarded
|
||||
* so you should be able to do things like clone out protected git
|
||||
* repos and such.
|
||||
*
|
||||
* The example uses agent authentication to ensure an agent to forward
|
||||
* is running.
|
||||
*
|
||||
* Run it like this:
|
||||
*
|
||||
* $ ./ssh2_agent_forwarding 127.0.0.1 user "uptime"
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
|
||||
{
|
||||
struct timeval timeout;
|
||||
int rc;
|
||||
fd_set fd;
|
||||
fd_set *writefd = NULL;
|
||||
fd_set *readfd = NULL;
|
||||
int dir;
|
||||
|
||||
timeout.tv_sec = 10;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&fd);
|
||||
|
||||
FD_SET(socket_fd, &fd);
|
||||
|
||||
/* now make sure we wait in the correct direction */
|
||||
dir = libssh2_session_block_directions(session);
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_INBOUND)
|
||||
readfd = &fd;
|
||||
|
||||
if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
|
||||
writefd = &fd;
|
||||
|
||||
rc = select(socket_fd + 1, readfd, writefd, NULL, &timeout);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *hostname = "127.0.0.1";
|
||||
const char *commandline = "uptime";
|
||||
const char *username = NULL;
|
||||
unsigned long hostaddr;
|
||||
int sock;
|
||||
struct sockaddr_in sin;
|
||||
LIBSSH2_SESSION *session;
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
LIBSSH2_AGENT *agent = NULL;
|
||||
struct libssh2_agent_publickey *identity, *prev_identity = NULL;
|
||||
int rc;
|
||||
int exitcode;
|
||||
char *exitsignal = (char *)"none";
|
||||
int bytecount = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
#endif
|
||||
if(argc < 2) {
|
||||
fprintf(stderr, "At least IP and username arguments are required.\n");
|
||||
return 1;
|
||||
}
|
||||
/* must be ip address only */
|
||||
hostname = argv[1];
|
||||
username = argv[2];
|
||||
|
||||
if(argc > 3) {
|
||||
commandline = argv[3];
|
||||
}
|
||||
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hostaddr = inet_addr(hostname);
|
||||
|
||||
/* Ultra basic "connect to port 22 on localhost"
|
||||
* Your code is responsible for creating the socket establishing the
|
||||
* connection
|
||||
*/
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create a session instance */
|
||||
session = libssh2_session_init();
|
||||
if(!session)
|
||||
return -1;
|
||||
|
||||
if(libssh2_session_handshake(session, sock) != 0) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Connect to the ssh-agent */
|
||||
agent = libssh2_agent_init(session);
|
||||
if(!agent) {
|
||||
fprintf(stderr, "Failure initializing ssh-agent support\n");
|
||||
rc = 1;
|
||||
goto shutdown;
|
||||
}
|
||||
if(libssh2_agent_connect(agent)) {
|
||||
fprintf(stderr, "Failure connecting to ssh-agent\n");
|
||||
rc = 1;
|
||||
goto shutdown;
|
||||
}
|
||||
if(libssh2_agent_list_identities(agent)) {
|
||||
fprintf(stderr, "Failure requesting identities to ssh-agent\n");
|
||||
rc = 1;
|
||||
goto shutdown;
|
||||
}
|
||||
while(1) {
|
||||
rc = libssh2_agent_get_identity(agent, &identity, prev_identity);
|
||||
if(rc == 1)
|
||||
break;
|
||||
if(rc < 0) {
|
||||
fprintf(stderr,
|
||||
"Failure obtaining identity from ssh-agent support\n");
|
||||
rc = 1;
|
||||
goto shutdown;
|
||||
}
|
||||
if(libssh2_agent_userauth(agent, username, identity)) {
|
||||
fprintf(stderr, "\tAuthentication with username %s and "
|
||||
"public key %s failed!\n",
|
||||
username, identity->comment);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tAuthentication with username %s and "
|
||||
"public key %s succeeded!\n",
|
||||
username, identity->comment);
|
||||
break;
|
||||
}
|
||||
prev_identity = identity;
|
||||
}
|
||||
if(rc) {
|
||||
fprintf(stderr, "Couldn't continue authentication\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
#if 0
|
||||
libssh2_trace(session, ~0);
|
||||
#endif
|
||||
|
||||
/* Set session to non-blocking */
|
||||
libssh2_session_set_blocking(session, 0);
|
||||
|
||||
/* Exec non-blocking on the remove host */
|
||||
while((channel = libssh2_channel_open_session(session)) == NULL &&
|
||||
libssh2_session_last_error(session, NULL, NULL, 0) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if(channel == NULL) {
|
||||
fprintf(stderr, "Error\n");
|
||||
exit(1);
|
||||
}
|
||||
while((rc = libssh2_channel_request_auth_agent(channel)) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Error, couldn't request auth agent, error code %d.\n",
|
||||
rc);
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "\tAgent forwarding request succeeded!\n");
|
||||
}
|
||||
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Error\n");
|
||||
exit(1);
|
||||
}
|
||||
for(;;) {
|
||||
/* loop until we block */
|
||||
int rc;
|
||||
do {
|
||||
char buffer[0x4000];
|
||||
rc = libssh2_channel_read(channel, buffer, sizeof(buffer) );
|
||||
if(rc > 0) {
|
||||
int i;
|
||||
bytecount += rc;
|
||||
fprintf(stderr, "We read:\n");
|
||||
for(i = 0; i < rc; ++i)
|
||||
fputc(buffer[i], stderr);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
else {
|
||||
if(rc != LIBSSH2_ERROR_EAGAIN)
|
||||
/* no need to output this for the EAGAIN case */
|
||||
fprintf(stderr, "libssh2_channel_read returned %d\n", rc);
|
||||
}
|
||||
}
|
||||
while(rc > 0);
|
||||
|
||||
/* this is due to blocking that would occur otherwise so we loop on
|
||||
this condition */
|
||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
exitcode = 127;
|
||||
while((rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if(rc == 0) {
|
||||
exitcode = libssh2_channel_get_exit_status(channel);
|
||||
libssh2_channel_get_exit_signal(channel, &exitsignal,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if(exitsignal) {
|
||||
printf("\nGot signal: %s\n", exitsignal);
|
||||
}
|
||||
else {
|
||||
printf("\nEXIT: %d bytecount: %d\n", exitcode, bytecount);
|
||||
}
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
channel = NULL;
|
||||
|
||||
shutdown:
|
||||
|
||||
libssh2_session_disconnect(session,
|
||||
"Normal Shutdown, Thank you for playing");
|
||||
libssh2_session_free(session);
|
||||
|
||||
#ifdef WIN32
|
||||
closesocket(sock);
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
fprintf(stderr, "all done\n");
|
||||
|
||||
libssh2_exit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
int rc;
|
||||
int exitcode = 0;
|
||||
char *exitsignal=(char *)"none";
|
||||
char *exitsignal = (char *)"none";
|
||||
size_t len;
|
||||
LIBSSH2_KNOWNHOSTS *nh;
|
||||
int type;
|
||||
@@ -96,27 +96,27 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
if(argc > 1)
|
||||
/* must be ip address only */
|
||||
hostname = argv[1];
|
||||
|
||||
if (argc > 2) {
|
||||
if(argc > 2) {
|
||||
username = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if(argc > 3) {
|
||||
password = argv[3];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Create a session instance */
|
||||
session = libssh2_session_init();
|
||||
if (!session)
|
||||
if(!session)
|
||||
return -1;
|
||||
|
||||
/* tell libssh2 we want it all done non-blocking */
|
||||
@@ -148,9 +148,9 @@ int main(int argc, char *argv[])
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
while ((rc = libssh2_session_handshake(session, sock)) ==
|
||||
while((rc = libssh2_session_handshake(session, sock)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
@@ -193,11 +193,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
libssh2_knownhost_free(nh);
|
||||
|
||||
if ( strlen(password) != 0 ) {
|
||||
if(strlen(password) != 0) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -206,22 +206,22 @@ int main(int argc, char *argv[])
|
||||
libssh2_trace(session, LIBSSH2_TRACE_SOCKET);
|
||||
|
||||
/* Exec non-blocking on the remove host */
|
||||
while( (channel = libssh2_channel_open_session(session)) == NULL &&
|
||||
libssh2_session_last_error(session,NULL,NULL,0) ==
|
||||
LIBSSH2_ERROR_EAGAIN ) {
|
||||
while((channel = libssh2_channel_open_session(session)) == NULL &&
|
||||
libssh2_session_last_error(session, NULL, NULL, 0) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if( channel == NULL ) {
|
||||
fprintf(stderr,"Error\n");
|
||||
exit( 1 );
|
||||
if(channel == NULL) {
|
||||
fprintf(stderr, "Error\n");
|
||||
exit(1);
|
||||
}
|
||||
while( (rc = libssh2_channel_exec(channel, commandline)) ==
|
||||
LIBSSH2_ERROR_EAGAIN )
|
||||
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
||||
LIBSSH2_ERROR_EAGAIN)
|
||||
waitsocket(sock, session);
|
||||
|
||||
if( rc != 0 ) {
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "exec error\n");
|
||||
exit( 1 );
|
||||
exit(1);
|
||||
}
|
||||
else {
|
||||
LIBSSH2_POLLFD *fds = NULL;
|
||||
@@ -236,10 +236,11 @@ int main(int argc, char *argv[])
|
||||
int rewrites = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BUFSIZE; i++)
|
||||
for(i = 0; i < BUFSIZE; i++)
|
||||
buffer[i] = 'A';
|
||||
|
||||
if ((fds = malloc (sizeof (LIBSSH2_POLLFD))) == NULL) {
|
||||
fds = malloc(sizeof (LIBSSH2_POLLFD));
|
||||
if(!fds) {
|
||||
fprintf(stderr, "malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -252,18 +253,18 @@ int main(int argc, char *argv[])
|
||||
int rc = (libssh2_poll(fds, 1, 10));
|
||||
int act = 0;
|
||||
|
||||
if (rc < 1)
|
||||
if(rc < 1)
|
||||
continue;
|
||||
|
||||
if (fds[0].revents & LIBSSH2_POLLFD_POLLIN) {
|
||||
if(fds[0].revents & LIBSSH2_POLLFD_POLLIN) {
|
||||
int n = libssh2_channel_read(channel, buffer, sizeof(buffer));
|
||||
act++;
|
||||
|
||||
if (n == LIBSSH2_ERROR_EAGAIN) {
|
||||
if(n == LIBSSH2_ERROR_EAGAIN) {
|
||||
rereads++;
|
||||
fprintf(stderr, "will read again\n");
|
||||
}
|
||||
else if (n < 0) {
|
||||
else if(n < 0) {
|
||||
fprintf(stderr, "read failed\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -274,20 +275,20 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (fds[0].revents & LIBSSH2_POLLFD_POLLOUT) {
|
||||
if(fds[0].revents & LIBSSH2_POLLFD_POLLOUT) {
|
||||
act++;
|
||||
|
||||
if (totwritten < totsize) {
|
||||
if(totwritten < totsize) {
|
||||
/* we have not written all data yet */
|
||||
int left = totsize - totwritten;
|
||||
int size = (left < bufsize) ? left : bufsize;
|
||||
int n = libssh2_channel_write_ex(channel, 0, buffer, size);
|
||||
|
||||
if (n == LIBSSH2_ERROR_EAGAIN) {
|
||||
if(n == LIBSSH2_ERROR_EAGAIN) {
|
||||
rewrites++;
|
||||
fprintf(stderr, "will write again\n");
|
||||
}
|
||||
else if (n < 0) {
|
||||
else if(n < 0) {
|
||||
fprintf(stderr, "write failed\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -295,20 +296,21 @@ int main(int argc, char *argv[])
|
||||
totwritten += n;
|
||||
fprintf(stderr, "wrote %d bytes (%d in total)",
|
||||
n, totwritten);
|
||||
if (left >= bufsize && n != bufsize) {
|
||||
if(left >= bufsize && n != bufsize) {
|
||||
partials++;
|
||||
fprintf(stderr, " PARTIAL");
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* all data written, send EOF */
|
||||
rc = libssh2_channel_send_eof(channel);
|
||||
|
||||
if (rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
fprintf(stderr, "will send eof again\n");
|
||||
}
|
||||
else if (rc < 0) {
|
||||
else if(rc < 0) {
|
||||
fprintf(stderr, "send eof failed\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -320,23 +322,23 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (fds[0].revents & LIBSSH2_POLLFD_CHANNEL_CLOSED) {
|
||||
if (!act) /* don't leave loop until we have read all data */
|
||||
if(fds[0].revents & LIBSSH2_POLLFD_CHANNEL_CLOSED) {
|
||||
if(!act) /* don't leave loop until we have read all data */
|
||||
running = 0;
|
||||
}
|
||||
} while(running);
|
||||
|
||||
exitcode = 127;
|
||||
while( (rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN )
|
||||
while((rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN)
|
||||
waitsocket(sock, session);
|
||||
|
||||
if( rc == 0 ) {
|
||||
exitcode = libssh2_channel_get_exit_status( channel );
|
||||
if(rc == 0) {
|
||||
exitcode = libssh2_channel_get_exit_status(channel);
|
||||
libssh2_channel_get_exit_signal(channel, &exitsignal,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if (exitsignal)
|
||||
if(exitsignal)
|
||||
fprintf(stderr, "\nGot signal: %s\n", exitsignal);
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
@@ -345,7 +347,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "\nrereads: %d rewrites: %d totwritten %d\n",
|
||||
rereads, rewrites, totwritten);
|
||||
|
||||
if (totwritten != totread) {
|
||||
if(totwritten != totread) {
|
||||
fprintf(stderr, "\n*** FAIL bytes written: %d bytes "
|
||||
"read: %d ***\n", totwritten, totread);
|
||||
exit(1);
|
||||
|
||||
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
int rc;
|
||||
int exitcode;
|
||||
char *exitsignal=(char *)"none";
|
||||
char *exitsignal = (char *)"none";
|
||||
int bytecount = 0;
|
||||
size_t len;
|
||||
LIBSSH2_KNOWNHOSTS *nh;
|
||||
@@ -97,30 +97,30 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
if(argc > 1)
|
||||
/* must be ip address only */
|
||||
hostname = argv[1];
|
||||
|
||||
if (argc > 2) {
|
||||
if(argc > 2) {
|
||||
username = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if(argc > 3) {
|
||||
password = argv[3];
|
||||
}
|
||||
if (argc > 4) {
|
||||
if(argc > 4) {
|
||||
commandline = argv[4];
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ int main(int argc, char *argv[])
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -143,7 +143,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Create a session instance */
|
||||
session = libssh2_session_init();
|
||||
if (!session)
|
||||
if(!session)
|
||||
return -1;
|
||||
|
||||
/* tell libssh2 we want it all done non-blocking */
|
||||
@@ -152,9 +152,9 @@ int main(int argc, char *argv[])
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
while ((rc = libssh2_session_handshake(session, sock)) ==
|
||||
while((rc = libssh2_session_handshake(session, sock)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
}
|
||||
@@ -206,104 +206,95 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
libssh2_knownhost_free(nh);
|
||||
|
||||
if ( strlen(password) != 0 ) {
|
||||
if(strlen(password) != 0) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
while((rc = libssh2_userauth_password(session, username, password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Or by public key */
|
||||
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
while((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/user/"
|
||||
".ssh/id_rsa.pub",
|
||||
"/home/user/"
|
||||
".ssh/id_rsa",
|
||||
password)) ==
|
||||
LIBSSH2_ERROR_EAGAIN);
|
||||
if (rc) {
|
||||
if(rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
libssh2_trace(session, ~0 );
|
||||
libssh2_trace(session, ~0);
|
||||
#endif
|
||||
|
||||
/* Exec non-blocking on the remove host */
|
||||
while( (channel = libssh2_channel_open_session(session)) == NULL &&
|
||||
libssh2_session_last_error(session,NULL,NULL,0) ==
|
||||
LIBSSH2_ERROR_EAGAIN )
|
||||
{
|
||||
while((channel = libssh2_channel_open_session(session)) == NULL &&
|
||||
libssh2_session_last_error(session, NULL, NULL, 0) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if( channel == NULL )
|
||||
{
|
||||
fprintf(stderr,"Error\n");
|
||||
exit( 1 );
|
||||
if(channel == NULL) {
|
||||
fprintf(stderr, "Error\n");
|
||||
exit(1);
|
||||
}
|
||||
while( (rc = libssh2_channel_exec(channel, commandline)) ==
|
||||
LIBSSH2_ERROR_EAGAIN )
|
||||
{
|
||||
while((rc = libssh2_channel_exec(channel, commandline)) ==
|
||||
LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
if( rc != 0 )
|
||||
{
|
||||
fprintf(stderr,"Error\n");
|
||||
exit( 1 );
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Error\n");
|
||||
exit(1);
|
||||
}
|
||||
for( ;; )
|
||||
{
|
||||
for(;;) {
|
||||
/* loop until we block */
|
||||
int rc;
|
||||
do
|
||||
{
|
||||
do {
|
||||
char buffer[0x4000];
|
||||
rc = libssh2_channel_read( channel, buffer, sizeof(buffer) );
|
||||
if( rc > 0 )
|
||||
{
|
||||
rc = libssh2_channel_read(channel, buffer, sizeof(buffer) );
|
||||
if(rc > 0) {
|
||||
int i;
|
||||
bytecount += rc;
|
||||
fprintf(stderr, "We read:\n");
|
||||
for( i=0; i < rc; ++i )
|
||||
fputc( buffer[i], stderr);
|
||||
for(i = 0; i < rc; ++i)
|
||||
fputc(buffer[i], stderr);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
else {
|
||||
if( rc != LIBSSH2_ERROR_EAGAIN )
|
||||
if(rc != LIBSSH2_ERROR_EAGAIN)
|
||||
/* no need to output this for the EAGAIN case */
|
||||
fprintf(stderr, "libssh2_channel_read returned %d\n", rc);
|
||||
}
|
||||
}
|
||||
while( rc > 0 );
|
||||
while(rc > 0);
|
||||
|
||||
/* this is due to blocking that would occur otherwise so we loop on
|
||||
this condition */
|
||||
if( rc == LIBSSH2_ERROR_EAGAIN )
|
||||
{
|
||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
waitsocket(sock, session);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
exitcode = 127;
|
||||
while( (rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN )
|
||||
while((rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN)
|
||||
waitsocket(sock, session);
|
||||
|
||||
if( rc == 0 )
|
||||
{
|
||||
exitcode = libssh2_channel_get_exit_status( channel );
|
||||
if(rc == 0) {
|
||||
exitcode = libssh2_channel_get_exit_status(channel);
|
||||
libssh2_channel_get_exit_signal(channel, &exitsignal,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if (exitsignal)
|
||||
if(exitsignal)
|
||||
fprintf(stderr, "\nGot signal: %s\n", exitsignal);
|
||||
else
|
||||
else
|
||||
fprintf(stderr, "\nEXIT: %d bytecount: %d\n", exitcode, bytecount);
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
|
||||
@@ -57,12 +57,12 @@ static int netconf_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t len)
|
||||
|
||||
do {
|
||||
i = libssh2_channel_write(channel, buf, len);
|
||||
if (i < 0) {
|
||||
if(i < 0) {
|
||||
fprintf(stderr, "libssh2_channel_write: %d\n", i);
|
||||
return -1;
|
||||
}
|
||||
wr += i;
|
||||
} while (i > 0 && wr < (ssize_t)len);
|
||||
} while(i > 0 && wr < (ssize_t)len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -78,9 +78,9 @@ static int netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
|
||||
|
||||
do {
|
||||
len = libssh2_channel_read(channel, buf + rd, buflen - rd);
|
||||
if (LIBSSH2_ERROR_EAGAIN == len)
|
||||
if(LIBSSH2_ERROR_EAGAIN == len)
|
||||
continue;
|
||||
else if (len < 0) {
|
||||
else if(len < 0) {
|
||||
fprintf(stderr, "libssh2_channel_read: %d\n", (int)len);
|
||||
return -1;
|
||||
}
|
||||
@@ -92,13 +92,14 @@ static int netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
|
||||
/* really, this MUST be replaced with proper XML parsing! */
|
||||
|
||||
endreply = strstr(buf, endtag);
|
||||
if (endreply)
|
||||
if(endreply)
|
||||
specialsequence = strstr(endreply, "]]>]]>");
|
||||
|
||||
} while (!specialsequence && rd < buflen);
|
||||
} while(!specialsequence && rd < buflen);
|
||||
|
||||
if (!specialsequence) {
|
||||
fprintf(stderr, "%s: ]]>]]> not found! read buffer too small?\n", __func__);
|
||||
if(!specialsequence) {
|
||||
fprintf(stderr, "%s: ]]>]]> not found! read buffer too small?\n",
|
||||
__func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -125,8 +126,8 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
@@ -134,40 +135,41 @@ int main(int argc, char *argv[])
|
||||
int sock = -1;
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
if(argc > 1)
|
||||
server_ip = argv[1];
|
||||
if (argc > 2)
|
||||
if(argc > 2)
|
||||
username = argv[2];
|
||||
if (argc > 3)
|
||||
if(argc > 3)
|
||||
password = argv[3];
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Connect to SSH server */
|
||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (sock == INVALID_SOCKET) {
|
||||
if(sock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open socket!\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (sock == -1) {
|
||||
if(sock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(server_ip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
fprintf(stderr, "inet_addr: Invalid IP address \"%s\"\n", server_ip);
|
||||
return -1;
|
||||
}
|
||||
sin.sin_port = htons(830);
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "Failed to connect to %s!\n", inet_ntoa(sin.sin_addr));
|
||||
return -1;
|
||||
@@ -203,39 +205,41 @@ int main(int argc, char *argv[])
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password"))
|
||||
if(strstr(userauthlist, "password"))
|
||||
auth |= AUTH_PASSWORD;
|
||||
if (strstr(userauthlist, "publickey"))
|
||||
if(strstr(userauthlist, "publickey"))
|
||||
auth |= AUTH_PUBLICKEY;
|
||||
|
||||
/* check for options */
|
||||
if(argc > 4) {
|
||||
if ((auth & AUTH_PASSWORD) && !strcasecmp(argv[4], "-p"))
|
||||
if((auth & AUTH_PASSWORD) && !strcasecmp(argv[4], "-p"))
|
||||
auth = AUTH_PASSWORD;
|
||||
if ((auth & AUTH_PUBLICKEY) && !strcasecmp(argv[4], "-k"))
|
||||
if((auth & AUTH_PUBLICKEY) && !strcasecmp(argv[4], "-k"))
|
||||
auth = AUTH_PUBLICKEY;
|
||||
}
|
||||
|
||||
if (auth & AUTH_PASSWORD) {
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(auth & AUTH_PASSWORD) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
}
|
||||
else if(auth & AUTH_PUBLICKEY) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "Authentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
fprintf(stderr, "Authentication by public key succeeded.\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
/* open a channel */
|
||||
channel = libssh2_channel_open_session(session);
|
||||
if (!channel) {
|
||||
if(!channel) {
|
||||
fprintf(stderr, "Could not open the channel!\n"
|
||||
"(Note that this can be a problem at the server!"
|
||||
" Please review the server logs.)\n");
|
||||
@@ -243,14 +247,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* execute the subsystem on our channel */
|
||||
if (libssh2_channel_subsystem(channel, "netconf")) {
|
||||
if(libssh2_channel_subsystem(channel, "netconf")) {
|
||||
fprintf(stderr, "Could not execute the \"netconf\" subsystem!\n"
|
||||
"(Note that this can be a problem at the server!"
|
||||
" Please review the server logs.)\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
/* NETCONF: http://tools.ietf.org/html/draft-ietf-netconf-ssh-06 */
|
||||
/* NETCONF: https://tools.ietf.org/html/draft-ietf-netconf-ssh-06 */
|
||||
|
||||
fprintf(stderr, "Sending NETCONF client <hello>\n");
|
||||
snprintf(buf, sizeof(buf),
|
||||
@@ -261,15 +265,16 @@ int main(int argc, char *argv[])
|
||||
"</capabilities>"
|
||||
"</hello>\n"
|
||||
"]]>]]>\n%n", (int *)&len);
|
||||
if (-1 == netconf_write(channel, buf, len))
|
||||
if(-1 == netconf_write(channel, buf, len))
|
||||
goto shutdown;
|
||||
|
||||
fprintf(stderr, "Reading NETCONF server <hello>\n");
|
||||
len = netconf_read_until(channel, "</hello>", buf, sizeof(buf));
|
||||
if (-1 == len)
|
||||
if(-1 == len)
|
||||
goto shutdown;
|
||||
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s", (int)len, buf);
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s",
|
||||
(int)len, buf);
|
||||
|
||||
fprintf(stderr, "Sending NETCONF <rpc>\n");
|
||||
snprintf(buf, sizeof(buf),
|
||||
@@ -278,18 +283,19 @@ int main(int argc, char *argv[])
|
||||
"<get-interface-information><terse/></get-interface-information>"
|
||||
"</rpc>\n"
|
||||
"]]>]]>\n%n", (int *)&len);
|
||||
if (-1 == netconf_write(channel, buf, len))
|
||||
if(-1 == netconf_write(channel, buf, len))
|
||||
goto shutdown;
|
||||
|
||||
fprintf(stderr, "Reading NETCONF <rpc-reply>\n");
|
||||
len = netconf_read_until(channel, "</rpc-reply>", buf, sizeof(buf));
|
||||
if (-1 == len)
|
||||
if(-1 == len)
|
||||
goto shutdown;
|
||||
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s", (int)len, buf);
|
||||
fprintf(stderr, "Got %d bytes:\n----------------------\n%s",
|
||||
(int)len, buf);
|
||||
|
||||
shutdown:
|
||||
if (channel)
|
||||
if(channel)
|
||||
libssh2_channel_free(channel);
|
||||
libssh2_session_disconnect(session, "Client disconnecting normally");
|
||||
libssh2_session_free(session);
|
||||
|
||||
@@ -70,8 +70,8 @@ int main(int argc, char *argv[])
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
err = WSAStartup(MAKEWORD(2, 0), &wsadata);
|
||||
if(err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
@@ -79,48 +79,49 @@ int main(int argc, char *argv[])
|
||||
int sock = -1, forwardsock = -1;
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
if(argc > 1)
|
||||
server_ip = argv[1];
|
||||
if (argc > 2)
|
||||
if(argc > 2)
|
||||
username = argv[2];
|
||||
if (argc > 3)
|
||||
if(argc > 3)
|
||||
password = argv[3];
|
||||
if (argc > 4)
|
||||
if(argc > 4)
|
||||
remote_listenhost = argv[4];
|
||||
if (argc > 5)
|
||||
if(argc > 5)
|
||||
remote_wantport = atoi(argv[5]);
|
||||
if (argc > 6)
|
||||
if(argc > 6)
|
||||
local_destip = argv[6];
|
||||
if (argc > 7)
|
||||
if(argc > 7)
|
||||
local_destport = atoi(argv[7]);
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Connect to SSH server */
|
||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (sock == INVALID_SOCKET) {
|
||||
if(sock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open socket!\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (sock == -1) {
|
||||
if(sock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(server_ip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
perror("inet_addr");
|
||||
return -1;
|
||||
}
|
||||
sin.sin_port = htons(22);
|
||||
if (connect(sock, (struct sockaddr*)(&sin),
|
||||
if(connect(sock, (struct sockaddr*)(&sin),
|
||||
sizeof(struct sockaddr_in)) != 0) {
|
||||
fprintf(stderr, "failed to connect!\n");
|
||||
return -1;
|
||||
@@ -156,32 +157,34 @@ int main(int argc, char *argv[])
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password"))
|
||||
if(strstr(userauthlist, "password"))
|
||||
auth |= AUTH_PASSWORD;
|
||||
if (strstr(userauthlist, "publickey"))
|
||||
if(strstr(userauthlist, "publickey"))
|
||||
auth |= AUTH_PUBLICKEY;
|
||||
|
||||
/* check for options */
|
||||
if(argc > 8) {
|
||||
if ((auth & AUTH_PASSWORD) && !strcasecmp(argv[8], "-p"))
|
||||
if((auth & AUTH_PASSWORD) && !strcasecmp(argv[8], "-p"))
|
||||
auth = AUTH_PASSWORD;
|
||||
if ((auth & AUTH_PUBLICKEY) && !strcasecmp(argv[8], "-k"))
|
||||
if((auth & AUTH_PUBLICKEY) && !strcasecmp(argv[8], "-k"))
|
||||
auth = AUTH_PUBLICKEY;
|
||||
}
|
||||
|
||||
if (auth & AUTH_PASSWORD) {
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
if(auth & AUTH_PASSWORD) {
|
||||
if(libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else if (auth & AUTH_PUBLICKEY) {
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
}
|
||||
else if(auth & AUTH_PUBLICKEY) {
|
||||
if(libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -191,7 +194,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
listener = libssh2_channel_forward_listen_ex(session, remote_listenhost,
|
||||
remote_wantport, &remote_listenport, 1);
|
||||
if (!listener) {
|
||||
if(!listener) {
|
||||
fprintf(stderr, "Could not start the tcpip-forward listener!\n"
|
||||
"(Note that this can be a problem at the server!"
|
||||
" Please review the server logs.)\n");
|
||||
@@ -203,7 +206,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "Waiting for remote connection\n");
|
||||
channel = libssh2_channel_forward_accept(listener);
|
||||
if (!channel) {
|
||||
if(!channel) {
|
||||
fprintf(stderr, "Could not accept connection!\n"
|
||||
"(Note that this can be a problem at the server!"
|
||||
" Please review the server logs.)\n");
|
||||
@@ -215,12 +218,12 @@ int main(int argc, char *argv[])
|
||||
local_destip, local_destport);
|
||||
forwardsock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (forwardsock == INVALID_SOCKET) {
|
||||
if(forwardsock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open forward socket!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
#else
|
||||
if (forwardsock == -1) {
|
||||
if(forwardsock == -1) {
|
||||
perror("socket");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -228,11 +231,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(local_destport);
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(local_destip))) {
|
||||
sin.sin_addr.s_addr = inet_addr(local_destip);
|
||||
if(INADDR_NONE == sin.sin_addr.s_addr) {
|
||||
perror("inet_addr");
|
||||
goto shutdown;
|
||||
}
|
||||
if (-1 == connect(forwardsock, (struct sockaddr *)&sin, sinlen)) {
|
||||
if(-1 == connect(forwardsock, (struct sockaddr *)&sin, sinlen)) {
|
||||
perror("connect");
|
||||
goto shutdown;
|
||||
}
|
||||
@@ -243,22 +247,23 @@ int main(int argc, char *argv[])
|
||||
/* Must use non-blocking IO hereafter due to the current libssh2 API */
|
||||
libssh2_session_set_blocking(session, 0);
|
||||
|
||||
while (1) {
|
||||
while(1) {
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(forwardsock, &fds);
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 100000;
|
||||
rc = select(forwardsock + 1, &fds, NULL, NULL, &tv);
|
||||
if (-1 == rc) {
|
||||
if(-1 == rc) {
|
||||
perror("select");
|
||||
goto shutdown;
|
||||
}
|
||||
if (rc && FD_ISSET(forwardsock, &fds)) {
|
||||
if(rc && FD_ISSET(forwardsock, &fds)) {
|
||||
len = recv(forwardsock, buf, sizeof(buf), 0);
|
||||
if (len < 0) {
|
||||
if(len < 0) {
|
||||
perror("read");
|
||||
goto shutdown;
|
||||
} else if (0 == len) {
|
||||
}
|
||||
else if(0 == len) {
|
||||
fprintf(stderr, "The local server at %s:%d disconnected!\n",
|
||||
local_destip, local_destport);
|
||||
goto shutdown;
|
||||
@@ -266,31 +271,31 @@ int main(int argc, char *argv[])
|
||||
wr = 0;
|
||||
do {
|
||||
i = libssh2_channel_write(channel, buf, len);
|
||||
if (i < 0) {
|
||||
if(i < 0) {
|
||||
fprintf(stderr, "libssh2_channel_write: %d\n", i);
|
||||
goto shutdown;
|
||||
}
|
||||
wr += i;
|
||||
} while(i > 0 && wr < len);
|
||||
}
|
||||
while (1) {
|
||||
while(1) {
|
||||
len = libssh2_channel_read(channel, buf, sizeof(buf));
|
||||
if (LIBSSH2_ERROR_EAGAIN == len)
|
||||
if(LIBSSH2_ERROR_EAGAIN == len)
|
||||
break;
|
||||
else if (len < 0) {
|
||||
else if(len < 0) {
|
||||
fprintf(stderr, "libssh2_channel_read: %d", (int)len);
|
||||
goto shutdown;
|
||||
}
|
||||
wr = 0;
|
||||
while (wr < len) {
|
||||
while(wr < len) {
|
||||
i = send(forwardsock, buf + wr, len - wr, 0);
|
||||
if (i <= 0) {
|
||||
if(i <= 0) {
|
||||
perror("write");
|
||||
goto shutdown;
|
||||
}
|
||||
wr += i;
|
||||
}
|
||||
if (libssh2_channel_eof(channel)) {
|
||||
if(libssh2_channel_eof(channel)) {
|
||||
fprintf(stderr, "The remote client at %s:%d disconnected!\n",
|
||||
remote_listenhost, remote_listenport);
|
||||
goto shutdown;
|
||||
@@ -304,9 +309,9 @@ shutdown:
|
||||
#else
|
||||
close(forwardsock);
|
||||
#endif
|
||||
if (channel)
|
||||
if(channel)
|
||||
libssh2_channel_free(channel);
|
||||
if (listener)
|
||||
if(listener)
|
||||
libssh2_channel_forward_cancel(listener);
|
||||
libssh2_session_disconnect(session, "Client disconnecting normally");
|
||||
libssh2_session_free(session);
|
||||
|
||||
163
example/x11.c
163
example/x11.c
@@ -48,14 +48,14 @@ static void remove_node(struct chan_X11_list *elem)
|
||||
|
||||
current_node = gp_x11_chan;
|
||||
|
||||
if (gp_x11_chan == elem) {
|
||||
if(gp_x11_chan == elem) {
|
||||
gp_x11_chan = gp_x11_chan->next;
|
||||
free(current_node);
|
||||
return;
|
||||
}
|
||||
|
||||
while (current_node->next != NULL) {
|
||||
if (current_node->next == elem) {
|
||||
while(current_node->next != NULL) {
|
||||
if(current_node->next == elem) {
|
||||
current_node->next = current_node->next->next;
|
||||
current_node = current_node->next;
|
||||
free(current_node);
|
||||
@@ -78,7 +78,7 @@ static int _raw_mode(void)
|
||||
struct termios tio;
|
||||
|
||||
rc = tcgetattr(fileno(stdin), &tio);
|
||||
if (rc != -1) {
|
||||
if(rc != -1) {
|
||||
_saved_tio = tio;
|
||||
/* do the equivalent of cfmakeraw() manually, to build on Solaris */
|
||||
tio.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
|
||||
@@ -106,37 +106,40 @@ static int _normal_mode(void)
|
||||
static void x11_callback(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel,
|
||||
char *shost, int sport, void **abstract)
|
||||
{
|
||||
const char * display = NULL;
|
||||
char * ptr = NULL;
|
||||
char * temp_buff = NULL;
|
||||
const char *display = NULL;
|
||||
char *ptr = NULL;
|
||||
char *temp_buff = NULL;
|
||||
int display_port = 0;
|
||||
int sock = 0;
|
||||
int rc = 0;
|
||||
struct sockaddr_un addr;
|
||||
struct chan_X11_list *new;
|
||||
struct chan_X11_list *chan_iter;
|
||||
|
||||
(void)session;
|
||||
(void)shost;
|
||||
(void)sport;
|
||||
(void)abstract;
|
||||
/*
|
||||
* Connect to the display
|
||||
* Inspired by x11_connect_display in openssh
|
||||
*/
|
||||
display = getenv("DISPLAY");
|
||||
if ( display != NULL) {
|
||||
if (strncmp( display, "unix:", 5) == 0 ||
|
||||
if(display != NULL) {
|
||||
if(strncmp(display, "unix:", 5) == 0 ||
|
||||
display[0] == ':') {
|
||||
/* Connect to the local unix domain */
|
||||
ptr = strrchr(display, ':');
|
||||
temp_buff = (char *) calloc(strlen(ptr+1), sizeof(char));
|
||||
if (!temp_buff) {
|
||||
temp_buff = (char *) calloc(strlen(ptr + 1), sizeof(char));
|
||||
if(!temp_buff) {
|
||||
perror("calloc");
|
||||
return;
|
||||
}
|
||||
memcpy(temp_buff, ptr+1, strlen(ptr+1));
|
||||
memcpy(temp_buff, ptr + 1, strlen(ptr + 1));
|
||||
display_port = atoi(temp_buff);
|
||||
free(temp_buff);
|
||||
|
||||
sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock < 0)
|
||||
if(sock < 0)
|
||||
return;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
@@ -144,9 +147,9 @@ static void x11_callback(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel,
|
||||
_PATH_UNIX_X, display_port);
|
||||
rc = connect(sock, (struct sockaddr *) &addr, sizeof(addr));
|
||||
|
||||
if (rc != -1){
|
||||
if(rc != -1) {
|
||||
/* Connection Successfull */
|
||||
if (gp_x11_chan == NULL) {
|
||||
if(gp_x11_chan == NULL) {
|
||||
/* Calloc ensure that gp_X11_chan is full of 0 */
|
||||
gp_x11_chan = (struct chan_X11_list *)
|
||||
calloc(1, sizeof(struct chan_X11_list));
|
||||
@@ -156,7 +159,7 @@ static void x11_callback(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel,
|
||||
}
|
||||
else {
|
||||
chan_iter = gp_x11_chan;
|
||||
while (chan_iter->next != NULL)
|
||||
while(chan_iter->next != NULL)
|
||||
chan_iter = chan_iter->next;
|
||||
/* Create the new Node */
|
||||
new = (struct chan_X11_list *)
|
||||
@@ -180,10 +183,10 @@ static void x11_callback(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel,
|
||||
*/
|
||||
static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
|
||||
{
|
||||
char * buf = NULL;
|
||||
int bufsize = 8192;
|
||||
int rc = 0;
|
||||
int nfds = 1;
|
||||
char *buf = NULL;
|
||||
int bufsize = 8192;
|
||||
int rc = 0;
|
||||
int nfds = 1;
|
||||
LIBSSH2_POLLFD *fds = NULL;
|
||||
fd_set set;
|
||||
struct timeval timeval_out;
|
||||
@@ -192,12 +195,14 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
|
||||
|
||||
|
||||
FD_ZERO(&set);
|
||||
FD_SET(sock,&set);
|
||||
FD_SET(sock, &set);
|
||||
|
||||
if ((buf = calloc (bufsize, sizeof(char))) == NULL)
|
||||
buf = calloc(bufsize, sizeof(char));
|
||||
if(!buf)
|
||||
return 0;
|
||||
|
||||
if ((fds = malloc (sizeof (LIBSSH2_POLLFD))) == NULL) {
|
||||
fds = malloc(sizeof (LIBSSH2_POLLFD));
|
||||
if(!fds) {
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
@@ -208,18 +213,18 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
|
||||
fds[0].revents = LIBSSH2_POLLFD_POLLIN;
|
||||
|
||||
rc = libssh2_poll(fds, nfds, 0);
|
||||
if (rc >0) {
|
||||
if(rc >0) {
|
||||
rc = libssh2_channel_read(channel, buf, bufsize);
|
||||
write(sock, buf, rc);
|
||||
}
|
||||
|
||||
rc = select(sock+1, &set, NULL, NULL, &timeval_out);
|
||||
if (rc > 0) {
|
||||
rc = select(sock + 1, &set, NULL, NULL, &timeval_out);
|
||||
if(rc > 0) {
|
||||
memset((void *)buf, 0, bufsize);
|
||||
|
||||
/* Data in sock*/
|
||||
rc = read(sock, buf, bufsize);
|
||||
if (rc > 0) {
|
||||
if(rc > 0) {
|
||||
libssh2_channel_write(channel, buf, rc);
|
||||
}
|
||||
else {
|
||||
@@ -230,7 +235,7 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
|
||||
|
||||
free(fds);
|
||||
free(buf);
|
||||
if (libssh2_channel_eof(channel) == 1) {
|
||||
if(libssh2_channel_eof(channel) == 1) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -270,10 +275,10 @@ main (int argc, char *argv[])
|
||||
timeval_out.tv_usec = 10;
|
||||
|
||||
|
||||
if (argc > 3) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
username = argv[2];
|
||||
password = argv[3];
|
||||
if(argc > 3) {
|
||||
hostaddr = inet_addr(argv[1]);
|
||||
username = argv[2];
|
||||
password = argv[3];
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Usage: %s destination username password",
|
||||
@@ -281,51 +286,55 @@ main (int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (argc > 4) {
|
||||
if(argc > 4) {
|
||||
set_debug_on = 1;
|
||||
fprintf (stderr, "DEBUG is ON: %d\n", set_debug_on);
|
||||
fprintf(stderr, "DEBUG is ON: %d\n", set_debug_on);
|
||||
}
|
||||
|
||||
rc = libssh2_init (0);
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
rc = libssh2_init(0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sock == -1) {
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(sock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons (22);
|
||||
sin.sin_port = htons(22);
|
||||
sin.sin_addr.s_addr = hostaddr;
|
||||
|
||||
rc = connect(sock, (struct sockaddr *) &sin,
|
||||
sizeof(struct sockaddr_in));
|
||||
if (rc != 0) {
|
||||
fprintf (stderr, "Failed to established connection!\n");
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Failed to established connection!\n");
|
||||
return -1;
|
||||
}
|
||||
/* Open a session */
|
||||
session = libssh2_session_init();
|
||||
rc = libssh2_session_handshake(session, sock);
|
||||
if (rc != 0) {
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Failed Start the SSH session\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (set_debug_on == 1)
|
||||
if(set_debug_on == 1)
|
||||
libssh2_trace(session, LIBSSH2_TRACE_CONN);
|
||||
|
||||
/* ignore pedantic warnings by gcc on the callback argument */
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
/* Set X11 Callback */
|
||||
libssh2_session_callback_set(session, LIBSSH2_CALLBACK_X11,
|
||||
(void *)x11_callback);
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
/* Authenticate via password */
|
||||
rc = libssh2_userauth_password(session, username, password);
|
||||
if (rc != 0) {
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Failed to authenticate\n");
|
||||
session_shutdown(session);
|
||||
close(sock);
|
||||
@@ -334,7 +343,7 @@ main (int argc, char *argv[])
|
||||
|
||||
/* Open a channel */
|
||||
channel = libssh2_channel_open_session(session);
|
||||
if ( channel == NULL ) {
|
||||
if(channel == NULL) {
|
||||
fprintf(stderr, "Failed to open a new channel\n");
|
||||
session_shutdown(session);
|
||||
close(sock);
|
||||
@@ -343,8 +352,8 @@ main (int argc, char *argv[])
|
||||
|
||||
|
||||
/* Request a PTY */
|
||||
rc = libssh2_channel_request_pty( channel, "xterm");
|
||||
if (rc != 0) {
|
||||
rc = libssh2_channel_request_pty(channel, "xterm");
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Failed to request a pty\n");
|
||||
session_shutdown(session);
|
||||
close(sock);
|
||||
@@ -352,8 +361,8 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Request X11 */
|
||||
rc = libssh2_channel_x11_req(channel,0);
|
||||
if(rc!=0) {
|
||||
rc = libssh2_channel_x11_req(channel, 0);
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Failed to request X11 forwarding\n");
|
||||
session_shutdown(session);
|
||||
close(sock);
|
||||
@@ -362,7 +371,7 @@ main (int argc, char *argv[])
|
||||
|
||||
/* Request a shell */
|
||||
rc = libssh2_channel_shell(channel);
|
||||
if (rc!=0) {
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Failed to open a shell\n");
|
||||
session_shutdown(session);
|
||||
close(sock);
|
||||
@@ -370,7 +379,7 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
rc = _raw_mode();
|
||||
if (rc != 0) {
|
||||
if(rc != 0) {
|
||||
fprintf(stderr, "Failed to entered in raw mode\n");
|
||||
session_shutdown(session);
|
||||
close(sock);
|
||||
@@ -380,15 +389,15 @@ main (int argc, char *argv[])
|
||||
memset(&w_size, 0, sizeof(struct winsize));
|
||||
memset(&w_size_bck, 0, sizeof(struct winsize));
|
||||
|
||||
while (1) {
|
||||
while(1) {
|
||||
|
||||
FD_ZERO(&set);
|
||||
FD_SET(fileno(stdin),&set);
|
||||
FD_SET(fileno(stdin), &set);
|
||||
|
||||
/* Search if a resize pty has to be send */
|
||||
ioctl(fileno(stdin), TIOCGWINSZ, &w_size);
|
||||
if ((w_size.ws_row != w_size_bck.ws_row) ||
|
||||
(w_size.ws_col != w_size_bck.ws_col)) {
|
||||
if((w_size.ws_row != w_size_bck.ws_row) ||
|
||||
(w_size.ws_col != w_size_bck.ws_col)) {
|
||||
w_size_bck = w_size;
|
||||
|
||||
libssh2_channel_request_pty_size(channel,
|
||||
@@ -396,10 +405,12 @@ main (int argc, char *argv[])
|
||||
w_size.ws_row);
|
||||
}
|
||||
|
||||
if ((buf = calloc (bufsiz, sizeof(char))) == NULL)
|
||||
buf = calloc(bufsiz, sizeof(char));
|
||||
if(buf == NULL)
|
||||
break;
|
||||
|
||||
if ((fds = malloc (sizeof (LIBSSH2_POLLFD))) == NULL) {
|
||||
fds = malloc(sizeof (LIBSSH2_POLLFD));
|
||||
if(fds == NULL) {
|
||||
free(buf);
|
||||
break;
|
||||
}
|
||||
@@ -410,25 +421,25 @@ main (int argc, char *argv[])
|
||||
fds[0].revents = LIBSSH2_POLLFD_POLLIN;
|
||||
|
||||
rc = libssh2_poll(fds, nfds, 0);
|
||||
if (rc >0) {
|
||||
if(rc >0) {
|
||||
libssh2_channel_read(channel, buf, sizeof(buf));
|
||||
fprintf(stdout, "%s", buf);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/* Looping on X clients */
|
||||
if (gp_x11_chan != NULL) {
|
||||
if(gp_x11_chan != NULL) {
|
||||
current_node = gp_x11_chan;
|
||||
}
|
||||
else
|
||||
current_node = NULL;
|
||||
|
||||
while (current_node != NULL) {
|
||||
while(current_node != NULL) {
|
||||
struct chan_X11_list *next_node;
|
||||
rc = x11_send_receive(current_node->chan, current_node->sock);
|
||||
next_node = current_node->next;
|
||||
if (rc == -1){
|
||||
shutdown(current_node->sock,SHUT_RDWR);
|
||||
if(rc == -1) {
|
||||
shutdown(current_node->sock, SHUT_RDWR);
|
||||
close(current_node->sock);
|
||||
remove_node(current_node);
|
||||
}
|
||||
@@ -437,25 +448,25 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
rc = select(fileno(stdin)+1,&set,NULL,NULL,&timeval_out);
|
||||
if (rc > 0) {
|
||||
rc = select(fileno(stdin) + 1, &set, NULL, NULL, &timeval_out);
|
||||
if(rc > 0) {
|
||||
/* Data in stdin*/
|
||||
rc = read(fileno(stdin), buf,1);
|
||||
if (rc > 0)
|
||||
libssh2_channel_write(channel,buf, sizeof(buf));
|
||||
rc = read(fileno(stdin), buf, 1);
|
||||
if(rc > 0)
|
||||
libssh2_channel_write(channel, buf, sizeof(buf));
|
||||
}
|
||||
|
||||
free (fds);
|
||||
free (buf);
|
||||
free(fds);
|
||||
free(buf);
|
||||
|
||||
if (libssh2_channel_eof (channel) == 1) {
|
||||
break;
|
||||
if(libssh2_channel_eof (channel) == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (channel) {
|
||||
libssh2_channel_free (channel);
|
||||
channel = NULL;
|
||||
if(channel) {
|
||||
libssh2_channel_free(channel);
|
||||
channel = NULL;
|
||||
}
|
||||
_normal_mode();
|
||||
|
||||
|
||||
@@ -40,18 +40,18 @@
|
||||
#ifndef LIBSSH2_H
|
||||
#define LIBSSH2_H 1
|
||||
|
||||
#define LIBSSH2_COPYRIGHT "2004-2015 The libssh2 project and its contributors."
|
||||
#define LIBSSH2_COPYRIGHT "2004-2019 The libssh2 project and its contributors."
|
||||
|
||||
/* We use underscore instead of dash when appending DEV in dev versions just
|
||||
to make the BANNER define (used by src/session.c) be a valid SSH
|
||||
banner. Release versions have no appended strings and may of course not
|
||||
have dashes either. */
|
||||
#define LIBSSH2_VERSION "1.6.0"
|
||||
#define LIBSSH2_VERSION "1.10.0"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBSSH2_VERSION_MAJOR 1
|
||||
#define LIBSSH2_VERSION_MINOR 6
|
||||
#define LIBSSH2_VERSION_MINOR 10
|
||||
#define LIBSSH2_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libssh2 version number, meant for easier
|
||||
@@ -69,7 +69,7 @@
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
*/
|
||||
#define LIBSSH2_VERSION_NUM 0x010600
|
||||
#define LIBSSH2_VERSION_NUM 0x010a00
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
@@ -80,7 +80,7 @@
|
||||
*
|
||||
* "Mon Feb 12 11:35:33 UTC 2007"
|
||||
*/
|
||||
#define LIBSSH2_TIMESTAMP "Fri Jun 12 06:58:26 UTC 2015"
|
||||
#define LIBSSH2_TIMESTAMP "Sun 29 Aug 2021 08:37:50 PM UTC"
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
@@ -121,18 +121,28 @@ extern "C" {
|
||||
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
|
||||
# include <sys/bsdskt.h>
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short int uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef long long int64_t;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short int uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef unsigned __int64 libssh2_uint64_t;
|
||||
typedef __int64 libssh2_int64_t;
|
||||
#ifndef ssize_t
|
||||
#if (!defined(HAVE_SSIZE_T) && !defined(ssize_t))
|
||||
typedef SSIZE_T ssize_t;
|
||||
#define HAVE_SSIZE_T
|
||||
#endif
|
||||
#else
|
||||
#include <stdint.h>
|
||||
typedef unsigned long long libssh2_uint64_t;
|
||||
typedef long long libssh2_int64_t;
|
||||
#endif
|
||||
@@ -145,17 +155,91 @@ typedef int libssh2_socket_t;
|
||||
#define LIBSSH2_INVALID_SOCKET -1
|
||||
#endif /* WIN32 */
|
||||
|
||||
/*
|
||||
* Determine whether there is small or large file support on windows.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
|
||||
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||
# define LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
# else
|
||||
# define LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES)
|
||||
# define LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES)
|
||||
# define LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(__POCC__)
|
||||
# undef LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES) && \
|
||||
!defined(LIBSSH2_USE_WIN32_SMALL_FILES)
|
||||
# define LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Large file (>2Gb) support using WIN32 functions.
|
||||
*/
|
||||
|
||||
#ifdef LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
# include <io.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%I64d"
|
||||
typedef struct _stati64 libssh2_struct_stat;
|
||||
typedef __int64 libssh2_struct_stat_size;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Small file (<2Gb) support using WIN32 functions.
|
||||
*/
|
||||
|
||||
#ifdef LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# ifndef _WIN32_WCE
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%d"
|
||||
typedef struct _stat libssh2_struct_stat;
|
||||
typedef off_t libssh2_struct_stat_size;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBSSH2_STRUCT_STAT_SIZE_FORMAT
|
||||
# ifdef __VMS
|
||||
/* We have to roll our own format here because %z is a C99-ism we don't
|
||||
have. */
|
||||
# if __USE_OFF64_T || __USING_STD_STAT
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%Ld"
|
||||
# else
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%d"
|
||||
# endif
|
||||
# else
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%zd"
|
||||
# endif
|
||||
typedef struct stat libssh2_struct_stat;
|
||||
typedef off_t libssh2_struct_stat_size;
|
||||
#endif
|
||||
|
||||
/* Part of every banner, user specified or not */
|
||||
#define LIBSSH2_SSH_BANNER "SSH-2.0-libssh2_" LIBSSH2_VERSION
|
||||
|
||||
/* We *could* add a comment here if we so chose */
|
||||
#define LIBSSH2_SSH_DEFAULT_BANNER LIBSSH2_SSH_BANNER
|
||||
#define LIBSSH2_SSH_DEFAULT_BANNER_WITH_CRLF LIBSSH2_SSH_DEFAULT_BANNER "\r\n"
|
||||
#define LIBSSH2_SSH_DEFAULT_BANNER LIBSSH2_SSH_BANNER
|
||||
#define LIBSSH2_SSH_DEFAULT_BANNER_WITH_CRLF LIBSSH2_SSH_DEFAULT_BANNER "\r\n"
|
||||
|
||||
/* Default generate and safe prime sizes for diffie-hellman-group-exchange-sha1 */
|
||||
#define LIBSSH2_DH_GEX_MINGROUP 1024
|
||||
#define LIBSSH2_DH_GEX_OPTGROUP 1536
|
||||
#define LIBSSH2_DH_GEX_MAXGROUP 2048
|
||||
/* Default generate and safe prime sizes for
|
||||
diffie-hellman-group-exchange-sha1 */
|
||||
#define LIBSSH2_DH_GEX_MINGROUP 2048
|
||||
#define LIBSSH2_DH_GEX_OPTGROUP 4096
|
||||
#define LIBSSH2_DH_GEX_MAXGROUP 8192
|
||||
|
||||
#define LIBSSH2_DH_MAX_MODULUS_BITS 16384
|
||||
|
||||
/* Defaults for pty requests */
|
||||
#define LIBSSH2_TERM_WIDTH 80
|
||||
@@ -188,14 +272,14 @@ typedef int libssh2_socket_t;
|
||||
|
||||
typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT
|
||||
{
|
||||
char* text;
|
||||
char *text;
|
||||
unsigned int length;
|
||||
unsigned char echo;
|
||||
} LIBSSH2_USERAUTH_KBDINT_PROMPT;
|
||||
|
||||
typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE
|
||||
{
|
||||
char* text;
|
||||
char *text;
|
||||
unsigned int length;
|
||||
} LIBSSH2_USERAUTH_KBDINT_RESPONSE;
|
||||
|
||||
@@ -206,10 +290,10 @@ typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE
|
||||
|
||||
/* 'keyboard-interactive' authentication callback */
|
||||
#define LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(name_) \
|
||||
void name_(const char* name, int name_len, const char* instruction, \
|
||||
void name_(const char *name, int name_len, const char *instruction, \
|
||||
int instruction_len, int num_prompts, \
|
||||
const LIBSSH2_USERAUTH_KBDINT_PROMPT* prompts, \
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE* responses, void **abstract)
|
||||
const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts, \
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses, void **abstract)
|
||||
|
||||
/* Callbacks for special SSH packets */
|
||||
#define LIBSSH2_IGNORE_FUNC(name) \
|
||||
@@ -243,12 +327,14 @@ typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE
|
||||
LIBSSH2_CHANNEL *channel, void **channel_abstract)
|
||||
|
||||
/* I/O callbacks */
|
||||
#define LIBSSH2_RECV_FUNC(name) ssize_t name(libssh2_socket_t socket, \
|
||||
void *buffer, size_t length, \
|
||||
int flags, void **abstract)
|
||||
#define LIBSSH2_SEND_FUNC(name) ssize_t name(libssh2_socket_t socket, \
|
||||
const void *buffer, size_t length,\
|
||||
int flags, void **abstract)
|
||||
#define LIBSSH2_RECV_FUNC(name) \
|
||||
ssize_t name(libssh2_socket_t socket, \
|
||||
void *buffer, size_t length, \
|
||||
int flags, void **abstract)
|
||||
#define LIBSSH2_SEND_FUNC(name) \
|
||||
ssize_t name(libssh2_socket_t socket, \
|
||||
const void *buffer, size_t length, \
|
||||
int flags, void **abstract)
|
||||
|
||||
/* libssh2_session_callback_set() constants */
|
||||
#define LIBSSH2_CALLBACK_IGNORE 0
|
||||
@@ -332,11 +418,16 @@ typedef struct _LIBSSH2_POLLFD {
|
||||
/* Hash Types */
|
||||
#define LIBSSH2_HOSTKEY_HASH_MD5 1
|
||||
#define LIBSSH2_HOSTKEY_HASH_SHA1 2
|
||||
#define LIBSSH2_HOSTKEY_HASH_SHA256 3
|
||||
|
||||
/* Hostkey Types */
|
||||
#define LIBSSH2_HOSTKEY_TYPE_UNKNOWN 0
|
||||
#define LIBSSH2_HOSTKEY_TYPE_RSA 1
|
||||
#define LIBSSH2_HOSTKEY_TYPE_DSS 2
|
||||
#define LIBSSH2_HOSTKEY_TYPE_UNKNOWN 0
|
||||
#define LIBSSH2_HOSTKEY_TYPE_RSA 1
|
||||
#define LIBSSH2_HOSTKEY_TYPE_DSS 2
|
||||
#define LIBSSH2_HOSTKEY_TYPE_ECDSA_256 3
|
||||
#define LIBSSH2_HOSTKEY_TYPE_ECDSA_384 4
|
||||
#define LIBSSH2_HOSTKEY_TYPE_ECDSA_521 5
|
||||
#define LIBSSH2_HOSTKEY_TYPE_ED25519 6
|
||||
|
||||
/* Disconnect Codes (defined by SSH protocol) */
|
||||
#define SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT 1
|
||||
@@ -382,7 +473,8 @@ typedef struct _LIBSSH2_POLLFD {
|
||||
#define LIBSSH2_ERROR_FILE -16
|
||||
#define LIBSSH2_ERROR_METHOD_NONE -17
|
||||
#define LIBSSH2_ERROR_AUTHENTICATION_FAILED -18
|
||||
#define LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED LIBSSH2_ERROR_AUTHENTICATION_FAILED
|
||||
#define LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED \
|
||||
LIBSSH2_ERROR_AUTHENTICATION_FAILED
|
||||
#define LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED -19
|
||||
#define LIBSSH2_ERROR_CHANNEL_OUTOFORDER -20
|
||||
#define LIBSSH2_ERROR_CHANNEL_FAILURE -21
|
||||
@@ -411,6 +503,9 @@ typedef struct _LIBSSH2_POLLFD {
|
||||
#define LIBSSH2_ERROR_ENCRYPT -44
|
||||
#define LIBSSH2_ERROR_BAD_SOCKET -45
|
||||
#define LIBSSH2_ERROR_KNOWN_HOSTS -46
|
||||
#define LIBSSH2_ERROR_CHANNEL_WINDOW_FULL -47
|
||||
#define LIBSSH2_ERROR_KEYFILE_AUTH_FAILED -48
|
||||
#define LIBSSH2_ERROR_RANDGEN -49
|
||||
|
||||
/* this is a define to provide the old (<= 1.2.7) name */
|
||||
#define LIBSSH2_ERROR_BANNER_NONE LIBSSH2_ERROR_BANNER_RECV
|
||||
@@ -453,14 +548,14 @@ LIBSSH2_API void libssh2_free(LIBSSH2_SESSION *session, void *ptr);
|
||||
*
|
||||
* Fills algs with a list of supported acryptographic algorithms. Returns a
|
||||
* non-negative number (number of supported algorithms) on success or a
|
||||
* negative number (an eror code) on failure.
|
||||
* negative number (an error code) on failure.
|
||||
*
|
||||
* NOTE: on success, algs must be deallocated (by calling libssh2_free) when
|
||||
* not needed anymore
|
||||
*/
|
||||
LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
|
||||
int method_type,
|
||||
const char*** algs);
|
||||
const char ***algs);
|
||||
|
||||
/* Session API */
|
||||
LIBSSH2_API LIBSSH2_SESSION *
|
||||
@@ -506,6 +601,9 @@ LIBSSH2_API int libssh2_session_last_error(LIBSSH2_SESSION *session,
|
||||
char **errmsg,
|
||||
int *errmsg_len, int want_buf);
|
||||
LIBSSH2_API int libssh2_session_last_errno(LIBSSH2_SESSION *session);
|
||||
LIBSSH2_API int libssh2_session_set_last_error(LIBSSH2_SESSION* session,
|
||||
int errcode,
|
||||
const char *errmsg);
|
||||
LIBSSH2_API int libssh2_session_block_directions(LIBSSH2_SESSION *session);
|
||||
|
||||
LIBSSH2_API int libssh2_session_flag(LIBSSH2_SESSION *session, int flag,
|
||||
@@ -518,12 +616,14 @@ LIBSSH2_API char *libssh2_userauth_list(LIBSSH2_SESSION *session,
|
||||
unsigned int username_len);
|
||||
LIBSSH2_API int libssh2_userauth_authenticated(LIBSSH2_SESSION *session);
|
||||
|
||||
LIBSSH2_API int libssh2_userauth_password_ex(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
unsigned int username_len,
|
||||
const char *password,
|
||||
unsigned int password_len,
|
||||
LIBSSH2_PASSWD_CHANGEREQ_FUNC((*passwd_change_cb)));
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_password_ex(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
unsigned int username_len,
|
||||
const char *password,
|
||||
unsigned int password_len,
|
||||
LIBSSH2_PASSWD_CHANGEREQ_FUNC
|
||||
((*passwd_change_cb)));
|
||||
|
||||
#define libssh2_userauth_password(session, username, password) \
|
||||
libssh2_userauth_password_ex((session), (username), \
|
||||
@@ -550,7 +650,8 @@ libssh2_userauth_publickey(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
const unsigned char *pubkeydata,
|
||||
size_t pubkeydata_len,
|
||||
LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*sign_callback)),
|
||||
LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC
|
||||
((*sign_callback)),
|
||||
void **abstract);
|
||||
|
||||
LIBSSH2_API int
|
||||
@@ -590,13 +691,14 @@ libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session,
|
||||
* response_callback is provided with filled by library prompts array,
|
||||
* but client must allocate and fill individual responses. Responses
|
||||
* array is already allocated. Responses data will be freed by libssh2
|
||||
* after callback return, but before subsequent callback invokation.
|
||||
* after callback return, but before subsequent callback invocation.
|
||||
*/
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION* session,
|
||||
const char *username,
|
||||
unsigned int username_len,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*response_callback)));
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(
|
||||
(*response_callback)));
|
||||
|
||||
#define libssh2_userauth_keyboard_interactive(session, username, \
|
||||
response_callback) \
|
||||
@@ -619,7 +721,7 @@ LIBSSH2_API int libssh2_poll(LIBSSH2_POLLFD *fds, unsigned int nfds,
|
||||
|
||||
#define SSH_EXTENDED_DATA_STDERR 1
|
||||
|
||||
/* Returned by any function that would block during a read/write opperation */
|
||||
/* Returned by any function that would block during a read/write operation */
|
||||
#define LIBSSH2CHANNEL_EAGAIN LIBSSH2_ERROR_EAGAIN
|
||||
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *
|
||||
@@ -641,7 +743,8 @@ libssh2_channel_direct_tcpip_ex(LIBSSH2_SESSION *session, const char *host,
|
||||
|
||||
LIBSSH2_API LIBSSH2_LISTENER *
|
||||
libssh2_channel_forward_listen_ex(LIBSSH2_SESSION *session, const char *host,
|
||||
int port, int *bound_port, int queue_maxsize);
|
||||
int port, int *bound_port,
|
||||
int queue_maxsize);
|
||||
#define libssh2_channel_forward_listen(session, port) \
|
||||
libssh2_channel_forward_listen_ex((session), NULL, (port), NULL, 16)
|
||||
|
||||
@@ -661,6 +764,8 @@ LIBSSH2_API int libssh2_channel_setenv_ex(LIBSSH2_CHANNEL *channel,
|
||||
(unsigned int)strlen(varname), (value), \
|
||||
(unsigned int)strlen(value))
|
||||
|
||||
LIBSSH2_API int libssh2_channel_request_auth_agent(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
LIBSSH2_API int libssh2_channel_request_pty_ex(LIBSSH2_CHANNEL *channel,
|
||||
const char *term,
|
||||
unsigned int term_len,
|
||||
@@ -672,15 +777,17 @@ LIBSSH2_API int libssh2_channel_request_pty_ex(LIBSSH2_CHANNEL *channel,
|
||||
libssh2_channel_request_pty_ex((channel), (term), \
|
||||
(unsigned int)strlen(term), \
|
||||
NULL, 0, \
|
||||
LIBSSH2_TERM_WIDTH, LIBSSH2_TERM_HEIGHT, \
|
||||
LIBSSH2_TERM_WIDTH_PX, LIBSSH2_TERM_HEIGHT_PX)
|
||||
LIBSSH2_TERM_WIDTH, \
|
||||
LIBSSH2_TERM_HEIGHT, \
|
||||
LIBSSH2_TERM_WIDTH_PX, \
|
||||
LIBSSH2_TERM_HEIGHT_PX)
|
||||
|
||||
LIBSSH2_API int libssh2_channel_request_pty_size_ex(LIBSSH2_CHANNEL *channel,
|
||||
int width, int height,
|
||||
int width_px,
|
||||
int height_px);
|
||||
#define libssh2_channel_request_pty_size(channel, width, height) \
|
||||
libssh2_channel_request_pty_size_ex( (channel), (width), (height), 0, 0)
|
||||
libssh2_channel_request_pty_size_ex((channel), (width), (height), 0, 0)
|
||||
|
||||
LIBSSH2_API int libssh2_channel_x11_req_ex(LIBSSH2_CHANNEL *channel,
|
||||
int single_connection,
|
||||
@@ -742,8 +849,9 @@ LIBSSH2_API ssize_t libssh2_channel_write_ex(LIBSSH2_CHANNEL *channel,
|
||||
|
||||
#define libssh2_channel_write(channel, buf, buflen) \
|
||||
libssh2_channel_write_ex((channel), 0, (buf), (buflen))
|
||||
#define libssh2_channel_write_stderr(channel, buf, buflen) \
|
||||
libssh2_channel_write_ex((channel), SSH_EXTENDED_DATA_STDERR, (buf), (buflen))
|
||||
#define libssh2_channel_write_stderr(channel, buf, buflen) \
|
||||
libssh2_channel_write_ex((channel), SSH_EXTENDED_DATA_STDERR, \
|
||||
(buf), (buflen))
|
||||
|
||||
LIBSSH2_API unsigned long
|
||||
libssh2_channel_window_write_ex(LIBSSH2_CHANNEL *channel,
|
||||
@@ -780,7 +888,7 @@ LIBSSH2_API int libssh2_channel_handle_extended_data2(LIBSSH2_CHANNEL *channel,
|
||||
libssh2_channel_handle_extended_data((channel), \
|
||||
(ignore) ? \
|
||||
LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE : \
|
||||
LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL )
|
||||
LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL)
|
||||
|
||||
#define LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA -1
|
||||
#define LIBSSH2_CHANNEL_FLUSH_ALL -2
|
||||
@@ -805,9 +913,14 @@ LIBSSH2_API int libssh2_channel_close(LIBSSH2_CHANNEL *channel);
|
||||
LIBSSH2_API int libssh2_channel_wait_closed(LIBSSH2_CHANNEL *channel);
|
||||
LIBSSH2_API int libssh2_channel_free(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
/* libssh2_scp_recv is DEPRECATED, do not use! */
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session,
|
||||
const char *path,
|
||||
struct stat *sb);
|
||||
/* Use libssh2_scp_recv2 for large (> 2GB) file support on windows */
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv2(LIBSSH2_SESSION *session,
|
||||
const char *path,
|
||||
libssh2_struct_stat *sb);
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session,
|
||||
const char *path, int mode,
|
||||
size_t size, long mtime,
|
||||
@@ -879,13 +992,17 @@ libssh2_knownhost_init(LIBSSH2_SESSION *session);
|
||||
#define LIBSSH2_KNOWNHOST_KEYENC_RAW (1<<16)
|
||||
#define LIBSSH2_KNOWNHOST_KEYENC_BASE64 (2<<16)
|
||||
|
||||
/* type of key (2 bits) */
|
||||
#define LIBSSH2_KNOWNHOST_KEY_MASK (7<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_SHIFT 18
|
||||
#define LIBSSH2_KNOWNHOST_KEY_RSA1 (1<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_SSHRSA (2<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_SSHDSS (3<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_UNKNOWN (7<<18)
|
||||
/* type of key (4 bits) */
|
||||
#define LIBSSH2_KNOWNHOST_KEY_MASK (15<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_SHIFT 18
|
||||
#define LIBSSH2_KNOWNHOST_KEY_RSA1 (1<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_SSHRSA (2<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_SSHDSS (3<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_ECDSA_256 (4<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_ECDSA_384 (5<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_ECDSA_521 (6<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_ED25519 (7<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_UNKNOWN (15<<18)
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
@@ -1053,7 +1170,7 @@ libssh2_knownhost_writefile(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
* libssh2_knownhost_get()
|
||||
*
|
||||
* Traverse the internal list of known hosts. Pass NULL to 'prev' to get
|
||||
* the first one. Or pass a poiner to the previously returned one to get the
|
||||
* the first one. Or pass a pointer to the previously returned one to get the
|
||||
* next.
|
||||
*
|
||||
* Returns:
|
||||
@@ -1109,7 +1226,7 @@ libssh2_agent_list_identities(LIBSSH2_AGENT *agent);
|
||||
* libssh2_agent_get_identity()
|
||||
*
|
||||
* Traverse the internal list of public keys. Pass NULL to 'prev' to get
|
||||
* the first one. Or pass a poiner to the previously returned one to get the
|
||||
* the first one. Or pass a pointer to the previously returned one to get the
|
||||
* next.
|
||||
*
|
||||
* Returns:
|
||||
@@ -1153,6 +1270,24 @@ libssh2_agent_disconnect(LIBSSH2_AGENT *agent);
|
||||
LIBSSH2_API void
|
||||
libssh2_agent_free(LIBSSH2_AGENT *agent);
|
||||
|
||||
/*
|
||||
* libssh2_agent_set_identity_path()
|
||||
*
|
||||
* Allows a custom agent identity socket path beyond SSH_AUTH_SOCK env
|
||||
*
|
||||
*/
|
||||
LIBSSH2_API void
|
||||
libssh2_agent_set_identity_path(LIBSSH2_AGENT *agent,
|
||||
const char *path);
|
||||
|
||||
/*
|
||||
* libssh2_agent_get_identity_path()
|
||||
*
|
||||
* Returns the custom agent identity socket path if set
|
||||
*
|
||||
*/
|
||||
LIBSSH2_API const char *
|
||||
libssh2_agent_get_identity_path(LIBSSH2_AGENT *agent);
|
||||
|
||||
/*
|
||||
* libssh2_keepalive_config()
|
||||
@@ -1167,9 +1302,9 @@ libssh2_agent_free(LIBSSH2_AGENT *agent);
|
||||
* Note that non-blocking applications are responsible for sending the
|
||||
* keepalive messages using libssh2_keepalive_send().
|
||||
*/
|
||||
LIBSSH2_API void libssh2_keepalive_config (LIBSSH2_SESSION *session,
|
||||
int want_reply,
|
||||
unsigned interval);
|
||||
LIBSSH2_API void libssh2_keepalive_config(LIBSSH2_SESSION *session,
|
||||
int want_reply,
|
||||
unsigned interval);
|
||||
|
||||
/*
|
||||
* libssh2_keepalive_send()
|
||||
@@ -1179,8 +1314,8 @@ LIBSSH2_API void libssh2_keepalive_config (LIBSSH2_SESSION *session,
|
||||
* it again. Returns 0 on success, or LIBSSH2_ERROR_SOCKET_SEND on
|
||||
* I/O errors.
|
||||
*/
|
||||
LIBSSH2_API int libssh2_keepalive_send (LIBSSH2_SESSION *session,
|
||||
int *seconds_to_next);
|
||||
LIBSSH2_API int libssh2_keepalive_send(LIBSSH2_SESSION *session,
|
||||
int *seconds_to_next);
|
||||
|
||||
/* NOTE NOTE NOTE
|
||||
libssh2_trace() has no function in builds that aren't built with debug
|
||||
@@ -1198,11 +1333,11 @@ LIBSSH2_API int libssh2_trace(LIBSSH2_SESSION *session, int bitmask);
|
||||
#define LIBSSH2_TRACE_SOCKET (1<<9)
|
||||
|
||||
typedef void (*libssh2_trace_handler_func)(LIBSSH2_SESSION*,
|
||||
void*,
|
||||
void *,
|
||||
const char *,
|
||||
size_t);
|
||||
LIBSSH2_API int libssh2_trace_sethandler(LIBSSH2_SESSION *session,
|
||||
void* context,
|
||||
void *context,
|
||||
libssh2_trace_handler_func callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -69,7 +69,8 @@ typedef struct _libssh2_publickey_list {
|
||||
libssh2_publickey_attribute *attrs; /* free me */
|
||||
} libssh2_publickey_list;
|
||||
|
||||
/* Generally use the first macro here, but if both name and value are string literals, you can use _fast() to take advantage of preprocessing */
|
||||
/* Generally use the first macro here, but if both name and value are string
|
||||
literals, you can use _fast() to take advantage of preprocessing */
|
||||
#define libssh2_publickey_attribute(name, value, mandatory) \
|
||||
{ (name), strlen(name), (value), strlen(value), (mandatory) },
|
||||
#define libssh2_publickey_attribute_fast(name, value, mandatory) \
|
||||
@@ -80,16 +81,18 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Publickey Subsystem */
|
||||
LIBSSH2_API LIBSSH2_PUBLICKEY *libssh2_publickey_init(LIBSSH2_SESSION *session);
|
||||
LIBSSH2_API LIBSSH2_PUBLICKEY *
|
||||
libssh2_publickey_init(LIBSSH2_SESSION *session);
|
||||
|
||||
LIBSSH2_API int libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY *pkey,
|
||||
const unsigned char *name,
|
||||
unsigned long name_len,
|
||||
const unsigned char *blob,
|
||||
unsigned long blob_len, char overwrite,
|
||||
unsigned long num_attrs,
|
||||
const libssh2_publickey_attribute attrs[]);
|
||||
#define libssh2_publickey_add(pkey, name, blob, blob_len, overwrite, \
|
||||
LIBSSH2_API int
|
||||
libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY *pkey,
|
||||
const unsigned char *name,
|
||||
unsigned long name_len,
|
||||
const unsigned char *blob,
|
||||
unsigned long blob_len, char overwrite,
|
||||
unsigned long num_attrs,
|
||||
const libssh2_publickey_attribute attrs[]);
|
||||
#define libssh2_publickey_add(pkey, name, blob, blob_len, overwrite, \
|
||||
num_attrs, attrs) \
|
||||
libssh2_publickey_add_ex((pkey), (name), strlen(name), (blob), (blob_len), \
|
||||
(overwrite), (num_attrs), (attrs))
|
||||
@@ -106,8 +109,9 @@ LIBSSH2_API int
|
||||
libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY *pkey,
|
||||
unsigned long *num_keys,
|
||||
libssh2_publickey_list **pkey_list);
|
||||
LIBSSH2_API void libssh2_publickey_list_free(LIBSSH2_PUBLICKEY *pkey,
|
||||
libssh2_publickey_list *pkey_list);
|
||||
LIBSSH2_API void
|
||||
libssh2_publickey_list_free(LIBSSH2_PUBLICKEY *pkey,
|
||||
libssh2_publickey_list *pkey_list);
|
||||
|
||||
LIBSSH2_API int libssh2_publickey_shutdown(LIBSSH2_PUBLICKEY *pkey);
|
||||
|
||||
|
||||
@@ -79,6 +79,9 @@ typedef struct _LIBSSH2_SFTP_STATVFS LIBSSH2_SFTP_STATVFS;
|
||||
#define LIBSSH2_SFTP_READLINK 1
|
||||
#define LIBSSH2_SFTP_REALPATH 2
|
||||
|
||||
/* Flags for sftp_mkdir() */
|
||||
#define LIBSSH2_SFTP_DEFAULT_MODE -1
|
||||
|
||||
/* SFTP attribute flag bits */
|
||||
#define LIBSSH2_SFTP_ATTR_SIZE 0x00000001
|
||||
#define LIBSSH2_SFTP_ATTR_UIDGID 0x00000002
|
||||
@@ -186,32 +189,32 @@ struct _LIBSSH2_SFTP_STATVFS {
|
||||
#define LIBSSH2_FXF_EXCL 0x00000020
|
||||
|
||||
/* SFTP Status Codes (returned by libssh2_sftp_last_error() ) */
|
||||
#define LIBSSH2_FX_OK 0
|
||||
#define LIBSSH2_FX_EOF 1
|
||||
#define LIBSSH2_FX_NO_SUCH_FILE 2
|
||||
#define LIBSSH2_FX_PERMISSION_DENIED 3
|
||||
#define LIBSSH2_FX_FAILURE 4
|
||||
#define LIBSSH2_FX_BAD_MESSAGE 5
|
||||
#define LIBSSH2_FX_NO_CONNECTION 6
|
||||
#define LIBSSH2_FX_CONNECTION_LOST 7
|
||||
#define LIBSSH2_FX_OP_UNSUPPORTED 8
|
||||
#define LIBSSH2_FX_INVALID_HANDLE 9
|
||||
#define LIBSSH2_FX_NO_SUCH_PATH 10
|
||||
#define LIBSSH2_FX_FILE_ALREADY_EXISTS 11
|
||||
#define LIBSSH2_FX_WRITE_PROTECT 12
|
||||
#define LIBSSH2_FX_NO_MEDIA 13
|
||||
#define LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM 14
|
||||
#define LIBSSH2_FX_QUOTA_EXCEEDED 15
|
||||
#define LIBSSH2_FX_UNKNOWN_PRINCIPLE 16 /* Initial mis-spelling */
|
||||
#define LIBSSH2_FX_UNKNOWN_PRINCIPAL 16
|
||||
#define LIBSSH2_FX_LOCK_CONFlICT 17 /* Initial mis-spelling */
|
||||
#define LIBSSH2_FX_LOCK_CONFLICT 17
|
||||
#define LIBSSH2_FX_DIR_NOT_EMPTY 18
|
||||
#define LIBSSH2_FX_NOT_A_DIRECTORY 19
|
||||
#define LIBSSH2_FX_INVALID_FILENAME 20
|
||||
#define LIBSSH2_FX_LINK_LOOP 21
|
||||
#define LIBSSH2_FX_OK 0UL
|
||||
#define LIBSSH2_FX_EOF 1UL
|
||||
#define LIBSSH2_FX_NO_SUCH_FILE 2UL
|
||||
#define LIBSSH2_FX_PERMISSION_DENIED 3UL
|
||||
#define LIBSSH2_FX_FAILURE 4UL
|
||||
#define LIBSSH2_FX_BAD_MESSAGE 5UL
|
||||
#define LIBSSH2_FX_NO_CONNECTION 6UL
|
||||
#define LIBSSH2_FX_CONNECTION_LOST 7UL
|
||||
#define LIBSSH2_FX_OP_UNSUPPORTED 8UL
|
||||
#define LIBSSH2_FX_INVALID_HANDLE 9UL
|
||||
#define LIBSSH2_FX_NO_SUCH_PATH 10UL
|
||||
#define LIBSSH2_FX_FILE_ALREADY_EXISTS 11UL
|
||||
#define LIBSSH2_FX_WRITE_PROTECT 12UL
|
||||
#define LIBSSH2_FX_NO_MEDIA 13UL
|
||||
#define LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM 14UL
|
||||
#define LIBSSH2_FX_QUOTA_EXCEEDED 15UL
|
||||
#define LIBSSH2_FX_UNKNOWN_PRINCIPLE 16UL /* Initial mis-spelling */
|
||||
#define LIBSSH2_FX_UNKNOWN_PRINCIPAL 16UL
|
||||
#define LIBSSH2_FX_LOCK_CONFlICT 17UL /* Initial mis-spelling */
|
||||
#define LIBSSH2_FX_LOCK_CONFLICT 17UL
|
||||
#define LIBSSH2_FX_DIR_NOT_EMPTY 18UL
|
||||
#define LIBSSH2_FX_NOT_A_DIRECTORY 19UL
|
||||
#define LIBSSH2_FX_INVALID_FILENAME 20UL
|
||||
#define LIBSSH2_FX_LINK_LOOP 21UL
|
||||
|
||||
/* Returned by any function that would block during a read/write opperation */
|
||||
/* Returned by any function that would block during a read/write operation */
|
||||
#define LIBSSH2SFTP_EAGAIN LIBSSH2_ERROR_EAGAIN
|
||||
|
||||
/* SFTP API */
|
||||
@@ -221,12 +224,13 @@ LIBSSH2_API unsigned long libssh2_sftp_last_error(LIBSSH2_SFTP *sftp);
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_sftp_get_channel(LIBSSH2_SFTP *sftp);
|
||||
|
||||
/* File / Directory Ops */
|
||||
LIBSSH2_API LIBSSH2_SFTP_HANDLE *libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp,
|
||||
const char *filename,
|
||||
unsigned int filename_len,
|
||||
unsigned long flags,
|
||||
long mode, int open_type);
|
||||
#define libssh2_sftp_open(sftp, filename, flags, mode) \
|
||||
LIBSSH2_API LIBSSH2_SFTP_HANDLE *
|
||||
libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp,
|
||||
const char *filename,
|
||||
unsigned int filename_len,
|
||||
unsigned long flags,
|
||||
long mode, int open_type);
|
||||
#define libssh2_sftp_open(sftp, filename, flags, mode) \
|
||||
libssh2_sftp_open_ex((sftp), (filename), strlen(filename), (flags), \
|
||||
(mode), LIBSSH2_SFTP_OPENFILE)
|
||||
#define libssh2_sftp_opendir(sftp, path) \
|
||||
@@ -328,7 +332,8 @@ LIBSSH2_API int libssh2_sftp_symlink_ex(LIBSSH2_SFTP *sftp,
|
||||
const char *path,
|
||||
unsigned int path_len,
|
||||
char *target,
|
||||
unsigned int target_len, int link_type);
|
||||
unsigned int target_len,
|
||||
int link_type);
|
||||
#define libssh2_sftp_symlink(sftp, orig, linkpath) \
|
||||
libssh2_sftp_symlink_ex((sftp), (orig), strlen(orig), (linkpath), \
|
||||
strlen(linkpath), LIBSSH2_SFTP_SYMLINK)
|
||||
|
||||
566
install-sh
566
install-sh
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2005-05-14.22
|
||||
scriptversion=2020-11-14.01; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
@@ -35,42 +35,62 @@ scriptversion=2005-05-14.22
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# 'make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
# from scratch.
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
tab=' '
|
||||
nl='
|
||||
'
|
||||
IFS=" $tab$nl"
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
# Set DOITPROG to "echo" to test this script.
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
doit=${DOITPROG-}
|
||||
doit_exec=${doit:-exec}
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
# Create dirs (including intermediate dirs) using mode 755.
|
||||
# This is like GNU 'install' as of coreutils 8.32 (2020).
|
||||
mkdir_umask=22
|
||||
|
||||
backupsuffix=
|
||||
chgrpcmd=
|
||||
stripcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dstarg=
|
||||
no_target_directory=
|
||||
dst_arg=
|
||||
|
||||
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
copy_on_change=false
|
||||
is_target_a_directory=possibly
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
@@ -80,108 +100,187 @@ In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
-c (ignored)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-p pass -p to $cpprog.
|
||||
-s $stripprog installed files.
|
||||
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
|
||||
By default, rm is invoked with -f; when overridden with RMPROG,
|
||||
it's up to you to specify -f if you want it.
|
||||
|
||||
If -S is not specified, no backups are attempted.
|
||||
|
||||
Email bug reports to bug-automake@gnu.org.
|
||||
Automake home page: https://www.gnu.org/software/automake/
|
||||
"
|
||||
|
||||
while test -n "$1"; do
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) shift
|
||||
continue;;
|
||||
-c) ;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog
|
||||
shift
|
||||
continue;;
|
||||
-p) cpprog="$cpprog -p";;
|
||||
|
||||
-t) dstarg=$2
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-T) no_target_directory=true
|
||||
shift
|
||||
continue;;
|
||||
-S) backupsuffix="$2"
|
||||
shift;;
|
||||
|
||||
-t)
|
||||
is_target_a_directory=always
|
||||
dst_arg=$2
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) is_target_a_directory=never;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
*) # When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
test -n "$dir_arg$dstarg" && break
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dstarg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dstarg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dstarg=$arg
|
||||
done
|
||||
break;;
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$1"; then
|
||||
# We allow the use of options -d and -T together, by making -d
|
||||
# take the precedence; this is for compatibility with GNU install.
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
if test -n "$dst_arg"; then
|
||||
echo "$0: target directory not allowed when installing a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# It's OK to call 'install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
||||
if test ! -d "$dst_arg"; then
|
||||
echo "$0: $dst_arg: Is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $src in
|
||||
-*) src=./$src ;;
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
src=
|
||||
|
||||
if test -d "$dst"; then
|
||||
mkdircmd=:
|
||||
chmodcmd=
|
||||
else
|
||||
mkdircmd=$mkdirprog
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
# Don't chown directories that already exist.
|
||||
if test $dstdir_status = 0; then
|
||||
chowncmd=""
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
@@ -190,82 +289,185 @@ do
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dstarg"; then
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
dst=$dstarg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst ;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
# If destination is a directory, append the input filename.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dstarg: Is a directory" >&2
|
||||
exit 1
|
||||
if test "$is_target_a_directory" = never; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst/`basename "$src"`
|
||||
dstdir=$dst
|
||||
dstbase=`basename "$src"`
|
||||
case $dst in
|
||||
*/) dst=$dst$dstbase;;
|
||||
*) dst=$dst/$dstbase;;
|
||||
esac
|
||||
dstdir_status=0
|
||||
else
|
||||
dstdir=`dirname "$dst"`
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
# This sed command emulates the dirname command.
|
||||
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
|
||||
case $dstdir in
|
||||
*/) dstdirslash=$dstdir;;
|
||||
*) dstdirslash=$dstdir/;;
|
||||
esac
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if test ! -d "$dstdir"; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-$defaultIFS}"
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
oIFS=$IFS
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
shift
|
||||
IFS=$oIFS
|
||||
posix_mkdir=false
|
||||
# The $RANDOM variable is not portable (e.g., dash). Use it
|
||||
# here however when possible just to lower collision chance.
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
|
||||
pathcomp=
|
||||
trap '
|
||||
ret=$?
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
|
||||
exit $ret
|
||||
' 0
|
||||
|
||||
while test $# -ne 0 ; do
|
||||
pathcomp=$pathcomp$1
|
||||
# Because "mkdir -p" follows existing symlinks and we likely work
|
||||
# directly in world-writeable /tmp, make sure that the '$tmpdir'
|
||||
# directory is successfully created first before we actually test
|
||||
# 'mkdir -p'.
|
||||
if (umask $mkdir_umask &&
|
||||
$mkdirprog $mkdir_mode "$tmpdir" &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
test_tmpdir="$tmpdir/a"
|
||||
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
if test ! -d "$pathcomp"; then
|
||||
$mkdirprog "$pathcomp"
|
||||
# mkdir can fail with a `File exist' error in case several
|
||||
# install-sh are creating the directory concurrently. This
|
||||
# is OK.
|
||||
test -d "$pathcomp" || exit
|
||||
set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
pathcomp=$pathcomp/
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
$doit $mkdircmd "$dst" \
|
||||
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
|
||||
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
dstfile=`basename "$dst"`
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
dsttmp=${dstdirslash}_inst.$$_
|
||||
rmtmp=${dstdirslash}_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
$doit $cpprog "$src" "$dsttmp" &&
|
||||
(umask $cp_umask &&
|
||||
{ test -z "$stripcmd" || {
|
||||
# Create $dsttmp read-write so that cp doesn't create it read-only,
|
||||
# which would cause strip to fail.
|
||||
if test -z "$doit"; then
|
||||
: >"$dsttmp" # No need to fork-exec 'touch'.
|
||||
else
|
||||
$doit touch "$dsttmp"
|
||||
fi
|
||||
}
|
||||
} &&
|
||||
$doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
@@ -273,51 +475,67 @@ do
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|
||||
|| {
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
set +f &&
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# If $backupsuffix is set, and the file being installed
|
||||
# already exists, attempt a backup. Don't worry if it fails,
|
||||
# e.g., if mv doesn't support -f.
|
||||
if test -n "$backupsuffix" && test -f "$dst"; then
|
||||
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
if test -f "$dstdir/$dstfile"; then
|
||||
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|
||||
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|
||||
|| {
|
||||
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
else
|
||||
:
|
||||
fi
|
||||
} &&
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||
}
|
||||
}
|
||||
fi || { (exit 1); exit 1; }
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# The final little trick to "correctly" pass the exit status to the exit trap.
|
||||
{
|
||||
(exit 0); exit 0
|
||||
}
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
||||
@@ -8,10 +8,10 @@ libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: libssh2
|
||||
URL: http://www.libssh2.org/
|
||||
URL: https://www.libssh2.org/
|
||||
Description: Library for SSH-based communication
|
||||
Version: @LIBSSH2VER@
|
||||
Requires.private: @LIBSREQUIRED@
|
||||
Libs: -L${libdir} -lssh2 @LDFLAGS@ @LIBS@
|
||||
Libs: -L${libdir} -lssh2 @LIBS@
|
||||
Libs.private: @LIBS@
|
||||
Cflags: -I${includedir}
|
||||
|
||||
2549
m4/libtool.m4
vendored
2549
m4/libtool.m4
vendored
File diff suppressed because it is too large
Load Diff
127
m4/ltoptions.m4
vendored
127
m4/ltoptions.m4
vendored
@@ -1,14 +1,14 @@
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
#
|
||||
# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
|
||||
# Foundation, Inc.
|
||||
# Written by Gary V. Vaughan, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 7 ltoptions.m4
|
||||
# serial 8 ltoptions.m4
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
|
||||
@@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION],
|
||||
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
|
||||
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
|
||||
_LT_MANGLE_DEFUN([$1], [$2]),
|
||||
[m4_warning([Unknown $1 option `$2'])])[]dnl
|
||||
[m4_warning([Unknown $1 option '$2'])])[]dnl
|
||||
])
|
||||
|
||||
|
||||
@@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[
|
||||
dnl
|
||||
dnl If no reference was made to various pairs of opposing options, then
|
||||
dnl we run the default mode handler for the pair. For example, if neither
|
||||
dnl `shared' nor `disable-shared' was passed, we enable building of shared
|
||||
dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
|
||||
dnl archives by default:
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
|
||||
[_LT_ENABLE_FAST_INSTALL])
|
||||
[_LT_ENABLE_FAST_INSTALL])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
|
||||
[_LT_WITH_AIX_SONAME([aix])])
|
||||
])
|
||||
])# _LT_SET_OPTIONS
|
||||
|
||||
@@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
|
||||
[_LT_SET_OPTION([LT_INIT], [dlopen])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the `dlopen' option into LT_INIT's first parameter.])
|
||||
put the 'dlopen' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
@@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
|
||||
_LT_SET_OPTION([LT_INIT], [win32-dll])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the `win32-dll' option into LT_INIT's first parameter.])
|
||||
put the 'win32-dll' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
@@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
|
||||
|
||||
# _LT_ENABLE_SHARED([DEFAULT])
|
||||
# ----------------------------
|
||||
# implement the --enable-shared flag, and supports the `shared' and
|
||||
# `disable-shared' LT_INIT options.
|
||||
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||
# implement the --enable-shared flag, and supports the 'shared' and
|
||||
# 'disable-shared' LT_INIT options.
|
||||
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
|
||||
m4_define([_LT_ENABLE_SHARED],
|
||||
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([shared],
|
||||
@@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared],
|
||||
*)
|
||||
enable_shared=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
|
||||
for pkg in $enableval; do
|
||||
IFS="$lt_save_ifs"
|
||||
IFS=$lt_save_ifs
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_shared=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
IFS=$lt_save_ifs
|
||||
;;
|
||||
esac],
|
||||
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
|
||||
@@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
|
||||
|
||||
# _LT_ENABLE_STATIC([DEFAULT])
|
||||
# ----------------------------
|
||||
# implement the --enable-static flag, and support the `static' and
|
||||
# `disable-static' LT_INIT options.
|
||||
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||
# implement the --enable-static flag, and support the 'static' and
|
||||
# 'disable-static' LT_INIT options.
|
||||
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
|
||||
m4_define([_LT_ENABLE_STATIC],
|
||||
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([static],
|
||||
@@ -226,14 +228,14 @@ AC_ARG_ENABLE([static],
|
||||
*)
|
||||
enable_static=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
|
||||
for pkg in $enableval; do
|
||||
IFS="$lt_save_ifs"
|
||||
IFS=$lt_save_ifs
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_static=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
IFS=$lt_save_ifs
|
||||
;;
|
||||
esac],
|
||||
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
|
||||
@@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
|
||||
|
||||
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
|
||||
# ----------------------------------
|
||||
# implement the --enable-fast-install flag, and support the `fast-install'
|
||||
# and `disable-fast-install' LT_INIT options.
|
||||
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||
# implement the --enable-fast-install flag, and support the 'fast-install'
|
||||
# and 'disable-fast-install' LT_INIT options.
|
||||
# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
|
||||
m4_define([_LT_ENABLE_FAST_INSTALL],
|
||||
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([fast-install],
|
||||
@@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install],
|
||||
*)
|
||||
enable_fast_install=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
|
||||
for pkg in $enableval; do
|
||||
IFS="$lt_save_ifs"
|
||||
IFS=$lt_save_ifs
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_fast_install=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
IFS=$lt_save_ifs
|
||||
;;
|
||||
esac],
|
||||
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
|
||||
@@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||
the `fast-install' option into LT_INIT's first parameter.])
|
||||
the 'fast-install' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||
the `disable-fast-install' option into LT_INIT's first parameter.])
|
||||
the 'disable-fast-install' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
@@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
|
||||
|
||||
|
||||
# _LT_WITH_AIX_SONAME([DEFAULT])
|
||||
# ----------------------------------
|
||||
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
|
||||
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
|
||||
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
|
||||
m4_define([_LT_WITH_AIX_SONAME],
|
||||
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
|
||||
shared_archive_member_spec=
|
||||
case $host,$enable_shared in
|
||||
power*-*-aix[[5-9]]*,yes)
|
||||
AC_MSG_CHECKING([which variant of shared library versioning to provide])
|
||||
AC_ARG_WITH([aix-soname],
|
||||
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
|
||||
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
|
||||
[case $withval in
|
||||
aix|svr4|both)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
|
||||
;;
|
||||
esac
|
||||
lt_cv_with_aix_soname=$with_aix_soname],
|
||||
[AC_CACHE_VAL([lt_cv_with_aix_soname],
|
||||
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
|
||||
with_aix_soname=$lt_cv_with_aix_soname])
|
||||
AC_MSG_RESULT([$with_aix_soname])
|
||||
if test aix != "$with_aix_soname"; then
|
||||
# For the AIX way of multilib, we name the shared archive member
|
||||
# based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
|
||||
# and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
|
||||
# Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
|
||||
# the AIX toolchain works better with OBJECT_MODE set (default 32).
|
||||
if test 64 = "${OBJECT_MODE-32}"; then
|
||||
shared_archive_member_spec=shr_64
|
||||
else
|
||||
shared_archive_member_spec=shr
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
with_aix_soname=aix
|
||||
;;
|
||||
esac
|
||||
|
||||
_LT_DECL([], [shared_archive_member_spec], [0],
|
||||
[Shared archive member basename, for filename based shared library versioning on AIX])dnl
|
||||
])# _LT_WITH_AIX_SONAME
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
|
||||
|
||||
|
||||
# _LT_WITH_PIC([MODE])
|
||||
# --------------------
|
||||
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
|
||||
# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
|
||||
# LT_INIT options.
|
||||
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
|
||||
# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
|
||||
m4_define([_LT_WITH_PIC],
|
||||
[AC_ARG_WITH([pic],
|
||||
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
|
||||
@@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC],
|
||||
*)
|
||||
pic_mode=default
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
|
||||
for lt_pkg in $withval; do
|
||||
IFS="$lt_save_ifs"
|
||||
IFS=$lt_save_ifs
|
||||
if test "X$lt_pkg" = "X$lt_p"; then
|
||||
pic_mode=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
IFS=$lt_save_ifs
|
||||
;;
|
||||
esac],
|
||||
[pic_mode=default])
|
||||
|
||||
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
|
||||
[pic_mode=m4_default([$1], [default])])
|
||||
|
||||
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
|
||||
])# _LT_WITH_PIC
|
||||
@@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
|
||||
[_LT_SET_OPTION([LT_INIT], [pic-only])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the `pic-only' option into LT_INIT's first parameter.])
|
||||
put the 'pic-only' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
|
||||
7
m4/ltsugar.m4
vendored
7
m4/ltsugar.m4
vendored
@@ -1,6 +1,7 @@
|
||||
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
|
||||
# Foundation, Inc.
|
||||
# Written by Gary V. Vaughan, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
@@ -33,7 +34,7 @@ m4_define([_lt_join],
|
||||
# ------------
|
||||
# Manipulate m4 lists.
|
||||
# These macros are necessary as long as will still need to support
|
||||
# Autoconf-2.59 which quotes differently.
|
||||
# Autoconf-2.59, which quotes differently.
|
||||
m4_define([lt_car], [[$1]])
|
||||
m4_define([lt_cdr],
|
||||
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
|
||||
@@ -44,7 +45,7 @@ m4_define([lt_unquote], $1)
|
||||
|
||||
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
|
||||
# ------------------------------------------
|
||||
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
|
||||
# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
|
||||
# Note that neither SEPARATOR nor STRING are expanded; they are appended
|
||||
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
|
||||
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
|
||||
|
||||
12
m4/ltversion.m4
vendored
12
m4/ltversion.m4
vendored
@@ -1,6 +1,6 @@
|
||||
# ltversion.m4 -- version numbers -*- Autoconf -*-
|
||||
#
|
||||
# Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
|
||||
# Written by Scott James Remnant, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
@@ -9,15 +9,15 @@
|
||||
|
||||
# @configure_input@
|
||||
|
||||
# serial 3337 ltversion.m4
|
||||
# serial 4179 ltversion.m4
|
||||
# This file is part of GNU Libtool
|
||||
|
||||
m4_define([LT_PACKAGE_VERSION], [2.4.2])
|
||||
m4_define([LT_PACKAGE_REVISION], [1.3337])
|
||||
m4_define([LT_PACKAGE_VERSION], [2.4.6])
|
||||
m4_define([LT_PACKAGE_REVISION], [2.4.6])
|
||||
|
||||
AC_DEFUN([LTVERSION_VERSION],
|
||||
[macro_version='2.4.2'
|
||||
macro_revision='1.3337'
|
||||
[macro_version='2.4.6'
|
||||
macro_revision='2.4.6'
|
||||
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
|
||||
_LT_DECL(, macro_revision, 0)
|
||||
])
|
||||
|
||||
7
m4/lt~obsolete.m4
vendored
7
m4/lt~obsolete.m4
vendored
@@ -1,6 +1,7 @@
|
||||
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
|
||||
# Foundation, Inc.
|
||||
# Written by Scott James Remnant, 2004.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
# These exist entirely to fool aclocal when bootstrapping libtool.
|
||||
#
|
||||
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
|
||||
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
|
||||
# which have later been changed to m4_define as they aren't part of the
|
||||
# exported API, or moved to Autoconf or Automake where they belong.
|
||||
#
|
||||
@@ -25,7 +26,7 @@
|
||||
# included after everything else. This provides aclocal with the
|
||||
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
|
||||
# because those macros already exist, or will be overwritten later.
|
||||
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
|
||||
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
|
||||
#
|
||||
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
|
||||
# Yes, that means every name once taken will need to remain here until
|
||||
|
||||
29
maketgz
29
maketgz
@@ -9,6 +9,11 @@ if [ -z "$version" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "xonly" = "x$2" ]; then
|
||||
echo "Setup version number only!"
|
||||
only=1
|
||||
fi
|
||||
|
||||
libversion="$version"
|
||||
|
||||
major=`echo $libversion |cut -d. -f1 | sed -e "s/[^0-9]//g"`
|
||||
@@ -19,22 +24,36 @@ numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"`
|
||||
|
||||
HEADER=include/libssh2.h
|
||||
|
||||
# requires a date command that knows -u for UTC time zone
|
||||
datestamp=`date -u`
|
||||
if test -z "$only"; then
|
||||
ext=".dist"
|
||||
# when not setting up version numbers locally
|
||||
for a in $HEADER; do
|
||||
cp $a "$a$ext"
|
||||
done
|
||||
HEADER="$HEADER$ext"
|
||||
fi
|
||||
|
||||
# Replace version number in header file:
|
||||
sed -e 's/^#define LIBSSH2_VERSION .*/#define LIBSSH2_VERSION "'$libversion'"/g' \
|
||||
# requires a date command that knows -u for UTC time zone
|
||||
datestamp=`LC_TIME=C date -u`
|
||||
|
||||
# Replace in-place version number in header file:
|
||||
sed -i -e 's/^#define LIBSSH2_VERSION .*/#define LIBSSH2_VERSION "'$libversion'"/g' \
|
||||
-e 's/^#define LIBSSH2_VERSION_NUM .*/#define LIBSSH2_VERSION_NUM 0x'$numeric'/g' \
|
||||
-e 's/^#define LIBSSH2_VERSION_MAJOR .*/#define LIBSSH2_VERSION_MAJOR '$major'/g' \
|
||||
-e 's/^#define LIBSSH2_VERSION_MINOR .*/#define LIBSSH2_VERSION_MINOR '$minor'/g' \
|
||||
-e 's/^#define LIBSSH2_VERSION_PATCH .*/#define LIBSSH2_VERSION_PATCH '$patch'/g' \
|
||||
-e "s/^#define LIBSSH2_TIMESTAMP .*/#define LIBSSH2_TIMESTAMP \"$datestamp\"/g" \
|
||||
$HEADER >$HEADER.dist
|
||||
$HEADER
|
||||
|
||||
echo "libssh2 version $libversion"
|
||||
echo "libssh2 numerical $numeric"
|
||||
echo "datestamp $datestamp"
|
||||
|
||||
if test -n "$only"; then
|
||||
# done!
|
||||
exit;
|
||||
fi
|
||||
|
||||
findprog()
|
||||
{
|
||||
file="$1"
|
||||
|
||||
451
missing
451
missing
@@ -1,11 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
# Common wrapper for a few potentially missing GNU programs.
|
||||
|
||||
scriptversion=2005-06-08.21
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
|
||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -18,9 +17,7 @@ scriptversion=2005-06-08.21
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -28,63 +25,40 @@ scriptversion=2005-06-08.21
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run=:
|
||||
case $1 in
|
||||
|
||||
# In the cases where this matters, `missing' is being run in the
|
||||
# srcdir already.
|
||||
if test -f configure.ac; then
|
||||
configure_ac=configure.ac
|
||||
else
|
||||
configure_ac=configure.in
|
||||
fi
|
||||
--is-lightweight)
|
||||
# Used by our autoconf macros to check whether the available missing
|
||||
# script is modern enough.
|
||||
exit 0
|
||||
;;
|
||||
|
||||
msg="missing on your system"
|
||||
|
||||
case "$1" in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
# Exit code 63 means version mismatch. This often happens
|
||||
# when the user try to use an ancient version of a tool on
|
||||
# a file that requires a minimum version. In this case we
|
||||
# we should proceed has if the program had been absent, or
|
||||
# if --run hadn't been passed.
|
||||
if test $? = 63; then
|
||||
run=:
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
--run)
|
||||
# Back-compat with the calling convention used by older automake.
|
||||
shift
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
|
||||
to PROGRAM being missing or too old.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--run try to run the given command, and emulate it if it fails
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
help2man touch the output file
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
aclocal autoconf autoheader autom4te automake makeinfo
|
||||
bison yacc flex lex help2man
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
|
||||
'g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
@@ -96,265 +70,146 @@ Send bug reports to <bug-automake@gnu.org>."
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
echo 1>&2 "$0: unknown '$1' option"
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program).
|
||||
case "$1" in
|
||||
lex|yacc)
|
||||
# Not GNU programs, they don't have --version.
|
||||
# Run the given program, remember its exit status.
|
||||
"$@"; st=$?
|
||||
|
||||
# If it succeeded, we are done.
|
||||
test $st -eq 0 && exit 0
|
||||
|
||||
# Also exit now if we it failed (or wasn't found), and '--version' was
|
||||
# passed; such an option is passed most likely to detect whether the
|
||||
# program is present and works.
|
||||
case $2 in --version|--help) exit $st;; esac
|
||||
|
||||
# Exit code 63 means version mismatch. This often happens when the user
|
||||
# tries to use an ancient version of a tool on a file that requires a
|
||||
# minimum version.
|
||||
if test $st -eq 63; then
|
||||
msg="probably too old"
|
||||
elif test $st -eq 127; then
|
||||
# Program was missing.
|
||||
msg="missing on your system"
|
||||
else
|
||||
# Program was found and executed, but failed. Give up.
|
||||
exit $st
|
||||
fi
|
||||
|
||||
perl_URL=https://www.perl.org/
|
||||
flex_URL=https://github.com/westes/flex
|
||||
gnu_software_URL=https://www.gnu.org/software
|
||||
|
||||
program_details ()
|
||||
{
|
||||
case $1 in
|
||||
aclocal|automake)
|
||||
echo "The '$1' program is part of the GNU Automake package:"
|
||||
echo "<$gnu_software_URL/automake>"
|
||||
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/autoconf>"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
autoconf|autom4te|autoheader)
|
||||
echo "The '$1' program is part of the GNU Autoconf package:"
|
||||
echo "<$gnu_software_URL/autoconf/>"
|
||||
echo "It also requires GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
give_advice ()
|
||||
{
|
||||
# Normalize program name to check for.
|
||||
normalized_program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
printf '%s\n' "'$1' is $msg."
|
||||
|
||||
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
|
||||
case $normalized_program in
|
||||
autoconf*)
|
||||
echo "You should only need it if you modified 'configure.ac',"
|
||||
echo "or m4 files included by it."
|
||||
program_details 'autoconf'
|
||||
;;
|
||||
autoheader*)
|
||||
echo "You should only need it if you modified 'acconfig.h' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'autoheader'
|
||||
;;
|
||||
automake*)
|
||||
echo "You should only need it if you modified 'Makefile.am' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'automake'
|
||||
;;
|
||||
aclocal*)
|
||||
echo "You should only need it if you modified 'acinclude.m4' or"
|
||||
echo "$configure_deps."
|
||||
program_details 'aclocal'
|
||||
;;
|
||||
autom4te*)
|
||||
echo "You might have modified some maintainer files that require"
|
||||
echo "the 'autom4te' program to be rebuilt."
|
||||
program_details 'autom4te'
|
||||
;;
|
||||
bison*|yacc*)
|
||||
echo "You should only need it if you modified a '.y' file."
|
||||
echo "You may want to install the GNU Bison package:"
|
||||
echo "<$gnu_software_URL/bison/>"
|
||||
;;
|
||||
lex*|flex*)
|
||||
echo "You should only need it if you modified a '.l' file."
|
||||
echo "You may want to install the Fast Lexical Analyzer package:"
|
||||
echo "<$flex_URL>"
|
||||
;;
|
||||
help2man*)
|
||||
echo "You should only need it if you modified a dependency" \
|
||||
"of a man page."
|
||||
echo "You may want to install the GNU Help2man package:"
|
||||
echo "<$gnu_software_URL/help2man/>"
|
||||
;;
|
||||
makeinfo*)
|
||||
echo "You should only need it if you modified a '.texi' file, or"
|
||||
echo "any other file indirectly affecting the aspect of the manual."
|
||||
echo "You might want to install the Texinfo package:"
|
||||
echo "<$gnu_software_URL/texinfo/>"
|
||||
echo "The spurious makeinfo call might also be the consequence of"
|
||||
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
|
||||
echo "want to install GNU make:"
|
||||
echo "<$gnu_software_URL/make/>"
|
||||
;;
|
||||
*)
|
||||
echo "You might have modified some files without having the proper"
|
||||
echo "tools for further handling them. Check the 'README' file, it"
|
||||
echo "often tells you about the needed prerequisites for installing"
|
||||
echo "this package. You may also peek at any GNU archive site, in"
|
||||
echo "case some other package contains this missing '$1' program."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
tar)
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
give_advice "$1" | sed -e '1s/^/WARNING: /' \
|
||||
-e '2,$s/^/ /' >&2
|
||||
|
||||
*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
# Could not run --version or --help. This is probably someone
|
||||
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case "$1" in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case "$f" in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them.
|
||||
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
|
||||
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo "#! /bin/sh"
|
||||
echo "# Created by GNU Automake missing as a replacement of"
|
||||
echo "# $ $@"
|
||||
echo "exit 0"
|
||||
chmod +x $file
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
bison|yacc)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' $msg. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f y.tab.h ]; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if [ ! -f y.tab.c ]; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex|flex)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f lex.yy.c ]; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
\`Help2man' package in order for those modifications to take
|
||||
effect. You can get \`Help2man' from any GNU archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
|
||||
fi
|
||||
if [ -f "$file" ]; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
# The file to touch is that specified with -o ...
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
# ... or it is the one specified with @setfilename ...
|
||||
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
|
||||
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||
fi
|
||||
# If the file does not exist, the user really needs makeinfo;
|
||||
# let's fail without touching anything.
|
||||
test -f $file || exit 1
|
||||
touch $file
|
||||
;;
|
||||
|
||||
tar)
|
||||
shift
|
||||
|
||||
# We have already tried tar in the generic part.
|
||||
# Look for gnutar/gtar before invocation to avoid ugly error
|
||||
# messages.
|
||||
if (gnutar --version > /dev/null 2>&1); then
|
||||
gnutar "$@" && exit 0
|
||||
fi
|
||||
if (gtar --version > /dev/null 2>&1); then
|
||||
gtar "$@" && exit 0
|
||||
fi
|
||||
firstarg="$1"
|
||||
if shift; then
|
||||
case "$firstarg" in
|
||||
*o*)
|
||||
firstarg=`echo "$firstarg" | sed s/o//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
case "$firstarg" in
|
||||
*h*)
|
||||
firstarg=`echo "$firstarg" | sed s/h//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: I can't seem to be able to run \`tar' with the given arguments.
|
||||
You may want to install GNU tar or Free paxutils, or check the
|
||||
command line arguments."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequisites for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
# Propagate the correct exit status (expected to be 127 for a program
|
||||
# not found, 63 for a program that failed due to version mismatch).
|
||||
exit $st
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
||||
@@ -38,7 +38,7 @@ DEVLARC = $(DEVLDIR).zip
|
||||
TARGET = libssh2
|
||||
VERSION = $(LIBSSH2_VERSION)
|
||||
CPRIGHT = Copyright (c) $(LIBSSH2_COPYRIGHT_STR)
|
||||
WWWURL = http://www.libssh2.org/
|
||||
WWWURL = https://www.libssh2.org/
|
||||
DESCR = libssh2 $(LIBSSH2_VERSION_STR) ($(LIBARCH)) - $(WWWURL)
|
||||
MTSAFE = YES
|
||||
STACK = 64000
|
||||
@@ -223,7 +223,7 @@ include ../Makefile.inc
|
||||
OBJECTS := $(patsubst %.c,%.o,$(CSOURCES))
|
||||
ifeq ($(LIBARCH),CLIB)
|
||||
# CLIB lacks of snprint() function - here's a replacement:
|
||||
# http://www.ijs.si/software/snprintf/
|
||||
# https://www.ijs.si/software/snprintf/
|
||||
OBJECTS += snprintf.o
|
||||
vpath %.c $(SNPRINTF)
|
||||
endif
|
||||
@@ -388,7 +388,7 @@ libssh2_config.h: GNUmakefile
|
||||
@echo $(DL)** All your changes will be lost!!$(DL) >> $@
|
||||
@echo $(DL)*/$(DL) >> $@
|
||||
@echo $(DL)#define VERSION "$(LIBSSH2_VERSION_STR)"$(DL) >> $@
|
||||
@echo $(DL)#define PACKAGE_BUGREPORT "http://sourceforge.net/projects/libssh2"$(DL) >> $@
|
||||
@echo $(DL)#define PACKAGE_BUGREPORT "https://github.com/libssh2/libssh2/issues"$(DL) >> $@
|
||||
ifeq ($(LIBARCH),CLIB)
|
||||
@echo $(DL)#define OS "i586-pc-clib-NetWare"$(DL) >> $@
|
||||
@echo $(DL)#define NETDB_USE_INTERNET 1$(DL) >> $@
|
||||
@@ -545,6 +545,7 @@ endif
|
||||
@echo $(DL) libssh2_knownhost_readfile,$(DL) >> $@
|
||||
@echo $(DL) libssh2_knownhost_writefile,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_recv,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_recv2,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_send64,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_send_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_abstract,$(DL) >> $@
|
||||
|
||||
169
os400/README400
Normal file
169
os400/README400
Normal file
@@ -0,0 +1,169 @@
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This is a true OS/400 implementation, not a PASE implementation (for PASE,
|
||||
use AIX implementation).
|
||||
|
||||
It uses ASCII as internal character set. This has been accomplished using the
|
||||
QADRT library and include files, a C and system procedures ASCII wrapper
|
||||
library. See IBM QADRT description for more information.
|
||||
This results in libssh2 being an ASCII library: any function string
|
||||
argument is taken/returned in ASCII and a C/C++ calling program built around
|
||||
QADRT may use libssh2 functions as on any other platform.
|
||||
QADRT does not define ASCII wrappers for all C/system procedures: an
|
||||
additional module (os400sys.c) define some more of them, that are used by
|
||||
libssh2 and that QADRT left out.
|
||||
Since standard library entry points expect and return ASCII character strings,
|
||||
additional procedures are provided for string transcoding (see below). No
|
||||
wrappers to standard procedures are provided: however, nested calls to
|
||||
transcoding procedures may be used.
|
||||
|
||||
Crypto API is provided by the IBM QC3 API library. It supports RSA, but not DSA.
|
||||
|
||||
|
||||
Standard compilation environment does support neither autotools nor make;
|
||||
in fact, very few common utilities are available. As a consequence, the
|
||||
libssh2_config.h has been coded manually and the compilation scripts are
|
||||
a set of shell scripts stored in subdirectory os400.
|
||||
|
||||
The test environment is currently not supported on OS/400.
|
||||
|
||||
|
||||
|
||||
Compiling on OS/400:
|
||||
|
||||
These instructions target people who knows about OS/400, compiling, IFS and
|
||||
archive extraction. Do not ask questions about these subjects if you're not
|
||||
familiar with.
|
||||
|
||||
_ As a prerequisite, QADRT development environment must be installed.
|
||||
_ Install the libssh2 sources directory in IFS.
|
||||
_ Enter shell (QSH)
|
||||
_ Change current directory to the libssh2 sources installation directory
|
||||
_ Change current directory to os400
|
||||
_ Edit file iniscript.sh. You may want to change tunable configuration
|
||||
parameters, like debug info generation, optimisation level, listing option,
|
||||
target library, zlib availability and location, etc.
|
||||
_ Copy any file in the current directory to makelog (i.e.:
|
||||
cp initscript.sh makelog): this is intended to create the makelog file with
|
||||
an ASCII CCSID!
|
||||
_ Enter the command "sh make.sh > makelog 2>&1'
|
||||
_ Examine the makelog file to check for compilation errors.
|
||||
|
||||
Leaving file initscript.sh unchanged, this will produce the following OS/400
|
||||
objects:
|
||||
_ Library LIBSSH2. All other objects will be stored in this library.
|
||||
_ Modules for all libssh2 units.
|
||||
_ Binding directory LIBSSH2_A, to be used at calling program link time for
|
||||
statically binding the modules (specify BNDSRVPGM(QADRTTS) when creating a
|
||||
program using LIBSSH2_A. Also give access to the zlib BNDDIR/SRVPGM if
|
||||
libssh2 is compiled with zlib).
|
||||
_ Service program LIBSSH2.<soname>, where <soname> is extracted from the
|
||||
src/Makefile.am VERSION variable. To be used at calling program run-time
|
||||
when this program has dynamically bound libssh2 at link time.
|
||||
_ Binding directory LIBSSH2. To be used to dynamically bind libssh2 when
|
||||
linking a calling program.
|
||||
_ Source file H. It contains all the include members needed to compile a C/C++
|
||||
module using libssh2.
|
||||
_ LIBSSH2, SSH2_PKEY, SSH2_SFTP members in file H. These are the C/C++ header
|
||||
files. Original fames have been mangled to fit member name allowed syntax.
|
||||
_ Source file LIBSSH2RPG. It contains all the ILE/RPG /INCLUDE members
|
||||
needed to compile an ILE/RPG program calling libssh2 procedures.
|
||||
_ LIBSSH2, SSH2_PKEY, SSH2_SFTP members in file LIBSSH2RPG. These are
|
||||
ILE/RPG translations of the corresponding C header files.
|
||||
|
||||
|
||||
|
||||
Special programming consideration:
|
||||
|
||||
QADRT being used, the following points must be considered:
|
||||
_ If static binding is used, service program QADRTTS must be linked too.
|
||||
_ Likewise, if libssh2 has been compiled with zlib support, access to the
|
||||
zlib objects must be provided at link time.
|
||||
_ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If
|
||||
another EBCDIC CCSID is required, it must be set via a locale through a call
|
||||
to setlocale_a (QADRT's setlocale() ASCII wrapper) with category LC_ALL or
|
||||
LC_CTYPE, or by setting environment variable QADRT_ENV_LOCALE to the locale
|
||||
object path before executing the program.
|
||||
_ Do not use original source include files unless you know what you are doing.
|
||||
Use the installed members instead (in /QSYS.LIB/LIBSSH2.LIB/H.FILE).
|
||||
|
||||
|
||||
|
||||
String transcoding support:
|
||||
|
||||
To help passing arbitrarily encoded string arguments and/or receiving string
|
||||
values from/to the libssh2 API, three non-standard additional procedures are
|
||||
provided. They use a session pointer and a "string cache" pointer.
|
||||
Each time a string is transcoded, it is cached in the given cache. It is
|
||||
the responsibility of the caller to release the cache when its associted strings
|
||||
are no longer needed. These procedures and the string cache type are defined
|
||||
in a new libssh2_ccsid.h header file.
|
||||
To create a string cache, use:
|
||||
|
||||
#include <libssh2_ccsid.h>
|
||||
libssh2_string_cache * cache = NULL;
|
||||
|
||||
To release all strings in a cache, call:
|
||||
|
||||
libssh2_release_string_cache(session, &cache);
|
||||
|
||||
The transcoding procedures are:
|
||||
|
||||
char * libssh2_from_ccsid(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache,
|
||||
unsigned short ccsid,
|
||||
const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
char * libssh2_to_ccsid(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache,
|
||||
unsigned short ccsid,
|
||||
const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
|
||||
where:
|
||||
session is a libssh2 session used for memory allocation.
|
||||
cache is the address of a string cache.
|
||||
ccsid is the external (i.e.: non libssh2) coded character set id.
|
||||
65535 means no conversion and 0 means the current job's CCSID.
|
||||
string is the string to convert.
|
||||
inlen is the source string length in bytes: set to -1 if
|
||||
null-terminated.
|
||||
outlen if not NULL, is the address of a variable that will receive
|
||||
the transcoded string length upon return.
|
||||
|
||||
libssh2_from_ccsid() transcodes the string from the given CCSID to libssh2
|
||||
internal encoding (UTF-8). It is intended to be used to convert API input
|
||||
parameters.
|
||||
libssh2_to_ccsid() transcodes the string from libssh2 internal encoding
|
||||
(UTF-8) to the given CCSID. This has been implemented to get standard API
|
||||
string results in a program's native encoding.
|
||||
|
||||
Both these functions return a pointer to the null-terminated converted string,
|
||||
or NULL if an error occurred. In addition, the variable pointed by outlen
|
||||
receives the effective byte length of the (cached) translated string, or -1
|
||||
in case of error.
|
||||
|
||||
|
||||
|
||||
ILE/RPG support:
|
||||
|
||||
Since 95% of the OS/400 programmers use ILE/RPG exclusively, a definition
|
||||
/INCLUDE member is provided for this language. To include libssh2
|
||||
definitions in an ILE/RPG module, line
|
||||
|
||||
h bnddir('LIBSSH2/LIBSSH2')
|
||||
|
||||
must figure in the program header, and line
|
||||
|
||||
d/include libssh2/libssh2rpg,libssh2
|
||||
|
||||
in the global data section of the module's source code.
|
||||
If required, members ssh2_sftp, ssh2_pkey and ssh2_ccsid may also be included.
|
||||
|
||||
For IFS source compilations, include members are located in directory
|
||||
/libssh2/include/libssh2rpg and have their original names retained.
|
||||
|
||||
ILE/RPG lacks a serious macro preprocessor, thus C macros requiring this
|
||||
feature have not been translated. However, function-like C macros have been
|
||||
implemented as procedures and therefore supported in ILE/RPG.
|
||||
252
os400/ccsid.c
Normal file
252
os400/ccsid.c
Normal file
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Character encoding wrappers. */
|
||||
|
||||
#include "libssh2_priv.h"
|
||||
#include "libssh2_ccsid.h"
|
||||
|
||||
#include <qtqiconv.h>
|
||||
#include <iconv.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
#define CCSID_UTF8 1208
|
||||
#define CCSID_UTF16BE 13488
|
||||
#define STRING_GRANULE 256
|
||||
#define MAX_CHAR_SIZE 4
|
||||
|
||||
#define OFFSET_OF(t, f) ((size_t) ((char *) &((t *) 0)->f - (char *) 0))
|
||||
|
||||
|
||||
struct _libssh2_string_cache {
|
||||
libssh2_string_cache * next;
|
||||
char string[1];
|
||||
};
|
||||
|
||||
|
||||
static const QtqCode_T utf8code = { CCSID_UTF8 };
|
||||
|
||||
|
||||
static ssize_t
|
||||
terminator_size(unsigned short ccsid)
|
||||
{
|
||||
QtqCode_T outcode;
|
||||
iconv_t cd;
|
||||
char *inp;
|
||||
char *outp;
|
||||
size_t ilen;
|
||||
size_t olen;
|
||||
char buf[MAX_CHAR_SIZE];
|
||||
|
||||
/* Return the null-terminator size for the given CCSID. */
|
||||
|
||||
/* Fast check usual CCSIDs. */
|
||||
switch (ccsid) {
|
||||
case CCSID_UTF8:
|
||||
case 0: /* Job CCSID is SBCS EBCDIC. */
|
||||
return 1;
|
||||
case CCSID_UTF16BE:
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Convert an UTF-8 NUL to the target CCSID: use the converted size as
|
||||
result. */
|
||||
memset((void *) &outcode, 0, sizeof outcode);
|
||||
outcode.CCSID = ccsid;
|
||||
cd = QtqIconvOpen(&outcode, (QtqCode_T *) &utf8code);
|
||||
if (cd.return_value == -1)
|
||||
return -1;
|
||||
inp = "";
|
||||
ilen = 1;
|
||||
outp = buf;
|
||||
olen = sizeof buf;
|
||||
iconv(cd, &inp, &ilen, &outp, &olen);
|
||||
iconv_close(cd);
|
||||
olen = sizeof buf - olen;
|
||||
return olen? olen: -1;
|
||||
}
|
||||
|
||||
static char *
|
||||
convert_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short outccsid, unsigned short inccsid,
|
||||
const char *instring, ssize_t inlen, size_t *outlen)
|
||||
{
|
||||
char *inp;
|
||||
char *outp;
|
||||
size_t olen;
|
||||
size_t ilen;
|
||||
size_t buflen;
|
||||
size_t curlen;
|
||||
ssize_t termsize;
|
||||
int i;
|
||||
char *dst;
|
||||
libssh2_string_cache *outstring;
|
||||
QtqCode_T incode;
|
||||
QtqCode_T outcode;
|
||||
iconv_t cd;
|
||||
|
||||
if (!instring) {
|
||||
if (outlen)
|
||||
*outlen = 0;
|
||||
return NULL;
|
||||
}
|
||||
if (outlen)
|
||||
*outlen = -1;
|
||||
if (!session || !cache)
|
||||
return NULL;
|
||||
|
||||
/* Get terminator size. */
|
||||
termsize = terminator_size(outccsid);
|
||||
if (termsize < 0)
|
||||
return NULL;
|
||||
|
||||
/* Prepare conversion parameters. */
|
||||
memset((void *) &incode, 0, sizeof incode);
|
||||
memset((void *) &outcode, 0, sizeof outcode);
|
||||
incode.CCSID = inccsid;
|
||||
outcode.CCSID = outccsid;
|
||||
curlen = OFFSET_OF(libssh2_string_cache, string);
|
||||
inp = (char *) instring;
|
||||
ilen = inlen;
|
||||
buflen = inlen + curlen;
|
||||
if (inlen < 0) {
|
||||
incode.length_option = 1;
|
||||
buflen = STRING_GRANULE;
|
||||
ilen = 0;
|
||||
}
|
||||
|
||||
/* Allocate output string buffer and open conversion descriptor. */
|
||||
dst = LIBSSH2_ALLOC(session, buflen + termsize);
|
||||
if (!dst)
|
||||
return NULL;
|
||||
cd = QtqIconvOpen(&outcode, &incode);
|
||||
if (cd.return_value == -1) {
|
||||
LIBSSH2_FREE(session, (char *) dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Convert string. */
|
||||
for (;;) {
|
||||
outp = dst + curlen;
|
||||
olen = buflen - curlen;
|
||||
i = iconv(cd, &inp, &ilen, &outp, &olen);
|
||||
if (inlen < 0 && olen == buflen - curlen) {
|
||||
/* Special case: converted 0-length (sub)strings do not store the
|
||||
terminator. */
|
||||
if (termsize) {
|
||||
memset(outp, 0, termsize);
|
||||
olen -= termsize;
|
||||
}
|
||||
}
|
||||
curlen = buflen - olen;
|
||||
if (i >= 0 || errno != E2BIG)
|
||||
break;
|
||||
/* Must expand buffer. */
|
||||
buflen += STRING_GRANULE;
|
||||
outp = LIBSSH2_REALLOC(session, dst, buflen + termsize);
|
||||
if (!outp)
|
||||
break;
|
||||
dst = outp;
|
||||
}
|
||||
|
||||
iconv_close(cd);
|
||||
|
||||
/* Check for error. */
|
||||
if (i < 0 || !outp) {
|
||||
LIBSSH2_FREE(session, dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Process terminator. */
|
||||
if (inlen < 0)
|
||||
curlen -= termsize;
|
||||
else if (termsize)
|
||||
memset(dst + curlen, 0, termsize);
|
||||
|
||||
/* Shorten buffer if possible. */
|
||||
if (curlen < buflen)
|
||||
dst = LIBSSH2_REALLOC(session, dst, curlen + termsize);
|
||||
|
||||
/* Link to cache. */
|
||||
outstring = (libssh2_string_cache *) dst;
|
||||
outstring->next = *cache;
|
||||
*cache = outstring;
|
||||
|
||||
/* Return length if required. */
|
||||
if (outlen)
|
||||
*outlen = curlen - OFFSET_OF(libssh2_string_cache, string);
|
||||
|
||||
return outstring->string;
|
||||
}
|
||||
|
||||
LIBSSH2_API char *
|
||||
libssh2_from_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen)
|
||||
{
|
||||
return convert_ccsid(session, cache,
|
||||
CCSID_UTF8, ccsid, string, inlen, outlen);
|
||||
}
|
||||
|
||||
LIBSSH2_API char *
|
||||
libssh2_to_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen)
|
||||
{
|
||||
return convert_ccsid(session, cache,
|
||||
ccsid, CCSID_UTF8, string, inlen, outlen);
|
||||
}
|
||||
|
||||
LIBSSH2_API void
|
||||
libssh2_release_string_cache(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache)
|
||||
{
|
||||
libssh2_string_cache *p;
|
||||
|
||||
if (session && cache)
|
||||
while ((p = *cache)) {
|
||||
*cache = p->next;
|
||||
LIBSSH2_FREE(session, (char *) p);
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
50
os400/include/alloca.h
Normal file
50
os400/include/alloca.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBSSH2_ALLOCA_H
|
||||
#define LIBSSH2_ALLOCA_H
|
||||
|
||||
/* alloca() emulation. */
|
||||
|
||||
#include <modasa.mih>
|
||||
|
||||
#define alloca(n) _MODASA(n)
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
72
os400/include/stdio.h
Normal file
72
os400/include/stdio.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBSSH2_STDIO_H
|
||||
#define LIBSSH2_STDIO_H
|
||||
|
||||
/*
|
||||
* <stdio.h> wrapper.
|
||||
* Its goal is to redefine snprintf/vsnprintf which are not supported by QADRT.
|
||||
*/
|
||||
|
||||
#include <qadrt.h>
|
||||
|
||||
#if __ILEC400_TGTVRM__ >= 710
|
||||
# include_next <stdio.h>
|
||||
#elif __ILEC400_TGTVRM__ >= 510
|
||||
# ifndef __SRCSTMF__
|
||||
# include <QADRT/h/stdio>
|
||||
# else
|
||||
# include </QIBM/ProdData/qadrt/include/stdio.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern int _libssh2_os400_vsnprintf(char *dst, size_t len,
|
||||
const char *fmt, va_list args);
|
||||
extern int _libssh2_os400_snprintf(char *dst, size_t len,
|
||||
const char *fmt, ...);
|
||||
|
||||
#ifndef LIBSSH2_DISABLE_QADRT_EXT
|
||||
# define vsnprintf(dst, len, fmt, args) \
|
||||
_libssh2_os400_vsnprintf((dst), (len), (fmt), (args))
|
||||
# define snprintf _libssh2_os400_snprintf
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
75
os400/include/sys/socket.h
Normal file
75
os400/include/sys/socket.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBSSH2_SYS_SOCKET_H
|
||||
#define LIBSSH2_SYS_SOCKET_H
|
||||
|
||||
/*
|
||||
* <sys/socket.h> wrapper.
|
||||
* Redefines connect().
|
||||
*/
|
||||
|
||||
#include <qadrt.h>
|
||||
|
||||
#ifndef _QADRT_LT
|
||||
# define _QADRT_LT <
|
||||
#endif
|
||||
#ifndef _QADRT_GT
|
||||
# define _QADRT_GT >
|
||||
#endif
|
||||
|
||||
#ifdef QADRT_SYSINC
|
||||
# include _QADRT_LT QADRT_SYSINC/sys/socket.h _QADRT_GT
|
||||
#elif __ILEC400_TGTVRM__ >= 710
|
||||
# include_next <sys/socket.h>
|
||||
#elif !defined(__SRCSTMF__)
|
||||
# include <QSYSINC/sys/socket>
|
||||
#else
|
||||
# include </QIBM/include/sys/socket.h>
|
||||
#endif
|
||||
|
||||
extern int _libssh2_os400_connect(int sd,
|
||||
struct sockaddr * destaddr, int addrlen);
|
||||
|
||||
#ifndef LIBSSH2_DISABLE_QADRT_EXT
|
||||
#define connect(sd, addr, len) _libssh2_os400_connect((sd), (addr), (len))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
||||
243
os400/initscript.sh
Normal file
243
os400/initscript.sh
Normal file
@@ -0,0 +1,243 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
setenv()
|
||||
|
||||
{
|
||||
# Define and export.
|
||||
|
||||
eval ${1}="${2}"
|
||||
export ${1}
|
||||
}
|
||||
|
||||
|
||||
case "${SCRIPTDIR}" in
|
||||
/*) ;;
|
||||
*) SCRIPTDIR="`pwd`/${SCRIPTDIR}"
|
||||
esac
|
||||
|
||||
while true
|
||||
do case "${SCRIPTDIR}" in
|
||||
*/.) SCRIPTDIR="${SCRIPTDIR%/.}";;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
# The script directory is supposed to be in $TOPDIR/os400.
|
||||
|
||||
TOPDIR=`dirname "${SCRIPTDIR}"`
|
||||
export SCRIPTDIR TOPDIR
|
||||
|
||||
# Extract the SONAME from the library makefile.
|
||||
|
||||
SONAME=`sed -e '/^VERSION=/!d' -e 's/^.* \([0-9]*\):.*$/\1/' -e 'q' \
|
||||
< "${TOPDIR}/src/Makefile.am"`
|
||||
export SONAME
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Tunable configuration parameters.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
setenv TARGETLIB 'LIBSSH2' # Target OS/400 program library.
|
||||
setenv STATBNDDIR 'LIBSSH2_A' # Static binding directory.
|
||||
setenv DYNBNDDIR 'LIBSSH2' # Dynamic binding directory.
|
||||
setenv SRVPGM "LIBSSH2.${SONAME}" # Service program.
|
||||
setenv TGTCCSID '500' # Target CCSID of objects.
|
||||
setenv DEBUG '*ALL' # Debug level.
|
||||
setenv OPTIMIZE '10' # Optimisation level
|
||||
setenv OUTPUT '*NONE' # Compilation output option.
|
||||
setenv TGTRLS 'V6R1M0' # Target OS release.
|
||||
setenv IFSDIR '/libssh2' # Installation IFS directory.
|
||||
|
||||
# Define ZLIB availability and locations.
|
||||
|
||||
setenv WITH_ZLIB 0 # Define to 1 to enable.
|
||||
setenv ZLIB_INCLUDE '/zlib/include' # ZLIB include IFS directory.
|
||||
setenv ZLIB_LIB 'ZLIB' # ZLIB library.
|
||||
setenv ZLIB_BNDDIR 'ZLIB_A' # ZLIB binding directory.
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
# Need to get the version definitions.
|
||||
|
||||
LIBSSH2_VERSION=`grep '^#define *LIBSSH2_VERSION ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/.*"\(.*\)".*/\1/'`
|
||||
LIBSSH2_VERSION_MAJOR=`grep '^#define *LIBSSH2_VERSION_MAJOR ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_MAJOR *\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_VERSION_MINOR=`grep '^#define *LIBSSH2_VERSION_MINOR ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_MINOR *\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_VERSION_PATCH=`grep '^#define *LIBSSH2_VERSION_PATCH ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_PATCH *\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_VERSION_NUM=`grep '^#define *LIBSSH2_VERSION_NUM ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_NUM *0x\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_TIMESTAMP=`grep '^#define *LIBSSH2_TIMESTAMP ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/.*"\(.*\)".*/\1/'`
|
||||
export LIBSSH2_VERSION
|
||||
export LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH
|
||||
export LIBSSH2_VERSION_NUM LIBSSH2_TIMESTAMP
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# OS/400 specific definitions.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Procedures.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# action_needed dest [src]
|
||||
#
|
||||
# dest is an object to build
|
||||
# if specified, src is an object on which dest depends.
|
||||
#
|
||||
# exit 0 (succeeds) if some action has to be taken, else 1.
|
||||
|
||||
action_needed()
|
||||
|
||||
{
|
||||
[ ! -e "${1}" ] && return 0
|
||||
[ "${2}" ] || return 1
|
||||
[ "${1}" -ot "${2}" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
# canonicalize_path path
|
||||
#
|
||||
# Return canonicalized path as:
|
||||
# - Absolute
|
||||
# - No . or .. component.
|
||||
|
||||
canonicalize_path()
|
||||
|
||||
{
|
||||
if expr "${1}" : '^/' > /dev/null
|
||||
then P="${1}"
|
||||
else P="`pwd`/${1}"
|
||||
fi
|
||||
|
||||
R=
|
||||
IFSSAVE="${IFS}"
|
||||
IFS="/"
|
||||
|
||||
for C in ${P}
|
||||
do IFS="${IFSSAVE}"
|
||||
case "${C}" in
|
||||
.) ;;
|
||||
..) R=`expr "${R}" : '^\(.*/\)..*'`
|
||||
;;
|
||||
?*) R="${R}${C}/"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
IFS="${IFSSAVE}"
|
||||
echo "/`expr "${R}" : '^\(.*\)/'`"
|
||||
}
|
||||
|
||||
|
||||
# make_module module_name source_name [additional_definitions]
|
||||
#
|
||||
# Compile source name into ASCII module if needed.
|
||||
# As side effect, append the module name to variable MODULES.
|
||||
# Set LINK to "YES" if the module has been compiled.
|
||||
|
||||
make_module()
|
||||
|
||||
{
|
||||
MODULES="${MODULES} ${1}"
|
||||
MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
|
||||
action_needed "${MODIFSNAME}" "${2}" || return 0;
|
||||
SRCDIR=`dirname \`canonicalize_path "${2}"\``
|
||||
|
||||
# #pragma convert has to be in the source file itself, i.e.
|
||||
# putting it in an include file makes it only active
|
||||
# for that include file.
|
||||
# Thus we build a temporary file with the pragma prepended to
|
||||
# the source file and we compile that temporary file.
|
||||
|
||||
echo "#line 1 \"${2}\"" > __tmpsrcf.c
|
||||
echo "#pragma convert(819)" >> __tmpsrcf.c
|
||||
echo "#line 1" >> __tmpsrcf.c
|
||||
cat "${2}" >> __tmpsrcf.c
|
||||
CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
|
||||
# CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
|
||||
CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
|
||||
CMD="${CMD} LOCALETYPE(*LOCALE) FLAG(10)"
|
||||
CMD="${CMD} INCDIR('${TOPDIR}/os400/include'"
|
||||
CMD="${CMD} '/QIBM/ProdData/qadrt/include' '${TOPDIR}/include'"
|
||||
CMD="${CMD} '${TOPDIR}/os400' '${SRCDIR}'"
|
||||
|
||||
if [ "${WITH_ZLIB}" != "0" ]
|
||||
then CMD="${CMD} '${ZLIB_INCLUDE}'"
|
||||
fi
|
||||
|
||||
CMD="${CMD} ${INCLUDES})"
|
||||
CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
|
||||
CMD="${CMD} OUTPUT(${OUTPUT})"
|
||||
CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
|
||||
CMD="${CMD} DBGVIEW(${DEBUG})"
|
||||
|
||||
DEFINES="${3}"
|
||||
|
||||
if [ "${WITH_ZLIB}" != "0" ]
|
||||
then DEFINES="${DEFINES} HAVE_LIBZ LIBSSH2_HAVE_ZLIB"
|
||||
fi
|
||||
|
||||
if [ "${DEFINES}" ]
|
||||
then CMD="${CMD} DEFINE(${DEFINES})"
|
||||
fi
|
||||
|
||||
system "${CMD}"
|
||||
rm -f __tmpsrcf.c
|
||||
LINK=YES
|
||||
}
|
||||
|
||||
|
||||
# Determine DB2 object name from IFS name.
|
||||
|
||||
db2_name()
|
||||
|
||||
{
|
||||
if [ "${2}" = 'nomangle' ]
|
||||
then basename "${1}" |
|
||||
tr 'a-z-' 'A-Z_' |
|
||||
sed -e 's/\..*//;s/^\(.\).*\(.........\)$/\1\2/'
|
||||
else basename "${1}" |
|
||||
tr 'a-z-' 'A-Z_' |
|
||||
sed -e 's/\..*//;s/^LIBSSH2_/SSH2_/' \
|
||||
-e 's/^\(.\).*\(.........\)$/\1\2/' \
|
||||
-e 's/^SPUBLICKEY$/SSH2_PKEY/'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Copy stream replacing version info.
|
||||
|
||||
versioned_copy()
|
||||
|
||||
{
|
||||
sed -e "s/@LIBSSH2_VERSION@/${LIBSSH2_VERSION}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_MAJOR@/${LIBSSH2_VERSION_MAJOR}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_MINOR@/${LIBSSH2_VERSION_MINOR}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_PATCH@/${LIBSSH2_VERSION_PATCH}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_NUM@/${LIBSSH2_VERSION_NUM}/g" \
|
||||
-e "s/@LIBSSH2_TIMESTAMP@/${LIBSSH2_TIMESTAMP}/g"
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user