0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

updated for version 7.0058

This commit is contained in:
Bram Moolenaar
2005-03-08 22:34:32 +00:00
parent 95fb60ac58
commit 9be038da7d

View File

@@ -3317,7 +3317,7 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit,
/* Open with O_EXCL to avoid the file being created while /* Open with O_EXCL to avoid the file being created while
* we were sleeping (symlink hacker attack?) */ * we were sleeping (symlink hacker attack?) */
bfd = mch_open((char *)backup, bfd = mch_open((char *)backup,
O_WRONLY|O_CREAT|O_EXTRA|O_EXCL, 0666); O_WRONLY|O_CREAT|O_EXTRA|O_EXCL, perm & 0777);
if (bfd < 0) if (bfd < 0)
{ {
vim_free(backup); vim_free(backup);
@@ -3701,7 +3701,7 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit,
while ((fd = mch_open((char *)wfname, O_WRONLY | O_EXTRA | (append while ((fd = mch_open((char *)wfname, O_WRONLY | O_EXTRA | (append
? (forceit ? (O_APPEND | O_CREAT) : O_APPEND) ? (forceit ? (O_APPEND | O_CREAT) : O_APPEND)
: (O_CREAT | O_TRUNC)) : (O_CREAT | O_TRUNC))
, 0666)) < 0) , perm & 0777)) < 0)
{ {
/* /*
* A forced write will try to create a new file if the old one is * A forced write will try to create a new file if the old one is
@@ -4108,7 +4108,8 @@ restore_backup:
if ((fd = mch_open((char *)backup, O_RDONLY | O_EXTRA, 0)) >= 0) if ((fd = mch_open((char *)backup, O_RDONLY | O_EXTRA, 0)) >= 0)
{ {
if ((write_info.bw_fd = mch_open((char *)fname, if ((write_info.bw_fd = mch_open((char *)fname,
O_WRONLY | O_CREAT | O_TRUNC | O_EXTRA, 0666)) >= 0) O_WRONLY | O_CREAT | O_TRUNC | O_EXTRA,
perm & 0777)) >= 0)
{ {
/* copy the file. */ /* copy the file. */
write_info.bw_buf = smallbuf; write_info.bw_buf = smallbuf;
@@ -4268,7 +4269,7 @@ restore_backup:
if (org == NULL if (org == NULL
|| (empty_fd = mch_open(org, O_CREAT | O_EXTRA | O_EXCL, || (empty_fd = mch_open(org, O_CREAT | O_EXTRA | O_EXCL,
0666)) < 0) perm & 0777)) < 0)
EMSG(_("E206: patchmode: can't touch empty original file")); EMSG(_("E206: patchmode: can't touch empty original file"));
else else
close(empty_fd); close(empty_fd);
@@ -5673,6 +5674,7 @@ vim_rename(from, to)
BPTR flock; BPTR flock;
#endif #endif
struct stat st; struct stat st;
long perm;
/* /*
* When the names are identical, there is nothing to do. * When the names are identical, there is nothing to do.
@@ -5723,10 +5725,13 @@ vim_rename(from, to)
/* /*
* Rename() failed, try copying the file. * Rename() failed, try copying the file.
*/ */
perm = mch_getperm(from);
fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0); fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
if (fd_in == -1) if (fd_in == -1)
return -1; return -1;
fd_out = mch_open((char *)to, O_CREAT|O_EXCL|O_WRONLY|O_EXTRA, 0666);
/* Create the new file with same permissions as the original. */
fd_out = mch_open((char *)to, O_CREAT|O_EXCL|O_WRONLY|O_EXTRA, (int)perm);
if (fd_out == -1) if (fd_out == -1)
{ {
close(fd_in); close(fd_in);
@@ -5757,6 +5762,7 @@ vim_rename(from, to)
errmsg = _("E210: Error reading \"%s\""); errmsg = _("E210: Error reading \"%s\"");
to = from; to = from;
} }
mch_setperm(to, perm);
if (errmsg != NULL) if (errmsg != NULL)
{ {
EMSG2(errmsg, to); EMSG2(errmsg, to);