smbd: pass twrp as NTTIME to filename_convert() and all the way down to canonicalize_...
authorRalph Boehme <slow@samba.org>
Thu, 30 Apr 2020 14:04:54 +0000 (16:04 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 5 May 2020 19:18:40 +0000 (19:18 +0000)
Also pass by value rather then by reference.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/printing/nt_printing.c
source3/rpc_server/srvsvc/srv_srvsvc_nt.c
source3/smbd/filename.c
source3/smbd/msdfs.c
source3/smbd/nttrans.c
source3/smbd/open.c
source3/smbd/proto.h
source3/smbd/reply.c
source3/smbd/smb2_create.c
source3/smbd/smb2_query_directory.c
source3/smbd/trans2.c

index 02d6a915755fbe5f5997cccbb167f2a296bdbc1a..4c7bc481b5a3b396a7c58c8189ba8abc1a6c284e 100644 (file)
@@ -277,7 +277,7 @@ static NTSTATUS driver_unix_convert(connection_struct *conn,
        }
        trim_string(name,"/","/");
 
-       status = unix_convert(ctx, conn, name, NULL, smb_fname, 0);
+       status = unix_convert(ctx, conn, name, 0, smb_fname, 0);
        if (!NT_STATUS_IS_OK(status)) {
                return NT_STATUS_NO_MEMORY;
        }
index b5908213b01e8dc41e43c0d264aa3ce1b250a061..f178ada9b8c305ed762bb0530f69e5a959772099 100644 (file)
@@ -2403,7 +2403,7 @@ WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p,
                                        conn,
                                        r->in.file,
                                        ucf_flags,
-                                       NULL,
+                                       0,
                                        NULL,
                                        &smb_fname);
        if (!NT_STATUS_IS_OK(nt_status)) {
@@ -2539,7 +2539,7 @@ WERROR _srvsvc_NetSetFileSecurity(struct pipes_struct *p,
                                        conn,
                                        r->in.file,
                                        ucf_flags,
-                                       NULL,
+                                       0,
                                        NULL,
                                        &smb_fname);
        if (!NT_STATUS_IS_OK(nt_status)) {
index b038287aa228239c2c414e728a19519101997f43..25f898abc82f930bb13ce561a86f062e250b1c7e 100644 (file)
@@ -365,7 +365,7 @@ static NTSTATUS rearrange_snapshot_path(struct smb_filename *smb_fname,
  */
 
 static NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
-                                          time_t *twrp)
+                                          NTTIME twrp)
 {
        char *startp = strchr_m(smb_fname->base_name, '@');
        char *endp = NULL;
@@ -373,10 +373,13 @@ static NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
        time_t t;
        NTSTATUS status;
 
-       if (twrp != NULL) {
-               struct tm *ptm = gmtime_r(twrp, &tm);
+       if (twrp != 0) {
+               struct tm *ptm = NULL;
                char *twrp_name = NULL;
 
+               t = nt_time_to_unix(twrp);
+               ptm = gmtime_r(&t, &tm);
+
                twrp_name = talloc_asprintf(
                        smb_fname,
                        "@GMT-%04u.%02u.%02u-%02u.%02u.%02u/%s",
@@ -394,7 +397,7 @@ static NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
                TALLOC_FREE(smb_fname->base_name);
                smb_fname->base_name = twrp_name;
 
-               unix_to_nt_time(&smb_fname->twrp, *twrp);
+               smb_fname->twrp = twrp;
                return NT_STATUS_OK;
        }
 
@@ -930,7 +933,7 @@ static NTSTATUS unix_convert_step(struct uc_state *state)
 NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
                      connection_struct *conn,
                      const char *orig_path,
-                     time_t *twrp,
+                     NTTIME twrp,
                      struct smb_filename **smb_fname_out,
                      uint32_t ucf_flags)
 {
@@ -1814,7 +1817,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
                        TALLOC_FREE(fname);
                        return NULL;
                }
-               status = canonicalize_snapshot_path(smb_fname, NULL);
+               status = canonicalize_snapshot_path(smb_fname, 0);
                if (!NT_STATUS_IS_OK(status)) {
                        TALLOC_FREE(fname);
                        TALLOC_FREE(smb_fname);
@@ -1867,7 +1870,7 @@ static NTSTATUS filename_convert_internal(TALLOC_CTX *ctx,
                                struct smb_request *smbreq,
                                const char *name_in,
                                uint32_t ucf_flags,
-                               time_t *twrp,
+                               NTTIME twrp,
                                bool *ppath_contains_wcard,
                                struct smb_filename **_smb_fname)
 {
@@ -1972,7 +1975,7 @@ NTSTATUS filename_convert(TALLOC_CTX *ctx,
                                connection_struct *conn,
                                const char *name_in,
                                uint32_t ucf_flags,
-                               time_t *twrp,
+                               NTTIME twrp,
                                bool *ppath_contains_wcard,
                                struct smb_filename **pp_smb_fname)
 {
@@ -2004,7 +2007,7 @@ NTSTATUS filename_convert_with_privilege(TALLOC_CTX *ctx,
                                        smbreq,
                                        name_in,
                                        ucf_flags,
-                                       NULL,
+                                       0,
                                        ppath_contains_wcard,
                                        pp_smb_fname);
 }
index 7eb838cef5f2f6a2263dbc9e4be47c57d42f9ab8..41b73afc05654c95394fdd1081b65629f7ecdfd2 100644 (file)
@@ -686,7 +686,7 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
         * unix_convert later in the codepath.
         */
 
-       status = unix_convert(ctx, conn, pdp->reqpath, NULL, &smb_fname,
+       status = unix_convert(ctx, conn, pdp->reqpath, 0, &smb_fname,
                              ucf_flags);
 
        if (!NT_STATUS_IS_OK(status)) {
index e83ccc25ac46040a6f61aa63331e94920b751f0d..5f82c30f0dfcb37ff0f6c6ec82106b89e8d3ded2 100644 (file)
@@ -542,7 +542,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
                                conn,
                                fname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
 
@@ -1131,7 +1131,7 @@ static void call_nt_transact_create(connection_struct *conn,
                                conn,
                                fname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
 
@@ -1671,7 +1671,7 @@ void reply_ntrename(struct smb_request *req)
        status = filename_convert(ctx, conn,
                                  oldname,
                                  ucf_flags_src,
-                                 NULL,
+                                 0,
                                  NULL,
                                  &smb_fname_old);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1689,7 +1689,7 @@ void reply_ntrename(struct smb_request *req)
        status = filename_convert(ctx, conn,
                                  newname,
                                  ucf_flags_dst,
-                                 NULL,
+                                 0,
                                  &dest_has_wcard,
                                  &smb_fname_new);
        if (!NT_STATUS_IS_OK(status)) {
index 0dc468e2e5406f64d7254ceb94dbe2c2a6225739..39587bfe9512b5106aa1b857771d5393f291e6b8 100644 (file)
@@ -5922,7 +5922,7 @@ static NTSTATUS get_relative_fid_filename(
                                conn,
                                new_base_name,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                smb_fname_out);
        if (!NT_STATUS_IS_OK(status)) {
index ab2cd3539b3d2b9a3600a08462bcf1dcc6463b1a..2dd469a62134faee607f23ba183ea2314e555fa8 100644 (file)
@@ -362,7 +362,7 @@ uint32_t filename_create_ucf_flags(struct smb_request *req, uint32_t create_disp
 NTSTATUS unix_convert(TALLOC_CTX *ctx,
                      connection_struct *conn,
                      const char *orig_path,
-                     time_t *twrp,
+                     NTTIME twrp,
                      struct smb_filename **smb_fname,
                      uint32_t ucf_flags);
 NTSTATUS check_name(connection_struct *conn,
@@ -378,7 +378,7 @@ NTSTATUS filename_convert(TALLOC_CTX *mem_ctx,
                        connection_struct *conn,
                        const char *name_in,
                        uint32_t ucf_flags,
-                       time_t *twrp,
+                       NTTIME twrp,
                        bool *ppath_contains_wcard,
                        struct smb_filename **pp_smb_fname);
 NTSTATUS filename_convert_with_privilege(TALLOC_CTX *mem_ctx,
index b29ae9df7c9868c770ca9da1221cac49dac7cce4..c9e4d7e9c9001a7912f10b8f412a4b97a72924a1 100644 (file)
@@ -1320,7 +1320,7 @@ void reply_checkpath(struct smb_request *req)
                                conn,
                                name,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
 
@@ -1419,7 +1419,7 @@ void reply_getatr(struct smb_request *req)
                                conn,
                                fname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
                if (!NT_STATUS_IS_OK(status)) {
@@ -1522,7 +1522,7 @@ void reply_setatr(struct smb_request *req)
                                conn,
                                fname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1832,7 +1832,7 @@ void reply_search(struct smb_request *req)
                nt_status = filename_convert(ctx, conn,
                                             path,
                                             ucf_flags,
-                                            NULL,
+                                            0,
                                             &mask_contains_wcard,
                                             &smb_fname);
                if (!NT_STATUS_IS_OK(nt_status)) {
@@ -2268,7 +2268,7 @@ void reply_open(struct smb_request *req)
                                conn,
                                fname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
        if (!NT_STATUS_IS_OK(status)) {
@@ -2459,7 +2459,7 @@ void reply_open_and_X(struct smb_request *req)
                                conn,
                                fname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
        if (!NT_STATUS_IS_OK(status)) {
@@ -2885,7 +2885,7 @@ void reply_mknew(struct smb_request *req)
                                conn,
                                fname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
        if (!NT_STATUS_IS_OK(status)) {
@@ -3028,7 +3028,7 @@ void reply_ctemp(struct smb_request *req)
                status = filename_convert(ctx, conn,
                                fname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
                if (!NT_STATUS_IS_OK(status)) {
@@ -3591,7 +3591,7 @@ void reply_unlink(struct smb_request *req)
        status = filename_convert(ctx, conn,
                                  name,
                                  ucf_flags,
-                                 NULL,
+                                 0,
                                  &path_contains_wcard,
                                  &smb_fname);
        if (!NT_STATUS_IS_OK(status)) {
@@ -7123,7 +7123,7 @@ void reply_mkdir(struct smb_request *req)
        status = filename_convert(ctx, conn,
                                 directory,
                                 ucf_flags,
-                                NULL,
+                                0,
                                 NULL,
                                 &smb_dname);
        if (!NT_STATUS_IS_OK(status)) {
@@ -7193,7 +7193,7 @@ void reply_rmdir(struct smb_request *req)
        status = filename_convert(ctx, conn,
                                 directory,
                                 ucf_flags,
-                                NULL,
+                                0,
                                 NULL,
                                 &smb_dname);
        if (!NT_STATUS_IS_OK(status)) {
@@ -8362,7 +8362,7 @@ void reply_mv(struct smb_request *req)
                                  conn,
                                  name,
                                  src_ucf_flags,
-                                 NULL,
+                                 0,
                                  &src_has_wcard,
                                  &smb_fname_src);
 
@@ -8380,7 +8380,7 @@ void reply_mv(struct smb_request *req)
                                  conn,
                                  newname,
                                  dst_ucf_flags,
-                                 NULL,
+                                 0,
                                  &dest_has_wcard,
                                  &smb_fname_dst);
 
@@ -8698,7 +8698,7 @@ void reply_copy(struct smb_request *req)
        status = filename_convert(ctx, conn,
                                  fname_src,
                                  ucf_flags_src,
-                                 NULL,
+                                 0,
                                  &source_has_wild,
                                  &smb_fname_src);
        if (!NT_STATUS_IS_OK(status)) {
@@ -8714,7 +8714,7 @@ void reply_copy(struct smb_request *req)
        status = filename_convert(ctx, conn,
                                  fname_dst,
                                  ucf_flags_dst,
-                                 NULL,
+                                 0,
                                  &dest_has_wild,
                                  &smb_fname_dst);
        if (!NT_STATUS_IS_OK(status)) {
index 0418ca34f95086f67159b0946941c34c03a46c16..e04ae3d15508f9d15c16118907d64ee3c08b7a59 100644 (file)
@@ -461,7 +461,7 @@ static NTSTATUS smbd_smb2_create_durable_lease_check(struct smb_request *smb1req
        ucf_flags = filename_create_ucf_flags(smb1req, FILE_OPEN);
        status = filename_convert(talloc_tos(), fsp->conn,
                                  filename, ucf_flags,
-                                 NULL, NULL, &smb_fname);
+                                 0, NULL, &smb_fname);
        TALLOC_FREE(filename);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10, ("filename_convert returned %s\n",
@@ -514,8 +514,7 @@ struct smbd_smb2_create_state {
        ssize_t lease_len;
        bool need_replay_cache;
        struct smbXsrv_open *op;
-       time_t twrp_time;
-       time_t *twrp_timep;
+       NTTIME twrp_time;
 
        struct smb2_create_blob *dhnc;
        struct smb2_create_blob *dh2c;
@@ -946,7 +945,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                                  smb1req->conn,
                                  state->fname,
                                  ucf_flags,
-                                 state->twrp_timep,
+                                 state->twrp_time,
                                  NULL, /* ppath_contains_wcards */
                                  &smb_fname);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1233,16 +1232,12 @@ static void smbd_smb2_create_before_exec(struct tevent_req *req)
        }
 
        if (state->twrp != NULL) {
-               NTTIME nttime;
-
                if (state->twrp->data.length != 8) {
                        tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
                        return;
                }
 
-               nttime = BVAL(state->twrp->data.data, 0);
-               state->twrp_time = nt_time_to_unix(nttime);
-               state->twrp_timep = &state->twrp_time;
+               state->twrp_time = BVAL(state->twrp->data.data, 0);
 
                smb1req->flags2 |= FLAGS2_REPARSE_PATH;
        }
index 28c4b51fbf9c1db931e1989b72b1d94c64f7f566..4da051e18ebe281a918ea28e72c66518c10111dd 100644 (file)
@@ -425,7 +425,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
                                conn,
                                fullpath,
                                ucf_flags,
-                               NULL,
+                               0,
                                &wcard_has_wild,
                                &smb_fname);
 
index f47d754514f92f6da2c99ab58f00ff179be2a9cc..96087e6b456d533386d92d91f2a45e7069e0d782 100644 (file)
@@ -1363,7 +1363,7 @@ static void call_trans2open(connection_struct *conn,
                                conn,
                                fname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname);
        if (!NT_STATUS_IS_OK(status)) {
@@ -2840,7 +2840,7 @@ close_if_end = %d requires_resume_key = %d backup_priv = %d level = 0x%x, max_da
                ntstatus = filename_convert(talloc_tos(), conn,
                                    directory,
                                    ucf_flags,
-                                   NULL,
+                                   0,
                                    &mask_contains_wcard,
                                    &smb_dname);
        }
@@ -6184,7 +6184,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                                        conn,
                                        fname,
                                        ucf_flags,
-                                       NULL,
+                                       0,
                                        NULL,
                                        &smb_fname);
                if (!NT_STATUS_IS_OK(status)) {
@@ -7067,7 +7067,7 @@ static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
                                conn,
                                oldname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname_old);
        if (!NT_STATUS_IS_OK(status)) {
@@ -7143,7 +7143,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
                                conn,
                                newname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname_dst);
        if (!NT_STATUS_IS_OK(status)) {
@@ -7259,7 +7259,7 @@ static NTSTATUS smb_file_link_information(connection_struct *conn,
                                conn,
                                newname,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_fname_dst);
        if (!NT_STATUS_IS_OK(status)) {
@@ -7431,7 +7431,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                                          conn,
                                          base_name,
                                          ucf_flags,
-                                         NULL,
+                                         0,
                                          NULL,
                                          &smb_fname_dst);
 
@@ -9408,7 +9408,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                status = filename_convert(req, conn,
                                         fname,
                                         ucf_flags,
-                                        NULL,
+                                        0,
                                         NULL,
                                         &smb_fname);
                if (!NT_STATUS_IS_OK(status)) {
@@ -9564,7 +9564,7 @@ static void call_trans2mkdir(connection_struct *conn, struct smb_request *req,
                                conn,
                                directory,
                                ucf_flags,
-                               NULL,
+                               0,
                                NULL,
                                &smb_dname);