2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-08-26 08:36:42 +00:00
Commit Graph

27375 Commits

Author SHA1 Message Date
Vinícius Ferrão e9c8aaefbb test(xcatd): cover commands.log response redaction
Extracts the three command-log response subs and drives them. It checks the
request classification, the redaction of a bare passwd value, a secret split
across callbacks in either order, the password-content fallback, that a benign
response is kept, and that the finalizer preserves an earlier command's response
on a shared connection. It fails hard if a sub cannot be extracted.
2026-08-18 17:01:26 -03:00
Vinícius Ferrão eda5c35bba fix(xcatd): redact secrets in the commands.log response
xcatd redacts the request in commands.log but appends the command response
verbatim. A command whose output holds a secret writes it in clear text.
Examples are tabdump passwd, gettab of a passwd column, and getcredentials.

Collect the response into a per-command buffer. Set a sensitive flag when the
command is getcredentials, an argument names a password, or the request was
redacted. When the command finishes, replace the whole buffer if the flag is
set or the buffer still holds password content, then append the buffer. A
connection can carry more than one command, so the buffer is finalized at the
next command's start and at the end of the connection.

The buffer holds the full response, so a secret split across several callbacks
is also redacted. A per-callback check cannot do this.

The word-content check is a fallback. The request classification is the main
signal. A secret with no password marker, such as the output of an xdsh cat of
a shadow file, is a pre-existing leak of the root-only log. It is out of scope.

Recovered from the lenovobuild branch. Reimplemented against master.
2026-08-18 17:01:26 -03:00
Daniel Hilst 91505a2141 Merge pull request #7719 from VersatusHPC/fix/redact-password-attributes
fix(xcatd): redact node passwords from the command logs
2026-08-18 16:35:46 -03:00
Vinícius Ferrão 8a47a02762 Merge pull request #7729 from VersatusHPC/fix/noderange-file-load
fix(xcatd): stop a noderange from running a command through the ^ operator
2026-08-18 13:14:18 -03:00
Vinícius Ferrão dd930681a5 test(xcatd): cover the noderange ^ file operator
The test runs the real NodeRange code. It sends a ^ range that a
two-argument open would run as a command and checks the command does not
run. It also reads a real comment-only file to show the operator still
works.

The command assertion fails against the previous behavior.
2026-08-17 12:24:20 -03:00
Vinícius Ferrão e3e132967c fix(xcatd): stop a noderange from running a command through the ^ operator
The ^ noderange operator reads node names from a file. NodeRange opened
that file with a two-argument open. A two-argument open reads shell
metacharacters in the path, so a noderange such as ^"id|" ran a command.
xcatd expands a noderange while it processes a request, so the command
ran on the management node.

Use a three-argument open with an explicit read mode. The value is then
only ever a file name. The ^ operator keeps working: ^/tmp/nodes still
reads the file.

This fix was recovered from the lenovobuild branch. The original there
(commit for "Remove load from file in noderange support") removed the ^
operator. This keeps the documented operator and closes the command path
instead.
2026-08-17 12:24:20 -03:00
Vinícius Ferrão 875a6ef40d Merge pull request #7723 from VersatusHPC/fix/kea-xnba-network-fallback 2026-08-11 12:49:44 -03:00
Vinícius Ferrão be51b428a3 Merge pull request #7720 from VersatusHPC/fix/ci-noninteractive-install
fix(ci): make package validation noninteractive
2026-08-11 03:27:56 -03:00
Vinícius Ferrão d8464db7ac Merge pull request #7712 from VersatusHPC/fix/52-ubunturepo-builddir
fix(build-ubunturepo): scope the build lock + scratch under an option…
2026-08-11 03:25:48 -03:00
Vinícius Ferrão c211fdb3bb test(dhcp): cover Kea xNBA network fallback 2026-08-10 17:12:37 -03:00
Vinícius Ferrão caa4e838eb fix(dhcp): boot unknown xNBA clients with Kea 2026-08-10 17:12:17 -03:00
Vinícius Ferrão ff20a0041d Merge pull request #7722 from VersatusHPC/fix/mknb-genesis-boot-paths 2026-08-10 16:43:53 -03:00
Vinícius Ferrão 0b8c44b283 test(mknb): cover Genesis boot paths 2026-08-10 15:08:28 -03:00
Vinícius Ferrão aeb07dce85 fix(mknb): render Genesis boot paths correctly 2026-08-10 15:07:49 -03:00
Daniel Hilst edfe6a8840 fix(build-ubunturepo): scope the build lock per checkout so parallel-lane builds don't fail
build-ubunturepo guarded builds with a single host-global, fail-fast lock at
/var/lock/xcatbld.lock (`flock -n`). Two builds on one host -- e.g. the devel and
stable Ubuntu CD lanes on xcat-master-ub -- therefore collided on that one lock and
the loser exited 1 with "Can't get lock ...", failing the whole pipeline, even though
each lane builds from its own checkout into its own DEST and they share nothing.

build-ubunturepo builds its packages in-place in its own source checkout (it rewrites
debian/changelog and debian/control, drops *.orig.tar.gz at the checkout root and runs
dpkg-buildpackage inside the package dirs), so the resource two concurrent builds
actually contend for is the checkout, not the host. Key the lock on the checkout path
($curdir): builds of the SAME checkout still fail-fast (they would corrupt each other
in-place), while builds of DISTINCT checkouts get distinct locks and run in parallel.
The lock file stays on the local /var/lock (reliable flock, unlike the NFS/virtiofs
checkout) and the source tree is left byte-pristine.

Add xCAT-test/unit/build_ubunturepo_lock.t, which extracts the lock block from the
script verbatim and asserts: the lock path is /var/lock/xcatbld-<hash-of-checkout>.lock
and deterministic per checkout; a second build of the same checkout fails fast; two
distinct checkouts acquire their locks concurrently.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-08-10 10:26:03 -03:00
Vinícius Ferrão fca07665fe test(xcatd): cover password redaction in the logged commands
Run redact_password rather than inspecting its source, so that a secret which
survives is a failure here rather than something the shape of the code hides.
Each supported way of writing an assignment is exercised, including the table
qualified form and spaces around the equals sign, together with the positional
flag that the per-command table handles.

The expected set is derived from Schema.pm rather than repeated, so an attribute
added there with a secret column fails this test instead of quietly reaching the
logs, and the test bails if that mapping cannot be parsed so it cannot pass
vacuously. Detail that is not secret is asserted to survive, since redacting it
would cost the log its usefulness without protecting anything.
2026-08-09 14:01:11 -03:00
Vinícius Ferrão 65f7b21265 fix(xcatd): redact the arguments stored in the auditlog table
Only syslog received the redacted arguments. The auditlog table was given the
raw string, so a password removed from syslog and from commands.log was still
written to the database, which persists and is readable by anything with access
to it.

Use the redacted text for both. This also covers the mkvm --password and -w
masking a few lines above, which the table did not have either.
2026-08-09 14:01:11 -03:00
Vinícius Ferrão 49149bb922 fix(xcatd): redact node password attributes from logged commands
redact_password only knew about bmcdiscover, mkhwconn and rspconfig, so setting
a password the ordinary way left it in the clear:

    [Request]    chdef node01 'bmcpassword=SEKRET'

Those secrets are carried as an assignment on whichever command happens to set
them, so match them by name rather than by command. The names are every
attribute Schema.pm maps to a password, passwd, authkey or privkey column, and
the columns themselves, since a table qualified assignment such as
passwd.password= is accepted too. An assignment may be written with spaces
around the equals sign and the value may contain spaces, so a quoted argument is
redacted to its closing quote.

Attributes such as key, which names a monitoring attribute, and sshkeydir, which
is a directory, are not secrets and are left readable. The existing per-command
table is kept for a flag like bmcdiscover -p, which carries its secret in the
following argument where there is no name to match.
2026-08-09 14:01:11 -03:00
Vinícius Ferrão edd1ca040e test(ci): check syntax exclusions 2026-08-09 13:16:38 -03:00
Vinícius Ferrão 2a3e2f5eee fix(ci): skip installed source tests 2026-08-09 13:16:35 -03:00
Vinícius Ferrão de8f81d674 test(ci): check dependency install 2026-08-09 13:09:54 -03:00
Vinícius Ferrão 1ae5998f01 fix(ci): make dependency install noninteractive 2026-08-09 13:09:51 -03:00
Vinícius Ferrão e3d9a633b5 test(ci): cover noninteractive installs 2026-08-09 12:15:04 -03:00
Vinícius Ferrão 19c1c2c9ab fix(ci): make package installs noninteractive 2026-08-09 12:14:48 -03:00
Daniel Hilst 32ff727e62 Merge pull request #7708 from VersatusHPC/fix/kea-inconsistent-reservation-state
fix(dhcp): Kea reservation updates leave inconsistent state
2026-07-31 23:15:23 -03:00
Vinícius Ferrão 6d26cf7fff fix(dhcp): correct inconsistent Kea reservation updates 2026-07-31 22:29:58 -03:00
Vinícius Ferrão 3b6bcac8db test(dhcp): expose inconsistent Kea reservation state 2026-07-31 22:21:51 -03:00
Vinícius Ferrão 287ed79b62 Merge pull request #7706 from VersatusHPC/fix/kea-makedhcp-noip-reservation
fix(xcat-core): skip *NOIP* NICs when building Kea DHCP reservations
2026-07-31 20:15:43 -03:00
Daniel Hilst 9125d4da3c fix(xcat-core): skip *NOIP* NICs when building Kea DHCP reservations
makedhcp using the Kea backend fails for any node whose mac table entry
uses the *NOIP* sentinel to mark a secondary NIC that has no IP address
(e.g. "mac1|mac2!*NOIP*|mac3!*NOIP*"). kea_node_reservations() and
kea_node_reservations6() split each NIC's hostname and pass it straight
to getipaddr(), so the literal string "*NOIP*" is treated as a host to
resolve. It cannot resolve, and the reservation is reported as unresolved
-- which aborts the whole makedhcp run, leaving the node with no Kea
reservation at all and therefore no DHCP lease.

This breaks provisioning on distros that use the Kea backend (e.g. EL10,
which has no ISC dhcp-server): the node never gets an address and is
unreachable, while the ISC backend has always handled *NOIP* and is
unaffected.

Skip *NOIP* NICs in both the DHCPv4 and DHCPv6 reservation builders, the
same way the ISC path does -- there is no address to reserve for them.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-31 19:29:20 -03:00
Daniel Hilst 52cdf7fe36 test(xcat-core): cover *NOIP* NICs in Kea DHCP reservation builders
Add a regression case to dhcp_kea_plugin_intent.t for a node whose mac
table entry uses the *NOIP* sentinel on a secondary NIC
("mac1|mac2!*NOIP*"). The mocked getipaddr resolves every name (including
the literal *NOIP*), so the only thing that can keep the node to a single
reservation is an explicit *NOIP* skip in kea_node_reservations() and
kea_node_reservations6(). The test asserts exactly one v4 and one v6
reservation, for the real NIC, with no reservation carrying *NOIP* as a
hostname -- covering both the "bogus second reservation" and the
"unresolved reservation aborts makedhcp" failure modes.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-31 19:22:51 -03:00
Daniel Hilst 2c9d0a3523 Merge pull request #7703 from VersatusHPC/fix/kea-preserve-reservations-on-makedhcp-n
fix(dhcp): preserve Kea reservations on makedhcp -n
2026-07-31 17:32:04 -03:00
Daniel Hilst 1bdaf01835 Merge pull request #7702 from VersatusHPC/fix/kea-report-unresolved-reservations
fix(dhcp): report unresolved Kea reservations
2026-07-31 17:31:17 -03:00
Vinícius Ferrão 3bc24cf08f test(dhcp): cover Kea reservation regeneration 2026-07-31 15:22:27 -03:00
Vinícius Ferrão 781d5e4163 fix(dhcp): preserve Kea reservations on makedhcp -n 2026-07-31 15:22:19 -03:00
Vinícius Ferrão 40f05589f9 test(dhcp): cover unresolved Kea reservations 2026-07-31 15:14:54 -03:00
Vinícius Ferrão 90c6eeae55 fix(dhcp): report unresolved Kea reservations 2026-07-31 15:12:41 -03:00
Vinícius Ferrão 1bb7baac9e Merge pull request #7701 from VersatusHPC/fix/ci-parallel-buildrpms
build: Fixes to get 2.19 green on CI/CD
2026-07-30 23:59:24 -03:00
Daniel Hilst d621d7fc29 fix(xcat-core): treat signal-killed build workers as failures too
The parallel-build failure gate only inspected $exit_code in run_on_finish. A
ForkManager child killed by a signal -- SIGKILL, or the OOM-killer under the
concurrent build load -- is reaped with $exit_code == 0 but $exit_signal != 0
(and possibly $core_dump). Such a worker therefore was NOT recorded as a
failure, so the parent could still index and GPG-sign a repository that is
missing the package that worker was building -- the exact partial-repo hazard
the gate was added to prevent, via a path it did not cover.

Capture $exit_signal and $core_dump from the run_on_finish callback and fail
the build when any of $exit_code, $exit_signal, or $core_dump is set.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-30 19:03:00 -03:00
Daniel Hilst 0c26dc19f5 fix(xcat-core): make parallel buildrpms fail-closed and lock/cleanup-safe
Addresses three concurrency-safety defects raised in review of the parallel
buildrpms.pl work:

1. Per-target build lock was released immediately. The flock filehandle was a
   lexical (my $blk) scoped to the guard block, so it was destroyed -- and the
   lock dropped -- as soon as that block exited, before any worker forked. The
   "intentionally leaked" comment did not match the code. Hold the handle in a
   file-scoped $BUILD_LOCK_FH so the fd (and the lock) live for the whole
   process; forked children inherit the fd but their exits never release it.

2. Build failures were silently swallowed. buildspkgs()/buildpkgs() called
   sh_retry() in void context, so a mock build that failed all retries returned
   non-zero into the void; the child then exited 0 and the parent's run_on_finish
   ignored the exit code. The parent could therefore index and GPG-sign a repo
   that was missing packages and still exit 0. Now sh_retry failures die in the
   child, run_on_finish records any non-zero child, and the run aborts before
   update_repo and again before signing if any child failed -- never publishing
   a partial core.

3. Abort cleanup unmounted unrelated builds. sweep_mock_mounts() lazy-unmounted
   every bind under /var/lib/mock, which on a shared host tears out the live
   chroots of concurrent, unrelated builds. Scope it to this run's own chroots
   (each chroot dir plus its -bootstrap sibling), passed in from abort_builds.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-30 16:35:01 -03:00
Daniel Hilst 5d9286cfb7 fix(xcat-core): fold release-alias finalize into merge_core_repos
merge_core_repos already assembles the multi-arch core and runs the full
finalize tail (index -> sign -> final metadata -> write_release_alias, in the
required order so the xCAT-release-latest alias lands AFTER metadata and stays
out of the repo index). The preceding commit restored a separate finalize_core
sub purely to satisfy xcat_release_package.t, which grepped for
'sub finalize_core { ... $dir ... }'. That left two overlapping entry points:
--finalize-core (finalize one pre-assembled dir) and --merge-core-repos
(assemble N per-arch dirs THEN finalize) -- the former a strict subset of the
latter, with no in-tree or CI caller.

Consolidate on the single assemble+finalize path: inline the finalize tail into
merge_core_repos, drop sub finalize_core and the --finalize-core getopt/dispatch,
and update xcat_release_package.t to assert the stable alias is created after the
final metadata pass inside merge_core_repos ($out). Behaviour is unchanged (merge
already wrote the alias); only the redundant finalize_core interface is removed.
xcat_release_package.t 26/26; perl -c clean.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-30 13:07:06 -03:00
Daniel Hilst e20853681b fix(xcat-core): restore finalize_core so xCAT-release stable-alias test passes
The CI buildrpms.pl port (d2d98b724) renamed the upstream sub finalize_core($dir)
to merge_core_repos($out) and inlined its index/sign/metadata/alias tail. The
xCAT-release logic (write the xCAT-release-latest stable bootstrap alias AFTER the
final metadata pass, so it stays out of the repo index) was preserved, but the rename
broke xCAT-test/unit/xcat_release_package.t, which statically pins:
  sub finalize_core { ... write_repo_metadata_dir($dir); ... write_release_alias($dir); }
so 'assembled core repository creates the stable alias after final metadata' failed
(1 of 26), turning xcat_pr_test red on PR #7701.

Restore finalize_core($dir) as the shared finalize primitive (index -> sign ->
final metadata -> stable alias) and have merge_core_repos delegate to it on the
assembled multi-arch dir. Re-expose the --finalize-core CLI (single already-populated
dir) it also feeds. Behaviour is unchanged for both --merge-core-repos (CI) and
--finalize-core; only the shared code path is named again. xcat_release_package.t now
26/26; perl -c clean.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-30 12:13:13 -03:00
Daniel Hilst 75fd87e707 fix(xcat-core): clean mock buildroot before each build (--init), not reuse-dirty
buildrpms.pl built every package with mock -N (--no-clean), reusing the per-package
<pkg>-<target><ext> chroot across runs for flat disk. But a build aborted or killed
mid-flight leaves that chroot half-initialised with a corrupt rpmdb; the NEXT run
reused it and failed (cannot open Packages database .../usr/lib/sysimage/rpm),
producing an incomplete core (e.g. missing xCAT-test) that fails the deploy-time
completeness gate.

Re-init the buildroot (mock --init) right before building each package, after the
diskcache skip so it only runs when actually building. --init restores from mock's
root-cache tarball (cheap) so disk stays flat and builds stay fast; -N is kept on the
srpm/binary calls so they still reuse the freshly initialised root within the run.
This stabilises builds against corrupt state left by any previous failed/aborted build.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-29 09:51:27 -03:00
Daniel Hilst d2d98b7248 fix(xcat-core): port CI buildrpms.pl (parallel builds, multi-arch merge) into tree
The 3 EL CD pipelines (xcat-core-devel-cd, xcat-core-stable-cd, xcat-dep-el-cd)
overlaid a pinned $CI/buildrpms.pl at build time because the tree's buildrpms.pl
lacked the options they depend on:
  - a per-target flock guard alongside --mock-uniqueext, so concurrent same-target
    builds do not corrupt each other's /var/lib/mock chroot namespace;
  - --native-only (build only arch-native pkgs on the secondary arch) plus
    --merge-core-repos/--output-dir/--input-core-repos, replacing --finalize-core,
    to assemble one signed flat multi-arch core from per-arch build outputs;
  - sh_retry() to absorb transient mock/nspawn flakes;
  - a single --target guard and graceful mock cancellation
    (sweep_mock_mounts/abort_builds) that unmounts chroots on abort.

The xCAT-release repository package (master/2.19 only) is preserved: its
write_release_alias() is invoked from the new merge_core_repos() and per-target.

Porting them in-tree lets CI drop the $CI/buildrpms.pl pin and run the three
pipelines in parallel without the cross-job serialize lock.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-28 19:56:56 -03:00
Daniel Hilst e10fb869cb Merge pull request #7699 from VersatusHPC/fix/rhels9-ppc64le-pkglist-trailing-blank
fix(xcat-core): drop trailing blank line in rhels9 ppc64le pkglist
2026-07-28 17:40:46 -03:00
Daniel Hilst e3f3862280 fix(xcat-core): drop trailing blank line in rhels9 ppc64le pkglist
PR #7677 added xCAT-server/share/xcat/netboot/rh/compute.rhels9.ppc64le.pkglist
with a stray empty line at the end of the file. The reviewer asked for it to be
removed before merge, but it slipped through. A trailing blank line in a pkglist
is meaningless and inconsistent with the rest of the netboot package lists, so
remove it.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-07-28 16:44:22 -03:00
Daniel Hilst c811f2b1bd Merge pull request #7677 from VersatusHPC/fix/xcat-core-matrix-build
fix(xcat-core) Fixes to get internal CI green
2026-07-28 16:33:08 -03:00
Vinícius Ferrão 036bb24c87 fix(packaging): preserve xcatd init state on Debian (#7615)
* refactor(packaging): share precise systemd state detection

* test(packaging): cover precise systemd state detection

* test(packaging): allow explicit Debian init mode

* fix(packaging): honor explicit Debian init targets

* test(packaging): cover Debian init target detection

* fix(packaging): add Debian xcatd init state helper

* test(packaging): cover Debian xcatd init state helper

* test(packaging): allow delegated SysV registration

* fix(packaging): preserve Debian xcatd conffile lifecycle

* test(packaging): mirror explicit Debian init mode

* test(packaging): cover Debian xcatd conffile lifecycle

* fix(packaging): contain init state file umask

* test(packaging): cover init state permissions

* fix(packaging): contain preinstall context umask

* test(packaging): cover preinstall umask containment

* fix(packaging): detect all systemd enablement links

* test(packaging): cover all systemd enablement links

* test(packaging): allow shared purge state path

* refactor(packaging): reuse Debian init state path

* fix(packaging): detect runtime systemd masks

* test(packaging): cover runtime systemd masks

* test(packaging): model Debian SysV registration

* refactor(packaging): reuse shared init state detection

* test(packaging): enforce shared Debian state probes

* test(packaging): allow explicit unregistered masks

* fix(packaging): preserve Debian SysV registration state

* test(packaging): cover Debian SysV registration states

* fix(packaging): clean failed Debian state writes

* test(packaging): cover failed Debian state writes

* fix(packaging): retain unregistered systemd provenance

* test(packaging): cover unregistered systemd upgrades

* fix(packaging): fail closed on shared state errors

* test(packaging): cover shared state detector failures

* test(packaging): mirror native xcatd runlevels

* fix(packaging): recover rejected SysV layouts

* test(packaging): cover rejected SysV layouts

* test(packaging): cover SysV rebuild retries

* refactor(packaging): reuse systemctl readiness guard

* test(packaging): enforce shared systemctl guard
2026-07-28 19:31:36 +00:00
Daniel Hilst b5510dd017 Merge pull request #7696 from VersatusHPC/fix/buildrpms-release-alias
fix(buildrpms): only write xCAT-release-latest alias when the rpm exists
2026-07-28 15:56:10 -03:00
Daniel Hilst 9e7b281519 Merge pull request #7640 from VersatusHPC/refactor/openbmc-reuse-retry-after
refactor(openbmc): reuse retry scheduler for 503 responses
2026-07-28 15:53:10 -03:00
Daniel Hilst 18ef026fc5 Merge pull request #7638 from VersatusHPC/harvest/apache-security-hardening
fix(httpd): harden the xCAT Apache configuration
2026-07-28 11:05:42 -03:00