The branch, master has been updated via 81226b5179e vfs_aio_pthread: use SMB_VFS_NEXT_OPENAT() in aio_pthread_openat_fn() via 2c6a01c8925 libcli: Add required #includes to smbXcli_base.h via 939aa0e69ef clifuse: Use direct FSCC info level via dd801b69c60 libsmb: Use tevent_req_nterror() properly via edc6e69e254 libsmb: Remove a duplicate TALLOC_FREE() via 107beacfc02 libsmb: Use tevent_req_oom() where appropriate via a6a5ce7b426 libsmb: Move cli_raw_ioctl() to torture3 via 087cddc90c1 libsmb: Move cli_qpathinfo1() to torture3 via c0db32b457d torture3: Avoid unused variables via 914e0cf6f81 smbclient: Don't give up in allinfo if getting advanced info fails via 47509eb7f03 libsmb: Use cli_smb2_qpathinfo_basic() in cli_getatr() via f2d535dbe31 libsmb: Use cli_smb2_qpathinfo() in cli_qpathinfo2() via 50edb0266f9 libsmb: Use cli_smb2_qpathinfo() for streams via 55539629b20 libsmb: Add cli_smb2_qpathinfo_send/recv() from aba7eb094b9 selftest: Report time at which testsuite starts
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 81226b5179e6ba806a0a690806ca2f9004f7c9f9 Author: MikeLiu <mike...@qnap.com> Date: Tue Aug 22 10:01:14 2023 +0800 vfs_aio_pthread: use SMB_VFS_NEXT_OPENAT() in aio_pthread_openat_fn() 1. Set 'aio_allow_open' to false if fsp->fsp_flags.is_pathref 2. Move !(how->flags & O_CREAT) and !(how->flags & O_EXCL) up and set 'aio_allow_open' to false 3. Use SMB_VFS_NEXT_OPENAT() instead of openat() for disable async opens case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15453 Signed-off-by: MikeLiu <mike...@qnap.com> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Tue Aug 22 17:44:00 UTC 2023 on atb-devel-224 commit 2c6a01c8925d0cf8ee9d700e4e95379285e52f45 Author: Volker Lendecke <v...@samba.org> Date: Mon Aug 21 21:41:06 2023 +0200 libcli: Add required #includes to smbXcli_base.h Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 939aa0e69ef8f9d6c583703ef74da73a3e125a9b Author: Volker Lendecke <v...@samba.org> Date: Mon Aug 21 21:34:31 2023 +0200 clifuse: Use direct FSCC info level Avoid the magic -1000 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit dd801b69c60dc5d5793b46fbc5181f868a6db02a Author: Volker Lendecke <v...@samba.org> Date: Wed Aug 16 11:59:03 2023 +0200 libsmb: Use tevent_req_nterror() properly Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit edc6e69e25449a7162938cf7ddfd4b6b7d787023 Author: Volker Lendecke <v...@samba.org> Date: Wed Aug 16 15:45:32 2023 +0200 libsmb: Remove a duplicate TALLOC_FREE() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 107beacfc0212a7117c7b9ae2fbcb7d6224d434c Author: Volker Lendecke <v...@samba.org> Date: Wed Aug 16 15:39:55 2023 +0200 libsmb: Use tevent_req_oom() where appropriate Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit a6a5ce7b4261480ef79da965b43fcb5caa604e3d Author: Volker Lendecke <v...@samba.org> Date: Wed Aug 16 11:04:14 2023 +0200 libsmb: Move cli_raw_ioctl() to torture3 Only used there. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 087cddc90c1b126baabc8088588c07113d919b16 Author: Volker Lendecke <v...@samba.org> Date: Mon Aug 21 12:59:10 2023 +0200 libsmb: Move cli_qpathinfo1() to torture3 It's only used there, and it clutters general code. Re-adding the async flavor is trivial should it ever be required. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit c0db32b457d10aa894e0b6aeb6e682ccaff7737a Author: Volker Lendecke <v...@samba.org> Date: Mon Aug 21 12:45:52 2023 +0200 torture3: Avoid unused variables Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 914e0cf6f81ffef95354b4f8f8429909eb6c32c5 Author: Volker Lendecke <v...@samba.org> Date: Mon Aug 21 10:01:24 2023 +0200 smbclient: Don't give up in allinfo if getting advanced info fails Getting streams might fail, but further down getting reparse info might succeed. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 47509eb7f033c07f2f0aa13cba0e37b3dc1757bd Author: Volker Lendecke <v...@samba.org> Date: Fri Aug 18 16:15:19 2023 +0200 libsmb: Use cli_smb2_qpathinfo_basic() in cli_getatr() cli_smb2_qpathinfo_basic() uses the smb_create_returns and avoids a round-trip. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit f2d535dbe3107c5781e3f0b468780aacd17d9785 Author: Volker Lendecke <v...@samba.org> Date: Fri Aug 18 16:07:56 2023 +0200 libsmb: Use cli_smb2_qpathinfo() in cli_qpathinfo2() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 50edb0266f92cf2f00bbd9f242bb7ee1fd6d9024 Author: Volker Lendecke <v...@samba.org> Date: Fri Aug 18 15:47:20 2023 +0200 libsmb: Use cli_smb2_qpathinfo() for streams Remove sync cli_smb2_qpathinfo_streams() wrapper. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 55539629b20a67884d520ad1639ae7ac3c9e736a Author: Volker Lendecke <v...@samba.org> Date: Fri Jun 30 22:43:43 2023 +0200 libsmb: Add cli_smb2_qpathinfo_send/recv() Wrap the create/qfileinfo/close, to be used in next patches Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: examples/fuse/clifuse.c | 20 +-- libcli/smb/smbXcli_base.h | 7 + source3/client/client.c | 27 ++-- source3/libsmb/cli_smb2_fnum.c | 280 +++++++++----------------------------- source3/libsmb/cli_smb2_fnum.h | 33 ++--- source3/libsmb/cliconnect.c | 21 +-- source3/libsmb/clifile.c | 46 +++---- source3/libsmb/clifsinfo.c | 6 +- source3/libsmb/climessage.c | 19 +-- source3/libsmb/clioplock.c | 2 +- source3/libsmb/clirap.c | 211 ++++++++-------------------- source3/libsmb/clirap.h | 17 --- source3/libsmb/proto.h | 1 - source3/libsmb/smbsock_connect.c | 3 +- source3/modules/vfs_aio_pthread.c | 28 ++-- source3/torture/proto.h | 8 ++ source3/torture/torture.c | 90 +++++++++++- 17 files changed, 309 insertions(+), 510 deletions(-) Changeset truncated at 500 lines: diff --git a/examples/fuse/clifuse.c b/examples/fuse/clifuse.c index 94ec3911ef6..890dae16307 100644 --- a/examples/fuse/clifuse.c +++ b/examples/fuse/clifuse.c @@ -284,14 +284,18 @@ static void cli_get_unixattr_opened(struct tevent_req *subreq) } subreq = smb2cli_query_info_send( - state, state->ev, cli->conn, 0, - cli->smb2.session, cli->smb2.tcon, - 1, /* in_info_type */ - (SMB_FILE_ALL_INFORMATION - 1000), /* in_file_info_class */ - 0xFFFF, /* in_max_output_length */ - NULL, /* in_input_buffer */ - 0, /* in_additional_info */ - 0, /* in_flags */ + state, + state->ev, + cli->conn, + 0, + cli->smb2.session, + cli->smb2.tcon, + 1, /* in_info_type */ + FSCC_FILE_ALL_INFORMATION, /* in_file_info_class */ + 0xFFFF, /* in_max_output_length */ + NULL, /* in_input_buffer */ + 0, /* in_additional_info */ + 0, /* in_flags */ state->fid_persistent, state->fid_volatile); if (tevent_req_nomem(subreq, req)) { diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h index bf8638711ba..fef68b6b38d 100644 --- a/libcli/smb/smbXcli_base.h +++ b/libcli/smb/smbXcli_base.h @@ -23,6 +23,13 @@ #define SMB_SUICIDE_PACKET 0x74697865 +#include "replace.h" +#include <tevent.h> +#include "libcli/smb/smb_constants.h" +#include "libcli/util/ntstatus.h" +#include "lib/util/time.h" +#include "lib/util/data_blob.h" + struct smbXcli_conn; struct smbXcli_session; struct smbXcli_tcon; diff --git a/source3/client/client.c b/source3/client/client.c index 19ff37248c3..1fb3918272b 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -1697,9 +1697,11 @@ static int do_allinfo(const char *name) status = cli_qpathinfo_streams(cli, name, talloc_tos(), &num_streams, &streams); if (!NT_STATUS_IS_OK(status)) { - d_printf("%s getting streams for %s\n", nt_errstr(status), - name); - return false; + d_fprintf(stderr, + "%s getting streams for %s\n", + nt_errstr(status), + name); + num_streams = 0; } for (i=0; i<num_streams; i++) { @@ -1765,15 +1767,20 @@ static int do_allinfo(const char *name) status = cli_shadow_copy_data(talloc_tos(), cli, fnum, false, &snapshots, &num_snapshots); - if (!NT_STATUS_IS_OK(status)) { - cli_close(cli, fnum); - return 0; + if (NT_STATUS_IS_OK(status)) { + status = cli_shadow_copy_data(talloc_tos(), + cli, + fnum, + true, + &snapshots, + &num_snapshots); } - status = cli_shadow_copy_data(talloc_tos(), cli, fnum, - true, &snapshots, &num_snapshots); if (!NT_STATUS_IS_OK(status)) { - cli_close(cli, fnum); - return 0; + d_fprintf(stderr, + "%s getting shadow copy data for %s\n", + nt_errstr(status), + name); + num_snapshots = 0; } for (j=0; j<num_snapshots; j++) { diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 59fdcccc98e..35593312283 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -1462,7 +1462,7 @@ struct tevent_req *cli_smb2_list_send( status = smb2_create_blob_add(in_cblobs, in_cblobs, SMB2_CREATE_TAG_POSIX, blob); - if (!NT_STATUS_IS_OK(status)) { + if (tevent_req_nterror(req, status)) { tevent_req_nterror(req, status); return tevent_req_post(req, ev); } @@ -2243,105 +2243,47 @@ NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli, return status; } -/*************************************************************** - Wrapper that allows SMB2 to get pathname attributes. - Synchronous only. -***************************************************************/ - -NTSTATUS cli_smb2_getatr(struct cli_state *cli, - const char *name, - uint32_t *pattr, - off_t *size, - time_t *write_time) -{ - NTSTATUS status; - uint16_t fnum = 0xffff; - struct timespec write_time_ts; - TALLOC_CTX *frame = talloc_stackframe(); - - 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; - } - - status = get_fnum_from_path(cli, - name, - FILE_READ_ATTRIBUTES, - &fnum); - - if (!NT_STATUS_IS_OK(status)) { - goto fail; - } - - status = cli_qfileinfo_basic( - cli, - fnum, - pattr, - size, - NULL, /* create_time */ - NULL, /* access_time */ - &write_time_ts, - NULL, /* change_time */ - NULL); /* ino */ - if (!NT_STATUS_IS_OK(status)) { - goto fail; - } - if (write_time != NULL) { - *write_time = write_time_ts.tv_sec; - } - - fail: - - if (fnum != 0xffff) { - cli_smb2_close_fnum(cli, fnum); - } - - cli->raw_status = status; - - TALLOC_FREE(frame); - return status; -} - -struct cli_smb2_qpathinfo2_state { +struct cli_smb2_qpathinfo_state { struct tevent_context *ev; struct cli_state *cli; + const char *fname; uint16_t fnum; + uint16_t level; + uint32_t min_rdata; + uint32_t max_rdata; - NTSTATUS queryinfo_status; - struct timespec create_time; - struct timespec access_time; - struct timespec write_time; - struct timespec change_time; - off_t size; - uint32_t attr; - SMB_INO_T ino; + NTSTATUS status; + DATA_BLOB out; }; -static void cli_smb2_qpathinfo2_opened(struct tevent_req *subreq); -static void cli_smb2_qpathinfo2_done(struct tevent_req *subreq); -static void cli_smb2_qpathinfo2_closed(struct tevent_req *subreq); - -struct tevent_req *cli_smb2_qpathinfo2_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct cli_state *cli, - const char *fname) +static void cli_smb2_qpathinfo_opened(struct tevent_req *subreq); +static void cli_smb2_qpathinfo_done(struct tevent_req *subreq); +static void cli_smb2_qpathinfo_closed(struct tevent_req *subreq); + +struct tevent_req *cli_smb2_qpathinfo_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + const char *fname, + uint16_t level, + uint32_t min_rdata, + uint32_t max_rdata) { struct tevent_req *req = NULL, *subreq = NULL; - struct cli_smb2_qpathinfo2_state *state = NULL; + struct cli_smb2_qpathinfo_state *state = NULL; req = tevent_req_create(mem_ctx, &state, - struct cli_smb2_qpathinfo2_state); + struct cli_smb2_qpathinfo_state); if (req == NULL) { return NULL; } state->ev = ev; state->cli = cli; + state->level = level; + state->min_rdata = min_rdata; + state->max_rdata = max_rdata; - subreq = get_fnum_from_path_send(mem_ctx, + subreq = get_fnum_from_path_send(state, ev, cli, fname, @@ -2349,16 +2291,16 @@ struct tevent_req *cli_smb2_qpathinfo2_send(TALLOC_CTX *mem_ctx, if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } - tevent_req_set_callback(subreq, cli_smb2_qpathinfo2_opened, req); + tevent_req_set_callback(subreq, cli_smb2_qpathinfo_opened, req); return req; } -static void cli_smb2_qpathinfo2_opened(struct tevent_req *subreq) +static void cli_smb2_qpathinfo_opened(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data(subreq, struct tevent_req); - struct cli_smb2_qpathinfo2_state *state = - tevent_req_data(req, struct cli_smb2_qpathinfo2_state); + struct cli_smb2_qpathinfo_state *state = + tevent_req_data(req, struct cli_smb2_qpathinfo_state); NTSTATUS status; status = get_fnum_from_path_recv(subreq, &state->fnum); @@ -2367,33 +2309,38 @@ static void cli_smb2_qpathinfo2_opened(struct tevent_req *subreq) return; } - subreq = cli_qfileinfo_basic_send(state, - state->ev, - state->cli, - state->fnum); + subreq = cli_smb2_query_info_fnum_send(state, + state->ev, + state->cli, + state->fnum, + 1, /* in_info_type */ + state->level, + state->max_rdata, + NULL, /* in_input_buffer */ + 0, /* in_additional_info */ + 0); /* in_flags */ if (tevent_req_nomem(subreq, req)) { return; } - tevent_req_set_callback(subreq, cli_smb2_qpathinfo2_done, req); + tevent_req_set_callback(subreq, cli_smb2_qpathinfo_done, req); } -static void cli_smb2_qpathinfo2_done(struct tevent_req *subreq) +static void cli_smb2_qpathinfo_done(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data(subreq, struct tevent_req); - struct cli_smb2_qpathinfo2_state *state = - tevent_req_data(req, struct cli_smb2_qpathinfo2_state); - - state->queryinfo_status = cli_qfileinfo_basic_recv(subreq, - &state->attr, - &state->size, - &state->create_time, - &state->access_time, - &state->write_time, - &state->change_time, - &state->ino); + struct cli_smb2_qpathinfo_state *state = + tevent_req_data(req, struct cli_smb2_qpathinfo_state); + + state->status = + cli_smb2_query_info_fnum_recv(subreq, state, &state->out); TALLOC_FREE(subreq); + if (NT_STATUS_IS_OK(state->status) && + (state->out.length < state->min_rdata)) { + state->status = NT_STATUS_INVALID_NETWORK_RESPONSE; + } + subreq = cli_smb2_close_fnum_send(state, state->ev, state->cli, @@ -2401,15 +2348,15 @@ static void cli_smb2_qpathinfo2_done(struct tevent_req *subreq) if (tevent_req_nomem(subreq, req)) { return; } - tevent_req_set_callback(subreq, cli_smb2_qpathinfo2_closed, req); + tevent_req_set_callback(subreq, cli_smb2_qpathinfo_closed, req); } -static void cli_smb2_qpathinfo2_closed(struct tevent_req *subreq) +static void cli_smb2_qpathinfo_closed(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data(subreq, struct tevent_req); - struct cli_smb2_qpathinfo2_state *state = - tevent_req_data(req, struct cli_smb2_qpathinfo2_state); + struct cli_smb2_qpathinfo_state *state = + tevent_req_data(req, struct cli_smb2_qpathinfo_state); NTSTATUS status; status = cli_smb2_close_fnum_recv(subreq); @@ -2417,128 +2364,31 @@ static void cli_smb2_qpathinfo2_closed(struct tevent_req *subreq) if (tevent_req_nterror(req, status)) { return; } - if (tevent_req_nterror(req, state->queryinfo_status)) { + if (tevent_req_nterror(req, state->status)) { return; } tevent_req_done(req); } -NTSTATUS cli_smb2_qpathinfo2_recv(struct tevent_req *req, - struct timespec *create_time, - struct timespec *access_time, - struct timespec *write_time, - struct timespec *change_time, - off_t *size, - uint32_t *attr, - SMB_INO_T *ino) +NTSTATUS cli_smb2_qpathinfo_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + uint8_t **rdata, + uint32_t *num_rdata) { - struct cli_smb2_qpathinfo2_state *state = - tevent_req_data(req, struct cli_smb2_qpathinfo2_state); + struct cli_smb2_qpathinfo_state *state = + tevent_req_data(req, struct cli_smb2_qpathinfo_state); NTSTATUS status; if (tevent_req_is_nterror(req, &status)) { return status; } - if (create_time != NULL) { - *create_time = state->create_time; - } - if (access_time != NULL) { - *access_time = state->access_time; - } - if (write_time != NULL) { - *write_time = state->write_time; - } - if (change_time != NULL) { - *change_time = state->change_time; - } - if (attr != NULL) { - *attr = state->attr; - } - if (size != NULL) { - *size = state->size; - } - if (ino) { - *ino = state->ino; - } - + *rdata = talloc_move(mem_ctx, &state->out.data); + *num_rdata = state->out.length; + tevent_req_received(req); return NT_STATUS_OK; } -/*************************************************************** - Wrapper that allows SMB2 to query pathname streams. - Synchronous only. -***************************************************************/ - -NTSTATUS cli_smb2_qpathinfo_streams(struct cli_state *cli, - const char *name, - TALLOC_CTX *mem_ctx, - unsigned int *pnum_streams, - struct stream_struct **pstreams) -{ - NTSTATUS status; - uint16_t fnum = 0xffff; - DATA_BLOB outbuf = data_blob_null; - TALLOC_CTX *frame = talloc_stackframe(); - - 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; - } - - status = get_fnum_from_path(cli, - name, - FILE_READ_ATTRIBUTES, - &fnum); - - if (!NT_STATUS_IS_OK(status)) { - goto fail; - } - - /* getinfo on the handle with info_type SMB2_GETINFO_FILE (1), - level 22 (SMB2_FILE_STREAM_INFORMATION). */ - - status = cli_smb2_query_info_fnum( - cli, - fnum, - 1, /* in_info_type */ - (SMB_FILE_STREAM_INFORMATION - 1000), /* in_file_info_class */ - 0xFFFF, /* in_max_output_length */ - NULL, /* in_input_buffer */ - 0, /* in_additional_info */ - 0, /* in_flags */ - frame, - &outbuf); - - if (!NT_STATUS_IS_OK(status)) { - goto fail; - } - - /* Parse the reply. */ - if (!parse_streams_blob(mem_ctx, - outbuf.data, - outbuf.length, - pnum_streams, - pstreams)) { - status = NT_STATUS_INVALID_NETWORK_RESPONSE; - goto fail; - } - - fail: - - if (fnum != 0xffff) { - cli_smb2_close_fnum(cli, fnum); - } - - cli->raw_status = status; - - TALLOC_FREE(frame); - return status; -} - /*************************************************************** Wrapper that allows SMB2 to set SMB_FILE_BASIC_INFORMATION on a pathname. diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h index 986db2c1b0f..0eb2a026527 100644 --- a/source3/libsmb/cli_smb2_fnum.h +++ b/source3/libsmb/cli_smb2_fnum.h @@ -118,6 +118,17 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli, NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli, const char *name, fstring alt_name); +struct tevent_req *cli_smb2_qpathinfo_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + const char *fname, + uint16_t level, + uint32_t min_rdata, + uint32_t max_rdata); +NTSTATUS cli_smb2_qpathinfo_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + uint8_t **rdata, + uint32_t *num_rdata); struct tevent_req *cli_smb2_query_info_fnum_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -159,28 +170,6 @@ NTSTATUS cli_smb2_query_info_fnum( uint32_t in_flags, TALLOC_CTX *mem_ctx, -- Samba Shared Repository