Skip to content

Commit aa4029d

Browse files
n0toosel0kod
authored andcommitted
fs: Add more background to path_beneath_rules() doc
This example is shown at the homepage of rust-landlock's documentation, and essentially serves as some sort of an introduction to implementers. Since this example serves as some sort of a "first impression", it is quite easy for the reader to make a false generalization. To fix this, some additional background regarding the compatibility of rules was provided. Additionally, I attempted to separate the role of file descriptors and paths, as well as add a subtle separation between Landlock (the LSM) and rust-landlock (the crate). Signed-off-by: Panagiotis "Ivory" Vasilopoulos <git@n0toose.net>
1 parent a7c2b3f commit aa4029d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/fs.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,16 @@ fn path_fd() {
552552
///
553553
/// # Note
554554
///
555-
/// Landlock rules operate on file descriptors, not paths. This is a helper to create rules based on paths. **It
556-
/// silently ignores paths that cannot be opened**, and automatically adjusts access rights according to file types when
557-
/// possible.
555+
/// From the kernel's perspective, Landlock rules operate on file descriptors, not paths.
556+
/// This is a helper to create rules based on paths. Here, `path_beneath_rules()` silently ignores
557+
/// paths that cannot be opened, hence making the obtainment of a file descriptor impossible. When
558+
/// possible and for a given path, `path_beneath_rules()` automatically adjusts [access rights](`AccessFs`),
559+
/// depending on whether a directory or a file is present at that said path.
560+
///
561+
/// This behavior is the result of [`CompatLevel::BestEffort`], which is the default compatibility level of
562+
/// all created rulesets. Thus, it applies to the example below. However, if [`CompatLevel::HardRequirement`]
563+
/// is set using [`Compatible::set_compatibility`], attempting to create an incompatible rule at runtime will cause
564+
/// this crate to raise an error instead.
558565
///
559566
/// # Example
560567
///

0 commit comments

Comments
 (0)