Skip to content

Implement common traits for public types#108

Merged
l0kod merged 1 commit intolandlock-lsm:mainfrom
l0kod:abi-traits
Sep 14, 2025
Merged

Implement common traits for public types#108
l0kod merged 1 commit intolandlock-lsm:mainfrom
l0kod:abi-traits

Conversation

@l0kod
Copy link
Member

@l0kod l0kod commented Sep 11, 2025

Implement Debug for ABI, Ruleset, RulesetCreated, PathBeneath, PathFd, and NetPort (and other non-public dependencies). Derived Debug formats are not stable:
https://doc.rust-lang.org/stable/std/fmt/trait.Debug.html#stability

Implement PartialEq, Eq, PartialOrd, and Ord for ABI.

This might be needed when these types are wrapped (see LandlockConfig).

See #82

Implement Debug for ABI, Ruleset, RulesetCreated, PathBeneath, PathFd,
and NetPort (and other non-public dependencies).  Derived Debug formats
are not stable:
https://doc.rust-lang.org/stable/std/fmt/trait.Debug.html#stability

Implement PartialEq, Eq, PartialOrd, and Ord for ABI.

This might be needed when these types are wrapped (see LandlockConfig).

Closes: landlock-lsm#82
Signed-off-by: Mickaël Salaün <mic@digikod.net>
l0kod added a commit to l0kod/landlockconfig that referenced this pull request Sep 11, 2025
TODO: Remove patch.cartes-io once this PR land:
landlock-lsm/rust-landlock#108

In preparation to replace the "vN." prefixes with a global max ABI
version.  This new approach is flexible enough and simpler.

This is now possible thanks to the composition feature (each file can
have a dedicated max ABI) and its similar to the use of a local
variable.

The variable `abi = 4` is the highest version of the Landlock ABI, which
should replace the hardcoded v4 uses.  This is convenient to update
configurations to newest Landlock features by only updating one line
instead of all use of vN.

Example:

  abi = 4

  [[ruleset]]
  handled_access_fs = ["abi.all"]

  [[path_beneath]]
  allowed_access = ["abi.read_execute"]
  parent = ["/usr"]

Signed-off-by: Mickaël Salaün <mic@digikod.net>
l0kod added a commit to l0kod/landlockconfig that referenced this pull request Sep 11, 2025
TODO: Remove patch.cartes-io once this PR land:
landlock-lsm/rust-landlock#108

TODO: Factor out code

In preparation to replace the "vN." prefixes with a global max ABI
version.  This new approach is flexible enough and simpler.

This is now possible thanks to the composition feature (each file can
have a dedicated max ABI) and its similar to the use of a local
variable.

The variable `abi = 4` is the highest version of the Landlock ABI, which
should replace the hardcoded v4 uses.  This is convenient to update
configurations to newest Landlock features by only updating one line
instead of all use of vN.

Example:

  abi = 4

  [[ruleset]]
  handled_access_fs = ["abi.all"]

  [[path_beneath]]
  allowed_access = ["abi.read_execute"]
  parent = ["/usr"]

Signed-off-by: Mickaël Salaün <mic@digikod.net>
l0kod added a commit to l0kod/landlockconfig that referenced this pull request Sep 14, 2025
TODO: Remove patch.cartes-io once this PR land:
landlock-lsm/rust-landlock#108

TODO: Factor out code

In preparation to replace the "vN." prefixes with a global max ABI
version.  This new approach is flexible enough and simpler.

This is now possible thanks to the composition feature (each file can
have a dedicated max ABI) and its similar to the use of a local
variable.

For instance, the variable `abi = 4` represents the highest version of
the Landlock ABI in a configuration file, which should replace the
hardcoded v4 uses.  This is convenient to update configurations to
newest Landlock features by only updating one line instead of all use of
vN.

Example:

  abi = 4

  [[ruleset]]
  handled_access_fs = ["abi.all"]

  [[path_beneath]]
  allowed_access = ["abi.read_execute"]
  parent = ["/usr"]

Add new ValueAccess enums and AbiGroup trait to factor out common code.
Replace get_fs_read_execute() and get_fs_read_write() with
AbiGroupFs::ReadExecute and AbiGroupFs::ReadWrite.

Signed-off-by: Mickaël Salaün <mic@digikod.net>
l0kod added a commit to l0kod/landlockconfig that referenced this pull request Sep 14, 2025
TODO: Remove patch.cartes-io once this PR land:
landlock-lsm/rust-landlock#108

TODO: Factor out code

In preparation to replace the "vN." prefixes with a global max ABI
version.  This new approach is flexible enough and simpler.

This is now possible thanks to the composition feature (each file can
have a dedicated max ABI) and its similar to the use of a local
variable.

For instance, the variable `abi = 4` represents the highest version of
the Landlock ABI in a configuration file, which should replace the
hardcoded v4 uses.  This is convenient to update configurations to
newest Landlock features by only updating one line instead of all use of
vN.

Example:

  abi = 4

  [[ruleset]]
  handled_access_fs = ["abi.all"]

  [[path_beneath]]
  allowed_access = ["abi.read_execute"]
  parent = ["/usr"]

Add new ValueAccess enums and AbiGroup trait to factor out common code.
Replace get_fs_read_execute() and get_fs_read_write() with
AbiGroupFs::ReadExecute and AbiGroupFs::ReadWrite.

Signed-off-by: Mickaël Salaün <mic@digikod.net>
@l0kod l0kod merged commit 19f01a9 into landlock-lsm:main Sep 14, 2025
19 checks passed
@l0kod l0kod deleted the abi-traits branch September 14, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant