Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,7 @@ jobs:
export RUST_BACKTRACE=1
export CARGO_TERM_COLOR=always
if (test -z "\$FAULT"); then cargo nextest run --hide-progress-bar --profile ci --features '${{ matrix.job.features }}' || FAULT=1 ; fi
# There is no systemd-logind on FreeBSD, so test all features except feat_systemd_logind ( https://github.com/rust-lang/cargo/issues/3126#issuecomment-2523441905 )
if (test -z "\$FAULT"); then
UUCORE_FEATURES=\$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "uucore") | .features | keys | .[]' | grep -v "feat_systemd_logind" | paste -s -d "," -)
cargo nextest run --hide-progress-bar --profile ci --features "\$UUCORE_FEATURES" -p uucore || FAULT=1
fi
if (test -z "\$FAULT"); then cargo nextest run --hide-progress-bar --profile ci --all-features -p uucore || FAULT=1 ; fi
# Test building with make
if (test -z "\$FAULT"); then make || FAULT=1 ; fi
# Clean to avoid to rsync back the files
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/openbsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,9 @@ jobs:
cargo test --features '${{ matrix.job.features }}' || FAULT=1
echo "::endgroup::"
fi
# There is no systemd-logind on OpenBSD, so test all features except feat_systemd_logind
if (test -z "\$FAULT"); then
echo "::group::cargo test (uucore)"
UUCORE_FEATURES=\$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "uucore") | .features | keys | .[]' | grep -v "feat_systemd_logind" | paste -s -d "," -)
cargo test --features "\$UUCORE_FEATURES" -p uucore || FAULT=1
cargo test --all-features -p uucore || FAULT=1
echo "::endgroup::"
fi
# Test building with make
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,13 @@ feat_diagnostics = ["uucore/diagnostics"]
## Optional feature for stdbuf
# "feat_external_libstdbuf" == use an external libstdbuf.so for stdbuf instead of embedding it
feat_external_libstdbuf = ["stdbuf/feat_external_libstdbuf"]
# "feat_systemd_logind" == enable feat_systemd_logind support for utmpx replacement
# "feat_systemd_logind" == enable systemd_logind support for utmpx replacement
feat_systemd_logind = [
"pinky/feat_systemd_logind",
"uptime/feat_systemd_logind",
"users/feat_systemd_logind",
"uucore/feat_systemd_logind",
"who/feat_systemd_logind",
"pinky/systemd_logind",
"uptime/systemd_logind",
"users/systemd_logind",
"uucore/systemd_logind",
"who/systemd_logind",
]
# "feat_selinux" == enable support for SELinux Security Context (by using `--features feat_selinux`)
# NOTE:
Expand Down
2 changes: 1 addition & 1 deletion src/uu/pinky/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fluent = { workspace = true }
uucore = { workspace = true, features = ["utmpx", "entries"] }

[features]
feat_systemd_logind = ["uucore/feat_systemd_logind"]
systemd_logind = ["uucore/systemd_logind"]

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/uu/uptime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ thiserror = { workspace = true }
uucore = { workspace = true, features = ["libc", "utmpx", "uptime"] }

[features]
feat_systemd_logind = ["uucore/feat_systemd_logind"]
systemd_logind = ["uucore/systemd_logind"]

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/uu/users/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ uucore = { workspace = true, features = [] }
utmp-classic = { workspace = true }

[features]
feat_systemd_logind = ["uucore/feat_systemd_logind"]
systemd_logind = ["uucore/systemd_logind"]

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/uu/who/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ rustix = { workspace = true, features = ["fs", "termios"] }
uucore = { workspace = true, features = ["utmpx"] }

[features]
feat_systemd_logind = ["uucore/feat_systemd_logind"]
systemd_logind = ["uucore/systemd_logind"]

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/uucore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ fsext = ["libc", "windows-sys", "bstr", "wide"]
fsxattr = ["xattr", "itertools", "libc"]
hardware = []
lines = []
feat_systemd_logind = ["utmpx", "libc"]
format = [
"bigdecimal",
"extendedbigdecimal",
Expand Down Expand Up @@ -219,6 +218,7 @@ sum = [
"crc-fast",
"data-encoding",
]
systemd_logind = ["utmpx", "libc"]
Comment thread
xtqqczze marked this conversation as resolved.
# Use OpenSSL (libcrypto) for md5/sha1/sha2-family digests instead of the
# pure-Rust crates. This dramatically speeds up checksum utilities on CPUs
# without SHA-NI by using OpenSSL's optimized assembly implementations.
Expand Down
2 changes: 1 addition & 1 deletion src/uucore/src/lib/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub mod selinux;
pub mod signals;
#[cfg(all(feature = "smack", target_os = "linux"))]
pub mod smack;
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
pub mod systemd_logind;
#[cfg(all(
feature = "utmpx",
Expand Down
38 changes: 19 additions & 19 deletions src/uucore/src/lib/features/utmpx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use std::path::Path;
use std::ptr;
use std::sync::{Mutex, MutexGuard};

#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
use crate::features::systemd_logind;

pub use self::ut::*;
Expand Down Expand Up @@ -328,13 +328,13 @@ impl Utmpx {
/// Only one instance of [`UtmpxIter`] may be active at a time. This
/// function will block as long as one is still active. Beware!
pub fn iter_all_records() -> UtmpxIter {
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
{
// Use systemd-logind instead of traditional utmp when feature is enabled
UtmpxIter::new_systemd()
}

#[cfg(not(feature = "feat_systemd_logind"))]
#[cfg(not(all(feature = "systemd_logind", target_os = "linux")))]
{
let iter = UtmpxIter::new();
unsafe {
Expand All @@ -360,7 +360,7 @@ impl Utmpx {
///
/// The same caveats as for [`Utmpx::iter_all_records`] apply.
pub fn iter_all_records_from<P: AsRef<Path>>(path: P) -> UtmpxIter {
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
{
// Use systemd-logind for default utmp file when feature is enabled
if path.as_ref() == Path::new(DEFAULT_FILE) {
Expand Down Expand Up @@ -409,7 +409,7 @@ pub struct UtmpxIter {
/// Ensure UtmpxIter is !Send. Technically redundant because MutexGuard
/// is also !Send.
phantom: PhantomData<std::rc::Rc<()>>,
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
systemd_iter: Option<systemd_logind::SystemdUtmpxIter>,
}

Expand All @@ -422,12 +422,12 @@ impl UtmpxIter {
Self {
guard,
phantom: PhantomData,
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
systemd_iter: None,
}
}

#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
fn new_systemd() -> Self {
// PoisonErrors can safely be ignored
let guard = LOCK
Expand All @@ -452,7 +452,7 @@ impl UtmpxIter {
/// Wrapper type that can hold either traditional utmpx records or systemd records
pub enum UtmpxRecord {
Traditional(Box<Utmpx>),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Systemd(systemd_logind::SystemdUtmpxCompat),
}

Expand All @@ -461,7 +461,7 @@ impl UtmpxRecord {
pub fn record_type(&self) -> i16 {
match self {
Self::Traditional(utmpx) => utmpx.record_type(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => systemd.record_type(),
}
}
Expand All @@ -470,7 +470,7 @@ impl UtmpxRecord {
pub fn pid(&self) -> i32 {
match self {
Self::Traditional(utmpx) => utmpx.pid(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => systemd.pid(),
}
}
Expand All @@ -479,7 +479,7 @@ impl UtmpxRecord {
pub fn terminal_suffix(&self) -> String {
match self {
Self::Traditional(utmpx) => utmpx.terminal_suffix(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => systemd.terminal_suffix(),
}
}
Expand All @@ -488,7 +488,7 @@ impl UtmpxRecord {
pub fn user(&self) -> String {
match self {
Self::Traditional(utmpx) => utmpx.user(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => systemd.user(),
}
}
Expand All @@ -497,7 +497,7 @@ impl UtmpxRecord {
pub fn host(&self) -> String {
match self {
Self::Traditional(utmpx) => utmpx.host(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => systemd.host(),
}
}
Expand All @@ -506,7 +506,7 @@ impl UtmpxRecord {
pub fn tty_device(&self) -> String {
match self {
Self::Traditional(utmpx) => utmpx.tty_device(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => systemd.tty_device(),
}
}
Expand All @@ -515,7 +515,7 @@ impl UtmpxRecord {
pub fn login_time(&self) -> time::OffsetDateTime {
match self {
Self::Traditional(utmpx) => utmpx.login_time(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => systemd.login_time(),
}
}
Expand All @@ -526,7 +526,7 @@ impl UtmpxRecord {
pub fn exit_status(&self) -> (i16, i16) {
match self {
Self::Traditional(utmpx) => utmpx.exit_status(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => systemd.exit_status(),
}
}
Expand All @@ -535,7 +535,7 @@ impl UtmpxRecord {
pub fn is_user_process(&self) -> bool {
match self {
Self::Traditional(utmpx) => utmpx.is_user_process(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => systemd.is_user_process(),
}
}
Expand All @@ -544,7 +544,7 @@ impl UtmpxRecord {
pub fn canon_host(&self) -> IOResult<String> {
match self {
Self::Traditional(utmpx) => utmpx.canon_host(),
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Systemd(systemd) => Ok(systemd.canon_host()),
}
}
Expand All @@ -553,7 +553,7 @@ impl UtmpxRecord {
impl Iterator for UtmpxIter {
type Item = UtmpxRecord;
fn next(&mut self) -> Option<Self::Item> {
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
{
if let Some(ref mut systemd_iter) = self.systemd_iter {
// We have a systemd iterator - use it exclusively (never fall back to traditional utmp)
Expand Down
2 changes: 1 addition & 1 deletion src/uucore/src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub use crate::features::ranges;
pub use crate::features::ringbuffer;
#[cfg(feature = "sum")]
pub use crate::features::sum;
#[cfg(feature = "feat_systemd_logind")]
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
pub use crate::features::systemd_logind;
#[cfg(feature = "time")]
pub use crate::features::time;
Expand Down
Loading