Gate SELinux functionality to Linux-only and provide stub implementations
for chcon/runcon on non-Linux platforms to maintain cross-platform builds.
Changes:
- Gate all SELinux code with target_os = "linux" checks
- Add stub main() for chcon/runcon on non-Linux with user-friendly errors
- Add CI job to verify stubs build correctly on macOS and Windows
- Update ls to check both selinux feature AND target_os
Benefits:
- Fixes build failures on macOS/Windows (#8581, #7996, #7695, #6491)
- Maintains workspace buildability across all platforms
- Provides clear error messages instead of silent failures
- Prevents accidental SELinux usage on unsupported platforms
CI Testing:
- New 'Build/SELinux-Stubs (Non-Linux)' job tests macOS and Windows
- Verifies stub binaries are created and compilation succeeds
- Validates full workspace builds with stubs present
Addresses maintainer feedback in PR #8795
The make build was failing when the list of UTILS didn't contain stdbuf.
This fixes this issue by adding feat_externa_libstdbuf only when stdbuf is being compiled.
Fixes https://github.com/uutils/coreutils/issues/8701
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
In the context of musl, users are typically expecting statically-linked tools,
as this is one of musl's strong suits and one of the biggest reasons to use it
instead of glibc (that is not static-link-friendly for reasons).
- remove the build-flag which was causing musl libc to be linked dynamically
- re-add feat_os_unix_musl which was removed in 21d5cef153
- exclude stdbuf from feat_os_unix_musl, since libstdbuf.so can't be built with a statically linked musl libc
- add test_musl_no_dynamic_deps so that this does not regress in the future
Fixes https://github.com/uutils/coreutils/issues/8572
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* add support for systemd-logind
Add support for systemd-logind for systems where `/var/run/utmp` does not exist any more (e.g. Ubuntu 25.04).
Here is some context explaining the switch from utmp to systemd-logind:
https://www.thkukuk.de/blog/Y2038_glibc_utmp_64bit/
Fixes https://github.com/uutils/coreutils/issues/8376
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* fix duplicated boot record
When feature feat_systemd_logind is enabled and utmp is present, two boot records were printed.
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* improve error forwarding
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* remove unnecessary negation in if/else block
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* use getpwuid_r() instead of getpwuid()
getpwuid() is not thread-safe.
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* improve error handling
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* use Path instead of string
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* use closure to reduce the number of clones() calls
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* use MaybeUninit instead of mem::zeroed()
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* systemd-logind: add some unit-tests
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* use sysconf(_SC_GETPW_R_SIZE_MAX) instead of 1024
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* fix cspell
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* add auto-enablement of feat_systemd_logind in GNUmakefile
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* Revert "add auto-enablement of feat_systemd_logind in GNUmakefile"
This breaks "Tests/BusyBox test suite" in CI.
This reverts commit 16626d4653.
---------
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
- Added devcontainer configuration based on Ubuntu 24.04
- Added GitHub Actions workflow for devcontainer testing
- Update cSpell configuration to ingore spelling in devcontainer configs
- Update pre-commit hooks to exclude cSpell.json because pre-commit
fails for that file due to json with comments format
- Fix filename for cSpell config in vscode settings
- Two tests in `test_dd.rs` are now skipped if /dev/sda1 is not
available, which is the case in devcontainer
- Update check for existing gnu clone in build-gnu.sh, not checking the
existence of the directory but the presence of the .git directory.
This allows us to have the directly as a volume mount in devcontainer
- Remove temporary file `g` after use in build-gnu.sh
Looks like the "system boot" entry is not present in /var/lib/utmp
on recent ubuntu-latest images.
Not totally clear why it disappeared, but let's just create a fake
one instead.
* tests: fix execution on WSL2, Ubuntu 24.04
Skip incompatible parts of tests to ensure that
cargo nextest run --features unix
executes successfully in WSL2, Ubuntu 24.04 distribution.
Changes
* Skip tests that required sys/kernel/profiling which is not
available in WSL2 default configuration.
* Use timezones in tests that are part of the standard tzdata
list and not only available in backwards list. Backwards list is
not installed by default in Ubuntu 24.04 (package tzdata-legacy).
* check that /proc/modules is not empty when expecting content,
because it is empty in WSL2 default configuration.
* Skip logname test not only in WSL1, also in WSL2.
* Add workflow for WSL2
This will setup WSL2 on windows-latest runner, install
Ubuntu-24.04, and run the feat_os_unix tests.
* wsl2: implemented review findings
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>