Skip to content

Commit a39033a

Browse files
authored
Enable /dev/urandom fallback for MUSL-based Linux targets (#408)
1 parent 968dd48 commit a39033a

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.2.14] - 2024-04-08
8+
### Fixed
9+
- Enable `/dev/urandom` fallback for MUSL-based Linux targets [#408]
10+
11+
[#408]: https://github.com/rust-random/getrandom/pull/408
12+
713
## [0.2.13] - 2024-04-06
814
### Added
915
- `linux_disable_fallback` crate feature to disable `/dev/urandom`-based fallback on Linux and
@@ -433,6 +439,7 @@ Publish initial implementation.
433439
## [0.0.0] - 2019-01-19
434440
Publish an empty template library.
435441

442+
[0.2.14]: https://github.com/rust-random/getrandom/compare/v0.2.13...v0.2.14
436443
[0.2.13]: https://github.com/rust-random/getrandom/compare/v0.2.12...v0.2.13
437444
[0.2.12]: https://github.com/rust-random/getrandom/compare/v0.2.11...v0.2.12
438445
[0.2.11]: https://github.com/rust-random/getrandom/compare/v0.2.10...v0.2.11

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "getrandom"
3-
version = "0.2.13" # Also update html_root_url in lib.rs when bumping this
3+
version = "0.2.14" # Also update html_root_url in lib.rs when bumping this
44
edition = "2018"
55
authors = ["The Rand Project Developers"]
66
license = "MIT OR Apache-2.0"

src/lib.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
//!
5050
//! ## `/dev/urandom` fallback on Linux and Android
5151
//!
52-
//! On Linux targets the fallback is present only for the following `target_arch`es:
53-
//! `aarch64`, `arm`, `powerpc`, `powerpc64`, `s390x`, `x86`, `x86_64`. Other supported
54-
//! `target_arch`es [require](https://doc.rust-lang.org/stable/rustc/platform-support.html)
52+
//! On Linux targets the fallback is present only if either `target_env` is `musl`,
53+
//! or `target_arch` is one of the following: `aarch64`, `arm`, `powerpc`, `powerpc64`,
54+
//! `s390x`, `x86`, `x86_64`. Other supported targets [require][platform-support]
5555
//! kernel versions which support `getrandom` system call, so fallback is not needed.
5656
//!
5757
//! On Android targets the fallback is present only for the following `target_arch`es:
@@ -200,11 +200,12 @@
200200
//! [CommonJS modules]: https://nodejs.org/api/modules.html
201201
//! [ES modules]: https://nodejs.org/api/esm.html
202202
//! [`sys_read_entropy`]: https://github.com/hermit-os/kernel/blob/315f58ff5efc81d9bf0618af85a59963ff55f8b1/src/syscalls/entropy.rs#L47-L55
203+
//! [platform-support]: https://doc.rust-lang.org/stable/rustc/platform-support.html
203204
204205
#![doc(
205206
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
206207
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
207-
html_root_url = "https://docs.rs/getrandom/0.2.13"
208+
html_root_url = "https://docs.rs/getrandom/0.2.14"
208209
)]
209210
#![no_std]
210211
#![warn(rust_2018_idioms, unused_lifetimes, missing_docs)]
@@ -270,6 +271,10 @@ cfg_if! {
270271
target_arch = "s390x",
271272
target_arch = "x86",
272273
target_arch = "x86_64",
274+
// Minimum supported Linux kernel version for MUSL targets
275+
// is not specified explicitly (as of Rust 1.77) and they
276+
// are used in practice to target pre-3.17 kernels.
277+
target_env = "musl",
273278
),
274279
)
275280
),

0 commit comments

Comments
 (0)