summaryrefslogtreecommitdiff
path: root/source3/libsmb
Commit message (Collapse)AuthorAgeFilesLines
* s3: libsmbclient: Fix smbc_lseekdir() to work with smbc_readdirplus().Jeremy Allison2019-09-191-26/+43
| | | | | | | | | | | If returning files the dir_list and the dirplus_list have exactly the same entries, we just need to keep the next pointers in sync on seek. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14094 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org> (cherry picked from commit 0d9b1645499ce12a79a137d3482434aa5d2eb47c)
* s3: libsmbclient: Ensure SMBC_getdents_ctx() also updates the readdirplus ↵Jeremy Allison2019-09-191-0/+11
| | | | | | | | | | | | | | | | pointers. If we are returning file entries, we have a duplicate list in dirplus. Update dirplus_next also so readdir and readdirplus are kept in sync. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14094 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org> (cherry picked from commit 754cec7756b2ddb1cfcc3984265f01cb366beb76)
* s3: libsmbclient: Ensure SMBC_readdirplus_ctx() also updates the readdir ↵Jeremy Allison2019-09-191-0/+11
| | | | | | | | | | | | | | | | pointers. If we are returning file entries, we have a duplicate list in dir_list. Update dir_next also so readdir and readdirplus are kept in sync. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14094 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org> (cherry picked from commit 3d82b7d11cd7b78adc6b3642e64e3a8f251de869)
* s3: libsmbclient: Ensure SMBC_readdir_ctx() also updates the readdirplus ↵Jeremy Allison2019-09-191-0/+11
| | | | | | | | | | | | | | | | pointers. If we are returning file entries, we have a duplicate list in dirplus. Update dirplus_next also so readdir and readdirplus are kept in sync. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14094 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org> (cherry picked from commit 4bca8e097f5a909c628daa4dbfa932ddc1725ebc)
* s3:libsmb: Add some useful debug output to cliconnectAndreas Schneider2019-04-091-0/+13
| | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13861 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> (cherry picked from commit 011a47f04dabe22095a30d284662d8ca50463ee8)
* s3:libsmb: cli_smb2_list() can sometimes fail initially on a connectionTim Beale2019-02-011-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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=13736 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Stefan 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 fd355dff906f5f4832901bce76544f1a4e50c33d)
* s3: libsmb: use smb2cli_conn_max_trans_size() in cli_smb2_list()Ralph Boehme2019-02-011-1/+2
| | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13736 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit 580ff206431969dc2924d520053b956b7169ca07)
* s3:libsmb: Honor disable_netbios option in smbsock_connect_sendJustin Stephenson2019-02-011-0/+7
| | | | | | | | | | | | If disable_netbios is set, return before the tevent timer is triggered to prevent outgoing netbios connections. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13727 Signed-off-by: Justin Stephenson <jstephen@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit c324f84a2fa25e29d2f7879fbcd35ce0e76a78f8)
* s3:smbpasswd: Print debug message about NetbiosJustin Stephenson2019-02-011-4/+12
| | | | | | | | | | | | | | | With a preceding patch, cli_connect_nb() will return NT_STATUS_NOT_SUPPORTED when 'disable netbios' is set in smb.conf. Print an informative error message to indicate Netbios is disabled if this occurs. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13727 Signed-off-by: Justin Stephenson <jstephen@redhat.com> Reviewed-by: Noel Power <nopower@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit ecbb2f78cec6d9e6f5180c8ba274a1da2152f098)
* s3:libsmb: Print debug message about NetbiosJustin Stephenson2019-02-012-3/+11
| | | | | | | | | | | | | | | With a preceding patch, cli_connect_nb() will return NT_STATUS_NOT_SUPPORTED when 'disable netbios' is set in smb.conf. Print an informative error message to indicate Netbios is disabled if this occurs. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13727 Signed-off-by: Justin Stephenson <jstephen@redhat.com> Reviewed-by: Noel Power <nopower@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 499f051c9d527a14f9712365f8403a1ee0662c5b)
* s3:libsmb: Check disable_netbios in socket connectJustin Stephenson2019-02-011-0/+5
| | | | | | | | | | | | If the disable_netbios option is set then return NT_STATUS_NOT_SUPPORTED for a port 139 connection in the low level socket connection code. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13727 Signed-off-by: Justin Stephenson <jstephen@redhat.com> Reviewed-by: Noel Power <nopower@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 78f51a1d3c53248159c1e7643364b62e52457bb9)
* s3: lib: nmbname: Ensure we limit the NetBIOS name correctly. CID: 1433607Jeremy Allison2019-01-211-13/+21
| | | | | | | | | | | | | | | | | | | | Firstly, make the exit condition from the loop explicit (we must never write into byte n, where n >= sizeof(name->name). Secondly ensure exiting from the loop that n==MAX_NETBIOSNAME_LEN, as this is the sign of a correct NetBIOS name encoding (RFC1002) in order to properly read the NetBIOS name type (which is always encoded in byte 16 == name->name[15]). BUG: https://bugzilla.samba.org/show_bug.cgi?id=11495 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Tue Nov 13 20:54:56 CET 2018 on sn-devel-144 (cherry picked from commit 3634e20c7603103b0f2e00e5b61cc63f905d780d)
* libsmb: Fix CID 1438243 Unchecked return valueVolker Lendecke2018-08-141-1/+8
| | | | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13553 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Aug 8 23:10:22 CEST 2018 on sn-devel-144 Autobuild-User(v4-9-test): Stefan Metzmacher <metze@samba.org> Autobuild-Date(v4-9-test): Tue Aug 14 20:49:09 CEST 2018 on sn-devel-144
* libsmb: Fix CID 1438244 Unsigned compared against 0Volker Lendecke2018-08-141-4/+0
| | | | | | | | | | | | ndr_size_dom_sid returns a size_t, so that can't be <0. Also, the only case that ndr_size_dom_sid returns 0 is a NULL sid pointer. ndr_size_dom_sid can reasonably be assumed to not overflow, the number of sub-auths is a uint8. That times 4 plus 8 always fits into a size_t. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13553 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/libsmb: Explicitly set delete_on_close token for rmdirAnoop C S2018-08-141-1/+8
| | | | | | | | | | | | | | | | | | | | | The current implementation of `rmdir` hopes to get the directory deleted on closing last open handle when FILE_DELETE_ON_CLOSE is set on it. But for non-empty directories Windows doesn't error out during an open call. Following that we internally refuse to set initial delete_on_close while opening a non-empty directory. This prevents us from trying to delete the directory when last open handle is closed. Instead of relying on FILE_DELETE_ON_CLOSE during an open we explicitly set delete_on_close token on directory handle once it is available. This ensures that NT_STATUS_DIRECTORY_NOT_EMPTY is returned for `rmdir` on non-empty directories while closing open directory handle. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13204 Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> (cherry picked from commit 6b68e3eca631c04d6d57c489daf60f64732fc86d)
* libsmb: Harden smbc_readdir_internal() against returns from malicious servers.Jeremy Allison2018-08-142-8/+51
| | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13453 CVE-2018-10858: Insufficient input validation on client directory listing in libsmbclient. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* libsmb: Ensure smbc_urlencode() can't overwrite passed in buffer.Jeremy Allison2018-08-141-2/+7
| | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13453 CVE-2018-10858: Insufficient input validation on client directory listing in libsmbclient. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3/smbd: adjust smb1 server to use idl structs and generated ndr push/pull funcsNoel Power2018-08-131-12/+7
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13553 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/libsmb: adjust smb2 code for new idl structs & generated ndr push/pull funcs.Noel Power2018-08-131-28/+58
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13553 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/libsmb: adjust smb1 cli code to use idl structs and ndr push/pull funcs.Noel Power2018-08-132-180/+223
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13553 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/libsmb: Avoid potential smbpanic calling parse_user_quota_list.Noel Power2018-08-131-0/+8
| | | | | | | | | | | | | Calling parse_user_quota_list with a NULL buffer can cause a panic, while this shouldn't happen, I managed to trigger this with an early implementation of SMB2 quota support in smbd which didn't pass back NT_STATUS_NO_MORE_ENTRIES when handling a SMB2_0_INFO_QUOTA GETINFO message. OTHOH the Windows client handled the same situation gracefully. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13553 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
* libsmbclient: Initialize written in cli_splice_fallback()Bailey Berro2018-07-091-0/+2
| | | | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13511 Signed-off-by: Bailey Berro <baileyberro@chromium.org> Reviewed-by: David Mulder <dmulder@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Mon Jul 9 21:29:48 CEST 2018 on sn-devel-144
* libsmbclient: Initialize written value before use.Jeremy Allison2018-07-091-1/+1
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13511 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* s3:libsmbclient: cleanup smbc_setWorkgroup() usageDavid Disseldorp2018-05-171-12/+4
| | | | | | | It now takes a const char *. There's no need to use heap memory here. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:libsmbclient: Use const for setting and getting stringsAndreas Schneider2018-05-173-6/+190
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* Fix spelling s/unitialized/uninitialized/Mathieu Parent2018-05-121-1/+1
| | | | | | Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* s3: libsmbclient: Add new function SMBC_readdirplus_ctx().Puran Chand2018-05-056-1/+248
| | | | | | | | | New ABI function, move to library version 0.33. Signed-off-by: Puran Chand <pchand@vmware.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
* s3: libsmbclient: Add function add_dirplus() to fill the list from a ↵Puran Chand2018-05-051-0/+73
| | | | | | | | | | | returned file info. Not yet externally visible. Signed-off-by: Puran Chand <pchand@vmware.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
* s3: libsmbclient: Add readdirplus cleanup code on directory close.Puran Chand2018-05-051-0/+21
| | | | | | | Signed-off-by: Puran Chand <pchand@vmware.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
* s3: client: Add btime_ts to struct finfo.Jeremy Allison2018-05-052-0/+20
| | | | | | | | | | Fill it in when available, else return it as zero. Based on a patch from Puran Chand <pchand@vmware.com>. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
* s3: libsmbclient: Fix hard-coded connection error return of ETIMEDOUT.Jeremy Allison2018-05-031-1/+1
| | | | | | | | | | | | | | | | We shouldn't hard-code the connection error as ETIMEDOUT when we have a perfectly good NT_STATUS to map from. Found by the ChromeOS guys trying to connect an SMB2-only client to an SMB1-only supporting server. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13419 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <Volker.Lendecke@SerNet.DE> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu May 3 02:42:20 CEST 2018 on sn-devel-144
* tevent: Fix callers of tevent_req_set_endtimeVolker Lendecke2018-04-241-4/+0
| | | | | | | | tevent_req_set_endtime internally already calls tevent_req_nomem and thus sets the error status correctly. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libsmb: Pass "account_name/flags" through nb_getdcVolker Lendecke2018-04-113-16/+21
| | | | | | | Don't hardcode values that we might want to change later Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libsmb: Pass "account_name/flags" through prep_getdc_requestVolker Lendecke2018-04-111-11/+19
| | | | | | | Don't hardcode values that we might want to change later Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libsmb: Introduce a helper variableVolker Lendecke2018-04-111-2/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libsmb: Give dsgetdcname.c its own headerVolker Lendecke2018-04-112-0/+38
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libsmb: Give namequery.c its own headerVolker Lendecke2018-04-116-0/+120
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libsmb: Remove unused trustdom_cache.cVolker Lendecke2018-04-111-360/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* python3 port for libsmb_samba_internal moduleNoel Power2018-04-051-8/+20
| | | | | | Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* libsmb: Handle IO_TIMEOUT in cli_smb2_notify properlyVolker Lendecke2018-04-051-0/+9
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libsmb: Use the same #ifdef for is_our_primary_domain() as the only callerAndrew Bartlett2018-03-221-1/+1
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:libsmb: Fix size types in nmblibAndreas Schneider2018-03-201-3/+3
| | | | | | | This fixes compilation with -Wstrict-overflow=2 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s3:libsmb/samlogon_cache: zero session keys before storing the info3 structureStefan Metzmacher2018-03-191-0/+4
| | | | | | | | | | The samlogon_cache is only used to get group memberships of the account without asking the dc. But for authentication we always ask the dc. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* libsmb: Use smb2 tcon if conn_protocol >= SMB2_02Dan Robertson2018-03-021-1/+1
| | | | | | | | | | | | When the connection protocol is SMB2 the tid from the smb1 member is used instead of smb2 in cli_state_set_tid which often results in a null deref. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13310 Signed-off-by: Dan Robertson <drobertson@tripwire.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* libsmb: Remove incorrect fall through comment in trusts_util.cAndreas Schneider2018-03-011-1/+0
| | | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Mar 1 09:52:37 CET 2018 on sn-devel-144
* s3:libsmb: Add FALL_THROUGH statements in dsgetdcname.cAndreas Schneider2018-03-011-0/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s3:cliconnect.c: remove useless ';'Stefan Metzmacher2018-02-221-1/+1
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13206 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s3:libsmb: allow -U"\\administrator" to workStefan Metzmacher2018-02-221-1/+6
| | | | | | | | | cli_credentials_get_principal() returns NULL in that case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13206 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* dsgetdcname: Add some constVolker Lendecke2018-02-131-10/+12
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* libsmb: Fix an error path memleakVolker Lendecke2018-02-131-0/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>