[SCM] Samba Shared Repository - branch v4-14-test updated
Jule Anger
janger at samba.org
Wed Nov 10 15:55:01 UTC 2021
The branch, v4-14-test has been updated
via 4a106c2322c lib: handle NTTIME_THAW in nt_time_to_full_timespec()
via 4e2c7c66c96 torture: add a test for NTTIME_FREEZE and NTTIME_THAW
via 7e1a65ed980 lib: add a test for null_nttime(NTTIME_THAW)
via 38ac4c09474 lib: update null_nttime() of -1: -1 is NTTIME_FREEZE
via f8fec80020e lib: use NTTIME_FREEZE in a null_nttime() test
via 43f873d52ab lib: fix null_nttime() tests
via ac6f4c093b8 lib: add NTTIME_THAW
from a1dae6a208a VERSION: Bump version up to Samba 4.14.11...
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-14-test
- Log -----------------------------------------------------------------
commit 4a106c2322c5f69f008707701ca54904b51cb297
Author: Ralph Boehme <slow at samba.org>
Date: Tue Oct 5 15:10:33 2021 +0200
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 at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit 6ed71ad7e6aa98a34cfde95d7d62c46694d58469)
Autobuild-User(v4-14-test): Jule Anger <janger at samba.org>
Autobuild-Date(v4-14-test): Wed Nov 10 15:54:35 UTC 2021 on sn-devel-184
commit 4e2c7c66c9699276f3fb1b81c4a6f574068d7141
Author: Ralph Boehme <slow at samba.org>
Date: Thu Oct 28 12:55:39 2021 +0200
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 at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit 0659069f8292996be475d407b53d161aa3f35554)
commit 7e1a65ed980afe6d5c987baf98d6f3700bbb9145
Author: Ralph Boehme <slow at samba.org>
Date: Thu Oct 28 10:18:54 2021 +0200
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 at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit 194faa76161a12ae1eae2b471d6f159d97ef75a8)
commit 38ac4c094749d880ae8b1e25942ebb7b1c182c49
Author: Ralph Boehme <slow at samba.org>
Date: Thu Oct 28 10:18:17 2021 +0200
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 at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit 5503bde93bddf3634b183e665773399c110251d4)
commit f8fec80020e8aadba8b49a3f0247009534ab7410
Author: Ralph Boehme <slow at samba.org>
Date: Thu Oct 28 10:17:01 2021 +0200
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 at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit e2740e4868f2a49877a86a8666d26226b5657317)
commit 43f873d52ab9e17209595677c4672de19da7c65a
Author: Ralph Boehme <slow at samba.org>
Date: Wed Oct 27 17:02:48 2021 +0200
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 at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit d84779302cc54a7b84c05ccc458e04b27fd142f4)
commit ac6f4c093b82501a3282c142b4912c501b2c2999
Author: Ralph Boehme <slow at samba.org>
Date: Tue Oct 5 15:10:10 2021 +0200
lib: add NTTIME_THAW
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14127
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
(cherry picked from commit f73aff502cadabb7fe6b94a697f0a2256d1d4aca)
-----------------------------------------------------------------------
Summary of changes:
lib/util/tests/time.c | 5 +-
lib/util/time.c | 8 +-
lib/util/time.h | 1 +
source4/torture/smb2/timestamps.c | 208 ++++++++++++++++++++++++++++++++++++++
4 files changed, 216 insertions(+), 6 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/tests/time.c b/lib/util/tests/time.c
index fce0eef5e2e..d94f50355d0 100644
--- a/lib/util/tests/time.c
+++ b/lib/util/tests/time.c
@@ -34,8 +34,9 @@ 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(-1), "-1");
+ 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;
}
diff --git a/lib/util/time.c b/lib/util/time.c
index e8b58e87268..680bfe7c282 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -180,7 +180,7 @@ check if it's a null NTTIME
**/
_PUBLIC_ bool null_nttime(NTTIME t)
{
- return t == 0 || t == (NTTIME)-1;
+ return t == 0;
}
/*******************************************************************
@@ -1133,10 +1133,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/lib/util/time.h b/lib/util/time.h
index 04945b5f25f..d3dfde77e2b 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
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
--
Samba Shared Repository
More information about the samba-cvs
mailing list