Skip to content

fix: guard the paths that remove or overwrite - #58

Merged
grojof merged 1 commit into
mainfrom
fix/destructive-guards
Oct 8, 2026
Merged

grojof merged 1 commit into
mainfrom
fix/destructive-guards

Conversation

@grojof

@grojof grojof commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Second audit, group A: the paths that remove or overwrite. Each fix is checked by running it (tools/verify_data_safety.py).

  • Install over an existing instance removed it. A new instance now needs a free name: no system account or service, and nothing on the host under it. Ctrl+C at the confirmation runs nothing. A failure while applying previews the undo of only what that run made, and asks first.
  • Purge dropped other instances' databases and filestores on a shared data dir, and dropped a shared role. It now selects databases by owner or exact name, refuses superusers, drops databases before their files, and removes only the selected filestores from a shared data dir. The Linux user is removed only when the tool made it.
  • chown -R /var/log/odoo on every install. The directory is now root's, each instance owns its own log, and logrotate no longer uses su.
  • Delete instance checks the database owner and drops the database before removing the config. It reloads nginx only if it is installed, reads the legacy config location, and removes the logrotate policy.
  • Copies chown only what belongs to the target, move an existing filestore aside and copy into the target. A refresh asks for REPLACE <target>, and a replica's filestore goes to its configured data dir.
  • Backups: the backup directory must be dedicated, retention keeps the newest by name, and DB names read from file names are validated.

OpenSpec: 2026-10-08-guard-destructive-paths (7 specs).

Assisted-by: Claude

- Install: a new instance needs a free name (no system account or
  service, nothing on the host under it); Ctrl+C or cancel at the
  confirmation runs nothing; a failure while applying previews the undo
  of what that run made and asks first. A pre-existing data dir or role
  is kept.
- Purge: databases by owner or exact name only, superuser roles
  refused, databases dropped before their filestores, a shared data dir
  loses only the selected filestores, a role another instance uses is
  kept, the Linux user goes only when the tool made it, logrotate
  policy removed.
- /var/log/odoo is root's; each instance owns its log, earlier logs get
  their owner back, logrotate policies lose su.
- Delete: owner-checked dropdb before the config goes, data dir from
  both config locations, nginx reloaded only if installed, logrotate
  policy removed.
- Copies: scoped chown, existing target filestore moved aside, copy into
  the target after checking the source, REPLACE <target> for a refresh,
  the data dir of the config being built wins.
- Backups: dedicated directories only; retention by name; valid
  database names from file names.
@grojof
grojof merged commit 96bd556 into main Oct 8, 2026
1 check passed
@grojof
grojof deleted the fix/destructive-guards branch October 8, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant