fix(codex): model_catalog_json pointed to /var/root for all users
Root cause: generate_config_toml() used os.path.expanduser("~") which
always returns root's home under sudo. Every user's config.toml had
model_catalog_json = "/var/root/.codex/model_catalog.json" → Permission denied.
Fix: pass home_dir to generate_config_toml() so each user gets their own path.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -242,7 +242,7 @@ def toml_key(k):
|
||||
return k
|
||||
|
||||
|
||||
def generate_config_toml(existing, config):
|
||||
def generate_config_toml(existing, config, home_dir=None):
|
||||
"""Generate config.toml content, merging with existing user config.
|
||||
|
||||
Strategy:
|
||||
@@ -259,7 +259,7 @@ def generate_config_toml(existing, config):
|
||||
lines.append('model_provider = "custom"')
|
||||
|
||||
# Model catalog path (for model picker)
|
||||
codex_dir_path = os.path.join(os.path.expanduser("~"), ".codex")
|
||||
codex_dir_path = os.path.join(home_dir or os.path.expanduser("~"), ".codex")
|
||||
catalog_path = os.path.join(codex_dir_path, "model_catalog.json")
|
||||
catalog_path_toml = catalog_path.replace("\\", "/")
|
||||
lines.append(f'model_catalog_json = "{catalog_path_toml}"')
|
||||
@@ -578,7 +578,7 @@ def apply_all_patches(config, home_dir=None):
|
||||
backup_file(config_path)
|
||||
|
||||
# Generate new config.toml (merge)
|
||||
new_content = generate_config_toml(existing, config)
|
||||
new_content = generate_config_toml(existing, config, home_dir=home_dir)
|
||||
|
||||
# Write config.toml
|
||||
with open(config_path, "w", encoding="utf-8") as f:
|
||||
@@ -727,7 +727,7 @@ def patch_user(user_home, config, uid=None, gid=None):
|
||||
existing = read_toml(config_path)
|
||||
backup_file(config_path)
|
||||
|
||||
new_content = generate_config_toml(existing, config)
|
||||
new_content = generate_config_toml(existing, config, home_dir=user_home)
|
||||
with open(config_path, "w", encoding="utf-8") as f:
|
||||
f.write(new_content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user