Commit Graph

6 Commits

Author SHA1 Message Date
Maciej Lisiewski
0d9e2c3cfa fix(profiles): profile import and snapshot restore narrow archive file modes
hermes profile import extracts with each tar member's mode, so a 0666
config.yaml/.env landed world-writable. The staged tree now drops world
access on config.yaml and makes .env 0600 before publish; the PM runtime
stripping moves into the same helper (profiles.py size ratchet).
Quick-snapshot restore also tightens .env to 0600, as hermes import does.

Refs #59726
2026-11-13 17:48:43 -08:00
Maciej Lisiewski
740fd2f6ea fix(config): drop world access on config.yaml copies outside the writer
FileBackend.write_path only covers the round-trip writer. The xAI
migration (atomic_write_text preserve_mode), snapshot restore and
`hermes import` (copy2 / atomic extract keep the old mode), profile
clones and distribution installs (copy2 of the source) still published
a world-writable config.yaml as-is. Each now calls the shared
drop_other_access after its write. _restore_snapshot_entry moves to
backup_restore.py to keep backup.py under the size ratchet.

Fixes #59726
2026-11-13 17:48:43 -08:00
Teknium
d778246c84 fix(vault): a failed clone rolls back only the keychain entry it made
discard_copied_key inferred ownership by rereading the source's vault.keyref:
a staged copy whose account differed from (or had no) source pointer was taken
as the clone's own entry. If the source vault moved while the clone was still
copying (before custody), the staged pointer still named the SOURCE's entry,
the source path had no pointer, and the rollback deleted the source's only key.

own_copied_key now returns the exact entry it created; create_profile keeps it
and, on failure, deletes that entry and nothing else. A pointer-save failure
inside custody deletes the new entry even when the pointer landed, since the
staged clone is discarded with the error.

Review: Greptile on f9f9c0408c.
2026-10-25 05:45:51 -07:00
Teknium
d1a65f5e30 fix(vault): a keychain entry no pointer names is deleted, never left behind
Every keychain account is random, so an entry whose vault.keyref was never
saved is a key Hermes can neither find nor remove later (a retry mints another).
New entries made by key creation, migrate --to keychain and clone custody now go
through save_new_ref: if saving the pointer fails, the entry is deleted unless
the pointer did land. migrate --to keychain then reports that vault.key stays.

A --clone-all create that fails after the copy got its own entry (layout,
publish rename) deletes that entry while unwinding; it compares against the
source's pointer, so the source's entry is never touched. Clone custody also no
longer trusts a copied pointer that happens to name the clone's own path (a
renamed profile cloned back into its old name): a clone always gets a new entry.

Review: Greptile on b322737dfd.
2026-10-25 05:45:51 -07:00
Teknium
7cb0168ee6 fix(vault): a --clone-all copy owns its keychain entry before it is published
A clone copied vault.keyref, which names the SOURCE's keychain entry, and only
switched to an entry of its own on first open. If the source ran
`hermes vault key migrate --to file` before the clone was ever opened, the
source deleted its (sole-owner) entry and the clone could no longer find a key.

create_profile(clone_all=True) now gives the staged vault its own entry, owned
by the final profile path, before the publish rename. When the keychain cannot
be reached at that moment the clone is refused with a ValueError naming the way
out, instead of being published sharing the source's entry. A source whose own
entry is already gone is copied as-is (no worse off than the source). Lazy
adoption on first open stays for renames and clones made before this.

_clone_staging_dir moves to profiles_initialization (the staging-tree sibling)
to offset profiles.py's growth under the file-size ratchet.
2026-10-25 05:45:51 -07:00
unsupportedpastels
4ef87f4c4c fix(desktop): authorize native profile creation with a dedicated grant 2026-10-13 01:38:59 +00:00