1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
Commit Graph

367 Commits

Author SHA1 Message Date
Noel Power
bf567380a7 s3/libsmb: clang: Fix 'Value stored to 'ea_size' is never read'
Fixes:

source3/libsmb/clifile.c:5290:2: warning: Value stored to 'ea_size' is never read <--[clang]
        ea_size = (size_t)IVAL(rdata,0);
        ^         ~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-08-27 23:04:37 +00:00
Noel Power
ce9fef5fd5 s3/libsmb: clang: Fix 'Assigned value is garbage or undefined'
Fixes:

source3/libsmb/clifile.c:4898:10: warning: Assigned value is garbage or undefined <--[clang]
                *bsize = (uint64_t)old_bsize;
                       ^ ~~~~~~~~~~~~~~~~~~~
source3/libsmb/clifile.c:4901:10: warning: Assigned value is garbage or undefined <--[clang]
                *total = (uint64_t)old_total;
                       ^ ~~~~~~~~~~~~~~~~~~~
source3/libsmb/clifile.c:4904:10: warning: Assigned value is garbage or undefined <--[clang]
                *avail = (uint64_t)old_avail;

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-08-27 23:04:37 +00:00
Noel Power
4bb9255473 s3/libsmb: clang: Fix 'The left operand of '&' is a garbage value'
Fixes:

source3/libsmb/clifile.c:3108:26: warning: The left operand of '&' is a garbage value <--[clang]
            (cr.file_attributes & FILE_ATTRIBUTE_DIRECTORY))
             ~~~~~~~~~~~~~~~~~~ ^

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-08-27 23:04:37 +00:00
Noel Power
e06d34e98e s3/libsmb: clang: Fix 'The left operand of '!=' is a garbage value'
Fixes:

source3/libsmb/clifile.c:789:15: warning: The left operand of '!=' is a garbage value <--[clang]
        if (num_data != 100) {
            ~~~~~~~~ ^

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-08-27 23:04:37 +00:00
Volker Lendecke
56521c5fbf libsmb: Make cli_lockingx cancellable
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-06-20 17:18:18 +00:00
Volker Lendecke
22aeb005d9 libsmb: Use cli_lockingx() in cli_unlock()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-06-18 12:54:00 +00:00
Volker Lendecke
5211f6afdf libsmb: Use cli_lockingx() in cli_locktype()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-06-18 12:54:00 +00:00
Volker Lendecke
cc69f49cba libsmb: Add async cli_lockingx()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-06-18 12:53:59 +00:00
Volker Lendecke
aec8b4a2a9 libsmb: Remove unused cli_[un]lock64()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-06-18 12:53:59 +00:00
Volker Lendecke
0876712ce8 libsmb: Make cli_posix_chown/chmod proper tevent_req functions
This prepares for making them smb2-aware

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): Mon Apr  1 19:00:11 UTC 2019 on sn-devel-144
2019-04-01 19:00:11 +00:00
Volker Lendecke
3e1d8ab125 libsmb: Change cli_posix_readlink to return talloc'ed target
This is a deviation from the Posix readlink function that from my
point of view makes this function easier to use. In Posix, probably
the assumption is that readlink is cheap, so someone under memory
constraints could just start with a small buffer and incrementally
increase the buffer size. For us, it's a network round-trip, and we
have the luxury of [mt]alloc, which the syscall kernel interface does
not have.

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 Mar 27 12:31:37 UTC 2019 on sn-devel-144
2019-03-27 12:31:37 +00:00
Volker Lendecke
3478e9d124 libsmb: Don't pass "cli" to cli_posix_readlink_recv
From my point of view the option to change "cli" between
cli_posix_readlink_send and _recv is not necessary.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-27 11:20:23 +00:00
Volker Lendecke
c7fae52ff0 libsmb: Rename "readlink_state" to "cli_posix_readlink_state"
This is more in line with most other users of tevent_req: The state is
called fully after the routines it acts as a state repository for.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-27 11:20:23 +00:00
Volker Lendecke
2a430625e7 libsmb: Make SMB1-only cli_nt_hardlink calls static
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 Mar 20 23:32:31 UTC 2019 on sn-devel-144
2019-03-20 23:32:31 +00:00
Volker Lendecke
b5af004b23 libsmb: Introduce protocol-agnostic cli_hardlink
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-20 22:07:45 +00:00
Volker Lendecke
7e6991565e libsmb: Change cli_posix_stat_send to take a pointer to sbuf
This moves the parsing work from the _recv function into the _done
function. This makes writing the SMB2 call easier later on: We can
have a smb2-specific done function doing the smb2-specific work and we
don't have to fork on protocol in the _recv function.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-18 19:21:24 +00:00
Volker Lendecke
cfc3f32038 libsmb: Make cli_posix_[sym|hard]link proper tevent_req functions
Simplify adding SMB2 to those functions

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-18 19:21:23 +00:00
Volker Lendecke
2040196e10 libsmb: Use tevent_req_simple_finish_ntstatus
Less lines of code

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-18 19:21:23 +00:00
Volker Lendecke
7caf2cbdf1 libsmb: Use tevent_req_simple_finish_ntstatus
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): Fri Mar  8 19:16:18 UTC 2019 on sn-devel-144
2019-03-08 19:16:18 +00:00
Volker Lendecke
9a38dc0c1f libsmb: Add "in_cblobs" to cli_smb2_unlink
This reveals the fact that unlink is an open/close in smb2 through the
API. This is not nice, but it's an internal API with currently only
one user. And it enables posix semantics for the open easily.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-08 18:20:10 +00:00
Volker Lendecke
7fc3b2b264 libsmb: Add "in_cblobs" to cli_smb2_rmdir
This reveals the fact that rmdir is an open/close in smb2 through the
API. This is not nice, but it's an internal API with currently only
one user. And it enables posix semantics for the open easily.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-08 18:20:10 +00:00
Volker Lendecke
d1c2fe8907 libsmb: Make cli_posix_unlink/rmdir proper tevent_req/subreq pairs
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): Sat Mar  2 00:55:56 UTC 2019 on sn-devel-144
2019-03-02 00:55:56 +00:00
Volker Lendecke
02f4080284 libsmb: add in/out cblobs to cli_smb2_create_fnum
This is driven by the imminent smb2 unix extensions, we'll want to make use of
it from source3/libsmb.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-01 00:32:12 +00:00
Volker Lendecke
a787c319f1 libsmb: Reformat the cli_smb2_create_fnum_send args
We'll add parameters in the next commit, make that commit a bit more obvious

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-01 00:32:12 +00:00
Volker Lendecke
26f18b9bd7 libsmb: Resolve special _recv handling in cli_ntcreate
cli_smb2_create_fnum_recv will gain output create blobs soon and thus
differ from the NT1 function.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-02-25 19:36:20 +01:00
Volker Lendecke
5dd67797ca libsmb: Fix a resource leak in cli_posix_mkdir
smbd does posix_mkdir if the wire flags are exactly

	if (wire_open_mode == (SMB_O_CREAT|SMB_O_DIRECTORY))

open_flags_to_wire however adds a SMB_O_RDONLY, so that we enter the
normal open routine which happens to create a directory as well. The
main difference is that posix_mkdir does *NOT* return an open
handle. As we did not enter this code path due to the SMB_O_RDONLY we
leak a SMB1 fd per cli_posix_mkdir call.

Pretty hard to test automatically, this would be an interaction with
smbstatus.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-02-22 21:48:11 +01:00
Volker Lendecke
529c61d0c9 libsmb: Pull up wire_flags calculation from open_internal
This avoids passing down a boolean

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-02-22 21:48:11 +01:00
Volker Lendecke
64176f00bf libsmb: Convert cli_posix_open to normal tevent_req pattern
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-02-22 21:48:11 +01:00
Stefan Metzmacher
c8a5e89d9f s3:libsmb: pass impersonation_level to cli_ntcreate_send()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Tim Beale <timbeale@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-13 08:52:24 +01:00
Stefan Metzmacher
ed0deadf62 s3:libsmb: pass ImpersonationLevel to cli_ntcreate1_send()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Tim Beale <timbeale@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-13 08:52:24 +01:00
Stefan Metzmacher
be464c1dc8 s3:libsmb: pass impersonation_level to cli_smb2_create_fnum_send()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Tim Beale <timbeale@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-13 08:52:24 +01:00
Volker Lendecke
88d82b44c3 libsmb: Make cli_notify_send cancellable
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Nov 21 20:50:13 CET 2018 on sn-devel-144
2018-11-21 20:50:13 +01:00
Volker Lendecke
4c984f3f50 libsmb: Make cli_notify_send/recv smb2-aware
smb2-awareness only existed in the sync wrapper

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-11-21 16:53:42 +01:00
Jeremy Allison
1b6e8e52f0 s3: libsmb: Make cli_close_send()/cli_close_recv() work for SMB1 and SMB2.
Remove the escape into synchronous smb2 code.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13159

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2017-12-06 15:02:16 +01:00
Jeremy Allison
f29b59239e s3: libsmb: Rename cli_close_create() -> cli_smb1_close_create().
Move cli_smb1_close_done() next to its caller. This is SMB1 specific.
Prepare to wrap cli_close_send/cli_close_recv to handle SMB2.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13159

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
2017-12-06 15:02:16 +01:00
Jeremy Allison
8448dcaa8d s3: client: Rename <oldname> to <link_target> in cmd_symlink() and cli_posix_symlink().
Stops us from mixing up the old and new names. Only behavior change
is correcting the names printed in the error messages.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13172

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2017-11-30 15:30:23 +01:00
Jeremy Allison
428fc22e8b s3: libsmb: Add cli_smb2_chkpath() and use from cli_chkpath().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12968

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-08-18 00:51:25 +02:00
Volker Lendecke
5005a3a696 libsmb: Enable "cli_notify" for SMB2+
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 Jul 26 01:33:25 CEST 2017 on sn-devel-144
2017-07-26 01:33:25 +02:00
Stefan Metzmacher
38f1aeba7e s3:libsmb: add support for SMB2 to cli_nt_delete_on_close*()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-06-22 13:07:40 +02:00
Uri Simchoni
26dbe684dc s3-libsmb: support rename and replace for SMB1
Add cli_smb1_rename_send() which renames a file via
setting FileRenameInformation.

Curretly this path is invoked only if replacing
an existing file is requested. This is because as far
as I can see, Windows uses CIFS rename for anything below
SMB2.

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-03-28 17:45:19 +02:00
Uri Simchoni
057aa39e6a s3-libsmb: fail rename and replace inside cifs variant
Another refactoring step - fail request to rename and
replace existing file from within the CIFS version,
allowing the soon-to-be-added SMB version to succeed.

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-03-28 17:45:19 +02:00
Uri Simchoni
3154c4cb70 s3-libsmb: cli_cifs_rename_send()
Pure refactoring - current rename is [MS-CIFS] - style
rename. In later patch we'll introduce [MS-SMB] rename.

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-03-28 17:45:19 +02:00
Uri Simchoni
200dbca238 s3: libsmb: add replace support to cli_rename()
Adds support for replacing the destination file at
the higher-level cli_rename(). This is actually supported
only by SMB2, and fails with invalid parameter with SMB1.

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-03-28 17:45:19 +02:00
Uri Simchoni
a67802fad5 s3: libsmb: add replace support to SMB2 rename
SMB2 rename operation supports replacing the
destination file if it exists.

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-03-28 17:45:19 +02:00
Chris Lamb
5482e5426e Correct "existence" typos.
Signed-off-by: Chris Lamb <chris@chris-lamb.co.uk>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-02-22 08:26:22 +01:00
Jeremy Allison
e0f1ed9f45 s3: libsmb: Add cli_smb2_ftruncate(), plumb into cli_ftruncate().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12479

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
2017-01-04 12:22:12 +01:00
Stefan Metzmacher
7999e6f6c0 libcli/smb: move {smb,trans2}_bytes_push_{str,bytes}() to common code
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-11-15 11:00:26 +01:00
Jeremy Allison
03bf1f858d s3: libsmb: Plumb new SMB2 shadow copy call into cli_shadow_copy_data().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12166

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
2016-08-22 19:10:22 +02:00
Jeremy Allison
14fd6dca4e s3: libsmb: Add return args to clistr_is_previous_version_path().
Not yet used - we will use these to construct the SMB2 TWrp blob.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12166

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
2016-08-22 19:10:22 +02:00
Jeremy Allison
336da63754 s3: libsmb: Do some hardening in the receive processing of cli_shadow_copy_data_recv().
Protect against malicious servers.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
2016-08-19 20:03:13 +02:00