Petition to relocate the SELinux policy store to /etc/selinux or propose a new standard

Summary

Move the SELinux policy store (installed modules, local customizations and the compiled policy) from /var/lib/selinux to /etc/selinux/<policy>/active by setting store-root = /etc/selinux in the default semanage.conf. This brings every Fedora edition, spin and atomic variant to a single layout, matches the location already used on ostree-based systems such as Fedora Silverblue, and follows the migration that openSUSE completed in 2026. Existing systems are migrated automatically on upgrade.

Detailed Description

Current location

Since the SELinux userspace release adopted in Fedora 23, the policy store lives under /var/lib/selinux/<policy>/, while the configuration (/etc/selinux/config, semanage.conf) and the policy-related content shipped by packages live under /etc/selinux and /usr/share/selinux. The policy store is the area that semodule, semanage and setsebool -P read and write: it holds the module set, local changes (booleans, users, ports, file contexts) and the linked and compiled policy.

New location

/etc/selinux/<policy>/active (for example /etc/selinux/targeted/active), reached by changing store-root in /etc/selinux/semanage.conf from its default /var/lib/selinux to /etc/selinux. This is the layout that Fedora Silverblue 44 already uses: booleans.local, file_contexts, file_contexts.homedirs, homedir_template, modules/, policy.kern, policy.linked, seusers and users_extra all sit under /etc/selinux/targeted/active.

Why this is needed

/usr and /etc are the trees that atomic and snapshot-based update schemes capture and roll back together; /var holds mutable state and is deliberately left alone. A policy store in /var therefore breaks that model. After a rollback, the files from packages under /usr/share/selinux and /etc/selinux return to their earlier state while the store in /var/lib/selinux keeps the newer one. If the update added or removed types, attributes or modules, rebuilding the policy or installing an external module afterwards can fail, and the system ends up in a state that is hard to recover automatically. openSUSE documented exactly this failure mode, rated it very rare in practice, and still decided to remove it by moving the store to /etc.

The same reasoning drove two earlier decisions that this Change builds on:

  • Fedora 36, RPM database to /usr (Changes/RelocateRPMToUsr): the RPM database describes mostly /usr, so it was moved next to it so that /usr can be rolled back as a unit without touching /var. The rpm-ostree variants and openSUSE were already doing so, and the move was applied on upgrade by a systemd service that relocated the data. The discussion also raised FHS objections, which are addressed below for this proposal.
  • openSUSE, SELinux store to /etc (2026): the migration landed in Tumbleweed snapshot 20260505 after months of testing, runs automatically on package update, preserves local changes and custom modules, and removes the old /var/lib/selinux tree only once no snapshot still needs it.

On the atomic side, the problem was already visible in 2016: with an empty /var after a factory reset, the store in /var/lib/selinux was missing and semanage and semodule stopped working, which led to a dedicated policy variant that kept the store in /etc. Standardizing on /etc/selinux removes that special case and the divergence between variants.

What will change

  1. The default semanage.conf shipped by Fedora sets store-root = /etc/selinux like Atomic spins but for all the Fedora ecosystem.
  2. On upgrade, a migration step moves the store from /var/lib/selinux/<policy> to /etc/selinux/<policy>, keeping local booleans, users, ports, file-context changes, custom modules at any priority and disabled modules, then records completion with a marker file so it runs once. It follows the approach used for the RPM database in Fedora 36: a one-time step during the offline upgrade, with scriptlets as a safety net for online upgrades.
  3. The old tree is kept unused as a fallback for one release and then removed.
  4. Packages that install SELinux modules or set booleans from scriptlets are audited, for the new location.
  5. The policy is checked for the file contexts and rules that apply to the new paths, so semanage tools run in their usual domain without new denials.
  6. Ostree-based variants drop whatever special-casing they carry today and use the same default as everyone else.

Benefit to Fedora

  • Policy and module changes roll back together with the rest of the system on any setup that snapshots /usr and /etc: openSUSE-style btrfs layouts with /var as a separate subvolume, LVM and device-mapper snapshots, and similar schemes.

  • One layout across Workstation, Server, spins and the atomic variants instead of two. Documentation, tooling and troubleshooting become the same everywhere.

  • Fixes the empty-/var failure on atomic systems at the source, with no variant-specific workaround.

EDIT

OPTION B: Propose a new dedicated top-level directory standard (FHS) for operating-system state

Instead of placing the SELinux policy store in /etc, define a new standard top-level directory, /<name>, for critical system state that must stay associated with the operating system installation or deployment. It would be shared by traditional, atomic and immutable distributions, and by any distribution that adopts it. The package manager databases and the SELinux policy store would be the first components to live there.

Admission criteria. A component belongs only if it:

  1. describes or depends on the installed operating system;
  2. must stay consistent with it across snapshots, deployments and rollbacks;
  3. is modified by system tools, not by users.

Proposed hierarchy.

/<name>/                    # It could be /sysstate, /osstate, /state, /osdata
├── rpm/                    # RPM database (today /usr/lib/sysimage/rpm)
├── dpkg/                   # other package managers, only where present
├── pacman/
└── selinux/
    └── targeted/
        └── active/         # policy store (/var/lib/selinux or /etc/selinux)
├── any other critical component

Each distribution ships only the subdirectories it uses. Other components are added later, one at a time, if they meet the admission criteria.

Same layout, different semantics.

  • Traditional systems: writable, so package managers and SELinux tools update it in place. It must be covered by whatever snapshot mechanism the administrator uses.
  • Atomic systems: read-only in the active deployment. Its contents are updated as part of a new deployment and roll back with it.
  • Immutable or image-based systems: part of the image or snapshot, with the same rollback guarantees.

Benefits. One location and one rule for every distribution model, with no further load on the responsibilities of /etc, /usr or /var, and no generated state in the configuration tree.

Trade-offs.

  • It needs agreement on the name and semantics among distributions and upstream projects, so it cannot realistically land in Fedora 46.
  • It requires a multi-release migration, probably with compatibility symlinks for the old paths.
  • It adds a new top-level directory, which has to be justified against the existing hierarchy.

Relation to this Change. Option A (move the SELinux store to /etc/selinux) solves the rollback problem now with locations that already exist. Option B is a longer-term direction, and Option A does not prevent it.

Please share your thoughts on this proposal so that it can serve as an incentive for developers and help make this change a reality.

Do you support moving the SELinux store to /etc/selinux?
  • Yes
  • Yes, but with some changes
  • No
0 voters
Would you prefer to propose a new standard??
  • Yes
  • No
0 voters

Should we consider a new top-level directory instead of creating more legacy filesystem layouts?

I understand the problem this proposal is trying to solve, particularly the need to keep the SELinux policy store consistent with the operating system across snapshots and rollbacks.

However, I wonder whether moving the entire SELinux policy store into /etc is the right long-term architectural decision.

Traditionally, /etc is intended for system configuration. Moving compiled policies, installed modules, and generated policy state into /etc introduces content that is not necessarily configuration.

For example, I manage /etc using Git. I could certainly add exclusions for the SELinux policy store, but should this kind of generated state be placed under /etc in the first place?

We already have another interesting precedent: the RPM database was relocated to /usr/lib/sysimage/rpm. This makes sense in terms of associating the database with the installed operating system, but /usr has different operational characteristics in traditional Fedora and Atomic variants such as Silverblue.

Perhaps we should consider whether modern Linux distributions need a new top-level directory specifically for system state that must remain associated with the operating system installation or deployment.

Such a directory could have different characteristics depending on the distribution model:

  • Traditional Fedora: writable, allowing RPM/DNF and other system management tools to update its contents.

  • Fedora Silverblue and other Atomic variants: read-only in the active deployment, with its contents updated as part of a new deployment and kept consistent across rollbacks.

For example, a possible filesystem layout could be:

/<name-to-be-decided>/
├── rpm/
└── selinux/
    └── targeted/
        └── active/

The actual directory name is deliberately left undefined. Choosing an appropriate, descriptive, and future-proof name should be part of the discussion, ideally involving other Linux distributions.

The important point is that the same directory structure could be used by both traditional Fedora and Atomic variants, while its write and deployment semantics would differ.

This would provide a dedicated location for operating-system-associated state without continuing to expand the responsibilities of /etc, /usr, or /var.

The RPM database and SELinux policy store would be the initial candidates for this new location. Additional components could be considered in the future, but only when their requirements justify it.

I am not suggesting moving all generated state out of /var, replacing /run, or redesigning the entire filesystem hierarchy.

There is also a useful historical precedent.

In 2011, Linux distributions introduced /run to address a problem that the existing filesystem hierarchy did not adequately solve. Fedora, Debian, Ubuntu, and SUSE coordinated on the approach, and /run was eventually incorporated into FHS 3.0 in 2015.

Perhaps we are facing another situation where the requirements of modern Linux distributions have evolved beyond some of the assumptions of the existing filesystem hierarchy.

If so, I think the directory name and its semantics should be carefully chosen from the beginning, because once adopted by distributions, changing them later would be extremely difficult.

This should ideally be discussed with other Linux distributions and relevant upstream projects rather than becoming another Fedora-specific filesystem convention.

We have spent years trying to simplify historical filesystem layouts and eliminate legacy behavior. It would be unfortunate to solve today’s problems by introducing decisions that become tomorrow’s legacy.

I am not proposing a specific directory name or expecting this entire architectural change to be implemented in Fedora 46. A gradual migration over future releases could be more appropriate.

My main concern is whether we should first consider a more future-proof filesystem layout before committing additional generated system state to /etc.

Even if cross-distribution agreement proves difficult, I think the question is worth discussing.

3 Likes

I appreciate your idea on this aspect and I agree, distributions are evolving, and a new layout standard needs to be defined for all relevant upstream projects and distributions to keep consistency on some critical components for traditional/immutable/atomic systems that use a rollback mechanism.

1 Like

I’m editing this post to include your idea.

2 Likes

While I appreciate the idea, this seems to havr not followed the change proposal submission procedure. Please either rename the topic or close it and follow that process.

As for the proposal itself:

  • introduction of a new top-level is a highly loaded topic, it should be discussed on its own
  • using both /usr and /etc is standard practice, and am I missing something, because it seems to already be provided (see selinux-policy for example)
  • the current trend is to move away from distro owned files from being installed in /etc precisely because of atomic desktops and not being able to overwrite anything other than /usr. The usual approach is to allow multiple locations and merger of the configuration
2 Likes

I’ll edit the topic bc currently I’m not a Fedora developer, and I’m not familiar with the infrastructure and process to become one.

If anyone wants to take this idea and make a proposal following the procedure, they can do so without any problem.

But I would recommend considering, in the long term, a standard that would bring all this configuration together in one place—just as a suggestion.

Based on the votes, several users agree to relocate the SELinux store to /etc/selinux for now; please keep this in mind for a future release.

2 Likes

Thank you, appreciate the renaming of the topic.

Yes this is an active topic, see the moving of /etc/yum.repos.d to /usr for F45.

And for selinux it seems you got the answer on the mail thread that the selinux developers are indeed working on this.

There is not a grand proposal to move everything, probably since everything inter-depends on everything. But you could consider a proposal to deprecate and not add more packages that use non-standard install locations. /var I believe is already checked at least through fedora-review.

3 Likes