2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-19 08:52:15 +00:00

feat(xcat-core): run xcatd and the xCAT clients in the xcat_t domain

xCAT had no process domain. xcatd ran in unconfined_service_t, where the
policy constrains nothing, and each client command ran in the domain of its
caller. The module could therefore only grant access to other services.

xcat.te declares the xcat_t domain, the xcatd_exec_t and xcat_client_exec_t
entrypoints, the transition from systemd, and the transition from
unconfined_t for a client command. xcat.fc labels /opt/xcat/sbin/xcatd and
the two xcatclient scripts, which 115 command names reach through a symlink.

xcat_t is permissive, and the policy source declares it. The host stays
enforcing, and the CI collects the accesses the domain needs. The module
grants the domain one access of its own: the execute of the interpreter that
its Perl entrypoint names. A confined user domain gets no transition, so it
keeps its own confinement.

The module compiles at version 19 in the alma+epel-10-x86_64 mock root, and
the binary carries (typepermissive xcat_t) and both type transitions.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-10-14 16:55:21 -03:00
parent 2efdce66b9
commit 0f0c2a1f94
2 changed files with 48 additions and 4 deletions
+6
View File
@@ -1,3 +1,9 @@
# The entrypoints of the xcat_t domain. /usr/sbin/xcatd is a symlink, and
# execve resolves it, so the context belongs to the file it names.
/opt/xcat/sbin/xcatd -- gen_context(system_u:object_r:xcatd_exec_t,s0)
/opt/xcat/bin/xcatclient -- gen_context(system_u:object_r:xcat_client_exec_t,s0)
/opt/xcat/bin/xcatclientnnr -- gen_context(system_u:object_r:xcat_client_exec_t,s0)
/install(/.*)? gen_context(system_u:object_r:public_content_t,s0)
# A rootimg keeps the labels of its own OS, so restorecon must not change them.
+42 -4
View File
@@ -1,4 +1,4 @@
policy_module(xcat, 1.0.0)
policy_module(xcat, 1.1.0)
gen_require(`
type httpd_t, httpd_sys_script_t, tftpdir_t, ntop_port_t;
@@ -6,6 +6,45 @@ gen_require(`
type useradd_t, groupadd_t, public_content_t;
')
########################################
#
# The xCAT domain
#
# xcatd and the client commands share one domain. Each command sends its
# request to xcatd, and the two read the same tables and the same /install tree.
type xcat_t;
type xcatd_exec_t;
init_daemon_domain(xcat_t, xcatd_exec_t)
# /opt/xcat/bin/xcatclient is the entrypoint of every dispatching command.
type xcat_client_exec_t;
application_domain(xcat_t, xcat_client_exec_t)
# The CI collects the accesses xcat_t needs while the host stays enforcing.
# A later release removes this line and the domain becomes enforcing.
permissive xcat_t;
# xcatd and xcatclient are Perl scripts. The kernel enters the domain on the
# script, so the domain runs the interpreter of the shebang line itself.
corecmd_exec_bin(xcat_t)
optional_policy(`
gen_require(`
type unconfined_t;
')
# Targeted policy gives root unconfined_t, which is where the administrator
# and the CI run the commands. A confined user domain gets no transition: it
# would leave its own confinement for a permissive domain.
domtrans_pattern(unconfined_t, xcat_client_exec_t, xcat_t)
')
########################################
#
# Access for the services that read the xCAT trees
#
# httpd serves /tftpboot through the AliasMatch in xcat.conf. The stock policy lets only tftpd read tftpdir_t.
# mmap_read_file_perms, not read_file_perms: httpd maps the per-node xnba boot config it serves.
allow httpd_t tftpdir_t:dir list_dir_perms;
@@ -18,9 +57,8 @@ allow httpd_sys_script_t ntop_port_t:tcp_socket name_connect;
# xdcp and "updatenode -F" copy /etc/shadow to the nodes and into a rootimg.
# rsync_export_all_ro holds the read, and rsync_full_access does not grant it:
# shadow_t is not in non_auth_file_type. These two rules are narrower than
# either boolean. They are reached only where rsync runs in rsync_t, which
# needs a system-service caller; xcatd is unconfined_service_t and does not
# transition there.
# either boolean. They are reached only where rsync runs in rsync_t, and xcat_t
# has no transition to it.
allow rsync_t shadow_t:file { getattr open read };
# rsync preserves the mode of /etc/shadow, so it writes a target it created at