Skip to content

Commit f0a3dc8

Browse files
committed
Reapply "1.0.0 Release"
This reverts commit 5e1e3d3.
1 parent 26fb480 commit f0a3dc8

File tree

41 files changed

+454
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+454
-278
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ jobs:
2727
account required pam_permit.so
2828
session [success=1 default=ignore] pam_permit.so
2929
session requisite pam_permit.so
30-
session required pam_permit.so" | tee /etc/pam.d/sr'
30+
session required pam_permit.so" | tee /etc/pam.d/dosr'
3131
- name: Install RootAsRole
3232
run: cargo xtask install -bip sudo
3333
- name: print config
34-
run: sr cat /etc/security/rootasrole.json
34+
run: dosr cat /etc/security/rootasrole.json
3535
- name: getenv
3636
run: env
37-
- name: Run Sr
37+
- name: Run dosr
3838
env:
3939
RUST_LOG: debug
40-
run: /usr/bin/sr -h
41-
- name: Run Chsr with sr
42-
run: sr /usr/bin/chsr -h
40+
run: /usr/bin/dosr -h
41+
- name: Run Chsr with dosr
42+
run: dosr /usr/bin/chsr -h

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "lldb",
99
"request": "launch",
1010
"name": "Launch",
11-
"program": "${workspaceFolder}/target/debug/sr",
11+
"program": "${workspaceFolder}/target/debug/dosr",
1212
"args": ["ls"],
1313
"cwd": "${workspaceFolder}"
1414
}

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"args": [
1515
"/usr/bin/setcap",
1616
"=p",
17-
"${cwd}/bin/sr"
17+
"${cwd}/bin/dosr"
1818
],
1919
"options": {
2020
"cwd": "${cwd}"

Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ version = "3.1.3"
88
rust-version = "1.76.0"
99
authors = ["Eddie Billoir <[email protected]>"]
1010
edition = "2021"
11-
default-run = "sr"
11+
default-run = "dosr"
1212
description = "An alternative to sudo that uses Linux capabilities and Role based access control."
1313
license = "LGPL-3.0-or-later"
1414
repository = "https://github.com/LeChatP/RootAsRole"
@@ -41,7 +41,7 @@ debug = true
4141
#srlibs = [ "pam-client", "bitflags" ]
4242

4343
[[bin]]
44-
name = "sr"
44+
name = "dosr"
4545
path = "src/sr/main.rs"
4646
required-features = ["finder"]
4747

@@ -76,8 +76,7 @@ serde = { version = "1.0", features=["rc", "derive"] }
7676
serde_json = "1.0"
7777
cbor4ii = { version = "1.0.0", features = ["serde", "serde1", "use_std"] }
7878
glob = "0.3"
79-
pam-client2 = "0.5"
80-
bitflags = { version = "2.6" }
79+
bitflags = { version = "2.9" }
8180
shell-words = "1.1"
8281
linked_hash_set = { version = "0.1" }
8382
derivative = "2.2"
@@ -89,9 +88,11 @@ pest = "2.7"
8988
pest_derive = "2.7"
9089
const_format = "0.2"
9190
hex = "0.4"
92-
bon = "3.5.1"
93-
serde_json_borrow = "0.7.1"
94-
konst = "0.3.16"
91+
bon = "3"
92+
serde_json_borrow = "0.8"
93+
konst = "0.3"
94+
nonstick = "0.1.1"
95+
libpam-sys = "0.2.0"
9596

9697
[dev-dependencies]
9798
log = "0.4"
@@ -121,7 +122,7 @@ changelog = "target/debian/changelog"
121122

122123
[package.metadata.generate-rpm]
123124
assets = [
124-
{ source = "target/release/sr", dest = "/usr/bin/sr", user = "root", group = "root", mode = "0555", caps = "=p" },
125+
{ source = "target/release/dosr", dest = "/usr/bin/dosr", user = "root", group = "root", mode = "0555", caps = "=p" },
125126
{ source = "target/release/chsr", dest = "/usr/bin/chsr", user = "root", group = "root", mode = "0555" },
126127
{ source = "resources/rh/rh_sr_pam.conf", dest = "/etc/pam.d/sr", user = "root", group = "root", mode = "0644", config = true },
127128
{ source = "resources/rootasrole.json", dest = "/etc/security/rootasrole.json", user = "root", group = "root", mode = "0644", config = true },

README.md

Lines changed: 6 additions & 5 deletions
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.3) — A better alternative to `sudo(-rs)`/`su` • ⚡ Blazing fast • 🛡️ Memory-safe • 🔐 Security-oriented
17+
# RootAsRole (V3.1.3) — A better alternative to `sudo(-rs
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

@@ -44,7 +44,7 @@ RootAsRole solves this:
4444

4545
## 📊 Why It’s Better Than Others
4646

47-
| Feature | setcap?? | doas | sudo | sudo-rs | sr (RootAsRole) |
47+
| Feature | setcap?? | doas | sudo | sudo-rs | dosr (RootAsRole) |
4848
|------------------------------------------|-------------------|------------|--------------------------------|--------------------------------|----------------------------------------------|
4949
| **Change user/groups** | N/A |||| ✅✅ mandatory or optional |
5050
| **Environment variables** | N/A | partial || partial ||
@@ -97,7 +97,7 @@ RootAsRole solves this:
9797
<pre>
9898
Execute privileged commands with a role-based access control system
9999

100-
<u><b>Usage</b></u>: <b>sr</b> [OPTIONS] [COMMAND]...
100+
<u><b>Usage</b></u>: <b>dosr</b> [OPTIONS] [COMMAND]...
101101

102102
<u><b>Arguments</b></u>:
103103
[COMMAND]... Command to execute
@@ -116,7 +116,8 @@ Execute privileged commands with a role-based access control system
116116

117117
If you're accustomed to utilizing the sudo tool and find it difficult to break that habit, consider creating an alias :
118118
```sh
119-
alias sudo="sr"
119+
alias sudo="dosr"
120+
alias sr="dosr"
120121
```
121122
122123
## 🏎️ Performance
@@ -132,7 +133,7 @@ RootAsRole **3.1.0** introduced **CBOR** support, significantly boosting perform
132133
133134
### Why Performance Matters
134135
135-
When using **Ansible** (or any automation tool), every task that uses `become: true` will invoke `sr` on the target host.
136+
When using **Ansible** (or any automation tool), every task that uses `become: true` will invoke `dosr` on the target host.
136137
With **RootAsRole (RaR)**, each role and task introduces additional access control logic --- this doesn’t slow you down.
137138
138139
💡 **Here’s the reality**: You can reach the performance of **1 `sudo` rule** with **~4000 RaR rules**.

book/src/README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
## Usage
1919

20-
The main command line tool is `sr`. It allows you to execute a command by simply typing:
20+
The main command line tool is `dosr`. It allows you to execute a command by simply typing:
2121

2222
```bash
23-
sr <command>
23+
dosr <command>
2424
```
2525

26-
You can find more information about this command in the [sr](sr/README.md) section.
26+
You can find more information about this command in the [dosr](sr/README.md) section.
2727

2828
The `chsr` command allows you to configure the roles and capabilities of the system. You can find more information about this command in the [Configure RootAsRole](chsr/README.md) section.
2929

@@ -51,43 +51,43 @@ By using a role-based access control model, this project allows us to better man
5151
You are using your personal computer and you want to install a new package. By default, RootAsRole add one role with 2 tasks : one task for using `chsr` command that grant only the `CAP_LINUX_IMMUTABLE` capability as `root` user (unprivileged), and one task for all commands but without `CAP_LINUX_IMMUTABLE` privilege. As installing a package may require almost all capabilities, you can use the default role to install a package. Indeed, if you wish to install apache2, you'll need `CAP_NET_BIND_SERVICE`, if you install docker you'll need many privileges, virtualbox needs `CAP_SYS_MODULE`, etc. So, you can use the default role to install a package:
5252

5353
```bash
54-
sr apt install <package>
54+
dosr apt install <package>
5555
```
5656

5757
### Scenario 2: Granting users the right to restart their system
5858

5959
You are the system administrator of a company and you want to delegate the right to restart the server to a user. You can use `chsr` to create a role and grant the right to restart the server to users.
6060

6161
```bash
62-
sr chsr role r_users add # Create a new role
63-
sr chsr role r_users grant -g users # Grant the role to the group users
64-
sr chsr role r_users task t_reboot add # Create a new task
65-
sr chsr role r_users task t_reboot cmd whitelist add reboot # Add the reboot command to the task
66-
sr chsr role r_users task t_reboot cred caps whitelist add CAP_SYS_BOOT # Add the CAP_SYS_BOOT capability to the task
62+
dosr chsr role r_users add # Create a new role
63+
dosr chsr role r_users grant -g users # Grant the role to the group users
64+
dosr chsr role r_users task t_reboot add # Create a new task
65+
dosr chsr role r_users task t_reboot cmd whitelist add reboot # Add the reboot command to the task
66+
dosr chsr role r_users task t_reboot cred caps whitelist add CAP_SYS_BOOT # Add the CAP_SYS_BOOT capability to the task
6767
```
6868

6969
Then users can restart the server with the following command:
7070

7171
```bash
72-
sr reboot
72+
dosr reboot
7373
```
7474

7575
### Scenario 3 : Passing environment variables to a command
7676

7777
You are a developer and you want to pass environment variables to a command. For example with sudo you can use the `-E` option to pass environment variables to a command. With RootAsRole, you'll need to setup a role with a task that allows the command to use environment variables. However, as you keep the default configuration, you'll have two roles that matches ANY commands, and if the first one is more restrictive than the second one, you'll need to specify the role to use. Here is an example:
7878

7979
```bash
80-
sr chsr role env add # Create a new role
81-
sr chsr role env task env add # Create a new task
82-
sr chsr role env task env cmd setpolicy allow-all # Add all command to the task
83-
sr chsr role env task env cred caps setpolicy allow-all # Add all capabilities to the task
84-
sr chsr role env task env o env setpolicy keep-all # Keep the environment variables
80+
dosr chsr role env add # Create a new role
81+
dosr chsr role env task env add # Create a new task
82+
dosr chsr role env task env cmd setpolicy allow-all # Add all command to the task
83+
dosr chsr role env task env cred caps setpolicy allow-all # Add all capabilities to the task
84+
dosr chsr role env task env o env setpolicy keep-all # Keep the environment variables
8585
```
8686

8787
Then you can use the following command to pass environment variables to a command:
8888

8989
```bash
90-
sr -r env [command]
90+
dosr -r env [command]
9191
```
9292

9393
This is because the default role do not keep the environment variables, so if you want to keep environment variables you need to specify the role to use.
@@ -97,26 +97,26 @@ This is because the default role do not keep the environment variables, so if yo
9797
You are an administrator that want to automatically reboot the system at 04:05 every day with cron for example. You can disable authentication by setting skip-auth in the options. Here is an example:
9898

9999
```bash
100-
sr chsr role auto add # Create a new role
101-
sr chsr role grant -u cron # Grant the role to the user cron
102-
sr chsr role auto task cron_reboot add # Create a new task
103-
sr chsr role auto task cron_reboot cmd whitelist add reboot # Add the reboot command to the task
104-
sr chsr role auto task cron_reboot cred caps whitelist add CAP_SYS_BOOT # Add the CAP_SYS_BOOT capability to the task
105-
sr chsr role auto task cron_reboot o authentication skip # Skip authentication
100+
dosr chsr role auto add # Create a new role
101+
dosr chsr role grant -u cron # Grant the role to the user cron
102+
dosr chsr role auto task cron_reboot add # Create a new task
103+
dosr chsr role auto task cron_reboot cmd whitelist add reboot # Add the reboot command to the task
104+
dosr chsr role auto task cron_reboot cred caps whitelist add CAP_SYS_BOOT # Add the CAP_SYS_BOOT capability to the task
105+
dosr chsr role auto task cron_reboot o authentication skip # Skip authentication
106106
```
107107

108108
Then you can configure the cron to reboot the system with the following command:
109109

110110
```bash
111-
sr crontab -u cron -e
111+
dosr crontab -u cron -e
112112
```
113113

114114
and add the following line to reboot the system at 04:05 every day
115115

116116
```cron
117-
5 4 * * * sr -r auto -t cron_reboot reboot
117+
5 4 * * * dosr -r auto -t cron_reboot reboot
118118
```
119119

120-
Note: You should consider to set the `-r auto -t cron_reboot` options to the `sr` command when you automate a task to avoid any security issue or future conflict.
120+
Note: You should consider to set the `-r auto -t cron_reboot` options to the `dosr` command when you automate a task to avoid any security issue or future conflict.
121121

122122
For a more complete example, you can checkout the [Is a Linux system without root user possible ?](knowledge/no-root.md) section.

book/src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# User Guide
77

88
- [Installation](guide/installation.md)
9-
- [`sr` Command Line Tool](sr/README.md)
9+
- [`dosr` Command Line Tool](dosr/README.md)
1010
- [`chsr` Command Line Tool](chsr/README.md)
1111
- [`capable` Command Line Tool](capable/README.md)
1212

book/src/chsr/file-config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ The following example shows a RootAsRole config without plugins when almost ever
9393
"cred": {
9494
"setuid": {
9595
"fallback": "thefallbackuser", // Fallback user if the -u option is not set
96-
"default": "none", // The sr user cannot use -u option in general
97-
"add": ["theuser"], // the sr user can use "-u theuser" option
98-
"sub": ["anotheruser"] // the sr user cannot use "-u anotheruser" option (overrides add, applies only if default is all)
96+
"default": "none", // The dosr user cannot use -u option in general
97+
"add": ["theuser"], // the dosr user can use "-u theuser" option
98+
"sub": ["anotheruser"] // the dosr user cannot use "-u anotheruser" option (overrides add, applies only if default is all)
9999
}, // User to setuid before executing the command
100100
"setgid": [ // Groups to setgid before executing the command, The first one is the primary group
101101
"group1",
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# What is sr tool
1+
# What is dosr tool
22

3-
`sr` is the abbrevation of "switch role" is a command line tool like sudo. It allows a permitted user to execute a command as another user and groups. More than sudo it allows to a permitted user to obtain some privileges. The sr command is used to switch to a role.
3+
`dosr` is the abbrevation of "do switch role" is a command line tool like sudo. It allows a permitted user to execute a command as another user and groups. More than sudo it allows to a permitted user to obtain some privileges. The sr command is used to switch to a role.
44

55
# Usage
66

77
<pre>
8-
<u><b>Usage</b></u>: <b>sr</b> [OPTIONS] [COMMAND]...
8+
<u><b>Usage</b></u>: <b>dosr</b> [OPTIONS] [COMMAND]...
99

1010
<u><b>Arguments</b></u>:
1111
[COMMAND]... Command to execute

book/src/guide/installation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Install script does the following:
2828
- Dependency Step :
2929
- Installing necessary dependencies considering if compiling from source.
3030
- Build Step :
31-
- Building sr and chsr binaries
31+
- Building dosr and chsr binaries
3232
- Install Step :
33-
- Copying sr and chsr binaries to /usr/bin
34-
- Setting all capabilities on /usr/bin/sr
35-
- Setting owners and permissions on /usr/bin/sr
33+
- Copying dosr and chsr binaries to /usr/bin
34+
- Setting all capabilities on /usr/bin/dosr
35+
- Setting owners and permissions on /usr/bin/dosr
3636
- Configuration Step :
37-
- Deploying /etc/pam.d/sr for PAM configuration
37+
- Deploying /etc/pam.d/dosr for PAM configuration
3838
- Deploying /etc/security/rootasrole.json for configuration
3939
- Setting immutable on /etc/security/rootasrole.json if filesytem supports it

0 commit comments

Comments
 (0)