s3:libsmb: pass impersonation_level to cli_ntcreate_send()
authorStefan Metzmacher <metze@samba.org>
Fri, 7 Dec 2018 15:38:57 +0000 (16:38 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 13 Dec 2018 07:52:24 +0000 (08:52 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Tim Beale <timbeale@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
examples/winexe/winexe.c
source3/libsmb/clifile.c
source3/libsmb/clisymlink.c
source3/libsmb/proto.h
source3/libsmb/pylibsmb.c
source3/torture/nbench.c
source3/torture/test_chain3.c
source3/torture/test_notify.c
source3/torture/test_notify_online.c
source3/torture/test_oplock_cancel.c
source3/torture/torture.c

index cf667a6..429ba2f 100644 (file)
@@ -872,6 +872,7 @@ static struct tevent_req *winexe_out_pipe_send(
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
                FILE_OPEN,      /* CreateDisposition */
                0,              /* CreateOptions */
+               SMB2_IMPERSONATION_IMPERSONATION,
                0);             /* SecurityFlags */
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
@@ -1044,6 +1045,7 @@ static struct tevent_req *winexe_in_pipe_send(
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
                FILE_OPEN,      /* CreateDisposition */
                0,              /* CreateOptions */
+               SMB2_IMPERSONATION_IMPERSONATION,
                0);             /* SecurityFlags */
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
@@ -1462,6 +1464,7 @@ static struct tevent_req *winexe_ctrl_send(
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
                FILE_OPEN,      /* CreateDisposition */
                0,              /* CreateOptions */
+               SMB2_IMPERSONATION_IMPERSONATION,
                0);             /* SecurityFlags */
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
index 1694af5..6defa38 100644 (file)
@@ -2099,11 +2099,11 @@ struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
                                     uint32_t share_access,
                                     uint32_t create_disposition,
                                     uint32_t create_options,
+                                    uint32_t impersonation_level,
                                     uint8_t security_flags)
 {
        struct tevent_req *req, *subreq;
        struct cli_ntcreate_state *state;
-       uint32_t impersonation_level = SMB2_IMPERSONATION_IMPERSONATION;
 
        req = tevent_req_create(mem_ctx, &state, struct cli_ntcreate_state);
        if (req == NULL) {
@@ -2197,6 +2197,7 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
        struct tevent_req *req;
+       uint32_t ImpersonationLevel = SMB2_IMPERSONATION_IMPERSONATION;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
        if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -2215,7 +2216,7 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
        req = cli_ntcreate_send(frame, ev, cli, fname, CreatFlags,
                                DesiredAccess, FileAttributes, ShareAccess,
                                CreateDisposition, CreateOptions,
-                               SecurityFlags);
+                               ImpersonationLevel, SecurityFlags);
        if (req == NULL) {
                goto fail;
        }
index 54435e4..1330752 100644 (file)
@@ -72,7 +72,8 @@ struct tevent_req *cli_symlink_send(TALLOC_CTX *mem_ctx,
                FILE_READ_ATTRIBUTES|FILE_WRITE_ATTRIBUTES,
                FILE_ATTRIBUTE_NORMAL, FILE_SHARE_NONE, FILE_CREATE,
                FILE_OPEN_REPARSE_POINT|FILE_SYNCHRONOUS_IO_NONALERT|
-               FILE_NON_DIRECTORY_FILE, 0);
+               FILE_NON_DIRECTORY_FILE,
+               SMB2_IMPERSONATION_IMPERSONATION, 0);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -274,7 +275,8 @@ struct tevent_req *cli_readlink_send(TALLOC_CTX *mem_ctx,
        subreq = cli_ntcreate_send(
                state, ev, cli, fname, 0, FILE_READ_ATTRIBUTES | FILE_READ_EA,
                0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
-               FILE_OPEN, FILE_OPEN_REPARSE_POINT, 0);
+               FILE_OPEN, FILE_OPEN_REPARSE_POINT,
+               SMB2_IMPERSONATION_IMPERSONATION, 0);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
index 941d154..bfad4dc 100644 (file)
@@ -397,6 +397,7 @@ struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
                                     uint32_t ShareAccess,
                                     uint32_t CreateDisposition,
                                     uint32_t CreateOptions,
+                                    uint32_t ImpersonationLevel,
                                     uint8_t SecurityFlags);
 NTSTATUS cli_ntcreate_recv(struct tevent_req *req,
                        uint16_t *pfnum,
index b6cff0b..3f84d34 100644 (file)
@@ -666,6 +666,7 @@ static PyObject *py_cli_create(struct py_cli_state *self, PyObject *args,
        unsigned ShareAccess = 0;
        unsigned CreateDisposition = FILE_OPEN;
        unsigned CreateOptions = 0;
+       unsigned ImpersonationLevel = SMB2_IMPERSONATION_IMPERSONATION;
        unsigned SecurityFlags = 0;
        uint16_t fnum;
        struct tevent_req *req;
@@ -687,7 +688,7 @@ static PyObject *py_cli_create(struct py_cli_state *self, PyObject *args,
        req = cli_ntcreate_send(NULL, self->ev, self->cli, fname, CreateFlags,
                                DesiredAccess, FileAttributes, ShareAccess,
                                CreateDisposition, CreateOptions,
-                               SecurityFlags);
+                               ImpersonationLevel, SecurityFlags);
        if (!py_tevent_req_wait_exc(self, req)) {
                return NULL;
        }
index 80b5a72..e9a0b4f 100644 (file)
@@ -263,7 +263,8 @@ static struct tevent_req *nbench_cmd_send(TALLOC_CTX *mem_ctx,
                        state, ev, nb_state->cli, state->ft->cp.fname, flags,
                        desired_access, 0, share_mode,
                        state->ft->cp.cr_disposition,
-                       state->ft->cp.cr_options, 0);
+                       state->ft->cp.cr_options,
+                       SMB2_IMPERSONATION_IMPERSONATION, 0);
                break;
        }
        case NBENCH_CMD_CLOSE: {
index eff39de..d957e51 100644 (file)
@@ -180,7 +180,8 @@ static struct tevent_req *chain3_send(TALLOC_CTX *mem_ctx,
                GENERIC_READ_ACCESS|GENERIC_WRITE_ACCESS,
                FILE_ATTRIBUTE_NORMAL,
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-               FILE_OVERWRITE_IF, 0, 0);
+               FILE_OVERWRITE_IF, 0,
+               SMB2_IMPERSONATION_IMPERSONATION, 0);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
index e377875..20b39d1 100644 (file)
@@ -66,7 +66,8 @@ static struct tevent_req *wait_for_one_notify_send(TALLOC_CTX *mem_ctx,
                state, state->ev, state->cli, path, 0,
                MAXIMUM_ALLOWED_ACCESS,
                0, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-               FILE_OPEN, FILE_DIRECTORY_FILE, 0);
+               FILE_OPEN, FILE_DIRECTORY_FILE,
+               SMB2_IMPERSONATION_IMPERSONATION, 0);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -318,7 +319,8 @@ static struct tevent_req *notify_bench3_send(
                state, state->ev, state->cli, state->dir, 0,
                MAXIMUM_ALLOWED_ACCESS, 0,
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-               FILE_OPEN_IF, FILE_DIRECTORY_FILE, 0);
+               FILE_OPEN_IF, FILE_DIRECTORY_FILE,
+               SMB2_IMPERSONATION_IMPERSONATION, 0);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -456,7 +458,8 @@ static void notify_bench3_before_mkdir2(struct tevent_req *subreq)
                MAXIMUM_ALLOWED_ACCESS, 0,
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
                FILE_CREATE,
-               FILE_DIRECTORY_FILE, 0);
+               FILE_DIRECTORY_FILE,
+               SMB2_IMPERSONATION_IMPERSONATION, 0);
        if (tevent_req_nomem(subreq, req)) {
                return;
        }
index 7f4f521..c8ddf7c 100644 (file)
@@ -61,7 +61,7 @@ static struct tevent_req *notify_online_send(
                state, ev, cli, dname, EXTENDED_RESPONSE_REQUIRED,
                SEC_FILE_READ_DATA, 0,
                FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
-               FILE_OPEN, 0, 0);
+               FILE_OPEN, 0, SMB2_IMPERSONATION_IMPERSONATION, 0);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -93,7 +93,8 @@ static void notify_online_opened_dir(struct tevent_req *subreq)
                state, state->ev, state->cli, state->fname, 0,
                GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-               FILE_OPEN, FILE_NON_DIRECTORY_FILE, 0);
+               FILE_OPEN, FILE_NON_DIRECTORY_FILE,
+               SMB2_IMPERSONATION_IMPERSONATION, 0);
        if (tevent_req_nomem(subreq, req)) {
                return;
        }
index d856650..b003876 100644 (file)
@@ -48,7 +48,7 @@ static struct tevent_req *create_cancel_send(
        subreq = cli_ntcreate_send(
                mem_ctx, ev, cli, fname, 0, FILE_GENERIC_READ,
                FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE,
-               FILE_OPEN_IF, 0, 0);
+               FILE_OPEN_IF, 0, SMB2_IMPERSONATION_IMPERSONATION, 0);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
index 4f810e5..1849a8d 100644 (file)
@@ -8249,7 +8249,8 @@ static struct tevent_req *torture_createdel_send(TALLOC_CTX *mem_ctx,
                FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
                FILE_ATTRIBUTE_NORMAL,
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
-               FILE_OPEN_IF, FILE_DELETE_ON_CLOSE, 0);
+               FILE_OPEN_IF, FILE_DELETE_ON_CLOSE,
+               SMB2_IMPERSONATION_IMPERSONATION, 0);
 
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);