mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-22 18:32:13 +00:00
e2bae62e61
/opt/xcat/probe/subcmds/bin is created by the %post of xCAT-probe, so no
package owns it. A directory a scriptlet creates takes the context of its
parent, usr_t, and not the bin_t that the policy gives /opt/.*/bin, and
nothing relabels it afterwards. Measured on xcat163-mn-tmp-286:
restorecon -n -v -R /opt/xcat
Would relabel /opt/xcat/probe/subcmds/bin from
unconfined_u:object_r:usr_t:s0 to unconfined_u:object_r:bin_t:s0
It is the only path under /opt/xcat whose label does not match the policy.
The directory is in use: xcatprobe:263 drops a switchprobe symlink in it,
and xCAT-probe/debian/dirs already packages it on Debian.
xcat_probe_package_payload.t asserts that %install creates it, that %post
does not, and that the Debian package keeps it. 2 of its 4 checks fail on
this commit.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
30 lines
1.3 KiB
Perl
30 lines
1.3 KiB
Perl
#!/usr/bin/env perl
|
|
use strict;
|
|
use warnings;
|
|
use FindBin;
|
|
use lib "$FindBin::Bin/../lib";
|
|
use Test::More;
|
|
use XCAT::Test::File qw(slurp_repo_file);
|
|
|
|
my $control = slurp_repo_file('xCAT-probe/debian/control');
|
|
my ($probe) = $control =~ /^Package: xcat-probe\n(.*?)(?:\n\n|\z)/ms;
|
|
like($probe // '', qr/^Depends:.*\biproute2\s*\|\s*net-tools\b/m,
|
|
'Debian probe keeps the socket-tool alternatives');
|
|
|
|
# The rpm created subcmds/bin in %post, so the directory belonged to no package
|
|
# and took the context of its parent, usr_t, instead of the bin_t the policy
|
|
# gives /opt/.*/bin. Nothing relabels it afterwards, and xcatprobe drops a
|
|
# switchprobe symlink in it at run time. The Debian package already owns the
|
|
# directory through debian/dirs.
|
|
my $spec = slurp_repo_file('xCAT-probe/xCAT-probe.spec');
|
|
my ($install) = $spec =~ /^%install\n(.*?)^%\w+/ms;
|
|
like($install // '', qr{^mkdir -p \$RPM_BUILD_ROOT/%\{prefix\}/probe/subcmds/bin\b}m,
|
|
'%install creates subcmds/bin, so rpm owns it and labels it from the policy');
|
|
my ($post) = $spec =~ /^%post\n(.*?)(?:^%\w+|\z)/ms;
|
|
unlike($post // '', qr{mkdir -p .*probe/subcmds/bin},
|
|
'... and %post no longer creates it behind rpm');
|
|
my $dirs = slurp_repo_file('xCAT-probe/debian/dirs');
|
|
like($dirs, qr{^opt/xcat/probe/subcmds/bin$}m, 'the Debian package still owns it too');
|
|
|
|
done_testing();
|