From f0440ae85fbc1da623091da814078254f8d3575e Mon Sep 17 00:00:00 2001 From: Etienne Cordonnier Date: Sat, 15 Mar 2025 23:02:39 +0100 Subject: [PATCH] enable utmpx feature for musl bump libc to 0.2.172 musl provides stubs of utmpx functions, and those stubs are available in the libc crate version 0.2.172. Thus let's enable the feature so that it can compile with musl. Note that those stubs always return a success exit value, and commands such as "users" will report an empty list of users, when calling those stubs. This is consistent with the behavior of GNU coreutils which does the same thing. The coreutils utillities using utmpx are "pinky", "uptime", "users", "who". This is the expected behavior when using those utilities compiled with those musl utmpx stubs: ``` root@qemuarm64:~# users root@qemuarm64:~# echo $? 0 root@qemuarm64:~# pinky Login Name TTY Idle When Where root@qemuarm64:~# echo $? 0 root@qemuarm64:~# uptime 12:58:47 up 0 min, 0 users, load average: 0.07, 0.02, 0.00 root@qemuarm64:~# echo $? 0 root@qemuarm64:~# who root@qemuarm64:~# echo $? 0 ``` Closes #1361 Signed-off-by: Etienne Cordonnier --- Cargo.toml | 3 ++- src/uucore/src/lib/features.rs | 1 - src/uucore/src/lib/lib.rs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 05dc4ed7d..539ba2c8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -178,6 +178,7 @@ feat_os_unix_musl = [ "feat_require_crate_cpp", "feat_require_unix", "feat_require_unix_hostid", + "feat_require_unix_utmpx", ] feat_os_unix_android = [ "feat_Tier1", @@ -308,7 +309,7 @@ hostname = "0.4" iana-time-zone = "0.1.57" indicatif = "0.17.8" itertools = "0.14.0" -libc = "0.2.153" +libc = "0.2.172" linux-raw-sys = "0.9" lscolors = { version = "0.20.0", default-features = false, features = [ "gnu_legacy", diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index b19387c69..3f0649c0c 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -76,7 +76,6 @@ pub mod signals; not(target_os = "fuchsia"), not(target_os = "openbsd"), not(target_os = "redox"), - not(target_env = "musl"), feature = "utmpx" ))] pub mod utmpx; diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index bc4281979..0762240ed 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -89,7 +89,6 @@ pub use crate::features::signals; not(target_os = "fuchsia"), not(target_os = "openbsd"), not(target_os = "redox"), - not(target_env = "musl"), feature = "utmpx" ))] pub use crate::features::utmpx;