From 32bd60eb7d7c81e043ed2738f210a75533a0d96a Mon Sep 17 00:00:00 2001 From: viyatb-oai Date: Mon, 8 Jun 2026 17:03:40 -0700 Subject: [PATCH] refactor: simplify no-follow write helper Co-authored-by: Codex --- codex-rs/utils/path-utils/src/lib.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/codex-rs/utils/path-utils/src/lib.rs b/codex-rs/utils/path-utils/src/lib.rs index 0d6af71936..f6ba20f0e4 100644 --- a/codex-rs/utils/path-utils/src/lib.rs +++ b/codex-rs/utils/path-utils/src/lib.rs @@ -150,15 +150,6 @@ pub fn write_atomically(write_path: &Path, contents: &str) -> io::Result<()> { /// `0o666`, subject to the process umask. #[cfg(unix)] pub fn open_file_for_write_no_follow(path: &Path) -> io::Result { - open_file_no_follow( - path, - libc::O_WRONLY | libc::O_CREAT | libc::O_TRUNC, - /*mode*/ 0o666, - ) -} - -#[cfg(unix)] -fn open_file_no_follow(path: &Path, flags: libc::c_int, mode: libc::mode_t) -> io::Result { let components = path .components() .filter_map(|component| match component { @@ -194,8 +185,8 @@ fn open_file_no_follow(path: &Path, flags: libc::c_int, mode: libc::mode_t) -> i openat( ¤t_dir, file_name, - flags | libc::O_CLOEXEC | libc::O_NOFOLLOW, - mode, + libc::O_WRONLY | libc::O_CREAT | libc::O_TRUNC | libc::O_CLOEXEC | libc::O_NOFOLLOW, + /*mode*/ 0o666, ) }