| Crates.io | rootasrole |
| lib.rs | rootasrole |
| version | 3.2.4 |
| created_at | 2024-09-23 12:41:32.209149+00 |
| updated_at | 2025-09-04 08:28:01.29633+00 |
| description | A better alternative to sudo(-rs)/su |
| homepage | https://lechatp.github.io/RootAsRole/ |
| repository | https://github.com/LeChatP/RootAsRole |
| max_upload_size | |
| id | 1384013 |
| size | 868,046 |
sudo(-rs)/su β’ β‘ Blazing fast β’ π‘οΈ Memory-safe β’ π Security-orientedRootAsRole 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.
π Full Documentation for more details
Most Linux systems break the Principle of Least Privilege. Tools like sudo give full root, even if you just need one capability like CAP_NET_RAW.
RootAsRole solves this:
sudo, doas, setcap, or pam_cap, see Comparison table below| Feature | setcap?? | doas | sudo | sudo-rs | dosr (RootAsRole) |
|---|---|---|---|---|---|
| Change user/groups | N/A | β | β | β | β β mandatory or optional |
| Environment variables | N/A | partial | β | partial | β |
| Specific command matching | N/A | strict | strict & regex | strict & wildcard | strict & regex |
| Centralized policy | β | β | β | β | Planned |
| Secure signal forwarding | N/A | β | β | β | Planned |
| Set capabilities | β οΈ files | β | β | β | β |
| Prevent direct privilege escalation | β | β | β | β | β |
| Untrust authorized users | β | β | β | β | β |
| Standardized policy format | β | β | β | β | β |
| Scalable access control model | N/A | β ACL | β ACL | β ACL | β RBAC |
We really need your help to bring the project to Linux distributions repositories! Please contribute π!
git clone https://aur.archlinux.org/dosr.git
cd dosr
makepkg -si
you can also use yay AUR manager or any other one you like. Please vote for the AUR if you want it into pacman extra repo! All you need is an Arch AUR account and you could vote for the AUR π
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
(Do not forget to add the cargo bin directory to your PATH with . "$HOME/.cargo/env" command)sudo apt-get install git, RedHat : sudo yum install git, ArchLinux : sudo pacman -S gitYou can install clang by running the following commands depending on your distribution:
Ubuntu : sudo apt-get install clang, RedHat : sudo yum install clang, ArchLinux : sudo pacman -S clang
[!WARNING] This installation process configures RaR with all privileges for the user who install the program. See what it does.
git clone https://github.com/LeChatP/RootAsRolecd RootAsRolecargo xtask install -bip sudo
Execute privileged commands with a role-based access control system Usage: dosr [OPTIONS] [COMMAND]... Arguments: [COMMAND]... Command to execute Options: -r, --role <ROLE> Role to select -t, --task <TASK> Task to select (--role required) -u, --user <USER> User to execute the command as -g, --group <GROUP<,GROUP...>> Group(s) to execute the command as -E, --preserve-env Keep environment variables from the current process -p, --prompt <PROMPT> Prompt to display -K Remove timestamp file -i, --info Print the execution context of a command if allowed by a matching task -h, --help Print help (see more with '--help') -V, --version Print version
If you're accustomed to utilizing the sudo tool and find it difficult to break that habit, consider creating an alias :
alias sudo="dosr"
alias sr="dosr"
RootAsRole 3.1.0 introduced CBOR support, significantly boosting performance:
sudo when using a single rulesudo as more rules are addedπ sudo-rs matches sudo performance but crashes with >100 rules (wonβt fix for now)
When using Ansible (or any automation tool), every task that uses become: true will invoke dosr on the target host.
With RootAsRole (RaR), each role and task introduces additional access control logic --- this doesnβt slow you down.
π‘ Hereβs the reality: You can reach the performance of 1 sudo rule with ~4000 RaR rules.
That means:
Use the chsr command to:
More information in the documentation
Use the capable command to:
Use gensr for Ansible to:
This logo were generated using DALL-E 2 AI, for any license issue or plagiarism, please note that is not intentionnal and don't hesitate to contact us.
This project includes sudo-rs code licensed under the Apache-2 and MIT licenses: We have included cutils.rs, securemem.rs to make work the rpassword.rs file. Indeed, We thought that the password was well managed in this file and we have reused it. As sudo-rs does, rpassword.rs is from the rpassword project (License: Apache-2.0). We use it as a replacement of the rpassword project usage.
This project was initiated by IRIT and sponsored by both IRIT and Airbus PROTECT through an industrial PhD during 2022 and 2025.