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

test(xcat-core): capture three paths the file contexts get wrong

xcat.fc labels /opt/xcat/bin/genimage as the image entrypoint, although the
wrapper only writes a request to the socket; in --interactive mode it runs
the per-OS program through a shell (xCAT-client/bin/genimage:453), and that
exec transitions on its own from either caller domain. A dispatching client
therefore held the authority of the image build.

It also misses two paths. netboot/fedora12/geninitrd is a real 41 KB
program, and the genimage glob never matches a name spelled geninitrd. And
/opt/xcat/bin/xcatDBcmds is a third dispatcher, reached by 12 spec symlinks
including lsdef, chdef, mkdef and rmdef, which therefore run in the caller's
domain while rpower runs in xcat_t.

3 of the 85 checks fail on this commit.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-10-15 16:23:26 -03:00
parent c4934af926
commit 2bb5d83d28
+18 -2
View File
@@ -264,9 +264,25 @@ like($te, qr/^role system_r types xcat_image_t;$/m, 'system_r is authorized for
like($te, qr/^\s*role unconfined_r types xcat_image_t;$/m,
'... and so is unconfined_r, for an administrator who runs genimage');
# The per-OS programs are the entrypoint, and the geninitrd name needs its own
# pattern: most are symlinks to their sibling genimage, but
# netboot/fedora12/geninitrd is a real program the genimage glob never matches.
#
# /opt/xcat/bin/genimage is NOT one of them. It writes a request to the socket,
# and in --interactive mode it runs the per-OS program through a shell
# (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/bin/genimage', '/opt/xcat/share/xcat/netboot/[^/]+/genimage' ],
'the two genimage programs carry the entrypoint, and nothing else does');
[ '/opt/xcat/share/xcat/netboot/[^/]+/geninitrd',
'/opt/xcat/share/xcat/netboot/[^/]+/genimage' ],
'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');
# xcatDBcmds is the third dispatcher: 12 spec symlinks reach it, among them
# lsdef, chdef, mkdef and rmdef, and it does nothing but submit_request.
is(fc_type('/opt/xcat/bin/xcatDBcmds'), 'xcat_client_exec_t',
'the definition commands enter the domain too');
# THE SECURITY PROPERTY OF THE SPLIT. The image build writes and relabels files
# of every type, because it creates an operating system tree. The daemon that