Script Executor
OpenFrame Documentation
Get the most out of OpenFrame · Book 30 minutes with Conrad, 25 years in IT. He'll show you what Mingo and Fae can take off your list.
OpenFrame Documentation
The Script Executor is the operating-system boundary used by the OpenFrame client agent to run a received script and normalize its outcome. It is implemented by the openframe_agent_lib Cargo dependency from OpenFrame OSS Library, which this repository consumes at version v0.0.5.
Its public contract is deliberately small: callers supply script text, a shell name, arguments, timeout, requested privilege, and environment-variable entries. The platform-specific executor runs the script and returns captured standard output, standard error, an exit code, and a timeout indicator. The owning execution service turns that result into the RMM result sent through the agent workflow.
execute_script entry point for Unix and Windows builds.ScriptParams without embedding transport or scheduling concerns.Privilege.ExecResult whether execution succeeds, times out, or fails before the script starts.The module does not decide whether a request is authorized, persist results, or publish them. Those responsibilities are upstream and downstream of the executor.
flowchart LR
Request["Execution request"] --> Service["Execution Service"]
Service --> Params["Script Params"]
Params --> Executor["Script Executor"]
Executor --> Unix["Unix executor"]
Executor --> Windows["Windows executor"]
Unix --> Process["Operating system process"]
Windows --> Process
Process --> Result["Execution result"]
Result --> Service
Service --> Rmm["RMM result"]
At compile time, conditional Rust modules select the implementation:
ExecutionService instead returns an unsupported-platform RMM result with exit code 85.The executor module source defines the following types.
| Type | Purpose | Key contents |
|---|---|---|
Privilege |
Selects the runtime identity/context for the process. | Agent, User, and Windows-only ElevatedUser. |
ScriptParams |
Borrowed input passed to the selected executor. | Script code, shell, arguments, timeout in seconds, privilege, and environment-variable entries. |
ExecResult |
Platform-neutral process outcome. | Captured standard output, captured standard error, integer return code, and timed_out. |
ScriptParams borrows its string data and argument lists. Consequently, the caller owns the request data for the duration of execution; the executor does not define a persisted script representation.
flowchart TD
Requested["Requested privilege"] --> Choice{"Platform"}
Choice -->|"Unix"| UnixPolicy["Resolve supported run-as context"]
Choice -->|"Windows"| WinPolicy["Map to process elevation"]
UnixPolicy --> UnixAgent["Agent or user context"]
WinPolicy --> Agent["Agent: normal process"]
WinPolicy --> User["User: logged-on interactive user"]
WinPolicy --> Elevated["Elevated user: elevated interactive user"]
On Windows, the implementation maps Agent to a normal process. It maps User to the logged-on interactive user and ElevatedUser to an elevated interactive-user process. On Unix, the implementation first resolves the requested run-as context; an inability to do so returns a startup-style error result rather than attempting the command.
The upstream execution model separately represents script shell choices and requested user or administrator levels. ExecutionService resolves that request-level policy into this module's Privilege value before invoking the executor.
The Unix implementation performs this sequence:
The Windows implementation takes a platform-specific path:
powershell and cmd are accepted by this implementation; any other value returns an error result.sequenceDiagram
participant Service as Execution Service
participant Executor as Script Executor
participant Platform as Platform executor
participant OS as Operating system
Service->>Executor: Script parameters
Executor->>Platform: Select compiled platform path
Platform->>Platform: Create temporary script file
Platform->>Platform: Build process and apply context
Platform->>OS: Start interpreter process
OS-->>Platform: Output, exit code, timeout state
Platform-->>Executor: Execution result
Executor-->>Service: Execution result
Service->>Service: Build RMM result
The executor is called by the OpenFrame client library's ExecutionService. Before calling it, that service increments its active-execution tracking, records the start time, selects a default timeout of 900 seconds when the incoming timeout is zero, and caps nonzero values to a u32 number of seconds.
After the platform executor returns, the service creates an RMM result containing:
Exit code 85 has a special meaning at this boundary: the service treats it as a script-start failure, logs a warning, and copies standard error into the RMM result's optional error field. This behavior also covers unsupported platforms in the service implementation.
flowchart TD
Incoming["Inbound script request"] --> Normalize["Execution Service resolves timeout and privilege"]
Normalize --> Run["Script Executor runs temporary script"]
Run --> Outcome{"Process outcome"}
Outcome -->|"Started"| Capture["Capture output, exit code, and timeout"]
Outcome -->|"Could not start"| StartError["Return code 85 with error text"]
Capture --> Build["Build RMM result"]
StartError --> Build
Build --> Delivery["Client result delivery workflow"]
The executor's result is therefore a local execution artifact, not the final delivery protocol. The surrounding client agent is responsible for receiving the execution request and for storing or publishing the resulting RMM message.
User or ElevatedUser request may require an interactive console session. Callers should expect startup failure information when the requested context cannot be established.ExecResult with timed_out set. Consumers must use that field rather than infer a timeout solely from output or exit code.When modifying Script Executor behavior:
ScriptParams and ExecResult platform-neutral unless a field is inherently platform-specific.85 startup-failure convention or update the consuming execution service in the same change.Although this repository assembles and runs the OpenFrame client agent, Script Executor source is supplied by the OpenFrame OSS Library through the openframe_agent_lib dependency. The authoritative implementation is the library source linked above; application-level execution orchestration resides in the same client library's execution service.