mirror of
https://github.com/openai/codex.git
synced 2026-12-04 00:51:02 +00:00
## Why The daemon's automatic update preference still permits manual updates. Administrators need a policy that covers both paths. ## What changed Set `features.daemon_updates = false` in managed `requirements.toml` or local MDM policy to block scheduled updates and manual daemon package replacements. Updates are allowed by default. User configuration cannot override the policy, and cloud-delivered requirements reject the setting. When policy blocks updates, the TUI hides update actions in `/daemon`, suppresses update offers in version notices, and directs users to their administrator where a newer daemon is required. ## Testing Add coverage for the default, disabled, and invalid policy cases, rejection of the setting in cloud requirements, and the TUI with daemon updates disabled. GitOrigin-RevId: de9e50c4acc4dc8e83bbd2b9a5e902deb8c6f477
46 lines
1.4 KiB
Rust
46 lines
1.4 KiB
Rust
//! Enforces managed daemon update policy independently of daemon preferences.
|
|
|
|
use anyhow::Context;
|
|
use anyhow::Result;
|
|
use codex_config::LoaderOverrides;
|
|
use codex_config::loader::load_managed_requirements_state;
|
|
use codex_config::loader::refresh_managed_preferences;
|
|
use codex_exec_server::LOCAL_FS;
|
|
use codex_features::Feature;
|
|
|
|
use crate::Daemon;
|
|
|
|
pub(crate) async fn allowed(daemon: &Daemon) -> Result<bool> {
|
|
let home = daemon
|
|
.settings_file
|
|
.parent()
|
|
.and_then(std::path::Path::parent)
|
|
.context("daemon settings path has no Codex home")?;
|
|
updates_allowed(home, LoaderOverrides::default()).await
|
|
}
|
|
|
|
pub(crate) async fn ensure_allowed(daemon: &Daemon) -> Result<()> {
|
|
anyhow::ensure!(
|
|
allowed(daemon).await?,
|
|
"Daemon updates are disabled by managed policy (features.daemon_updates = false)."
|
|
);
|
|
Ok(())
|
|
}
|
|
|
|
async fn updates_allowed(home: &std::path::Path, overrides: LoaderOverrides) -> Result<bool> {
|
|
refresh_managed_preferences(&overrides).await?;
|
|
let requirements = load_managed_requirements_state(LOCAL_FS.as_ref(), home, overrides)
|
|
.await
|
|
.context("failed to load managed daemon update policy")?;
|
|
Ok(requirements
|
|
.feature_requirements
|
|
.as_ref()
|
|
.and_then(|features| features.entries.get(Feature::DaemonUpdates.key()))
|
|
.copied()
|
|
.unwrap_or(true))
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "update_policy_tests.rs"]
|
|
mod tests;
|