mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
refactor(mkfifo): remove unsafe libc::mkfifo, use safe rustix::fs::mknodat
This commit is contained in:
Generated
+2
-1
@@ -3772,7 +3772,8 @@ version = "0.8.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"fluent",
|
||||
"nix",
|
||||
"libc",
|
||||
"rustix",
|
||||
"uucore",
|
||||
]
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ uucore = { workspace = true, features = ["fs", "mode"] }
|
||||
fluent = { workspace = true }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
nix = { workspace = true, features = ["fs"] }
|
||||
libc = { workspace = true }
|
||||
rustix = { workspace = true, features = ["fs"] }
|
||||
|
||||
[features]
|
||||
selinux = ["uucore/selinux"]
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
// file that was distributed with this source code.
|
||||
|
||||
use clap::{Arg, ArgAction, Command, value_parser};
|
||||
use nix::sys::stat::Mode;
|
||||
use nix::unistd::mkfifo;
|
||||
use std::fs;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use uucore::display::Quotable;
|
||||
@@ -48,7 +46,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
};
|
||||
|
||||
for f in fifos {
|
||||
if mkfifo(f.as_str(), Mode::from_bits_truncate(0o666)).is_err() {
|
||||
let c_path = std::ffi::CString::new(f.as_str()).unwrap();
|
||||
// SAFETY: c_path is a valid null-terminated C string
|
||||
let ret = unsafe { libc::mkfifo(c_path.as_ptr(), 0o666) };
|
||||
if ret != 0 {
|
||||
show!(USimpleError::new(
|
||||
1,
|
||||
translate!("mkfifo-error-cannot-create-fifo", "path" => f.quote()),
|
||||
|
||||
Reference in New Issue
Block a user