# dcodingtheweb/rsudoas architecture

> Architecture diagram of the GitHub repository dcodingtheweb/rsudoas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dcodingtheweb/rsudoas
- Repository: https://github.com/dcodingtheweb/rsudoas

## Overview

##### Main Components

a) Core Components:
- Privilege Escalation Engine
- Permission Verification System
- User Authentication Module
- Command Execution Handler
- Configuration Parser
- (Planned) Sudo Compatibility Shim

b) System Interactions:
- Linux PAM (Pluggable Authentication Modules)
- System User Database
- File System Access
- Process Management

**┌─ Application Layer ─────┐**
- Command Line Interface│
- Sudo Compatibility    │
- ┘
- ↓
**┌─ Core Services Layer ────┐**
- Auth Management       │
- Permission Validation │
- Process Elevation     │
- ┘
- ↓
**┌─ System Interface Layer ─┐**
- PAM Integration       │
- Process Management    │
- File System Access    │
- ┘

##### Key Relationships to Highlight

- Flow from user input through authentication to privileged command execution
- Security boundaries between privileged and unprivileged operations
- Demonstrate the interaction with system components (PAM, user database, etc.)
- Planned sudo compatibility layer as a parallel entry point

##### Implementation Details

- Use `src/lib.rs` to represent the core library components
- Use `src/main.rs` to show the CLI interface
- `build.rs` for compile-time configuration
- Configuration file parsing and validation flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef cli fill:#f9f,stroke:#333,stroke-width:2px
    classDef core fill:#9cf,stroke:#333,stroke-width:2px
    classDef system fill:#9f9,stroke:#333,stroke-width:2px
    classDef security fill:#ff9,stroke:#333,stroke-width:2px
    classDef privileged fill:#f99,stroke:#333,stroke-width:2px
    classDef planned fill:#eee,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        CLI["Command Line Interface"]:::cli
        SudoShim["Sudo Compatibility Shim"]:::planned
    end

    %% Core Services Layer
    subgraph CoreLayer["Core Services Layer"]
        AuthMgmt["Authentication Management"]:::security
        PermValid["Permission Validation"]:::security
        ProcElev["Process Elevation"]:::privileged
        ConfigParser["Configuration Parser"]:::core
    end

    %% System Interface Layer
    subgraph SysLayer["System Interface Layer"]
        PAM["PAM Integration"]:::system
        ProcMgmt["Process Management"]:::system
        FSAccess["File System Access"]:::system
        UserDB["System User Database"]:::system
    end

    %% Relationships
    CLI --> AuthMgmt
    CLI --> ConfigParser
    SudoShim -.-> AuthMgmt
    
    AuthMgmt --> PAM
    AuthMgmt --> UserDB
    
    PermValid --> FSAccess
    PermValid --> UserDB
    
    ConfigParser --> FSAccess
    
    AuthMgmt --> PermValid
    PermValid --> ProcElev
    ProcElev --> ProcMgmt

    %% Click events for component mapping
    click CLI "https://github.com/DcodingTheWeb/rsudoas/blob/master/src/main.rs"
    click AuthMgmt "https://github.com/DcodingTheWeb/rsudoas/blob/master/src/lib.rs"
    click PermValid "https://github.com/DcodingTheWeb/rsudoas/blob/master/src/lib.rs"
    click ProcElev "https://github.com/DcodingTheWeb/rsudoas/blob/master/src/lib.rs"
    click ConfigParser "https://github.com/DcodingTheWeb/rsudoas/blob/master/build.rs"

    %% Legend
    subgraph Legend["Legend"]
        L1["CLI Component"]:::cli
        L2["Core Component"]:::core
        L3["System Interface"]:::system
        L4["Security Component"]:::security
        L5["Privileged Operation"]:::privileged
        L6["Planned Feature"]:::planned
    end
```
