[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Wed Mar 20 23:33:01 UTC 2019
The branch, master has been updated
via 2a430625e77 libsmb: Make SMB1-only cli_nt_hardlink calls static
via 8c12a705e6f utils: Use cli_hardlink instead of cli_nt_hardlink
via b5af004b235 libsmb: Introduce protocol-agnostic cli_hardlink
via b4c87b09b66 libsmb: Use cli_smb2_set_info_fnum()
via c013aad7b73 libsmb: Simplify cli_smb2_ftruncate
via 32c5b6c1c21 libsmb: Simplify cli_smb2_delete_on_close
via 4f5b9e509f4 libsmb: Add cli_smb2_set_info_fnum
from bf469343f57 s4:librpc: Fix installation of Samba
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 2a430625e77ecf81552f06b98b7bf91f5112a7df
Author: Volker Lendecke <vl at samba.org>
Date: Mon Mar 18 11:03:32 2019 +0100
libsmb: Make SMB1-only cli_nt_hardlink calls static
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Wed Mar 20 23:32:31 UTC 2019 on sn-devel-144
commit 8c12a705e6f16bfe0260c82fcbd62043a4a6ee37
Author: Volker Lendecke <vl at samba.org>
Date: Mon Mar 18 11:00:50 2019 +0100
utils: Use cli_hardlink instead of cli_nt_hardlink
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit b5af004b23541550f46ef9b8fcaf5cb045f9da25
Author: Volker Lendecke <vl at samba.org>
Date: Mon Mar 18 10:34:53 2019 +0100
libsmb: Introduce protocol-agnostic cli_hardlink
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit b4c87b09b6630e29f8f0a7e4533acee63839d899
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 17 14:00:09 2019 +0100
libsmb: Use cli_smb2_set_info_fnum()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit c013aad7b737bf95dd381b3bfa16b70e36884459
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 17 12:24:05 2019 +0100
libsmb: Simplify cli_smb2_ftruncate
We don't need to talloc 8 bytes, they can live on the stack. When we
go async, this can go into the state struct.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 32c5b6c1c216f264f4d8560b2b53e19dbf66e447
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 17 09:25:42 2019 +0100
libsmb: Simplify cli_smb2_delete_on_close
Use cli_smb2_set_info_fnum, remove "state" variables
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 4f5b9e509f4217dea8842c4c8ae428728efa33da
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 17 09:17:11 2019 +0100
libsmb: Add cli_smb2_set_info_fnum
This wraps getting the file handle from the fnum
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/client/client.c | 2 +-
source3/libsmb/cli_smb2_fnum.c | 343 +++++++++++++++++++++--------------------
source3/libsmb/cli_smb2_fnum.h | 17 ++
source3/libsmb/clifile.c | 235 +++++++++++++++++++++++++---
source3/libsmb/proto.h | 18 ++-
source3/torture/torture.c | 4 +-
6 files changed, 426 insertions(+), 193 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/client/client.c b/source3/client/client.c
index 9db8ff65717..366368630cb 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -4492,7 +4492,7 @@ static int cmd_hardlink(void)
return 1;
}
- status = cli_nt_hardlink(targetcli, targetname, dest);
+ status = cli_hardlink(targetcli, targetname, dest);
if (!NT_STATUS_IS_OK(status)) {
d_printf("%s doing an NT hard link of files\n",
nt_errstr(status));
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index fd73e26fb2a..38e46329fb0 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -534,10 +534,118 @@ NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum)
return status;
}
+struct cli_smb2_set_info_fnum_state {
+ uint8_t dummy;
+};
+
+static void cli_smb2_set_info_fnum_done(struct tevent_req *subreq);
+
+struct tevent_req *cli_smb2_set_info_fnum_send(
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cli_state *cli,
+ uint16_t fnum,
+ uint8_t in_info_type,
+ uint8_t in_info_class,
+ const DATA_BLOB *in_input_buffer,
+ uint32_t in_additional_info)
+{
+ struct tevent_req *req = NULL, *subreq = NULL;
+ struct cli_smb2_set_info_fnum_state *state = NULL;
+ struct smb2_hnd *ph = NULL;
+ NTSTATUS status;
+
+ req = tevent_req_create(
+ mem_ctx, &state, struct cli_smb2_set_info_fnum_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ status = map_fnum_to_smb2_handle(cli, fnum, &ph);
+ if (tevent_req_nterror(req, status)) {
+ return tevent_req_post(req, ev);
+ }
+
+ subreq = smb2cli_set_info_send(
+ state,
+ ev,
+ cli->conn,
+ cli->timeout,
+ cli->smb2.session,
+ cli->smb2.tcon,
+ in_info_type,
+ in_info_class,
+ in_input_buffer,
+ in_additional_info,
+ ph->fid_persistent,
+ ph->fid_volatile);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, cli_smb2_set_info_fnum_done, req);
+ return req;
+}
+
+static void cli_smb2_set_info_fnum_done(struct tevent_req *subreq)
+{
+ NTSTATUS status = smb2cli_set_info_recv(subreq);
+ tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
+NTSTATUS cli_smb2_set_info_fnum_recv(struct tevent_req *req)
+{
+ return tevent_req_simple_recv_ntstatus(req);
+}
+
+NTSTATUS cli_smb2_set_info_fnum(
+ struct cli_state *cli,
+ uint16_t fnum,
+ uint8_t in_info_type,
+ uint8_t in_info_class,
+ const DATA_BLOB *in_input_buffer,
+ uint32_t in_additional_info)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct tevent_context *ev = NULL;
+ struct tevent_req *req = NULL;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+ bool ok;
+
+ if (smbXcli_conn_has_async_calls(cli->conn)) {
+ /*
+ * Can't use sync call while an async call is in flight
+ */
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
+ }
+ ev = samba_tevent_context_init(frame);
+ if (ev == NULL) {
+ goto fail;
+ }
+ req = cli_smb2_set_info_fnum_send(
+ frame,
+ ev,
+ cli,
+ fnum,
+ in_info_type,
+ in_info_class,
+ in_input_buffer,
+ in_additional_info);
+ if (req == NULL) {
+ goto fail;
+ }
+ ok = tevent_req_poll_ntstatus(req, ev, &status);
+ if (!ok) {
+ goto fail;
+ }
+ status = cli_smb2_set_info_fnum_recv(req);
+fail:
+ TALLOC_FREE(frame);
+ return status;
+}
+
struct cli_smb2_delete_on_close_state {
struct cli_state *cli;
- uint16_t fnum;
- struct smb2_hnd *ph;
uint8_t data[1];
DATA_BLOB inbuf;
};
@@ -555,7 +663,6 @@ struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx,
struct tevent_req *subreq = NULL;
uint8_t in_info_type;
uint8_t in_file_info_class;
- NTSTATUS status;
req = tevent_req_create(mem_ctx, &state,
struct cli_smb2_delete_on_close_state);
@@ -563,18 +670,12 @@ struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx,
return NULL;
}
state->cli = cli;
- state->fnum = fnum;
if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
return tevent_req_post(req, ev);
}
- status = map_fnum_to_smb2_handle(cli, fnum, &state->ph);
- if (tevent_req_nterror(req, status)) {
- return tevent_req_post(req, ev);
- }
-
/*
* setinfo on the handle with info_type SMB2_SETINFO_FILE (1),
* level 13 (SMB_FILE_DISPOSITION_INFORMATION - 1000).
@@ -586,17 +687,15 @@ struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx,
state->inbuf.data = &state->data[0];
state->inbuf.length = 1;
- subreq = smb2cli_set_info_send(state, ev,
- cli->conn,
- cli->timeout,
- cli->smb2.session,
- cli->smb2.tcon,
- in_info_type,
- in_file_info_class,
- &state->inbuf, /* in_input_buffer */
- 0, /* in_additional_info */
- state->ph->fid_persistent,
- state->ph->fid_volatile);
+ subreq = cli_smb2_set_info_fnum_send(
+ state,
+ ev,
+ cli,
+ fnum,
+ in_info_type,
+ in_file_info_class,
+ &state->inbuf,
+ 0);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
@@ -608,7 +707,7 @@ struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx,
static void cli_smb2_delete_on_close_done(struct tevent_req *subreq)
{
- NTSTATUS status = smb2cli_set_info_recv(subreq);
+ NTSTATUS status = cli_smb2_set_info_fnum_recv(subreq);
tevent_req_simple_finish_ntstatus(subreq, status);
}
@@ -2258,7 +2357,6 @@ NTSTATUS cli_smb2_setpathinfo(struct cli_state *cli,
{
NTSTATUS status;
uint16_t fnum = 0xffff;
- struct smb2_hnd *ph = NULL;
TALLOC_CTX *frame = talloc_stackframe();
if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -2283,23 +2381,13 @@ NTSTATUS cli_smb2_setpathinfo(struct cli_state *cli,
goto fail;
}
- status = map_fnum_to_smb2_handle(cli,
- fnum,
- &ph);
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
- }
-
- status = smb2cli_set_info(cli->conn,
- cli->timeout,
- cli->smb2.session,
- cli->smb2.tcon,
- in_info_type,
- in_file_info_class,
- p_in_data, /* in_input_buffer */
- 0, /* in_additional_info */
- ph->fid_persistent,
- ph->fid_volatile);
+ status = cli_smb2_set_info_fnum(
+ cli,
+ fnum,
+ in_info_type,
+ in_file_info_class,
+ p_in_data, /* in_input_buffer */
+ 0); /* in_additional_info */
fail:
if (fnum != 0xffff) {
@@ -2385,8 +2473,6 @@ NTSTATUS cli_smb2_setattrE(struct cli_state *cli,
time_t access_time,
time_t write_time)
{
- NTSTATUS status;
- struct smb2_hnd *ph = NULL;
uint8_t inbuf_store[40];
DATA_BLOB inbuf = data_blob_null;
@@ -2401,13 +2487,6 @@ NTSTATUS cli_smb2_setattrE(struct cli_state *cli,
return NT_STATUS_INVALID_PARAMETER;
}
- status = map_fnum_to_smb2_handle(cli,
- fnum,
- &ph);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
/* setinfo on the handle with info_type SMB2_SETINFO_FILE (1),
level 4 (SMB_FILE_BASIC_INFORMATION - 1000). */
@@ -2426,16 +2505,13 @@ NTSTATUS cli_smb2_setattrE(struct cli_state *cli,
put_long_date((char *)inbuf.data + 16, write_time);
}
- cli->raw_status = smb2cli_set_info(cli->conn,
- cli->timeout,
- cli->smb2.session,
- cli->smb2.tcon,
- 1, /* in_info_type */
- SMB_FILE_BASIC_INFORMATION - 1000, /* in_file_info_class */
- &inbuf, /* in_input_buffer */
- 0, /* in_additional_info */
- ph->fid_persistent,
- ph->fid_volatile);
+ cli->raw_status = cli_smb2_set_info_fnum(
+ cli,
+ fnum,
+ 1, /* in_info_type */
+ SMB_FILE_BASIC_INFORMATION - 1000, /* in_file_info_class */
+ &inbuf, /* in_input_buffer */
+ 0); /* in_additional_info */
return cli->raw_status;
}
@@ -2921,7 +2997,6 @@ NTSTATUS cli_smb2_set_security_descriptor(struct cli_state *cli,
{
NTSTATUS status;
DATA_BLOB inbuf = data_blob_null;
- struct smb2_hnd *ph = NULL;
TALLOC_CTX *frame = talloc_stackframe();
if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -2937,13 +3012,6 @@ NTSTATUS cli_smb2_set_security_descriptor(struct cli_state *cli,
goto fail;
}
- status = map_fnum_to_smb2_handle(cli,
- fnum,
- &ph);
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
- }
-
status = marshall_sec_desc(frame,
sd,
&inbuf.data,
@@ -2955,16 +3023,13 @@ NTSTATUS cli_smb2_set_security_descriptor(struct cli_state *cli,
/* setinfo on the returned handle with info_type SMB2_SETINFO_SEC (3) */
- status = smb2cli_set_info(cli->conn,
- cli->timeout,
- cli->smb2.session,
- cli->smb2.tcon,
- 3, /* in_info_type */
- 0, /* in_file_info_class */
- &inbuf, /* in_input_buffer */
- sec_info, /* in_additional_info */
- ph->fid_persistent,
- ph->fid_volatile);
+ status = cli_smb2_set_info_fnum(
+ cli,
+ fnum,
+ 3, /* in_info_type */
+ 0, /* in_file_info_class */
+ &inbuf, /* in_input_buffer */
+ sec_info); /* in_additional_info */
fail:
@@ -3170,7 +3235,6 @@ NTSTATUS cli_smb2_rename(struct cli_state *cli,
NTSTATUS status;
DATA_BLOB inbuf = data_blob_null;
uint16_t fnum = 0xffff;
- struct smb2_hnd *ph = NULL;
smb_ucs2_t *converted_str = NULL;
size_t converted_size_bytes = 0;
size_t namelen = 0;
@@ -3198,13 +3262,6 @@ NTSTATUS cli_smb2_rename(struct cli_state *cli,
goto fail;
}
- status = map_fnum_to_smb2_handle(cli,
- fnum,
- &ph);
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
- }
-
/* SMB2 is pickier about pathnames. Ensure it doesn't
start in a '\' */
if (*fname_dst == '\\') {
@@ -3255,16 +3312,13 @@ NTSTATUS cli_smb2_rename(struct cli_state *cli,
/* setinfo on the returned handle with info_type SMB2_GETINFO_FILE (1),
level SMB2_FILE_RENAME_INFORMATION (SMB_FILE_RENAME_INFORMATION - 1000) */
- status = smb2cli_set_info(cli->conn,
- cli->timeout,
- cli->smb2.session,
- cli->smb2.tcon,
- 1, /* in_info_type */
- SMB_FILE_RENAME_INFORMATION - 1000, /* in_file_info_class */
- &inbuf, /* in_input_buffer */
- 0, /* in_additional_info */
- ph->fid_persistent,
- ph->fid_volatile);
+ status = cli_smb2_set_info_fnum(
+ cli,
+ fnum,
+ 1, /* in_info_type */
+ SMB_FILE_RENAME_INFORMATION - 1000, /* in_file_info_class */
+ &inbuf, /* in_input_buffer */
+ 0); /* in_additional_info */
fail:
@@ -3294,7 +3348,6 @@ NTSTATUS cli_smb2_set_ea_fnum(struct cli_state *cli,
size_t bloblen = 0;
char *ea_name_ascii = NULL;
size_t namelen = 0;
- struct smb2_hnd *ph = NULL;
TALLOC_CTX *frame = talloc_stackframe();
if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -3310,13 +3363,6 @@ NTSTATUS cli_smb2_set_ea_fnum(struct cli_state *cli,
goto fail;
}
- status = map_fnum_to_smb2_handle(cli,
- fnum,
- &ph);
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
- }
-
/* Marshall the SMB2 EA data. */
if (ea_len > 0xFFFF) {
status = NT_STATUS_INVALID_PARAMETER;
@@ -3354,16 +3400,13 @@ NTSTATUS cli_smb2_set_ea_fnum(struct cli_state *cli,
/* setinfo on the handle with info_type SMB2_SETINFO_FILE (1),
level 15 (SMB_FILE_FULL_EA_INFORMATION - 1000). */
- status = smb2cli_set_info(cli->conn,
- cli->timeout,
- cli->smb2.session,
- cli->smb2.tcon,
- 1, /* in_info_type */
- SMB_FILE_FULL_EA_INFORMATION - 1000, /* in_file_info_class */
- &inbuf, /* in_input_buffer */
- 0, /* in_additional_info */
- ph->fid_persistent,
- ph->fid_volatile);
+ status = cli_smb2_set_info_fnum(
+ cli,
+ fnum,
+ 1, /* in_info_type */
+ SMB_FILE_FULL_EA_INFORMATION - 1000, /* in_file_info_class */
+ &inbuf, /* in_input_buffer */
+ 0); /* in_additional_info */
fail:
@@ -3779,7 +3822,6 @@ NTSTATUS cli_smb2_set_user_quota(struct cli_state *cli,
{
NTSTATUS status;
DATA_BLOB inbuf = data_blob_null;
- struct smb2_hnd *ph = NULL;
TALLOC_CTX *frame = talloc_stackframe();
if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -3795,22 +3837,18 @@ NTSTATUS cli_smb2_set_user_quota(struct cli_state *cli,
goto cleanup;
}
- status = map_fnum_to_smb2_handle(cli, quota_fnum, &ph);
- if (!NT_STATUS_IS_OK(status)) {
- goto cleanup;
- }
-
status = build_user_quota_buffer(qtl, 0, talloc_tos(), &inbuf, NULL);
if (!NT_STATUS_IS_OK(status)) {
goto cleanup;
}
- status = smb2cli_set_info(cli->conn, cli->timeout, cli->smb2.session,
- cli->smb2.tcon, 4, /* in_info_type */
- 0, /* in_file_info_class */
- &inbuf, /* in_input_buffer */
- 0, /* in_additional_info */
- ph->fid_persistent, ph->fid_volatile);
+ status = cli_smb2_set_info_fnum(
+ cli,
+ quota_fnum,
+ 4, /* in_info_type */
+ 0, /* in_file_info_class */
+ &inbuf, /* in_input_buffer */
+ 0); /* in_additional_info */
cleanup:
cli->raw_status = status;
@@ -3826,7 +3864,6 @@ NTSTATUS cli_smb2_set_fs_quota_info(struct cli_state *cli,
{
NTSTATUS status;
DATA_BLOB inbuf = data_blob_null;
- struct smb2_hnd *ph = NULL;
TALLOC_CTX *frame = talloc_stackframe();
if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -3842,23 +3879,18 @@ NTSTATUS cli_smb2_set_fs_quota_info(struct cli_state *cli,
goto cleanup;
}
- status = map_fnum_to_smb2_handle(cli, quota_fnum, &ph);
- if (!NT_STATUS_IS_OK(status)) {
- goto cleanup;
- }
-
status = build_fs_quota_buffer(talloc_tos(), pqt, &inbuf, 0);
if (!NT_STATUS_IS_OK(status)) {
goto cleanup;
}
- status = smb2cli_set_info(
- cli->conn, cli->timeout, cli->smb2.session, cli->smb2.tcon,
- 2, /* in_info_type */
- SMB_FS_QUOTA_INFORMATION - 1000, /* in_file_info_class */
- &inbuf, /* in_input_buffer */
- 0, /* in_additional_info */
- ph->fid_persistent, ph->fid_volatile);
+ status = cli_smb2_set_info_fnum(
+ cli,
+ quota_fnum,
+ 2, /* in_info_type */
+ SMB_FS_QUOTA_INFORMATION - 1000, /* in_file_info_class */
+ &inbuf, /* in_input_buffer */
+ 0); /* in_additional_info */
cleanup:
--
Samba Shared Repository
More information about the samba-cvs
mailing list