From 73323090409fcbca7358ede6ada4fe2c8e026fcc Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Thu, 15 Oct 2026 16:23:54 -0300 Subject: [PATCH] fix(xcat-core): three paths the file contexts get wrong The wrapper /opt/xcat/bin/genimage carried the image entrypoint, so a command that writes a request to the socket ran with the authority to relabel every type. It is now a client. The build still reaches xcat_image_t: the plugin, and the --interactive mode of the wrapper, run the per-OS program through a shell, and that exec transitions from either caller domain. The per-OS geninitrd gets its own line, because most of those names are symlinks to their sibling genimage but netboot/fedora12/geninitrd is a real program, and the genimage glob never matches it. /opt/xcat/bin/xcatDBcmds is labelled as a client. It is the third dispatcher, reached by 12 symlinks including lsdef, chdef, mkdef and rmdef, and without this they ran in the caller's domain while rpower ran in xcat_t. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-selinux/xcat.fc | 11 +++++++---- xCAT-test/unit/xcat_selinux_package.t | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xCAT-selinux/xcat.fc b/xCAT-selinux/xcat.fc index 26ed9b766a..d69e58c9a5 100644 --- a/xCAT-selinux/xcat.fc +++ b/xCAT-selinux/xcat.fc @@ -3,12 +3,15 @@ /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) +/opt/xcat/bin/xcatDBcmds -- gen_context(system_u:object_r:xcat_client_exec_t,s0) +/opt/xcat/bin/genimage -- gen_context(system_u:object_r:xcat_client_exec_t,s0) -# The entrypoints of the image build. The wrapper and the per-OS program are -# both real files; packimage and liteimg are symlinks to xcatclientnnr, so the -# work they ask for runs in xcat_t. -/opt/xcat/bin/genimage -- gen_context(system_u:object_r:xcat_image_exec_t,s0) +# The entrypoints of the image build are the per-OS programs. The geninitrd +# name needs its own line: most are symlinks to their sibling genimage, but +# netboot/fedora12/geninitrd is a real program. packimage and liteimg are +# symlinks to xcatclientnnr, so the work they ask for runs in xcat_t. /opt/xcat/share/xcat/netboot/[^/]+/genimage -- gen_context(system_u:object_r:xcat_image_exec_t,s0) +/opt/xcat/share/xcat/netboot/[^/]+/geninitrd -- gen_context(system_u:object_r:xcat_image_exec_t,s0) /install(/.*)? gen_context(system_u:object_r:public_content_t,s0) diff --git a/xCAT-test/unit/xcat_selinux_package.t b/xCAT-test/unit/xcat_selinux_package.t index d1a9904f76..8758b2e045 100644 --- a/xCAT-test/unit/xcat_selinux_package.t +++ b/xCAT-test/unit/xcat_selinux_package.t @@ -273,8 +273,8 @@ like($te, qr/^\s*role unconfined_r types xcat_image_t;$/m, # (xCAT-client/bin/genimage:453), which transitions on its own. Labelling the # wrapper gave a dispatching client the authority of the image domain. is_deeply([ grep { fc_type($_) eq 'xcat_image_exec_t' } sort keys %fc ], - [ '/opt/xcat/share/xcat/netboot/[^/]+/geninitrd', - '/opt/xcat/share/xcat/netboot/[^/]+/genimage' ], + [ '/opt/xcat/share/xcat/netboot/[^/]+/genimage', + '/opt/xcat/share/xcat/netboot/[^/]+/geninitrd' ], 'only the per-OS build programs carry the image entrypoint'); is(fc_type('/opt/xcat/bin/genimage'), 'xcat_client_exec_t', 'the genimage wrapper is a client, like every other dispatching command');