The Samba-Bugzilla – Attachment 16885 Details for
Bug 14127
Samba doesn't implement semantics of setting a file's timestamp to -1 and -2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.14 and 4.15 cherry-picked from master.
bug-14127-4.15 (text/plain), 14.84 KB, created by
Jeremy Allison
on 2021-10-28 19:33:18 UTC
(
hide
)
Description:
Patch for 4.14 and 4.15 cherry-picked from master.
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2021-10-28 19:33:18 UTC
Size:
14.84 KB
patch
obsolete
>From 3b900f320f4be5aa4686512315d58c22e447b349 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 5 Oct 2021 15:10:10 +0200 >Subject: [PATCH 1/7] lib: add NTTIME_THAW > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14127 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit f73aff502cadabb7fe6b94a697f0a2256d1d4aca) >--- > lib/util/time.h | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/lib/util/time.h b/lib/util/time.h >index 6726f39c7cc..72347b39b99 100644 >--- a/lib/util/time.h >+++ b/lib/util/time.h >@@ -63,6 +63,7 @@ > * implement this yet. > */ > #define NTTIME_FREEZE UINT64_MAX >+#define NTTIME_THAW (UINT64_MAX - 1) > > #define SAMBA_UTIME_NOW UTIME_NOW > #define SAMBA_UTIME_OMIT UTIME_OMIT >-- >2.30.2 > > >From a9ae33e8849ff4529bba86d78961ce6a16dbbf2f Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Wed, 27 Oct 2021 17:02:48 +0200 >Subject: [PATCH 2/7] lib: fix null_nttime() tests > >The test was checking -1 twice: > > torture_assert(tctx, null_nttime(-1), "-1"); > torture_assert(tctx, null_nttime(-1), "-1"); > >The first line was likely supposed to test the value "0". > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14127 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit d84779302cc54a7b84c05ccc458e04b27fd142f4) >--- > lib/util/tests/time.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/lib/util/tests/time.c b/lib/util/tests/time.c >index 039f7f4ccf8..6742e7fd3fe 100644 >--- a/lib/util/tests/time.c >+++ b/lib/util/tests/time.c >@@ -34,7 +34,7 @@ static bool test_null_time(struct torture_context *tctx) > > static bool test_null_nttime(struct torture_context *tctx) > { >- torture_assert(tctx, null_nttime(-1), "-1"); >+ torture_assert(tctx, null_nttime(0), "0"); > torture_assert(tctx, null_nttime(-1), "-1"); > torture_assert(tctx, !null_nttime(42), "42"); > return true; >-- >2.30.2 > > >From d72a21fa322f1a138e01fc4a2557e5e59c1e74cb Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 28 Oct 2021 10:17:01 +0200 >Subject: [PATCH 3/7] lib: use NTTIME_FREEZE in a null_nttime() test > >No change in behaviour. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14127 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit e2740e4868f2a49877a86a8666d26226b5657317) >--- > lib/util/tests/time.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/lib/util/tests/time.c b/lib/util/tests/time.c >index 6742e7fd3fe..ee1fd42c8cf 100644 >--- a/lib/util/tests/time.c >+++ b/lib/util/tests/time.c >@@ -35,7 +35,7 @@ static bool test_null_time(struct torture_context *tctx) > static bool test_null_nttime(struct torture_context *tctx) > { > torture_assert(tctx, null_nttime(0), "0"); >- torture_assert(tctx, null_nttime(-1), "-1"); >+ torture_assert(tctx, null_nttime(NTTIME_FREEZE), "-1"); > torture_assert(tctx, !null_nttime(42), "42"); > return true; > } >-- >2.30.2 > > >From ecfde393c5bb6fd11334dc08fbba51a2a6e889c0 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 28 Oct 2021 10:18:17 +0200 >Subject: [PATCH 4/7] lib: update null_nttime() of -1: -1 is NTTIME_FREEZE > >NTTIME_FREEZE is not a nil sentinel value, instead it implies special, yet >unimplemented semantics. Callers must deal with those values specifically and >null_nttime() must not lie about their nature. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14127 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 5503bde93bddf3634b183e665773399c110251d4) >--- > lib/util/tests/time.c | 2 +- > lib/util/time.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > >diff --git a/lib/util/tests/time.c b/lib/util/tests/time.c >index ee1fd42c8cf..33930a77173 100644 >--- a/lib/util/tests/time.c >+++ b/lib/util/tests/time.c >@@ -35,7 +35,7 @@ static bool test_null_time(struct torture_context *tctx) > static bool test_null_nttime(struct torture_context *tctx) > { > torture_assert(tctx, null_nttime(0), "0"); >- torture_assert(tctx, null_nttime(NTTIME_FREEZE), "-1"); >+ torture_assert(tctx, !null_nttime(NTTIME_FREEZE), "-1"); > torture_assert(tctx, !null_nttime(42), "42"); > return true; > } >diff --git a/lib/util/time.c b/lib/util/time.c >index 53bf194fe0b..e6a0668cf90 100644 >--- a/lib/util/time.c >+++ b/lib/util/time.c >@@ -178,7 +178,7 @@ check if it's a null NTTIME > **/ > _PUBLIC_ bool null_nttime(NTTIME t) > { >- return t == 0 || t == (NTTIME)-1; >+ return t == 0; > } > > /******************************************************************* >-- >2.30.2 > > >From 57c603a4a2be6452488dead15b87fc8954f1c851 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 28 Oct 2021 10:18:54 +0200 >Subject: [PATCH 5/7] lib: add a test for null_nttime(NTTIME_THAW) > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14127 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 194faa76161a12ae1eae2b471d6f159d97ef75a8) >--- > lib/util/tests/time.c | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/lib/util/tests/time.c b/lib/util/tests/time.c >index 33930a77173..ec27f567a71 100644 >--- a/lib/util/tests/time.c >+++ b/lib/util/tests/time.c >@@ -36,6 +36,7 @@ static bool test_null_nttime(struct torture_context *tctx) > { > torture_assert(tctx, null_nttime(0), "0"); > torture_assert(tctx, !null_nttime(NTTIME_FREEZE), "-1"); >+ torture_assert(tctx, !null_nttime(NTTIME_THAW), "-2"); > torture_assert(tctx, !null_nttime(42), "42"); > return true; > } >-- >2.30.2 > > >From f34b0933dab493738e723c99a424a70e2fd0a460 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 28 Oct 2021 12:55:39 +0200 >Subject: [PATCH 6/7] torture: add a test for NTTIME_FREEZE and NTTIME_THAW > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14127 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 0659069f8292996be475d407b53d161aa3f35554) >--- > selftest/knownfail.d/samba3.smb2.timestamps | 1 + > source4/torture/smb2/timestamps.c | 208 ++++++++++++++++++++ > 2 files changed, 209 insertions(+) > create mode 100644 selftest/knownfail.d/samba3.smb2.timestamps > >diff --git a/selftest/knownfail.d/samba3.smb2.timestamps b/selftest/knownfail.d/samba3.smb2.timestamps >new file mode 100644 >index 00000000000..d183ec1f583 >--- /dev/null >+++ b/selftest/knownfail.d/samba3.smb2.timestamps >@@ -0,0 +1 @@ >+^samba3.smb2.timestamps.freeze-thaw\(.*\)$ >diff --git a/source4/torture/smb2/timestamps.c b/source4/torture/smb2/timestamps.c >index c37e81d2adc..0e3f0c0ab69 100644 >--- a/source4/torture/smb2/timestamps.c >+++ b/source4/torture/smb2/timestamps.c >@@ -352,6 +352,213 @@ static bool test_time_t_1968(struct torture_context *tctx, > -63158400 /* 1968 */); > } > >+static bool test_freeze_thaw(struct torture_context *tctx, >+ struct smb2_tree *tree) >+{ >+ const char *filename = BASEDIR "\\test_freeze_thaw"; >+ struct smb2_create cr; >+ struct smb2_handle handle = {{0}}; >+ struct smb2_handle testdirh = {{0}}; >+ struct timespec ts = { .tv_sec = time(NULL) }; >+ uint64_t nttime; >+ union smb_fileinfo gi; >+ union smb_setfileinfo si; >+ NTSTATUS status; >+ bool ret = true; >+ >+ smb2_deltree(tree, BASEDIR); >+ >+ status = torture_smb2_testdir(tree, BASEDIR, &testdirh); >+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, >+ "torture_smb2_testdir failed\n"); >+ >+ cr = (struct smb2_create) { >+ .in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED, >+ .in.file_attributes = FILE_ATTRIBUTE_NORMAL, >+ .in.share_access = NTCREATEX_SHARE_ACCESS_MASK, >+ .in.create_disposition = NTCREATEX_DISP_OPEN_IF, >+ .in.impersonation_level = NTCREATEX_IMPERSONATION_ANONYMOUS, >+ .in.fname = filename, >+ }; >+ >+ status = smb2_create(tree, tctx, &cr); >+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, >+ "smb2_create failed\n"); >+ handle = cr.out.file.handle; >+ >+ si = (union smb_setfileinfo) { >+ .basic_info.level = RAW_SFILEINFO_BASIC_INFORMATION, >+ .basic_info.in.file.handle = handle, >+ }; >+ >+ /* >+ * Step 1: >+ * First set timestamps of testfile to current time >+ */ >+ >+ nttime = full_timespec_to_nt_time(&ts); >+ si.basic_info.in.create_time = nttime; >+ si.basic_info.in.write_time = nttime; >+ si.basic_info.in.change_time = nttime; >+ >+ status = smb2_setinfo_file(tree, &si); >+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, >+ "smb2_setinfo_file failed\n"); >+ >+ gi = (union smb_fileinfo) { >+ .generic.level = SMB_QFILEINFO_BASIC_INFORMATION, >+ .generic.in.file.handle = handle, >+ }; >+ >+ /* >+ * Step 2: >+ * Verify timestamps are indeed set to the value in "nttime". >+ */ >+ >+ status = smb2_getinfo_file(tree, tctx, &gi); >+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, >+ "smb2_getinfo_file failed\n"); >+ >+ torture_comment(tctx, "Got: create: %s, write: %s, change: %s\n", >+ nt_time_string(tctx, gi.basic_info.out.create_time), >+ nt_time_string(tctx, gi.basic_info.out.write_time), >+ nt_time_string(tctx, gi.basic_info.out.change_time)); >+ >+ torture_assert_u64_equal_goto(tctx, >+ nttime, >+ gi.basic_info.out.create_time, >+ ret, done, >+ "Wrong create time\n"); >+ torture_assert_u64_equal_goto(tctx, >+ nttime, >+ gi.basic_info.out.write_time, >+ ret, done, >+ "Wrong write time\n"); >+ torture_assert_u64_equal_goto(tctx, >+ nttime, >+ gi.basic_info.out.change_time, >+ ret, done, >+ "Wrong change time\n"); >+ >+ /* >+ * Step 3: >+ * First set timestamps with NTTIME_FREEZE, must not change any >+ * timestamp value. >+ */ >+ >+ si.basic_info.in.create_time = NTTIME_FREEZE; >+ si.basic_info.in.write_time = NTTIME_FREEZE; >+ si.basic_info.in.change_time = NTTIME_FREEZE; >+ >+ status = smb2_setinfo_file(tree, &si); >+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, >+ "smb2_setinfo_file failed\n"); >+ >+ gi = (union smb_fileinfo) { >+ .generic.level = SMB_QFILEINFO_BASIC_INFORMATION, >+ .generic.in.file.handle = handle, >+ }; >+ >+ /* >+ * Step 4: >+ * Verify timestamps are unmodified from step 2. >+ */ >+ >+ gi = (union smb_fileinfo) { >+ .generic.level = SMB_QFILEINFO_BASIC_INFORMATION, >+ .generic.in.file.handle = handle, >+ }; >+ >+ status = smb2_getinfo_file(tree, tctx, &gi); >+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, >+ "smb2_getinfo_file failed\n"); >+ >+ torture_comment(tctx, "Got: create: %s, write: %s, change: %s\n", >+ nt_time_string(tctx, gi.basic_info.out.create_time), >+ nt_time_string(tctx, gi.basic_info.out.write_time), >+ nt_time_string(tctx, gi.basic_info.out.change_time)); >+ >+ torture_assert_u64_equal_goto(tctx, >+ nttime, >+ gi.basic_info.out.create_time, >+ ret, done, >+ "Wrong create time\n"); >+ torture_assert_u64_equal_goto(tctx, >+ nttime, >+ gi.basic_info.out.write_time, >+ ret, done, >+ "Wrong write time\n"); >+ torture_assert_u64_equal_goto(tctx, >+ nttime, >+ gi.basic_info.out.change_time, >+ ret, done, >+ "Wrong change time\n"); >+ >+ /* >+ * Step 5: >+ * First set timestamps with NTTIME_THAW, must not change any timestamp >+ * value. >+ */ >+ >+ si.basic_info.in.create_time = NTTIME_THAW; >+ si.basic_info.in.write_time = NTTIME_THAW; >+ si.basic_info.in.change_time = NTTIME_THAW; >+ >+ status = smb2_setinfo_file(tree, &si); >+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, >+ "smb2_setinfo_file failed\n"); >+ >+ gi = (union smb_fileinfo) { >+ .generic.level = SMB_QFILEINFO_BASIC_INFORMATION, >+ .generic.in.file.handle = handle, >+ }; >+ >+ /* >+ * Step 6: >+ * Verify timestamps are unmodified from step 2. >+ */ >+ >+ gi = (union smb_fileinfo) { >+ .generic.level = SMB_QFILEINFO_BASIC_INFORMATION, >+ .generic.in.file.handle = handle, >+ }; >+ >+ status = smb2_getinfo_file(tree, tctx, &gi); >+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done, >+ "smb2_getinfo_file failed\n"); >+ >+ torture_comment(tctx, "Got: create: %s, write: %s, change: %s\n", >+ nt_time_string(tctx, gi.basic_info.out.create_time), >+ nt_time_string(tctx, gi.basic_info.out.write_time), >+ nt_time_string(tctx, gi.basic_info.out.change_time)); >+ >+ torture_assert_u64_equal_goto(tctx, >+ nttime, >+ gi.basic_info.out.create_time, >+ ret, done, >+ "Wrong create time\n"); >+ torture_assert_u64_equal_goto(tctx, >+ nttime, >+ gi.basic_info.out.write_time, >+ ret, done, >+ "Wrong write time\n"); >+ torture_assert_u64_equal_goto(tctx, >+ nttime, >+ gi.basic_info.out.change_time, >+ ret, done, >+ "Wrong change time\n"); >+ >+done: >+ if (!smb2_util_handle_empty(handle)) { >+ smb2_util_close(tree, handle); >+ } >+ if (!smb2_util_handle_empty(testdirh)) { >+ smb2_util_close(tree, testdirh); >+ } >+ smb2_deltree(tree, BASEDIR); >+ return ret; >+} >+ > static bool test_delayed_write_vs_seteof(struct torture_context *tctx, > struct smb2_tree *tree) > { >@@ -980,6 +1187,7 @@ struct torture_suite *torture_smb2_timestamps_init(TALLOC_CTX *ctx) > torture_suite_add_1smb2_test(suite, "time_t_-1", test_time_t_minus_1); > torture_suite_add_1smb2_test(suite, "time_t_-2", test_time_t_minus_2); > torture_suite_add_1smb2_test(suite, "time_t_1968", test_time_t_1968); >+ torture_suite_add_1smb2_test(suite, "freeze-thaw", test_freeze_thaw); > > /* > * Testing of delayed write-time udpates >-- >2.30.2 > > >From 61da035cdc3c07410c745c544e7a18fa395d7775 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 5 Oct 2021 15:10:33 +0200 >Subject: [PATCH 7/7] lib: handle NTTIME_THAW in nt_time_to_full_timespec() > >Preliminary handling of NTTIME_THAW to avoid NTTIME_THAW is passed as some >mangled value down to the VFS set timestamps function. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14127 >RN: Avoid storing NTTIME_THAW (-2) as value on disk > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 6ed71ad7e6aa98a34cfde95d7d62c46694d58469) >--- > lib/util/time.c | 6 +++--- > selftest/knownfail.d/samba3.smb2.timestamps | 1 - > 2 files changed, 3 insertions(+), 4 deletions(-) > delete mode 100644 selftest/knownfail.d/samba3.smb2.timestamps > >diff --git a/lib/util/time.c b/lib/util/time.c >index e6a0668cf90..cec91c14791 100644 >--- a/lib/util/time.c >+++ b/lib/util/time.c >@@ -1128,10 +1128,10 @@ struct timespec nt_time_to_full_timespec(NTTIME nt) > if (nt == NTTIME_OMIT) { > return make_omit_timespec(); > } >- if (nt == NTTIME_FREEZE) { >+ if (nt == NTTIME_FREEZE || nt == NTTIME_THAW) { > /* >- * This should be returned as SAMBA_UTIME_FREEZE in the >- * future. >+ * This should be returned as SAMBA_UTIME_FREEZE or >+ * SAMBA_UTIME_THAW in the future. > */ > return make_omit_timespec(); > } >diff --git a/selftest/knownfail.d/samba3.smb2.timestamps b/selftest/knownfail.d/samba3.smb2.timestamps >deleted file mode 100644 >index d183ec1f583..00000000000 >--- a/selftest/knownfail.d/samba3.smb2.timestamps >+++ /dev/null >@@ -1 +0,0 @@ >-^samba3.smb2.timestamps.freeze-thaw\(.*\)$ >-- >2.30.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
slow
:
review+
Actions:
View
Attachments on
bug 14127
:
16678
| 16885