openOMSI GitHub Discord

Docs / Plugins / Lua plugins

Native helper programs

5 min readEdit this pagedocs/PLUGINS.md

The interactive game asks for permission when a plugin first tries to start a native helper. The host-owned window initially shows the plugin name, the application's filename and the number of arguments, together with the safety warning and decision descriptions.

Details reveals the full executable path, plugin entry path, individual arguments and working directory; Hide details collapses them again. Each new request starts collapsed, and opening details never approves execution. Allow once covers only that launch.

Always allow stores a hash-bound approval in ~/.openomsi/plugin-process-permissions.json (on Windows, %USERPROFILE%\.openomsi\plugin-process-permissions.json). It applies only to that entry, folder snapshot and helper; changed content asks again.

Deny blocks all native helpers for that canonical plugin entry for the current game session, even if helper names, content or arguments change. Escape also denies; Enter never automatically approves. The game and other plugins keep running while a request waits. Unload/reload cancels it. Packages must still declare process.

Dialog text and buttons are translated into every supported interface language; plugin names, file paths and arguments are displayed literally and are never sent to translation.

Embedded hosts remain default-deny unless they explicitly install ProcessPermissions through Plugins::load_with_process_permissions. The optional OMSI_PLUGIN_PROCESS_ALLOW variable names an absolute JSON manifest for preapproved content; ordinary players do not need environment variables or terminal commands.

The manifest schema is unchanged, but older full-folder snapshots may need regeneration under the executable-content policy below. All approvals bind the canonical entry path and SHA256, canonical plugin folder, relevant executable-content files (including required modules), and the helper path and SHA256. Remove a saved approval from the user settings file with the game closed to revoke it.

Inspect the plugin and its helpers before granting access. For example, generate a manifest from a dedicated deployed plugin folder with the repository utility:

PowerShell
cargo run -p omsi-plugin --bin omsi-plugin-grant -- D:\Plugins\example\plugin.lua D:\Plugins\example bin/helper.exe | Set-Content -Encoding utf8 D:\Plugins\process-grants.json
$env:OMSI_PLUGIN_PROCESS_ALLOW = 'D:\Plugins\process-grants.json'

When using a manual manifest, save it outside the plugin folder; its hashes must describe the deployed files, not the manifest itself. For .oop, use the archive as the entry and its extracted runtime asset folder as the folder (the archive's parent if it has no extracted assets).

Multiple entries can be combined in the manifest's grants array. Embedded hosts can pass ProcessGrants through Plugins::load_with_process_grants; ProcessGrant::capture creates a snapshot, while from_paths approves code without any executable helpers.

Replacing the entry/helper or changing executable content invalidates the saved grant. Ordinary *.save.lua files and non-executable files in top-level data/ or *.data/ directories are excluded: omsi.save(), omsi.storage and omsi.files writes therefore preserve consent.

Lua modules in those directories remain hashed, since disk require can reach Lua modules. Native .dll, .so (including versioned names) and .dylib libraries also remain covered. For a folder plugin, other package files remain covered.

For a one-file Lua plugin sharing the top-level plugins folder, the snapshot covers its entry, all disk-importable Lua code, native libraries and the explicitly selected helper; unrelated images, XML/configuration files, other helper executables and saved data are excluded.

Sibling Lua code remains a shared trust boundary because require can import it; use a dedicated folder plugin to isolate module dependencies. Moving the plugin also requires new approval. Existing approvals created with the older full-folder snapshot may require approval once after updating.

Load/reload only selects a manifest candidate by its absolute lexical entry/folder paths;

Windows path casing and ambiguous DOS (8.3) components are accepted as candidate hints without filesystem I/O. This grants no executable access by itself: the worker resolves the actual canonical entry/folder, so a short-name lookalike at a different location is rejected.

Every start freshly verifies executable content on a worker. Relevant symlinks, special files, traversal and absolute helper paths fail closed. Limits are 256 MiB/4096 included files and 4096 traversed directories; excluded data files do not consume the file/byte budget.

Denial takes effect immediately for all queued requests from that plugin and survives plugin reload/content changes until the game restarts. After 256 distinct plugin session denials the broker rejects further starts rather than forgetting denials.

Remove any manual manifest override and the matching saved approval, then restart to revoke consent. An already running helper is not retroactively stopped by editing its files.

process.start("bin/helper.exe", args, options) accepts only explicitly approved helpers inside the plugin folder; Windows accepts .exe files, not shell scripts. Helpers run with the game account's permissions and inherited environment, except the grant variable is always removed even if an override supplies it.

The hash is a check, not a filesystem lock: a concurrent writer can replace a file between verification and the path-based spawn. The checks do not sandbox trusted native code. cwd and env remain controlled by the approved plugin; overrides such as PATH, LD_PRELOAD or DYLD_INSERT_LIBRARIES can affect executable/library loading.

Always allow therefore trusts that code to choose its arguments, working directory and environment, not only the displayed invocation.

process.start reserves and returns a plugin-owned handle immediately. Hash verification and OS process creation run on two shared workers, with a global queue of at most 32 starts. The per-plugin limit of 32 handles counts queued and failed requests and is checked before admission.

Queue/capacity failure returns nil and a reason immediately. Accepted requests can fail later: status has starting, failed and error, and pid is nil until launched. exit_code/Lua wait return nil, "failed", reason on preparation failure. Forget failed handles as well as completed children.

Requests are limited to 256 arguments, 128 environment overrides and 64 KiB of argument/options text. Polling uses a cached snapshot and never waits for the worker lock. A separate owner thread polls and cleans children even while validation is slow; stop/reload cancels queued work and kills/reaps late launches.

process.start returns a plugin-owned handle; status and exit_code poll without blocking. Lua process.wait suspends the top-level callback while the game and other plugins continue. Nested event callbacks and manual coroutines cannot wait. Stop, disable and reload cancel pending waits and terminate direct children.

Windows assigns children atomically to a kill-on-close Job Object, including descendants, so abrupt game termination also cleans them up. Linux sets PR_SET_PDEATHSIG for direct children with a parent-race check; descendants are not covered. On macOS only normal plugin lifecycle cleanup is provided.

Completed handles retain status until forget; the limit is 32 handles per plugin. Windows closes the job on forget, killing any remaining descendants. Plugins without consent keep direct callback dispatch; approved Lua plugins reuse completed callback coroutines.

On macOS, helpers extracted from ZIP files may need their executable bit restored (chmod +x /absolute/path/to/helper) and may be blocked by Gatekeeper quarantine. Review the downloaded helper and use macOS's normal security approval flow before running it; the plugin host does not remove quarantine automatically.

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open