diff --git a/src/autoload.rs b/src/autoload.rs index c02e3d7bf..9f6b3d38b 100644 --- a/src/autoload.rs +++ b/src/autoload.rs @@ -341,7 +341,7 @@ fn touch_file(path: &wstr) { let fd = wopen_cloexec( path, OFlag::O_RDWR | OFlag::O_CREAT, - Mode::from_bits(0o666).unwrap(), + Mode::from_bits_truncate(0o666), ) .unwrap(); write_loop(&fd, "Hello".as_bytes()).unwrap(); diff --git a/src/env_universal_common.rs b/src/env_universal_common.rs index 8e809625b..45762420d 100644 --- a/src/env_universal_common.rs +++ b/src/env_universal_common.rs @@ -441,11 +441,7 @@ fn open_and_acquire_lock(&mut self) -> Option { let mut res_fd = None; while res_fd.is_none() { - let fd = match wopen_cloexec( - &self.vars_path, - flags, - Mode::S_IRUSR | Mode::S_IWUSR | Mode::S_IRGRP | Mode::S_IROTH, - ) { + let fd = match wopen_cloexec(&self.vars_path, flags, Mode::from_bits_truncate(0o644)) { Ok(fd) => fd, Err(err) => { if err == nix::Error::EINTR { diff --git a/src/history.rs b/src/history.rs index 06ed7d0fe..1f9ed693d 100644 --- a/src/history.rs +++ b/src/history.rs @@ -128,7 +128,7 @@ pub enum SearchDirection { const HISTORY_OUTPUT_BUFFER_SIZE: usize = 64 * 1024; /// The file access mode we use for creating history files -const HISTORY_FILE_MODE: Mode = Mode::S_IRUSR.union(Mode::S_IWUSR); +const HISTORY_FILE_MODE: Mode = Mode::from_bits_truncate(0o600); /// How many times we retry to save /// Saving may fail if the file is modified in between our opening diff --git a/src/io.rs b/src/io.rs index 53fc7ebf5..b8f4d0dc6 100644 --- a/src/io.rs +++ b/src/io.rs @@ -1007,7 +1007,7 @@ pub fn out_is_terminal(&self) -> bool { const NOCLOB_ERROR: &wstr = L!("The file '%ls' already exists"); /// Base open mode to pass to calls to open. -const OPEN_MASK: Mode = unsafe { Mode::from_bits_unchecked(0o666) }; +const OPEN_MASK: Mode = Mode::from_bits_truncate(0o666); /// Provide the fd monitor used for background fillthread operations. fn fd_monitor() -> &'static mut FdMonitor {