Fix bug #7693 - smbd changing mode of files on rename
authorJeremy Allison <jra@samba.org>
Wed, 22 Sep 2010 19:26:13 +0000 (12:26 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 22 Sep 2010 19:30:12 +0000 (12:30 -0700)
When using "map archive", don't change the archive bit on
renames or writes with UNIX extensions turned on.

Jeremy.
(cherry picked from commit 314dc23ecfb5fc014f9c2ef70bd508eb837632b0)

source3/smbd/fileio.c
source3/smbd/reply.c

index b4e8a1d5d4d0cb53a8124712d3ad4af87f06fde0..aec6554436cfdbe8eacb3a07f161f1b97ca165b8 100644 (file)
@@ -312,14 +312,15 @@ ssize_t write_file(struct smb_request *req,
                fsp->modified = True;
 
                if (SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) == 0) {
-                       int dosmode;
                        trigger_write_time_update(fsp);
-                       dosmode = dos_mode(fsp->conn, fsp->fsp_name);
-                       if ((lp_store_dos_attributes(SNUM(fsp->conn)) ||
-                                       MAP_ARCHIVE(fsp->conn)) &&
-                                       !IS_DOS_ARCHIVE(dosmode)) {
-                               file_set_dosmode(fsp->conn, fsp->fsp_name,
+                       if (!fsp->posix_open &&
+                                       (lp_store_dos_attributes(SNUM(fsp->conn)) ||
+                                       MAP_ARCHIVE(fsp->conn))) {
+                               int dosmode = dos_mode(fsp->conn, fsp->fsp_name);
+                               if (!IS_DOS_ARCHIVE(dosmode)) {
+                                       file_set_dosmode(fsp->conn, fsp->fsp_name,
                                                 dosmode | aARCH, NULL, false);
+                               }
                        }
 
                        /*
index ba4c90d55299dce791712866a87c508706659f96..72f09cd1cde1196f0baa72d412302c505ddcccad 100644 (file)
@@ -5976,8 +5976,9 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                          "%s -> %s\n", smb_fname_str_dbg(fsp->fsp_name),
                          smb_fname_str_dbg(smb_fname_dst)));
 
-               if (lp_map_archive(SNUM(conn)) ||
-                   lp_store_dos_attributes(SNUM(conn))) {
+               if (!lp_unix_extensions() &&
+                   (lp_map_archive(SNUM(conn)) ||
+                   lp_store_dos_attributes(SNUM(conn)))) {
                        /* We must set the archive bit on the newly
                           renamed file. */
                        if (SMB_VFS_STAT(conn, smb_fname_dst) == 0) {