From f72ef19cf51d8ededa449344cc16b72cf3685302 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 7 Oct 2023 12:06:26 +0200 Subject: [PATCH] libsmb: Add "flags" to cli_smb2_close_fnum_send() Bug: https://bugzilla.samba.org/show_bug.cgi?id=15487 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- examples/fuse/clifuse.c | 2 +- source3/libsmb/cli_smb2_fnum.c | 56 +++++++++++++++++++++++----------- source3/libsmb/cli_smb2_fnum.h | 3 +- source3/libsmb/clifile.c | 12 ++++---- 4 files changed, 48 insertions(+), 25 deletions(-) diff --git a/examples/fuse/clifuse.c b/examples/fuse/clifuse.c index 28c5177b250..ba4aca751fe 100644 --- a/examples/fuse/clifuse.c +++ b/examples/fuse/clifuse.c @@ -952,7 +952,7 @@ static void cli_ll_release(fuse_req_t freq, fuse_ino_t ino, fnum = fi->fh; - req = cli_smb2_close_fnum_send(state, mstate->ev, mstate->cli, fnum); + req = cli_smb2_close_fnum_send(state, mstate->ev, mstate->cli, fnum, 0); if (req == NULL) { TALLOC_FREE(state); fuse_reply_err(freq, ENOMEM); diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 42f6d807fc5..1939db1b711 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -463,7 +463,8 @@ static void cli_smb2_close_fnum_done(struct tevent_req *subreq); struct tevent_req *cli_smb2_close_fnum_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, - uint16_t fnum) + uint16_t fnum, + uint16_t flags) { struct tevent_req *req, *subreq; struct cli_smb2_close_fnum_state *state; @@ -482,9 +483,14 @@ struct tevent_req *cli_smb2_close_fnum_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - subreq = smb2cli_close_send(state, ev, cli->conn, cli->timeout, - cli->smb2.session, cli->smb2.tcon, - 0, state->ph->fid_persistent, + subreq = smb2cli_close_send(state, + ev, + cli->conn, + cli->timeout, + cli->smb2.session, + cli->smb2.tcon, + flags, + state->ph->fid_persistent, state->ph->fid_volatile); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); @@ -546,7 +552,7 @@ NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum) if (ev == NULL) { goto fail; } - req = cli_smb2_close_fnum_send(frame, ev, cli, fnum); + req = cli_smb2_close_fnum_send(frame, ev, cli, fnum, 0); if (req == NULL) { goto fail; } @@ -843,7 +849,8 @@ static void cli_smb2_mkdir_opened(struct tevent_req *subreq) return; } - subreq = cli_smb2_close_fnum_send(state, state->ev, state->cli, fnum); + subreq = + cli_smb2_close_fnum_send(state, state->ev, state->cli, fnum, 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -1004,8 +1011,11 @@ static void cli_smb2_rmdir_disp_set(struct tevent_req *subreq) * Close the fd even if the set_disp failed */ - subreq = cli_smb2_close_fnum_send( - state, state->ev, state->cli, state->fnum); + subreq = cli_smb2_close_fnum_send(state, + state->ev, + state->cli, + state->fnum, + 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -1134,7 +1144,8 @@ static void cli_smb2_unlink_opened1(struct tevent_req *subreq) return; } - subreq = cli_smb2_close_fnum_send(state, state->ev, state->cli, fnum); + subreq = + cli_smb2_close_fnum_send(state, state->ev, state->cli, fnum, 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -1157,7 +1168,8 @@ static void cli_smb2_unlink_opened2(struct tevent_req *subreq) return; } - subreq = cli_smb2_close_fnum_send(state, state->ev, state->cli, fnum); + subreq = + cli_smb2_close_fnum_send(state, state->ev, state->cli, fnum, 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -1541,8 +1553,11 @@ static void cli_smb2_list_done(struct tevent_req *subreq) TALLOC_FREE(response); - subreq = cli_smb2_close_fnum_send( - state, state->ev, state->cli, state->fnum); + subreq = cli_smb2_close_fnum_send(state, + state->ev, + state->cli, + state->fnum, + 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -2345,7 +2360,8 @@ static void cli_smb2_qpathinfo_done(struct tevent_req *subreq) subreq = cli_smb2_close_fnum_send(state, state->ev, state->cli, - state->fnum); + state->fnum, + 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -3027,8 +3043,11 @@ static void cli_smb2_mxac_opened(struct tevent_req *subreq) state->mxac = IVAL(mxac_blob->data.data, 4); close: - subreq = cli_smb2_close_fnum_send( - state, state->ev, state->cli, state->fnum); + subreq = cli_smb2_close_fnum_send(state, + state->ev, + state->cli, + state->fnum, + 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -3333,8 +3352,11 @@ static void cli_smb2_rename_renamed(struct tevent_req *subreq) state->rename_status = cli_smb2_rename_fnum_recv(subreq); TALLOC_FREE(subreq); - subreq = cli_smb2_close_fnum_send( - state, state->ev, state->cli, state->fnum); + subreq = cli_smb2_close_fnum_send(state, + state->ev, + state->cli, + state->fnum, + 0); if (tevent_req_nomem(subreq, req)) { return; } diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h index 0eb2a026527..7f3d7c2be1b 100644 --- a/source3/libsmb/cli_smb2_fnum.h +++ b/source3/libsmb/cli_smb2_fnum.h @@ -70,7 +70,8 @@ NTSTATUS cli_smb2_create_fnum( struct tevent_req *cli_smb2_close_fnum_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, - uint16_t fnum); + uint16_t fnum, + uint16_t flags); NTSTATUS cli_smb2_close_fnum_recv(struct tevent_req *req); NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum); struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx, diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 46b9f27bf4e..fff45072936 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -2048,8 +2048,11 @@ static void cli_smb2_hardlink_info_set(struct tevent_req *subreq) /* ignore error here, we need to close the file */ - subreq = cli_smb2_close_fnum_send( - state, state->ev, state->cli, state->fnum_src); + subreq = cli_smb2_close_fnum_send(state, + state->ev, + state->cli, + state->fnum_src, + 0); if (tevent_req_nomem(subreq, req)) { return; } @@ -3648,10 +3651,7 @@ struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx, } if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { - subreq = cli_smb2_close_fnum_send(state, - ev, - cli, - fnum); + subreq = cli_smb2_close_fnum_send(state, ev, cli, fnum, 0); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); }