Commit graph

625 commits

Author SHA1 Message Date
Milos Malik
e978f12992 modify tests to run successfully on CentOS stream machines
Some tests failed when executed on CentOS-stream machines because of
insufficient code conditions. From now on, this problem should not
happen anymore.
2024-11-06 13:57:29 +01:00
Milos Malik
2e6dd329b8 add basic test which covers the gnome-remote-desktop service
Sooner or later, the gnome-remote-desktop service will be confined
by SELinux policy and this automated test should find out if basic
functions of the program/service are affected or not.

The TC covers RHEL-35877.

During the development of the automated test, a new SELinux denial
was identified and reported. The reproducer is already part of this
test.

In order to support various functions of the grdctl program, I believe
that SELinux policy should allow the gnome-remote-desktop-daemon
processes to watch (syscall = inotify_add_watch) the
/etc/gnome-remote-desktop directory. The TC looks for appropriate
policy rules and file context patterns.

The TC covers BZ#2321236.
2024-10-26 10:00:43 +00:00
Milos Malik
386ee4ea46 test if systemd-run works inside systemd-run service
Recently, debugging of unrelated systemd issue revealed that SELinux
prevents a successful execution of systemd-run inside systemd-run
session. The TC reproduces the situation.

In order to support the above-mentioned scenario, I believe that
SELinux policy should allow the dbus-broker to read/write from/to
UNIX stream socket owned by the systemd session. The TC looks for
appropriate policy rules.

The TC covers RHEL-61928 and RHEL-62185.
2024-10-23 08:06:48 +00:00
Milos Malik
597fc277da fill in the missing metadata in some tests
Now, all tests in the repository should have their nitrate id and
UUID in their main.fmf file.
2024-10-21 15:19:06 +00:00
Petr Lautrbach
deaf7662f4 Test rpm transaction for stderr output
Commands stderr output should be hidden unless it's fatal error

Verifies: https://issues.redhat.com/browse/RHEL-59192
2024-10-18 14:48:15 +00:00
Milos Malik
c3676f738b add basic test which covers the tlshd service
Sooner or later, the tlshd service will be confined by SELinux
policy and this automated test should find out if basic functions
of the program/service are affected or not.

The TC covers RHEL-29439 and RHEL-42672.
2024-10-16 11:52:44 +00:00
Zdenek Pytela
981c13333c Install linuxptp for the chrony test
In Fedora 41+, the timemaster_t type is available only when the
linuxptp-selinux package is installed. It is pulled in by linuxptp if
linuxptp-selinux exists, so linuxptp is a safe requirement working
for older releases, too.
2024-10-14 13:17:32 +02:00
Milos Malik
cb72821400 add basic test which covers pcm-sensor-server
Sooner or later, the pcm-sensor-server will be confined by SELinux
policy and this automated test should find out if basic functions
of the pcm-sensor-server program/service are affected or not.

The TC covers RHEL-52838.
2024-10-11 18:17:18 +00:00
Milos Malik
f179552e1b do not test services which are not present
Try to install packages which bring the services if they are
not present already.
Skip the "real scenario" test phase if the service is missing.
2024-10-08 08:14:51 +00:00
Milos Malik
239992b457 add test metadata which were missing
Recently created tests were missing FMF ids and Nitrate ids.
Newly created SELinux types are slightly different from what I expected.
Both issues are solved now.
2024-10-08 07:59:49 +00:00
Milos Malik
94564f402a run stress-ng only if secretmem_t is defined
The test phase covers both BZ#2270895 and RHEL-60837 because they
the same. The test phase should not be executed in environments
where the following SELinux type is not defined:
 * secretmem_t
2024-10-07 11:14:08 +00:00
Milos Malik
8ed58cb4ea add basic test which covers power-profiles-daemon
Sooner or later, the power-profiles-daemon will be confined by SELinux
policy and this automated test should find out if basic functions
of the power-profiles-daemon program/service are affected or not.

The TC covers RHEL-61117.
2024-10-07 09:21:31 +00:00
Milos Malik
b5a0def0c7 add basic test which covers switcheroo-control
Sooner or later, the switcheroo-control will be confined by SELinux
policy and this automated test should find out if basic functions
of the switcheroo-control program/service are affected or not.

The TC covers RHEL-24268.
2024-10-07 09:11:14 +00:00
Milos Malik
3184400050 add basic test which covers systemd-mountfsd
Recently, the systemd-mountfsd program/service got confined by SELinux.
Purpose of this automated test is to cover the basic scenarios in
which the daemon is used. The systemd-mountfsd man page was used as
the source of test scenarios/ideas.
2024-10-07 09:06:40 +00:00
Milos Malik
4ca2560ddd add basic test which covers iio-sensor-proxy
Sooner or later, the iio-sensor-proxy will be confined by SELinux
policy and this automated test should find out if basic functions
of the iio-sensor-proxy program/service are affected or not.

The TC covers RHEL-17346.
2024-10-07 07:49:08 +00:00
Milos Malik
2aa1759692 test if systemd-homed can read /var/cache/systemd/home/
Several recent BZ reports revealed that SELinux prevents the
systemd-homed processes from reading the /var/cache/systemd/home/
directory. The TC reproduces the situation.

In order to support the expected systemd-homed functionality, I believe
that SELinux policy should allow the action. The TC looks for
appropriate policy rules and file context patterns.

The TC covers BZ#2036108 and its duplicates.
2024-10-04 11:49:13 +00:00
Milos Malik
6b1406c6b2 test if systemd-modules-load can read /run/modprobe.d/*.conf
A recent cockpit CI + selinux-policy + FIPS testing revealed that
SELinux prevents the systemd-modules-load processes from reading
files stored in the /run/modprobe.d/ directory. The TC reproduces
the situation.

In order to support the documented locations for modprobe config
files, I believe that SELinux policy should allow the action. The
TC looks for appropriate policy rules and file context patterns.

The TC covers RHEL-54591.
2024-10-03 12:55:42 +00:00
Milos Malik
c9a5369366 test if systemd-journal-upload can read /run/systemd/journal-upload.conf.d/
A recent systemd + selinux-policy testing revealed that SELinux
prevents the systemd-journal-upload processes from reading the
the /run/systemd/journal-upload.conf.d/ directory. The TC reproduces
the situation.

In order to support the documented locations where systemd-journal-upload
configurations can be located, I believe that SELinux policy should
allow this action. The TC looks for appropriate policy rules and
file context patterns.

The TC covers RHEL-57774.
2024-10-03 11:54:36 +00:00
Milos Malik
2b36306eb2 test if 'hostapd_cli ping' can run as a systemd service
A recent testing of a documented hostapd + freeradius use case
revealed that SELinux prevents the hostapd processes from writing
to a control socket located in /tmp. The TC reproduces the situation.

In order to support the documented use case, I believe that SELinux
policy should allow the action. The TC looks for appropriate policy
rules and file context patterns.

The TC covers RHEL-59683.
2024-10-03 07:48:29 +00:00
Jan Onderka
2b631b367f Set time duration for tests seliabel-functions and selinux_restorecon-functions 2024-09-30 09:54:43 +00:00
Milos Malik
f471756eb4 fix the "unable to detect release version" situation
The yum process is sometimes not able to detect the Fedora version.
From now on, the --releasever option will be included on the command
line.
2024-09-24 18:15:56 +00:00
Petr Lautrbach
186b346eed Some SELABEL_ options are only supported in SELABEL_CTX_FILE
Since
65c8fd457b
selabel_open() would fail if used with unsupported option

Fixes:
    selabel_open - ERROR: Invalid argument
    selabel_options: SELABEL_OPT_PATH = (null), SELABEL_OPT_SUBSET = (null), SELABEL_OPT_VALIDATE = 0, SELABEL_OPT_BASEONLY = 0
    Executing: selabel_open(SELABEL_CTX_MEDIA, &selabel_option, 4)
    :: [ 07:57:09 ] :: [   FAIL   ] :: Command './test_open CTX_MEDIA NULL NULL 0 0' (Expected 0, got 22)
2024-09-24 16:18:45 +02:00
Milos Malik
9245b35ac6 test if boothd can talk to kernel via UNIX socket
A recent booth + selinux-policy testing revealed that SELinux
prevents the boothd processes from reading the /run/systemd/userdb/
directory and connecting through the io.systemd.DynamicUser socket
stored in it. The TC reproduces the situation.

In order to support the intended boothd functionality, I believe that
SELinux policy should allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-57104 and RHEL-58060.
2024-09-19 10:46:49 +00:00
Milos Malik
917da0db4b test if systemd-sysctl can read files under /run/sysctl.d/
A recently filed issue revealed that SELinux prevents the
systemd-sysctl from reading the files stored under the /run/sysctl.d/
directory. The TC reproduces the situation.

In order to support this documented sysctl specific location,
I believe that SELinux policy should allow the action. The TC
looks for SELinux denials that may appear when reproducing the
scenario.

The TC covers RHEL-56988 and RHEL-58380.
2024-09-19 10:04:46 +00:00
Milos Malik
4f44f21f57 test if new dhcpcd instance can kill an old instance
Because the ISC dhcp is no longer maintained by upstream, the dhcpcd
package is used as a replacement. Unfortunately, SELinux prevents
a new dhcpcd instance from communicating to and terminating the old one.
The TC does not reproduce the situation.

In order to support the intented dhcpcd functionality, I believe that
SELinux policy should allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-33081 and RHEL-43417.
2024-09-18 15:47:51 +00:00
Milos Malik
28a763c2e0 mark tests which are failing on RHEL-10
Tests which require the EPEL repository are tagged with rhel10-epel.
Tests which fail for other reasons are tagged with rhel10_broken.
2024-09-12 15:53:29 +02:00
Zdenek Pytela
9d0f01d9c3 Fix the phase for secretmem anon_inode type
The fix for bz#2270895 contains a transition when a secretmem type of
anon_inode class is to be created, similar to io_uring and userfaultfd.
2024-09-11 16:30:54 +00:00
Zdenek Pytela
7615b2d8c7 Do not check if "%{_sbindir}" rpm macro is used
With Changes/Unify_bin_and_sbin [1] in process, policy sources
stopped to refer to executables with full path using the "%{_bindir}"
and "%{_sbindir}" rpm macros.

[1] https://fedoraproject.org/wiki/Changes/Unify_bin_and_sbin
2024-09-11 16:27:13 +00:00
Milos Malik
34b7237513 do not rely on /etc/firewalld/lockdown-whitelist.xml
Recently, the automated test started failing because the following
file was not present: /etc/firewalld/lockdown-whitelist.xml.

From now on, the test should not fail because of this.
2024-09-10 07:53:36 +00:00
Ondrej Mosnacek
2401e40bac
kernel: improve kernel pkg name detection
When kernel-uk-virt is installed, the rpm query returns more than one
result, leading to (non-fatal) errors in the Setup phase. Query for the
kernel image path instead to avoid this.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-09-09 11:29:40 +02:00
Milos Malik
0b5f4b8236 add a new boothd test
Recently, the boothd program got confined by SELinux. Purpose of
this automated test is to find out if basic scenarios work as
expected under the current SELinux policy.

The TC covers RHEL-45907.
2024-08-30 11:31:09 +00:00
Ondrej Mosnacek
5e03405ed4 Add a test for two-way SCTP association setup
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-08-29 10:06:21 +00:00
Ondrej Mosnacek
6efe97887e
kernel/selinux-testsuite: apply a patch for ELN/EL10 compatibility
Fedora ELN / RHEL-10 has disabled CONFIG_NET_KEY, so apply a patch that
allows the testsuite to succeed by skipping the key_socket test when it
is not supported.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2024-08-28 15:18:33 +02:00
Vit Mojzis
b30e460af8 libselinux/matchpathcon: Add the previous fix to the correct test
Commit ab42eb93 added the change to another test by mistake.

Fixes:
  # cd libselinux/setfiles-in-chroot-env
  # 1minutetip 1MT-CentOS-Stream-9
  # ./runtest.sh

  yum -y install filesystem libselinux libselinux-utils python3-libselinux policycoreutils --installroot=/tmp/tmp.WhKcf2BrOe  --skip-broken'
  Unable to detect release version (use '--releasever' to specify release version)
  Error: Failed to download metadata for repo 'epel': Cannot prepare internal mirrorlist: Status code: 404
  [   FAIL   ]

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2024-08-16 13:46:58 +02:00
Vit Mojzis
ab42eb9378 libselinux/matchpathcon: Work around yum issue on CentOS 9
Fixes:
  # cd libselinux/setfiles-in-chroot-env
  # 1minutetip 1MT-CentOS-Stream-9
  # ./runtest.sh

  yum -y install filesystem libselinux libselinux-utils python3-libselinux policycoreutils --installroot=/tmp/tmp.WhKcf2BrOe  --skip-broken'
  Unable to detect release version (use '--releasever' to specify release version)
  Error: Failed to download metadata for repo 'epel': Cannot prepare internal mirrorlist: Status code: 404
  [   FAIL   ]

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2024-08-15 23:36:22 +02:00
Milos Malik
705e5154fa test if cups-browsed can access /root/.cups/lpoptions
A recent cups + selinux-policy testing revealed that SELinux prevents
the cups-browsed processes from accessing the /root/.cups/lpoptions
file. The TC reproduces the situation.

In order to support the cups-browsed ability to access the lpoptions
file, I believe that SELinux policy should allow the access. Either
file context patterns need to change or an appropriate policy rule
need to be added. The TC looks for these changes.

The TC covers RHEL-47401.
2024-08-03 06:20:00 +00:00
Milos Malik
ed49590c43 test if stalld works with the queue_track backend
Recent changes (BPF code that is involved in the queue_track
backend) in the stalld component trigger SELinux denials because
SELinux policy does not expect such a behavior. The TC reproduces
the situation.

In order to support this new feature, I believe that SELinux policy
should allow the necessary actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-50356.
2024-08-02 16:04:27 +00:00
Milos Malik
a2c9af2d18 fix tests which fail for known reasons
The chronyd test does not produce non-printable characters now.

The libvirt-dbus test phases relevancy is improved now.
2024-08-02 17:29:13 +02:00
Milos Malik
a915243c7d recognize the new virt* policy and adapt checks
Instead of checking Fedora or CentOS or RHEL version, the decision
to adapt should be made according to the defined SELinux policy types
or attributes.

The TC also covers RHEL-40834.
2024-07-30 16:05:32 +02:00
Milos Malik
1fa9327a33 avoid showing of unprintable characters in the output
Unprintable characters in the test output can cause problems
when importing test results to the Report Portal.
The problem should be fixed now.
2024-07-30 13:27:03 +02:00
Milos Malik
1d726848e6 skip irrelevant phases and install required packages
If required packages are not installed, the tests will try to install
them (only 1 attempt per test will be done).

Certain test phases may not be relevant if:
 * required SELinux types/attributes are not defined
 * required programs/files are not installed
 * required packages are not available
2024-07-26 18:12:20 +02:00
Milos Malik
96d9e69fc4 test if systemd-machined can create socket in /run/systemd/machine/
Recent cockpit + systemd + selinux-policy testing revealed that
SELinux prevents the systemd-machined process (started by the
machinectl command) from doing the following actions:
 * creating the /run/systemd/machine directory
 * creating the /run/systemd/machine/io.systemd.Machine socket
 * unlinking the /run/systemd/machine/io.systemd.Machine socket
The TC reproduces the situation.

In order to support the basic machinectl functions, I believe that
SELinux policy allow these actions. The TC looks for appropriate
policy rules and file context patterns.

The TC covers RHEL-49567.
2024-07-26 09:48:20 +00:00
Milos Malik
1ea9253e58 add basic test coverage of the libvirt-dbus service
A recent cockpit + selinux-policy testing revealed that SELinux
prevents libvirt-dbus processes from connecting to virtqemud
processes. The TC reproduces the situation.

The libvirt-dbus service is confined by SELinux now. The TC covers
basic scenarios in which the service is used. The TC looks for
appropriate policy rules and file context patterns.

The TC covers RHEL-46893.
2024-07-26 09:18:37 +00:00
Milos Malik
5a7dbcf733 increase the chances of successful "yum install" runs
Package installations via yum can fail for many reasons. For example:
 * unsatisfied package dependencies
 * repository availability problems
 * unrecognized command line options

Hopefully, this change helps the yum command to run successfully
when such issues occur.
2024-07-24 13:21:02 +02:00
Milos Malik
ad41a9d3c2 fix problematic tests
Avoid problems caused by test failures or tests getting stuck.
2024-07-23 11:34:23 +02:00
Milos Malik
9aa7176654 update test relevancy to match the expectations
Certain test phases or tests are not relevant for CentOS stream 9.
2024-07-19 13:30:29 +02:00
Milos Malik
64f5b0129b keep the rlSETranslateBoolean() up-to-date
Make sure the upstream and downstream version of the rlSETranslateBoolean
function is the same. Otherwise, differences can cause problems
when running tests which use the function.
2024-07-18 14:19:26 +02:00
Milos Malik
3e4943c596 add missing metadata to the tests
Some tests were missing important TCMS metadata. Now, the problem
should be fixed.
2024-07-10 17:18:28 +00:00
Petr Lautrbach
c4bc437c3f Improve README
- rename to README.md
- add basic instruction how to run tests on localhost

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
2024-07-10 08:57:28 +00:00
Milos Malik
1800d74961 test if matchpathcon works fine in chroot environment
A recent anaconda testing on Fedora rawhide machines revealed a
regression in the libselinux code which leads to segfaults. The TC
reproduces the situation.

The TC uses 2 reproducers (python code, binary command) to find out
if the problem is present or not. Both of them should pass when the
problem is fixed.

The TC covers BZ#2295428 and RHEL-46558.
2024-07-10 09:32:35 +02:00