From: Volker Lendecke Date: Mon, 4 Mar 2019 19:40:14 +0000 (+0100) Subject: libsmb: Add "in_cblobs" to cli_smb2_rmdir X-Git-Tag: talloc-2.2.0~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fc3b2b2642425cf9f55b4409cfb108a5a87e69e;p=thirdparty%2Fsamba.git 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 12f36d9b092..1ba95bb0760 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -707,6 +707,7 @@ struct cli_smb2_rmdir_state { struct tevent_context *ev; struct cli_state *cli; const char *dname; + const struct smb2_create_blobs *in_cblobs; uint16_t fnum; NTSTATUS status; }; @@ -716,10 +717,12 @@ static void cli_smb2_rmdir_opened2(struct tevent_req *subreq); static void cli_smb2_rmdir_disp_set(struct tevent_req *subreq); static void cli_smb2_rmdir_closed(struct tevent_req *subreq); -struct tevent_req *cli_smb2_rmdir_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct cli_state *cli, - const char *dname) +struct tevent_req *cli_smb2_rmdir_send( + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + const char *dname, + const struct smb2_create_blobs *in_cblobs) { struct tevent_req *req = NULL, *subreq = NULL; struct cli_smb2_rmdir_state *state = NULL; @@ -731,6 +734,7 @@ struct tevent_req *cli_smb2_rmdir_send(TALLOC_CTX *mem_ctx, state->ev = ev; state->cli = cli; state->dname = dname; + state->in_cblobs = in_cblobs; if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) { tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); @@ -749,7 +753,7 @@ struct tevent_req *cli_smb2_rmdir_send(TALLOC_CTX *mem_ctx, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */ FILE_OPEN, /* create_disposition */ FILE_DIRECTORY_FILE, /* create_options */ - NULL); /* in_cblobs */ + state->in_cblobs); /* in_cblobs */ if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -790,7 +794,7 @@ static void cli_smb2_rmdir_opened1(struct tevent_req *subreq) FILE_DIRECTORY_FILE| FILE_DELETE_ON_CLOSE| FILE_OPEN_REPARSE_POINT, /* create_options */ - NULL); /* in_cblobs */ + state->in_cblobs); /* in_cblobs */ if (tevent_req_nomem(subreq, req)) { return; } @@ -873,7 +877,10 @@ NTSTATUS cli_smb2_rmdir_recv(struct tevent_req *req) return state->status; } -NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname) +NTSTATUS cli_smb2_rmdir( + struct cli_state *cli, + const char *dname, + const struct smb2_create_blobs *in_cblobs) { TALLOC_CTX *frame = talloc_stackframe(); struct tevent_context *ev; @@ -892,7 +899,7 @@ NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname) if (ev == NULL) { goto fail; } - req = cli_smb2_rmdir_send(frame, ev, cli, dname); + req = cli_smb2_rmdir_send(frame, ev, cli, dname, in_cblobs); if (req == NULL) { goto fail; } diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h index 15a271d3655..9a7b31abc00 100644 --- a/source3/libsmb/cli_smb2_fnum.h +++ b/source3/libsmb/cli_smb2_fnum.h @@ -74,12 +74,17 @@ struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx, NTSTATUS cli_smb2_delete_on_close_recv(struct tevent_req *req); NTSTATUS cli_smb2_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag); NTSTATUS cli_smb2_mkdir(struct cli_state *cli, const char *dirname); -struct tevent_req *cli_smb2_rmdir_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct cli_state *cli, - const char *dname); +struct tevent_req *cli_smb2_rmdir_send( + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct cli_state *cli, + const char *dname, + const struct smb2_create_blobs *in_cblobs); NTSTATUS cli_smb2_rmdir_recv(struct tevent_req *req); -NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dirname); +NTSTATUS cli_smb2_rmdir( + struct cli_state *cli, + const char *dname, + const struct smb2_create_blobs *in_cblobs); struct tevent_req *cli_smb2_unlink_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 49e58c0d252..695ab5e5d84 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -1758,7 +1758,7 @@ NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname) NTSTATUS status = NT_STATUS_OK; if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) { - return cli_smb2_rmdir(cli, dname); + return cli_smb2_rmdir(cli, dname, NULL); } frame = talloc_stackframe();