core-agent-ide/codex-rs
Xiao-Yong Jin 5860481bc4
Fix FreeBSD/OpenBSD builds: target-specific keyring features and BSD hardening (#6680)
## Summary
Builds on FreeBSD and OpenBSD were failing due to globally enabled
Linux-specific keyring features and hardening code paths not gated by
OS. This PR scopes keyring native backends to the
appropriate targets, disables default features at the workspace root,
and adds a BSD-specific hardening function. Linux/macOS/Windows behavior
remains unchanged, while FreeBSD/OpenBSD
  now build and run with a supported backend.

## Key Changes

  - Keyring features:
- Disable keyring default features at the workspace root to avoid
pulling Linux backends on non-Linux.
- Move native backend features into target-specific sections in the
affected crates:
          - Linux: linux-native-async-persistent
          - macOS: apple-native
          - Windows: windows-native
          - FreeBSD/OpenBSD: sync-secret-service
  - Process hardening:
      - Add pre_main_hardening_bsd() for FreeBSD/OpenBSD, applying:
          - Set RLIMIT_CORE to 0
          - Clear LD_* environment variables
- Simplify process-hardening Cargo deps to unconditional libc (avoid
conflicting OS fragments).
  - No changes to CODEX_SANDBOX_* behavior.

## Rationale

- Previously, enabling keyring native backends globally pulled
Linux-only features on BSD, causing build errors.
- Hardening logic was tailored for Linux/macOS; BSD builds lacked a
gated path with equivalent safeguards.
- Target-scoped features and BSD hardening make the crates portable
across these OSes without affecting existing behavior elsewhere.

## Impact by Platform

  - Linux: No functional change; backends now selected via target cfg.
  - macOS: No functional change; explicit apple-native mapping.
  - Windows: No functional change; explicit windows-native mapping.
- FreeBSD/OpenBSD: Builds succeed using sync-secret-service; BSD
hardening applied during startup.

## Testing

- Verified compilation across affected crates with target-specific
features.
- Smoke-checked that Linux/macOS/Windows feature sets remain identical
functionally after scoping.
- On BSD, confirmed keyring resolves to sync-secret-service and
hardening compiles.

## Risks / Compatibility

  - Minimal risk: only feature scoping and OS-gated additions.
- No public API changes in the crates; runtime behavior on non-BSD
platforms is preserved.
- On BSD, the new hardening clears LD_*; this is consistent with
security posture on other Unix platforms.

## Reviewer Notes

- Pay attention to target-specific sections for keyring in the affected
Cargo.toml files.
- Confirm pre_main_hardening_bsd() mirrors the safe subset of
Linux/macOS hardening without introducing Linux-only calls.
- Confirm no references to CODEX_SANDBOX_ENV_VAR or
CODEX_SANDBOX_NETWORK_DISABLED_ENV_VAR were added/modified.

## Checklist

  - Disable keyring default features at workspace root.
- Target-specific keyring features mapped per OS
(Linux/macOS/Windows/BSD).
  - Add BSD hardening (RLIMIT_CORE=0, clear LD_*).
  - Simplify process-hardening dependencies to unconditional libc.
  - No changes to sandbox env var code.
  - Formatting and linting: just fmt + just fix -p for changed crates.
  - Project tests pass for changed crates; broader suite unchanged.

---------

Co-authored-by: celia-oai <celia@openai.com>
2025-11-17 05:07:34 +00:00
..
.cargo build: 8mb stacks on win (#5997) 2025-10-30 16:12:50 -07:00
.config Add test timeout (#6612) 2025-11-14 09:30:37 -08:00
ansi-escape Fix transcript mode rendering issue when showing tab chars (#4911) 2025-10-08 11:42:09 -07:00
app-server [App server] add mcp tool call item started/completed events (#6642) 2025-11-14 08:08:43 -08:00
app-server-protocol [App server] add mcp tool call item started/completed events (#6642) 2025-11-14 08:08:43 -08:00
app-server-test-client feat: add app-server-test-client crate for internal use (#5391) 2025-11-14 12:39:58 -08:00
apply-patch Fix apply_patch rename move path resolution (#5486) 2025-11-06 17:02:09 -08:00
arg0 Use codex-linux-sandbox in unified exec (#6480) 2025-11-10 17:17:09 -08:00
async-utils Support graceful agent interruption (#5287) 2025-10-17 18:52:57 +00:00
backend-client [app-server] read rate limits API (#5302) 2025-10-20 14:11:54 -07:00
chatgpt chore: merge git crates (#5909) 2025-10-29 12:11:44 +00:00
cli Revert "templates and build step for validating/submitting winget package" (#6696) 2025-11-15 03:47:58 +00:00
cloud-tasks Add test timeout (#6612) 2025-11-14 09:30:37 -08:00
cloud-tasks-client chore(deps): bump thiserror from 2.0.16 to 2.0.17 in /codex-rs (#4426) 2025-10-30 19:00:00 -07:00
codex-backend-openapi-models fix: icu_decimal version (#5919) 2025-10-29 20:46:45 +00:00
common Reasoning level update (#6586) 2025-11-13 06:24:36 +00:00
core Fix FreeBSD/OpenBSD builds: target-specific keyring features and BSD hardening (#6680) 2025-11-17 05:07:34 +00:00
docs [App-server] Add auth v2 doc & update codex mcp interface auth section (#6353) 2025-11-07 08:17:19 -08:00
exec feat: better UI for unified_exec (#6515) 2025-11-14 16:31:12 +01:00
execpolicy Use anyhow::Result in tests for error propagation (#4105) 2025-09-23 13:31:36 -07:00
feedback Add feedback upload request handling (#5682) 2025-10-27 05:53:39 +00:00
file-search Follow symlinks during file search (#4453) 2025-11-03 20:28:33 -08:00
keyring-store Fix FreeBSD/OpenBSD builds: target-specific keyring features and BSD hardening (#6680) 2025-11-17 05:07:34 +00:00
linux-sandbox chore: unify config crates (#5958) 2025-10-30 10:28:32 +00:00
login [Auth] Choose which auth storage to use based on config (#5792) 2025-10-27 19:41:49 -07:00
mcp-server Add warning on compact (#6052) 2025-10-31 13:27:33 -07:00
mcp-types [app-server] remove serde(skip_serializing_if = "Option::is_none") annotations (#5939) 2025-10-30 18:18:53 +00:00
ollama Use assert_matches (#4756) 2025-10-05 21:12:31 +00:00
otel Changes to sandbox command assessment feature based on initial experiment feedback (#6091) 2025-11-01 14:52:23 -07:00
process-hardening Fix FreeBSD/OpenBSD builds: target-specific keyring features and BSD hardening (#6680) 2025-11-17 05:07:34 +00:00
protocol Handle "Don't Trust" directory selection in onboarding (#4941) 2025-11-14 15:23:35 -08:00
responses-api-proxy feat: add options to responses-api-proxy to support Azure (#6129) 2025-11-03 10:06:00 -08:00
rmcp-client Fix FreeBSD/OpenBSD builds: target-specific keyring features and BSD hardening (#6680) 2025-11-17 05:07:34 +00:00
scripts feat: add --promote-alpha option to create_github_release script (#6370) 2025-11-07 20:05:22 +00:00
stdio-to-uds feat: experimental codex stdio-to-uds subcommand (#5350) 2025-10-19 21:12:45 -07:00
tui Fix AltGr/backslash input on Windows Codex terminal (#6720) 2025-11-16 19:15:06 -08:00
utils feat: cache tokenizer (#6609) 2025-11-14 17:05:00 +01:00
windows-sandbox-rs fix codex detection, add new security-focused smoketests. (#6682) 2025-11-14 12:08:59 -08:00
.gitignore [MCP] Prefix MCP tools names with mcp__ (#5309) 2025-10-19 20:41:55 -04:00
Cargo.lock fix: resolve Windows MCP server execution for script-based tools (#3828) 2025-11-16 13:41:10 -08:00
Cargo.toml Fix FreeBSD/OpenBSD builds: target-specific keyring features and BSD hardening (#6680) 2025-11-17 05:07:34 +00:00
clippy.toml fix: switch rate limit reset handling to timestamps (#5304) 2025-10-17 17:39:37 -07:00
code Send text parameter for non-gpt-5 models (#4195) 2025-09-24 22:00:06 +00:00
config.md Fix link to MCP Servers config section (#5301) 2025-10-17 14:58:27 -07:00
default.nix Fix nix build (#6230) 2025-11-04 17:07:37 -08:00
justfile feat: add app-server-test-client crate for internal use (#5391) 2025-11-14 12:39:58 -08:00
README.md add codex debug seatbelt --log-denials (#4098) 2025-11-10 22:48:14 +00:00
rust-toolchain.toml chore: upgrade to Rust 1.90 (#4124) 2025-09-24 08:32:00 -07:00
rustfmt.toml Update cargo to 2024 edition (#842) 2025-05-07 08:37:48 -07:00

Codex CLI (Rust Implementation)

We provide Codex CLI as a standalone, native executable to ensure a zero-dependency install.

Installing Codex

Today, the easiest way to install Codex is via npm:

npm i -g @openai/codex
codex

You can also install via Homebrew (brew install --cask codex) or download a platform-specific release directly from our GitHub Releases.

Documentation quickstart

What's new in the Rust CLI

The Rust implementation is now the maintained Codex CLI and serves as the default experience. It includes a number of features that the legacy TypeScript CLI never supported.

Config

Codex supports a rich set of configuration options. Note that the Rust CLI uses config.toml instead of config.json. See docs/config.md for details.

Model Context Protocol Support

MCP client

Codex CLI functions as an MCP client that allows the Codex CLI and IDE extension to connect to MCP servers on startup. See the configuration documentation for details.

MCP server (experimental)

Codex can be launched as an MCP server by running codex mcp-server. This allows other MCP clients to use Codex as a tool for another agent.

Use the @modelcontextprotocol/inspector to try it out:

npx @modelcontextprotocol/inspector codex mcp-server

Use codex mcp to add/list/get/remove MCP server launchers defined in config.toml, and codex mcp-server to run the MCP server directly.

Notifications

You can enable notifications by configuring a script that is run whenever the agent finishes a turn. The notify documentation includes a detailed example that explains how to get desktop notifications via terminal-notifier on macOS.

codex exec to run Codex programmatically/non-interactively

To run Codex non-interactively, run codex exec PROMPT (you can also pass the prompt via stdin) and Codex will work on your task until it decides that it is done and exits. Output is printed to the terminal directly. You can set the RUST_LOG environment variable to see more about what's going on.

Experimenting with the Codex Sandbox

To test to see what happens when a command is run under the sandbox provided by Codex, we provide the following subcommands in Codex CLI:

# macOS
codex sandbox macos [--full-auto] [--log-denials] [COMMAND]...

# Linux
codex sandbox linux [--full-auto] [COMMAND]...

# Windows
codex sandbox windows [--full-auto] [COMMAND]...

# Legacy aliases
codex debug seatbelt [--full-auto] [--log-denials] [COMMAND]...
codex debug landlock [--full-auto] [COMMAND]...

Selecting a sandbox policy via --sandbox

The Rust CLI exposes a dedicated --sandbox (-s) flag that lets you pick the sandbox policy without having to reach for the generic -c/--config option:

# Run Codex with the default, read-only sandbox
codex --sandbox read-only

# Allow the agent to write within the current workspace while still blocking network access
codex --sandbox workspace-write

# Danger! Disable sandboxing entirely (only do this if you are already running in a container or other isolated env)
codex --sandbox danger-full-access

The same setting can be persisted in ~/.codex/config.toml via the top-level sandbox_mode = "MODE" key, e.g. sandbox_mode = "workspace-write".

Code Organization

This folder is the root of a Cargo workspace. It contains quite a bit of experimental code, but here are the key crates:

  • core/ contains the business logic for Codex. Ultimately, we hope this to be a library crate that is generally useful for building other Rust/native applications that use Codex.
  • exec/ "headless" CLI for use in automation.
  • tui/ CLI that launches a fullscreen TUI built with Ratatui.
  • cli/ CLI multitool that provides the aforementioned CLIs via subcommands.