SkillAgentSearch skills...

RootAsRole

A better alternative to sudo(-rs)/su β€’ ⚑ Blazing fast β€’ πŸ›‘οΈ Memory-safe β€’ πŸ” Security-oriented

Install / Use

/learn @LeChatP/RootAsRole
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<!-- markdownlint-capture --> <!-- markdownlint-disable --> <p align="center"> <img src="./RootAsRolev2.svg" width=30%> </p> <p align="center"> <img alt="crates.io" src="https://img.shields.io/crates/v/rootasrole.svg?style=for-the-badge&label=Version&color=e37602&logo=rust" height="25"/> <img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/LeChatP/RootAsRole/build.yml?style=for-the-badge&logo=githubactions&label=Build&logoColor=white" height="25"/> <img alt="Tests Status" src="https://img.shields.io/github/actions/workflow/status/LeChatP/RootAsRole/tests.yml?style=for-the-badge&logo=githubactions&logoColor=white&label=Tests" height="25"/> <img alt="Codecov" src="https://img.shields.io/codecov/c/github/lechatp/rootasrole?style=for-the-badge&logo=codecov&color=green&link=https%3A%2F%2Fapp.codecov.io%2Fgh%2FLeChatP%2FRootAsRole" height="25"> <img alt="GitHub" src="https://img.shields.io/github/license/LeChatP/RootAsRole?style=for-the-badge&logo=github&logoColor=white" height="25"/> </p> <!-- The project version is managed on json file in resources/rootasrole.json --> <!-- markdownlint-restore -->

RootAsRole β€” A better alternative to sudo(-rs)/su β€’ ⚑ Blazing fast β€’ πŸ›‘οΈ Memory-safe β€’ πŸ” Security-oriented

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.

πŸ“š Full Documentation for more details

πŸš€ Why you need RootAsRole?

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:

  • Grants only the required capabilities
  • Uses roles and tasks to delegate rights securely
  • Better than sudo, doas, setcap, or pam_cap, see Comparison table below

βš™οΈ Features

πŸ“Š Why It’s Better Than Others

| 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 |

πŸ“₯ Installation

Install from Linux distributions

Packaging status

We really need your help to bring the project to Linux distributions repositories! Please contribute πŸ™!

Arch Linux (AUR)

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 πŸ™‚

πŸ”§ From Source

Prerequisites

  • Rust >= 1.83.0
    • You can install Rust by running the following command:
      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)
  • git
    • You can install git by running the following commands depending on your distribution: Ubuntu : sudo apt-get install git, RedHat : sudo yum install git, ArchLinux : sudo pacman -S git
  • clang (or gcc, but clang is highly recommended)
    • You 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

Install Steps

[!WARNING] This installation process configures RaR with all privileges for the user who install the program. See what it does.

  1. git clone https://github.com/LeChatP/RootAsRole
  2. cd RootAsRole
  3. cargo xtask install -bip sudo

🧰 Usage

<pre> Execute privileged commands with a role-based access control system <u><b>Usage</b></u>: <b>dosr</b> [OPTIONS] [COMMAND]... <u><b>Arguments</b></u>: [COMMAND]... Command to execute <u><b>Options</b></u>: <b>-r, --role</b> &lt;ROLE&gt; Role to select <b>-t, --task</b> &lt;TASK&gt; Task to select (--role required) <b>-u, --user</b> &lt;USER&gt; User to execute the command as <b>-g, --group</b> &lt;GROUP<,GROUP...>&gt; Group(s) to execute the command as <b>-E, --preserve-env</b> Keep environment variables from the current process <b>-p, --prompt</b> &lt;PROMPT&gt; Prompt to display <b>-K</b> Remove timestamp file <b>-i, --info</b> Print the execution context of a command if allowed by a matching task <b>-h, --help</b> Print help (see more with '--help') <b>-V, --version</b> Print version </pre>

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"

🏎️ Performance

RootAsRole 3.1.0 introduced CBOR support, significantly boosting performance:

  • ⚑ 77% faster than sudo when using a single rule
  • πŸ“ˆ Scales 40% better than sudo as more rules are added

Performance comparison

πŸ“ sudo-rs matches sudo performance but crashes with >100 rules (won’t fix for now)

Why Performance Matters

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:

  • You can define thousands of fine-grained rules
  • You enforce better security (POLP) without degrading performance
  • The system stays fast, even at scale

🧱 Configuration

Use the chsr command to:

  • Define roles and tasks
  • Assign them to users or groups

More information in the documentation

Use the capable command to:

  • Analyze specific command rights
  • Generate "credentials" task structure

Use gensr for Ansible to:

  • Auto-generate security policies for your playbooks
  • Detect supply chain attacks by reviewing the generated policy

βœ… Compatibility

  • Linux kernel >= 4.3

πŸ‘₯ Contributors

πŸ–ΌοΈ Logo

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.

View on GitHub
GitHub Stars260
CategoryDevelopment
Updated6h ago
Forks9

Languages

Rust

Security Score

100/100

Audited on Apr 2, 2026

No findings