From 80045cdbb984a760cbc33257031f18e8f9f4e6f6 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 13:49:37 +0100 Subject: [PATCH 01/17] update libssh to 0.9.3 --- depends/common/libssh/01-removelegacy.patch | 3 +- depends/common/libssh/02-build-static.patch | 18 -------- .../libssh/{03-md5.patch => 02-md5.patch} | 15 +++--- ...otector.patch => 03-stack-protector.patch} | 2 +- .../{05-android.patch => 04-android.patch} | 8 ++-- .../{06-windows.patch => 05-windows.patch} | 7 +-- ...ndowsstore.patch => 06-windowsstore.patch} | 36 ++++----------- ...-openssl.patch => 07-static-openssl.patch} | 46 ++++++++++++++++++- .../{09-werror.patch => 08-werror.patch} | 5 +- .../libssh/{10-tvos.patch => 09-tvos.patch} | 9 ++-- depends/common/libssh/flags.txt | 2 +- depends/common/libssh/libssh.sha256 | 2 +- depends/common/libssh/libssh.txt | 2 +- 13 files changed, 82 insertions(+), 73 deletions(-) delete mode 100644 depends/common/libssh/02-build-static.patch rename depends/common/libssh/{03-md5.patch => 02-md5.patch} (72%) rename depends/common/libssh/{04-stack-protector.patch => 03-stack-protector.patch} (97%) rename depends/common/libssh/{05-android.patch => 04-android.patch} (76%) rename depends/common/libssh/{06-windows.patch => 05-windows.patch} (89%) rename depends/common/libssh/{07-windowsstore.patch => 06-windowsstore.patch} (69%) rename depends/common/libssh/{08-static-openssl.patch => 07-static-openssl.patch} (56%) rename depends/common/libssh/{09-werror.patch => 08-werror.patch} (86%) rename depends/common/libssh/{10-tvos.patch => 09-tvos.patch} (88%) diff --git a/depends/common/libssh/01-removelegacy.patch b/depends/common/libssh/01-removelegacy.patch index bdec257..d6aa95f 100644 --- a/depends/common/libssh/01-removelegacy.patch +++ b/depends/common/libssh/01-removelegacy.patch @@ -1,6 +1,6 @@ --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt -@@ -134,7 +134,6 @@ +@@ -114,7 +114,6 @@ set(libssh_SRCS kex.c known_hosts.c knownhosts.c @@ -8,3 +8,4 @@ log.c match.c messages.c + diff --git a/depends/common/libssh/02-build-static.patch b/depends/common/libssh/02-build-static.patch deleted file mode 100644 index 0536dee..0000000 --- a/depends/common/libssh/02-build-static.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -312,6 +312,7 @@ - ) - endif (WITH_SYMBOL_VERSIONING AND HAVE_LD_VERSION_SCRIPT AND ABIMAP_FOUND) - -+if(OFF) - add_library(${LIBSSH_SHARED_LIBRARY} SHARED ${libssh_SRCS}) - target_compile_options(${LIBSSH_SHARED_LIBRARY} - PRIVATE -@@ -361,6 +362,7 @@ - ARCHIVE DESTINATION ${LIB_INSTALL_DIR} - COMPONENT libraries - ) -+endif() - - if (BUILD_STATIC_LIB) - add_library(${LIBSSH_STATIC_LIBRARY} STATIC ${libssh_SRCS}) diff --git a/depends/common/libssh/03-md5.patch b/depends/common/libssh/02-md5.patch similarity index 72% rename from depends/common/libssh/03-md5.patch rename to depends/common/libssh/02-md5.patch index d228b0a..7c1d3e3 100644 --- a/depends/common/libssh/03-md5.patch +++ b/depends/common/libssh/02-md5.patch @@ -1,6 +1,6 @@ --- a/include/libssh/wrapper.h +++ b/include/libssh/wrapper.h -@@ -74,7 +74,7 @@ +@@ -66,7 +66,7 @@ struct ssh_cipher_struct; struct ssh_crypto_struct; typedef struct ssh_mac_ctx_struct *ssh_mac_ctx; @@ -11,7 +11,7 @@ --- a/src/libcrypto.c +++ b/src/libcrypto.c -@@ -316,7 +316,7 @@ +@@ -316,7 +316,7 @@ void sha512(const unsigned char *digest, int len, unsigned char *hash) } } @@ -22,7 +22,7 @@ MD5CTX c = EVP_MD_CTX_create(); --- a/src/libgcrypt.c +++ b/src/libgcrypt.c -@@ -198,7 +198,7 @@ +@@ -198,7 +198,7 @@ void sha512(const unsigned char *digest, int len, unsigned char *hash) { gcry_md_hash_buffer(GCRY_MD_SHA512, hash, digest, len); } @@ -33,7 +33,7 @@ --- a/src/libmbedcrypto.c +++ b/src/libmbedcrypto.c -@@ -338,7 +338,7 @@ +@@ -338,7 +338,7 @@ void sha512(const unsigned char *digest, int len, unsigned char *hash) } } @@ -44,7 +44,7 @@ int rc; --- a/src/pki_gcrypt.c +++ b/src/pki_gcrypt.c -@@ -256,7 +256,7 @@ +@@ -256,7 +256,7 @@ static int passphrase_to_key(char *data, unsigned int datalen, unsigned int md_not_empty; for (j = 0, md_not_empty = 0; j < keylen; ) { @@ -55,7 +55,7 @@ } --- a/src/session.c +++ b/src/session.c -@@ -987,7 +987,7 @@ +@@ -1003,7 +1003,7 @@ int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash) return SSH_ERROR; } @@ -64,7 +64,7 @@ if (ctx == NULL) { SAFE_FREE(h); return SSH_ERROR; -@@ -1177,7 +1177,7 @@ +@@ -1193,7 +1193,7 @@ int ssh_get_publickey_hash(const ssh_key key, goto out; } @@ -73,3 +73,4 @@ if (ctx == NULL) { free(h); rc = -1; + diff --git a/depends/common/libssh/04-stack-protector.patch b/depends/common/libssh/03-stack-protector.patch similarity index 97% rename from depends/common/libssh/04-stack-protector.patch rename to depends/common/libssh/03-stack-protector.patch index 8723e3a..695b7de 100644 --- a/depends/common/libssh/04-stack-protector.patch +++ b/depends/common/libssh/03-stack-protector.patch @@ -1,6 +1,6 @@ --- a/CompilerChecks.cmake +++ b/CompilerChecks.cmake -@@ -66,20 +66,20 @@ +@@ -67,20 +67,20 @@ if (UNIX) endif() endif() diff --git a/depends/common/libssh/05-android.patch b/depends/common/libssh/04-android.patch similarity index 76% rename from depends/common/libssh/05-android.patch rename to depends/common/libssh/04-android.patch index c93fdd5..cf23c87 100644 --- a/depends/common/libssh/05-android.patch +++ b/depends/common/libssh/04-android.patch @@ -1,6 +1,6 @@ --- a/src/misc.c +++ b/src/misc.c -@@ -215,6 +215,9 @@ +@@ -240,6 +240,9 @@ int ssh_is_ipaddr(const char *str) { char *ssh_get_user_home_dir(void) { @@ -10,7 +10,7 @@ char *szPath = NULL; struct passwd pwd; struct passwd *pwdbuf = NULL; -@@ -235,6 +238,7 @@ +@@ -260,6 +263,7 @@ char *ssh_get_user_home_dir(void) szPath = strdup(pwd.pw_dir); return szPath; @@ -18,7 +18,7 @@ } /* we have read access on file */ -@@ -249,6 +253,17 @@ +@@ -299,6 +303,17 @@ int ssh_dir_writeable(const char *path) char *ssh_get_local_username(void) { @@ -36,7 +36,7 @@ struct passwd pwd; struct passwd *pwdbuf = NULL; char buf[NSS_BUFLEN_PASSWD]; -@@ -262,6 +277,7 @@ +@@ -312,6 +327,7 @@ char *ssh_get_local_username(void) name = strdup(pwd.pw_name); diff --git a/depends/common/libssh/06-windows.patch b/depends/common/libssh/05-windows.patch similarity index 89% rename from depends/common/libssh/06-windows.patch rename to depends/common/libssh/05-windows.patch index 5913a34..0d3e9fb 100644 --- a/depends/common/libssh/06-windows.patch +++ b/depends/common/libssh/05-windows.patch @@ -1,6 +1,6 @@ --- a/include/libssh/sftp.h +++ b/include/libssh/sftp.h -@@ -57,7 +57,7 @@ +@@ -57,7 +57,7 @@ extern "C" { # ifndef _SSIZE_T_DEFINED # undef ssize_t # include @@ -11,8 +11,8 @@ --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt -@@ -372,7 +372,7 @@ - -D_GNU_SOURCE) +@@ -384,7 +384,7 @@ if (BUILD_STATIC_LIB) + add_library(ssh::static ALIAS ssh-static) if (MSVC) - set(OUTPUT_SUFFIX static) @@ -48,3 +48,4 @@ #include #include #if _MSC_VER >= 1400 + diff --git a/depends/common/libssh/07-windowsstore.patch b/depends/common/libssh/06-windowsstore.patch similarity index 69% rename from depends/common/libssh/07-windowsstore.patch rename to depends/common/libssh/06-windowsstore.patch index f58d992..0fb46b0 100644 --- a/depends/common/libssh/07-windowsstore.patch +++ b/depends/common/libssh/06-windowsstore.patch @@ -1,16 +1,6 @@ ---- a/CompilerChecks.cmake -+++ b/CompilerChecks.cmake -@@ -105,6 +105,7 @@ - add_c_compiler_flag("/D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1" SUPPORTED_COMPILER_FLAGS) - add_c_compiler_flag("/D _CRT_NONSTDC_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS) - add_c_compiler_flag("/D _CRT_SECURE_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS) -+ add_c_compiler_flag("/D _WINSOCK_DEPRECATED_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS) - endif() - - # This removes this annoying warning --- a/src/external/curve25519_ref.c +++ b/src/external/curve25519_ref.c -@@ -61,7 +61,14 @@ +@@ -61,7 +61,14 @@ static void freeze(unsigned int a[32]) for (j = 0;j < 32;++j) aorig[j] = a[j]; add(a,a,minusp); @@ -27,7 +17,7 @@ --- a/src/external/fe25519.c +++ b/src/external/fe25519.c -@@ -87,7 +87,14 @@ +@@ -87,7 +87,14 @@ void fe25519_freeze(fe25519 *r) } m &= ge(r->v[0],237); @@ -42,7 +32,7 @@ r->v[31] -= m&127; for (i = 30; i > 0; i--) { -@@ -159,7 +166,14 @@ +@@ -159,7 +166,14 @@ void fe25519_cmov(fe25519 *r, const fe25519 *x, unsigned char b) int i; uint32_t mask = b; @@ -78,7 +68,7 @@ char tmp[MAX_PATH] = {0}; char *szPath = NULL; -@@ -117,6 +122,7 @@ +@@ -117,6 +122,7 @@ char *ssh_get_user_home_dir(void) { strcpy(szPath, tmp); return szPath; } @@ -86,7 +76,7 @@ return NULL; } -@@ -147,6 +153,7 @@ +@@ -172,6 +178,7 @@ int gettimeofday(struct timeval *__p, void *__t) { } char *ssh_get_local_username(void) { @@ -94,7 +84,7 @@ DWORD size = 0; char *user; -@@ -161,6 +168,7 @@ +@@ -186,6 +193,7 @@ char *ssh_get_local_username(void) { if (GetUserName(user, &size)) { return user; } @@ -104,7 +94,7 @@ } --- a/src/options.c +++ b/src/options.c -@@ -1667,7 +1667,7 @@ +@@ -1674,7 +1674,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, int key_type; ssh_key key; ssh_key *bind_key_loc = NULL; @@ -113,14 +103,4 @@ rc = ssh_pki_import_privkey_file(value, NULL, NULL, NULL, &key); if (rc != SSH_OK) { ---- a/src/pki_container_openssh.c -+++ b/src/pki_container_openssh.c -@@ -112,7 +112,7 @@ - char passphrase_buffer[128]; - size_t key_material_len; - ssh_buffer buffer; -- ssh_string salt; -+ ssh_string salt = NULL; - uint32_t rounds; - int cmp; - int rc; + diff --git a/depends/common/libssh/08-static-openssl.patch b/depends/common/libssh/07-static-openssl.patch similarity index 56% rename from depends/common/libssh/08-static-openssl.patch rename to depends/common/libssh/07-static-openssl.patch index ad45a90..04901da 100644 --- a/depends/common/libssh/08-static-openssl.patch +++ b/depends/common/libssh/07-static-openssl.patch @@ -1,6 +1,16 @@ +--- a/CompilerChecks.cmake ++++ b/CompilerChecks.cmake +@@ -106,6 +106,7 @@ if (MSVC) + add_c_compiler_flag("/D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1" SUPPORTED_COMPILER_FLAGS) + add_c_compiler_flag("/D _CRT_NONSTDC_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS) + add_c_compiler_flag("/D _CRT_SECURE_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS) ++ add_c_compiler_flag("/D _WINSOCK_DEPRECATED_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS) + endif() + + # This removes this annoying warning --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake -@@ -77,6 +77,15 @@ +@@ -74,6 +74,15 @@ if (WIN32) endif (WIN32) if (OPENSSL_FOUND) @@ -16,7 +26,7 @@ set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) check_include_file(openssl/des.h HAVE_OPENSSL_DES_H) if (NOT HAVE_OPENSSL_DES_H) -@@ -104,35 +113,35 @@ +@@ -101,53 +110,53 @@ if (OPENSSL_FOUND) check_include_file(openssl/ecdsa.h HAVE_OPENSSL_ECDSA_H) set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) @@ -56,7 +66,39 @@ set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) ++ set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH_LINK_LIBRARIES}) + check_function_exists(FIPS_mode HAVE_OPENSSL_FIPS_MODE) + + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) +- set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) + set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH_LINK_LIBRARIES}) check_function_exists(RAND_priv_bytes HAVE_OPENSSL_RAND_PRIV_BYTES) + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) +- set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) ++ set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH_LINK_LIBRARIES}) + check_function_exists(EVP_DigestSign HAVE_OPENSSL_EVP_DIGESTSIGN) + + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) +- set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) ++ set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH_LINK_LIBRARIES}) + check_function_exists(EVP_DigestVerify HAVE_OPENSSL_EVP_DIGESTVERIFY) + check_function_exists(OPENSSL_ia32cap_loc HAVE_OPENSSL_IA32CAP_LOC) + + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) +- set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) ++ set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH_LINK_LIBRARIES}) + check_symbol_exists(EVP_PKEY_ED25519 "openssl/evp.h" FOUND_OPENSSL_ED25519) + + if (HAVE_OPENSSL_EVP_DIGESTSIGN AND HAVE_OPENSSL_EVP_DIGESTVERIFY AND +@@ -156,7 +165,7 @@ if (OPENSSL_FOUND) + endif() + + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) +- set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) ++ set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH_LINK_LIBRARIES}) + check_symbol_exists(EVP_PKEY_X25519 "openssl/evp.h" HAVE_OPENSSL_X25519) + + unset(CMAKE_REQUIRED_INCLUDES) + diff --git a/depends/common/libssh/09-werror.patch b/depends/common/libssh/08-werror.patch similarity index 86% rename from depends/common/libssh/09-werror.patch rename to depends/common/libssh/08-werror.patch index 5532dcd..73915ee 100644 --- a/depends/common/libssh/09-werror.patch +++ b/depends/common/libssh/08-werror.patch @@ -1,6 +1,6 @@ --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake -@@ -380,6 +380,9 @@ +@@ -402,6 +402,9 @@ if (NOT WIN32) }" HAVE_UNUSED_ATTRIBUTE) endif() @@ -10,7 +10,7 @@ check_c_source_compiles(" #include -@@ -418,9 +421,6 @@ +@@ -440,9 +443,6 @@ int main(void) { }" HAVE_GCC_BOUNDED_ATTRIBUTE) endif(OPENBSD) @@ -20,3 +20,4 @@ # Check for version script support file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { global: sym; + diff --git a/depends/common/libssh/10-tvos.patch b/depends/common/libssh/09-tvos.patch similarity index 88% rename from depends/common/libssh/10-tvos.patch rename to depends/common/libssh/09-tvos.patch index f67daad..0205618 100644 --- a/depends/common/libssh/10-tvos.patch +++ b/depends/common/libssh/09-tvos.patch @@ -12,7 +12,7 @@ struct ssh_poll_handle_struct; /* socket.c */ -@@ -37,9 +42,11 @@ +@@ -37,9 +42,11 @@ void ssh_socket_set_fd(ssh_socket s, socket_t fd); socket_t ssh_socket_get_fd(ssh_socket s); #ifndef _WIN32 int ssh_socket_unix(ssh_socket s, const char *path); @@ -37,7 +37,7 @@ #define set_status(session, status) do {\ if (session->common.callbacks && session->common.callbacks->connect_status_function) \ session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \ -@@ -563,7 +567,7 @@ +@@ -563,7 +567,7 @@ int ssh_connect(ssh_session session) { session->session_state=SSH_SESSION_STATE_SOCKET_CONNECTED; ssh_socket_set_fd(session->socket, session->opts.fd); ret=SSH_OK; @@ -48,7 +48,7 @@ session->opts.ProxyCommand); --- a/src/socket.c +++ b/src/socket.c -@@ -58,6 +58,10 @@ +@@ -58,6 +58,10 @@ typedef intptr_t ssize_t; #include "libssh/poll.h" #include "libssh/session.h" @@ -59,7 +59,7 @@ /** * @internal * -@@ -832,7 +836,7 @@ +@@ -833,7 +837,7 @@ int ssh_socket_connect(ssh_socket s, return SSH_OK; } @@ -68,3 +68,4 @@ /** * @internal * @brief executes a command and redirect input and outputs + diff --git a/depends/common/libssh/flags.txt b/depends/common/libssh/flags.txt index c3a0df7..30ebf39 100644 --- a/depends/common/libssh/flags.txt +++ b/depends/common/libssh/flags.txt @@ -1 +1 @@ --DWITH_STATIC_LIB=1 -DBUILD_SHARED_LIBS=0 -DTHREADS_PTHREAD_ARG=0 -DWITH_EXAMPLES=0 -DWITH_GSSAPI=0 +-DBUILD_STATIC_LIB=1 -DBUILD_SHARED_LIBS=0 -DTHREADS_PTHREAD_ARG=0 -DWITH_EXAMPLES=0 -DWITH_GSSAPI=0 diff --git a/depends/common/libssh/libssh.sha256 b/depends/common/libssh/libssh.sha256 index e243f5b..2e2a19e 100644 --- a/depends/common/libssh/libssh.sha256 +++ b/depends/common/libssh/libssh.sha256 @@ -1 +1 @@ -25303c2995e663cd169fdd902bae88106f48242d7e96311d74f812023482c7a5 +2c8b5f894dced58b3d629f16f3afa6562c20b4bdc894639163cf657833688f0c diff --git a/depends/common/libssh/libssh.txt b/depends/common/libssh/libssh.txt index fed1ec6..11fce7b 100644 --- a/depends/common/libssh/libssh.txt +++ b/depends/common/libssh/libssh.txt @@ -1 +1 @@ -libssh http://mirrors.kodi.tv/build-deps/sources/libssh-0.9.0.tar.xz +libssh http://mirrors.kodi.tv/build-deps/sources/libssh-0.9.3.tar.xz From f6334db8ac486113acb91ccf6a312f931100642f Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 13:57:19 +0100 Subject: [PATCH 02/17] update depend openssl to version 1.1.1d --- depends/common/openssl/01-android.patch | 21 ++- .../02-android-standalone-toolchain.patch | 143 ------------------ depends/common/openssl/03-android-cc.patch | 17 --- depends/common/openssl/openssl.sha256 | 2 +- depends/common/openssl/openssl.txt | 2 +- depends/windows/openssl/01-quote-cc.patch | 3 +- depends/windows/openssl/openssl.sha256 | 2 +- depends/windows/openssl/openssl.txt | 2 +- depends/windowsstore/openssl/CMakeLists.txt | 4 +- 9 files changed, 26 insertions(+), 170 deletions(-) delete mode 100644 depends/common/openssl/02-android-standalone-toolchain.patch delete mode 100644 depends/common/openssl/03-android-cc.patch diff --git a/depends/common/openssl/01-android.patch b/depends/common/openssl/01-android.patch index b8e664d..41bc6a3 100644 --- a/depends/common/openssl/01-android.patch +++ b/depends/common/openssl/01-android.patch @@ -1,6 +1,20 @@ --- a/Configurations/15-android.conf +++ b/Configurations/15-android.conf -@@ -89,7 +89,6 @@ +@@ -112,18 +112,17 @@ + # *after* announcement that gcc is being phased out, so + # favouring clang is considered adequate. Those who insist + # have option to enforce test for gcc with CC=gcc. +- if (which("$triarch-$cc") !~ m|^$ndk|) { +- die "no NDK $triarch-$cc on \$PATH"; ++ if (realpath(which("$cc")) !~ m|^$ndk|) { ++ die "no NDK $cc on \$PATH"; + } + $user{CC} = $cc; +- $user{CROSS_COMPILE} = "$triarch-"; ++ $user{CROSS_COMPILE} = ""; + } elsif ($user{CC} eq "clang") { + die "no NDK clang on \$PATH"; + } else { if (which("$triarch-gcc") !~ m|^$ndk/.*/prebuilt/([^/]+)/|) { die "no NDK $triarch-gcc on \$PATH"; } @@ -8,12 +22,13 @@ $user{CROSS_COMPILE} = "$triarch-"; } -@@ -105,7 +104,7 @@ +@@ -139,7 +138,7 @@ $sysroot =~ s|^$ndk/||; $android_ndk = { -- cflags => "$cflags --sysroot=\$(ANDROID_NDK)/$sysroot", +- cflags => "$cflags --sysroot=\$($ndk_var)/$sysroot", + cflags => $cflags, cppflags => $cppflags, bn_ops => $arch =~ m/64$/ ? "SIXTY_FOUR_BIT_LONG" : "BN_LLONG", + diff --git a/depends/common/openssl/02-android-standalone-toolchain.patch b/depends/common/openssl/02-android-standalone-toolchain.patch deleted file mode 100644 index a3d511b..0000000 --- a/depends/common/openssl/02-android-standalone-toolchain.patch +++ /dev/null @@ -1,143 +0,0 @@ -From a66c361a773e697b5c6bb805ae37d2c4c8d32cb1 Mon Sep 17 00:00:00 2001 -From: Andy Polyakov -Date: Sun, 14 Oct 2018 15:19:41 +0200 -Subject: [PATCH] Configurations/15-android.conf: add support for "standalone - toolchain". - -Reviewed-by: Richard Levitte -(Merged from https://github.com/openssl/openssl/pull/7400) - -(cherry picked from commit 03ad7c009e16a233c733098db3169c560142ccd3) ---- - Configurations/15-android.conf | 41 +++++++++++++++++++++++++--------- - NOTES.ANDROID | 18 ++++++++++----- - 2 files changed, 44 insertions(+), 15 deletions(-) - -diff --git a/Configurations/15-android.conf b/Configurations/15-android.conf -index d3b428b6cb4..a6b0d7a06d2 100644 ---- a/Configurations/15-android.conf -+++ b/Configurations/15-android.conf -@@ -24,7 +24,12 @@ - - my $ndk = $ENV{ANDROID_NDK}; - die "\$ANDROID_NDK is not defined" if (!$ndk); -- die "\$ANDROID_NDK=$ndk is invalid" if (!-d "$ndk/platforms"); -+ if (!-d "$ndk/platforms" && !-f "$ndk/AndroidVersion.txt") { -+ # $ndk/platforms is traditional "all-inclusive" NDK, while -+ # $ndk/AndroidVersion.txt is so-called standalone toolchain -+ # tailored for specific target down to API level. -+ die "\$ANDROID_NDK=$ndk is invalid"; -+ } - $ndk = canonpath($ndk); - - my $ndkver = undef; -@@ -40,10 +45,18 @@ - close $fh; - } - -- my $sysroot; -+ my ($sysroot, $api, $arch); -+ -+ $config{target} =~ m|[^-]+-([^-]+)$|; # split on dash -+ $arch = $1; - -- if (!($sysroot = $ENV{CROSS_SYSROOT})) { -- my $api = "*"; -+ if ($sysroot = $ENV{CROSS_SYSROOT}) { -+ $sysroot =~ m|/android-([0-9]+)/arch-(\w+)/?$|; -+ ($api, $arch) = ($1, $2); -+ } elsif (-f "$ndk/AndroidVersion.txt") { -+ $sysroot = "$ndk/sysroot"; -+ } else { -+ $api = "*"; - - # see if user passed -D__ANDROID_API__=N - foreach (@{$useradd{CPPDEFINES}}, @{$user{CPPFLAGS}}) { -@@ -59,19 +72,15 @@ - } glob("$ndk/platforms/android-$api"); - die "no $ndk/platforms/android-$api" if ($#platforms < 0); - -- $config{target} =~ m|[^-]+-([^-]+)$|; # split on dash -- $sysroot = "@platforms[$#platforms]/arch-$1"; -+ $sysroot = "@platforms[$#platforms]/arch-$arch"; - } - die "no sysroot=$sysroot" if (!-d $sysroot); - -- $sysroot =~ m|/android-([0-9]+)/arch-(\w+)/?$|; -- my ($api, $arch) = ($1, $2); -- - my $triarch = $triplet{$arch}; - my $cflags; - my $cppflags; - -- # see if there is NDK clang on $PATH -+ # see if there is NDK clang on $PATH, "universal" or "standalone" - if (which("clang") =~ m|^$ndk/.*/prebuilt/([^/]+)/|) { - my $host=$1; - # harmonize with gcc default -@@ -83,6 +92,18 @@ - . "/$tritools-4.9/prebuilt/$host"; - $user{CC} = "clang" if ($user{CC} !~ m|clang|); - $user{CROSS_COMPILE} = undef; -+ } elsif (-f "$ndk/AndroidVersion.txt") { #"standalone toolchain" -+ my $cc = $user{CC} // "clang"; -+ # One can probably argue that both clang and gcc should be -+ # probed, but support for "standalone toolchain" was added -+ # *after* announcement that gcc is being phased out, so -+ # favouring clang is considered adequate. Those who insist -+ # have option to enforce test for gcc with CC=gcc. -+ if (which("$triarch-$cc") !~ m|^$ndk|) { -+ die "no NDK $triarch-$cc on \$PATH"; -+ } -+ $user{CC} = $cc; -+ $user{CROSS_COMPILE} = "$triarch-"; - } elsif ($user{CC} eq "clang") { - die "no NDK clang on \$PATH"; - } else { -diff --git a/NOTES.ANDROID b/NOTES.ANDROID -index d13f47d6675..bbbd8e4db92 100644 ---- a/NOTES.ANDROID -+++ b/NOTES.ANDROID -@@ -24,16 +24,18 @@ - in order to invoke $(CROSS_COMPILE)gcc and company. (Configure will fail - and give you a hint if you get it wrong.) Apart from PATH adjustment - you need to set ANDROID_NDK environment to point at NDK directory -- as /some/where/android-ndk-. NDK customarily supports multiple -+ as /some/where/android-ndk-. Both variables are significant at both -+ configuration and compilation times. NDK customarily supports multiple - Android API levels, e.g. android-14, android-21, etc. By default latest - one available is chosen. If you need to target older platform, pass - additional -D__ANDROID_API__=N to Configure. N is numeric value of the - target platform version. For example, to compile for ICS on ARM with - NDK 10d: - -- ANDROID_NDK=/some/where/android-ndk-10d -+ export ANDROID_NDK=/some/where/android-ndk-10d - PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH - ./Configure android-arm -D__ANDROID_API__=14 -+ make - - Caveat lector! Earlier OpenSSL versions relied on additional CROSS_SYSROOT - variable set to $ANDROID_NDK/platforms/android-/arch- to -@@ -43,12 +45,18 @@ - conflict, and mixing the two is therefore not supported. Migration to - CROSS_SYSROOT-less setup is recommended. - -- One can engage clang by adjusting PATH to cover NDK's clang. Just keep -- in mind that if you miss it, Configure will try to use gcc... Also, -- PATH would need even further adjustment to cover unprefixed, yet -+ One can engage clang by adjusting PATH to cover same NDK's clang. Just -+ keep in mind that if you miss it, Configure will try to use gcc... -+ Also, PATH would need even further adjustment to cover unprefixed, yet - target-specific, ar and ranlib. It's possible that you don't need to - bother, if binutils-multiarch is installed on your Linux system. - -+ Another option is to create so called "standalone toolchain" tailored -+ for single specific platform including Android API level, and assign its -+ location to ANDROID_NDK. In such case you have to pass matching target -+ name to Configure and shouldn't use -D__ANDROID_API__=N. PATH adjusment -+ becomes simpler, $ANDROID_NDK/bin:$PATH suffices. -+ - Running tests (on Linux) - ------------------------ - diff --git a/depends/common/openssl/03-android-cc.patch b/depends/common/openssl/03-android-cc.patch deleted file mode 100644 index 204ae33..0000000 --- a/depends/common/openssl/03-android-cc.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/Configurations/15-android.conf -+++ b/Configurations/15-android.conf -@@ -99,11 +99,11 @@ - # *after* announcement that gcc is being phased out, so - # favouring clang is considered adequate. Those who insist - # have option to enforce test for gcc with CC=gcc. -- if (which("$triarch-$cc") !~ m|^$ndk|) { -- die "no NDK $triarch-$cc on \$PATH"; -+ if (realpath(which("$cc")) !~ m|^$ndk|) { -+ die "no NDK $cc on \$PATH"; - } - $user{CC} = $cc; -- $user{CROSS_COMPILE} = "$triarch-"; -+ $user{CROSS_COMPILE} = ""; - } elsif ($user{CC} eq "clang") { - die "no NDK clang on \$PATH"; - } else { diff --git a/depends/common/openssl/openssl.sha256 b/depends/common/openssl/openssl.sha256 index a11c35c..20e81ad 100644 --- a/depends/common/openssl/openssl.sha256 +++ b/depends/common/openssl/openssl.sha256 @@ -1 +1 @@ -2836875a0f89c03d0fdf483941512613a50cfb421d6fd94b9f41d7279d586a3d +1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2 diff --git a/depends/common/openssl/openssl.txt b/depends/common/openssl/openssl.txt index 6e7e56d..fc8996d 100644 --- a/depends/common/openssl/openssl.txt +++ b/depends/common/openssl/openssl.txt @@ -1 +1 @@ -openssl http://mirrors.kodi.tv/build-deps/sources/openssl-1.1.1.tar.gz +openssl http://mirrors.kodi.tv/build-deps/sources/openssl-1.1.1d.tar.gz diff --git a/depends/windows/openssl/01-quote-cc.patch b/depends/windows/openssl/01-quote-cc.patch index 017bdce..537cc46 100644 --- a/depends/windows/openssl/01-quote-cc.patch +++ b/depends/windows/openssl/01-quote-cc.patch @@ -1,6 +1,6 @@ --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl -@@ -162,8 +162,8 @@ +@@ -164,8 +164,8 @@ libdir={- file_name_is_absolute($libdir) ##### User defined commands and flags ################################ @@ -11,3 +11,4 @@ CPPFLAGS={- our $cppflags1 = join(" ", (map { "-D".$_} @{$config{CPPDEFINES}}), (map { " /I ".$_} @{$config{CPPINCLUDES}}), + diff --git a/depends/windows/openssl/openssl.sha256 b/depends/windows/openssl/openssl.sha256 index a11c35c..20e81ad 100644 --- a/depends/windows/openssl/openssl.sha256 +++ b/depends/windows/openssl/openssl.sha256 @@ -1 +1 @@ -2836875a0f89c03d0fdf483941512613a50cfb421d6fd94b9f41d7279d586a3d +1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2 diff --git a/depends/windows/openssl/openssl.txt b/depends/windows/openssl/openssl.txt index 6e7e56d..fc8996d 100644 --- a/depends/windows/openssl/openssl.txt +++ b/depends/windows/openssl/openssl.txt @@ -1 +1 @@ -openssl http://mirrors.kodi.tv/build-deps/sources/openssl-1.1.1.tar.gz +openssl http://mirrors.kodi.tv/build-deps/sources/openssl-1.1.1d.tar.gz diff --git a/depends/windowsstore/openssl/CMakeLists.txt b/depends/windowsstore/openssl/CMakeLists.txt index d129825..8abfbc7 100644 --- a/depends/windowsstore/openssl/CMakeLists.txt +++ b/depends/windowsstore/openssl/CMakeLists.txt @@ -7,9 +7,9 @@ check_symbol_exists(_AMD64_ "Windows.h" _X64_) check_symbol_exists(_ARM_ "Windows.h" _ARM_) if(_X86_) - set(OPENSSL_ARCHIVE_NAME openssl-1.0.2o-win10-Win32-v141) + set(OPENSSL_ARCHIVE_NAME openssl-1.1.1b-win10-Win32-v141) elseif(_X64_) - set(OPENSSL_ARCHIVE_NAME openssl-1.0.2o-win10-x64-v141) + set(OPENSSL_ARCHIVE_NAME openssl-1.1.1b-win10-x64-v141) elseif(_ARM_) set(OPENSSL_ARCHIVE_NAME openssl-1.0.2o-win10-ARM-v141) else() From 59260557517fe6cf2180b16f7cad0431b79f4046 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 13:58:21 +0100 Subject: [PATCH 03/17] update strawberry perl on win UWP to 5.30.1.1 --- depends/windows/strawberryperl/CMakeLists.txt | 2 +- depends/windows/strawberryperl/strawberryperl.sha256 | 2 +- depends/windows/strawberryperl/strawberryperl.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/windows/strawberryperl/CMakeLists.txt b/depends/windows/strawberryperl/CMakeLists.txt index 837dda6..95f3531 100644 --- a/depends/windows/strawberryperl/CMakeLists.txt +++ b/depends/windows/strawberryperl/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -project(strawberryperl VERSION 5.28.0.1) +project(strawberryperl VERSION 5.30.1.1) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/StrawberryPerlConfig.cmake "set(STRAWBERRYPERL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/perl/bin)\n") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/StrawberryPerlConfig.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/depends/windows/strawberryperl/strawberryperl.sha256 b/depends/windows/strawberryperl/strawberryperl.sha256 index 502c4a1..527ab86 100644 --- a/depends/windows/strawberryperl/strawberryperl.sha256 +++ b/depends/windows/strawberryperl/strawberryperl.sha256 @@ -1 +1 @@ -dcdc5f4d54e6def73a472bbd4820aa7a22d336f6004fc35e180818f3d388c7e1 +45d6bc187ab40f59ebd1a44d4014703c5cda23316ea7f2fb5eac182ea2972f0b diff --git a/depends/windows/strawberryperl/strawberryperl.txt b/depends/windows/strawberryperl/strawberryperl.txt index 27624b6..cef4e01 100644 --- a/depends/windows/strawberryperl/strawberryperl.txt +++ b/depends/windows/strawberryperl/strawberryperl.txt @@ -1 +1 @@ -strawberryperl http://strawberryperl.com/download/5.28.0.1/strawberry-perl-5.28.0.1-64bit-portable.zip +strawberryperl http://mirrors.kodi.tv/build-deps/win32/strawberry-perl-5.30.1.1-64bit-portable.zip From 9603ab21babb9760ff47eefccc64ce9d2d0d9f81 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 14:00:10 +0100 Subject: [PATCH 04/17] remove not needed virtual --- src/SFTPFile.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/SFTPFile.cpp b/src/SFTPFile.cpp index 6b4fe6b..bfe8f04 100644 --- a/src/SFTPFile.cpp +++ b/src/SFTPFile.cpp @@ -38,7 +38,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS public: CSFTPFile(KODI_HANDLE instance) : CInstanceVFS(instance) { } - virtual void* Open(const VFSURL& url) override + void* Open(const VFSURL& url) override { SFTPContext* result = new SFTPContext; @@ -58,7 +58,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS return nullptr; } - virtual ssize_t Read(void* context, void* buffer, size_t uiBufSize) override + ssize_t Read(void* context, void* buffer, size_t uiBufSize) override { SFTPContext* ctx = (SFTPContext*)context; if (ctx && ctx->session && ctx->sftp_handle) @@ -76,7 +76,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS return -1; } - virtual int64_t Seek(void* context, int64_t iFilePosition, int whence) override + int64_t Seek(void* context, int64_t iFilePosition, int whence) override { SFTPContext* ctx = (SFTPContext*)context; if (ctx && ctx->session && ctx->sftp_handle) @@ -101,7 +101,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS } } - virtual int64_t GetLength(void* context) override + int64_t GetLength(void* context) override { SFTPContext* ctx = (SFTPContext*)context; struct __stat64 buffer; @@ -111,7 +111,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS return buffer.st_size; } - virtual int64_t GetPosition(void* context) override + int64_t GetPosition(void* context) override { SFTPContext* ctx = (SFTPContext*)context; if (ctx->session && ctx->sftp_handle) @@ -121,7 +121,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS return 0; } - virtual int IoControl(void* context, XFILE::EIoControl request, void* param) override + int IoControl(void* context, XFILE::EIoControl request, void* param) override { if(request == XFILE::IOCTRL_SEEK_POSSIBLE) return 1; @@ -129,7 +129,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS return -1; } - virtual int Stat(const VFSURL& url, struct __stat64* buffer) override + int Stat(const VFSURL& url, struct __stat64* buffer) override { CSFTPSessionPtr session = CSFTPSessionManager::Get().CreateSession(url); if (session) @@ -141,7 +141,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS } } - virtual bool Close(void* context) override + bool Close(void* context) override { SFTPContext* ctx = (SFTPContext*)context; if (ctx->session && ctx->sftp_handle) @@ -151,7 +151,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS return true; } - virtual bool Exists(const VFSURL& url) override + bool Exists(const VFSURL& url) override { CSFTPSessionPtr session = CSFTPSessionManager::Get().CreateSession(url); if (session) @@ -163,17 +163,17 @@ class CSFTPFile : public kodi::addon::CInstanceVFS } } - virtual void ClearOutIdle() override + void ClearOutIdle() override { CSFTPSessionManager::Get().ClearOutIdleSessions(); } - virtual void DisconnectAll() override + void DisconnectAll() override { CSFTPSessionManager::Get().DisconnectAllSessions(); } - virtual bool DirectoryExists(const VFSURL& url) override + bool DirectoryExists(const VFSURL& url) override { CSFTPSessionPtr session = CSFTPSessionManager::Get().CreateSession(url); if (session) @@ -185,9 +185,9 @@ class CSFTPFile : public kodi::addon::CInstanceVFS } } - virtual bool GetDirectory(const VFSURL& url, - std::vector& items, - CVFSCallbacks callbacks) override + bool GetDirectory(const VFSURL& url, + std::vector& items, + CVFSCallbacks callbacks) override { CSFTPSessionPtr session = CSFTPSessionManager::Get().CreateSession(url); std::stringstream str; @@ -211,7 +211,7 @@ class CMyAddon : public kodi::addon::CAddonBase ssh_finalize(); } - virtual ADDON_STATUS CreateInstance(int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE& addonInstance) override + ADDON_STATUS CreateInstance(int instanceType, std::string instanceID, KODI_HANDLE instance, KODI_HANDLE& addonInstance) override { addonInstance = new CSFTPFile(instance); return ADDON_STATUS_OK; From 7d8704f773f70d274f5ce9b9e942635372edc082 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 23:51:17 +0100 Subject: [PATCH 05/17] remove p8platform time usage and use std::chrono --- src/SFTPSession.cpp | 17 +++++++++-------- src/SFTPSession.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/SFTPSession.cpp b/src/SFTPSession.cpp index 717995b..1e70327 100644 --- a/src/SFTPSession.cpp +++ b/src/SFTPSession.cpp @@ -86,7 +86,7 @@ CSFTPSession::CSFTPSession(const VFSURL& url) if (!Connect(url)) Disconnect(); - m_LastActive = P8PLATFORM::GetTimeMs(); + m_LastActive = std::chrono::high_resolution_clock::now(); } CSFTPSession::~CSFTPSession() @@ -100,7 +100,7 @@ sftp_file CSFTPSession::CreateFileHande(const std::string& file) if (m_connected) { P8PLATFORM::CLockObject lock(m_lock); - m_LastActive = P8PLATFORM::GetTimeMs(); + m_LastActive = std::chrono::high_resolution_clock::now(); sftp_file handle = sftp_open(m_sftp_session, CorrectPath(file).c_str(), O_RDONLY, 0); if (handle) { @@ -131,7 +131,7 @@ bool CSFTPSession::GetDirectory(const std::string& base, const std::string& fold sftp_dir dir = NULL; P8PLATFORM::CLockObject lock(m_lock); - m_LastActive = P8PLATFORM::GetTimeMs(); + m_LastActive = std::chrono::high_resolution_clock::now(); dir = sftp_opendir(m_sftp_session, CorrectPath(folder).c_str()); //Doing as little work as possible within the critical section @@ -242,7 +242,7 @@ int CSFTPSession::Stat(const char *path, struct __stat64* buffer) if(m_connected) { P8PLATFORM::CLockObject lock(m_lock); - m_LastActive = P8PLATFORM::GetTimeMs(); + m_LastActive = std::chrono::high_resolution_clock::now(); sftp_attributes attributes = sftp_stat(m_sftp_session, CorrectPath(path).c_str()); if (attributes) @@ -276,7 +276,7 @@ int CSFTPSession::Stat(const char *path, struct __stat64* buffer) int CSFTPSession::Seek(sftp_file handle, uint64_t position) { P8PLATFORM::CLockObject lock(m_lock); - m_LastActive = P8PLATFORM::GetTimeMs(); + m_LastActive = std::chrono::high_resolution_clock::now(); int result = sftp_seek64(handle, position); return result; } @@ -284,7 +284,7 @@ int CSFTPSession::Seek(sftp_file handle, uint64_t position) int CSFTPSession::Read(sftp_file handle, void *buffer, size_t length) { P8PLATFORM::CLockObject lock(m_lock); - m_LastActive = P8PLATFORM::GetTimeMs(); + m_LastActive = std::chrono::high_resolution_clock::now(); int result=sftp_read(handle, buffer, length); return result; } @@ -292,14 +292,15 @@ int CSFTPSession::Read(sftp_file handle, void *buffer, size_t length) int64_t CSFTPSession::GetPosition(sftp_file handle) { P8PLATFORM::CLockObject lock(m_lock); - m_LastActive = P8PLATFORM::GetTimeMs(); + m_LastActive = std::chrono::high_resolution_clock::now(); int64_t result = sftp_tell64(handle); return result; } bool CSFTPSession::IsIdle() { - return (P8PLATFORM::GetTimeMs() - m_LastActive) > 90000; + std::chrono::high_resolution_clock::time_point now = std::chrono::high_resolution_clock::now(); + return static_cast(std::chrono::duration_cast(now - m_LastActive).count()) > 90000; } bool CSFTPSession::VerifyKnownHost(ssh_session session) diff --git a/src/SFTPSession.h b/src/SFTPSession.h index 25079a2..96ec014 100644 --- a/src/SFTPSession.h +++ b/src/SFTPSession.h @@ -19,6 +19,7 @@ */ #include +#include #include #include #include "kodi/addon-instance/VFS.h" @@ -54,7 +55,7 @@ class CSFTPSession bool m_connected; ssh_session m_session; sftp_session m_sftp_session; - int m_LastActive; + std::chrono::high_resolution_clock::time_point m_LastActive; }; typedef std::shared_ptr CSFTPSessionPtr; From a4fb0019a6b20c2e9b44ff80dd084002df6052a9 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 23:59:43 +0100 Subject: [PATCH 06/17] use std::recursive_mutex and remove p8-platform usage complete --- CMakeLists.txt | 5 +---- src/SFTPFile.cpp | 1 - src/SFTPSession.cpp | 49 ++++++++++++++++++++++----------------------- src/SFTPSession.h | 10 ++++----- 4 files changed, 30 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b331bb7..c5374a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,13 +8,11 @@ set(CMAKE_CXX_EXTENSIONS OFF) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) find_package(Kodi REQUIRED) -find_package(p8-platform REQUIRED) find_package(OpenSSL REQUIRED) find_package(SSH REQUIRED) find_package(ZLIB REQUIRED) include_directories(${KODI_INCLUDE_DIR}/.. - ${p8-platform_INCLUDE_DIRS} ${SSH_INCLUDE_DIRS}) set(SFTP_SOURCES src/SFTPSession.cpp @@ -22,9 +20,8 @@ set(SFTP_SOURCES src/SFTPSession.cpp set(SFTP_HEADERS src/SFTPSession.h) -set(DEPLIBS ${p8-platform_LIBRARIES} +set(DEPLIBS ${OPENSSL_LIBRARIES} ${SSH_LIBRARIES} - ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) add_definitions( -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) diff --git a/src/SFTPFile.cpp b/src/SFTPFile.cpp index bfe8f04..d86a758 100644 --- a/src/SFTPFile.cpp +++ b/src/SFTPFile.cpp @@ -18,7 +18,6 @@ * */ -#include #include #include #include "SFTPSession.h" diff --git a/src/SFTPSession.cpp b/src/SFTPSession.cpp index 1e70327..f6e6169 100644 --- a/src/SFTPSession.cpp +++ b/src/SFTPSession.cpp @@ -19,7 +19,6 @@ */ #include "SFTPSession.h" -#include #include #include #include @@ -82,7 +81,7 @@ static const char * SFTPErrorText(int sftp_error) CSFTPSession::CSFTPSession(const VFSURL& url) { kodi::Log(ADDON_LOG_INFO, "SFTPSession: Creating new session on host '%s:%d' with user '%s'", url.hostname, url.port, url.username); - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); if (!Connect(url)) Disconnect(); @@ -91,7 +90,7 @@ CSFTPSession::CSFTPSession(const VFSURL& url) CSFTPSession::~CSFTPSession() { - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); Disconnect(); } @@ -99,7 +98,7 @@ sftp_file CSFTPSession::CreateFileHande(const std::string& file) { if (m_connected) { - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); m_LastActive = std::chrono::high_resolution_clock::now(); sftp_file handle = sftp_open(m_sftp_session, CorrectPath(file).c_str(), O_RDONLY, 0); if (handle) @@ -118,7 +117,7 @@ sftp_file CSFTPSession::CreateFileHande(const std::string& file) void CSFTPSession::CloseFileHandle(sftp_file handle) { - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); sftp_close(handle); } @@ -130,7 +129,7 @@ bool CSFTPSession::GetDirectory(const std::string& base, const std::string& fold { sftp_dir dir = NULL; - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); m_LastActive = std::chrono::high_resolution_clock::now(); dir = sftp_opendir(m_sftp_session, CorrectPath(folder).c_str()); @@ -138,7 +137,7 @@ bool CSFTPSession::GetDirectory(const std::string& base, const std::string& fold if (!dir) sftp_error = sftp_get_error(m_sftp_session); - lock.Unlock(); + lock.unlock(); if (!dir) { @@ -151,16 +150,16 @@ bool CSFTPSession::GetDirectory(const std::string& base, const std::string& fold { sftp_attributes attributes = NULL; - lock.Lock(); + lock.lock(); read = sftp_dir_eof(dir) == 0; attributes = sftp_readdir(m_sftp_session, dir); - lock.Unlock(); + lock.unlock(); if (attributes && (attributes->name == NULL || strcmp(attributes->name, "..") == 0 || strcmp(attributes->name, ".") == 0)) { - lock.Lock(); + lock.lock(); sftp_attributes_free(attributes); - lock.Unlock(); + lock.unlock(); continue; } @@ -172,10 +171,10 @@ bool CSFTPSession::GetDirectory(const std::string& base, const std::string& fold if (attributes->type == SSH_FILEXFER_TYPE_SYMLINK) { - lock.Lock(); + lock.lock(); sftp_attributes_free(attributes); attributes = sftp_stat(m_sftp_session, CorrectPath(localPath).c_str()); - lock.Unlock(); + lock.unlock(); if (attributes == NULL) continue; } @@ -200,17 +199,17 @@ bool CSFTPSession::GetDirectory(const std::string& base, const std::string& fold entry.SetPath(base+localPath); items.push_back(entry); - lock.Lock(); + lock.lock(); sftp_attributes_free(attributes); - lock.Unlock(); + lock.unlock(); } else read = false; } - lock.Lock(); + lock.lock(); sftp_closedir(dir); - lock.Unlock(); + lock.unlock(); return true; } @@ -241,7 +240,7 @@ int CSFTPSession::Stat(const char *path, struct __stat64* buffer) { if(m_connected) { - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); m_LastActive = std::chrono::high_resolution_clock::now(); sftp_attributes attributes = sftp_stat(m_sftp_session, CorrectPath(path).c_str()); @@ -275,7 +274,7 @@ int CSFTPSession::Stat(const char *path, struct __stat64* buffer) int CSFTPSession::Seek(sftp_file handle, uint64_t position) { - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); m_LastActive = std::chrono::high_resolution_clock::now(); int result = sftp_seek64(handle, position); return result; @@ -283,7 +282,7 @@ int CSFTPSession::Seek(sftp_file handle, uint64_t position) int CSFTPSession::Read(sftp_file handle, void *buffer, size_t length) { - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); m_LastActive = std::chrono::high_resolution_clock::now(); int result=sftp_read(handle, buffer, length); return result; @@ -291,7 +290,7 @@ int CSFTPSession::Read(sftp_file handle, void *buffer, size_t length) int64_t CSFTPSession::GetPosition(sftp_file handle) { - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); m_LastActive = std::chrono::high_resolution_clock::now(); int64_t result = sftp_tell64(handle); return result; @@ -473,7 +472,7 @@ void CSFTPSession::Disconnect() bool CSFTPSession::GetItemPermissions(const char *path, uint32_t &permissions) { bool gotPermissions = false; - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); if(m_connected) { sftp_attributes attributes = sftp_stat(m_sftp_session, CorrectPath(path).c_str()); @@ -510,7 +509,7 @@ CSFTPSessionPtr CSFTPSessionManager::CreateSession(const VFSURL& url) itoa << url2.port; std::string portstr = itoa.str(); - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); std::string key = std::string(url2.username) + ":" + url2.password + "@" + url2.hostname + ":" + portstr; CSFTPSessionPtr ptr = sessions[key]; @@ -525,7 +524,7 @@ CSFTPSessionPtr CSFTPSessionManager::CreateSession(const VFSURL& url) void CSFTPSessionManager::ClearOutIdleSessions() { - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); for(std::map::iterator iter = sessions.begin(); iter != sessions.end();) { if (iter->second->IsIdle()) @@ -537,6 +536,6 @@ void CSFTPSessionManager::ClearOutIdleSessions() void CSFTPSessionManager::DisconnectAllSessions() { - P8PLATFORM::CLockObject lock(m_lock); + std::unique_lock lock(m_lock); sessions.clear(); } diff --git a/src/SFTPSession.h b/src/SFTPSession.h index 96ec014..223558c 100644 --- a/src/SFTPSession.h +++ b/src/SFTPSession.h @@ -18,13 +18,13 @@ * */ -#include #include +#include #include #include -#include "kodi/addon-instance/VFS.h" -#include #include +#include +#include #include #include @@ -50,7 +50,7 @@ class CSFTPSession bool Connect(const VFSURL& url); void Disconnect(); bool GetItemPermissions(const char *path, uint32_t &permissions); - P8PLATFORM::CMutex m_lock; + std::recursive_mutex m_lock; bool m_connected; ssh_session m_session; @@ -70,6 +70,6 @@ class CSFTPSessionManager private: CSFTPSessionManager() {} CSFTPSessionManager& operator=(const CSFTPSessionManager&); - P8PLATFORM::CMutex m_lock; + std::recursive_mutex m_lock; std::map sessions; }; From 40c553656040c3aa7076bf11c88ed83b258c56ff Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 23:09:25 +0100 Subject: [PATCH 07/17] change license year and name to Kodi / code cleanups --- src/SFTPFile.cpp | 10 +++++----- src/SFTPSession.cpp | 7 ++++--- src/SFTPSession.h | 8 +++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/SFTPFile.cpp b/src/SFTPFile.cpp index d86a758..fe2b642 100644 --- a/src/SFTPFile.cpp +++ b/src/SFTPFile.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org + * Copyright (C) 2005-2019 Team Kodi + * https://kodi.tv * * 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 @@ -13,15 +13,15 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see + * along with Kodi; see the file COPYING. If not, see * . * */ -#include -#include #include "SFTPSession.h" +#include +#include #include #include diff --git a/src/SFTPSession.cpp b/src/SFTPSession.cpp index f6e6169..f504ba1 100644 --- a/src/SFTPSession.cpp +++ b/src/SFTPSession.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org + * Copyright (C) 2005-2019 Team Kodi + * https://kodi.tv * * 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 @@ -13,12 +13,13 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see + * along with Kodi; see the file COPYING. If not, see * . * */ #include "SFTPSession.h" + #include #include #include diff --git a/src/SFTPSession.h b/src/SFTPSession.h index 223558c..f623782 100644 --- a/src/SFTPSession.h +++ b/src/SFTPSession.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2005-2013 Team XBMC - * http://xbmc.org + * Copyright (C) 2005-2019 Team Kodi + * https://kodi.tv * * 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 @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see + * along with Kodi; see the file COPYING. If not, see * . * */ @@ -45,6 +45,7 @@ class CSFTPSession int Read(sftp_file handle, void *buffer, size_t length); int64_t GetPosition(sftp_file handle); bool IsIdle(); + private: bool VerifyKnownHost(ssh_session session); bool Connect(const VFSURL& url); @@ -67,6 +68,7 @@ class CSFTPSessionManager CSFTPSessionPtr CreateSession(const VFSURL& url); void ClearOutIdleSessions(); void DisconnectAllSessions(); + private: CSFTPSessionManager() {} CSFTPSessionManager& operator=(const CSFTPSessionManager&); From f7f6aa84e0279d9f74159decdeaea0fd7d67b06f Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 23:13:25 +0100 Subject: [PATCH 08/17] add ATTRIBUTE_HIDDEN --- src/SFTPFile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SFTPFile.cpp b/src/SFTPFile.cpp index fe2b642..69d011b 100644 --- a/src/SFTPFile.cpp +++ b/src/SFTPFile.cpp @@ -25,7 +25,7 @@ #include #include -class CSFTPFile : public kodi::addon::CInstanceVFS +class ATTRIBUTE_HIDDEN CSFTPFile : public kodi::addon::CInstanceVFS { struct SFTPContext { @@ -197,7 +197,7 @@ class CSFTPFile : public kodi::addon::CInstanceVFS } }; -class CMyAddon : public kodi::addon::CAddonBase +class ATTRIBUTE_HIDDEN CMyAddon : public kodi::addon::CAddonBase { public: CMyAddon() From a665b232b36f9f12ef47f2a19cb3b8db0dfa5c11 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Fri, 16 Aug 2019 16:37:55 +0200 Subject: [PATCH 09/17] add .gitignore --- .gitignore | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59bffb8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# build artifacts +build/ +vfs.*/addon.xml + +# Debian build files +debian/changelog +debian/files +debian/*.log +debian/*.substvars +debian/.debhelper/ +debian/tmp/ +debian/kodi-vfs-*/ +obj-x86_64-linux-gnu/ + +# commonly used editors +# vim +*.swp + +# Eclipse +*.project +*.cproject +.classpath +*.sublime-* +.settings/ + +# KDevelop 4 +*.kdev4 + +# gedit +*~ + +# CLion +/.idea + +# clion +.idea/ From 055ef8c4b1b5bfa0b49f045d3122525ff779e31f Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 14:25:29 +0100 Subject: [PATCH 10/17] add license and source url to addon.xml --- vfs.sftp/addon.xml.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vfs.sftp/addon.xml.in b/vfs.sftp/addon.xml.in index 4fd3b67..16818ad 100644 --- a/vfs.sftp/addon.xml.in +++ b/vfs.sftp/addon.xml.in @@ -25,5 +25,7 @@ SFTP support SFTP support @PLATFORM@ + GPL-2.0 + https://github.com/xbmc/vfs.sftp From cd46988567e8d706bc2a9d894d7edbb361011b84 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 18 Dec 2019 23:23:27 +0100 Subject: [PATCH 11/17] increase addon description --- vfs.sftp/addon.xml.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vfs.sftp/addon.xml.in b/vfs.sftp/addon.xml.in index 16818ad..2ed8fb7 100644 --- a/vfs.sftp/addon.xml.in +++ b/vfs.sftp/addon.xml.in @@ -22,8 +22,10 @@ zeroconf="_sftp-ssh._tcp" library_@PLATFORM@="@LIBRARY_FILENAME@"/> - SFTP support - SFTP support + SSH File Transfer Protocol support + The SSH File Transfer Protocol (also Secure File Transfer Protocol, or SFTP) is a network protocol that provides file access, file transfer, and file management over any reliable data stream. + +This addon allows file access to data in it. @PLATFORM@ GPL-2.0 https://github.com/xbmc/vfs.sftp From 616abeb7d75afffdd2ad05ee8b26a64126ac21f7 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Mon, 6 Jan 2020 19:56:16 +0100 Subject: [PATCH 12/17] add addon icon --- vfs.sftp/icon.png | Bin 0 -> 9058 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 vfs.sftp/icon.png diff --git a/vfs.sftp/icon.png b/vfs.sftp/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..441ef8e7d231ad25a0bf197be4ca0bbf11d74e3b GIT binary patch literal 9058 z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U%S8WbPkqKCx;9U2NhHmKKh_*81D5*x3M7rdNnk_r>(E Date: Thu, 19 Dec 2019 00:05:07 +0100 Subject: [PATCH 13/17] change 'C' (*...) to 'C++' static_cast usage<*...>(...) --- src/SFTPFile.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SFTPFile.cpp b/src/SFTPFile.cpp index 69d011b..ae7292f 100644 --- a/src/SFTPFile.cpp +++ b/src/SFTPFile.cpp @@ -59,7 +59,7 @@ class ATTRIBUTE_HIDDEN CSFTPFile : public kodi::addon::CInstanceVFS ssize_t Read(void* context, void* buffer, size_t uiBufSize) override { - SFTPContext* ctx = (SFTPContext*)context; + SFTPContext* ctx = static_cast(context); if (ctx && ctx->session && ctx->sftp_handle) { int rc = ctx->session->Read(ctx->sftp_handle, buffer, uiBufSize); @@ -77,7 +77,7 @@ class ATTRIBUTE_HIDDEN CSFTPFile : public kodi::addon::CInstanceVFS int64_t Seek(void* context, int64_t iFilePosition, int whence) override { - SFTPContext* ctx = (SFTPContext*)context; + SFTPContext* ctx = static_cast(context); if (ctx && ctx->session && ctx->sftp_handle) { uint64_t position = 0; @@ -102,7 +102,7 @@ class ATTRIBUTE_HIDDEN CSFTPFile : public kodi::addon::CInstanceVFS int64_t GetLength(void* context) override { - SFTPContext* ctx = (SFTPContext*)context; + SFTPContext* ctx = static_cast(context); struct __stat64 buffer; if (ctx->session->Stat(ctx->file.c_str(), &buffer) != 0) return 0; @@ -112,7 +112,7 @@ class ATTRIBUTE_HIDDEN CSFTPFile : public kodi::addon::CInstanceVFS int64_t GetPosition(void* context) override { - SFTPContext* ctx = (SFTPContext*)context; + SFTPContext* ctx = static_cast(context); if (ctx->session && ctx->sftp_handle) return ctx->session->GetPosition(ctx->sftp_handle); @@ -142,7 +142,7 @@ class ATTRIBUTE_HIDDEN CSFTPFile : public kodi::addon::CInstanceVFS bool Close(void* context) override { - SFTPContext* ctx = (SFTPContext*)context; + SFTPContext* ctx = static_cast(context); if (ctx->session && ctx->sftp_handle) ctx->session->CloseFileHandle(ctx->sftp_handle); delete ctx; From 4af07e585acd3358d49bbe3c4218e4fcd2dd138d Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Thu, 19 Dec 2019 00:34:02 +0100 Subject: [PATCH 14/17] replace deprecated functions if ssh v0.8.0 and above is used ssh_is_server_known is now ssh_session_is_known_server ssh_write_knownhost is now ssh_session_update_known_hosts --- src/SFTPSession.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/SFTPSession.cpp b/src/SFTPSession.cpp index f504ba1..177c227 100644 --- a/src/SFTPSession.cpp +++ b/src/SFTPSession.cpp @@ -305,6 +305,35 @@ bool CSFTPSession::IsIdle() bool CSFTPSession::VerifyKnownHost(ssh_session session) { +#if !(LIBSSH_VERSION_MAJOR == 0 && LIBSSH_VERSION_MINOR < 8) + // Code used on libssh 0.8.0 and above + // See https://api.libssh.org/stable/deprecated.html + switch (ssh_session_is_known_server(session)) + { + case SSH_KNOWN_HOSTS_OK: + return true; + case SSH_KNOWN_HOSTS_CHANGED: + kodi::Log(ADDON_LOG_ERROR, "SFTPSession: Server that was known has changed"); + return false; + case SSH_KNOWN_HOSTS_OTHER: + kodi::Log(ADDON_LOG_ERROR, "SFTPSession: The host key for this server was not found but an other type of key exists. An attacker might change the default server key to confuse your client into thinking the key does not exist"); + return false; + case SSH_KNOWN_HOSTS_NOT_FOUND: + kodi::Log(ADDON_LOG_INFO, "SFTPSession: Server file was not found, creating a new one"); + case SSH_KNOWN_HOSTS_UNKNOWN: + kodi::Log(ADDON_LOG_INFO, "SFTPSession: Server unkown, we trust it for now"); + if (ssh_session_update_known_hosts(session) != SSH_OK) + { + kodi::Log(ADDON_LOG_ERROR, "CSFTPSession: Failed to save host '%s'", strerror(errno)); + return false; + } + + return true; + case SSH_KNOWN_HOSTS_ERROR: + kodi::Log(ADDON_LOG_ERROR, "SFTPSession: Failed to verify host '%s'", ssh_get_error(session)); + return false; + } +#else switch (ssh_is_server_known(session)) { case SSH_SERVER_KNOWN_OK: @@ -330,6 +359,7 @@ bool CSFTPSession::VerifyKnownHost(ssh_session session) kodi::Log(ADDON_LOG_ERROR, "SFTPSession: Failed to verify host '%s'", ssh_get_error(session)); return false; } +#endif return false; } From 8cf138581ee14d5656d8ca9da6fdab82a8efda08 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Thu, 19 Dec 2019 00:40:24 +0100 Subject: [PATCH 15/17] replace NULL with nullptr --- src/SFTPSession.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/SFTPSession.cpp b/src/SFTPSession.cpp index 177c227..1693029 100644 --- a/src/SFTPSession.cpp +++ b/src/SFTPSession.cpp @@ -113,7 +113,7 @@ sftp_file CSFTPSession::CreateFileHande(const std::string& file) else kodi::Log(ADDON_LOG_ERROR, "SFTPSession: Not connected and can't create file handle for '%s'", file.c_str()); - return NULL; + return nullptr; } void CSFTPSession::CloseFileHandle(sftp_file handle) @@ -128,7 +128,7 @@ bool CSFTPSession::GetDirectory(const std::string& base, const std::string& fold int sftp_error = SSH_FX_OK; if (m_connected) { - sftp_dir dir = NULL; + sftp_dir dir = nullptr; std::unique_lock lock(m_lock); m_LastActive = std::chrono::high_resolution_clock::now(); @@ -149,14 +149,14 @@ bool CSFTPSession::GetDirectory(const std::string& base, const std::string& fold bool read = true; while (read) { - sftp_attributes attributes = NULL; + sftp_attributes attributes = nullptr; lock.lock(); read = sftp_dir_eof(dir) == 0; attributes = sftp_readdir(m_sftp_session, dir); lock.unlock(); - if (attributes && (attributes->name == NULL || strcmp(attributes->name, "..") == 0 || strcmp(attributes->name, ".") == 0)) + if (attributes && (attributes->name == nullptr || strcmp(attributes->name, "..") == 0 || strcmp(attributes->name, ".") == 0)) { lock.lock(); sftp_attributes_free(attributes); @@ -176,7 +176,7 @@ bool CSFTPSession::GetDirectory(const std::string& base, const std::string& fold sftp_attributes_free(attributes); attributes = sftp_stat(m_sftp_session, CorrectPath(localPath).c_str()); lock.unlock(); - if (attributes == NULL) + if (attributes == nullptr) continue; } @@ -368,11 +368,11 @@ bool CSFTPSession::Connect(const VFSURL& url) { int timeout = SFTP_TIMEOUT; m_connected = false; - m_session = NULL; - m_sftp_session = NULL; + m_session = nullptr; + m_sftp_session = nullptr; m_session=ssh_new(); - if (m_session == NULL) + if (m_session == nullptr) { kodi::Log(ADDON_LOG_ERROR, "SFTPSession: Failed to initialize session for host '%s'", url.hostname); return false; @@ -421,17 +421,17 @@ bool CSFTPSession::Connect(const VFSURL& url) } int noAuth = SSH_AUTH_DENIED; - if ((noAuth = ssh_userauth_none(m_session, NULL)) == SSH_AUTH_ERROR) + if ((noAuth = ssh_userauth_none(m_session, nullptr)) == SSH_AUTH_ERROR) { kodi::Log(ADDON_LOG_ERROR, "SFTPSession: Failed to authenticate via guest '%s'", ssh_get_error(m_session)); return false; } - int method = ssh_userauth_list(m_session, NULL); + int method = ssh_userauth_list(m_session, nullptr); // Try to authenticate with public key first int publicKeyAuth = SSH_AUTH_DENIED; - if (method & SSH_AUTH_METHOD_PUBLICKEY && (publicKeyAuth = ssh_userauth_publickey_auto(m_session, NULL, NULL)) == SSH_AUTH_ERROR) + if (method & SSH_AUTH_METHOD_PUBLICKEY && (publicKeyAuth = ssh_userauth_publickey_auto(m_session, nullptr, nullptr)) == SSH_AUTH_ERROR) { kodi::Log(ADDON_LOG_ERROR, "SFTPSession: Failed to authenticate via publickey '%s'", ssh_get_error(m_session)); return false; @@ -457,7 +457,7 @@ bool CSFTPSession::Connect(const VFSURL& url) { m_sftp_session = sftp_new(m_session); - if (m_sftp_session == NULL) + if (m_sftp_session == nullptr) { kodi::Log(ADDON_LOG_ERROR, "SFTPSession: Failed to initialize channel '%s'", ssh_get_error(m_session)); return false; @@ -490,8 +490,8 @@ void CSFTPSession::Disconnect() ssh_free(m_session); } - m_sftp_session = NULL; - m_session = NULL; + m_sftp_session = nullptr; + m_session = nullptr; } /*! @@ -544,7 +544,7 @@ CSFTPSessionPtr CSFTPSessionManager::CreateSession(const VFSURL& url) std::string key = std::string(url2.username) + ":" + url2.password + "@" + url2.hostname + ":" + portstr; CSFTPSessionPtr ptr = sessions[key]; - if (ptr == NULL) + if (ptr == nullptr) { ptr = CSFTPSessionPtr(new CSFTPSession(url2)); sessions[key] = ptr; From 4bda9e862c383ac6280ad8999f9a7842f747c66a Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Thu, 19 Dec 2019 00:43:09 +0100 Subject: [PATCH 16/17] remove from CMakeLists.txt set of C++11, done by Kodi cmake itself --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5374a3..1e66493 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,6 @@ cmake_minimum_required(VERSION 3.5) project(vfs.sftp) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) find_package(Kodi REQUIRED) From b156112bd42a047bc109a4cada690ac00e589539 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Thu, 19 Dec 2019 00:44:50 +0100 Subject: [PATCH 17/17] increase version to 1.0.4 --- vfs.sftp/addon.xml.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vfs.sftp/addon.xml.in b/vfs.sftp/addon.xml.in index 2ed8fb7..79878e9 100644 --- a/vfs.sftp/addon.xml.in +++ b/vfs.sftp/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@