[Pkg-samba-maint] [samba] 11/17: s3: libsmb: Add the capability to find a @GMT- path in an SMB2 create and transform to a timewarp token.
Mathieu Parent
sathieu at moszumanska.debian.org
Thu Mar 30 22:15:34 UTC 2017
This is an automated email from the git hooks/post-receive script.
sathieu pushed a commit to branch jessie
in repository samba.
commit 3df2edb46ff0f725c3d11b00bc8f3a19a2deff7f
Author: Jeremy Allison <jra at samba.org>
Date: Fri Aug 19 17:00:25 2016 -0700
s3: libsmb: Add the capability to find a @GMT- path in an SMB2 create and transform to a timewarp token.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12166
Signed-off-by: Jeremy Allison <jra at samba.org>
Reviewed-by: Uri Simchoni <uri at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Mon Aug 22 22:59:22 CEST 2016 on sn-devel-144
(back ported from commit 272f5c95cfb3d8035939dada7bd473058c7b6517)
---
source3/libsmb/cli_smb2_fnum.c | 55 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 15eaf96..53a6e0f 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -177,6 +177,11 @@ struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
{
struct tevent_req *req, *subreq;
struct cli_smb2_create_fnum_state *state;
+ size_t fname_len = 0;
+ const char *startp = NULL;
+ const char *endp = NULL;
+ time_t tstamp = (time_t)0;
+ struct smb2_create_blobs *cblobs = NULL;
req = tevent_req_create(mem_ctx, &state,
struct cli_smb2_create_fnum_state);
@@ -194,10 +199,58 @@ struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
create_options |= FILE_OPEN_FOR_BACKUP_INTENT;
}
+ /* Check for @GMT- paths. Remove the @GMT and turn into TWrp if so. */
+ fname_len = strlen(fname);
+ if (clistr_is_previous_version_path(fname, &startp, &endp, &tstamp)) {
+ size_t len_before_gmt = startp - fname;
+ size_t len_after_gmt = fname + fname_len - endp;
+ DATA_BLOB twrp_blob;
+ NTTIME ntt;
+ NTSTATUS status;
+
+ char *new_fname = talloc_array(state, char,
+ len_before_gmt + len_after_gmt + 1);
+
+ if (tevent_req_nomem(new_fname, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ memcpy(new_fname, fname, len_before_gmt);
+ memcpy(new_fname + len_before_gmt, endp, len_after_gmt + 1);
+ fname = new_fname;
+ fname_len = len_before_gmt + len_after_gmt;
+
+ unix_to_nt_time(&ntt, tstamp);
+ twrp_blob = data_blob_const((const void *)&ntt, 8);
+
+ cblobs = talloc_zero(state, struct smb2_create_blobs);
+ if (tevent_req_nomem(cblobs, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ status = smb2_create_blob_add(state, cblobs,
+ SMB2_CREATE_TAG_TWRP, twrp_blob);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return tevent_req_post(req, ev);
+ }
+ }
+
/* SMB2 is pickier about pathnames. Ensure it doesn't
start in a '\' */
if (*fname == '\\') {
fname++;
+ fname_len--;
+ }
+
+ /* Or end in a '\' */
+ if (fname_len > 0 && fname[fname_len-1] == '\\') {
+ char *new_fname = talloc_strdup(state, fname);
+ if (tevent_req_nomem(new_fname, req)) {
+ return tevent_req_post(req, ev);
+ }
+ new_fname[fname_len-1] = '\0';
+ fname = new_fname;
}
subreq = smb2cli_create_send(state, ev,
@@ -213,7 +266,7 @@ struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
share_access,
create_disposition,
create_options,
- NULL);
+ cblobs);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-samba/samba.git
More information about the Pkg-samba-maint
mailing list