# jamf/makemeanadmin architecture

> Architecture diagram of the GitHub repository jamf/makemeanadmin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jamf/makemeanadmin
- Repository: https://github.com/jamf/makemeanadmin

## Overview

##### Main Components
- User/Trigger: Represents the person executing the script (for example, via a self-service portal or command line).
- Shell Script (MakeMeAnAdmin.sh): The central component which:
- Instantly upgrades the user’s account privileges.
- Configures a launch daemon to schedule a demotion task after the designated time (30 minutes).
- Initiates log capture, grabbing logs recorded over the last 30 minutes.
- Launch Daemon (Scheduled Task): An OS-level component that is installed/configured by the script to ensure that, regardless of user logouts or system reboots, the privilege escalation will be undone after the given time interval.
- Operating System’s Logging & Privilege Management: The underlying system functionalities that handle the actual admin rights and the collection/storage of log data.

##### Relationships and Interactions
- The user initiates the process by running the script.
- The script immediately interacts with the OS to grant temporary admin privileges.
- Once privileges are granted, the script sets up a launch daemon. This daemon is responsible for:
- Monitoring uptime.
- Triggering a demotion script once the 30-minute window expires.
- Concurrently, the script directs the OS’s logging system to capture a snapshot of the past 30 minutes and save the logs to a specific directory.
- After the time frame elapses, the launch daemon automatically calls a demotion function that revokes the admin rights.

##### Architectural Patterns and Key Design Principles
- Sequential Workflow: The execution occurs in a linear sequence where privilege escalation, scheduling, and log capture happen one after the other.
- Automated Revocation: Incorporates an automated rollback mechanism using the OS’s launch daemon to ensure security is maintained, no matter how many times a user logs out or how the system reboots.
- Configuration Flexibility: Clear parameters in the script’s code (e.g., prompt text, duration values, log directory) allow changes per environment or policy requirements.

##### Relevant Technologies and Frameworks
- Shell/Bash Scripting: The primary language used.
- macOS Launch Daemons: Represented as a system-level service that helps schedule and execute the demotion process.
- System Logging: The built-in log capture facilities that the script leverages to record user activity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U["User Trigger"]:::user

    %% Utility Script Execution
    S["Privilege Escalation Script (MakeMeAnAdmin.sh)"]:::script

    %% System Operations
    P["OS Privilege Management"]:::os
    L["OS Log Capture (Last 30 Min)"]:::os
    D["Launch Daemon (Scheduled Task)"]:::daemon
    R["Admin Revocation"]:::revocation

    %% Documentation Node
    Doc["Project Documentation (ReadMe.md)"]:::doc

    %% Flow Connections (vertical layout)
    U -->|"executes"| S
    S -->|"grants_temp_admin"| P
    S -->|"configures_daemon"| D
    S -->|"initiates_log_capture"| L
    D -->|"triggers_after_30_min"| R
    R -->|"revokes_admin"| P
    U -->|"references"| Doc

    %% Click Events
    click S "https://github.com/jamf/makemeanadmin/blob/master/MakeMeAnAdmin.sh"
    click Doc "https://github.com/jamf/makemeanadmin/blob/master/ReadMe.md"

    %% Styles
    classDef user fill:#8ecae6,stroke:#219ebc,stroke-width:2px;
    classDef script fill:#ffb703,stroke:#fb8500,stroke-width:2px;
    classDef os fill:#219ebc,stroke:#023047,stroke-width:2px;
    classDef daemon fill:#ff006e,stroke:#d62828,stroke-width:2px;
    classDef revocation fill:#00b4d8,stroke:#0077b6,stroke-width:2px;
    classDef doc fill:#90be6d,stroke:#43aa8b,stroke-width:2px;
```
