Add mls_cats property to se_policy_conf

To support overriding mls_num_cats for devices which don't need MLS

Bug: 223596384
Test: build
Change-Id: I007d3bab51e0aa67b14c2af1e92bee1d644ef4c7
This commit is contained in:
Inseob Kim 2022-03-10 13:15:05 +09:00
parent e29df1ec4a
commit 6e384f3a4b

View file

@ -88,6 +88,9 @@ type policyConfProperties struct {
// Whether this module is directly installable to one of the partitions. Default is true // Whether this module is directly installable to one of the partitions. Default is true
Installable *bool Installable *bool
// Desired number of MLS categories. Defaults to 1024
Mls_cats *int64
} }
type policyConf struct { type policyConf struct {
@ -189,6 +192,10 @@ func (c *policyConf) enforceDebugfsRestrictions(ctx android.ModuleContext) strin
return strconv.FormatBool(ctx.DeviceConfig().BuildDebugfsRestrictionsEnabled()) return strconv.FormatBool(ctx.DeviceConfig().BuildDebugfsRestrictionsEnabled())
} }
func (c *policyConf) mlsCats() int {
return proptools.IntDefault(c.properties.Mls_cats, MlsCats)
}
func findPolicyConfOrder(name string) int { func findPolicyConfOrder(name string) int {
for idx, pattern := range policyConfOrder { for idx, pattern := range policyConfOrder {
if pattern == name || (pattern == "*.te" && strings.HasSuffix(name, ".te")) { if pattern == name || (pattern == "*.te" && strings.HasSuffix(name, ".te")) {
@ -212,7 +219,7 @@ func (c *policyConf) transformPolicyToConf(ctx android.ModuleContext) android.Ou
Flag("--fatal-warnings"). Flag("--fatal-warnings").
FlagForEachArg("-D ", ctx.DeviceConfig().SepolicyM4Defs()). FlagForEachArg("-D ", ctx.DeviceConfig().SepolicyM4Defs()).
FlagWithArg("-D mls_num_sens=", strconv.Itoa(MlsSens)). FlagWithArg("-D mls_num_sens=", strconv.Itoa(MlsSens)).
FlagWithArg("-D mls_num_cats=", strconv.Itoa(MlsCats)). FlagWithArg("-D mls_num_cats=", strconv.Itoa(c.mlsCats())).
FlagWithArg("-D target_arch=", ctx.DeviceConfig().DeviceArch()). FlagWithArg("-D target_arch=", ctx.DeviceConfig().DeviceArch()).
FlagWithArg("-D target_with_asan=", c.withAsan(ctx)). FlagWithArg("-D target_with_asan=", c.withAsan(ctx)).
FlagWithArg("-D target_with_dexpreopt=", strconv.FormatBool(ctx.DeviceConfig().WithDexpreopt())). FlagWithArg("-D target_with_dexpreopt=", strconv.FormatBool(ctx.DeviceConfig().WithDexpreopt())).