xCAT-test/autotest/testcase/commoncmd/vm_machine_type.sh conflicted:
this branch picks q35 for an x86_64 node with firmware:efi, and master
asks the vmhost libvirt for the machine type. The vmhost probe from
master is kept. vm_machine_type_alias now takes the vmothersetting and
returns q35 for firmware:efi, and q35 does not fall back to the libvirt
default, because the x86_64 default is i440fx.
xCAT-test/bats/vm_machine_type.bats conflicted where both sides added
tests before assert_round_trip. Both sets are kept, with the
assert_round_trip of this branch, plus one test for the q35 rule.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
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>
selinux_avc_classify matched the entries of XCAT_AVC_PATH as string prefixes,
with [^"]* before the alternation and no boundary after it. A directory name
is not a string prefix: /var/lib/xcat-cluster-test is not /var/lib/xcat, and
/installer is not /install.
The CI writes its regnotif notification hook to
/var/lib/xcat-cluster-test/event-notify.pl. xcatd executes it, the file
carries var_lib_t, and xcat_t has no execute_no_trans on it, so the audit log
holds the record. The classifier kept it on the strength of the prefix, the
count read XCAT_AVC=1, and selinux_cn_diskful_enforcing failed on a file the
product does not ship. The policy was confining xcat_t correctly.
The path half of the pattern now starts at the opening quote and ends at a /
or at the closing quote, so a listed directory matches itself and the files
under it, and nothing else. The subject half is unchanged: a denial by an
xCAT program is still kept whatever the path.
selinux_avc_check.bats covers it. Reverting the boundary group fails the
sibling-path test alone; requiring a trailing / fails the bare-directory test
alone.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
node_pingable asks ICMP up to PING_TRIES times and stops at the first answer,
so a few seconds of loss after a node boots no longer forces a second full
rinstall. A node that never answers still reports non-pingable, and the caller
still vetoes it: the signal is kept, not removed.
The probe is lifted into a function with a main-guard rather than left inline,
so a bats test can drive it without running a provisioning loop or needing an
xCAT database. Nothing sources this script -- all nine callers execute it -- so
the guard changes no caller.
The happy path is unchanged at one ask. A node that never answers now costs
PING_TRIES asks before the verdict, which is under a minute against the six
minutes of the reinstall it decides.
retry_install_transient_icmp.bats passes 5 of 5. Removing the bounded retry
fails assertions 2 and 4, which are the retry properties, and leaves assertion 3
passing -- a node that never answers is still not pingable. That assertion is
the discriminator: without it the change could not be told apart from deleting
the check, which would turn a flaky probe into one that cannot fail.
xCAT-test/bats is 596 passed, 19 failed. All 19 are
xcatroot_rootimg_checksum.bats, which reports 0 passed and 19 failed on
upstream master with none of this branch applied.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The diskless cases snapshot the mount table before genimage and after it and require the two to
be identical, ignoring only fusectl. The comparison is there to catch a bind mount genimage
leaves inside the root image, which is worth catching.
It also fails for mounts the kernel makes on its own. binfmt_misc is an autofs stub that becomes
a real mount the first time a process reads /proc/sys/fs/binfmt_misc, and tracefs appears under
/sys/kernel/debug the first time anything opens debugfs tracing. On openeuler22.03sp4 both
appeared during genimage and failed reg_linux_diskless_installation_flat four minutes into a
1168 second case, while the provisioning that followed succeeded and the node reached booted.
The single fusectl exclusion shows the same class was met once before and patched by name.
mount_snapshot.sh drops the mounts whose mount POINT is under /proc or /sys, which is where the
kernel keeps its on-demand mounts, and the three cases take their snapshots through it. Dropping
them by filesystem TYPE would hide the leak the comparison exists for, because a leaked genimage
bind is itself a proc or sysfs mount. fusectl needs no exclusion of its own any more.
mount_snapshot.bats covers both directions. Taking the filter out fails the two
ignore-the-kernel assertions and keeps both leak assertions; filtering by type instead of by
mount point fails only the leaked-bind assertion. A test-only commit would skip rather than fail,
because require_repo_file skips when the script is absent, so the proof is those two mutations.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
reg_linux_diskless_installation_flat fails on every ppc64le cell. rpower boot
leaves the compute node down and libvirt reports "unsupported configuration:
Emulator '/usr/bin/qemu-system-ppc64' does not support machine type
'pseries-rhel7.6.0'".
vm_machine_type_for_arch in vm_machine_type.sh answered machine:pseries-rhel7.6.0
for every ppc64 architecture. The ppc64le hypervisor runs AlmaLinux 10, whose
qemu-system-ppc64 declares pseries-5.0 to pseries-10.2 and no rhel machine type,
so the name the case writes cannot be defined there.
The function now reads the vmhost of the node and asks that host's libvirt. It
writes the plain alias when libvirt accepts it, that libvirt's own default when
it does not, and the alias when the vmhost cannot be asked. x86_64 keeps
machine:pc, which is an alias and stays valid.
xCAT-test/bats/vm_machine_type.bats covers it. Nine of its tests fail on the
previous commit, among them "the vmhost accepts the machine type that comes
back" and "the machine type is the alias the vmhost accepts".
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>
Exercise certificate policy and real SSH copies in a disposable MN/SN/node fixture. This test is opt-in and skips in ordinary CI without XCAT_SYNCFILES_LIVE_CONFIG.
reg_linux_diskless_installation_flat asks vm_machine_type.sh for a valid
machine type, and the helper answers machine:pc for every x86_64 node. A
node with firmware:efi then cannot boot: libvirt refuses a UEFI firmware
on i440fx, rpower boot fails and the case reports a provision failure
that has nothing to do with provisioning.
vm_machine_type_for_arch now reads the vmothersetting it saved and
answers machine:q35 for an x86_64 node that asks for a UEFI firmware. An
x86_64 node without one still gets machine:pc.
vm_machine_type.bats covers both, and a mutation that answers machine:pc
for a UEFI node turns the two new tests red.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The SELinux cases marked their audit window with date "+%H:%M:%S" and
gave it to selinux_avc_check.sh. Two failures follow from the time
window. The body of selinux_mn_labels runs inside one second, so an el9
run reported SEARCHED=0 and the guard called a quiet node a usage error.
And ausearch -ts has one second of granularity, so the denials that the
positive control of selinux_mn_labels creates on purpose landed in the
window of selinux_restapi_avc, which failed with XCAT_AVC=2 on two
httpd_t getattr records it did not cause.
selinux_avc_check.sh takes a checkpoint file: --init consumes the
records written so far and prints BASELINE, --since reports the denials
after that point. A checkpoint is an offset, so an empty answer has one
meaning and two cases cannot read one record. Each case opens its own
checkpoint, and the positive control opens a second one, which also
removes the sleep 1 that the granularity needed.
The count refuses an answer that is neither a record nor '<no matches>',
so an ausearch error message cannot read as a clean window. The -ts form
stays for the keywords boot and today, and now asks for today's records
before it calls an empty window a usage error.
/xcatpost is reported and no longer asserted on a compute or service
node. The kickstart relabel runs in %post, the xCAT post scripts write
that tree at the first boot, and the node carries no xCAT-selinux, so a
clean restorecon -Rnv there is not what the design promises.
selinux_avc_check.bats fails 7 of its 15 checks without this change, on
rome01.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The case ran xcatprobe xcatmn through grep -i selinux and checked the rc
of the pipeline. Nothing in the output named SELinux, so grep exited 1,
the case failed with an empty output, and the log carries no checkpoint
and no reason. The probe prints every checkpoint, so the diagnostics
existed and the filter threw them away.
The case now runs the probe with -H, which runs the checks on this node
instead of dispatching them, and keeps the whole output. It asserts that
the SELinux checkpoint is marked [ OK ] and is not marked [FAIL], which
xcatprobe writes for a checkpoint that passes and one that fails. It no
longer asserts the rc of the probe: a management node under test can
report another checkpoint as a problem, and that is not this case.
probe_xcatmn_selinux_case.t fails 3 of its 11 checks without this change,
on rome01.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The cases marked the start of their window with date "+%x %T" and gave
it to ausearch. audit 4.0.3 takes a bare HH:MM:SS and rejects that
format: it prints nothing and exits 0. Measured on an enforcing
AlmaLinux 10.2 management node, with the raw log holding 4197 records:
"-ts 10/21/2026 20:59:08" returned 0 records, "-ts 20:59:08" returned
22 and "-ts today" returned 4006. So selinux_avc_check.sh searched
nothing and reported XCAT_AVC=0 whatever the node did.
The positive control of selinux_mn_labels is what found it. The case
mislabels /install/postscripts/xcatdsklspost, shows httpd answering 403
and requires the check to report XCAT_AVC=[1-9]; it reported
SEARCHED=0 AVC=0 XCAT_AVC=0 and the case failed on an enforcing el10
node.
The four cases now write date "+%H:%M:%S". selinux_avc_check.sh refuses
a window that holds no audit record at all, because that is not a
credible answer on a running node, and names the format in the message.
selinux_avc_check.bats fails its ninth check against the unguarded
script.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
selinux_cn_statelite_disabled_by_design ran nodeset against the
statelite osimage without building it. copycds declares the osimage, and
nodeset needs the image tree and the litefile links that genimage and
liteimg create, so the case failed on a fresh cluster for a reason that
has nothing to do with SELinux.
Build the image in the case.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The selinux cases cover the management node and a compute node. A
hierarchical cluster has a service node, which installs xCAT itself and
serves /install and /tftpboot to its own nodes, and nothing measured it
under SELinux. A statelite node was not measured either, although
node_modes resolves it to disabled on purpose.
selinux_sn_enforcing reads the provisioned service node: getenforce,
the kernel command line, the xcat policy module, the labels of /install,
/tftpboot, /opt/xcat and /xcatpost, a restorecon dry run that must find
nothing to relabel, xcatd active, and no xCAT denial since boot.
selinux_sn_per_node_switch sets noderes.selinux on the service node and
reads the mode out of the kickstart that nodeset writes for it, in all
three directions, and checks that a value on the compute node does not
reach the service node.
selinux_cn_statelite_disabled_by_design asks for enforcing on a
statelite node and requires selinux=0 on its boot configuration, with
nodeset saying why.
selinux_bundle.t now keeps a service-node case out of the
management-node bundle, the same way it keeps a compute-node case out.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
selinux_bundle.t fails on this branch: selinux_client_domain is in no
bundle, so no run selects it. The case measures that an xCAT client
command execs and transitions into xcat_t, which is the check that a
client cannot run at all under enforcing.
Name it in selinux.bundle and selinux_mn.bundle. It needs no compute
node, so it belongs in both.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
No case in xCAT-test/autotest/testcase runs xcatprobe xcatmn, so a broken MN
check reaches a release unseen. The new case runs the probe and asserts that
the SELinux checkpoint appears and does not carry the FAIL marker.
The case cannot reach the enforcing mode. A management node under test runs
with SELinux disabled, and a disabled node needs a reboot and a relabel to
become enforcing. probe_utils_selinux.t covers the enforcing verdict.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The substitution had two unanchored alternatives, SELINUX=enforcing and the bare word
permissive. An image whose /etc/selinux/config reads SELINUX=permissive therefore gets
SELINUX=SELINUX=disabled, which the policy loader rejects, so the image boots with
SELinux enabled. The bare alternative also matches the comment that lists the three
values, so every image gets a rewritten comment line.
The substitution is now anchored on the whole assignment, the form xcatconfig already
uses. Thirteen scripts carry it, and eleven more postinstall paths are symlinks into
those files.
The postinstall scripts source no shared library, so each copy is edited in place.
Symlinks are how this tree already shares a postinstall between distributions.
The xcat_inventory fixture test1.postinstall is changed as well. cases.environment
names it as the postinstall attribute of an osimage, so genimage runs it on a real
diskless image.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
nodeset boot clears nodetype.provmethod when the image of the node is a
netboot or statelite image. The helper restored the image attributes
after the replay of an osimage state only, so a node in boot lost its
image assignment while the case reported IPXE_SHIM_OK.
The helper now restores the image attributes before the replay and
again after every replay, then restores currchain last. A failed
restoration still fails the case.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
When the forward nodeset osimage wrote the image attributes and then
failed, the restoration replayed a saved shell, standby or runcmd state
while the node still had the arch of the image. nodeset then wrote the
Genesis kernel and initrd of that arch. The chdef after the replay
corrected the database, not the boot files.
restore_state now writes provmethod, os, arch and profile back before
the replay. After the replay it writes them again only for an osimage
state, which sets them from the image row, and then writes currchain.
A failed chdef still makes the case fail without IPXE_SHIM_OK.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
nodeset osimage= sets chain.currchain to boot and copies os, arch and
profile from the osimage row into the node. The cleanup replayed only
chain.currstate, and restored profile only when provmethod was empty.
A node at runcmd=bmcsetup lost the osimage action queued after it, and
a node whose image row differed from its own values kept the values of
the row, while the case printed IPXE_SHIM_OK.
The helper now reads currchain with the other attributes before the
first mutation. After the replay it writes back provmethod, os, arch,
profile and currchain as it read them, on both paths. A failed write
fails the case without IPXE_SHIM_OK.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
vm_machine_type.sh invalid ignored the exit status of lsdef. When lsdef
failed, it saved an empty vmothersetting, and the next restore deleted
the configuration of the node. A second invalid replaced the saved
value with one that holds machine:invalid. The state file was a
predictable /tmp path that the script truncated and followed through a
symbolic link.
invalid now stops before it saves or changes anything when lsdef fails,
or when a saved value already exists. An empty value that lsdef read
is still saved. The script creates the state file with O_EXCL in a
directory that the current user owns with mode 0700. The default
directory is /tmp/xcattest-vmothersetting.<uid>. The script refuses a
symbolic link, a directory that other users can open, and a file it
does not own. When chdef fails in invalid, the script deletes the new
snapshot. A failed restore still keeps it.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
reg_linux_diskless_installation_flat adds a machine type to
vmothersetting and removes it again with a substring sed. When the node
already names a versioned machine type, the sed removes the first match
from the user's own value: cpumode:host-passthrough;machine:pc-q35-9.2
comes back as cpumode:host-passthrough-q35-9.2;machine:pc. The same
happens on riscv64 with machine:virt-9.2.
vm_machine_type.sh now saves the exact vmothersetting before it adds
machine:invalid, and restore writes that value back and deletes the
saved copy. An empty value clears the attribute. apply keeps a machine
type that the node already names and adds the architecture default only
when there is none. restore fails when no value was saved, and apply
fails for an architecture without a default.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
reg_linux_diskless_installation_flat sets machine:invalid, a valid
machine type and then no machine type in vmothersetting with three long
inline commands. The bats test for them cut the commands out of the case
file with a regex.
Move the three commands unchanged into commoncmd/vm_machine_type.sh and
call it from the case. The bats test now sources the helper and runs the
case's three steps against a stubbed lsdef and chdef.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
reg_linux_diskless_installation_flat fails on aarch64 at the check
"lsdef $$CN | grep vmothersetting" matched against "machine". The case
stops there, so the diskless provisioning it exists to measure is never
asserted.
The case sets vmothersetting to machine:invalid, confirms the node still
provisions, then replaces it with a valid machine type and confirms
again. The second step selects that type by architecture and knows only
ppc64, x86_64 and riscv64. On aarch64 the variable stays empty, chdef
clears vmothersetting, and the check that looks for the word "machine"
returns 1.
Give aarch64 the machine type QEMU uses for it, which is virt, the same
value riscv64 already gets. The other three architectures keep the value
they had.
Measured on xcat-ci/xcat-test-el10-aarch64 #9: the case reported Failed
at this check, 08:36:51Z, while genimage and packimage returned 0 and
the node reached status=booted with rootfs on / type tmpfs and
IMAGENAME alma10.2-aarch64-netboot-compute.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
blackbox_prov_failing_at_one_place fails about 1 run in 30 on the
GitHub runner: missing-ptr/getdestiny expects discover and gets the
state of provtestcn, because xcatd still resolves 10.99.1.11 to
provtestcn.
xcatd names a client with gethostbyaddr, which on the runner reaches
systemd-resolved. systemd-resolved rereads /etc/hosts at most every 2
seconds, so for up to 2 seconds after makehosts -d it still returns the
removed entry. do_run_ordering sent getdestiny in that window.
do_run_ordering now waits until getent hosts no longer names the node
before it runs missing-ptr, and fails the stage after 10 seconds.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
ipxe_secureboot_shim.sh reads every attribute and the nodeset state before the
first mutation, refuses a state it cannot put back, and replays the saved state
verbatim.
read_attr keeps the exit status of lsdef instead of the status of the sed that
follows it, so a lookup that failed no longer reads as an attribute that is
unset. must_read ends the case on a failed lookup, before the chdef and the
nodeset that change the node. This is what stops the restoration clearing a
provmethod or a netboot method the node really had.
The restoration replays the whole string nodeset stat reported, so a state that
carries an argument goes back with it. A state the helper cannot replay ends the
case while the node is untouched: install, netboot and statelite are deprecated
and the restoring nodeset rejects them, and iscsiboot, image, winshell and
sysclone read rows this case never saved. The restoring chdef also puts back
nodetype.profile, which nodeset osimage= overwrites from the osimage row.
xCAT-test/bats/ipxe_secureboot_shim_restore.bats covers it. Against the previous
commit the four refusal cases exit 0 and print IPXE_SHIM_OK after calling nodeset
osimage= on the node.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The case accepted IPXE_SHIM_SKIPPED, so a cell whose compute node is not
declared netboot=ipxe passed it without reading a boot script. Four of the six
confs that carry the case declare netboot=xnba, so four cells reported a pass
for a shim line nothing had measured.
The case now asserts IPXE_SHIM_OK and declares arch:x86_64, which keeps it off
another architecture through xcattest rather than through a token that passes.
The helper sets netboot=ipxe when the node is declared another way, and puts the
method back before the nodeset that restores the state. A netboot method that
cannot be put back is reported like the provmethod and the nodeset state. The
two conditions that used to skip now fail and name what the case could not read.
xCAT-test/bats/ipxe_secureboot_shim_restore.bats fails 5 of 9 without this
change.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
restore_state dropped the exit status of chdef and nodeset, and the helper
printed IPXE_SHIM_OK after it. A node left with provmethod set and nodeset
osimage reads as a pass, and the next case on that node runs against the
state this one set.
restore_state now reports which command failed and returns non-zero, and the
helper exits non-zero in place of the pass token. An EXIT trap holds the
restoration, armed immediately before the nodeset call that changes the state,
so no later branch can leave the node behind. A skip above that line changes
nothing and calls neither command.
Two assertions of five in ipxe_secureboot_shim_restore.bats fail without this
change.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The unit tests in this branch call the plugins in their own process against a
scratch TFTP root. No xcattest case reads a script that nodeset wrote on a
management node, so a cell whose compute node has netboot=ipxe runs this code
and asserts nothing about it. el9-x86_64-devel is such a cell.
nodeset_ipxe_secureboot_shim runs nodeset against the compute node of the conf,
reads /tftpboot/xcat/ipxe/nodes/<node>.uefi, and reports whether the line after
imgload names a shim that the web server serves. It puts the nodeset state back
afterwards. A node that is not an x86_64 ipxe node prints IPXE_SHIM_SKIPPED and
passes, so a bundle can carry the case on every cell. Where no provisioning case
has set nodetype.provmethod, the case names the stateful image of the node.
Measured on an AlmaLinux 9.8 management node: with the plugins of this branch
the case reports the shim of the install source and passes. With xnba.pm and
ipxe.pm from the branch point it reports imgargs kernel as the line after
imgload and fails.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>