mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-11 13:51:16 -03:00
committed by
Johannes Altmanninger
parent
448471bd50
commit
d414967b79
@@ -9,7 +9,7 @@
|
||||
},
|
||||
};
|
||||
use errno::errno;
|
||||
use libc::{LOCK_EX, LOCK_SH, c_int, fchown, flock};
|
||||
use libc::{LOCK_EX, LOCK_SH, c_int, flock};
|
||||
use nix::{fcntl::OFlag, sys::stat::Mode};
|
||||
use std::{
|
||||
ffi::CString,
|
||||
@@ -314,12 +314,11 @@ fn update_metadata(old_file: &File, new_file: &File) {
|
||||
// did, it would be tricky to set the permissions correctly. (bash doesn't get this
|
||||
// case right either).
|
||||
if let Ok(md) = old_file.metadata() {
|
||||
// TODO(MSRV): Consider replacing with std::os::unix::fs::fchown when MSRV >= 1.73
|
||||
if unsafe { fchown(new_file.as_raw_fd(), md.uid(), md.gid()) } == -1 {
|
||||
if let Err(e) = std::os::unix::fs::fchown(new_file, Some(md.uid()), Some(md.gid())) {
|
||||
FLOG!(
|
||||
synced_file_access,
|
||||
"Error when changing ownership of file:",
|
||||
errno::errno()
|
||||
e
|
||||
);
|
||||
}
|
||||
if let Err(e) = new_file.set_permissions(md.permissions()) {
|
||||
|
||||
Reference in New Issue
Block a user