Skip to content

Commit b80c553

Browse files
authored
Merge pull request #76 from LeChatP/dev
v3.1.1 Fix regression with path management, please update
2 parents 52127d6 + ed2d22a commit b80c553

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ members = ["xtask", "rar-common"]
44
[package]
55
name = "rootasrole"
66
# The project version is managed on json file in resources/rootasrole.json
7-
version = "3.1.0"
7+
version = "3.1.1"
88
rust-version = "1.76.0"
99
authors = ["Eddie Billoir <[email protected]>"]
1010
edition = "2021"
@@ -64,7 +64,7 @@ serde_json = "1.0"
6464
toml = "0.8"
6565

6666
[dependencies]
67-
rar-common = { path = "rar-common", version = "3.0.3", package = "rootasrole-core" }
67+
rar-common = { path = "rar-common", version = "3.1.0", package = "rootasrole-core" }
6868
log = "0.4"
6969
libc = "0.2"
7070
strum = { version = "0.26", features = ["derive"] }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<!-- The project version is managed on json file in resources/rootasrole.json -->
1515
<!-- markdownlint-restore -->
1616

17-
# RootAsRole (V3.1.0) — A better alternative to `sudo(-rs)`/`su` • ⚡ Blazing fast • 🛡️ Memory-safe • 🔐 Security-oriented
17+
# RootAsRole (V3.1.1) — A better alternative to `sudo(-rs)`/`su` • ⚡ Blazing fast • 🛡️ Memory-safe • 🔐 Security-oriented
1818

1919
RootAsRole is a Linux/Unix privilege delegation tool based on **Role-Based Access Control (RBAC)**. It empowers administrators to assign precise privileges — not full root — to users and commands.
2020

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.1.0"
3+
version = "3.1.1"
44
edition = "2021"
55
description = "This core crate contains the RBAC and main features for the RootAsRole project."
66
license = "LGPL-3.0-or-later"

src/sr/finder/mod.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl BestExecSettings {
125125
}
126126
result.env = opt_stack
127127
.calc_temp_env(opt_stack.calc_override_behavior(), &cli.opt_filter)
128-
.calc_final_env(env_vars, env_path, cred)?;
128+
.calc_final_env(env_vars, opt_stack.calc_path(env_path), cred)?;
129129
result.auth = opt_stack.calc_authentication();
130130
result.bounding = opt_stack.calc_bounding();
131131
result.timeout = opt_stack.calc_timeout();
@@ -386,13 +386,34 @@ mod tests {
386386

387387
#[test]
388388
fn test_retrieve_settings_no_matching_role() {
389-
let cli = dummy_cli();
389+
let cli = Cli::builder().cmd_path("/usr/bin/cat".to_string()).build();
390390
let cred = dummy_cred();
391391
let data = dummy_dconfigfinder();
392392
let env_vars = vec![("KEY", "VALUE")];
393393
let env_path = &["/bin"];
394394
let result = BestExecSettings::retrieve_settings(&cli, &cred, &data, env_vars, env_path);
395+
assert!(!result.is_ok());
396+
}
397+
398+
#[test]
399+
fn test_retrieve_settings_with_matching_role() {
400+
let cli = dummy_cli();
401+
let cred = dummy_cred();
402+
let data = dummy_dconfigfinder();
403+
let env_vars = vec![("KEY", "VALUE")];
404+
let env_path = &["/UNWANTED"];
405+
let result = BestExecSettings::retrieve_settings(&cli, &cred, &data, env_vars, env_path);
395406
assert!(result.is_ok());
407+
let settings = result.unwrap();
408+
assert_eq!(settings.final_path, PathBuf::from("/usr/bin/ls"));
409+
assert_eq!(settings.role, "test");
410+
assert_eq!(settings.task, Some("0".to_string()));
411+
assert!(!settings.setuid.is_some());
412+
assert!(!settings.setgroups.is_some());
413+
assert!(settings.caps.is_some());
414+
assert!(!settings.env.is_empty());
415+
assert!(!settings.env_path.is_empty());
416+
assert!(settings.env_path.iter().all(|p| p != "/UNWANTED"));
396417
}
397418

398419
#[test]

src/sr/finder/options.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<'a> DEnvOptions<'a> {
289289
pub fn calc_final_env(
290290
&self,
291291
env_vars: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
292-
env_path: &[&str],
292+
env_path: impl IntoIterator<Item = impl AsRef<str>>,
293293
target: &Cred,
294294
) -> Result<HashMap<String, String>, Box<dyn Error>> {
295295
let mut final_set = match self.default_behavior {
@@ -325,11 +325,11 @@ impl<'a> DEnvOptions<'a> {
325325
}?;
326326
final_set.insert(
327327
"PATH".into(),
328-
env_path.iter().fold(String::new(), |acc, path| {
328+
env_path.into_iter().fold(String::new(), |acc, path| {
329329
if acc.is_empty() {
330-
path.to_string()
330+
path.as_ref().to_string()
331331
} else {
332-
format!("{}:{}", acc, path)
332+
format!("{}:{}", acc, path.as_ref())
333333
}
334334
}),
335335
);

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.1.0"
4+
version = "3.1.1"
55
edition = "2021"
66
publish = false
77

0 commit comments

Comments
 (0)