xCAT-server/lib/xcat/plugins/anaconda.pm conflicted in the module
imports: this branch adds "use xCAT::MediaPerms" and master adds
"use xCAT::SELinux" on the same line. Both imports are kept. The two
modules are used in different subs, and no other hunk conflicted.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
With nodeauthentication off and no peer name, getpostscript used
_xcat_authname as the client identity and expanded it with noderange.
becomeuser and tokens set _xcat_authname to an account name, so a user
named after a node group received the postscripts of the first node in
that group.
xcatd now records the CN of the validated client certificate as
_xcat_certname, and only while no becomeuser or token replaced it. It
deletes any _xcat_certname the client sent. getpostscript uses that
name only when it names exactly one node, with no group or range
expansion. _xcat_authname is no longer a candidate.
getpostscript_client_identity.t drives the plugin with these requests.
On the previous head the group and node login checks fail, and
dropping the exact match fails the group and range checks.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
xCAT installs on the leap15.6 node and the install gate still fails:
GATE FAIL: xcatd not active
GATE FAIL: lsdef cannot reach xcatd
GATE FAIL: site.xcatdport not seeded
journalctl for xcatd has no entries, and loading the library by hand on the
node says why:
Can't locate JSON.pm in @INC ... (@INC contains: /opt/xcat/lib/perl ...)
openSUSE has no perl-generators. Nothing generates a perl(...) requirement for
any xCAT package there, so no spec installs the modules its code loads, and
perl-xCAT names no Requires at all. Measured on xcat20-mn against the 85
external modules the EL build auto-requires: five are absent -- Date::Parse,
Expect, HTML::Form, JSON and SNMP -- and the other 80 are present.
Each openSUSE branch now names the modules EL's generator emits for that
package, as capabilities, so the same core build serves the sles15 and sles12
cells: both Leap releases provide all five, from perl-TimeDate, perl-Expect,
perl-HTML-Form, perl-JSON and perl-SNMP.
Verified with rpmspec that only openSUSE gets these; EL and openEuler are
unchanged and keep generating them.
xCAT-test/unit/opensuse_mn_requires.t fails on the commit before this one.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
xcatd fills _xcat_clienthost and _xcat_clientfqdn from a reverse lookup of the
client socket, so both are empty when that lookup fails, however good the
client credentials are. A plugin that asks only for the peer host therefore
cannot identify a node whose certificate names it correctly.
xCAT::DiscoveryUtils::request_client_names returns the names a request offers,
most trustworthy first: the peer host, its fully qualified form, then
_xcat_authname, which is the name in the validated client certificate and does
not depend on name resolution. The request's own node attribute is excluded on
purpose -- a client sends it, so it states what the client wants to be rather
than what it proved it is, and postscripts carry the cluster root ssh key.
xCAT-test/unit/getpostscript_client_identity.t drives the routine directly: the
request hash is its only input and a list of names its only output. It fails on
five mutants of the routine, each naming the assertion it breaks -- the
certificate name dropped (2 checks), the empty-name guard dropped (1), the
client-supplied node offered (3), the de-duplication dropped (2), and the
array-ref guard dropped (1).
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
Twelve conflicts, all from xcat-core/#7970 landing.
Eleven are the one sed line in the netboot postinstall profiles, where #7970 and
this branch replaced the same line with different patterns. Master's wins: it
anchors on optional leading blanks and preserves a trailing comment, which this
branch's `s/^SELINUX=.*$/SELINUX=disabled/` would have eaten. This branch's own
postinstall_selinux_config.bats asserts "the comment that names permissive keeps
its text", so the better pattern is the one its test already wanted -- 6 of 6
pass on master's version. What master's pattern does not catch is a value
outside enforcing|permissive, which nothing here tests and no stock config
ships.
The twelfth is .github/workflows/xcat_test.yml: master added a step to the
existing job and this branch adds a whole selinux_policy_test job after it.
Resolved as the union, with master's step where it put it; the file still parses
and names three jobs.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
Some aarch64 UEFI firmware ignores a DHCP boot file name that does not
end in .efi and requests grubaa64.efi from the TFTP root instead. xCAT
names grub2-<node>, so these nodes stop with a TFTP error before grub2
runs.
For an aarch64 node, nodeset now links grub2-<node>.efi to
grub2.aarch64 beside grub2-<node>. Both DHCP backends name the .efi
link once it exists in the node's TFTP directory (noderes.tftpdir, or
the site one). A node set by an older xCAT keeps grub2-<node> until its
next nodeset, so makedhcp after an upgrade does not name a missing
file. With site.sharedtftp off, every server that runs nodeset for the
node creates both links. This relies on service nodes running the same
xCAT version as the management node, which xCAT requires.
The old link stays for DHCP configurations that makedhcp did not
write. The boot and offline states remove both links. Other
architectures keep grub2-<node>.
Two statements about this branch are narrower than the code.
Commit 1edcddab8 says a node with a machine type xCAT cannot judge
"failed at mkvm". firmware_machine_error is returned by build_xmldesc,
and makedom calls build_xmldesc for a node whose domain is not yet built,
so the refusal also reaches the rpower boot of that node. The POD of
firmware_machine_error now names both callers.
The Secure Boot section of the ipxe guide did not name
firmware:efi-secureboot at all. It now says what mkvm asks libvirt for,
why both the secure-boot feature and enrolled-keys are asked for, and
what a hypervisor without such a firmware answers.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
guest_os stated <loader secure='yes'/> alone for a node with
vm.othersettings firmware:efi-secureboot. libvirt reads that element as
the secure-boot feature, and a firmware with secure-boot and an empty key
store boots an unsigned binary. The two x86_64 descriptors of an EL 10
host name the same OVMF_CODE.secboot.fd and differ in the nvram template,
OVMF_VARS.secboot.fd against OVMF_VARS.fd, so only descriptor priority
picked the one that holds keys. Commit 772b2c656 of this branch says that
element selects the descriptor with enrolled keys. It does not.
firmware_features names secure-boot and enrolled-keys for a Secure Boot
guest, and add_firmware_features writes them into the <os> of the domain.
guest_os cannot carry the element: the firmware attribute of <os> and the
<firmware> child of <os> are one key of one hash for XMLout, and the
attribute is the one that starts the selection. firmware:efi asks for no
feature and is unchanged.
Measured with libvirt 11.10.0 on an x86_64 host, with the enrolled
descriptor masked for one connection: the old XML starts on OVMF_VARS.fd
with enrolled-keys resolved to no, and the new XML is refused with
"Unable to find 'efi' firmware that is compatible with the current
configuration". virt-xml-validate accepts the new XML.
kvm_secureboot_firmware.t covers the features and the element. Two
mutations turn it red: dropping enrolled-keys from firmware_features, and
making add_firmware_features return its argument.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
firmware_machine_error refused every machine type that did not contain
q35, so a node with firmware:efi and a machine type xCAT does not know
failed at mkvm. xCAT does not know which machine types a hypervisor
offers, and reg_linux_diskless_installation_flat relies on mkvm accepting
machine:invalid so that it can measure the provisioning failure that
follows. That case failed at the mkvm before it reached the measurement.
The guard now names the i440fx family alone: pc, pc-i440fx-* and
i440fx-*, whose descriptors carry no UEFI firmware. Any other value goes
to libvirt, which reports a machine type it cannot use.
kvm_secureboot_firmware.t covers both halves, and a mutation that
restores the q35 test turns the invalid-machine check red.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
guest_arch_profile moves an x86_64 node that asks for efi to q35, because
every x86_64 OVMF descriptor targets pc-q35-* only. guest_os then writes
a machine: setting of vm.othersettings over that machine type, so a node
with firmware:efi and machine:pc reaches libvirt asking for a UEFI
firmware on i440fx. libvirt answers "Unable to find 'efi' firmware that
is compatible with the current configuration" and names neither the node
nor either setting, and rpower boot fails with no way to see why.
firmware_machine_error refuses the pair, and build_xmldesc returns it
before the domain is built. The message names the node, both settings and
the machine type to use. A node that names no machine type, a q35 of any
version, and the machine types of another architecture are all unchanged.
kvm_secureboot_firmware.t covers the refusal and the five values that are
not refused.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
A node with netboot=ipxe and Secure Boot on fetches the shim of its
install source over HTTP, and the server answers 403. EL media ships the
EFI binaries of its boot loader mode 0700, copycds copies the media with
the modes the media carries, and xCAT serves the install directory over
HTTP. Measured on an AlmaLinux 10 tree: EFI/BOOT/grub.cfg is 0444 and
answers 200, and BOOTX64.EFI, grubx64.efi and mmx64.efi are 0700 and
answer 403. The node reports "Verification failed: Security Policy
Violation" for its kernel and then "Operation not permitted" for the
shim, and boots nothing.
copycd gave the top directory of the copy mode 0755 and left every path
under it as the media had it. Both copycd plugins now call
xCAT::MediaPerms::make_readable on the copied tree, which adds read
permission for the group and for others, and search permission on a
directory. It adds no write permission, it adds no execute permission to
a file, and it leaves a path that is already group and other readable
alone, so a second call changes nothing.
On the same AlmaLinux 10 tree it walks 5850 paths, 5835 files and 15
directories, and changes 3 of them: the three files above, each from 0700
to 0744. An install tree that is already copied keeps its modes until
copycds runs again for that osimage, so an operator with an existing tree
re-runs copycds or gives those files read permission.
media_perms_readable.t covers the modes and the idempotence. Three
mutations of the module each turn it red.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
vm.othersettings now takes firmware:efi-secureboot. guest_os puts
<loader secure='yes'/> on the domain beside firmware="efi". libvirt
reads that element while it selects the firmware and keeps only the
descriptors that carry secure-boot, so a hypervisor with no such
firmware refuses the domain instead of starting the node on a firmware
that verifies nothing.
firmware:efi keeps its meaning and states no requirement.
Measured with libvirt 11.10.0 on an x86_64 host: the domain resolves to
OVMF_CODE.secboot.fd with <smm state='on'/>, and the same domain with
secure-boot asked off resolves to OVMF_CODE.fd.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
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>
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>
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>
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>
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>
UFTP multicast distribution of the root image needs a switch for each
image and a default for the cluster, as the root image checksum has.
site.rootimgtransport sets the default, which is http when it is unset.
The rootimgtransport attribute of an osimage overrides it.
rootimg_transport returns http or uftp, and refuses any other value with
the name of the attribute that holds it.
kvm.pm made $parser, $node, $confdata and $updatetable package
variables so that kvm_uefi_firmware.t could set them and call
build_xmldesc and reconfigvm. That exposes plugin state to make it
testable, which xCAT::KVMUtils replaced for the other guest decisions.
xCAT::KVMUtils now holds vm_othersettings, requested_firmware,
firmware_error, guest_os, clock_offset and reconfigure_domain. Each one
takes its inputs as arguments. guest_os replaces build_oshash and the
<os> edits in build_xmldesc. reconfigure_domain replaces the XML
rewrite in reconfigvm and loads XML::LibXML when it is called. kvm.pm
calls these subs, and the four variables are file lexicals again.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
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>
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>
chtab -d called delEntries on each table that it named without a check
that the table opened. A table name that xCAT does not know made chtab
die after it had deleted the rows of the tables named before it. The
error was "Can't call method delEntries on an undefined value".
The delete moves to xCAT::TableUtils->delete_rows, which opens every
named table first. When a table does not open, it deletes no row and
returns the table name. chtab -d reports that table with the error of
the update form.
preferred_video_model returned vga whenever no preferred model was
found, also when the hypervisor did not offer vga, did not support video,
or the capability query failed. Under native aarch64 KVM, vga and the
other PCI framebuffer models do not display correctly.
An aarch64 guest now takes the first offered model of virtio and ramfb
under KVM, or of virtio, vga and ramfb under TCG. When video is
unsupported or no wanted model is offered, build_xmldesc writes no
<video> and no <graphics>, and the guest uses its serial console. When
the capabilities are unavailable, build_xmldesc returns an error that
names the query error and vm.vidmodel.
vm.vidmodel still overrides the choice. Other architectures do not
query the capabilities and keep their fixed model.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
rollback did not mark the caches of the rolled-back tables as stale. A
cached read after a write and before the rollback kept the rejected
value. Cached readers then got it for up to 5 seconds after the
rollback. MySQL and PostgreSQL share one handle among tables, so a
rollback through one table also undoes the changes of the others.
rollback now refreshes the cache of every table on its handle.