Package: samba Version: 2:3.2.5-4lenny9 Severity: normal Tags: patch "cp -a ${FILE} ${CIFS_SHARE}/" does not maintain the original file's mtime when copied (and possibly "moved", but i can't remember) to a samba CIFS share.
client: * ubuntu hardy (amd64) * debian lenny (i386) server: * debian lenny (amd64) i've suffered from this bug ever since lenny was released, but found nothing a year ago. a week ago i finally got fed up with it and did some hard searching finding this upstream bug report. https://bugzilla.samba.org/show_bug.cgi?id=6520 attached is my patch to 2:3.2.5-4lenny9 which i've successfully tested and used for the last week in three different installations. corey -- undefi...@pobox.com
diff -urNpd samba-3.2.5/debian/changelog samba-3.2.5.new/debian/changelog --- samba-3.2.5/debian/changelog 2010-04-30 19:13:04.000000000 +0000 +++ samba-3.2.5.new/debian/changelog 2010-04-30 19:12:17.000000000 +0000 @@ -1,3 +1,9 @@ +samba (2:3.2.5-4lenny9~udo50+1) lenny; urgency=low + + * Bug fix, fixing preserving modtime with "cp -p". + + -- Corey Wright <undefi...@pobox.com> Fri, 30 Apr 2010 14:11:29 -0500 + samba (2:3.2.5-4lenny9) stable-security; urgency=low * Security update, fixing the following issues in mount.cifs: diff -urNpd samba-3.2.5/debian/patches/samba_preserve_modtime.patch samba-3.2.5.new/debian/patches/samba_preserve_modtime.patch --- samba-3.2.5/debian/patches/samba_preserve_modtime.patch 1970-01-01 00:00:00.000000000 +0000 +++ samba-3.2.5.new/debian/patches/samba_preserve_modtime.patch 2010-04-30 18:53:06.000000000 +0000 @@ -0,0 +1,65 @@ +Index: samba-3.2.5/source/smbd/trans2.c +=================================================================== +--- samba-3.2.5.orig/source/smbd/trans2.c 2010-04-30 18:46:44.000000000 +0000 ++++ samba-3.2.5/source/smbd/trans2.c 2010-04-30 18:52:58.000000000 +0000 +@@ -4878,7 +4878,7 @@ + + if (setting_write_time) { + /* +- * This was a setfileinfo on an open file. ++ * This was a Windows setfileinfo on an open file. + * NT does this a lot. We also need to + * set the time here, as it can be read by + * FindFirst/FindNext and with the patch for bug #2045 +@@ -5911,6 +5911,9 @@ + NTSTATUS status = NT_STATUS_OK; + bool delete_on_fail = False; + enum perm_type ptype; ++ files_struct *all_fsps = NULL; ++ bool modify_mtime = true; ++ struct file_id id; + + if (total_data < 100) { + return NT_STATUS_INVALID_PARAMETER; +@@ -6057,13 +6060,39 @@ + } + + /* Deal with any time changes. */ ++ id = vfs_file_id_from_sbuf(conn, psbuf); ++ for(all_fsps = file_find_di_first(id); all_fsps; ++ all_fsps = file_find_di_next(all_fsps)) { ++ /* ++ * We're setting the time explicitly for UNIX. ++ * Cancel any pending changes over all handles. ++ */ ++ all_fsps->update_write_time_on_close = false; ++ TALLOC_FREE(all_fsps->update_write_time_event); ++ } + +- return smb_set_file_time(conn, ++ /* ++ * Override the "setting_write_time" ++ * parameter here as it almost does what ++ * we need. Just remember if we modified ++ * mtime and send the notify ourselves. ++ */ ++ if (null_timespec(ts[1])) { ++ modify_mtime = false; ++ } ++ ++ status = smb_set_file_time(conn, + fsp, + fname, + psbuf, + ts, +- true); ++ false); ++ ++ if (modify_mtime) { ++ notify_fname(conn, NOTIFY_ACTION_MODIFIED, ++ FILE_NOTIFY_CHANGE_LAST_WRITE, fname); ++ } ++ return status; + } + + /**************************************************************************** diff -urNpd samba-3.2.5/debian/patches/series samba-3.2.5.new/debian/patches/series --- samba-3.2.5/debian/patches/series 2010-04-30 19:13:04.000000000 +0000 +++ samba-3.2.5.new/debian/patches/series 2010-04-30 18:54:33.000000000 +0000 @@ -1,3 +1,4 @@ +samba_preserve_modtime.patch documentation.patch fhs-filespaths.patch fhs-filespaths-debatable.patch