Skip to content

Commit 5dfa43c

Browse files
authored
Merge pull request #89 from LeChatP/dev
feat: add landlock glob pattern
2 parents 3a9885b + 4368869 commit 5dfa43c

File tree

7 files changed

+32
-14
lines changed

7 files changed

+32
-14
lines changed

Cargo.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = ["xtask", "rar-common"]
33

44
[package]
55
name = "rootasrole"
6-
version = "3.3.1"
6+
version = "3.3.2"
77
rust-version = "1.83.0"
88
authors = ["Eddie Billoir <lechatp@outlook.fr>"]
99
edition = "2021"
@@ -59,7 +59,7 @@ hashchecker = ["dep:hex", "dep:sha2"]
5959
ssd = []
6060
hierarchy = []
6161
timeout = []
62-
landlock = ["dep:landlock", "dep:bitflags"]
62+
landlock = ["dep:landlock", "dep:bitflags", "dep:glob"]
6363
editor = ["dep:landlock", "dep:libseccomp", "dep:pest", "dep:pest_derive", "dep:linked_hash_set"]
6464

6565
[lints.rust]
@@ -69,7 +69,7 @@ unexpected_cfgs = { level = "allow", check-cfg = ['cfg(tarpaulin_include)'] }
6969
toml = { version = "0.8", default-features = false, features = ["parse", "display", "preserve_order"] }
7070

7171
[dependencies]
72-
rar-common = { path = "rar-common", version = "3.3.1", package = "rootasrole-core" }
72+
rar-common = { path = "rar-common", version = "3.3.2", package = "rootasrole-core" }
7373
log = { version = "0.4", default-features = false, features = ["std"] }
7474
libc = { version = "0.2", default-features = false, features = ["std"]}
7575
strum = { version = "0.26", default-features = false, features = ["derive"] }
@@ -87,6 +87,7 @@ bon = { version = "3", default-features = false }
8787
nonstick = { version = "0.1.1", optional = true }
8888
libpam-sys = { version = "0.2.0", default-features = false, optional = true }
8989
pcre2 = { version = "0.2", default-features = false, optional = true }
90+
glob = { version = "0.3", default-features = false, optional = true }
9091
sha2 = { version = "0.10", default-features = false, optional = true }
9192
pty-process = { version = "0.4", default-features = false, optional = true }
9293
once_cell = { version = "1.20", default-features = false, optional = true, features = ["std"] }

rar-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rootasrole-core"
3-
version = "3.3.1"
3+
version = "3.3.2"
44
edition = "2021"
55
description = "This core crate for the RootAsRole project."
66
license = "LGPL-3.0-or-later"

resources/man/en_US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
% RootAsRole(8) RootAsRole 3.3.1 | System Manager's Manual
1+
% RootAsRole(8) RootAsRole 3.3.2 | System Manager's Manual
22
% Eddie Billoir <lechatp@outlook.fr>
33
% August 2025
44

resources/man/fr_FR.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
% RootAsRole(8) RootAsRole 3.3.1 | Manuel de l'administrateur système
1+
% RootAsRole(8) RootAsRole 3.3.2 | Manuel de l'administrateur système
22
% Eddie Billoir <lechatp@outlook.fr>
33
% Août 2025
44

src/sr/finder/api/landlock.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{collections::HashMap, path::PathBuf};
22

33
use bitflags::bitflags;
4+
use glob::glob;
45
use landlock::{
56
Access, AccessFs, BitFlags, PathBeneath, PathFd, Ruleset, RulesetAttr, RulesetCreatedAttr, ABI,
67
};
@@ -130,10 +131,25 @@ fn pre_exec(event: &mut ApiEvent) -> SrResult<()> {
130131

131132
for (path, access) in whitelist.iter() {
132133
let landlock_access = get_landlock_access(*access);
133-
let path_fd = PathFd::new(path).map_err(|_| SrError::ConfigurationError)?;
134-
ruleset = ruleset
135-
.add_rule(PathBeneath::new(path_fd, landlock_access))
136-
.map_err(|_| SrError::ConfigurationError)?;
134+
match glob(&path.to_string_lossy()) {
135+
Ok(paths) => {
136+
for entry in paths {
137+
if let Ok(p) = entry {
138+
let path_fd =
139+
PathFd::new(p).map_err(|_| SrError::ConfigurationError)?;
140+
ruleset = ruleset
141+
.add_rule(PathBeneath::new(path_fd, landlock_access))
142+
.map_err(|_| SrError::ConfigurationError)?;
143+
}
144+
}
145+
}
146+
Err(_) => {
147+
let path_fd = PathFd::new(path).map_err(|_| SrError::ConfigurationError)?;
148+
ruleset = ruleset
149+
.add_rule(PathBeneath::new(path_fd, landlock_access))
150+
.map_err(|_| SrError::ConfigurationError)?;
151+
}
152+
}
137153
}
138154

139155
ruleset

xtask/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "xtask"
33
# The project version is managed on json file in resources/rootasrole.json
4-
version = "3.3.1"
4+
version = "3.3.2"
55
edition = "2021"
66
publish = false
77

0 commit comments

Comments
 (0)