2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-19 08:52:15 +00:00
Commit Graph

28836 Commits

Author SHA1 Message Date
Daniel Hilst db07a23349 fix(xcat-core): rpm does not own the probe subcmds/bin directory
The %post of xCAT-probe created /opt/xcat/probe/subcmds/bin, so the
directory belonged to no package and carried usr_t from its parent rather
than the bin_t the policy gives /opt/.*/bin. It was the only path under
/opt/xcat that restorecon reported as pending, on every management node.

%install now creates the directory, so rpm owns it and labels it from the
policy at install, as the Debian package already does through debian/dirs.
The %post keeps removing the obsolete switchprobe file it finds there.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-15 12:06:01 -03:00
Daniel Hilst e2bae62e61 test(xcat-core): capture the probe directory no package owns
/opt/xcat/probe/subcmds/bin is created by the %post of xCAT-probe, so no
package owns it. A directory a scriptlet creates takes the context of its
parent, usr_t, and not the bin_t that the policy gives /opt/.*/bin, and
nothing relabels it afterwards. Measured on xcat163-mn-tmp-286:

    restorecon -n -v -R /opt/xcat
    Would relabel /opt/xcat/probe/subcmds/bin from
      unconfined_u:object_r:usr_t:s0 to unconfined_u:object_r:bin_t:s0

It is the only path under /opt/xcat whose label does not match the policy.
The directory is in use: xcatprobe:263 drops a switchprobe symlink in it,
and xCAT-probe/debian/dirs already packages it on Debian.

xcat_probe_package_payload.t asserts that %install creates it, that %post
does not, and that the Debian package keeps it. 2 of its 4 checks fail on
this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-15 12:06:01 -03:00
Daniel Hilst 6eb1d71317 feat(xcat-core): keep the TFTP server out of the xCAT domain
AAsn.pm starts /usr/sbin/in.tftpd with system() and no systemd unit, so the
daemon inherited xcat_t: a persistent listener on UDP 69, reachable from every
node of the provisioning network, held the authority of the domain that also
writes the image tree and reaches the database.

xcat.te now transitions from xcat_t to the stock tftpd_t on tftpd_exec_t.
tftp.if carries no tftp_domtrans, so the pattern and the three inherited
process permissions are written out.

Measured on xcat163-mn-tmp-286 with both xCAT domains enforcing and dontaudit
disabled: in.tftpd runs as system_u:system_r:tftpd_t:s0 and still owns port 69,
a TFTP fetch of /tftpboot/xcat/xnba.kpxe returns the file, and both flat
provisioning cases pass -- diskless 1177 s, which netboots the compute node
over that server, and diskful 654 s. Zero denials in xcat_t, xcat_image_t and
tftpd_t.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-15 10:37:57 -03:00
Daniel Hilst ca04e2c8ae fix(xcat-core): the image build cannot open the fifo dnf writes its progress to
The last two enforced denials of the enforcing run were
xcat_image_t tmp_t:fifo_file create. Neither provisioning case failed on
them, because dnf falls back to its plain output, but the grant belongs
with the rest of the /tmp set of that domain.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-15 03:16:26 -03:00
Daniel Hilst 078f607448 feat(xcat-core): build the image in a domain of its own
The policy granted xcat_t everything the image build needs, so the domain
that listens on the xcatd port could also write and relabel a file of any
type. The rules were one per target type, 558 of them from the measured
denials, and 85 per cent of those repeated one of 58 permission patterns.

xcat.te now carries two domains. xcat_image_t is entered through
/opt/xcat/bin/genimage and the per-OS genimage program, from xcat_t and
from the administrator, and it holds the filesystem-wide manage and relabel
grants: the build creates an operating system tree, and the kernel cannot
tell a path inside that tree from the same type on the management node.
xcat_t keeps the daemon surface -- its sockets and ports, /install,
/tftpboot, /etc, the credentials, the service class for the units it
restarts -- and no grant over the file_type attribute.

The rules are Reference Policy interface calls where one exists:
domain_read_all_domains_state replaces 93 of them, dev_getattr_all_chr_files
31, files_read_etc_files, auth_read_shadow, seutil_read_config,
logging_send_syslog_msg, fs_mount_all_fs and corecmd_exec_bin the rest. The
module is 203 statements where the generated set was 806 rules.

packimage and liteimg are symlinks to xcatclientnnr, so their work runs in
the xcatd plugin and the tree authority stays in xcat_t with them. It can
move to xcat_image_t when the plugin execs a helper instead.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-15 02:28:20 -03:00
Daniel Hilst 52605e3959 test(xcat-core): capture the missing image-build domain
The image build creates an operating system tree, so it writes and relabels
files of every type the packages own. xcat_t holds that authority today, and
the same domain listens on the xcatd port.

xcat_selinux_package.t now asserts a second domain for the build: the
xcat_image_t declaration, its permissive line, the entrypoint, the
transition from xcat_t with the three inherited process permissions, the
role statements for system_r and unconfined_r, and the file contexts of the
two genimage programs. One check holds the security property of the split:
only xcat_image_t may manage or relabel every file type, and the daemon
domain gets no filesystem-wide grant.

9 of the 74 checks fail on this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-15 02:27:38 -03:00
Daniel Hilst c18e415280 fix(xcat-core): mysqlsetup cannot find a configuration file to rewrite
The candidate list of comment_bind_address was assigned by a top-level
statement below the main flow's exit, so the statement never ran. The list
was empty, the fallback index read undef, and mysqlsetup -i failed with
"cannot read : No such file or directory" on every MySQL cluster. The
service node install stops there.

A BEGIN block now fills the list at compile time.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 18:49:02 -03:00
Daniel Hilst 2f5a4dbd3a test(xcat-core): capture the empty candidate list of mysqlsetup
mysqlsetup -i reports

    comment the bind-address line failed: cannot read : No such file or
    directory

on every MySQL cluster, with no file named. Measured on xcat185-mn-tmp-84
through SN_setup_case, which then stops: the Kea configuration and the
service node install never happen.

@BIND_FILES is assigned by a top-level statement that sits below the main
flow's exit, so the statement never runs and the list is empty at run time.
$BIND_FILES[-1] is then undef. Each case in the test localizes the list, so
none of them read the value the script itself holds.

The test now asserts the list of the loaded script. 2 of its 15 checks fail
on this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 18:48:54 -03:00
Daniel Hilst 7f5cf08ad8 fix(xcat-core): the erase of xCAT-selinux leaves three files unlabeled_t
%postun removed the module and relabelled nothing, so the two entrypoint
types left the policy while three files still carried them. The files
became unlabeled_t, and /install kept public_content_t, which the stock
policy does not define for it.

%preun now saves the file contexts, because %pre does not run on an erase,
and %postun relabels after the module is removed, on an erase only.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 17:33:44 -03:00
Daniel Hilst d3739aa512 test(xcat-core): capture the labels the erase of xCAT-selinux leaves behind
Removing the package removes the module, so xcatd_exec_t and
xcat_client_exec_t leave the policy and each file that carried one becomes
unlabeled_t. Measured on xcat162-mn-tmp-286 after dnf remove:

    system_u:object_r:unlabeled_t:s0 /opt/xcat/sbin/xcatd
    system_u:object_r:unlabeled_t:s0 /opt/xcat/bin/xcatclient
    system_u:object_r:unlabeled_t:s0 /opt/xcat/bin/xcatclientnnr

restorecon -n reported all three as pending, and /install kept
public_content_t, which the stock policy does not define for it.

xcat_selinux_package.t asserts the %preun snapshot and the %postun relabel
that an erase needs, guarded for the erase only. 3 of its 64 checks fail on
this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 17:33:39 -03:00
Daniel Hilst 8858c2f636 fix(xcat-test): ausearch refuses the start time the SELinux cases pass
The cases marked the start of a window with date "+%x %T" and passed the
result to ausearch -ts. Audit 4.0.3 rejects it:

    Invalid start time (10/14/2026 20:00:00). Hour, Minute, and Second are
    required.

ausearch then exits 1 with that message and no records. Measured on
xcat162-mn-tmp-286: the query returned 0 records where 653 were in the log,
and MM/DD/YY and ISO forms are refused the same way. Only a bare HH:MM:SS
is accepted. Each no-denial check therefore reported a clean node whatever
the node did, which is the defect --input-logs was meant to remove.

Each case now seeds an ausearch --checkpoint file at its start and reads
the new events with the same file, which is audit's own mechanism and has
no date to misparse. A check before the count asserts that ausearch
answered at all: the output has to hold a record or "<no matches>", and an
error message holds neither. Verified on the same node, where the guard
exits 1 on a deliberately broken query, 0 on an empty window, and the read
after a client run returned 63 new records.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 17:31:23 -03:00
Daniel Hilst 7086f2de95 fix(xcat-core): a client command cannot exec under enforcing
The transition into xcat_t computes unconfined_u:unconfined_r:xcat_t, and
the module did not authorize unconfined_r for that type. The context is
then invalid, so the kernel refuses the exec of the interpreter and the
command fails with "bad interpreter: Permission denied". Every client
command run by the administrator or the CI failed this way on an enforcing
node, while xcatd itself was unaffected: a daemon domain carries the daemon
attribute, which system_r already holds.

xcat.te now states "role unconfined_r types xcat_t" beside the transition.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 17:28:27 -03:00
Daniel Hilst 7b92b95034 test(xcat-core): capture the client exec that SELinux refuses
A client command run from unconfined_t fails under enforcing:

    /opt/xcat/bin/lsxcatd: /usr/bin/perl: bad interpreter: Permission denied

Measured on xcat162-mn-tmp-286, AlmaLinux 10.2, with the module loaded and
the entrypoints labelled. The same command returns 0 under setenforce 0.
The transition computes unconfined_u:unconfined_r:xcat_t, and the module
does not authorize unconfined_r for xcat_t, so the context is invalid and
the kernel refuses the exec. The permissive declaration does not help,
because an invalid context is not a permission check. The record is
SELINUX_ERR, op=security_compute_sid, which no AVC query finds.

xcat_selinux_package.t asserts the role statement, and check 49 of 60
fails on this commit. selinux_client_domain asserts that lsxcatd returns 0
and prints its version under enforcing, that seinfo reports xcat_t for
unconfined_r, and that the run leaves no invalid_context record.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 17:28:02 -03:00
Daniel Hilst 167f04d2e9 docs(selinux): document the xcat_t domain and the management-node scope
The pull request adds a process domain and says nowhere which machine it
covers, which commands enter it, or why the domain is permissive while the
host is enforcing.

The new page names the scope as the management node, lists the three
entrypoint files and the rule that the unit must exec xcatd and not a shell,
and states that the permissive declaration is in the policy source and a
later release removes it. It gives the commands that read the domain of
xcatd and the enforced denials of a run, with the --input-logs finding:
ausearch read the journal on an EL10 node whose log held 1032 denials.

It also records why a confined user domain gets no transition, and that the
file permissions still decide what a user can read.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:56:37 -03:00
Daniel Hilst 07b7041011 docs(xcat-core): two comments name the domain xcatd no longer runs in
The unit file and xcatd_service_direct_exec.t said that a direct ExecStart
keeps xcatd out of initrc_t and in unconfined_service_t. The entrypoint of
the xcat_t domain is the xcatd script, so a shell in ExecStart now costs the
domain, not the confinement.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:55:48 -03:00
Daniel Hilst 0f0c2a1f94 feat(xcat-core): run xcatd and the xCAT clients in the xcat_t domain
xCAT had no process domain. xcatd ran in unconfined_service_t, where the
policy constrains nothing, and each client command ran in the domain of its
caller. The module could therefore only grant access to other services.

xcat.te declares the xcat_t domain, the xcatd_exec_t and xcat_client_exec_t
entrypoints, the transition from systemd, and the transition from
unconfined_t for a client command. xcat.fc labels /opt/xcat/sbin/xcatd and
the two xcatclient scripts, which 115 command names reach through a symlink.

xcat_t is permissive, and the policy source declares it. The host stays
enforcing, and the CI collects the accesses the domain needs. The module
grants the domain one access of its own: the execute of the interpreter that
its Perl entrypoint names. A confined user domain gets no transition, so it
keeps its own confinement.

The module compiles at version 19 in the alma+epel-10-x86_64 mock root, and
the binary carries (typepermissive xcat_t) and both type transitions.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:55:21 -03:00
Daniel Hilst 2efdce66b9 test(xcat-core): capture the missing xcat_t domain
xCAT ships no process domain. xcatd runs in unconfined_service_t, and a
client command runs in the domain of its caller, so no rule in the policy
module reaches either of them.

xcat_selinux_package.t now asserts the domain, the two entrypoint types,
the file contexts of the three entrypoints, the transition from systemd and
the transition from unconfined_t, and that no confined user domain gets a
transition. 9 of its 59 checks fail on this commit.

selinux_xcatd_domain asserts the live context of xcatd and its workers, and
the new selinux_client_domain case asserts the entrypoint labels and the
transition rules the loaded policy holds.

The two no-denial cases now count only the denials the kernel enforced,
because xcat_t is permissive and each access it needs is recorded. They also
pass --input-logs: on EL10 audit 4.0.3 ausearch reads the journal rather than
the file auditd.conf names, and answered "<no matches>" on a node whose log
held 1032 denials.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:52:43 -03:00
Daniel Hilst 07ba4abbac test(xcat-core): measure xCAT on an enforcing management node
No xcattest case checks xCAT on an enforcing management node, so an
SELinux denial in xcatd, httpd or the REST API reaches a release unseen.

selinux_xcatd_domain checks that xcatd and its workers run in
unconfined_service_t and not in initrc_t. selinux_mn_labels checks the
xcat module, the /install and rootimg file contexts, and that httpd
serves a file from /install and from /tftpboot. selinux_restapi_avc gets
a site attribute through xcatws.cgi. The last two read the audit log from
the start of the case and expect no AVC record. Every case first requires
getenforce to report Enforcing, and none carries the ci_test label.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:33 -03:00
Daniel Hilst 8e9c1e2ab1 fix(xcat-core): mysqlsetup leaves /etc/my.cnf with the label of /tmp
mysqlsetup commented the bind-address line by writing the result to
/tmp/my.cnf and renaming it over the configuration file. A file created in
/tmp takes user_tmp_t, and a rename keeps the type of the file it moves, so
the management node was left with a MySQL configuration that mysqld is denied
read of. The denial survives the command and was seen in three rounds of the
SELinux campaign. The temporary path is also a fixed name in a world writable
directory, written as root.

comment_bind_address now reads the file, substitutes the line and writes the
result back through the same file. Truncating in place keeps the inode, which
is what carries the label, so no relabel is needed afterwards. The candidate
list moves to @BIND_FILES and the resolution order does not change: the
Ubuntu mariadb.conf.d file, then /etc/mysql/my.cnf, then /etc/my.cnf.

mysqlsetup_bind_address_label.t drives the sub against a scratch tree and
asserts the inode survives, that only a line starting with bind is commented,
and that no temporary file is left beside the target. With the rewrite put back
through a renamed file in /tmp, the inode check is the one check of the
thirteen that fails.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:33 -03:00
Daniel Hilst aed2df95c9 fix(xcat-core): a failed Genesis kernel relabel is reported as success
stage_genesis_payload() discarded the exit status of restorecon, so mknb
reported success with the staged kernel still carrying the context of the xCAT
install tree. The routine now returns that status, the kernel path and a message
that names the relabel, and process_request reports it. A failed copy keeps its
own message.

selinux_context.sh reads the exit status of restorecon -F -n -v before its
output, so a non-zero exit with no output is a failure.

The helper also resolves the name mknb stages instead of the architecture it was
given: the exact architecture when an OpenEmbedded export is installed, ppc64
for the legacy POWER image. When that kernel is absent it lists the kernels that
are present, so a mapping that no longer matches mknb is named rather than read
as a missing file.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:33 -03:00
Daniel Hilst 809e209d9e test(xcat-core): measure the SELinux context of the staged Genesis kernel
The unit test in this branch drives stage_genesis_payload with a stub runner, so
it reads the command mknb builds and never a context on disk. No xcattest case
reads one either, so a cell with SELinux enabled cannot show a Genesis kernel
that arrives in the TFTP root with the context of the xCAT install tree.

genesis_kernel_selinux_context deletes the staged kernel, runs mknb, and reports
whether restorecon -F -n -v finds a difference from the policy. cp keeps the
context of a destination that exists, so the delete is what makes the case
measure the copy. Where SELinux is disabled, or libselinux-utils is absent, the
case prints GENESIS_SELINUX_SKIPPED and passes. A permissive node applies labels
and is measured like an enforcing one.

Measured on an AlmaLinux 9.8 management node with SELinux permissive: without
the fix the case reports system_u:object_r:usr_t:s0 against the policy's
tftpdir_t and fails, and with the fix it reports tftpdir_t and passes.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:33 -03:00
Daniel Hilst e35e2f8e19 test(xcat-core): the Genesis SELinux checks pass when the relabel fails
stage_genesis_payload() runs restorecon and discards its exit status, so a
relabel that fails returns 0 and the kernel keeps the context of the install
tree. mknb_genesis_selinux_context.t asserted that rc, so the test held the
defect in place. It now requires the failure to reach the caller, with the
kernel path and a message that names the relabel.

selinux_context.sh reads only the output of restorecon -F -n -v, so a non-zero
exit with no output reports GENESIS_SELINUX_OK.

The helper also builds genesis.kernel.<arch> from the architecture it was
given. With legacy Genesis, mknb ppc64le resolves share/xcat/netboot/genesis/
ppc64 and writes genesis.kernel.ppc64, so the helper fails on a kernel mknb
never staged. Three ppc64le cells run this case.

genesis_kernel_selinux_context.bats drives the helper with lsdef, mknb,
selinuxenabled and restorecon shadowed and XCATROOT in a scratch tree. Three of
its four checks fail without the fix that follows, and the fourth fails when the
OpenEmbedded branch is removed.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:21 -03:00
Daniel Hilst 16e20fbb52 fix(xcat-core): Genesis kernel keeps the install tree SELinux context
mknb stages the legacy Genesis kernel with cp -a, which implies --preserve=all
and copies the SELinux context of /opt/xcat/share/xcat/netboot/genesis with it.
On a management node with SELinux enabled the kernel then carries usr_t, while
the policy declares tftpdir_t for that path. Measured on an el9 management node,
restorecon -nvR /tftpboot names genesis.kernel.x86_64 and no other path, so it
is the one file xCAT mislabels under the TFTP root. Nothing in the netboot path
relabels it.

stage_genesis_payload now copies with --no-preserve=context,xattr, and runs
restorecon -F on the staged kernel when xCAT::Utils->isSELINUX reports SELinux
enabled. xattr goes with context because cp stores the context in the
security.selinux xattr, so --no-preserve=context alone still copies it. The
relabel corrects a kernel that an earlier xCAT staged, because a copy over an
existing file keeps that file's context. A failed relabel does not fail the
step.

mknb_genesis_staging.t reports SELinux as disabled, so its command counts stay
about the copies it tests.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:21 -03:00
Daniel Hilst ec2a48dec0 test(xcat-core): capture the SELinux context of the staged Genesis kernel
mknb stages the legacy Genesis kernel into the TFTP root with cp -a. The flag
implies --preserve=all, so the kernel arrives with the SELinux context of the
xCAT install tree and not the context the policy declares for that path.

The test drives stage_genesis_payload with a recording runner. It asserts that
the copy does not preserve the context, and that the staged kernel is relabelled
after the copy when SELinux is enabled. It fails on the current code: 4 of its
14 checks are red.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst b293dfe744 fix(xcat-core): the policy module omits five measured accesses
The xcat policy module granted httpd read of /tftpboot and let xcatws.cgi
connect to the xcatd port. Five further accesses were measured denied on a
management node and are not granted, so an enforcing node fails at them.

httpd mmaps the per-node xnba boot config it serves out of /tftpboot.
read_file_perms does not hold map, so the module now grants
mmap_read_file_perms. Two sites recorded this denial three days apart, on
xCAT 2.19.1 and 2.20.

xdcp and "updatenode -F" copy /etc/shadow to the nodes and into a rootimg.
rsync_export_all_ro holds that read and rsync_full_access does not grant it,
because shadow_t is not in non_auth_file_type. rsync also writes a target it
created at mode 0000, which needs CAP_DAC_OVERRIDE. Both rules are reached only
where rsync runs in rsync_t, which needs a system-service caller.

genimage installs packages into a rootimg with yum in a chroot, and useradd and
groupadd read the rootimg /var/run symlink from the rpm scriptlets. The symlink
carries public_content_t because the rootimg is under /install, and the base
grant for that read names public_content_t nowhere.

The module compiles at version 19 in the alma+epel-10-x86_64 mock root, and the
five types reach the binary.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst 3607c3f7bd test(xcat-core): capture the five measured rules the policy module omits
The xcat policy module carries four allow rules and xcat_selinux_package.t reads
only the spec and the file context list, so no test reads the module source. The
SELinux campaign measured five more accesses that the module does not grant:
httpd maps the per-node xnba boot config it serves, rsync reads /etc/shadow and
needs CAP_DAC_OVERRIDE to write it, and useradd and groupadd read the rootimg
/var/run symlink from an rpm scriptlet.

The test parses the allow rules of xcat.te into a permission set per source,
target and class, and asserts each access. It also asserts that no rule grants
kernel_t anything. Two such rules make an EL10 diskless node boot enforcing, and
they grant the pre-pivot domain execute on an unlabelled file, which on that
node is the whole root.

7 of the 43 checks fail on this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst 414504d069 feat(xcat-core): add the xCAT-selinux policy package
xCAT shipped no SELinux policy. On an enforcing management node httpd
could not read /install, which had no file context, or the /tftpboot
files that xcat.conf serves, and xcatws.cgi could not connect to xcatd.

The new noarch xCAT-selinux package builds the xcat module with the
selinux-policy-devel Makefile. The module labels /install
public_content_t and leaves each rootimg tree out of the relabel. It lets
httpd read tftpdir_t and lets httpd_sys_script_t connect to ntop_port_t.
The scriptlets use the selinux-policy macros, and %posttrans relabels
/install. They do not change the SELinux mode.

checkmodule writes module version 19, so the package built in the EL10
mock root installs on EL8, EL9 and EL10. On a Red Hat family build,
xCAT-server and xCATsn require xCAT-selinux when selinux-policy-targeted
is installed. SUSE and Debian builds do not change.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst d53b723379 test(xcat-core): capture the missing xCAT SELinux policy package
xCAT ships no SELinux policy. On an enforcing management node, httpd
cannot read /install, which has no file context and is default_t, and
cannot read the /tftpboot files that xcat.conf serves. xcatws.cgi cannot
connect to xcatd.

xcat_selinux_package.t reads the xCAT-selinux spec, its file context list
and the xCAT-server and xCATsn specs. It checks the build and the
scriptlet macros, the /install labels, and the conditional Requires on
xCAT-selinux. 23 of its 31 checks fail on this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst cdeec6668e fix(xcat-core): xcatd runs in initrc_t under SELinux
xcatd.service started xcatd through /bin/sh to read
/etc/profile.d/xcat.sh. systemd runs the shell in initrc_t, and xcatd
inherited that domain. initrc_t moves rsync, useradd, groupadd, hwclock
and setfiles into confined domains, so an enforcing management node
denies syncfiles, updatenode -F and genimage.

ExecStart now runs /usr/sbin/xcatd directly. systemd starts the bin_t
binary in unconfined_service_t, which has none of these transitions. The
unit sets XCATROOT, PATH and PERL_BADLANG with Environment=, and
/etc/sysconfig/xcat can still override them. RPM and Debian packages ship
the same unit. The SysV script for hosts without systemd still reads the
profile.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst 61bc1dc1e9 test(xcat-core): capture the shell that starts xcatd
xcatd.service starts xcatd through /bin/sh to read /etc/profile.d/xcat.sh.
systemd runs that shell in initrc_t, so on an SELinux system xcatd runs in
initrc_t. That domain moves rsync, useradd, groupadd, hwclock and setfiles
into confined domains, which deny syncfiles, updatenode -F and genimage.

xcatd_service_direct_exec.t reads the [Service] section of the unit and
checks that ExecStart runs /usr/sbin/xcatd and that Environment= carries
XCATROOT, PATH and PERL_BADLANG. 11 of its 14 checks fail on this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst e6ba4e4be1 fix(xcat-core): an xCAT installation turns off the SELinux policy of the node
xcatconfig set the running system permissive and wrote SELINUX=disabled into
/etc/selinux/config on a Red Hat or openEuler management node. The node lost
the SELinux policy of the site during the installation, and the log reported
only a warning. Every CI cell that declares SELINUX=enforcing ran its test
cases permissive for this reason, and two measurements needed setenforce 1
after the install to get an enforcing node.

xCAT::SELinux->xcatconfig_action now returns the mode and asks for no change.
xcatconfig reports the mode and leaves the running system and
/etc/selinux/config alone. A node that already has SELinux off gets no
warning, as before.

xCAT-test/unit/xcatconfig_selinux_policy.t fails 10 of its 27 checks on the
parent commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst d5a162cc11 test(xcat-core): measure what xcatconfig does to the SELinux policy of a node
xcatconfig turns SELinux off during an installation. It sets the running
system permissive and writes SELINUX=disabled into /etc/selinux/config. A
management node therefore loses the SELinux policy of the site, and only a
warning in the log reports it. Every CI cell that declares SELINUX=enforcing
ran its test cases permissive for this reason.

The test drives xCAT::SELinux->xcatconfig_action against a scratch root and
asserts that an enforcing node, a permissive node and a node with SELinux
already off all get an answer that asks for no change. It also asserts that
the call rewrites no file under that root.

10 of the 27 checks fail on this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst 5b138f24a6 refactor(xcat-core): move the xcatconfig SELinux decision into a module
xcatconfig held the SELinux decision inline and read the state with
xCAT::Utils->isSELINUX, so no unit test can reach it. The script has no sub
API.

xCAT::SELinux now reports the runtime mode and the mode that
/etc/selinux/config selects, and xcatconfig_action returns what xcatconfig
must do about it. xcatconfig applies that answer. The behavior does not
change: a node with SELinux enabled still gets the permissive write and the
/etc/selinux/config rewrite.

runtime_mode reads the selinuxfs enforce file instead of running
selinuxenabled. Both report SELinux as enabled when selinuxfs is mounted.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-14 16:45:20 -03:00
Daniel Hilst ba4824ef62 Merge pull request #7940 from VersatusHPC/fix/imgexport-destination
fix(imgport): write the imgexport bundle to its destination
2026-10-14 12:05:47 -03:00
Daniel Hilst bdd2a51efc Merge pull request #7945 from VersatusHPC/fix/imgimport-litefile-lookup
fix(imgport): quote the image column of the litefile lookup
2026-10-14 12:04:38 -03:00
Daniel Hilst 19d4b661af Merge pull request #7939 from middelkoopt/tm-configib-autoconnect
fix(postscripts/configib): turn autoconnect on when reusing a connection
2026-10-14 11:55:24 -03:00
Daniel Hilst c8a20a1ea2 Merge pull request #7950 from VersatusHPC/fix/kit-rhel-release
fix(kit): compare the RHEL release as a number
2026-10-14 11:53:59 -03:00
Daniel Hilst 25a3c8e55d Merge pull request #7947 from VersatusHPC/fix/table-setattribswhere-cache
fix(table): refresh the cache after a conditional update or rollback
2026-10-14 11:53:16 -03:00
Daniel Hilst 675c9f3dfd Merge pull request #7946 from VersatusHPC/fix/kit-lock
fix(kit): refuse a kit command while another process holds the kit lock
2026-10-14 11:51:23 -03:00
Daniel Hilst 5c0944854f Merge pull request #7944 from VersatusHPC/fix/imgimport-extra-destination
fix(imgport): copy an extra file into its destination directory
2026-10-14 11:49:02 -03:00
Daniel Hilst 2c2ce39795 Merge pull request #7943 from VersatusHPC/fix/table-dbworker-exception
fix(table): pass an exception of the DB worker to its caller
2026-10-14 11:48:20 -03:00
Daniel Hilst 2ae9abbaf8 Merge pull request #7936 from VersatusHPC/refactor/r26-genesis-reuse
refactor(genesis): share runtime helpers and build policy
2026-10-14 11:47:15 -03:00
Daniel Hilst b1fd47ae17 Merge pull request #7938 from VersatusHPC/fix/packimage-image-dir-glob
fix(packimage): refuse an image directory that the shell would split
2026-10-14 11:46:58 -03:00
Daniel Hilst 82a658ff23 Merge pull request #7917 from VersatusHPC/test/r26-package-artifacts
test(packaging): exercise package and repository behavior
2026-10-14 11:44:03 -03:00
Daniel Hilst f631faa68d Merge pull request #7911 from VersatusHPC/test/r26-genesis-hardware-isolation
test(genesis): isolate BMC and adapter script checks
2026-10-14 11:41:58 -03:00
Daniel Hilst 1dc9eebb76 Merge pull request #7915 from VersatusHPC/test/r26-image-network-behavior
test(provisioning): exercise image and network callers
2026-10-14 11:41:06 -03:00
Daniel Hilst dafe7a4aeb Merge pull request #7922 from VersatusHPC/fix/xcattest-vmothersetting-restore
fix(xcat-test): the installation cases corrupt a versioned machine type in vmothersetting
2026-10-14 11:04:30 -03:00
Daniel Hilst 74ec6acdde Merge pull request #7900 from VersatusHPC/fix/x86-unstable-cases
fix(xcat-core): x86_64 CLI cases report failures the product does not have
2026-10-14 11:04:10 -03:00
Vinícius Ferrão 6147399387 test(kit): cover the RHEL release check of the kit commands
A kit command must run on RHEL 7, and must be refused on RHEL 8, 9, 10
and 11. The release check must leave SLES and Ubuntu alone.
2026-10-14 01:21:01 -03:00
Vinícius Ferrão bb94a545ff fix(kit): compare the RHEL release as a number
The kit commands refuse RHEL 8 and later, but compared the release as a
string. "10.1" sorts before "8", so the kit commands ran on RHEL 10.
They now compare the major release as a number.
2026-10-14 01:21:01 -03:00