Skip to content
Search openEuler

    Browse this documentation

    SELinux on openEuler — Enforcing by default as measured, the policy toolchain, and what "on by default" means for operations

    This page’s evidence is the live-machine track (E3) — VM 381 (openEuler 24.03 LTS SP4 minimal install, 2026-11-04/05): the default-mode measurement, the policy-toolchain inventory, and a real file-context incident (from this site’s install troubleshooting — the kickstart E3 post-install-ssh-takeover step: authorized_keys with ssh_home_t vs root_home_t and the chcon fix). Raw log: evidence/logs/openeuler-p4-virt-vm.log (the SELinux default-mode section); the case chain is in evidence/e3/openeuler-kickstart-install.json.

    $ getenforce
    Enforcing
    $ sestatus | head -3
    SELinux status: enabled
    SELinuxfs mount: /sys/fs/selinux
    SELinux root directory: /etc/selinux

    openEuler 24.03 minimal install is enforcing by default — not “turned on after install”, but “always on”. Combined with another measured fact (the kernel cmdline ships apparmor=0 by default, see the kernel dual-track page): openEuler’s MAC mainline is clearly SELinux, with AppArmor explicitly off. What this means for operations: every deploy script and baseline tool must be designed around “SELinux is on” — dropping to permissive temporarily for troubleshooting is fine (setenforce 0), but writing disabled into a baseline is an anti-pattern (it takes effect only after a reboot and loses labels; coming back requires a relabel).

    The policy toolchain is in place (minimal-install measured)

    Section titled “The policy toolchain is in place (minimal-install measured)”

    policycoreutils comes with the minimal install (supplementary rpm inventory on 2026-11-12, openeuler-p6-supplement2.log); setools-console / policycoreutils-python3 measured absent — restorecon works directly, semanage/audit2allow need a supplementary install first.

    A real case: an install script writing files hits the context pitfall

    Section titled “A real case: an install script writing files hits the context pitfall”

    The full incident chain from this site’s install log (console evidence + screenshots): the authorized_keys written by Kickstart %post had correct content and permissions, yet SSH public-key login kept getting rejected — the root cause was files written directly by %post do not inherit the right context (the actual label root_home_t ≠ the policy-expected ssh_home_t), so sshd’s confined domain could not read it. The fix and prevention:

    Terminal window
    matchpathcon /root/.ssh/authorized_keys # what label the policy expects (ask before fixing)
    chcon -t ssh_home_t /root/.ssh/authorized_keys # the fix
    # end %post with a uniform restorecon/chcon in install templates (see the Kickstart page template)

    The generality of this case: any combination of “a script creates a file + a confined service reads it” (web roots, log directories, key directories) can hit the same pitfall — the troubleshooting order is always ls -Z to look at labels first, then permissions.

    • RHEL-family experience transfers wholesale (the semanage/audit2allow/policy-module workflow is isomorphic);
    • The opposite of the Ubuntu family (AppArmor mainline) — deploy scripts migrated from Ubuntu that depend on AppArmor profiles live in a different system on openEuler (and as measured above, AppArmor is off).
    • Custom policy modules end-to-end (the full audit2allow → semodule -i loop) was not reproduced in this environment (the case on this page needed only a single-file chcon fix); listed as a live-test item for the security deep-dive volume;
    • SELinux and iSulad container interplay (SELinux labels of container processes, the --security-opt label: surface) not measured;
    • MLS/targeted-policy differences not covered (the default targeted context).