diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a251776..4dfc5703 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -121,9 +121,6 @@ jobs: - env: RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom" run: cargo build --target=${{ matrix.target }} --features=std - - env: - RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix" - run: cargo build --target=${{ matrix.target }} --features=std - env: RUSTFLAGS: -Dwarnings --cfg getrandom_test_linux_fallback run: cargo build --features=std diff --git a/.github/workflows/nopanic.yaml b/.github/workflows/nopanic.yaml index f9821a1d..5b5734a0 100644 --- a/.github/workflows/nopanic.yaml +++ b/.github/workflows/nopanic.yaml @@ -49,13 +49,6 @@ jobs: - name: Check (linux_android.rs) run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so )) - - name: Build (linux_rustix.rs) - env: - RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix" - run: cargo build --release - - name: Check (linux_rustix.rs) - run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so )) - - name: Build (rdrand.rs) env: RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rdrand" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 673fd370..2be4cf9a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,9 +56,6 @@ jobs: - env: RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom" run: cargo test --target=${{ matrix.target }} --features=std - - env: - RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix" - run: cargo test --target=${{ matrix.target }} --features=std - env: RUSTFLAGS: -Dwarnings --cfg getrandom_test_linux_fallback run: cargo test --features=std diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index 7f62034a..f57b91c4 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -57,10 +57,6 @@ jobs: env: RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom" run: cargo clippy --target x86_64-unknown-linux-gnu - - name: Linux (linux_rustix.rs) - env: - RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix" - run: cargo clippy --target x86_64-unknown-linux-gnu - name: Linux (linux_android_with_fallback.rs) run: cargo clippy --target x86_64-unknown-linux-gnu - name: NetBSD (netbsd.rs) diff --git a/CHANGELOG.md b/CHANGELOG.md index afdefce2..c3765a23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `getrandom_backend` configuration flag for selection of opt-in backends [#504] - `Error::new_custom` method [#507] - `rndr` opt-in backend [#512] -- `linux_rustix` opt-in backend [#520] - Automatic MemorySanitizer support [#521] [#571] - `u32` and `u64` functions for generating random values of the respective type [#544] @@ -52,7 +51,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#504]: https://github.com/rust-random/getrandom/pull/504 [#507]: https://github.com/rust-random/getrandom/pull/507 [#512]: https://github.com/rust-random/getrandom/pull/512 -[#520]: https://github.com/rust-random/getrandom/pull/520 [#521]: https://github.com/rust-random/getrandom/pull/521 [#522]: https://github.com/rust-random/getrandom/pull/522 [#532]: https://github.com/rust-random/getrandom/pull/532 diff --git a/Cargo.toml b/Cargo.toml index 57fe2274..8fca0bf0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,13 +19,9 @@ compiler_builtins = { version = "0.1", optional = true } core = { version = "1.0", optional = true, package = "rustc-std-workspace-core" } # linux_android / linux_android_with_fallback -[target.'cfg(all(any(target_os = "linux", target_os = "android"), not(any(target_env = "", getrandom_backend = "linux_rustix", getrandom_backend = "custom"))))'.dependencies] +[target.'cfg(all(any(target_os = "linux", target_os = "android"), not(any(target_env = "", getrandom_backend = "custom"))))'.dependencies] libc = { version = "0.2.154", default-features = false } -# linux_rustix -[target.'cfg(all(any(target_os = "linux", target_os = "android"), any(target_env = "", getrandom_backend = "linux_rustix")))'.dependencies] -rustix = { version = "0.38.38", default-features = false, features = ["rand"] } - # apple-other [target.'cfg(any(target_os = "ios", target_os = "visionos", target_os = "watchos", target_os = "tvos"))'.dependencies] libc = { version = "0.2.154", default-features = false } @@ -80,7 +76,7 @@ rustc-dep-of-std = ["dep:compiler_builtins", "dep:core"] [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(getrandom_backend, values("custom", "rdrand", "rndr", "linux_getrandom", "linux_rustix", "wasm_js", "esp_idf"))', + 'cfg(getrandom_backend, values("custom", "rdrand", "rndr", "linux_getrandom", "wasm_js", "esp_idf"))', 'cfg(getrandom_msan)', 'cfg(getrandom_test_linux_fallback)', 'cfg(getrandom_test_netbsd_fallback)', diff --git a/README.md b/README.md index 7ece9ecf..7889e766 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,6 @@ of randomness based on their specific needs: | Backend name | Target | Target Triple | Implementation | ----------------- | -------------------- | ------------------------ | -------------- | `linux_getrandom` | Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call (without `/dev/urandom` fallback). Bumps minimum supported Linux kernel version to 3.17 and Android API level to 23 (Marshmallow). -| `linux_rustix` | Linux, Android | `*‑linux‑*` | Same as `linux_getrandom`, but uses [`rustix`] instead of `libc`. | `rdrand` | x86, x86-64 | `x86_64-*`, `i686-*` | [`RDRAND`] instruction | `rndr` | AArch64 | `aarch64-*` | [`RNDR`] register | `esp_idf` | ESP-IDF | `*‑espidf` | [`esp_fill_random`]. WARNING: can return low-quality entropy without proper hardware configuration! @@ -346,7 +345,6 @@ dual licensed as above, without any additional terms or conditions. [platform-support]: https://doc.rust-lang.org/stable/rustc/platform-support.html [WASI]: https://github.com/CraneStation/wasi [Emscripten]: https://www.hellorust.com/setup/emscripten/ -[`rustix`]: https://docs.rs/rustix [//]: # (licenses) diff --git a/src/backends.rs b/src/backends.rs index f7b720f5..900911fb 100644 --- a/src/backends.rs +++ b/src/backends.rs @@ -13,9 +13,6 @@ cfg_if! { } else if #[cfg(getrandom_backend = "linux_getrandom")] { mod linux_android; pub use linux_android::*; - } else if #[cfg(getrandom_backend = "linux_rustix")] { - mod linux_rustix; - pub use linux_rustix::*; } else if #[cfg(getrandom_backend = "rdrand")] { mod rdrand; pub use rdrand::*; diff --git a/src/backends/linux_rustix.rs b/src/backends/linux_rustix.rs deleted file mode 100644 index d3bcce3e..00000000 --- a/src/backends/linux_rustix.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! Implementation for Linux / Android without `/dev/urandom` fallback -use crate::{Error, MaybeUninit}; -use rustix::rand::{getrandom_uninit, GetRandomFlags}; - -pub use crate::util::{inner_u32, inner_u64}; - -#[cfg(not(any(target_os = "android", target_os = "linux")))] -compile_error!("`linux_rustix` backend can be enabled only for Linux/Android targets!"); - -pub fn fill_inner(mut dest: &mut [MaybeUninit]) -> Result<(), Error> { - loop { - let res = getrandom_uninit(dest, GetRandomFlags::empty()).map(|(res, _)| res.len()); - match res { - Ok(0) => return Err(Error::UNEXPECTED), - Ok(res_len) => { - dest = dest.get_mut(res_len..).ok_or(Error::UNEXPECTED)?; - if dest.is_empty() { - return Ok(()); - } - } - Err(rustix::io::Errno::INTR) => continue, - Err(err) => { - let code = err - .raw_os_error() - .wrapping_neg() - .try_into() - .map_err(|_| Error::UNEXPECTED)?; - return Err(Error::from_os_error(code)); - } - } - } -}