Patch to ignoring set_filetime commands

Andre Uratsuka Manoel andre at
Thu Jul 22 21:10:57 GMT 1999


	I have a client with a setup in which they write web pages in a
samba server. The pages are then mirrored to other sites, according to
their modification date. 

	I made a little patch against samba 2.0.4a to create an option
"ignore setfiletime" in the config file that causes samba to ignore the
set_filetime commands sent by the windows clients. That is because after a
copy operation (used by the users to publish files from the test share to
the production share), windows tries to set the modification times of the
copied files to be the same as those of the original files, but I want
those to be the time of the copy operation.

	I suppose this is the right place to post this patch, if not,
please redirect me to the right place. Also, I can try to make the changes
against 2.0.5 instead of against 2.0.4...


diff -U4 -N -r samba-2.0.4b/docs/textdocs/IgnoreSetFileTime.txt samba-2.0.4b-insite/docs/textdocs/IgnoreSetFileTime.txt
--- samba-2.0.4b/docs/textdocs/IgnoreSetFileTime.txt	Wed Dec 31 21:00:00 1969
+++ samba-2.0.4b-insite/docs/textdocs/IgnoreSetFileTime.txt	Wed Jul 21 19:13:34 1999
@@ -0,0 +1,24 @@
+!== IgnoreSetFileTime.txt for Samba release 2.0.4b 21 July 1999
+Contributor:	Andre Uratsuka Manoel (andre at
+Date:		July 1999
+Status:		Experimental
+Subject:	ignore setfiletime hack
+I had a problem with a directory hierarchy that was mirrored to another
+site by comparing dates. When a file was edited and then copied to a
+samba share, Windows would try to set the time of the file to the
+time of the original file. That was not what I wanted. I wanted to 
+know what the changes files were. So one option was added to the 
+configuration file to allow for certain shares to ignore the 
+setfiletime command sent by clients.
+That is probably not something people would normally use, but I needed
+this feature badly.
+The option is "ignore setfiletime" it is boolean that can be set either
+as "yes" or "no". The default behavior is "no".
diff -U4 -N -r samba-2.0.4b/docs/yodldocs/smb.conf.5.yo samba-2.0.4b-insite/docs/yodldocs/smb.conf.5.yo
--- samba-2.0.4b/docs/yodldocs/smb.conf.5.yo	Mon May  3 14:32:16 1999
+++ samba-2.0.4b-insite/docs/yodldocs/smb.conf.5.yo	Wed Jul 21 19:18:57 1999
@@ -421,8 +421,16 @@
 By default, Samba 2.0 has the same semantics as a Windows NT
 server, in that it is case insensitive but case preserving.
+bf("ignore setfiletime = yes/no") controls whether the samba server
+will ignore or not setfiletime commands sent by the clients. It is
+used primarily to stop windows client from changing the time of files
+during copies to the time of the original file. This way, the files
+will get the current time as the modification time.
 There are a number of ways in which a user can connect to a
@@ -949,8 +957,10 @@
 it() link(bf(share modes))(sharemodes)
 it() link(bf(short preserve case))(shortpreservecase)
+it() link(bf(ignore setfiletime))(ignoresetfiletime)
 it() link(bf(status))(status)
 it() link(bf(strict locking))(strictlocking)
diff -U4 -N -r samba-2.0.4b/source/param/loadparm.c samba-2.0.4b-insite/source/param/loadparm.c
--- samba-2.0.4b/source/param/loadparm.c	Mon May 17 20:37:24 1999
+++ samba-2.0.4b-insite/source/param/loadparm.c	Tue Jul 20 21:21:52 1999
@@ -338,9 +338,10 @@
   BOOL bDosFiletimeResolution;
   BOOL bFakeDirCreateTimes;
   BOOL bBlockingLocks;
   BOOL bMangleLocks;
-  char dummy[3]; /* for alignment */
+  BOOL bIgnoreSetFileTime; /* Ignora o comando set_filetime */
+  char dummy[2]; /* for alignment */
 } service;
 /* This is a default service used to prime a services structure */
@@ -433,8 +434,9 @@
   False, /* bDosFiletimeResolution */
   False, /* bFakeDirCreateTimes */
   True,  /* bBlockingLocks */
   True,  /* bMangleLocks */
+  False, /* bIgnoreSetFileTime */
   ""     /* dummy */
@@ -743,8 +745,9 @@
   {"fake oplocks",     P_BOOL,    P_LOCAL,  &sDefault.bFakeOplocks,     NULL,   NULL,  FLAG_SHARE},
   {"kernel oplocks",   P_BOOL,    P_GLOBAL, &Globals.bKernelOplocks,    NULL,   NULL,  FLAG_GLOBAL},
   {"locking",          P_BOOL,    P_LOCAL,  &sDefault.bLocking,         NULL,   NULL,  FLAG_SHARE|FLAG_GLOBAL},
   {"mangle locks",     P_BOOL,    P_LOCAL,  &sDefault.bMangleLocks,     NULL,   NULL,  FLAG_SHARE|FLAG_GLOBAL},
+  {"ignore setfiletime",     P_BOOL,    P_LOCAL,  &sDefault.bIgnoreSetFileTime,     NULL,   NULL,  FLAG_SHARE|FLAG_GLOBAL},
   {"ole locking compatibility",   P_BOOL,    P_GLOBAL,  &Globals.bOleLockingCompat,   NULL,   NULL,  FLAG_GLOBAL},
   {"oplocks",          P_BOOL,    P_LOCAL,  &sDefault.bOpLocks,         NULL,   NULL,  FLAG_SHARE|FLAG_GLOBAL},
   {"oplock break wait time",P_INTEGER,P_GLOBAL,&Globals.oplock_break_wait_time,NULL,NULL,FLAG_GLOBAL},
   {"oplock contention limit",P_INTEGER,P_LOCAL,&sDefault.iOplockContentionLimit,NULL,NULL,FLAG_SHARE|FLAG_GLOBAL},
@@ -1333,8 +1336,9 @@
diff -U4 -N -r samba-2.0.4b/source/smbd/dosmode.c samba-2.0.4b-insite/source/smbd/dosmode.c
--- samba-2.0.4b/source/smbd/dosmode.c	Tue Feb 16 19:55:03 1999
+++ samba-2.0.4b-insite/source/smbd/dosmode.c	Wed Jul 21 19:28:23 1999
@@ -246,10 +246,16 @@
   if (null_mtime(mtime)) return(True);
   times.modtime = times.actime = mtime;
-  if (file_utime(conn, fname, &times)) {
-    DEBUG(4,("set_filetime(%s) failed: %s\n",fname,strerror(errno)));
+  Ignore this command if "ignore setfiletime" option is set in the
+   configuration file for this share - Andre Manoel (andre at
+  if (!lp_ignore_setfiletime(SNUM(conn))) {
+    if (file_utime(conn, fname, &times)) {
+      DEBUG(4,("set_filetime(%s) failed: %s\n",fname,strerror(errno)));
+    }

More information about the samba-technical mailing list