summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2022-09-20 14:31:31 +0200
committerJeremy Allison <jra@samba.org>2022-11-22 18:27:33 +0000
commit18d6334ca4154649c66cb946834dc1b2588902df (patch)
tree4883da87b75741d6a6127736b46716255e1d9b19
parent0c419b8a204bd21e8991356ac88188c98bcfbb79 (diff)
downloadsamba-18d6334ca4154649c66cb946834dc1b2588902df.tar.gz
libsmb: Pass symlink error up through cli_smb2_create_fnum_recv()
Not passing through the sync wrapper yet. Not needed right now, and it's simple to add if required. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--examples/fuse/clifuse.c4
-rw-r--r--source3/libsmb/cli_smb2_fnum.c34
-rw-r--r--source3/libsmb/cli_smb2_fnum.h4
-rw-r--r--source3/libsmb/clifile.c3
-rw-r--r--source3/libsmb/pylibsmb.c2
5 files changed, 30 insertions, 17 deletions
diff --git a/examples/fuse/clifuse.c b/examples/fuse/clifuse.c
index 721b282baf0..2d9edad5f47 100644
--- a/examples/fuse/clifuse.c
+++ b/examples/fuse/clifuse.c
@@ -178,7 +178,7 @@ static void cli_ll_create_done(struct tevent_req *req)
uint16_t fnum;
NTSTATUS status;
- status = cli_smb2_create_fnum_recv(req, &fnum, NULL, NULL, NULL);
+ status = cli_smb2_create_fnum_recv(req, &fnum, NULL, NULL, NULL, NULL);
TALLOC_FREE(req);
if (!NT_STATUS_IS_OK(status)) {
fuse_reply_err(state->freq, map_errno_from_nt_status(status));
@@ -875,7 +875,7 @@ static void cli_ll_open_done(struct tevent_req *req)
uint16_t fnum;
NTSTATUS status;
- status = cli_smb2_create_fnum_recv(req, &fnum, NULL, NULL, NULL);
+ status = cli_smb2_create_fnum_recv(req, &fnum, NULL, NULL, NULL, NULL);
TALLOC_FREE(req);
if (!NT_STATUS_IS_OK(status)) {
fuse_reply_err(state->freq, map_errno_from_nt_status(status));
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 0f753f61d85..a0323d701c3 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -198,6 +198,7 @@ struct cli_smb2_create_fnum_state {
struct smb2_create_blobs in_cblobs;
struct smb2_create_blobs out_cblobs;
struct smb_create_returns cr;
+ struct symlink_reparse_struct *symlink;
uint16_t fnum;
struct tevent_req *subreq;
};
@@ -344,7 +345,7 @@ static void cli_smb2_create_fnum_done(struct tevent_req *subreq)
&h.fid_volatile, &state->cr,
state,
&state->out_cblobs,
- NULL);
+ &state->symlink);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -369,13 +370,18 @@ NTSTATUS cli_smb2_create_fnum_recv(
uint16_t *pfnum,
struct smb_create_returns *cr,
TALLOC_CTX *mem_ctx,
- struct smb2_create_blobs *out_cblobs)
+ struct smb2_create_blobs *out_cblobs,
+ struct symlink_reparse_struct **symlink)
{
struct cli_smb2_create_fnum_state *state = tevent_req_data(
req, struct cli_smb2_create_fnum_state);
NTSTATUS status;
if (tevent_req_is_nterror(req, &status)) {
+ if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK) &&
+ (symlink != NULL)) {
+ *symlink = talloc_move(mem_ctx, &state->symlink);
+ }
state->cli->raw_status = status;
return status;
}
@@ -447,7 +453,8 @@ NTSTATUS cli_smb2_create_fnum(
if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}
- status = cli_smb2_create_fnum_recv(req, pfid, cr, mem_ctx, out_cblobs);
+ status = cli_smb2_create_fnum_recv(
+ req, pfid, cr, mem_ctx, out_cblobs, NULL);
fail:
TALLOC_FREE(frame);
return status;
@@ -841,7 +848,8 @@ static void cli_smb2_mkdir_opened(struct tevent_req *subreq)
NTSTATUS status;
uint16_t fnum = 0xffff;
- status = cli_smb2_create_fnum_recv(subreq, &fnum, NULL, NULL, NULL);
+ status = cli_smb2_create_fnum_recv(
+ subreq, &fnum, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -927,7 +935,7 @@ static void cli_smb2_rmdir_opened1(struct tevent_req *subreq)
NTSTATUS status;
status = cli_smb2_create_fnum_recv(
- subreq, &state->fnum, NULL, NULL, NULL);
+ subreq, &state->fnum, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) {
@@ -980,7 +988,7 @@ static void cli_smb2_rmdir_opened2(struct tevent_req *subreq)
NTSTATUS status;
status = cli_smb2_create_fnum_recv(
- subreq, &state->fnum, NULL, NULL, NULL);
+ subreq, &state->fnum, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -1099,7 +1107,8 @@ static void cli_smb2_unlink_opened1(struct tevent_req *subreq)
uint16_t fnum = 0xffff;
NTSTATUS status;
- status = cli_smb2_create_fnum_recv(subreq, &fnum, NULL, NULL, NULL);
+ status = cli_smb2_create_fnum_recv(
+ subreq, &fnum, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK) ||
@@ -1153,7 +1162,8 @@ static void cli_smb2_unlink_opened2(struct tevent_req *subreq)
uint16_t fnum = 0xffff;
NTSTATUS status;
- status = cli_smb2_create_fnum_recv(subreq, &fnum, NULL, NULL, NULL);
+ status = cli_smb2_create_fnum_recv(
+ subreq, &fnum, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -1369,7 +1379,7 @@ static void cli_smb2_list_opened(struct tevent_req *subreq)
NTSTATUS status;
status = cli_smb2_create_fnum_recv(
- subreq, &state->fnum, NULL, NULL, NULL);
+ subreq, &state->fnum, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -1885,7 +1895,7 @@ static void get_fnum_from_path_opened_file(struct tevent_req *subreq)
NTSTATUS status;
status = cli_smb2_create_fnum_recv(
- subreq, &state->fnum, NULL, NULL, NULL);
+ subreq, &state->fnum, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) {
@@ -1955,7 +1965,7 @@ static void get_fnum_from_path_opened_reparse(struct tevent_req *subreq)
struct get_fnum_from_path_state *state = tevent_req_data(
req, struct get_fnum_from_path_state);
NTSTATUS status = cli_smb2_create_fnum_recv(
- subreq, &state->fnum, NULL, NULL, NULL);
+ subreq, &state->fnum, NULL, NULL, NULL, NULL);
tevent_req_simple_finish_ntstatus(subreq, status);
}
@@ -2913,7 +2923,7 @@ static void cli_smb2_mxac_opened(struct tevent_req *subreq)
NTSTATUS status;
status = cli_smb2_create_fnum_recv(
- subreq, &state->fnum, NULL, state, &out_cblobs);
+ subreq, &state->fnum, NULL, state, &out_cblobs, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 8940313c5cb..73a82b5551d 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -24,6 +24,7 @@ struct smbXcli_conn;
struct smbXcli_session;
struct cli_state;
struct file_info;
+struct symlink_reparse_struct;
struct tevent_req *cli_smb2_create_fnum_send(
TALLOC_CTX *mem_ctx,
@@ -43,7 +44,8 @@ NTSTATUS cli_smb2_create_fnum_recv(
uint16_t *pfnum,
struct smb_create_returns *cr,
TALLOC_CTX *mem_ctx,
- struct smb2_create_blobs *out_cblobs);
+ struct smb2_create_blobs *out_cblobs,
+ struct symlink_reparse_struct **symlink);
NTSTATUS cli_smb2_create_fnum(
struct cli_state *cli,
const char *fname,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 039bbcb076a..31776a58621 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1814,7 +1814,7 @@ static void cli_smb2_hardlink_opened(struct tevent_req *subreq)
bool ok;
status = cli_smb2_create_fnum_recv(
- subreq, &state->fnum_src, NULL, NULL, NULL);
+ subreq, &state->fnum_src, NULL, NULL, NULL, NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
@@ -2774,6 +2774,7 @@ static void cli_ntcreate_done_smb2(struct tevent_req *subreq)
&state->fnum,
&state->cr,
NULL,
+ NULL,
NULL);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index dea156d623c..eaff6d68bef 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -1118,7 +1118,7 @@ static PyObject *py_cli_create_ex(
if (smbXcli_conn_protocol(self->cli->conn) >= PROTOCOL_SMB2_02) {
status = cli_smb2_create_fnum_recv(
- req, &fnum, &cr, NULL, &create_contexts_out);
+ req, &fnum, &cr, NULL, &create_contexts_out, NULL);
} else {
status = cli_ntcreate_recv(req, &fnum, &cr);
}