| 1 |
package landlock |
| 2 |
|
| 3 |
// Rule represents one or more Landlock rules which can be added to a |
| 4 |
// Landlock ruleset. |
| 5 |
type Rule interface { |
| 6 |
// compatibleWithConfig is true if the given rule is |
| 7 |
// compatible with the configuration c. |
| 8 |
compatibleWithConfig(c Config) bool |
| 9 |
|
| 10 |
// downgrade returns a downgraded rule for "best effort" mode, |
| 11 |
// under the assumption that the kernel only supports c. |
| 12 |
// |
| 13 |
// It establishes that: |
| 14 |
// |
| 15 |
// - rule.accessFS ⊆ handledAccessFS for FSRules |
| 16 |
// - rule.accessNet ⊆ handledAccessNet for NetRules |
| 17 |
// |
| 18 |
// If the rule is unsupportable under the given Config at |
| 19 |
// all, ok is false. This happens when c represents a Landlock |
| 20 |
// V1 system but the rule wants to grant the refer right on |
| 21 |
// a path. "Refer" operations are always forbidden under |
| 22 |
// Landlock V1. |
| 23 |
// |
| 24 |
// This may yield a rule with empty access rights, but those |
| 25 |
// are a no-op when you apply them with addToRuleset(). |
| 26 |
downgrade(c Config) (out Rule, ok bool) |
| 27 |
|
| 28 |
// addToRuleset applies the rule to the given rulesetFD. |
| 29 |
// |
| 30 |
// This operation may be a no-op if the given rule requires |
| 31 |
// not access rights for the object that it refers to, |
| 32 |
// which can happen during downgrade(). |
| 33 |
// |
| 34 |
// This may return errors such as "file not found" depending |
| 35 |
// on the rule type. |
| 36 |
addToRuleset(rulesetFD int, c Config) error |
| 37 |
} |