[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Thu Dec 13 11:36:05 UTC 2018
The branch, master has been updated
via ecafdcb3914 s3:pylibsmb: allow ImpersonationLevel argument to create()
via c8a5e89d9f6 s3:libsmb: pass impersonation_level to cli_ntcreate_send()
via ed0deadf628 s3:libsmb: pass ImpersonationLevel to cli_ntcreate1_send()
via 850aef94dc4 s3:libsmb: pass impersonation_level to cli_smb2_create_fnum()
via be464c1dc86 s3:libsmb: pass impersonation_level to cli_smb2_create_fnum_send()
via 64e68abdc9e s3:pylibsmb: make use of protocol independent cli_read_send/recv in py_cli_read()
via 3c3b44004fd s3:pylibsmb: make use of protocol independent cli_write_send/recv in py_cli_write()
via 9fb0d8e7e2e s3:libsmb: add comments for cli_write_send/cli_push_send
via 6a3d2c3345a s3:libsmb: add cli_write_send/recv which work with SMB1/2/3
via 0af6b335448 s3:pylibsmb: make use of PYARG_BYTES_LEN in py_cli_write()
via 60148c9ee14 s3:pylibsmb: make use of PyBytes_FromStringAndSize() in py_cli_read()
via aaf7aaa6e26 s3:pylibsmb: .get_oplock_break API is dependent on multi_threaded=True
via fdc62b03ca5 s3:pylibsmb: remember that a connection uses SMB1
via 790dab571c4 s3:pylibsmb: add force_smb1=True in order to control forcing of SMB1
via 247a71b63ae s3:pylibsmb: add sign=True to require signing
via 1bccbfcff78 s3:pylibsmb: only use poll_mt backend if multi_threaded=True is specified
via 59cb025e61a s3:pylibsmb: pass self to py_tevent_req_wait_exc()
via 660b872163c wafsamba: fix pidl dependencies to rebuild on pidl changes
from 57783d6295d pidl: Fix unsigned integer comparison warning
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit ecafdcb39143b6b3a74f2b9d578241a0170f8486
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 16:40:10 2018 +0100
s3:pylibsmb: allow ImpersonationLevel argument to create()
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
Autobuild-Date(master): Thu Dec 13 12:35:06 CET 2018 on sn-devel-144
commit c8a5e89d9f6575c4e9eb770997172e9c25f8e9d0
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 16:38:57 2018 +0100
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit ed0deadf6287c4c56e99503bf78f20db2f297401
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 16:35:16 2018 +0100
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 850aef94dc4d9370d03f18510de93116221a0feb
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 16:42:06 2018 +0100
s3:libsmb: pass impersonation_level to cli_smb2_create_fnum()
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit be464c1dc8675f6e362b7a5b51c6776dc682e3b9
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 16:32:05 2018 +0100
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 64e68abdc9e7d991809e6eab57826b4456d8e973
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 14:28:04 2018 +0100
s3:pylibsmb: make use of protocol independent cli_read_send/recv in py_cli_read()
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 3c3b44004fd39a890f2bdfadf3ebb68a53f3403f
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 14:28:04 2018 +0100
s3:pylibsmb: make use of protocol independent cli_write_send/recv in py_cli_write()
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 9fb0d8e7e2e5c7a9485368f26d2fff05d51f32d8
Author: Tim Beale <timbeale at catalyst.net.nz>
Date: Tue Dec 11 16:05:43 2018 +1300
s3:libsmb: add comments for cli_write_send/cli_push_send
Added a code comment highlighting this 2 APIs do similar jobs, and tried
to explain why you might want to use one over the other.
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: Tim Beale <timbeale at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 6a3d2c3345a7ed4a9c4c9ad5ce767cc2ffd9413f
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 14:26:43 2018 +0100
s3:libsmb: add cli_write_send/recv which work with SMB1/2/3
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 0af6b335448f6ee4f4db6aa857666689e87f00ad
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 14:04:30 2018 +0100
s3:pylibsmb: make use of PYARG_BYTES_LEN in py_cli_write()
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 60148c9ee147105b36cbb8164cbb7b1c2249acb8
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Dec 7 13:47:40 2018 +0100
s3:pylibsmb: make use of PyBytes_FromStringAndSize() in py_cli_read()
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit aaf7aaa6e26c62c62650dc01fff902d3a949a315
Author: Tim Beale <timbeale at catalyst.net.nz>
Date: Tue Dec 4 12:32:58 2018 +1300
s3:pylibsmb: .get_oplock_break API is dependent on multi_threaded=True
The .get_oplock_break is dependent on the pthread code, which is only
used when creating a SMB connection with multi_threaded=True.
Add an explicit error to the .get_oplock_break() if someone tries to use
it in non-multithreaded mode.
Initializing self->oplock_waiter in non-multithreaded mode is similarly
redundant if the API can never be used.
Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
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: Tim Beale <timbeale at catalyst.net.nz>
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit fdc62b03ca5eac3f98f0e1f2db45a7df0b29095e
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Dec 4 10:42:55 2018 +0100
s3:pylibsmb: remember that a connection uses SMB1
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 790dab571c426abc1004d1c338e0b94382a2a2c0
Author: Stefan Metzmacher <metze at samba.org>
Date: Tue Dec 4 10:40:18 2018 +0100
s3:pylibsmb: add force_smb1=True in order to control forcing of SMB1
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 247a71b63aea9fe03e4e6ba22102eeb0cd648a2a
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Dec 3 15:42:50 2018 +0100
s3:pylibsmb: add sign=True to require signing
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 1bccbfcff78c49c74cf986a8b9e9a33d295d557c
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Dec 3 15:02:06 2018 +0100
s3:pylibsmb: only use poll_mt backend if multi_threaded=True is specified
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 59cb025e61abfe28a9d17616d10641cc74975375
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Dec 3 14:37:05 2018 +0100
s3:pylibsmb: pass self to py_tevent_req_wait_exc()
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 at samba.org>
Reviewed-by: Tim Beale <timbeale at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 660b872163c9aee99627cd2952ac06c8df85cf22
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Nov 23 14:06:52 2018 +0100
wafsamba: fix pidl dependencies to rebuild on pidl changes
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
-----------------------------------------------------------------------
Summary of changes:
buildtools/wafsamba/samba_pidl.py | 4 +-
examples/fuse/clifuse.c | 6 +-
examples/winexe/winexe.c | 3 +
python/samba/tests/libsmb_samba_internal.py | 4 +-
source3/libsmb/cli_smb2_fnum.c | 21 +++-
source3/libsmb/cli_smb2_fnum.h | 2 +
source3/libsmb/clifile.c | 12 +-
source3/libsmb/clireadwrite.c | 134 ++++++++++++++++++++
source3/libsmb/clisymlink.c | 6 +-
source3/libsmb/proto.h | 8 ++
source3/libsmb/pylibsmb.c | 186 +++++++++++++++++++++-------
source3/torture/nbench.c | 3 +-
source3/torture/test_chain3.c | 3 +-
source3/torture/test_notify.c | 9 +-
source3/torture/test_notify_online.c | 5 +-
source3/torture/test_oplock_cancel.c | 2 +-
source3/torture/torture.c | 3 +-
17 files changed, 346 insertions(+), 65 deletions(-)
Changeset truncated at 500 lines:
diff --git a/buildtools/wafsamba/samba_pidl.py b/buildtools/wafsamba/samba_pidl.py
index 1e55892127e..3fecfa90eb9 100644
--- a/buildtools/wafsamba/samba_pidl.py
+++ b/buildtools/wafsamba/samba_pidl.py
@@ -86,8 +86,6 @@ def SAMBA_PIDL(bld, pname, source,
name = name,
samba_type = 'PIDL')
- # prime the list of nodes we are dependent on with the cached pidl sources
- t.allnodes = pidl_src_nodes
t.env.PIDL_LAUNCH_DIR = bld.srcnode.path_from(bld.bldnode)
pnode = bld.srcnode.find_resource('pidl/pidl')
@@ -97,6 +95,8 @@ def SAMBA_PIDL(bld, pname, source,
t.env.IDLSRC = snode.path_from(bld.srcnode)
t.env.OUTPUTDIR = bld.bldnode.path_from(bld.srcnode) + '/' + bld.path.find_dir(output_dir).path_from(bld.srcnode)
+ bld.add_manual_dependency(snode, pidl_src_nodes)
+
if generate_tables and table_header_idx is not None:
pidl_headers = LOCAL_CACHE(bld, 'PIDL_HEADERS')
pidl_headers[name] = [bld.path.find_or_declare(out_files[table_header_idx])]
diff --git a/examples/fuse/clifuse.c b/examples/fuse/clifuse.c
index 3c7e4982475..b724e642d4b 100644
--- a/examples/fuse/clifuse.c
+++ b/examples/fuse/clifuse.c
@@ -151,7 +151,8 @@ static void cli_ll_create(fuse_req_t freq, fuse_ino_t parent, const char *name,
req = cli_smb2_create_fnum_send(
state, mstate->ev, mstate->cli, state->path,
- 0, FILE_GENERIC_READ|FILE_GENERIC_WRITE, FILE_ATTRIBUTE_NORMAL,
+ 0, SMB2_IMPERSONATION_IMPERSONATION,
+ FILE_GENERIC_READ|FILE_GENERIC_WRITE, FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_CREATE, FILE_NON_DIRECTORY_FILE);
if (req == NULL) {
@@ -836,7 +837,8 @@ static void cli_ll_open(fuse_req_t freq, fuse_ino_t ino,
req = cli_smb2_create_fnum_send(
state, mstate->ev, mstate->cli, istate->path,
- 0, acc, FILE_ATTRIBUTE_NORMAL,
+ 0, SMB2_IMPERSONATION_IMPERSONATION,
+ acc, FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OPEN, FILE_NON_DIRECTORY_FILE);
if (req == NULL) {
diff --git a/examples/winexe/winexe.c b/examples/winexe/winexe.c
index cf667a64ebc..429ba2f5163 100644
--- a/examples/winexe/winexe.c
+++ b/examples/winexe/winexe.c
@@ -872,6 +872,7 @@ static struct tevent_req *winexe_out_pipe_send(
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OPEN, /* CreateDisposition */
0, /* CreateOptions */
+ SMB2_IMPERSONATION_IMPERSONATION,
0); /* SecurityFlags */
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
@@ -1044,6 +1045,7 @@ static struct tevent_req *winexe_in_pipe_send(
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OPEN, /* CreateDisposition */
0, /* CreateOptions */
+ SMB2_IMPERSONATION_IMPERSONATION,
0); /* SecurityFlags */
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
@@ -1462,6 +1464,7 @@ static struct tevent_req *winexe_ctrl_send(
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OPEN, /* CreateDisposition */
0, /* CreateOptions */
+ SMB2_IMPERSONATION_IMPERSONATION,
0); /* SecurityFlags */
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
diff --git a/python/samba/tests/libsmb_samba_internal.py b/python/samba/tests/libsmb_samba_internal.py
index c88095c8bc2..8918d848ea8 100644
--- a/python/samba/tests/libsmb_samba_internal.py
+++ b/python/samba/tests/libsmb_samba_internal.py
@@ -59,7 +59,9 @@ class LibsmbTestCase(samba.tests.TestCase):
creds.set_username(os.getenv("USERNAME"))
creds.set_password(os.getenv("PASSWORD"))
- c = libsmb_samba_internal.Conn(os.getenv("SERVER_IP"), "tmp", creds)
+ c = libsmb_samba_internal.Conn(os.getenv("SERVER_IP"), "tmp",
+ creds, multi_threaded=True,
+ force_smb1=True)
mythreads = []
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 35edec88809..6cba4422634 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -171,6 +171,7 @@ struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
struct cli_state *cli,
const char *fname,
uint32_t create_flags,
+ uint32_t impersonation_level,
uint32_t desired_access,
uint32_t file_attributes,
uint32_t share_access,
@@ -262,7 +263,7 @@ struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
cli->smb2.tcon,
fname,
flags_to_smb2_oplock(create_flags),
- SMB2_IMPERSONATION_IMPERSONATION,
+ impersonation_level,
desired_access,
file_attributes,
share_access,
@@ -334,6 +335,7 @@ NTSTATUS cli_smb2_create_fnum_recv(struct tevent_req *req, uint16_t *pfnum,
NTSTATUS cli_smb2_create_fnum(struct cli_state *cli,
const char *fname,
uint32_t create_flags,
+ uint32_t impersonation_level,
uint32_t desired_access,
uint32_t file_attributes,
uint32_t share_access,
@@ -359,6 +361,7 @@ NTSTATUS cli_smb2_create_fnum(struct cli_state *cli,
goto fail;
}
req = cli_smb2_create_fnum_send(frame, ev, cli, fname, create_flags,
+ impersonation_level,
desired_access, file_attributes,
share_access, create_disposition,
create_options);
@@ -641,6 +644,7 @@ NTSTATUS cli_smb2_mkdir(struct cli_state *cli, const char *dname)
status = cli_smb2_create_fnum(cli,
dname,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
FILE_READ_ATTRIBUTES, /* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
@@ -679,6 +683,7 @@ NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname)
status = cli_smb2_create_fnum(cli,
dname,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
DELETE_ACCESS, /* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -697,6 +702,7 @@ NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname)
status = cli_smb2_create_fnum(cli,
dname,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
DELETE_ACCESS, /* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -745,6 +751,7 @@ NTSTATUS cli_smb2_unlink(struct cli_state *cli, const char *fname)
status = cli_smb2_create_fnum(cli,
fname,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
DELETE_ACCESS, /* desired_access */
FILE_ATTRIBUTE_NORMAL, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -763,6 +770,7 @@ NTSTATUS cli_smb2_unlink(struct cli_state *cli, const char *fname)
status = cli_smb2_create_fnum(cli,
fname,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
DELETE_ACCESS, /* desired_access */
FILE_ATTRIBUTE_NORMAL, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -940,6 +948,7 @@ NTSTATUS cli_smb2_list(struct cli_state *cli,
status = cli_smb2_create_fnum(cli,
parent_dir,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
SEC_DIR_LIST|SEC_DIR_READ_ATTRIBUTE,/* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
@@ -1116,6 +1125,7 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
status = cli_smb2_create_fnum(cli,
name,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
FILE_READ_ATTRIBUTES, /* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -1129,6 +1139,7 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
status = cli_smb2_create_fnum(cli,
name,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
FILE_READ_ATTRIBUTES, /* desired_access */
0, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -1181,6 +1192,7 @@ NTSTATUS cli_smb2_chkpath(struct cli_state *cli,
status = cli_smb2_create_fnum(cli,
name,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
FILE_READ_ATTRIBUTES, /* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -1226,6 +1238,7 @@ static NTSTATUS get_fnum_from_path(struct cli_state *cli,
status = cli_smb2_create_fnum(cli,
name,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
desired_access,
0, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -1245,6 +1258,7 @@ static NTSTATUS get_fnum_from_path(struct cli_state *cli,
status = cli_smb2_create_fnum(cli,
name,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
desired_access,
0, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -1259,6 +1273,7 @@ static NTSTATUS get_fnum_from_path(struct cli_state *cli,
status = cli_smb2_create_fnum(cli,
name,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
desired_access,
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -1994,6 +2009,7 @@ NTSTATUS cli_smb2_dskattr(struct cli_state *cli, const char *path,
status = cli_smb2_create_fnum(cli,
path,
0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
FILE_READ_ATTRIBUTES, /* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
@@ -2103,6 +2119,7 @@ NTSTATUS cli_smb2_get_fs_full_size_info(struct cli_state *cli,
/* First open the top level directory. */
status =
cli_smb2_create_fnum(cli, "", 0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
FILE_READ_ATTRIBUTES, /* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ | FILE_SHARE_WRITE |
@@ -2195,6 +2212,7 @@ NTSTATUS cli_smb2_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr)
/* First open the top level directory. */
status =
cli_smb2_create_fnum(cli, "", 0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
FILE_READ_ATTRIBUTES, /* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ | FILE_SHARE_WRITE |
@@ -2280,6 +2298,7 @@ NTSTATUS cli_smb2_get_fs_volume_info(struct cli_state *cli,
/* First open the top level directory. */
status =
cli_smb2_create_fnum(cli, "", 0, /* create_flags */
+ SMB2_IMPERSONATION_IMPERSONATION,
FILE_READ_ATTRIBUTES, /* desired_access */
FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
FILE_SHARE_READ | FILE_SHARE_WRITE |
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 4fce5fce1c3..921dc71d9eb 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -30,6 +30,7 @@ struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
struct cli_state *cli,
const char *fname,
uint32_t create_flags,
+ uint32_t impersonation_level,
uint32_t desired_access,
uint32_t file_attributes,
uint32_t share_access,
@@ -40,6 +41,7 @@ NTSTATUS cli_smb2_create_fnum_recv(struct tevent_req *req, uint16_t *pfnum,
NTSTATUS cli_smb2_create_fnum(struct cli_state *cli,
const char *fname,
uint32_t create_flags,
+ uint32_t impersonation_level,
uint32_t desired_access,
uint32_t file_attributes,
uint32_t share_access,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index b50926307a5..6defa38fdee 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1951,6 +1951,7 @@ static struct tevent_req *cli_ntcreate1_send(TALLOC_CTX *mem_ctx,
uint32_t ShareAccess,
uint32_t CreateDisposition,
uint32_t CreateOptions,
+ uint32_t ImpersonationLevel,
uint8_t SecurityFlags)
{
struct tevent_req *req, *subreq;
@@ -1985,7 +1986,7 @@ static struct tevent_req *cli_ntcreate1_send(TALLOC_CTX *mem_ctx,
SIVAL(vwv+17, 1, CreateDisposition);
SIVAL(vwv+19, 1, CreateOptions |
(cli->backup_intent ? FILE_OPEN_FOR_BACKUP_INTENT : 0));
- SIVAL(vwv+21, 1, 0x02); /* ImpersonationLevel */
+ SIVAL(vwv+21, 1, ImpersonationLevel);
SCVAL(vwv+23, 1, SecurityFlags);
bytes = talloc_array(state, uint8_t, 0);
@@ -2098,6 +2099,7 @@ struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
uint32_t share_access,
uint32_t create_disposition,
uint32_t create_options,
+ uint32_t impersonation_level,
uint8_t security_flags)
{
struct tevent_req *req, *subreq;
@@ -2116,7 +2118,8 @@ struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
}
subreq = cli_smb2_create_fnum_send(
- state, ev, cli, fname, create_flags, desired_access,
+ state, ev, cli, fname, create_flags,
+ impersonation_level, desired_access,
file_attributes, share_access, create_disposition,
create_options);
} else {
@@ -2124,7 +2127,7 @@ struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
subreq = cli_ntcreate1_send(
state, ev, cli, fname, create_flags, desired_access,
file_attributes, share_access, create_disposition,
- create_options, security_flags);
+ create_options, impersonation_level, security_flags);
}
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
@@ -2194,6 +2197,7 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
TALLOC_CTX *frame = talloc_stackframe();
struct tevent_context *ev;
struct tevent_req *req;
+ uint32_t ImpersonationLevel = SMB2_IMPERSONATION_IMPERSONATION;
NTSTATUS status = NT_STATUS_NO_MEMORY;
if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -2212,7 +2216,7 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
req = cli_ntcreate_send(frame, ev, cli, fname, CreatFlags,
DesiredAccess, FileAttributes, ShareAccess,
CreateDisposition, CreateOptions,
- SecurityFlags);
+ ImpersonationLevel, SecurityFlags);
if (req == NULL) {
goto fail;
}
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 6bf3df6913f..e953fa5e228 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -1065,6 +1065,130 @@ NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten)
return NT_STATUS_OK;
}
+struct cli_write_state {
+ struct cli_state *cli;
+ size_t written;
+};
+
+static void cli_write_done(struct tevent_req *subreq);
+
+/*
+ * Used to write to a file remotely.
+ * This is similar in functionality to cli_push_send(), except this is a more
+ * finer-grain API. For example, if the data we want to write exceeds the max
+ * write size of the underlying connection, then it's the caller's
+ * responsibility to handle this.
+ * For writing a small amount of data to file, this is a simpler API to use.
+ */
+struct tevent_req *cli_write_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli, uint16_t fnum,
+ uint16_t mode, const uint8_t *buf,
+ off_t offset, size_t size)
+{
+ struct tevent_req *req = NULL;
+ struct cli_write_state *state = NULL;
+ struct tevent_req *subreq = NULL;
+
+ req = tevent_req_create(mem_ctx, &state, struct cli_write_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->cli = cli;
+
+ if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+ uint32_t max_size;
+ bool ok;
+
+ ok = smb2cli_conn_req_possible(state->cli->conn, &max_size);
+ if (!ok) {
+ tevent_req_nterror(
+ req,
+ NT_STATUS_INSUFFICIENT_RESOURCES);
+ return tevent_req_post(req, ev);
+ }
+
+ /*
+ * downgrade depending on the available credits
+ */
+ size = MIN(max_size, size);
+
+ subreq = cli_smb2_write_send(state,
+ ev,
+ cli,
+ fnum,
+ mode,
+ buf,
+ offset,
+ size);
+ } else {
+ bool ok;
+
+ ok = smb1cli_conn_req_possible(state->cli->conn);
+ if (!ok) {
+ tevent_req_nterror(
+ req,
+ NT_STATUS_INSUFFICIENT_RESOURCES);
+ return tevent_req_post(req, ev);
+ }
+
+ subreq = cli_write_andx_send(state,
+ ev,
+ cli,
+ fnum,
+ mode,
+ buf,
+ offset,
+ size);
+ }
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, cli_write_done, req);
+
+ return req;
+}
+
+static void cli_write_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req =
+ tevent_req_callback_data(subreq,
+ struct tevent_req);
+ struct cli_write_state *state =
+ tevent_req_data(req,
+ struct cli_write_state);
+ NTSTATUS status;
+
+ if (smbXcli_conn_protocol(state->cli->conn) >= PROTOCOL_SMB2_02) {
+ status = cli_smb2_write_recv(subreq, &state->written);
+ } else {
+ status = cli_write_andx_recv(subreq, &state->written);
+ }
+ TALLOC_FREE(subreq);
+ if (tevent_req_nterror(req, status)) {
+ return;
+ }
+ tevent_req_done(req);
+}
+
+NTSTATUS cli_write_recv(struct tevent_req *req, size_t *pwritten)
+{
+ struct cli_write_state *state =
+ tevent_req_data(req,
+ struct cli_write_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ tevent_req_received(req);
+ return status;
+ }
+ if (pwritten != NULL) {
+ *pwritten = state->written;
+ }
+ tevent_req_received(req);
+ return NT_STATUS_OK;
+}
+
struct cli_smb1_writeall_state {
struct tevent_context *ev;
struct cli_state *cli;
@@ -1339,6 +1463,16 @@ static void cli_push_setup_chunks(struct tevent_req *req);
static void cli_push_chunk_ship(struct cli_push_chunk *chunk);
static void cli_push_chunk_done(struct tevent_req *subreq);
+/*
+ * Used to write to a file remotely.
+ * This is similar in functionality to cli_write_send(), except this API
+ * handles writing a large file by breaking the data into chunks (so we don't
+ * exceed the max write size of the underlying connection). To do this, the
+ * (*source) callback handles copying the underlying file data into a message
+ * buffer, one chunk at a time.
+ * This API is recommended when writing a potentially large amount of data,
+ * e.g. when copying a file (or doing a 'put').
+ */
struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct cli_state *cli,
uint16_t fnum, uint16_t mode,
diff --git a/source3/libsmb/clisymlink.c b/source3/libsmb/clisymlink.c
index 54435e468cd..1330752358d 100644
--- a/source3/libsmb/clisymlink.c
+++ b/source3/libsmb/clisymlink.c
@@ -72,7 +72,8 @@ struct tevent_req *cli_symlink_send(TALLOC_CTX *mem_ctx,
FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES,
FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE, FILE_CREATE,
FILE_OPEN_REPARSE_POINT|FILE_SYNCHRONOUS_IO_NONALERT|
- FILE_NON_DIRECTORY_FILE, 0);
--
Samba Shared Repository
More information about the samba-cvs
mailing list