From e591b5f2ccad17ac17e40d7856a59b876ad67b4e Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Fri, 14 Jun 2024 22:20:11 -0700 Subject: [PATCH] illumos support (#2838) * disable mimalloc on illumos, in part because it immediately segfaults, but also because we prefer libumem and link it into all Rust binaries * switch from fs2 (unmaintained crate) to fs4 which provides the same interface and has wider platform support --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- libs/file_permissions/src/unix.rs | 3 +++ server/daemon/Cargo.toml | 6 ++++-- server/daemon/src/main.rs | 4 ++-- server/lib/Cargo.toml | 4 +++- server/lib/src/lib.rs | 2 +- tools/orca/Cargo.toml | 4 +++- tools/orca/src/main.rs | 2 +- unix_integration/Cargo.toml | 4 +++- unix_integration/src/daemon.rs | 1 + 11 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c81644ed7..0fb5156ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1169,7 +1169,7 @@ dependencies = [ "clap", "clap_complete", "dhat", - "fs2", + "fs4", "futures", "kanidm_build_profiles", "kanidm_lib_file_permissions", @@ -1715,13 +1715,13 @@ dependencies = [ ] [[package]] -name = "fs2" -version = "0.4.3" +name = "fs4" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +checksum = "f7e180ac76c23b45e767bd7ae9579bc0bb458618c4bc71835926e098e61d15f8" dependencies = [ - "libc", - "winapi", + "rustix", + "windows-sys 0.52.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 720035aec..5d6f8b01b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -173,7 +173,7 @@ dhat = "0.3.3" dyn-clone = "^1.0.17" fernet = "^0.2.1" filetime = "^0.2.23" -fs2 = "^0.4.3" +fs4 = "^0.8.3" futures = "^0.3.30" futures-concurrency = "^3.1.0" futures-util = { version = "^0.3.30", features = ["sink"] } diff --git a/libs/file_permissions/src/unix.rs b/libs/file_permissions/src/unix.rs index d5b18d455..0253ed05a 100644 --- a/libs/file_permissions/src/unix.rs +++ b/libs/file_permissions/src/unix.rs @@ -6,6 +6,9 @@ use std::os::linux::fs::MetadataExt; #[cfg(target_os = "macos")] use std::os::macos::fs::MetadataExt; +#[cfg(target_os = "illumos")] +use std::os::illumos::fs::MetadataExt; + use kanidm_utils_users::{get_current_gid, get_current_uid}; use std::fmt; diff --git a/server/daemon/Cargo.toml b/server/daemon/Cargo.toml index 3f0eac815..07139881c 100644 --- a/server/daemon/Cargo.toml +++ b/server/daemon/Cargo.toml @@ -28,12 +28,11 @@ kanidm_proto = { workspace = true } kanidmd_core = { workspace = true } kanidm_lib_file_permissions = { workspace = true } sketching = { workspace = true } -fs2 = { workspace = true } +fs4 = { workspace = true } futures = { workspace = true } dhat = { workspace = true, optional = true } clap = { workspace = true, features = ["env"] } -mimalloc = { workspace = true } reqwest = { workspace = true } serde = { workspace = true, features = ["derive"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros", "signal"] } @@ -56,6 +55,9 @@ whoami = { workspace = true } [target.'cfg(not(target_family = "windows"))'.dependencies] kanidm_utils_users = { workspace = true } +[target.'cfg(not(target_os = "illumos"))'.dependencies] +mimalloc = { workspace = true } + [build-dependencies] serde = { workspace = true, features = ["derive"] } clap = { workspace = true, features = ["derive"] } diff --git a/server/daemon/src/main.rs b/server/daemon/src/main.rs index 5e5e3ed98..aa22b64a1 100644 --- a/server/daemon/src/main.rs +++ b/server/daemon/src/main.rs @@ -10,7 +10,7 @@ #![deny(clippy::needless_pass_by_value)] #![deny(clippy::trivially_copy_pass_by_ref)] -#[cfg(not(feature = "dhat-heap"))] +#[cfg(not(any(feature = "dhat-heap", target_os = "illumos")))] #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; @@ -20,7 +20,7 @@ static ALLOC: dhat::Alloc = dhat::Alloc; use std::fs::{metadata, File}; // This works on both unix and windows. -use fs2::FileExt; +use fs4::FileExt; use kanidm_proto::messages::ConsoleOutputMode; use sketching::otel::TracingPipelineGuard; use sketching::LogLevel; diff --git a/server/lib/Cargo.toml b/server/lib/Cargo.toml index 683f36850..63e8e2517 100644 --- a/server/lib/Cargo.toml +++ b/server/lib/Cargo.toml @@ -109,9 +109,11 @@ compact_jwt = { workspace = true, features = ["openssl", "hsm-crypto", "unsafe_r criterion = { workspace = true, features = ["html_reports"] } futures = { workspace = true } kanidmd_lib_macros = { workspace = true } -mimalloc = { workspace = true } webauthn-authenticator-rs = { workspace = true } +[target.'cfg(not(target_os = "illumos"))'.dev-dependencies] +mimalloc = { workspace = true } + [build-dependencies] hashbrown = { workspace = true } kanidm_build_profiles = { workspace = true } diff --git a/server/lib/src/lib.rs b/server/lib/src/lib.rs index b4ad43eb3..740b2807c 100644 --- a/server/lib/src/lib.rs +++ b/server/lib/src/lib.rs @@ -21,7 +21,7 @@ #![deny(clippy::manual_let_else)] #![allow(clippy::unreachable)] -#[cfg(all(test, not(feature = "dhat-heap")))] +#[cfg(all(test, not(any(feature = "dhat-heap", target_os = "illumos"))))] #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; diff --git a/tools/orca/Cargo.toml b/tools/orca/Cargo.toml index 31855570e..5b03c974c 100644 --- a/tools/orca/Cargo.toml +++ b/tools/orca/Cargo.toml @@ -28,7 +28,6 @@ hashbrown = { workspace = true } kanidm_client = { workspace = true } kanidm_proto = { workspace = true } mathru = { workspace = true } -mimalloc = { workspace = true } rand = { workspace = true } rand_chacha = { workspace = true } serde = { workspace = true, features = ["derive"] } @@ -39,6 +38,9 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true } uuid = { workspace = true, features = ["serde", "v4" ] } +[target.'cfg(not(any(target_family = "windows", target_os = "illumos")))'.dependencies] +mimalloc = { workspace = true } + [build-dependencies] kanidm_build_profiles = { workspace = true } diff --git a/tools/orca/src/main.rs b/tools/orca/src/main.rs index 9dd3dc1b1..2857aa3e1 100644 --- a/tools/orca/src/main.rs +++ b/tools/orca/src/main.rs @@ -6,7 +6,7 @@ #![deny(clippy::needless_pass_by_value)] #![deny(clippy::trivially_copy_pass_by_ref)] -#[cfg(not(target_family = "windows"))] +#[cfg(not(any(target_family = "windows", target_os = "illumos")))] #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; diff --git a/unix_integration/Cargo.toml b/unix_integration/Cargo.toml index 891b50ca2..701e8e7dd 100644 --- a/unix_integration/Cargo.toml +++ b/unix_integration/Cargo.toml @@ -67,7 +67,6 @@ kanidm_proto = { workspace = true } kanidm-hsm-crypto = { workspace = true } kanidm_lib_crypto = { workspace = true } kanidm_lib_file_permissions = { workspace = true } -mimalloc = { workspace = true } notify-debouncer-full = { workspace = true } rpassword = { workspace = true } rusqlite = { workspace = true } @@ -98,6 +97,9 @@ prctl.workspace = true [target.'cfg(not(target_family = "windows"))'.dependencies] kanidm_utils_users = { workspace = true } +[target.'cfg(not(target_os = "illumos"))'.dependencies] +mimalloc = { workspace = true } + [dev-dependencies] kanidmd_core = { workspace = true } kanidmd_testkit = { workspace = true } diff --git a/unix_integration/src/daemon.rs b/unix_integration/src/daemon.rs index ed3aec748..19f085d45 100644 --- a/unix_integration/src/daemon.rs +++ b/unix_integration/src/daemon.rs @@ -53,6 +53,7 @@ use kanidm_hsm_crypto::{soft::SoftTpm, AuthValue, BoxedDynTpm, Tpm}; use notify_debouncer_full::{new_debouncer, notify::RecursiveMode, notify::Watcher}; +#[cfg(not(target_os = "illumos"))] #[global_allocator] static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;