mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 01:08:20 +00:00
fileio: set group of backup file
Restores code removed in #9709. uv_fs_copyfile() copies the perm bits but not the group name. https://github.com/libuv/libuv/pull/1547 ref #9709 ref #8288
This commit is contained in:
@@ -2868,6 +2868,23 @@ buf_write (
|
||||
/* remove old backup, if present */
|
||||
os_remove((char *)backup);
|
||||
|
||||
// set file protection same as original file, but
|
||||
// strip s-bit.
|
||||
(void)os_setperm((const char *)backup, perm & 0777);
|
||||
|
||||
#ifdef UNIX
|
||||
//
|
||||
// Try to set the group of the backup same as the original file. If
|
||||
// this fails, set the protection bits for the group same as the
|
||||
// protection bits for others.
|
||||
//
|
||||
if (file_info_new.stat.st_gid != file_info_old.stat.st_gid
|
||||
&& os_chown((char *)backup, -1, file_info_old.stat.st_gid) != 0) {
|
||||
os_setperm((const char *)backup,
|
||||
(perm & 0707) | ((perm & 07) << 3));
|
||||
}
|
||||
#endif
|
||||
|
||||
// copy the file
|
||||
if (os_copy((char *)fname, (char *)backup, UV_FS_COPYFILE_FICLONE)
|
||||
!= 0) {
|
||||
|
Reference in New Issue
Block a user