2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-21 09:52:17 +00:00
Commit Graph

29059 Commits

Author SHA1 Message Date
Daniel Hilst dc4fb8f0c2 test(xcat-core): the netboot postinstall SELinux substitution is unanchored
Thirteen netboot postinstall scripts, and the xcat_inventory postinstall fixture,
disable SELinux in the rootimg with
s/SELINUX=enforcing\|permissive/SELINUX=disabled/. The second alternative is a bare
word with no key, so a config that reads SELINUX=permissive becomes
SELINUX=SELINUX=disabled. The same alternative matches the stock comment that names
permissive, which is rewritten on every image. sed returns 0 in both cases.

postinstall_selinux_config.bats runs each script over a scratch image root and reads
the config the script writes. Three of its six tests fail on this tree: the permissive
value, the already-disabled config and the comment.

The other three hold down behaviour the fix must keep. A no-op substitution turns the
enforcing test red, and a dropped -f guard turns the absent-config test red.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:35:52 -03:00
Daniel Hilst 76e57d4a08 docs(xcat-core): say what SELinux an operator gets
The branch changed what a cluster runs and added no documentation, while
the quick start guide still told the operator to write SELINUX=disabled
on the management node before installing xCAT.

docs/source/advanced/security/selinux.rst says which machine gets which
mode, why a stateless node runs with SELinux disabled, how to set
noderes.selinux and site.selinux, and that xcatd, in.tftpd, kea-dhcp4
and goconserver run in unconfined_service_t, so the work is about
running with SELinux enforcing and not about confining xCAT.

It also covers the upgrade: recordselinuxdefault runs on INITIALINSTALL
only, so an upgraded cluster has no site.selinux value, every node keeps
being provisioned with SELinux off, and reprovisioning is what gives a
node the new mode.

The quick start step now says SELinux can stay enabled and links there.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:35:22 -03:00
Daniel Hilst 4ee82d40d8 fix(xcat-core): a stateless node is told to run SELinux and cannot boot
netboot_supported() answered 1 for rhels8 and later and for every
openEuler, so mknetboot wrote no selinux= argument and a stateless node
was asked to run SELinux enforcing. It does not boot.

A stateless root is a cpio archive unpacked into tmpfs, and cpio carries
no SELinux label, so the root starts unlabelled. Three boots of an
AlmaLinux 10.1 image on an enforcing node measured both ways out of
that, on cluster xcat163:

- With the stock dracut selinux module, which this branch added to the
  module list, the policy loads at pre-pivot 50 over the unlabelled
  initramfs. 61 Permission denied lines follow, setfiles returns 126 and
  the node loops. That module ships with check() returning 255, so no
  image enables it by accident.
- Without it, and with the relabel hook corrected, setfiles labels the
  root: /usr/lib/systemd/systemd reads init_exec_t. systemd then loads
  the policy after switch_root, cannot relabel /dev or /run, and stops
  with "Failed to allocate manager object. Freezing execution".

The hook could not have worked as written either. It read the mode with
sed piped into tail, and the initramfs has neither tail nor chroot:
chroot arrived with the selinux module. The console reported "tail:
command not found" twice and relabelled nothing.

So netboot_supported() answers 0, mknetboot writes selinux=0 for every
stateless node and nodeset says why. The code that only serves a
stateless node with SELinux on is removed with it: the relabel hook and
its two installers, the selinux dracut module, write_image_config, and
the squashfs label machinery that stored labels nothing reads. The
netboot postinstalls and the stateless xcatroot write SELINUX=disabled
again, so the image says what the kernel command line does.

What stays is what was measured working: a diskful node provisioned
enforcing with zero xCAT denials, the kickstart templates, the policy
package, and the service node mount options.

Tests: selinux_netboot_kcmdline.t fails 34 of its 69 checks on the
parent commit. selinux_cn_diskless_disabled_by_design in cases1
provisions a stateless node asked for enforcing and requires selinux=0
on its command line and getenforce Disabled. selinux_image_config.t and
selinux_squashfs_labels.t go with the subs they tested.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:35:22 -03:00
Daniel Hilst b3038a2741 test(xcat-core): capture the stateless SELinux claim that no node meets
netboot_supported() answers 1 for rhels8 and later and for every
openEuler, so mknetboot omits selinux=0 and a stateless node is told to
run SELinux. No stateless node has been measured booting that way.

This test asserts the opposite: every OS answers 0, every mode gets
selinux=0, and no dracut module ships a relabel hook. It fails on this
commit, which is the point. The walk of the netboot tree carries a
positive control, so an empty hook list means the hooks are gone and not
that the walk looked nowhere.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:34:42 -03:00
Daniel Hilst 89dee4de1e fix(xcat-core): the SELinux AVC checks assert no denial of any kind
Eight checks in the selinux testcases asserted ausearch output =~ "<no
matches>", which is zero denials of any kind in the window. A cluster
denies things xCAT has nothing to do with. On an idle enforcing
management node httpd asks the kernel for net_admin on itself every ten
seconds, and the base policy carries no dontaudit rule for that shape.
One node logged 1034 denials in a day, 817 of them that one shape. So
the assertion cannot pass once ausearch is called correctly, and before
--input-logs was added it could not fail.

selinux_avc_check.sh keeps the denials whose subject program or object
path belongs to xCAT and counts those. The cases assert XCAT_AVC=0.
selinux_mn_labels now also plants a denial on purpose: it mislabels
/install/postscripts/xcatdsklspost, shows httpd answering 403, and
requires the check to report XCAT_AVC=[1-9] before restoring the label.
A counting method with no positive control cannot be trusted to find
anything.

restorecon -RnvF reports a difference in the SELinux user as well as the
type, and the files xCAT writes carry unconfined_u. On one node -RnvF
printed 12 lines over /install where -Rnv printed 2. The checks use
-Rnv, which is the type they assert.

The six cases were in no bundle and in no pipeline conf, so none had
ever run, which is why the dead checks were not noticed.
selinux.bundle and selinux_mn.bundle name them, and selinux_bundle.t
fails when a case is in no bundle.

Tests: selinux_avc_check.bats drives the classifier with records
measured on an enforcing management node. Replacing the filter with one
that keeps every record fails 4 of its 8 checks; dropping the
object-path branch fails 2. selinux_bundle.t fails when selinux.bundle
is removed. selinux_kickstart_template.t asserted the relabel order with
a regex that matched wherever the relabel sat; it now compares line
positions, and moving #SELINUXRELABEL# above the xCAT post includes
fails it.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:34:36 -03:00
Daniel Hilst d9924c41ae fix(xcat-core): every AVC check in the selinux cases reports clean
cases0 and cases1 call ausearch eight times to assert that a step produced
no AVC denial. On el10, audit 4.0.3 ships an ausearch that reads the
journal, and the journal carries no audit records. Measured on an
enforcing management node: "ausearch -ts today" returns 0 records while
"ausearch --input-logs -ts today" returns 11261, and the raw log holds
1032 denials. So each of the eight checks reports no denials whatever the
node does, and the suite cannot fail.

Add --input-logs to all eight. The option makes ausearch read
/var/log/audit/audit.log, which is where auditd writes.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:33:48 -03:00
Daniel Hilst fabfaedc89 feat(xcat-core): provision compute and service nodes with SELinux enabled
Every compute and service node was provisioned with SELinux disabled.
mknetboot added selinux=0, the kickstart templates said selinux
--disable, and the genimage postinstall and the dracut hooks wrote
SELINUX=disabled into the image. noderes.selinux and site.selinux had no
consumer on the node side.

The mode that xCAT::SELinux->node_modes resolves now reaches the node:

- Kernel command line: mknetboot appends kcmdline_selinux(): selinux=0
  for disabled, enforcing=0 for permissive, nothing for enforcing. An
  image built without the relabel hook (EL7 and older), and a squashfs
  image without labels, boot with selinux=0 and nodeset says why.
  Test: selinux_netboot_kcmdline.t.
- Kickstart: #SELINUXMODE# and #SELINUXRELABEL# in xCAT::Template. The
  rh el8/9/10, riscv64 and openEuler templates use them; the %post ends
  with restorecon -RF over the paths the xCAT scripts write. mkinstall
  warns when a template cannot express the mode of the node.
  Test: selinux_kickstart_template.t.
- genimage: the el8-10 postinstalls no longer write SELINUX=disabled, and
  the stateless xcatroot no longer writes /etc/sysconfig/selinux. genimage
  sets SELINUX=enforcing in the image, adds dracut 98selinux, and installs
  a pre-pivot hook that runs setfiles with the image file_contexts unless
  selinux=0 is set. Tests: selinux_image_config.t, selinux_relabel_hook.bats.
- packimage -m squashfs stores the labels of the image policy through
  mksquashfs pseudo xattr definitions (squashfs-tools 4.6 or later), and
  writes rootimg.sfs.selinux beside the image. Test:
  selinux_squashfs_labels.t.
- Service nodes mount /install and /tftpboot from the management node with
  context=public_content_t and tftpdir_t when SELinux is on.
  Test: selinux_sn_mount_options.t.
- makedns no longer warns about SELinux. xcatprobe xcatmn checks the xcat
  module and the labels of installdir and tftpdir instead of failing on
  enforcing. Test: probe_utils_selinux_policy.t.

The selinux/cases1 xcattest cases provision a diskful, a stateless and a
squashfs node enforcing, and a stateless node with site.selinux=disabled.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:33:16 -03:00
Daniel Hilst 9b469b68d5 feat(xcat-core): record the SELinux default at the first install
xcatconfig recorded no SELinux mode at the first install, so an enforcing
management node left site.selinux unset and its nodes were provisioned
with SELinux disabled.

At the first install, xcatconfig now sets site.selinux to enforcing when
the management node is enforcing, and to disabled when it is permissive
or disabled. xCAT::SELinux->install_default makes the decision. An
existing site.selinux value stays, and an upgrade does not set it.
xcatconfig does not change the SELinux mode of the management node.

With the existing value ignored, 12 checks of xcatconfig_selinux_policy.t
fail. With a permissive mode recorded as permissive, 4 checks fail.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:30:47 -03:00
Daniel Hilst 057fe98ccf test(xcat-core): capture the site.selinux default of a first install
xcatconfig records no SELinux mode at the first install. A management
node that is enforcing therefore leaves site.selinux unset, and its nodes
are provisioned with SELinux disabled.

xcatconfig_selinux_policy.t now drives xCAT::SELinux->install_default for
each runtime mode with no value, an empty value and each existing value.
Only an enforcing node records enforcing, and an existing value is kept.
The test dies on this commit because install_default does not exist.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:30:47 -03:00
Daniel Hilst 9923aadb11 feat(xcat-core): resolve the SELinux mode of each node
No code resolved the SELinux mode of a node, so each provisioning path
would have to repeat the precedence and the platform rules.

xCAT::SELinux->node_modes returns the mode for each node. The noderes row
of the node comes first, then the noderes rows of its groups, then
site.selinux, then disabled. A node or group row can enable SELinux when
site.selinux is disabled. A node resolves to disabled when its OS is not
in the Red Hat, Fedora or openEuler families, when its OS is not known,
and when the node or its osimage is statelite. The OS and the provisioning
method come from the osimage row when nodetype.provmethod names one. An
optional hash reference receives the reason for each such clamp.

With the clamp removed, 7 checks of selinux_node_modes.t fail. With the
site value read before noderes, 5 checks fail.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:30:46 -03:00
Daniel Hilst 7e495f118a test(xcat-core): capture how the SELinux mode of a node is resolved
No code resolves the SELinux mode of a node from noderes.selinux and
site.selinux. Each provisioning path would need to repeat the precedence
and the platform rules.

selinux_node_modes.t drives xCAT::SELinux->node_modes with Perl stubs for
the noderes, nodetype and osimage tables and for site.selinux. It covers
the node row, the group row, the site value, an absent site value, a node
that enables SELinux under a disabled site, an invalid value, the SLES and
Ubuntu clamp, the osimage OS and the statelite clamp. The test dies on
this commit because node_modes does not exist.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:30:46 -03:00
Daniel Hilst e0c12830fd feat(xcat-core): add site.selinux and noderes.selinux
xCAT had no attribute that selects the SELinux mode of a node.

site.selinux holds the default mode for the cluster. The values are
enforcing, permissive and disabled, and an unset key means disabled. The
new noderes.selinux column overrides it for a node or a group, and chdef
and lsdef show it as the selinux attribute of node and group objects.
Nothing reads the attributes yet.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:30:46 -03:00
Daniel Hilst c922dbcf52 test(xcat-core): capture the missing SELinux mode attributes
xCAT has no attribute that selects the SELinux mode of a node. The site
table help does not describe a selinux key, and noderes has no selinux
column, so neither the admin nor the provisioning code can set a mode per
site, group or node.

selinux_schema.t loads xCAT::Schema and checks the noderes.selinux column,
its description, the node and group object attribute, and the site.selinux
help. 18 of its 19 checks fail on this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 10:30:46 -03:00
Daniel Hilst c12dfe3063 Merge remote-tracking branch 'upstream/master' into feat/selinux-netboot 2026-10-21 10:30:06 -03:00
Daniel Hilst ee6b4f5328 Merge pull request #7964 from VersatusHPC/fix/ci-run-bats-after-perl-failure
fix(ci): run Bats after Perl unit failures
2026-10-21 09:33:40 -03:00
Vinícius Ferrão e87e226412 Merge pull request #7963 from KevinSpek/fix-dead-links
docs: replace the dead GitGuys reference for remote branches
2026-10-21 09:22:52 -03:00
Daniel Hilst 3a7c1d66a8 Merge master into feat/selinux-netboot
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-21 08:53:16 -03:00
Daniel Hilst 47168d7adf Merge pull request #7934 from VersatusHPC/refactor/r26-provisioning-reuse
refactor(provisioning): share package defaults and identical profiles
2026-10-21 08:21:57 -03:00
Daniel Hilst c0724ea08c Merge pull request #7959 from VersatusHPC/test/r26-oe-behavior-gaps
test(genesis): cover console interaction and NetworkManager policy
2026-10-21 07:59:14 -03:00
Vinícius Ferrão 9653713bdd test(ci): cover Perl and Bats failure combinations
Exercise the full driver with either or both unit suites failing. Check
execution order, both result messages, and the final exit status.

Allow multiple command failures in the fixture. Encode logged commands as
JSON arrays for compatibility with older JSON::PP versions.
2026-10-20 16:20:29 -03:00
Vinícius Ferrão a1b2ac7a80 fix(ci): run Bats after Perl unit failures
Run both unit suites before stopping the CI driver. Preserve the failure
of either suite and leave later phases blocked when either suite fails.
2026-10-20 16:14:13 -03:00
Vinícius Ferrão 32a98d6d99 docs(test): describe Genesis policy and terminal coverage 2026-10-20 13:09:32 -03:00
Vinícius Ferrão 8dab5e4989 test(genesis): exercise maintenance shell confirmation and return 2026-10-20 13:09:32 -03:00
Vinícius Ferrão 385f641e03 test(genesis): exercise journal follow and navigation 2026-10-20 13:09:32 -03:00
Vinícius Ferrão 2281b14a13 test(genesis): exercise live console status and diagnostics 2026-10-20 13:09:31 -03:00
Kevin 3926cafcff docs: replace the dead GitGuys reference for remote branches 2026-10-20 18:42:34 +03:00
Vinícius Ferrão 516e915bcc test(genesis): exercise the NetworkManager wait-online policy 2026-10-20 12:03:51 -03:00
Vinícius Ferrão 214cbd4c9a test(profiles): accept owner-only executable source assets
A restrictive checkout umask can remove group and other execute bits.
Require the owner execute bit on source postinstall files and reject all
execute bits on data files. Native package tests still require exact modes.
2026-10-19 19:47:59 -03:00
Vinícius Ferrão fa233e6d36 test(packaging): cover Debian profile permissions from writable sources
Preserve source modes when staging Debian package builds and accept a
private source fixture. Build group-writable profiles under umasks 0022
and 0002, then check the extracted data, postscripts and directories.

Verify that staging and packaging leave source permissions unchanged,
including a world-writable data file. Reuse the payload checks for normal,
reduced and permission-regression builds.
2026-10-19 19:33:33 -03:00
Vinícius Ferrão 0ad1448564 fix(packaging): remove write access from Debian profile payloads
Group-writable sources leave install and netboot assets writable by other users in the Debian package. Remove group and other write permission from those two staged trees. Preserve executable bits and leave source files and the rest of the payload unchanged.
2026-10-19 19:31:25 -03:00
Vinícius Ferrão fa29763b71 test(profiles): allow group-writable source checkouts
Check executable bits when selecting source profiles. Exact package modes remain covered by the native payload test.
2026-10-19 19:29:44 -03:00
Vinícius Ferrão 91e19b16b1 test(profiles): check packaged modes independently of checkout
RPM preparation removes group write permission from source files. Assert the packaged data and postinstall modes instead of comparing them with checkout permissions. Report modes in octal and keep the content, alias and customization checks.
2026-10-19 19:29:26 -03:00
Daniel Hilst 306723152f Merge pull request #7958 from VersatusHPC/fix/genesis-journal-selection
fix(genesis): retain the selected journal entry across history rollover
2026-10-19 16:14:11 -03:00
Daniel Hilst 37a25b0fbc Merge master into feat/selinux-netboot
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-19 16:11:59 -03:00
Vinícius Ferrão 7f3a0acf8e test(profiles): retain Rocky assets in the reduced RPM 2026-10-19 12:17:03 -03:00
Vinícius Ferrão 16ebc98702 test(ubuntu): cover package-list aliases across releases and architectures 2026-10-19 12:17:03 -03:00
Vinícius Ferrão 0d1e044ea9 refactor(ubuntu): share identical release and architecture package lists 2026-10-19 12:17:03 -03:00
Vinícius Ferrão 4a894610a5 test(profiles): exercise packaged assets and custom profile precedence 2026-10-19 12:17:03 -03:00
Vinícius Ferrão adaff490cf refactor(profiles): share identical EL10 RISC-V assets
Use relative aliases for identical shipped profiles. Keep their public names,
resolved contents and executable modes. Custom copies remain independent.
2026-10-19 11:48:36 -03:00
Vinícius Ferrão a13ecfe9c6 test(ubuntu): cover shared mirror defaults through provisioning callers 2026-10-19 11:30:49 -03:00
Vinícius Ferrão 2a5b55da47 refactor(ubuntu): share architecture-specific APT mirror defaults 2026-10-19 11:30:48 -03:00
Vinícius Ferrão 6931621d65 test(pkglist): cover shared line filtering through both readers
Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com>
2026-10-19 11:30:48 -03:00
Vinícius Ferrão db6cec2b80 refactor(pkglist): share package-list line filtering
Share line normalization and directive filtering across the legacy text
reader, its include reader and the record reader. Keep leading whitespace
in legacy includes and leave each parser expansion policy unchanged.

Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com>
2026-10-19 11:30:48 -03:00
Vinícius Ferrão f9024b9fd2 docs(test): describe journal selection rollover coverage 2026-10-18 19:28:55 -03:00
Vinícius Ferrão 53a2b75d49 test(genesis): cover paused journal selection during rollover 2026-10-18 19:28:55 -03:00
Vinícius Ferrão 5d125637ee fix(genesis): retain the selected journal entry across history rollover
A paused journal view restores a row number after refreshing its history.
When older records leave the window, that row selects a different entry.

Match the selected entry by its journal cursor and retain its wrapped-line
position. If the entry has left the window, select the oldest retained row
without resuming follow mode.
2026-10-18 19:06:39 -03:00
Daniel Hilst b5f48f2089 Merge pull request #7956 from VersatusHPC/fix/genesis-first-journal-entry
fix(genesis): retain the first entry in the journal view
2026-10-17 18:55:12 -03:00
Daniel Hilst 44386f7a47 Merge pull request #7960 from VersatusHPC/fix/imgimport-restore-boot-files
fix(imgport): put back the image when its definition cannot be written
2026-10-17 18:53:05 -03:00
Vinícius Ferrão 431bd0c23f test(imgport): cover the boot files after a failed definition write
Each failure of the definition write runs over a published image, an
image without a checksum, a new image, or a statelite image. The
previous root image, checksum, metainfo, kernel and ramdisk must be
back, and the files of a new image must be gone. When a row does not go
back, also after a changed rootimgdir, the new files must stay. The
publication lock must be held during the writes and released after
them. A row written before its call failed must keep the new files.
2026-10-17 00:16:05 -03:00
Vinícius Ferrão c0f1bef473 fix(imgport): put back the boot files when the definition is not written
imgimport publishes the root image, kernel and ramdisk before it writes
the image definition. When the database refused or failed a write, the
new boot files stayed with the previous definition.

The import now holds the publication lock of the image from before it
places the files until the outcome of the definition is known. When the
definition is not written and its rows went back, it puts back the
previous files, with the checksum and metainfo of the root image. It
removes the files that had no previous version. While a row did not go
back, the new files stay, as that row can refer to them.
2026-10-17 00:16:05 -03:00