[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Thu Jan 26 13:14:02 UTC 2023


The branch, master has been updated
       via  56c6f0b6d64 selftest: Only run samba.tests.smb3unix in developer mode
       via  e6f0e4d5328 python:tests: Avoid exceptions in cleanup code if a test fails in smb3unix.py
       via  ac0e844ea87 param: Use a higher time resolution for lp_file_list_changed()
       via  9440cb7322d lib:param: Remove trailing whitespaces from loadparm.c
       via  fcf05b1d233 lib:util: Print data in ISO 8601 format
       via  55a49527d61 lib:util: Remove trailing whitespaces from time.c
      from  f7b50bc059d smbd: Use smbXsrv_open_global_parse_record() in .._verify_record()

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 56c6f0b6d64d29a34659c9af2e4f6ee397b3e0ca
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jan 25 10:46:03 2023 +0100

    selftest: Only run samba.tests.smb3unix in developer mode
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Thu Jan 26 13:13:50 UTC 2023 on atb-devel-224

commit e6f0e4d53285177f7a60559394efeb5a78b6bd53
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jan 24 09:18:46 2023 +0100

    python:tests: Avoid exceptions in cleanup code if a test fails in smb3unix.py
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit ac0e844ea87be7974ba6ff81745b3b0cfeecaa57
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jan 24 21:44:34 2023 +0100

    param: Use a higher time resolution for lp_file_list_changed()
    
    It is possible that in our test environment one of the config 'include' files
    change more than once per second. To avoid missing a file update we use a
    higher time resolution than seconds.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 9440cb7322d35097d63455c3fe801e62cb29396c
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jan 24 21:43:09 2023 +0100

    lib:param: Remove trailing whitespaces from loadparm.c
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit fcf05b1d233aa90f6043730c17e94886b0a50be8
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jan 24 22:31:17 2023 +0100

    lib:util: Print data in ISO 8601 format
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 55a49527d61bc8ddae88178936b4e8fbba6a163c
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jan 24 22:31:00 2023 +0100

    lib:util: Remove trailing whitespaces from time.c
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/param/loadparm.c           | 28 ++++++++++++++++------------
 lib/param/loadparm.h           |  2 +-
 lib/util/time.c                | 42 +++++++++++++++++++++---------------------
 python/samba/tests/smb3unix.py | 12 +++++++-----
 source3/param/loadparm.c       | 38 ++++++++++++++++++++++++++++++--------
 source3/selftest/tests.py      |  5 ++++-
 source3/wscript                |  1 +
 7 files changed, 80 insertions(+), 48 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index fc0dc4df83f..c1d1f5393d1 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -1,4 +1,4 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Parameter loading functions
    Copyright (C) Karl Auer 1993-1998
@@ -1009,6 +1009,8 @@ void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **list,
 			     const char *fname, const char *subfname)
 {
 	struct file_lists *f = *list;
+	struct stat sb = {0};
+	int rc;
 
 	while (f) {
 		if (f->name && !strcmp(f->name, fname))
@@ -1017,7 +1019,7 @@ void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **list,
 	}
 
 	if (!f) {
-		f = talloc(mem_ctx, struct file_lists);
+		f = talloc_zero(mem_ctx, struct file_lists);
 		if (!f)
 			goto fail;
 		f->next = *list;
@@ -1032,12 +1034,14 @@ void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **list,
 			goto fail;
 		}
 		*list = f;
-		f->modtime = file_modtime(subfname);
-	} else {
-		time_t t = file_modtime(subfname);
-		if (t)
-			f->modtime = t;
 	}
+
+	rc = stat(subfname, &sb);
+	if (rc != 0) {
+		return;
+	}
+	f->modtime = get_mtimespec(&sb);
+
 	return;
 
 fail:
@@ -2146,7 +2150,7 @@ void lpcfg_print_parameter(struct parm_struct *p, void *ptr, FILE * f)
 			break;
 
 		case P_OCTAL: {
-			int val = *(int *)ptr; 
+			int val = *(int *)ptr;
 			if (val == -1) {
 				fprintf(f, "-1");
 			} else {
@@ -3199,7 +3203,7 @@ struct loadparm_context *loadparm_init_global(bool load_default)
 /**
  * Initialise the global parameter structure.
  */
-struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx, 
+struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx,
 					  const struct loadparm_s3_helpers *s3_fns)
 {
 	struct loadparm_context *loadparm_context = talloc_zero(mem_ctx, struct loadparm_context);
@@ -3227,7 +3231,7 @@ const char *lp_default_path(void)
 }
 
 /**
- * Update the internal state of a loadparm context after settings 
+ * Update the internal state of a loadparm context after settings
  * have changed.
  */
 static bool lpcfg_update(struct loadparm_context *lp_ctx)
@@ -3273,7 +3277,7 @@ static bool lpcfg_update(struct loadparm_context *lp_ctx)
 			   lp_ctx->globals->syslog,
 			   lp_ctx->globals->syslog_only);
 
-	/* FIXME: This is a bit of a hack, but we can't use a global, since 
+	/* FIXME: This is a bit of a hack, but we can't use a global, since
 	 * not everything that uses lp also uses the socket library */
 	if (lpcfg_parm_bool(lp_ctx, NULL, "socket", "testnonblock", false)) {
 		setenv("SOCKET_TESTNONBLOCK", "1", 1);
@@ -3305,7 +3309,7 @@ bool lpcfg_load_default(struct loadparm_context *lp_ctx)
     path = lp_default_path();
 
     if (!file_exist(path)) {
-	    /* We allow the default smb.conf file to not exist, 
+	    /* We allow the default smb.conf file to not exist,
 	     * basically the equivalent of an empty file. */
 	    return lpcfg_update(lp_ctx);
     }
diff --git a/lib/param/loadparm.h b/lib/param/loadparm.h
index 98263f0e62b..af6b530366a 100644
--- a/lib/param/loadparm.h
+++ b/lib/param/loadparm.h
@@ -102,7 +102,7 @@ struct file_lists {
 	struct file_lists *next;
 	char *name;
 	char *subfname;
-	time_t modtime;
+	struct timespec modtime;
 };
 
 #define DEFAULT_NAME_RESOLVE_ORDER "lmhosts wins host bcast"
diff --git a/lib/util/time.c b/lib/util/time.c
index f1d6b566618..773fd611a33 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -1,9 +1,9 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    time handling functions
 
    Copyright (C) Andrew Tridgell 		1992-2004
-   Copyright (C) Stefan (metze) Metzmacher	2002   
+   Copyright (C) Stefan (metze) Metzmacher	2002
    Copyright (C) Jeremy Allison			2007
    Copyright (C) Andrew Bartlett                2011
 
@@ -11,12 +11,12 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -137,12 +137,12 @@ This takes GMT as input
 **/
 _PUBLIC_ void unix_to_nt_time(NTTIME *nt, time_t t)
 {
-	uint64_t t2; 
+	uint64_t t2;
 
 	if (t == (time_t)-1) {
 		*nt = (NTTIME)-1LL;
 		return;
-	}	
+	}
 
 	if (t == TIME_T_MAX || t == INT64_MAX) {
 		*nt = 0x7fffffffffffffffLL;
@@ -152,7 +152,7 @@ _PUBLIC_ void unix_to_nt_time(NTTIME *nt, time_t t)
 	if (t == 0) {
 		*nt = 0;
 		return;
-	}		
+	}
 
 	t2 = t;
 	t2 += TIME_FIXUP_CONSTANT_INT;
@@ -167,8 +167,8 @@ check if it's a null unix time
 **/
 _PUBLIC_ bool null_time(time_t t)
 {
-	return t == 0 || 
-		t == (time_t)0xFFFFFFFF || 
+	return t == 0 ||
+		t == (time_t)0xFFFFFFFF ||
 		t == (time_t)-1;
 }
 
@@ -271,7 +271,7 @@ void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int *hour,in
 {
 	uint32_t p0,p1,p2,p3;
 
-	p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF; 
+	p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF;
 	p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
 
 	*second = 2*(p0 & 0x1F);
@@ -295,11 +295,11 @@ _PUBLIC_ time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset)
 	dos_date = IVAL(date_ptr,0);
 
 	if (dos_date == 0) return (time_t)0;
-  
+
 	interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
 			   &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
 	t.tm_isdst = -1;
-  
+
 	ret = timegm(&t);
 
 	ret += zone_offset;
@@ -397,7 +397,7 @@ const char *timespec_string_buf(const struct timespec *tp,
 		}
 	} else if (!hires) {
 		len = snprintf(buf->buf, sizeof(buf->buf),
-			       "%04d/%02d/%02d %02d:%02d:%02d",
+			       "%04d-%02d-%02d %02d:%02d:%02d",
 			       1900 + tm->tm_year,
 			       tm->tm_mon + 1,
 			       tm->tm_mday,
@@ -406,7 +406,7 @@ const char *timespec_string_buf(const struct timespec *tp,
 			       tm->tm_sec);
 	} else {
 		len = snprintf(buf->buf, sizeof(buf->buf),
-			       "%04d/%02d/%02d %02d:%02d:%02d.%09ld",
+			       "%04d-%02d-%02d %02d:%02d:%02d.%09ld",
 			       1900 + tm->tm_year,
 			       tm->tm_mon + 1,
 			       tm->tm_mday,
@@ -693,7 +693,7 @@ _PUBLIC_ struct timeval timeval_current_ofs_usec(uint32_t usecs)
 }
 
 /**
-  compare two timeval structures. 
+  compare two timeval structures.
   Return -1 if tv1 < tv2
   Return 0 if tv1 == tv2
   Return 1 if tv1 > tv2
@@ -723,7 +723,7 @@ _PUBLIC_ bool timeval_expired(const struct timeval *tv)
 */
 _PUBLIC_ double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2)
 {
-	return (tv2->tv_sec - tv1->tv_sec) + 
+	return (tv2->tv_sec - tv1->tv_sec) +
 	       (tv2->tv_usec - tv1->tv_usec)*1.0e-6;
 }
 
@@ -806,7 +806,7 @@ _PUBLIC_ struct timeval timeval_until(const struct timeval *tv1,
 */
 _PUBLIC_ NTTIME timeval_to_nttime(const struct timeval *tv)
 {
-	return 10*(tv->tv_usec + 
+	return 10*(tv->tv_usec +
 		  ((TIME_FIXUP_CONSTANT + (uint64_t)tv->tv_sec) * 1000000));
 }
 
@@ -828,7 +828,7 @@ _PUBLIC_ void nttime_to_timeval(struct timeval *tv, NTTIME t)
 		tv->tv_usec = 0;
 		return;
 	}
-	
+
 	tv->tv_usec = t - tv->tv_sec*1000000;
 }
 
@@ -938,8 +938,8 @@ bool nt_time_equal(NTTIME *t1, NTTIME *t2)
 
 bool null_timespec(struct timespec ts)
 {
-	return ts.tv_sec == 0 || 
-		ts.tv_sec == (time_t)0xFFFFFFFF || 
+	return ts.tv_sec == 0 ||
+		ts.tv_sec == (time_t)0xFFFFFFFF ||
 		ts.tv_sec == (time_t)-1;
 }
 
@@ -992,7 +992,7 @@ struct timespec timespec_min(const struct timespec *ts1,
 }
 
 /****************************************************************************
-  compare two timespec structures. 
+  compare two timespec structures.
   Return -1 if ts1 < ts2
   Return 0 if ts1 == ts2
   Return 1 if ts1 > ts2
diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py
index 3ad49af09fa..d8f9b7d5c33 100644
--- a/python/samba/tests/smb3unix.py
+++ b/python/samba/tests/smb3unix.py
@@ -189,8 +189,9 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
                              'SMB2_FIND_POSIX_INFORMATION failed to list contents')
 
         finally:
-            for fname in test_files:
-                self.delete_test_file(c, fname)
+            if len(test_files) > 0:
+                for fname in test_files:
+                    self.delete_test_file(c, fname)
 
             self.disable_smb3unix()
 
@@ -283,6 +284,7 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
             self.disable_smb3unix()
 
     def test_posix_perm_files(self):
+        test_files = {}
         try:
             self.enable_smb3unix()
 
@@ -294,7 +296,6 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
                 posix=True)
             self.assertTrue(c.have_posix())
 
-            test_files = {}
             for perm in range(0o600, 0o7777+1):
                 # Owner write permission is required or cleanup will fail, and
                 # owner read is required to list the file if O_PATH is disabled
@@ -332,8 +333,9 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
                                          (test_files[fname], found_files[fname]))
 
         finally:
-            for fname in test_files.keys():
-                self.delete_test_file(c, '\\%s' % fname)
+            if len(test_files) > 0:
+                for fname in test_files.keys():
+                    self.delete_test_file(c, '\\%s' % fname)
 
             self.disable_smb3unix()
 
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 56a8bc2d28b..05a5ae20abe 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -79,6 +79,7 @@
 #include "auth/credentials/credentials.h"
 #include "source3/lib/substitute.h"
 #include "source3/librpc/gen_ndr/ads.h"
+#include "lib/util/time_basic.h"
 
 #ifdef HAVE_SYS_SYSCTL_H
 #include <sys/sysctl.h>
@@ -2408,8 +2409,15 @@ bool lp_file_list_changed(void)
 				return true;
 			}
 		} else {
-			time_t mod_time;
+			struct timespec mod_time = {
+				.tv_sec = 0,
+			};
+			struct timeval_buf tbuf = {
+				.buf = {0},
+			};
 			char *n2 = NULL;
+			struct stat sb = {0};
+			int rc;
 
 			n2 = talloc_sub_basic(talloc_tos(),
 					      get_current_username(),
@@ -2419,19 +2427,29 @@ bool lp_file_list_changed(void)
 				return false;
 			}
 			DEBUGADD(6, ("file %s -> %s  last mod_time: %s\n",
-				     f->name, n2, ctime(&f->modtime)));
-
-			mod_time = file_modtime(n2);
+				     f->name, n2,
+				     timespec_string_buf(&f->modtime,
+							 true,
+							 &tbuf)));
+
+			rc = stat(n2, &sb);
+			if (rc == 0) {
+				mod_time = get_mtimespec(&sb);
+			}
 
-			if (mod_time &&
-			    ((f->modtime != mod_time) ||
+			if (mod_time.tv_sec > 0 &&
+			    ((timespec_compare(&mod_time, &f->modtime) != 0) ||
 			     (f->subfname == NULL) ||
 			     (strcmp(n2, f->subfname) != 0)))
 			{
+				f->modtime = mod_time;
+
 				DEBUGADD(6,
 					 ("file %s modified: %s\n", n2,
-					  ctime(&mod_time)));
-				f->modtime = mod_time;
+					  timespec_string_buf(&f->modtime,
+							      true,
+							      &tbuf)));
+
 				TALLOC_FREE(f->subfname);
 				f->subfname = talloc_strdup(f, n2);
 				if (f->subfname == NULL) {
@@ -4831,6 +4849,10 @@ uint32_t lp_get_async_dns_timeout(void)
 
 bool lp_smb3_unix_extensions(void)
 {
+	/*
+	 * FIXME: If this gets always enabled, check source3/selftest/tests.py
+	 * and source3/wscript for HAVE_SMB3_UNIX_EXTENSIONS.
+	 */
 #if defined(DEVELOPER)
 	return lp__smb3_unix_extensions();
 #else
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 8039b4a8171..187f3ccd9c0 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -92,6 +92,8 @@ have_inotify = ("HAVE_INOTIFY" in config_hash)
 have_ldwrap = ("HAVE_LDWRAP" in config_hash)
 with_pthreadpool = ("WITH_PTHREADPOOL" in config_hash)
 
+have_smb3_unix_extensions = ("HAVE_SMB3_UNIX_EXTENSIONS" in config_hash)
+
 def is_module_enabled(module):
     if module in config_hash["STRING_SHARED_MODULES"]:
         return True
@@ -1706,7 +1708,8 @@ for t in CLUSTERED_LOCAL_TESTS:
          smbtorture3,
          "-N 1000 -o 2000"])
 
-planpythontestsuite("fileserver", "samba.tests.smb3unix")
+if have_smb3_unix_extensions:
+    planpythontestsuite("fileserver", "samba.tests.smb3unix")
 planpythontestsuite("fileserver", "samba.tests.reparsepoints")
 planpythontestsuite("fileserver_smb1", "samba.tests.smb2symlink")
 planpythontestsuite("fileserver_smb1", "samba.tests.smb1posix")
diff --git a/source3/wscript b/source3/wscript
index e77cd127e60..0dbf02ed530 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -111,6 +111,7 @@ def configure(conf):
     if Options.options.developer:
         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
         conf.env.developer = True
+        conf.DEFINE('HAVE_SMB3_UNIX_EXTENSIONS', '1')
 
     if sys.platform != 'openbsd5':
         conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)


-- 
Samba Shared Repository



More information about the samba-cvs mailing list