diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index ef3d6d7..e85c794 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -4981,7 +4981,7 @@ NTSTATUS smb_set_file_time(connection_struct *conn, 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 @@ -6098,6 +6098,7 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn, NTSTATUS status = NT_STATUS_OK; bool delete_on_fail = False; enum perm_type ptype; + bool modify_mtime = true; ZERO_STRUCT(ft); @@ -6246,13 +6247,36 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n", } /* Deal with any time changes. */ + if (fsp) { + /* + * We're setting the time explicitly for UNIX. + * Cancel any pending change. + */ + fsp->update_write_time_on_close = false; + TALLOC_FREE(fsp->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(ft.mtime)) { + modify_mtime = false; + } + + status = smb_set_file_time(conn, fsp, fname, psbuf, &ft, - true); + false); + if (modify_mtime) { + notify_fname(conn, NOTIFY_ACTION_MODIFIED, + FILE_NOTIFY_CHANGE_LAST_WRITE, fname); + } + return status; } /****************************************************************************