[Samba] Samba patch kludge-gmt fixes red files in WinCvs

Thomas Günther tom at toms-cafe.de
Tue Feb 8 15:41:57 GMT 2005


Hi all,

in our LAN we use a Samba server (version 2.2.9) on Linux (Debian Woody)
to provide file services to workstations running (mostly) W2K. WinCVS is
a GUI frontend to the popular CVS version control system. After the swap
to and from daylight savings time WinCVS erroneously flags all files in
cvs working directories on Samba shares as modified (because of the icon
color WinCVS users refer to modified files as "red").

We found this rather astonishing: CVS records time stamps in GMT/UTC
just like Linux, so there shouldn't be any time zone related
differences. Closer examiniation revealed that Samba doesn't send the
original time stamps but converts them to so called kludge-GMT which
   1. may differ by 1 hour to GMT for some files,
   2. changes by 1 hour on every swap to and from daylight savings.

Samba does that in order to be compatible with some combination of MS
file and operating systems (for instance W2K with FAT as file server).
Since we use mainly W2K with NTFS which delivers "real" GMT time stamps,
we wanted to turn off the conversion to kludge-GMT in Samba but found no
way to do it through configuration.

A first workaround emerged from the observation that for a timezone
without daylight savings period (like UTC) there is no difference
between kludge-GMT and real GMT: we changed the timezone for the Samba
processes to GMT/UTC by setting the environment variable TZ to UTC for
the smbd process:
   export TZ=UTC
   smbd ...

This does the job but has some small disadvantages:
   1. The syslog entries of Samba are now in GMT while all other
      syslog entries remain in localtime which is confusing to
      misleading.
   2. Old clients without or with incomplete timezone support (e.g.
      OS/2) get the wrong time from the Samba server with "net time".

Therefore we searched for a better solution and created the attached
kludge-gmt patch for Samba. This patch adds a new option "kludge GMT".
For compatibility the default value is "true". When set to "false" in
the global section of smb.conf Samba always provides real GMT.

Last autumn both solutions were tested "in the field" during the swap
off daylight savings time. They worked very well.

The attached patch is made against samba-2.2.9. It doesn't apply cleanly
to recent versions of Samba but could put in manually (just ignore the
reject for time.c and search for "time offset" in loadparm.c).

Regards,
Thomas Honigmann and Thomas Günther

-------------- next part --------------
diff -Naur samba-2.2.9.orig/source/lib/time.c samba-2.2.9/source/lib/time.c
--- samba-2.2.9.orig/source/lib/time.c	Sat May  8 03:07:12 2004
+++ samba-2.2.9/source/lib/time.c	Fri Oct 22 15:53:01 2004
@@ -28,6 +28,7 @@
 
 
 int extra_time_offset = 0;
+BOOL use_kludge_gmt = True;
 
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
@@ -315,8 +316,11 @@
   ret = (time_t)(d+0.5);
 
   /* this takes us from kludge-GMT to real GMT */
-  ret -= get_serverzone();
-  ret += LocTimeDiff(ret);
+  if (use_kludge_gmt)
+  {
+    ret -= get_serverzone();
+    ret += LocTimeDiff(ret);
+  }
 
   return(ret);
 }
@@ -359,8 +363,11 @@
 	ret = (time_t)(d+0.5);
 
 	/* this takes us from kludge-GMT to real GMT */
-	ret -= get_serverzone();
-	ret += LocTimeDiff(ret);
+	if (use_kludge_gmt)
+	{
+		ret -= get_serverzone();
+		ret += LocTimeDiff(ret);
+	}
 
 	return(ret);
 }
@@ -406,7 +413,8 @@
 	}		
 
 	/* this converts GMT to kludge-GMT */
-	t -= TimeDiff(t) - get_serverzone(); 
+	if (use_kludge_gmt)
+		t -= TimeDiff(t) - get_serverzone(); 
 
 	d = (double)(t);
 	d += TIME_FIXUP_CONSTANT;
diff -Naur samba-2.2.9.orig/source/param/loadparm.c samba-2.2.9/source/param/loadparm.c
--- samba-2.2.9.orig/source/param/loadparm.c	Sat May  8 03:07:10 2004
+++ samba-2.2.9/source/param/loadparm.c	Fri Oct 22 15:40:35 2004
@@ -94,6 +94,7 @@
 BOOL use_getwd_cache = True;
 
 extern int extra_time_offset;
+extern BOOL use_kludge_gmt;
 
 static BOOL defaults_saved = False;
 
@@ -1065,6 +1066,7 @@
 	{"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL, 0},
 	{"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL, NULL, 0},
 	{"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL, NULL, 0},
+	{"kludge GMT", P_BOOL, P_GLOBAL, &use_kludge_gmt, NULL, NULL, FLAG_ADVANCED},
 	{"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL, 0},
 	{"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL, FLAG_HIDE},
 	





More information about the samba mailing list