mirror of
https://github.com/samba-team/samba.git
synced 2025-01-22 22:04:08 +03:00
smbd: pass twrp as NTTIME to filename_convert() and all the way down to canonicalize_snapshot_path()
Also pass by value rather then by reference. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
8a8fe887f5
commit
1e5164afaf
@ -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;
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
@ -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,
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user