Commit e3031729 authored by Soomin Lee's avatar Soomin Lee

Add smb2 patch

(backported from commit 5ebd16e4)
parent 07eb7b8e
From 2f150030470b72b65a323b415e232cef6263b5a0 Mon Sep 17 00:00:00 2001
From e1d54e02c93c6127deef5e6be55f2ebd2ffce25d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Thu, 18 Dec 2014 22:14:55 +0100
Subject: [PATCH 01/25] arm_neon: work-around libtool issue
Subject: [PATCH 01/26] arm_neon: work-around libtool issue
---
modules/arm_neon/Makefile.am | 2 ++
......
From 4f106a840a01ec607c5c45be53b8a10366c3a13e Mon Sep 17 00:00:00 2001
From e3a269e75ce4fae45ca9c1ee2e7556d045236ca7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Wed, 10 Dec 2014 22:14:55 +0100
Subject: [PATCH 02/25] disable neon volume plugin
Subject: [PATCH 02/26] disable neon volume plugin
---
modules/arm_neon/Makefile.am | 1 -
......
From a872eb73e7f8cfee1c89cdf344a2bd6a9c97b1c0 Mon Sep 17 00:00:00 2001
From 2e1e21f96b8a4b30d90b5e69f420590f4a5536ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Fri, 22 Jul 2016 11:11:44 +0200
Subject: [PATCH 03/25] Enable System DL
Subject: [PATCH 03/26] Enable System DL
---
contrib/src/ffmpeg/patch-as-patch-can.patch | 20 ++++++++++++++++++++
......
From 21bd6a724177eae2474ac71c000d9030876d4969 Mon Sep 17 00:00:00 2001
From 58b7ef19ba8b1c19f9e6c730ccd5c49f0e4e9058 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Fri, 16 Sep 2016 15:51:10 +0200
Subject: [PATCH 04/25] http: add vlc_http_cookies_clear
Subject: [PATCH 04/26] http: add vlc_http_cookies_clear
Clear all cookies without deleting the jar.
---
......
From ca9c67b0d095332e76c1d4b9b40873f3df6f1941 Mon Sep 17 00:00:00 2001
From 0e70de7034f46fde9505a949b4d0a71cf83d3614 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Fri, 16 Sep 2016 15:51:11 +0200
Subject: [PATCH 05/25] libvlc_media: add cookie_jar API
Subject: [PATCH 05/26] libvlc_media: add cookie_jar API
---
include/vlc/libvlc_media.h | 35 +++++++++++++++++++++++++++++++++++
......
From fb8203c1e73d37f8cc95bdf0f786e5a102684bf7 Mon Sep 17 00:00:00 2001
From 859b996c7176dbbfb5c7f0016023996c5760d4f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Sun, 7 Dec 2014 20:02:18 +0100
Subject: [PATCH 06/25] contrib/gcrypt: work-around a libtool limitation
Subject: [PATCH 06/26] contrib/gcrypt: work-around a libtool limitation
---
contrib/src/gcrypt/rules.mak | 1 +
......
From effc78557ff4dc6a42e12cd0b64342aa860020a3 Mon Sep 17 00:00:00 2001
From 94a9ab50e5a9fc367e77d1bae06ba168dc6f2680 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Sat, 3 Oct 2015 22:45:14 +0200
Subject: [PATCH 07/25] contrib/gcrypt: fix tvOS compilation
Subject: [PATCH 07/26] contrib/gcrypt: fix tvOS compilation
---
.../src/gcrypt/fix-sha1-ssse3-for-clang.patch | 16 ++++++++++++++++
......
From 13658e3b14706343eaac6e86f97bdbdc4b8c601e Mon Sep 17 00:00:00 2001
From 78234e81cd15d2a189a2874f05628867d3e11875 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Mon, 12 Sep 2016 17:03:37 +0200
Subject: [PATCH 08/25] contrib/gcrypt: update patches
Subject: [PATCH 08/26] contrib/gcrypt: update patches
---
.../src/gcrypt/fix-sha1-ssse3-for-clang.patch | 308 +++++++++++++++++-
......
From c20415c39eb7f13738a7536c4fcb86d52fd286d5 Mon Sep 17 00:00:00 2001
From 4fb594126a9825ada576fd3a81e43fdf294bb115 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Mon, 17 Jul 2017 17:03:24 +0200
Subject: [PATCH 09/25] Replace thread local with pthread TSD
Subject: [PATCH 09/26] Replace thread local with pthread TSD
---
src/misc/interrupt.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
......
From 24dc4bc8ee931bb0766e2c2e6f040421eecd269d Mon Sep 17 00:00:00 2001
From e604e5cca7c5b68b2fe6458b9824e88be0e589cf Mon Sep 17 00:00:00 2001
From: Carola Nitz <nitz.carola@googlemail.com>
Date: Fri, 29 Sep 2017 14:49:02 +0200
Subject: [PATCH 10/25] contrib: use live555 version that is compatible with
Subject: [PATCH 10/26] contrib: use live555 version that is compatible with
LGPL2
---
......
From 5da293c4d3fa9621851beeb93e5c7b090a0078b1 Mon Sep 17 00:00:00 2001
From 7c2e113c282d9367dbd74fceef8d4c3022f688bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <felix@feepk.net>
Date: Sun, 17 Dec 2017 18:05:40 +0100
Subject: [PATCH 11/25] libvlc: add a basic API to change freetype's color,
Subject: [PATCH 11/26] libvlc: add a basic API to change freetype's color,
bold, font and size variables on-the-fly
---
......
From 188b586bbebfb289f522802f489076721391fa0c Mon Sep 17 00:00:00 2001
From 6676c183324c28f12c839b7b7afdbccb7521c7e8 Mon Sep 17 00:00:00 2001
From: Carola Nitz <nitz.carola@googlemail.com>
Date: Fri, 23 Feb 2018 13:16:41 +0100
Subject: [PATCH 12/25] Work around lack of __thread storage qualifier on old
Subject: [PATCH 12/26] Work around lack of __thread storage qualifier on old
macOS
---
......
From 1de70527b032cdd82be21dbb4d0fa9846ee5018a Mon Sep 17 00:00:00 2001
From 619d4d19b1b39110a8340554cc8953cfba1c6550 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
Date: Mon, 26 Mar 2018 16:44:44 +0200
Subject: [PATCH 13/25] modules:common: Use the full module name as MODULE_NAME
Subject: [PATCH 13/26] modules:common: Use the full module name as MODULE_NAME
This avoid conflicts when linking modules staticly on platforms that don't
have objdump
......
From 83b4903d7a450ab8e66ef3f8ec0958f2edbd66b1 Mon Sep 17 00:00:00 2001
From e62a30891d250fcd1c6690b3b5ecb978a962bf5a Mon Sep 17 00:00:00 2001
From: Luis Fernandes <zipleen@gmail.com>
Date: Mon, 30 Apr 2018 14:33:08 +0100
Subject: [PATCH 14/25] add auto deinterlacer-mode which is also valid
Subject: [PATCH 14/26] add auto deinterlacer-mode which is also valid
---
lib/video.c | 3 ++-
......
From 2b75844b58d3d1ce45a6b0a6013bc368b6097ae0 Mon Sep 17 00:00:00 2001
From b7e0e7d11c8196324f45a928d01ae9b0df375303 Mon Sep 17 00:00:00 2001
From: Luis Fernandes <zipleen@gmail.com>
Date: Wed, 9 May 2018 10:44:43 +0100
Subject: [PATCH 15/25] Users will be able to change the deinterlace mode
Subject: [PATCH 15/26] Users will be able to change the deinterlace mode
without forcing it.
---
......
From eeeb15dbfd3d65e7c2dc9d83503cfd0472536e92 Mon Sep 17 00:00:00 2001
From 9da6ee35ee79f0202833b78fa491817be7d63978 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Tue, 27 Mar 2018 16:49:34 +0200
Subject: [PATCH 16/25] contrib: ffmpeg: enable videotoolbox encoder
Subject: [PATCH 16/26] contrib: ffmpeg: enable videotoolbox encoder
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
......
From aa9c3123921049670be603e9d0ed905b1ff43455 Mon Sep 17 00:00:00 2001
From 6b8fa092f6b1c25a1901c4c510b1e341d016783c Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Tue, 27 Mar 2018 16:52:35 +0200
Subject: [PATCH 17/25] chromecast: use vt encoder from avcodec
Subject: [PATCH 17/26] chromecast: use vt encoder from avcodec
---
modules/stream_out/chromecast/cast.cpp | 13 +++++++++++++
......
From 237824957bbb38de8e170e3e477330b014f2c089 Mon Sep 17 00:00:00 2001
From 0751562da380cd3632569793b6d23bc270d45f4c Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Mon, 18 Jun 2018 12:31:13 +0200
Subject: [PATCH 18/25] ffmpeg: backport vtenc patches
Subject: [PATCH 18/26] ffmpeg: backport vtenc patches
---
...lboxenc-fix-mutex-cond-leak-in-error.patch | 35 ++++++
......
From f1123cd046a2950c977175f6bc6cc96782c31717 Mon Sep 17 00:00:00 2001
From e151b6e7262e1e32df4f934234076e7b2f4594dd Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Wed, 17 Jan 2018 10:06:13 +0200
Subject: [PATCH 19/25] core: expose config_AutoSaveConfigFile
Subject: [PATCH 19/26] core: expose config_AutoSaveConfigFile
---
include/vlc_configuration.h | 2 ++
......
From b9c4f2f45f9abcb5e4cd22933f0806afea77b291 Mon Sep 17 00:00:00 2001
From f3bc8326ad9c0bfac27959a26818c4554ea11b82 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Wed, 17 Jan 2018 10:06:13 +0200
Subject: [PATCH 20/25] lib: save configuration after playback/parse
Subject: [PATCH 20/26] lib: save configuration after playback/parse
The configuration is also saved when the libvlc instance is terminated but this
doesn't happen often. Indeed, apps using libvlc will generally hold the libvlc
......
From 549df2379c1ff1896fd63c708d4f802366b4e963 Mon Sep 17 00:00:00 2001
From 657abc097cd6cd07cc411f858f9e8c8986daa982 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <felix@feepk.net>
Date: Mon, 10 Sep 2018 20:55:11 +0200
Subject: [PATCH 21/25] http access: retain auth struct for the runtime of the
Subject: [PATCH 21/26] http access: retain auth struct for the runtime of the
module
Previously, it was retained for a given connection only, so all information needed for a digest login was lost as soon as the module was reconnecting due to the expected 401 on attempted basic login
......
From 3bf2a0f10af8987e96ee4033e9ba82895e1dace7 Mon Sep 17 00:00:00 2001
From c8295b5931be6d8a779e705755813b82f619d0d3 Mon Sep 17 00:00:00 2001
From: Soomin Lee <bubu@mikan.io>
Date: Wed, 31 Oct 2018 10:08:55 +0100
Subject: [PATCH 22/25] libvlc: media_player: Add record method
Subject: [PATCH 22/26] libvlc: media_player: Add record method
---
include/vlc/libvlc_media_player.h | 13 +++++++++++++
......
From b608537b37e1944f42d56762b985a0663c7c4c61 Mon Sep 17 00:00:00 2001
From 209ee5cd04c91c5414d96d35bc9b6a60d9bf2a91 Mon Sep 17 00:00:00 2001
From: Soomin Lee <bubu@mikan.io>
Date: Thu, 27 Sep 2018 18:40:39 +0200
Subject: [PATCH 23/25] libvlc: events: Add callbacks for record
Subject: [PATCH 23/26] libvlc: events: Add callbacks for record
---
include/vlc/libvlc_events.h | 9 +++++++++
......
From a869647a6e8479d9e5963ed19fffdf5a3961723d Mon Sep 17 00:00:00 2001
From ff2937394b681e3362d06bb723825f2b3c680819 Mon Sep 17 00:00:00 2001
From: Soomin Lee <bubu@mikan.io>
Date: Mon, 1 Oct 2018 15:37:57 +0200
Subject: [PATCH 24/25] access_output: file: Add error dialog for write/open
Subject: [PATCH 24/26] access_output: file: Add error dialog for write/open
---
modules/access_output/file.c | 8 ++++++++
......
From 1cb6affcfdd0595147c19e2dc2114cf6505ef707 Mon Sep 17 00:00:00 2001
From f538091a0b09dbfbf0afcdd0605b21ce751e3685 Mon Sep 17 00:00:00 2001
From: Alexandre Janniaux <alexandre.janniaux@gmail.com>
Date: Wed, 28 Nov 2018 18:27:16 +0100
Subject: [PATCH 25/25] transcode: add support for mutliple venc parameters
Subject: [PATCH 25/26] transcode: add support for mutliple venc parameters
Add support for multiple venc parameters for transcoding. Venc
parameters are tested in th given order and fallback if the encoder
......
From c8ccacbf8154d63e88b817a294740778be1a1d9a Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Fri, 13 Apr 2018 16:15:16 +0200
Subject: [PATCH 26/26] access: add smb2 module
Using libsmb2 from Ronnie Sahlberg https://github.com/sahlberg/libsmb2
This is LGPL 2.1 fully async lib for accessing SMB2 and SMB3 shares.
This module use the async feature of the libsmb2 lib with the vlc interrupt
mechanism, therefore every network requests are cancellable almost immediately.
The 2.0.0 version is required since this version drop OpenSSL dependency and
allow to use Builtin NTLMSSP authentication instead of libkrb5.
---
configure.ac | 14 +-
...ot-exist-on-darwin-use-posix-ENODEV-.patch | 25 +
contrib/src/smb2/0001-master-backport.patch | 330 ++++++++
contrib/src/smb2/SHA512SUMS | 1 +
contrib/src/smb2/rules.mak | 29 +
modules/MODULES_LIST | 1 +
modules/access/Makefile.am | 11 +
modules/access/smb2.c | 717 ++++++++++++++++++
po/POTFILES.in | 1 +
9 files changed, 1128 insertions(+), 1 deletion(-)
create mode 100644 contrib/src/smb2/0001-ENOMEDIUM-does-not-exist-on-darwin-use-posix-ENODEV-.patch
create mode 100644 contrib/src/smb2/0001-master-backport.patch
create mode 100644 contrib/src/smb2/SHA512SUMS
create mode 100644 contrib/src/smb2/rules.mak
create mode 100644 modules/access/smb2.c
diff --git a/configure.ac b/configure.ac
index 32a45bac65..4c6305786a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1854,7 +1854,14 @@ AS_IF([test "${SYS}" = "mingw32" -a "${enable_winstore_app}" != "yes"], [ VLC_AD
dnl
dnl liBDSM access module
dnl
-PKG_ENABLE_MODULES_VLC([DSM], [dsm], [libdsm >= 0.2.0], [libdsm SMB/CIFS access/sd module], [auto])
+AM_CONDITIONAL(HAVE_DSM, [test "$AS_TR_SH(with_dsm)" = "yes"])
+PKG_WITH_MODULES([DSM], [libdsm >= 0.2.0], [
+ VLC_ADD_PLUGIN([dsm])
+ VLC_ADD_CFLAGS([dsm], [$DSM_CFLAGS])
+ VLC_ADD_LIBS([dsm], [$DSM_LIBS])
+ have_dsm="yes"
+ ],,[libdsm SMB/CIFS access/sd module], [auto])
+AM_CONDITIONAL([HAVE_DSM], [test "${have_dsm}" = "yes"])
dnl
dnl sftp access support
@@ -1866,6 +1873,11 @@ dnl nfs access support
dnl
PKG_ENABLE_MODULES_VLC([NFS], [nfs], [libnfs >= 1.10.0], (support nfs protocol via libnfs), [auto])
+dnl
+dnl smb2 access support
+dnl
+PKG_ENABLE_MODULES_VLC([SMB2], [smb2], [libsmb2 >= 2.0.0], (support smb2 protocol via libsmb2), [auto])
+
dnl
dnl Video4Linux 2
dnl
diff --git a/contrib/src/smb2/0001-ENOMEDIUM-does-not-exist-on-darwin-use-posix-ENODEV-.patch b/contrib/src/smb2/0001-ENOMEDIUM-does-not-exist-on-darwin-use-posix-ENODEV-.patch
new file mode 100644
index 0000000000..93763dd660
--- /dev/null
+++ b/contrib/src/smb2/0001-ENOMEDIUM-does-not-exist-on-darwin-use-posix-ENODEV-.patch
@@ -0,0 +1,25 @@
+From 2256d19bc9fead528bac900d894d65e9b030f7f8 Mon Sep 17 00:00:00 2001
+From: "S. Davilla" <davilla@4pi.com>
+Date: Mon, 22 Oct 2018 20:53:15 -0400
+Subject: [PATCH] ENOMEDIUM does not exist on darwin, use posix ENODEV instead
+
+---
+ lib/errors.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/errors.c b/lib/errors.c
+index f2696c0..3612f9a 100644
+--- a/lib/errors.c
++++ b/lib/errors.c
+@@ -218,7 +218,7 @@ int nterror_to_errno(uint32_t status) {
+ case SMB2_STATUS_MEDIA_WRITE_PROTECTED:
+ return EROFS;
+ case SMB2_STATUS_NO_MEDIA_IN_DEVICE:
+- return ENOMEDIUM;
++ return ENODEV;
+ case SMB2_STATUS_DATA_ERROR:
+ case SMB2_STATUS_CRC_ERROR:
+ case SMB2_STATUS_DEVICE_DATA_ERROR:
+--
+2.17.2 (Apple Git-113)
+
diff --git a/contrib/src/smb2/0001-master-backport.patch b/contrib/src/smb2/0001-master-backport.patch
new file mode 100644
index 0000000000..0f9cf7cf62
--- /dev/null
+++ b/contrib/src/smb2/0001-master-backport.patch
@@ -0,0 +1,330 @@
+From 49525025f8c91ae14e5fe3cfea0dc7948b7f5480 Mon Sep 17 00:00:00 2001
+From: Thomas Guillem <thomas@gllm.fr>
+Date: Tue, 12 Feb 2019 12:42:37 +0100
+Subject: [PATCH] master-backport
+
+Waiting for a new release, including the following patches:
+
+libsmb_error patch
+Delete libsmb2_error.latest.patch
+Allow passing NULL to smb2_set_password
+Add more error status
+Map more EACCESS error status
+---
+ include/smb2/smb2-errors.h | 50 +++++++++++
+ lib/errors.c | 178 +++++++++++++++++++++++++++++++++++--
+ lib/init.c | 4 +
+ 3 files changed, 223 insertions(+), 9 deletions(-)
+
+diff --git a/include/smb2/smb2-errors.h b/include/smb2/smb2-errors.h
+index 49c5d5c..3b741e7 100644
+--- a/include/smb2/smb2-errors.h
++++ b/include/smb2/smb2-errors.h
+@@ -35,13 +35,63 @@
+ /* Error codes */
+ #define SMB2_STATUS_SUCCESS 0x00000000
+ #define SMB2_STATUS_PENDING 0x00000103
++#define SMB2_STATUS_SMB_BAD_FID 0x00060001
+ #define SMB2_STATUS_NO_MORE_FILES 0x80000006
++#define SMB2_STATUS_NOT_IMPLEMENTED 0xC0000002
++#define SMB2_STATUS_INVALID_HANDLE 0xC0000008
+ #define SMB2_STATUS_INVALID_PARAMETER 0xC000000d
++#define SMB2_STATUS_NO_SUCH_DEVICE 0xC000000E
++#define SMB2_STATUS_NO_SUCH_FILE 0xC000000F
++#define SMB2_STATUS_INVALID_DEVICE_REQUEST 0xC0000010
+ #define SMB2_STATUS_END_OF_FILE 0xC0000011
++#define SMB2_STATUS_NO_MEDIA_IN_DEVICE 0xC0000013
+ #define SMB2_STATUS_MORE_PROCESSING_REQUIRED 0xC0000016
++#define SMB2_STATUS_INVALID_LOCK_SEQUENCE 0xC000001E
++#define SMB2_STATUS_INVALID_VIEW_SIZE 0xC000001F
++#define SMB2_STATUS_ALREADY_COMMITTED 0xC0000021
+ #define SMB2_STATUS_ACCESS_DENIED 0xC0000022
++#define SMB2_STATUS_OBJECT_TYPE_MISMATCH 0xC0000024
+ #define SMB2_STATUS_OBJECT_NAME_NOT_FOUND 0xC0000034
++#define SMB2_STATUS_OBJECT_NAME_COLLISION 0xC0000035
++#define SMB2_STATUS_PORT_DISCONNECTED 0xC0000037
++#define SMB2_STATUS_OBJECT_PATH_INVALID 0xC0000039
++#define SMB2_STATUS_OBJECT_PATH_NOT_FOUND 0xC000003A
++#define SMB2_STATUS_OBJECT_PATH_SYNTAX_BAD 0xC000003B
++#define SMB2_STATUS_DATA_ERROR 0xC000003E
++#define SMB2_STATUS_CRC_ERROR 0xC000003F
++#define SMB2_STATUS_SECTION_TOO_BIG 0xC0000040
++#define SMB2_STATUS_PORT_CONNECTION_REFUSED 0xC0000041
++#define SMB2_STATUS_INVALID_PORT_HANDLE 0xC0000042
++#define SMB2_STATUS_SHARING_VIOLATION 0xC0000043
++#define SMB2_STATUS_THREAD_IS_TERMINATING 0xC000004B
++#define SMB2_STATUS_FILE_LOCK_CONFLICT 0xC0000054
++#define SMB2_STATUS_LOCK_NOT_GRANTED 0xC0000055
++#define SMB2_STATUS_DELETE_PENDING 0xC0000056
++#define SMB2_STATUS_PRIVILEGE_NOT_HELD 0xC0000061
+ #define SMB2_STATUS_LOGON_FAILURE 0xC000006d
++#define SMB2_STATUS_ACCOUNT_RESTRICTION 0xC000006E
++#define SMB2_STATUS_INVALID_LOGON_HOURS 0xC000006F
++#define SMB2_STATUS_PASSWORD_EXPIRED 0xC0000071
++#define SMB2_STATUS_ACCOUNT_DISABLED 0xC0000072
++#define SMB2_STATUS_DISK_FULL 0xC000007F
++#define SMB2_STATUS_TOO_MANY_PAGING_FILES 0xC0000097
++#define SMB2_STATUS_DFS_EXIT_PATH_FOUND 0xC000009B
++#define SMB2_STATUS_DEVICE_DATA_ERROR 0xC000009C
++#define SMB2_STATUS_MEDIA_WRITE_PROTECTED 0xC00000A2
++#define SMB2_STATUS_ILLEGAL_FUNCTION 0xC00000AF
++#define SMB2_STATUS_PIPE_DISCONNECTED 0xC00000B0
++#define SMB2_STATUS_FILE_IS_A_DIRECTORY 0xC00000BA
++#define SMB2_STATUS_NETWORK_ACCESS_DENIED 0xC00000CA
+ #define SMB2_STATUS_BAD_NETWORK_NAME 0xC00000CC
++#define SMB2_STATUS_NOT_SAME_DEVICE 0xC00000D4
++#define SMB2_STATUS_FILE_RENAMED 0xC00000D5
++#define SMB2_STATUS_REDIRECTOR_NOT_STARTED 0xC00000FB
++#define SMB2_STATUS_DIRECTORY_NOT_EMPTY 0xC0000101
+ #define SMB2_STATUS_NOT_A_DIRECTORY 0xC0000103
++#define SMB2_STATUS_PROCESS_IS_TERMINATING 0xC000010A
++#define SMB2_STATUS_TOO_MANY_OPENED_FILES 0xC000011F
++#define SMB2_STATUS_CANNOT_DELETE 0xC0000121
++#define SMB2_STATUS_FILE_DELETED 0xC0000123
+ #define SMB2_STATUS_FILE_CLOSED 0xC0000128
++#define SMB2_STATUS_INSUFF_SERVER_RESOURCES 0xC0000205
++#define SMB2_STATUS_HANDLE_NOT_CLOSABLE 0xC0000235
+diff --git a/lib/errors.c b/lib/errors.c
+index 68150a0..2e1648d 100644
+--- a/lib/errors.c
++++ b/lib/errors.c
+@@ -30,26 +30,124 @@ const char *nterror_to_str(uint32_t status) {
+ return "STATUS_PENDING";
+ case SMB2_STATUS_NO_MORE_FILES:
+ return "STATUS_NO_MORE_FILES";
++ case SMB2_STATUS_NOT_IMPLEMENTED:
++ return "STATUS_NOT_IMPLEMENTED";
++ case SMB2_STATUS_INVALID_HANDLE:
++ return "STATUS_INVALID_HANDLE";
++ case SMB2_STATUS_INVALID_PARAMETER:
++ return "STATUS_INVALID_PARAMETER";
++ case SMB2_STATUS_NO_SUCH_DEVICE:
++ return "STATUS_NO_SUCH_DEVICE";
++ case SMB2_STATUS_NO_SUCH_FILE:
++ return "STATUS_NO_SUCH_FILE";
++ case SMB2_STATUS_INVALID_DEVICE_REQUEST:
++ return "STATUS_INVALID_DEVICE_REQUEST";
++ case SMB2_STATUS_END_OF_FILE:
++ return "STATUS_END_OF_FILE";
++ case SMB2_STATUS_NO_MEDIA_IN_DEVICE:
++ return "STATUS_NO_MEDIA_IN_DEVICE";
+ case SMB2_STATUS_MORE_PROCESSING_REQUIRED:
+ return "STATUS_MORE_PROCESSING_REQUIRED";
++ case SMB2_STATUS_INVALID_LOCK_SEQUENCE:
++ return "STATUS_INVALID_LOCK_SEQUENCE";
++ case SMB2_STATUS_INVALID_VIEW_SIZE:
++ return "STATUS_INVALID_VIEW_SIZE";
++ case SMB2_STATUS_ALREADY_COMMITTED:
++ return "STATUS_ALREADY_COMMITTED";
+ case SMB2_STATUS_ACCESS_DENIED:
+ return "STATUS_ACCESS_DENIED";
++ case SMB2_STATUS_OBJECT_TYPE_MISMATCH:
++ return "STATUS_OBJECT_TYPE_MISMATCH";
++ case SMB2_STATUS_OBJECT_NAME_NOT_FOUND:
++ return "STATUS_OBJECT_NAME_NOT_FOUND";
++ case SMB2_STATUS_OBJECT_NAME_COLLISION:
++ return "STATUS_OBJECT_NAME_COLLISION";
++ case SMB2_STATUS_PORT_DISCONNECTED:
++ return "STATUS_PORT_DISCONNECTED";
++ case SMB2_STATUS_OBJECT_PATH_INVALID:
++ return "STATUS_OBJECT_PATH_INVALID";
++ case SMB2_STATUS_OBJECT_PATH_NOT_FOUND:
++ return "STATUS_OBJECT_PATH_NOT_FOUND";
++ case SMB2_STATUS_OBJECT_PATH_SYNTAX_BAD:
++ return "STATUS_OBJECT_PATH_SYNTAX_BAD";
++ case SMB2_STATUS_DATA_ERROR:
++ return "STATUS_DATA_ERROR";
++ case SMB2_STATUS_CRC_ERROR:
++ return "STATUS_CRC_ERROR";
++ case SMB2_STATUS_SECTION_TOO_BIG:
++ return "STATUS_SECTION_TOO_BIG";
++ case SMB2_STATUS_PORT_CONNECTION_REFUSED:
++ return "STATUS_PORT_CONNECTION_REFUSED";
++ case SMB2_STATUS_INVALID_PORT_HANDLE:
++ return "STATUS_INVALID_PORT_HANDLE";
++ case SMB2_STATUS_SHARING_VIOLATION:
++ return "STATUS_SHARING_VIOLATION";
++ case SMB2_STATUS_THREAD_IS_TERMINATING:
++ return "STATUS_THREAD_IS_TERMINATING";
++ case SMB2_STATUS_FILE_LOCK_CONFLICT:
++ return "STATUS_FILE_LOCK_CONFLICT";
++ case SMB2_STATUS_LOCK_NOT_GRANTED:
++ return "STATUS_LOCK_NOT_GRANTED";
++ case SMB2_STATUS_DELETE_PENDING:
++ return "STATUS_DELETE_PENDING";
++ case SMB2_STATUS_PRIVILEGE_NOT_HELD:
++ return "STATUS_PRIVILEGE_NOT_HELD";
+ case SMB2_STATUS_LOGON_FAILURE:
+ return "STATUS_LOGON_FAILURE";
++ case SMB2_STATUS_ACCOUNT_RESTRICTION:
++ return "STATUS_ACCOUNT_RESTRICTION";
++ case SMB2_STATUS_INVALID_LOGON_HOURS:
++ return "STATUS_INVALID_LOGON_HOURS";
++ case SMB2_STATUS_PASSWORD_EXPIRED:
++ return "STATUS_PASSWORD_EXPIRED";
++ case SMB2_STATUS_ACCOUNT_DISABLED:
++ return "STATUS_ACCOUNT_DISABLED";
++ case SMB2_STATUS_DISK_FULL:
++ return "STATUS_DISK_FULL";
++ case SMB2_STATUS_TOO_MANY_PAGING_FILES:
++ return "STATUS_TOO_MANY_PAGING_FILES";
++ case SMB2_STATUS_DFS_EXIT_PATH_FOUND:
++ return "STATUS_DFS_EXIT_PATH_FOUND";
++ case SMB2_STATUS_DEVICE_DATA_ERROR:
++ return "STATUS_DEVICE_DATA_ERROR";
++ case SMB2_STATUS_MEDIA_WRITE_PROTECTED:
++ return "STATUS_MEDIA_WRITE_PROTECTED";
++ case SMB2_STATUS_ILLEGAL_FUNCTION:
++ return "STATUS_ILLEGAL_FUNCTION";
++ case SMB2_STATUS_PIPE_DISCONNECTED:
++ return "STATUS_PIPE_DISCONNECTED";
++ case SMB2_STATUS_FILE_IS_A_DIRECTORY:
++ return "STATUS_FILE_IS_A_DIRECTORY";
++ case SMB2_STATUS_NETWORK_ACCESS_DENIED:
++ return "STATUS_NETWORK_ACCESS_DENIED";
+ case SMB2_STATUS_BAD_NETWORK_NAME:
+ return "STATUS_BAD_NETWORK_NAME";
++ case SMB2_STATUS_NOT_SAME_DEVICE:
++ return "STATUS_NOT_SAME_DEVICE";
++ case SMB2_STATUS_FILE_RENAMED:
++ return "STATUS_FILE_RENAMED";
++ case SMB2_STATUS_REDIRECTOR_NOT_STARTED:
++ return "STATUS_REDIRECTOR_NOT_STARTED";
++ case SMB2_STATUS_DIRECTORY_NOT_EMPTY:
++ return "STATUS_DIRECTORY_NOT_EMPTY";
+ case SMB2_STATUS_NOT_A_DIRECTORY:
+ return "STATUS_NOT_A_DIRECTORY";
+- case SMB2_STATUS_INVALID_PARAMETER:
+- return "STATUS_INVALID_PARAMETER";
+- case SMB2_STATUS_END_OF_FILE:
+- return "STATUS_END_OF_FILE";
++ case SMB2_STATUS_PROCESS_IS_TERMINATING:
++ return "STATUS_PROCESS_IS_TERMINATING";
++ case SMB2_STATUS_TOO_MANY_OPENED_FILES:
++ return "STATUS_TOO_MANY_OPENED_FILES";
++ case SMB2_STATUS_CANNOT_DELETE:
++ return "STATUS_CANNOT_DELETE";
++ case SMB2_STATUS_FILE_DELETED:
++ return "STATUS_FILE_DELETED";
+ case SMB2_STATUS_FILE_CLOSED:
+ return "STATUS_FILE_CLOSED";
+- case SMB2_STATUS_OBJECT_NAME_NOT_FOUND:
+- return "STATUS_OBJECT_NAME_NOT_FOUND";
++ case SMB2_STATUS_INSUFF_SERVER_RESOURCES:
++ return "STATUS_INSUFF_SERVER_RESOURCES";
++ case SMB2_STATUS_HANDLE_NOT_CLOSABLE:
++ return "STATUS_HANDLE_NOT_CLOSABLE";
+ default:
+- return "Unknown";
++ return "Unknown";
+ }
+ }
+
+@@ -58,25 +156,87 @@ int nterror_to_errno(uint32_t status) {
+ case SMB2_STATUS_SUCCESS:
+ case SMB2_STATUS_END_OF_FILE:
+ return 0;
++ case SMB2_STATUS_PENDING:
++ return EAGAIN;
++ case SMB2_STATUS_NO_SUCH_FILE:
++ case SMB2_STATUS_NO_SUCH_DEVICE:
+ case SMB2_STATUS_BAD_NETWORK_NAME:
+ case SMB2_STATUS_OBJECT_NAME_NOT_FOUND:
++ case SMB2_STATUS_OBJECT_PATH_INVALID:
++ case SMB2_STATUS_OBJECT_PATH_NOT_FOUND:
++ case SMB2_STATUS_OBJECT_PATH_SYNTAX_BAD:
++ case SMB2_STATUS_DFS_EXIT_PATH_FOUND:
++ case SMB2_STATUS_REDIRECTOR_NOT_STARTED:
+ return ENOENT;
+ case SMB2_STATUS_FILE_CLOSED:
++ case SMB2_STATUS_SMB_BAD_FID:
++ case SMB2_STATUS_INVALID_HANDLE:
++ case SMB2_STATUS_OBJECT_TYPE_MISMATCH:
++ case SMB2_STATUS_PORT_DISCONNECTED:
++ case SMB2_STATUS_INVALID_PORT_HANDLE:
++ case SMB2_STATUS_HANDLE_NOT_CLOSABLE:
+ return EBADF;
+ case SMB2_STATUS_MORE_PROCESSING_REQUIRED:
+ return EAGAIN;
+ case SMB2_STATUS_ACCESS_DENIED:
++ case SMB2_STATUS_NETWORK_ACCESS_DENIED:
++ case SMB2_STATUS_ACCOUNT_RESTRICTION:
++ case SMB2_STATUS_INVALID_LOGON_HOURS:
++ case SMB2_STATUS_PASSWORD_EXPIRED:
++ case SMB2_STATUS_ACCOUNT_DISABLED:
+ return EACCES;
+- case SMB2_STATUS_PENDING:
+- return EAGAIN;
++ case SMB2_STATUS_INVALID_LOCK_SEQUENCE:
++ case SMB2_STATUS_INVALID_VIEW_SIZE:
++ case SMB2_STATUS_ALREADY_COMMITTED:
++ case SMB2_STATUS_PORT_CONNECTION_REFUSED:
++ case SMB2_STATUS_THREAD_IS_TERMINATING:
++ case SMB2_STATUS_DELETE_PENDING:
++ case SMB2_STATUS_PRIVILEGE_NOT_HELD:
++ case SMB2_STATUS_FILE_IS_A_DIRECTORY:
++ case SMB2_STATUS_FILE_RENAMED:
++ case SMB2_STATUS_PROCESS_IS_TERMINATING:
++ case SMB2_STATUS_DIRECTORY_NOT_EMPTY:
++ case SMB2_STATUS_CANNOT_DELETE:
++ case SMB2_STATUS_FILE_DELETED:
++ return EPERM;
+ case SMB2_STATUS_NO_MORE_FILES:
+ return ENODATA;
+ case SMB2_STATUS_LOGON_FAILURE:
+ return ECONNREFUSED;
+ case SMB2_STATUS_NOT_A_DIRECTORY:
+ return ENOTDIR;
++ case SMB2_STATUS_NOT_IMPLEMENTED:
++ case SMB2_STATUS_INVALID_DEVICE_REQUEST:
++ case SMB2_STATUS_ILLEGAL_FUNCTION:
+ case SMB2_STATUS_INVALID_PARAMETER:
+ return EINVAL;
++ case SMB2_STATUS_TOO_MANY_OPENED_FILES:
++ return EMFILE;
++ case SMB2_STATUS_SECTION_TOO_BIG:
++ case SMB2_STATUS_TOO_MANY_PAGING_FILES:
++ case SMB2_STATUS_INSUFF_SERVER_RESOURCES:
++ return ENOMEM;
++ case SMB2_STATUS_NOT_SAME_DEVICE:
++ return EXDEV;
++ case SMB2_STATUS_SHARING_VIOLATION:
++ return ETXTBSY;
++ case SMB2_STATUS_FILE_LOCK_CONFLICT:
++ case SMB2_STATUS_LOCK_NOT_GRANTED:
++ return EDEADLK;
++ case SMB2_STATUS_OBJECT_NAME_COLLISION:
++ return EEXIST;
++ case SMB2_STATUS_PIPE_DISCONNECTED:
++ return EPIPE;
++ case SMB2_STATUS_MEDIA_WRITE_PROTECTED:
++ return EROFS;
++ case SMB2_STATUS_NO_MEDIA_IN_DEVICE:
++ return ENOMEDIUM;
++ case SMB2_STATUS_DATA_ERROR:
++ case SMB2_STATUS_CRC_ERROR:
++ case SMB2_STATUS_DEVICE_DATA_ERROR:
++ return EIO;
++ case SMB2_STATUS_DISK_FULL:
++ return ENOSPC;
+ default:
+ return EIO;
+ }
+diff --git a/lib/init.c b/lib/init.c
+index 3720a1c..6c95cd2 100644
+--- a/lib/init.c
++++ b/lib/init.c
+@@ -412,6 +412,10 @@ void smb2_set_password(struct smb2_context *smb2, const char *password)
+ {
+ if (smb2->password) {
+ free(discard_const(smb2->password));
++ smb2->password = NULL;
++ }
++ if (password == NULL) {
++ return;
+ }
+ smb2->password = strdup(password);
+ }
+--
+2.20.1
+
diff --git a/contrib/src/smb2/SHA512SUMS b/contrib/src/smb2/SHA512SUMS
new file mode 100644
index 0000000000..eae3dd89c5
--- /dev/null
+++ b/contrib/src/smb2/SHA512SUMS
@@ -0,0 +1 @@
+5e7101e54a4a95eae2ed5b05dfb51a33e9d4ce19275a405fbb1e86f9e9fe197de53b41c301ca992f19a03e5117ccc90d0acb174eb9c000c71674a0dbacf57614 libsmb2-2.0.0.tar.gz
diff --git a/contrib/src/smb2/rules.mak b/contrib/src/smb2/rules.mak
new file mode 100644
index 0000000000..c14f58964f
--- /dev/null
+++ b/contrib/src/smb2/rules.mak
@@ -0,0 +1,29 @@
+# SMB2