6 Commits

5 changed files with 48 additions and 72 deletions

View File

@@ -1,60 +0,0 @@
From f5c3a2e4ecbb2ab733b19b0bf84c8334cedd8ba2 Mon Sep 17 00:00:00 2001
From: Eugenio Paolantonio <eugenio.paolantonio@suse.com>
Date: Wed, 30 Oct 2024 14:15:30 +0100
Subject: [PATCH] tests: umockdev-record: t_system_single: handle missing
SELinux context on /dev/null
/sys/fs/selinux might exist, yet the checked path might have no
context defined.
Drop the check for the selinux pseudo-fs, and check the eventual
errno if lgetfilecon() fails.
On ENODATA (context doesn't exist, or the process can't access it),
ENOTSUP (extended attributes not supported/disabled) and ENOSYS
(lgetxattr syscall used by lgetfilecon() not available), ensure
__DEVCONTEXT is not there and continue.
On every other error, fail the test case as before.
Signed-off-by: Eugenio Paolantonio <eugenio.paolantonio@suse.com>
---
tests/test-umockdev-record.vala | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/tests/test-umockdev-record.vala b/tests/test-umockdev-record.vala
index 8672ee1..2c362fa 100644
--- a/tests/test-umockdev-record.vala
+++ b/tests/test-umockdev-record.vala
@@ -201,13 +201,25 @@ t_system_single ()
assert_in("P: /devices/virtual/mem/null", sout);
assert_in("E: DEVNAME=/dev/zero", sout);
#if HAVE_SELINUX
- // we may run on a system without SELinux
- if (FileUtils.test("/sys/fs/selinux", FileTest.EXISTS)) {
- string context;
- assert_cmpint (Selinux.lgetfilecon ("/dev/null", out context), CompareOperator.GT, 0);
- assert_in("E: __DEVCONTEXT=" + context + "\n", sout);
+ string context;
+ int res = Selinux.lgetfilecon ("/dev/null", out context);
+ if (res > 0) {
+ assert_in ("E: __DEVCONTEXT=" + context + "\n", sout);
+ } else if (res == -1 && (Posix.errno == Posix.ENODATA ||
+ Posix.errno == Posix.ENOTSUP ||
+ Posix.errno == Posix.ENOSYS)) {
+ // If SELinux is not available, or is available but
+ // there is no context defined for /dev/null,
+ // we should skip this check as there is
+ // no context recorded.
+ //
+ // ENODATA: context doesn't exist, or the process
+ // can't access it
+ // ENOTSUP: extended attributes not supported/disabled
+ // ENOSYS: lgetxattr syscall not available
+ assert (!sout.contains("E: __DEVCONTEXT"));
} else {
- assert(!sout.contains("E: __DEVCONTEXT"));
+ assert_cmpint (res, CompareOperator.GT, 0);
}
#endif
}

Binary file not shown.

3
umockdev-0.19.4.tar.xz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b2014eb0835be508ddf0cdbdd682e33b3daefa6aab5b24c5b326f46f9db8706d
size 498200

View File

@@ -1,3 +1,41 @@
-------------------------------------------------------------------
Sun Nov 9 08:57:10 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>
- Update to version 0.19.4:
* preload: Hide sticky bit from emulated block dev stat.
* preload: Wrap listxattr().
* uevent-sender: Retry udev_device_new_from_syspath() on
failure.
* uevent_sender: Retry sendmsg() on EAGAIN.
* tests: Adjust for evtest 1.36.
-------------------------------------------------------------------
Mon Aug 4 14:37:54 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>
- Update to version 0.19.3:
* preload: Wrap __fstat64_time64().
- Changes from version 0.19.2:
* preload: Trap dirfd access to /dev, fstat(), and open_tree().
- Use %ldconfig_scriptlets macro for post(un) ldconfig scripts.
-------------------------------------------------------------------
Wed Apr 30 12:13:42 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>
- Update to version 0.19.1:
* preload: Restore errno in ioctl_emulate_open().
* preload: Only emulate ioctls on emulated devices.
* Fix ioctl_tree_execute() ret type and initialization.
* tests: Disable spidev on big-endian 32-bit platforms.
- Changes from version 0.19.0:
* API: Add UMockdev.Testbed.wait_script() to sync to
scripts/evemu replays.
* API: UMockdev.Testbed.load_script_from_string().
* API: UMockdev.Testbed.load_evemu_events_from_string().
* Make uevent synthesis thread-safe.
* Handle "connection refused" when sending a uevent.
- Drop 0001-t_system_single-handle-missing-selinux-context.patch:
incorporated upstream.
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Oct 31 14:19:29 UTC 2024 - Eugenio Paolantonio <eugenio.paolantonio@suse.com> Thu Oct 31 14:19:29 UTC 2024 - Eugenio Paolantonio <eugenio.paolantonio@suse.com>

View File

@@ -1,7 +1,7 @@
# #
# spec file for package umockdev # spec file for package umockdev
# #
# Copyright (c) 2024 SUSE LLC # Copyright (c) 2025 SUSE LLC and contributors
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@@ -19,14 +19,12 @@
%define shlib libumockdev0 %define shlib libumockdev0
%define shlibpre libumockdev-preload0 %define shlibpre libumockdev-preload0
Name: umockdev Name: umockdev
Version: 0.18.4 Version: 0.19.4
Release: 0 Release: 0
Summary: Mock hardware devices for creating unit tests and bug reporting Summary: Mock hardware devices for creating unit tests and bug reporting
License: LGPL-2.1-or-later License: LGPL-2.1-or-later
URL: https://github.com/martinpitt/umockdev/ URL: https://github.com/martinpitt/umockdev/
Source: https://github.com/martinpitt/umockdev/releases/download/%{version}/%{name}-%{version}.tar.xz Source: https://github.com/martinpitt/umockdev/releases/download/%{version}/%{name}-%{version}.tar.xz
# PATCH-FIX-UPSTREAM 0001-t_system_single-handle-missing-selinux-context.patch gh#martinpitt/umockdev#256 eugenio.paolantonio@suse.com -- tests: umockdev-record: t_system_single: handle missing SELinux context on /dev/null
Patch1: 0001-t_system_single-handle-missing-selinux-context.patch
BuildRequires: cmake BuildRequires: cmake
BuildRequires: gtk-doc BuildRequires: gtk-doc
BuildRequires: meson BuildRequires: meson
@@ -104,15 +102,15 @@ umockdev.
%check %check
%meson_test %meson_test
%post -n %{shlib} -p /sbin/ldconfig %ldconfig_scriptlets -n %{shlib}
%postun -n %{shlib} -p /sbin/ldconfig %ldconfig_scriptlets -n %{shlibpre}
%post -n %{shlibpre} -p /sbin/ldconfig
%postun -n %{shlibpre} -p /sbin/ldconfig
%files %files
%license COPYING %license COPYING
%doc NEWS README.md %doc NEWS README.md
%{_bindir}/* %{_bindir}/umockdev-record
%{_bindir}/umockdev-run
%{_bindir}/umockdev-wrapper
%files -n %{shlib} %files -n %{shlib}
%license COPYING %license COPYING