mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(backup): E1509 when writing extended attr to symlink (#28014)
Problem: E1509 when writing extended attributes to a symlink. Solution: Copy the file before copying extended attributes. On Fedora, the attribute being set is "security.selinux". For normal, non-symlink files this attribute doesn't show up and that's why calling os_copy_xattr() doesn't break in that case.
This commit is contained in:
parent
665d5d3969
commit
02d00cf3ee
@ -900,6 +900,14 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o
|
|||||||
// remove old backup, if present
|
// remove old backup, if present
|
||||||
os_remove(*backupp);
|
os_remove(*backupp);
|
||||||
|
|
||||||
|
// copy the file
|
||||||
|
if (os_copy(fname, *backupp, UV_FS_COPYFILE_FICLONE) != 0) {
|
||||||
|
*err = set_err(_("E509: Cannot create backup file (add ! to override)"));
|
||||||
|
XFREE_CLEAR(*backupp);
|
||||||
|
*backupp = NULL;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// set file protection same as original file, but
|
// set file protection same as original file, but
|
||||||
// strip s-bit.
|
// strip s-bit.
|
||||||
os_setperm(*backupp, perm & 0777);
|
os_setperm(*backupp, perm & 0777);
|
||||||
@ -914,20 +922,11 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o
|
|||||||
&& os_chown(*backupp, (uv_uid_t)-1, (uv_gid_t)file_info_old->stat.st_gid) != 0) {
|
&& os_chown(*backupp, (uv_uid_t)-1, (uv_gid_t)file_info_old->stat.st_gid) != 0) {
|
||||||
os_setperm(*backupp, (perm & 0707) | ((perm & 07) << 3));
|
os_setperm(*backupp, (perm & 0707) | ((perm & 07) << 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef HAVE_XATTR
|
# ifdef HAVE_XATTR
|
||||||
os_copy_xattr(fname, *backupp);
|
os_copy_xattr(fname, *backupp);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
|
||||||
|
|
||||||
// copy the file
|
|
||||||
if (os_copy(fname, *backupp, UV_FS_COPYFILE_FICLONE) != 0) {
|
|
||||||
*err = set_err(_("E509: Cannot create backup file (add ! to override)"));
|
|
||||||
XFREE_CLEAR(*backupp);
|
|
||||||
*backupp = NULL;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef UNIX
|
|
||||||
os_file_settime(*backupp,
|
os_file_settime(*backupp,
|
||||||
(double)file_info_old->stat.st_atim.tv_sec,
|
(double)file_info_old->stat.st_atim.tv_sec,
|
||||||
(double)file_info_old->stat.st_mtim.tv_sec);
|
(double)file_info_old->stat.st_mtim.tv_sec);
|
||||||
|
Loading…
Reference in New Issue
Block a user