Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: CICD
# spell-checker:ignore (jargon) SHAs deps dequote softprops subshell toolchain fuzzers dedupe devel profdata
# spell-checker:ignore (people) Peltoche rivy dtolnay Anson dawidd
# spell-checker:ignore (shell/tools) binutils choco clippy dmake dpkg esac fakeroot fdesc fdescfs gmake grcov halium lcov libclang libfuse libssl limactl mkdir nextest nocross pacman popd printf pushd redoxer rsync rustc rustfmt rustup shopt sccache utmpdump xargs
# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nofeatures nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils
# spell-checker:ignore (misc) aarch alnum armhf bindir busytest coreutils defconfig DESTDIR gecos getenforce gnueabihf issuecomment maint manpages msys multisize noconfirm nofeatures nullglob onexitbegin onexitend pell runtest Swatinem tempfile testsuite toybox uutils libsystemd

env:
PROJECT_NAME: coreutils
Expand Down Expand Up @@ -425,7 +425,7 @@ jobs:
run: |
## Install dependencies
sudo apt-get update
sudo apt-get install jq libselinux1-dev
sudo apt-get install jq libselinux1-dev libsystemd-dev
- name: "`make install`"
shell: bash
run: |
Expand Down Expand Up @@ -714,9 +714,9 @@ jobs:
esac
case '${{ matrix.job.os }}' in
ubuntu-*)
# selinux headers needed to build tests
# selinux and systemd headers needed to build tests
sudo apt-get -y update
sudo apt-get -y install libselinux1-dev
sudo apt-get -y install libselinux1-dev libsystemd-dev
# pinky is a tool to show logged-in users from utmp, and gecos fields from /etc/passwd.
# In GitHub Action *nix VMs, no accounts log in, even the "runner" account that runs the commands, and "system boot" entry is missing.
# The account also has empty gecos fields.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Code Quality

# spell-checker:ignore (people) reactivecircus Swatinem dtolnay juliangruber pell taplo
# spell-checker:ignore (misc) TERMUX noaudio pkill swiftshader esac sccache pcoreutils shopt subshell dequote
# spell-checker:ignore (misc) TERMUX noaudio pkill swiftshader esac sccache pcoreutils shopt subshell dequote libsystemd

on:
pull_request:
Expand Down Expand Up @@ -110,8 +110,8 @@ jobs:
## Install/setup prerequisites
case '${{ matrix.job.os }}' in
ubuntu-*)
# selinux headers needed to enable all features
sudo apt-get -y install libselinux1-dev
# selinux and systemd headers needed to enable all features
sudo apt-get -y install libselinux1-dev libsystemd-dev
;;
esac
- name: "`cargo clippy` lint testing"
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: FreeBSD

# spell-checker:ignore sshfs usesh vmactions taiki Swatinem esac fdescfs fdesc sccache nextest copyback
# spell-checker:ignore sshfs usesh vmactions taiki Swatinem esac fdescfs fdesc sccache nextest copyback logind

env:
# * style job configuration
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
usesh: true
sync: rsync
copyback: false
prepare: pkg install -y curl gmake sudo
prepare: pkg install -y curl gmake sudo jq
run: |
## Prepare, build, and test
# implementation modelled after ref: <https://github.com/rust-lang/rustup/pull/2783>
Expand Down Expand Up @@ -194,7 +194,11 @@ 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
if (test -z "\$FAULT"); then cargo nextest run --hide-progress-bar --profile ci --all-features -p uucore || 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 -p uucore | 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
# Test building with make
if (test -z "\$FAULT"); then make PROFILE=ci || FAULT=1 ; fi
# Clean to avoid to rsync back the files
Expand Down
10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coreutils (uutils)
# * see the repository LICENSE, README, and CONTRIBUTING files for more information

# spell-checker:ignore (libs) bigdecimal datetime serde bincode gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested
# spell-checker:ignore (libs) bigdecimal datetime serde bincode gethostid kqueue libselinux mangen memmap uuhelp startswith constness expl unnested logind

[package]
name = "coreutils"
Expand Down Expand Up @@ -38,6 +38,14 @@ uudoc = ["zip", "dep:uuhelp_parser"]
## 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 = [
"pinky/feat_systemd_logind",
"uptime/feat_systemd_logind",
"users/feat_systemd_logind",
"uucore/feat_systemd_logind",
"who/feat_systemd_logind",
]
# "feat_acl" == enable support for ACLs (access control lists; by using`--features feat_acl`)
# NOTE:
# * On linux, the posix-acl/acl-sys crate requires `libacl` headers and shared library to be accessible in the C toolchain at compile time.
Expand Down
5 changes: 5 additions & 0 deletions src/uu/pinky/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# spell-checker:ignore logind

[package]
name = "uu_pinky"
description = "pinky ~ (uutils) display user information"
Expand All @@ -14,6 +16,9 @@ readme.workspace = true
[lints]
workspace = true

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

[lib]
path = "src/pinky.rs"

Expand Down
6 changes: 3 additions & 3 deletions src/uu/pinky/src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use uucore::entries::{Locate, Passwd};
use uucore::error::{FromIo, UResult};
use uucore::libc::S_IWGRP;
use uucore::translate;
use uucore::utmpx::{self, Utmpx, time};
use uucore::utmpx::{self, Utmpx, UtmpxRecord, time};

use std::io::BufReader;
use std::io::prelude::*;
Expand Down Expand Up @@ -137,7 +137,7 @@ fn idle_string(when: i64) -> String {
})
}

fn time_string(ut: &Utmpx) -> String {
fn time_string(ut: &UtmpxRecord) -> String {
// "%b %e %H:%M"
let time_format: Vec<time::format_description::FormatItem> =
time::format_description::parse("[month repr:short] [day padding:space] [hour]:[minute]")
Expand All @@ -158,7 +158,7 @@ fn gecos_to_fullname(pw: &Passwd) -> Option<String> {
}

impl Pinky {
fn print_entry(&self, ut: &Utmpx) -> std::io::Result<()> {
fn print_entry(&self, ut: &UtmpxRecord) -> std::io::Result<()> {
let mut pts_path = PathBuf::from("/dev");
pts_path.push(ut.tty_device().as_str());

Expand Down
5 changes: 5 additions & 0 deletions src/uu/uptime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# spell-checker:ignore logind

[package]
name = "uu_uptime"
description = "uptime ~ (uutils) display dynamic system information"
Expand All @@ -14,6 +16,9 @@ readme.workspace = true
[lints]
workspace = true

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

[lib]
path = "src/uptime.rs"

Expand Down
5 changes: 5 additions & 0 deletions src/uu/users/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# spell-checker:ignore logind

[package]
name = "uu_users"
description = "users ~ (uutils) display names of currently logged-in users"
Expand All @@ -14,6 +16,9 @@ readme.workspace = true
[lints]
workspace = true

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

[lib]
path = "src/users.rs"

Expand Down
2 changes: 1 addition & 1 deletion src/uu/users/src/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let filename = maybe_file.unwrap_or(utmpx::DEFAULT_FILE.as_ref());

users = Utmpx::iter_all_records_from(filename)
.filter(Utmpx::is_user_process)
.filter(|ut| ut.is_user_process())
.map(|ut| ut.user())
.collect::<Vec<_>>();
};
Expand Down
6 changes: 6 additions & 0 deletions src/uu/who/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# spell-checker:ignore logind


[package]
name = "uu_who"
description = "who ~ (uutils) display information about currently logged-in users"
Expand All @@ -14,6 +17,9 @@ readme.workspace = true
[lints]
workspace = true

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

[lib]
path = "src/who.rs"

Expand Down
24 changes: 12 additions & 12 deletions src/uu/who/src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use uucore::libc::{S_IWGRP, STDIN_FILENO, ttyname};
use uucore::translate;

use uucore::LocalizedCommand;
use uucore::utmpx::{self, Utmpx, time};
use uucore::utmpx::{self, UtmpxRecord, time};

use std::borrow::Cow;
use std::ffi::CStr;
Expand Down Expand Up @@ -162,7 +162,7 @@ fn idle_string<'a>(when: i64, boottime: i64) -> Cow<'a, str> {
})
}

fn time_string(ut: &Utmpx) -> String {
fn time_string(ut: &UtmpxRecord) -> String {
// "%b %e %H:%M"
let time_format: Vec<time::format_description::FormatItem> =
time::format_description::parse("[month repr:short] [day padding:space] [hour]:[minute]")
Expand Down Expand Up @@ -202,14 +202,14 @@ impl Who {
utmpx::DEFAULT_FILE
};
if self.short_list {
let users = Utmpx::iter_all_records_from(f)
.filter(Utmpx::is_user_process)
let users = utmpx::Utmpx::iter_all_records_from(f)
.filter(|ut| ut.is_user_process())
.map(|ut| ut.user())
.collect::<Vec<_>>();
println!("{}", users.join(" "));
println!("{}", translate!("who-user-count", "count" => users.len()));
} else {
let records = Utmpx::iter_all_records_from(f);
let records = utmpx::Utmpx::iter_all_records_from(f);

if self.include_heading {
self.print_heading();
Expand Down Expand Up @@ -248,7 +248,7 @@ impl Who {
}

#[inline]
fn print_runlevel(&self, ut: &Utmpx) {
fn print_runlevel(&self, ut: &UtmpxRecord) {
let last = (ut.pid() / 256) as u8 as char;
let curr = (ut.pid() % 256) as u8 as char;
let runlevel_line = translate!("who-runlevel", "level" => curr);
Expand All @@ -268,7 +268,7 @@ impl Who {
}

#[inline]
fn print_clockchange(&self, ut: &Utmpx) {
fn print_clockchange(&self, ut: &UtmpxRecord) {
self.print_line(
"",
' ',
Expand All @@ -282,7 +282,7 @@ impl Who {
}

#[inline]
fn print_login(&self, ut: &Utmpx) {
fn print_login(&self, ut: &UtmpxRecord) {
let comment = translate!("who-login-id", "id" => ut.terminal_suffix());
let pidstr = format!("{}", ut.pid());
self.print_line(
Expand All @@ -298,7 +298,7 @@ impl Who {
}

#[inline]
fn print_deadprocs(&self, ut: &Utmpx) {
fn print_deadprocs(&self, ut: &UtmpxRecord) {
let comment = translate!("who-login-id", "id" => ut.terminal_suffix());
let pidstr = format!("{}", ut.pid());
let e = ut.exit_status();
Expand All @@ -316,7 +316,7 @@ impl Who {
}

#[inline]
fn print_initspawn(&self, ut: &Utmpx) {
fn print_initspawn(&self, ut: &UtmpxRecord) {
let comment = translate!("who-login-id", "id" => ut.terminal_suffix());
let pidstr = format!("{}", ut.pid());
self.print_line(
Expand All @@ -332,7 +332,7 @@ impl Who {
}

#[inline]
fn print_boottime(&self, ut: &Utmpx) {
fn print_boottime(&self, ut: &UtmpxRecord) {
self.print_line(
"",
' ',
Expand All @@ -345,7 +345,7 @@ impl Who {
);
}

fn print_user(&self, ut: &Utmpx) -> UResult<()> {
fn print_user(&self, ut: &UtmpxRecord) -> UResult<()> {
let mut p = PathBuf::from("/dev");
p.push(ut.tty_device().as_str());
let mesg;
Expand Down
3 changes: 2 additions & 1 deletion src/uucore/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# spell-checker:ignore (features) bigdecimal zerocopy extendedbigdecimal tzdb zoneinfo
# spell-checker:ignore (features) bigdecimal zerocopy extendedbigdecimal tzdb zoneinfo logind

[package]
name = "uucore"
Expand Down Expand Up @@ -113,6 +113,7 @@ fs = ["dunce", "libc", "winapi-util", "windows-sys"]
fsext = ["libc", "windows-sys"]
fsxattr = ["xattr"]
lines = []
feat_systemd_logind = ["utmpx", "libc"]
format = [
"bigdecimal",
"extendedbigdecimal",
Expand Down
4 changes: 3 additions & 1 deletion src/uucore/src/lib/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// file that was distributed with this source code.
// features ~ feature-gated modules (core/bundler file)
//
// spell-checker:ignore (features) extendedbigdecimal
// spell-checker:ignore (features) extendedbigdecimal logind

#[cfg(feature = "backup-control")]
pub mod backup_control;
Expand Down Expand Up @@ -74,6 +74,8 @@ pub mod fsxattr;
pub mod selinux;
#[cfg(all(unix, not(target_os = "fuchsia"), feature = "signals"))]
pub mod signals;
#[cfg(feature = "feat_systemd_logind")]
pub mod systemd_logind;
#[cfg(all(
unix,
not(target_os = "android"),
Expand Down
Loading
Loading