• Tim Beale's avatar
    s3:libsmb: cli_smb2_list() can sometimes fail initially on a connection · 3b19257a
    Tim Beale authored
    cli_smb2_list() appears to be a slightly unique SMB operation in that it
    specifies the max transaction size for the response buffer size. The
    Python bindings highlighted a problem where if cli_smb2_list() were one
    of the first operations performed on the SMBv2 connection, it would fail
    due to insufficient credits. Because the response buffer size is
    (potentially) so much larger, it requires more credits (128) compared
    with other SMB operations.
    
    When talking to a samba DC, the connection credits seem to start off at
    1, then increase by 32 for every SMB reply we receive back from the
    server. After cli_full_connection(), the connection has 65 credits. The
    cli_smb2_create_fnum() in cli_smb2_list() adds another 32 credits, but
    this is still less than the 128 that smb2cli_query_directory() requires.
    
    This problem doesn't happen for smbclient because the cli_cm_open() API
    it uses ends up sending more messages, and so the connection has more
    credits.
    
    This patch changes cli_smb2_list(), so it requests a smaller response
    buffer size if it doesn't have enough credits available for the max
    transaction size. smb2cli_query_directory() is already in a loop, so it
    can span multiple SMB messages if for some reason the transaction size
    isn't big enough for the listings.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13736Signed-off-by: default avatarTim Beale <timbeale@catalyst.net.nz>
    Reviewed-by: default avatarStefan Metzmacher <metze@samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
    Autobuild-Date(master): Thu Jan 10 02:40:16 CET 2019 on sn-devel-144
    
    (cherry picked from commit fd355dff)
    3b19257a
Name
Last commit
Last update
..
ABI Loading commit data...
async_smb.c Loading commit data...
auth_generic.c Loading commit data...
cli_smb2_fnum.c Loading commit data...
cli_smb2_fnum.h Loading commit data...
cliconnect.c Loading commit data...
clidfs.c Loading commit data...
clidgram.c Loading commit data...
clidgram.h Loading commit data...
clientgen.c Loading commit data...
clierror.c Loading commit data...
clifile.c Loading commit data...
clifsinfo.c Loading commit data...
clilist.c Loading commit data...
climessage.c Loading commit data...
clioplock.c Loading commit data...
cliprint.c Loading commit data...
cliquota.c Loading commit data...
clirap.c Loading commit data...
clirap.h Loading commit data...
clirap2.c Loading commit data...
clireadwrite.c Loading commit data...
clisecdesc.c Loading commit data...
clispnego.c Loading commit data...
clistr.c Loading commit data...
clisymlink.c Loading commit data...
clitrans.c Loading commit data...
conncache.c Loading commit data...
dsgetdcname.c Loading commit data...
dsgetdcname.h Loading commit data...
errormap.c Loading commit data...
errormap_wbc.c Loading commit data...
errormap_wbc.h Loading commit data...
libsmb.h Loading commit data...
libsmb_cache.c Loading commit data...
libsmb_compat.c Loading commit data...
libsmb_context.c Loading commit data...
libsmb_dir.c Loading commit data...
libsmb_file.c Loading commit data...
libsmb_misc.c Loading commit data...
libsmb_path.c Loading commit data...
libsmb_printjob.c Loading commit data...
libsmb_server.c Loading commit data...
libsmb_setget.c Loading commit data...
libsmb_stat.c Loading commit data...
libsmb_thread_impl.c Loading commit data...
libsmb_thread_posix.c Loading commit data...
libsmb_xattr.c Loading commit data...
namecache.c Loading commit data...
namequery.c Loading commit data...
namequery.h Loading commit data...
namequery_dc.c Loading commit data...
nmblib.c Loading commit data...
nmblib.h Loading commit data...
passchange.c Loading commit data...
proto.h Loading commit data...
pylibsmb.c Loading commit data...
reparse_symlink.c Loading commit data...
samlogon_cache.c Loading commit data...
samlogon_cache.h Loading commit data...
smb_share_modes.c Loading commit data...
smbclient.pc.in Loading commit data...
smberr.c Loading commit data...
smbsock_connect.c Loading commit data...
trusts_util.c Loading commit data...
unexpected.c Loading commit data...
unexpected.h Loading commit data...
wscript Loading commit data...