To:
[email protected]
Subject: Patch 6.3b.021
Fcc: outbox
From: Bram Moolenaar <
[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------
Patch 6.3b.021
Problem: The swapfile is not readable for others, the ATTENTION prompt does
not show all info when someone else is editing the same file.
(Marcel Svitalsky)
Solution: Use the protection of original file for the swapfile and set it
after creating the swapfile.
Files: src/fileio.c
*** ../vim-6.3b.020/src/fileio.c Fri May 21 13:40:43 2004
--- src/fileio.c Tue Jun 1 15:02:00 2004
***************
*** 246,251 ****
--- 246,252 ----
long linerest = 0; /* remaining chars in line */
#ifdef UNIX
int perm = 0;
+ int swap_mode = -1; /* protection bits for swap file */
#else
int perm;
#endif
***************
*** 452,464 ****
#endif
#ifdef UNIX
/*
! * Set the protection bits of the swap file equal to the original
! * file. This makes it possible for others to read the name of the
! * original file from the swapfile.
*/
! if (curbuf->b_ml.ml_mfp->mf_fname != NULL)
! (void)mch_setperm(curbuf->b_ml.ml_mfp->mf_fname,
! (long)((st.st_mode & 0777) | 0600));
#endif
#ifdef FEAT_CW_EDITOR
/* Get the FSSpec on MacOS
--- 453,469 ----
#endif
#ifdef UNIX
/*
! * Use the protection bits of the original file for the swap file.
! * This makes it possible for others to read the name of the
! * edited file from the swapfile, but only if they can read the
! * edited file.
! * Remove the "write" and "execute" bits for group and others
! * (they must not write the swapfile).
! * Add the "read" and "write" bits for the user, otherwise we may
! * not be able to write to the file ourselves.
! * Setting the bits is done below, after creating the swap file.
*/
! swap_mode = (st.st_mode & 0644) | 0600;
#endif
#ifdef FEAT_CW_EDITOR
/* Get the FSSpec on MacOS
***************
*** 617,623 ****
--- 622,635 ----
#ifdef FEAT_QUICKFIX
if (!bt_dontwrite(curbuf))
#endif
+ {
check_need_swap(newfile);
+ #ifdef UNIX
+ /* Set swap file protection bits after creating it. */
+ if (swap_mode > 0 && curbuf->b_ml.ml_mfp->mf_fname != NULL)
+ (void)mch_setperm(curbuf->b_ml.ml_mfp->mf_fname, (long)swap_mode);
+ #endif
+ }
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
/* If "Quit" selected at ATTENTION dialog, don't load the file */
*** ../vim-6.3b.020/src/version.c Tue Jun 1 09:46:26 2004
--- src/version.c Tue Jun 1 20:43:56 2004
***************
*** 643,644 ****
--- 643,646 ----
{ /* Add new patch number below this line */
+ /**/
+ 21,
/**/
--
How To Keep A Healthy Level Of Insanity:
9. As often as possible, skip rather than walk.
/// Bram Moolenaar --
[email protected] --
http://www.Moolenaar.net \\\
/// Sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ Project leader for A-A-P --
http://www.A-A-P.org ///
\\\ Buy at Amazon and help AIDS victims --
http://ICCF.nl/click1.html ///