mknb stages the legacy Genesis kernel into the TFTP root with cp -a. The flag
implies --preserve=all, so the kernel arrives with the SELinux context of the
xCAT install tree and not the context the policy declares for that path.
The test drives stage_genesis_payload with a recording runner. It asserts that
the copy does not preserve the context, and that the staged kernel is relabelled
after the copy when SELinux is enabled. It fails on the current code: 4 of its
14 checks are red.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The xcat policy module granted httpd read of /tftpboot and let xcatws.cgi
connect to the xcatd port. Five further accesses were measured denied on a
management node and are not granted, so an enforcing node fails at them.
httpd mmaps the per-node xnba boot config it serves out of /tftpboot.
read_file_perms does not hold map, so the module now grants
mmap_read_file_perms. Two sites recorded this denial three days apart, on
xCAT 2.19.1 and 2.20.
xdcp and "updatenode -F" copy /etc/shadow to the nodes and into a rootimg.
rsync_export_all_ro holds that read and rsync_full_access does not grant it,
because shadow_t is not in non_auth_file_type. rsync also writes a target it
created at mode 0000, which needs CAP_DAC_OVERRIDE. Both rules are reached only
where rsync runs in rsync_t, which needs a system-service caller.
genimage installs packages into a rootimg with yum in a chroot, and useradd and
groupadd read the rootimg /var/run symlink from the rpm scriptlets. The symlink
carries public_content_t because the rootimg is under /install, and the base
grant for that read names public_content_t nowhere.
The module compiles at version 19 in the alma+epel-10-x86_64 mock root, and the
five types reach the binary.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The xcat policy module carries four allow rules and xcat_selinux_package.t reads
only the spec and the file context list, so no test reads the module source. The
SELinux campaign measured five more accesses that the module does not grant:
httpd maps the per-node xnba boot config it serves, rsync reads /etc/shadow and
needs CAP_DAC_OVERRIDE to write it, and useradd and groupadd read the rootimg
/var/run symlink from an rpm scriptlet.
The test parses the allow rules of xcat.te into a permission set per source,
target and class, and asserts each access. It also asserts that no rule grants
kernel_t anything. Two such rules make an EL10 diskless node boot enforcing, and
they grant the pre-pivot domain execute on an unlabelled file, which on that
node is the whole root.
7 of the 43 checks fail on this commit.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
xCAT shipped no SELinux policy. On an enforcing management node httpd
could not read /install, which had no file context, or the /tftpboot
files that xcat.conf serves, and xcatws.cgi could not connect to xcatd.
The new noarch xCAT-selinux package builds the xcat module with the
selinux-policy-devel Makefile. The module labels /install
public_content_t and leaves each rootimg tree out of the relabel. It lets
httpd read tftpdir_t and lets httpd_sys_script_t connect to ntop_port_t.
The scriptlets use the selinux-policy macros, and %posttrans relabels
/install. They do not change the SELinux mode.
checkmodule writes module version 19, so the package built in the EL10
mock root installs on EL8, EL9 and EL10. On a Red Hat family build,
xCAT-server and xCATsn require xCAT-selinux when selinux-policy-targeted
is installed. SUSE and Debian builds do not change.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
xCAT ships no SELinux policy. On an enforcing management node, httpd
cannot read /install, which has no file context and is default_t, and
cannot read the /tftpboot files that xcat.conf serves. xcatws.cgi cannot
connect to xcatd.
xcat_selinux_package.t reads the xCAT-selinux spec, its file context list
and the xCAT-server and xCATsn specs. It checks the build and the
scriptlet macros, the /install labels, and the conditional Requires on
xCAT-selinux. 23 of its 31 checks fail on this commit.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
xcatd.service started xcatd through /bin/sh to read
/etc/profile.d/xcat.sh. systemd runs the shell in initrc_t, and xcatd
inherited that domain. initrc_t moves rsync, useradd, groupadd, hwclock
and setfiles into confined domains, so an enforcing management node
denies syncfiles, updatenode -F and genimage.
ExecStart now runs /usr/sbin/xcatd directly. systemd starts the bin_t
binary in unconfined_service_t, which has none of these transitions. The
unit sets XCATROOT, PATH and PERL_BADLANG with Environment=, and
/etc/sysconfig/xcat can still override them. RPM and Debian packages ship
the same unit. The SysV script for hosts without systemd still reads the
profile.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
xcatd.service starts xcatd through /bin/sh to read /etc/profile.d/xcat.sh.
systemd runs that shell in initrc_t, so on an SELinux system xcatd runs in
initrc_t. That domain moves rsync, useradd, groupadd, hwclock and setfiles
into confined domains, which deny syncfiles, updatenode -F and genimage.
xcatd_service_direct_exec.t reads the [Service] section of the unit and
checks that ExecStart runs /usr/sbin/xcatd and that Environment= carries
XCATROOT, PATH and PERL_BADLANG. 11 of its 14 checks fail on this commit.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
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 turns SELinux off during an installation. It sets the running
system permissive and writes SELINUX=disabled into /etc/selinux/config. A
management node therefore loses the SELinux policy of the site, and only a
warning in the log reports it. Every CI cell that declares SELINUX=enforcing
ran its test cases permissive for this reason.
The test drives xCAT::SELinux->xcatconfig_action against a scratch root and
asserts that an enforcing node, a permissive node and a node with SELinux
already off all get an answer that asks for no change. It also asserts that
the call rewrites no file under that root.
10 of the 27 checks fail on this commit.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
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>
The kit commands refuse RHEL 8 and later, but compared the release as a
string. "10.1" sorts before "8", so the kit commands ran on RHEL 10.
They now compare the major release as a number.
An extra file must go into its destination directory, which the import
creates with its missing parents. A file at the destination path, or at
a parent of it, must fail the import and stay as it was. A file name
with glob characters must stay literal. A failed backup of the previous
file must fail the import.
imgexport records an extra file with its destination directory. When
that directory did not exist, imgimport copied the file to the path of
the directory, so the file took the name of the directory. When a file
was at that path, imgimport replaced it.
imgimport now creates the destination directory and its missing
parents, as it does for an extra directory. A file at that path fails
the import and stays as it was. The copy runs without a shell, so a
file name with glob characters cannot match another file. A failed
backup of the previous file now fails the import.
A cached reader that saw an update before a rollback must see the
committed value after the rollback. This also holds when the rollback
goes through another table on the same handle, and after a table failed
to open on that handle.
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.
setAttribsWhere did not mark the cache of its table as stale, as the
other writes of xCAT::Table do. A cached reader, such as the one that
gives nodes their postscripts, got the previous values for up to 5
seconds after an update. setAttribsWhere now refreshes the cache after
an update.
When the configured database is MySQL, the litefile lookup of a
statelite import must quote the image column with backticks. An ALL
entry must still cover the same file of the image.
A kit command must hold the kit lock while it runs, and release it
after. It must refuse to run while another process holds the lock, also
in a process that ran a kit command before. A kit command that another
kit command runs must go on under the lock of that command.
kit.pm tested the bareword locked instead of $locked. The test was
always false, so a kit command never took the kit lock, and it ran also
while another process held the lock.
A kit command now takes the lock in one step, and fails while another
process holds it. The is_locked probe is gone, because its release
removed the lock file that another kit command could then hold. A kit
command that another kit command runs goes on under the lock of that
command.
imgimport looked up the litefile entries for all images with "image" =
'ALL'. MySQL takes a double-quoted name for a string, so the lookup
found nothing, and imgimport added entries that an ALL entry already
covered. The lookup now quotes the column the way the database needs.
When a table call died in the DB worker of xcatd, the worker sent its
error in an array. dbc_submit dies only for a scalar reference, so the
caller got the error text as the result of the call. A failed commit or
write then looked like a success to the caller.
The worker now sends the error as a scalar reference, and dbc_submit
dies with it, as the call dies without the DB worker.
Keep hardware and tuning settings in each machine. Use a common include for the repeated image and recommendation settings without changing their override semantics.
Preserve component labels, failure messages and exit policy at each caller. Give the runtime library its own package so discovery does not depend on the init package that already depends on discovery.