[gnu.emacs.bug] Auto-save in GNU

stoller@CS.UTAH.EDU (Leigh B. Stoller) (10/31/88)

The version is 18.52. The problem is that auto-save creates the new
file with a 666 protection. Instead, it should have the same
protection as the original file. The following a is context diff from
fileio.c. There are better ways to this, but this was easiest.

Leigh

*** /tmp/,RCSt1004274	Sun Oct 30 14:41:33 1988
--- fileio.c	Sun Oct 30 14:35:45 1988
***************
*** 71,76 ****
--- 71,80 ----
  /* Nonzero during writing of auto-save files */
  int auto_saving;
  
+ /* Set by auto_save_1 to mode of original file so Fwrite_region will create
+    a new file with the same mode as the original */
+ int auto_save_mode_bits;
+ 
  /* Nonzero means, when reading a filename in the minibuffer,
   start out by inserting the default directory into the minibuffer. */
  int insert_default_directory;
***************
*** 1645,1651 ****
  	  fd = creat (fn, 0666);
        }
  #else /* not VMS */
!   fd = creat (fn, 0666);
  #endif /* not VMS */
  
    if (fd < 0)
--- 1649,1659 ----
  	  fd = creat (fn, 0666);
        }
  #else /* not VMS */
!     if (auto_saving)
!       fd = creat (fn, auto_save_mode_bits);
!     else
!       fd = creat (fn, 0666);
! 
  #endif /* not VMS */
  
    if (fd < 0)
***************
*** 1881,1886 ****
--- 1889,1902 ----
  Lisp_Object
  auto_save_1 ()
  {
+   Lisp_Object filename;
+   unsigned char *fn;
+   struct stat st;
+ 
+   filename = Fexpand_file_name (bf_cur->name, Qnil);
+   fn = XSTRING (filename)->data;
+   stat (fn, &st);
+   auto_save_mode_bits = st.st_mode;
    return
      Fwrite_region (Qnil, Qnil,
  		   bf_cur->auto_save_file_name,