Skip to content

Commit f2ed1de

Browse files
authored
Merge pull request #62 from LeChatP/temp
Fix install process
2 parents a44820e + e606250 commit f2ed1de

File tree

28 files changed

+252
-259
lines changed

28 files changed

+252
-259
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
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.0.3"
7+
version = "3.0.4"
88
rust-version = "1.76.0"
99
authors = ["Eddie Billoir <eddie.billoir@irit.fr>"]
1010
edition = "2021"

README.md

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

19-
# RootAsRole (V3.0.3) : A memory-safe and security-oriented alternative to sudo/su commands
19+
# RootAsRole (V3.0.4) : A memory-safe and security-oriented alternative to sudo/su commands
2020

2121
**RootAsRole** is a project to allow Linux/Unix administrators to delegate their administrative tasks access rights to users. Its main features are :
2222

@@ -33,6 +33,12 @@
3333
* [glob](https://docs.rs/glob/latest/glob/) for binary path
3434
* [PCRE2](https://www.pcre.org/) for command arguments
3535

36+
If you need help to configure a RootAsRole policy, you can use our **[capable tool](https://github.com/LeChatP/RootAsRole-capable)**. This tool identifies the rights required by specific commands, making it easier to define a precise policy.
37+
38+
For administrators who already use **Ansible playbooks** for their tasks and wish to implement **RootAsRole**, our tool [gensr](https://github.com/LeChatP/RootAsRole-utils) can generate an initial draft of a **RootAsRole policy**. The `gensr` tool works by running your Ansible playbook alongside the [capable tool](https://github.com/LeChatP/RootAsRole-capable), creating a draft policy based on the observed required rights. This process helps administrators to harden their Ansible tasks. It helps to verify eventual third-party supply-chain attacks.
39+
40+
**Note:** The `gensr` tool is still in development and may not work with all playbooks. If you wish to contribute to this project, feel free to make issues and pull requests.
41+
3642
## <img src="https://lechatp.github.io/RootAsRole/favicon.svg" width="20px"/> You can find every interesting resources using [the RootAsRole User/Knowledge/Reference Guide Book](https://lechatp.github.io/RootAsRole/).</h2>
3743

3844
## Installation

book/src/chsr/file-config.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The following example shows a RootAsRole config without plugins when almost ever
2323
```json
2424
{
2525
"version": "3.0.0-alpha.4", // Version of the configuration file
26-
"storage": { // Storage settings, where the Roles and Execution options are stored
26+
"storage": { // Storage settings, Roles storage location
2727
"method": "json", // Storage method
2828
"settings": { // Storage settings
2929
"immutable": false, // Program return error if the file is not immutable, default is true
@@ -32,7 +32,7 @@ The following example shows a RootAsRole config without plugins when almost ever
3232
},
3333
"options": {
3434
"path": { // Path options
35-
"default": "delete", // Default policy for path, delete-all, keep-safe, keep-unsafe, inherit
35+
"default": "delete", // Default policy for path, delete, keep-safe, keep-unsafe, inherit
3636
"add": [ // Paths to add to the whitelist
3737
"path1",
3838
"path2"
@@ -43,7 +43,7 @@ The following example shows a RootAsRole config without plugins when almost ever
4343
]
4444
},
4545
"env": { // Environment options
46-
"default": "delete", // Default policy for environment, delete-all, keep-all, inherit
46+
"default": "delete", // Default policy for environment, delete, keep, inherit
4747
"keep": [ // Environment variables to keep
4848
"env1",
4949
"env2"
@@ -57,25 +57,25 @@ The following example shows a RootAsRole config without plugins when almost ever
5757
"env6"
5858
]
5959
},
60-
"root": "privileged", // Default policy for root, privileged, user, inherit
61-
"bounding": "ignore", // Default policy for bounding, strict, ignore, inherit
60+
"root": "privileged", // Default policy for root: privileged, user, inherit
61+
"bounding": "ignore", // Default policy for bounding: strict, ignore, inherit
6262
"wildcard-denied": "*", // Characters denied in any binary path
6363
"timeout": {
64-
"type": "ppid", // Type of timeout, tty, ppid, uid
65-
"duration": "15:30:30", // Duration of the timeout
64+
"type": "ppid", // Type of timeout: tty, ppid, uid
65+
"duration": "15:30:30", // Duration of the timeout in HH:MM:SS format
6666
"max_usage": 1 // Maximum usage before timeout expires
6767
}
6868
},
6969
"roles": [ // Role list
7070
{
7171
"name": "complete", // Role name
72-
"actors": [ // Actors granted
72+
"actors": [ // Actors granted to the role
7373
{
7474
"id": 0, // ID of the actor, could be a name
75-
"type": "user" // Type of actor, user, group
75+
"type": "user" // Type of actor: user, group
7676
},
7777
{
78-
"groups": 0, // ID of the group, could be a name
78+
"groups": 0, // ID of the group or a list of ID for AND condition
7979
"type": "group"
8080
},
8181
{
@@ -106,6 +106,14 @@ The following example shows a RootAsRole config without plugins when almost ever
106106
"CAP_SYS_ADMIN",
107107
"CAP_SYS_BOOT"
108108
]
109+
},
110+
// Dbus credentials are relied to Dbus and Polkit policies. They can be enforced using `gensr` tool
111+
"dbus": [
112+
"org.freedesktop.login1.Reboot", // DBus method to allow
113+
],
114+
// File credentials are relied to file permissions. They can be enforced using `gensr` tool
115+
"file": {
116+
"/path/to/file": "R", // File path and permission, r for read, w for write, x for execute
109117
}
110118
},
111119
"commands": {
@@ -648,3 +656,7 @@ Here is an example global configuration:
648656
```
649657

650658
The `check` list is a list of environment variables that will be checked for unsafe characters. If an environment variable contains unsafe characters, it will be removed from the environment.
659+
660+
## What are dbus and file credentials fields?
661+
662+
the `dbus` and `file` fields are used for gensr tool from RootAsRole-utils repository. They are enforced to the DBus and file permissions. The `dbus` field is used to allow DBus methods. The `file` field is used to allow file permissions. The gensr tool will generate the DBus and file permissions in according to the `setuid` credentials. So gensr tool requires the `setuid` field to be set.

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

rar-common/src/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::sync::Mutex;
22

33
use capctl::CapSet;
44

5+
#[cfg(feature = "finder")]
6+
use log::debug;
57
#[cfg(feature = "finder")]
68
use serde_json::Value;
79
use strum::EnumIs;
8-
#[cfg(feature = "finder")]
9-
use log::debug;
1010

1111
#[cfg(feature = "finder")]
1212
use crate::database::finder::{Cred, ExecSettings, FilterMatcher, TaskMatch, UserMin};

rar-common/src/database/finder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ use std::{
99

1010
use capctl::CapSet;
1111
use glob::Pattern;
12+
use log::{debug, warn};
1213
use nix::{
1314
libc::dev_t,
1415
unistd::{Group, Pid, User},
1516
};
1617
#[cfg(feature = "pcre2")]
1718
use pcre2::bytes::RegexBuilder;
1819
use strum::EnumIs;
19-
use log::{debug, warn};
2020

2121
use crate::database::{
2222
options::{Opt, OptStack},

rar-common/src/database/migration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::error::Error;
22

3-
use semver::Version;
43
use log::debug;
4+
use semver::Version;
55

66
use crate::version::PACKAGE_VERSION;
77

rar-common/src/database/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::path::Path;
12
use std::{cell::RefCell, error::Error, rc::Rc};
23

34
use crate::save_settings;
@@ -6,8 +7,8 @@ use crate::version::PACKAGE_VERSION;
67

78
use chrono::Duration;
89
use linked_hash_set::LinkedHashSet;
9-
use serde::{de, Deserialize, Serialize};
1010
use log::debug;
11+
use serde::{de, Deserialize, Serialize};
1112

1213
use self::{migration::Migration, options::EnvKey, structs::SConfig, versionning::Versioning};
1314

@@ -36,25 +37,24 @@ pub fn make_weak_config(config: &Rc<RefCell<SConfig>>) {
3637
}
3738
}
3839

39-
pub fn read_json_config(
40+
pub fn read_json_config<P: AsRef<Path>>(
4041
settings: Rc<RefCell<SettingsFile>>,
42+
settings_path: P,
4143
) -> Result<Rc<RefCell<SConfig>>, Box<dyn Error>> {
4244
let default_remote: RemoteStorageSettings = RemoteStorageSettings::default();
43-
let default = &ROOTASROLE.into();
4445
let binding = settings.as_ref().borrow();
4546
let path = binding
4647
.storage
4748
.settings
4849
.as_ref()
4950
.unwrap_or(&default_remote)
5051
.path
51-
.as_ref()
52-
.unwrap_or(default);
53-
if path == default {
52+
.as_ref();
53+
if path.is_none() || path.is_some_and(|p| p == settings_path.as_ref()) {
5454
make_weak_config(&settings.as_ref().borrow().config);
55-
Ok(settings.as_ref().borrow().config.clone())
55+
return Ok(settings.as_ref().borrow().config.clone());
5656
} else {
57-
let file = open_with_privileges(path)?;
57+
let file = open_with_privileges(path.unwrap())?;
5858
warn_if_mutable(
5959
&file,
6060
settings

rar-common/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ const ROOTASROLE: &str = "target/rootasrole.json";
5454

5555
use std::{cell::RefCell, error::Error, ffi::OsStr, path::PathBuf, rc::Rc};
5656

57-
use serde::{Deserialize, Serialize};
5857
use log::debug;
58+
use serde::{Deserialize, Serialize};
5959

6060
pub mod api;
6161
pub mod database;
@@ -183,7 +183,7 @@ impl Default for Settings {
183183
fn default() -> Self {
184184
Self {
185185
method: StorageMethod::JSON,
186-
settings: Some(RemoteStorageSettings::default()),
186+
settings: None,
187187
ldap: None,
188188
}
189189
}
@@ -193,7 +193,7 @@ impl Default for RemoteStorageSettings {
193193
fn default() -> Self {
194194
Self {
195195
immutable: None,
196-
path: Some(ROOTASROLE.into()),
196+
path: None,
197197
host: None,
198198
port: None,
199199
auth: None,

rar-common/src/plugin/hashchecker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use crate::{
66
open_with_privileges,
77
util::{final_path, parse_conf_command},
88
};
9+
use log::{debug, warn};
910
use nix::unistd::{access, AccessFlags};
1011
use serde::{Deserialize, Serialize};
11-
use log::{debug, warn};
1212

1313
use libc::FS_IOC_GETFLAGS;
1414
use sha2::Digest;

0 commit comments

Comments
 (0)