Skip to content

Commit 27867c4

Browse files
committed
Downgrade dir_iterator implementation on NTE_BAD_SIGNATURE error on Windows.
This error code is reported to be returned by GetFileInformationByHandleEx(FileIdExtdDirectoryRestartInfo) in case of Samba 3.0.2 share accessed from a Windows Server 2019 client, when RequireSecuritySignature is set to 1 on the client. In the same setup, GetFileInformationByHandleEx(FileBothDirectoryInformation) is reported to succeed. This doesn't seem to reproduce with Samba 4.19 server and Windows 10 client, so it may be specific to the client and server versions, or it may be something else in the user's setup. Add NTE_BAD_SIGNATURE to the list of errors on which we non-permanently downgrade directory_iterator implementation to an older method. Closes #334.
1 parent 3fa413e commit 27867c4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

doc/release_history.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
</tr>
4141
</table>
4242

43+
<h2>1.87.0</h2>
44+
<ul>
45+
<li>On Windows, added a workaround for <code>directory_iterator</code> constructor failing with an "Invalid Signature" error for a Samba 3.0.2 share, when SMB signing is required. (<a href="https://github.com/boostorg/filesystem/issues/334">#334</a>)</li>
46+
</ul>
47+
4348
<h2>1.87.0</h2>
4449
<ul>
4550
<li>As was announced in 1.84.0, Windows versions prior to 10 are no longer supported.</li>

src/directory.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,19 +832,27 @@ inline bool is_dir_info_class_not_supported(DWORD error)
832832
// GetFileInformationByHandleEx(FileIdExtdDirectoryRestartInfo) return ERROR_INVALID_PARAMETER,
833833
// even though in general the operation is supported by the kernel. SMBv1 returns a special error
834834
// code ERROR_INVALID_LEVEL in this case.
835+
//
835836
// Some other filesystems also don't implement other info classes and return ERROR_INVALID_PARAMETER
836837
// (e.g. see https://github.com/boostorg/filesystem/issues/266), ERROR_GEN_FAILURE, ERROR_INVALID_FUNCTION
837838
// or ERROR_INTERNAL_ERROR (https://github.com/boostorg/filesystem/issues/286). Treat these error codes
838839
// as "non-permanent", even though ERROR_INVALID_PARAMETER is also returned if GetFileInformationByHandleEx
839840
// in general does not support a certain info class. Worst case, we will make extra syscalls on directory
840841
// iterator construction.
842+
//
841843
// Also note that Wine returns ERROR_CALL_NOT_IMPLEMENTED for unimplemented info classes, and
842844
// up until 7.21 it didn't implement FileIdExtdDirectoryRestartInfo and FileFullDirectoryRestartInfo.
843845
// (https://bugs.winehq.org/show_bug.cgi?id=53590)
846+
//
847+
// NTE_BAD_SIGNATURE (0x80090006) is returned from GetFileInformationByHandleEx(FileIdExtdDirectoryInformation)
848+
// for a Samba 3.0.2 share, when RequireSecuritySignature is set to 1 on the Windows Server 2019 client
849+
// (https://github.com/boostorg/filesystem/issues/334). FileBothDirectoryInformation succeeds in this case.
850+
// This doesn't reproduce with Samba 4.19 server and Windows 10 client, so this may be a bug in either
851+
// the client or the server.
844852
return error == ERROR_NOT_SUPPORTED || error == ERROR_INVALID_PARAMETER ||
845853
error == ERROR_INVALID_LEVEL || error == ERROR_CALL_NOT_IMPLEMENTED ||
846854
error == ERROR_GEN_FAILURE || error == ERROR_INVALID_FUNCTION ||
847-
error == ERROR_INTERNAL_ERROR;
855+
error == ERROR_INTERNAL_ERROR || error == NTE_BAD_SIGNATURE;
848856
}
849857

850858
system::error_code dir_itr_create(boost::intrusive_ptr< detail::dir_itr_imp >& imp, fs::path const& dir, directory_options opts, directory_iterator_params* params, fs::path& first_filename, fs::file_status& sf, fs::file_status& symlink_sf)

0 commit comments

Comments
 (0)