The SELinux page carried the repair in two blocks. The first mapped the
published artifacts and ran restorecon over the image root. The second mapped
the publication directory and excluded both guest trees. An operator with
site.installdir=/srv/xcat-install who reads the page in order therefore
relabels before any mapping covers that tree, and rootimg/etc/shadow resolves to
var_t. The exclusion added afterwards keeps the var_t it finds, because it only
stops the next relabel from changing the label again.
The order also cost the artifacts. file_contexts keeps the expressions in the
order they are read and the last one that matches a path wins, so the exclusions
of the second block beat the artifact mappings of the first. Where the image
root carries a rootimg component in the middle, the exclusion matches the
artifacts as well, and the five expressions with a wildcard, the initrds and the
packed images, resolve <<none>>. kernel and hypervisor carry no wildcard and win
either way, which is why the defect showed on a subset.
The page is now one sequence: the publication directory, both guest exclusions,
the artifact mappings, then one restorecon. It says what each step orders and
why.
xCAT-test/native/selinux_image_repair.t passes 381 of 381 checks on this
sequence and fails 47 on the order of the parent commit. selinux_docs.t fails 3
of 30 on the parent commit.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The SELinux page told the operator to run chcon -R -t public_content_t over the
image root to repair a published artifact that kept an older type. That command
walks into rootimg and rootimg-statelite, so it replaces the labels of the guest
operating system with public_content_t. The xcat.fc comment carried the same
advice. chcon also writes a type that no mapping selects, so the next relabel of
a path that has a mapping reverts it: the repair held only until then.
The page now maps each published artifact with semanage fcontext and applies the
mapping with restorecon. Each expression names one regular file directly below
the image root, so no path in either guest tree matches one, and both trees keep
the <<none>> of the packaged mappings. The procedure reads the publication
directory from site.installdir, and a site that moved it maps the configured
directory and keeps both guest trees out of that mapping. The page says why a
tree mapping over the image root is the same defect as the chcon.
xCAT-test/native/selinux_image_repair.t passes 170 of 170 checks with the
documented procedure. With the chcon of the previous page it fails 101, 36 of
them guest labels. selinux_docs.t fails 7 of 26 on the parent commit.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The file contexts leave the published kernel of a middle-rootimg image
root out of the relabel. The comment and the SELinux page read that as
the kernel being unlabeled, httpd refusing to serve it, and that osimage
losing netboot, with restorecon as the repair. Three of those four
claims are wrong.
Measured. An entry of <<none>> keeps the label a path has: restorecon
-R, restorecon -RF and setfiles -F all left a kernel at default_t, while
the same setfiles call relabeled a path that has a rule. A new file
inherits the type of its directory, so a kernel that genimage writes
into an image root already made public_content_t is public_content_t. In
the policy with the xcat module loaded, httpd_t holds one allow rule to
read public_content_t and none for default_t. So the ordinary case
serves and netboot works, and restorecon is not the repair for the case
that does not: chcon -R -t public_content_t over the image root is, and
a later relabel leaves that value alone.
selinux_file_contexts.t now starts half the custom roots at
public_content_t, which is what genimage produces, and half at
default_t, and requires each to keep its own type. It fails 324 of its
618 checks against the previous xcat.fc.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
A file context of <<none>> stops restorecon changing the label. It does
not clear it. A tree that genimage creates under an image root that is
already public_content_t inherits that type, measured on an enforcing
el10 host: mkdir -p rootimg/common/sub under a public_content_t parent
gives every new component public_content_t, and the same tree under a
default_t parent gives default_t.
Say what the label is, and name the case that costs something: a tree
older than the package keeps default_t, and restorecon -RF over the
image root sets it.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The security page said xcatd runs in unconfined_service_t and that
xCAT-selinux defines no type. The module defines xcat_t for xcatd and
the client commands, and xcat_image_t for the image build, and declares
both permissive. The older page placed a service node and a compute node
outside the scope because xCAT does not select their mode, and the branch
ships noderes.selinux and site.selinux.
Both pages now state what the module does: the two permissive domains,
the transitions to tftpd_t and chronyd_t for the services xCAT starts,
the mode a node resolves, and the goal of an enforcing management node.
The scope page also records that a published common or overlay directory
of an image root called rootimg is unlabeled, for the same reason as a
published kernel there.
selinux_docs.t fails 6 of its 18 checks without this change, on rome01.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
%post writes /etc/xcat/xcatroot.env and %preun removes it, so the file
is absent on rpm --justdb, before %post runs, and after an interrupted
install. Both subtests of xcatd_relocated_startup.t have the file
present, so neither reads what happens without it.
Add a subtest that removes the file: each EnvironmentFile of the unit
carries a leading -, which makes a missing file not an error, XCATROOT
is the default of the unit, and the daemon starts with that default
instead of the installed prefix. Dropping the default XCATROOT from the
unit fails checks 4 and 7 of that subtest.
Record the trade the file contexts make for a rootimg component in the
middle of an image root: the guest labels are kept, which leaves the
published kernel of that one layout unlabeled, so httpd cannot serve it
and that osimage cannot netboot. The note names the recovery.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The page states that the context belongs to the file in /opt/xcat. The
prefix is now recorded at install time, so a relocated package starts
the daemon of its own tree, and the file contexts still name /opt/xcat.
Say both, so a reader of a relocated installation knows the entrypoints
need their own entries.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The page was written for a single domain and three entrypoints. It now names
both domains, the five client entrypoints including xcatDBcmds and the
genimage wrapper, and the two per-OS build programs.
It also states what each domain holds, so a reader does not take the split
for more than it is: xcat_image_t may relabel every type including the
security ones, and xcat_t keeps manage and relabel of non-security files
because packimage and liteimg run inside xcatd. And it records that a
permissive declaration does not cover a transition into a stock domain.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The pull request adds a process domain and says nowhere which machine it
covers, which commands enter it, or why the domain is permissive while the
host is enforcing.
The new page names the scope as the management node, lists the three
entrypoint files and the rule that the unit must exec xcatd and not a shell,
and states that the permissive declaration is in the policy source and a
later release removes it. It gives the commands that read the domain of
xcatd and the enforced denials of a run, with the --input-logs finding:
ausearch read the journal on an EL10 node whose log held 1032 denials.
It also records why a confined user domain gets no transition, and that the
file permissions still decide what a user can read.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>