Knowledge Base:Inserting base module in module store fails with duplicate declaration

Synopsis
When installing the package, the postinstall phase fails with the following error:

The package however is installed correctly.

Environment
This article applies to Gentoo Linux installations with a SELinux profile:

Analysis
The error itself means that the new policy cannot be inserted because an already running, but different, module provides the same type or attribute. For instance, suppose that  is declared by the   SELinux module, then a definition of   in the base policy will hold back the installation of this module as long as the   module is still loaded.

Sadly, there is no method available (yet) to look into modules and see what they offer, which means it is sometimes a trial and error. Luckily, we can extract some information from the modules that helps this trail and error method to be sufficiently fast.

Resolution
We first need to find the culprit module that is also defining the offending type (in the example, this is ). One method is to find any occurrence of the string " " in the available modules:

In the above example, there are two modules that have some reference to ; one is the "official" screen module, the second one is a module created by the user to update the policy (here called   but can be anything). Assuming the latter is the offending module, unload it:

After this, try to reload the base policy:

If inserting the base module still fails, unload the other module as well ( in our example) and retry.

Afterwards, rebuild the offending modules (through so that the updated policy is back in place.