s3: libsmb: Plumb in the new SMB2 reparse point calls into the cli_symlink_create_XXX...
authorJeremy Allison <jra@samba.org>
Tue, 28 Nov 2017 22:10:26 +0000 (14:10 -0800)
committerRalph Boehme <slow@samba.org>
Wed, 6 Dec 2017 14:02:16 +0000 (15:02 +0100)
Reparse point symlinks can now be created over SMB1 and SMB2 from
smbclient.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13159

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/libsmb/clisymlink.c

index a52f6ff7f6d6472d13b1d6abbcee3b6d072290a0..202435722c974ab985d1e9db9c8ca443a80eef2b 100644 (file)
@@ -86,8 +86,7 @@ static void cli_symlink_create_done(struct tevent_req *subreq)
                subreq, struct tevent_req);
        struct cli_symlink_state *state = tevent_req_data(
                req, struct cli_symlink_state);
-       uint8_t *data;
-       size_t data_len;
+       DATA_BLOB data;
        NTSTATUS status;
 
        status = cli_ntcreate_recv(subreq, &state->fnum, NULL);
@@ -96,24 +95,35 @@ static void cli_symlink_create_done(struct tevent_req *subreq)
                return;
        }
 
-       SIVAL(state->setup, 0, FSCTL_SET_REPARSE_POINT);
-       SSVAL(state->setup, 4, state->fnum);
-       SCVAL(state->setup, 6, 1); /* IsFcntl */
-       SCVAL(state->setup, 7, 0); /* IsFlags */
-
        if (!symlink_reparse_buffer_marshall(
                    state->link_target, NULL, state->flags, state,
-                   &data, &data_len)) {
+                   &data.data, &data.length)) {
                tevent_req_oom(req);
                return;
        }
 
-       subreq = cli_trans_send(state, state->ev, state->cli, 0, SMBnttrans,
+       if (smbXcli_conn_protocol(state->cli->conn) >= PROTOCOL_SMB2_02) {
+               subreq = cli_smb2_set_reparse_point_fnum_send(state,
+                                               state->ev,
+                                               state->cli,
+                                               state->fnum,
+                                               data);
+       } else {
+               SIVAL(state->setup, 0, FSCTL_SET_REPARSE_POINT);
+               SSVAL(state->setup, 4, state->fnum);
+               SCVAL(state->setup, 6, 1); /* IsFcntl */
+               SCVAL(state->setup, 7, 0); /* IsFlags */
+
+
+               subreq = cli_trans_send(state, state->ev, state->cli, 0,
+                               SMBnttrans,
                                NULL, -1, /* name, fid */
                                NT_TRANSACT_IOCTL, 0,
                                state->setup, 4, 0, /* setup */
                                NULL, 0, 0,         /* param */
-                               data, data_len, 0); /* data */
+                               data.data, data.length, 0); /* data */
+       }
+
        if (tevent_req_nomem(subreq, req)) {
                return;
        }
@@ -127,11 +137,16 @@ static void cli_symlink_set_reparse_done(struct tevent_req *subreq)
        struct cli_symlink_state *state = tevent_req_data(
                req, struct cli_symlink_state);
 
-       state->set_reparse_status = cli_trans_recv(
-               subreq, NULL, NULL,
-               NULL, 0, NULL,  /* rsetup */
-               NULL, 0, NULL,  /* rparam */
-               NULL, 0, NULL); /* rdata */
+       if (smbXcli_conn_protocol(state->cli->conn) >= PROTOCOL_SMB2_02) {
+               state->set_reparse_status =
+                       cli_smb2_set_reparse_point_fnum_recv(subreq);
+       } else {
+               state->set_reparse_status = cli_trans_recv(
+                       subreq, NULL, NULL,
+                       NULL, 0, NULL,  /* rsetup */
+                       NULL, 0, NULL,  /* rparam */
+                       NULL, 0, NULL); /* rdata */
+       }
        TALLOC_FREE(subreq);
 
        if (NT_STATUS_IS_OK(state->set_reparse_status)) {